npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nd-str

v1.0.13

Published

nd-str ======================= - simple wrap of v8::String - same as Buffer.from buf.toString() - just for test small-string - expose v8::internal::String which can make a string mutable(just for test nvlang's StringRef feature)

Downloads

8

Readme

nd-str

  • simple wrap of v8::String
  • same as Buffer.from buf.toString()
  • just for test small-string
  • expose v8::internal::String which can make a string mutable(just for test nvlang's StringRef feature)

install

  • npm install nd-str

splitted

usage

  const x  = require("nd-str");

example

make string-literal mutable

 const {set_u16cd_at} =  x

 > const fixed_str = "A B C D E F";
 > fixed_str
 'A B C D E F'

 > set_u16cd_at(fixed_str,2,65)
 > fixed_str
 'A A C D E F'
 >

			const {
			  utf8ab_to_str_always_aloc_new_mem,
			  utf8ab_to_str_created_in_old_space,
			   utf16ab_to_str_always_aloc_new_mem,
			   utf16ab_to_str_created_in_old_space,
			   latin1ab_to_str_always_aloc_new_mem,
			   latin1ab_to_str_created_in_old_space,
			} = x;


			const {sync} = require("nv-facutil-simple-test");

			var   s = "aÿ我𝑒";
			const s2ab = (s,encd="utf8")=> {
			    let buf =Buffer.from(s,encd);
			    let ab = buf.buffer;
			    return(ab.slice(buf.offset,buf.offset+buf.length))
			}


			var utf8ab = s2ab("aÿ我𝑒","utf8");
			console.log(utf8ab_to_str_always_aloc_new_mem(utf8ab));
			console.log(sync(10000000,utf8ab_to_str_always_aloc_new_mem,utf8ab))
			var f1= (ab)=>Buffer.from(ab).toString("utf8");
			console.log(f1(utf8ab));
			console.log(sync(10000000,f1,utf8ab))

			var utf16ab = s2ab("aÿ我a我","ucs2");
			console.log(utf16ab_to_str_always_aloc_new_mem(utf16ab));
			var f2 = (ab)=>Buffer.from(ab).toString("ucs2");
			console.log(f2(utf16ab));
			console.log(sync(10000000,utf16ab_to_str_always_aloc_new_mem,utf16ab))
			console.log(sync(10000000,f2,utf16ab))


			var latin1ab = s2ab("aÿaÿbbbb","latin1");
			var f3 = (ab)=>Buffer.from(ab).toString("latin1");

			console.log(latin1ab_to_str_always_aloc_new_mem(latin1ab));
			console.log(f3(latin1ab));
			console.log(sync(10000000,latin1ab_to_str_always_aloc_new_mem,latin1ab))
			console.log(sync(10000000,f3,latin1ab))

                           /*

			aÿ我𝑒
			{
			  rounds: 10000000,
			  f: [Function: utf8ab_to_str_always_aloc_new_mem],
			  costed: 1659.392198085785
			}
			aÿ我𝑒
			{ rounds: 10000000, f: [Function: f1], costed: 2637.066288948059 }
			aÿ我a我
			aÿ我a我
			{
			  rounds: 10000000,
			  f: [Function: utf16ab_to_str_always_aloc_new_mem],
			  costed: 962.3775280714035
			}
			{ rounds: 10000000, f: [Function: f2], costed: 1963.8920789957047 }
			aÿaÿbbbb
			aÿaÿbbbb
			{
			  rounds: 10000000,
			  f: [Function: latin1ab_to_str_always_aloc_new_mem],
			  costed: 924.0457830429077
			}
			{ rounds: 10000000, f: [Function: f3], costed: 1893.5889741182327 }

                           */

str to array-buffer

with exist ab

> var ab = new ArrayBuffer(16)
> x.str_to_utf8ab("123",ab,5)

/*
ArrayBuffer {
  [Uint8Contents]: <00 00 00 00 00 31 32 33 00 00 00 00 00 00 00 00>,
  byteLength: 16
}

creat new ab

> x.str_to_utf8ab("123我")
ArrayBuffer { [Uint8Contents]: <31 32 33 e6 88 91>, byteLength: 6 }
>
*/

METHODS

       String.prototype.utf16_blen  
       String.prototype.utf8_blen

APIS

		{
		  kMaxLength: 268435440,
		  UNKNOWN_ENCODING: 1,
		  TWO_BYTE_ENCODING: 0,
		  ONE_BYTE_ENCODING: 8,
		  is_one_byte: [Function (anonymous)],
		  is_one_byte_or_unknown: [Function (anonymous)],
		  utf8_blen: [Function (anonymous)],
		  utf16_blen: [Function: utf16_blen],
		  is_extern: [Function (anonymous)],
		  is_one_byte_extern: [Function (anonymous)],
		  is_two_byte_extern: [Function (anonymous)],
		  can_make_one_byte_extern: [Function (anonymous)],
		  can_make_two_byte_extern: [Function (anonymous)],
		  utf8ab_to_str_always_aloc_new_mem: [Function: utf8ab_to_str_always_aloc_new_mem],
		  utf8ab_to_str_created_in_old_space: [Function: utf8ab_to_str_created_in_old_space],
		  utf16ab_to_str_always_aloc_new_mem: [Function: utf16ab_to_str_always_aloc_new_mem],
		  utf16ab_to_str_created_in_old_space: [Function: utf16ab_to_str_created_in_old_space],
		  latin1ab_to_str_always_aloc_new_mem: [Function: latin1ab_to_str_always_aloc_new_mem],
		  latin1ab_to_str_created_in_old_space: [Function: latin1ab_to_str_created_in_old_space],
		  NO_OPTIONS: 0,
		  HINT_MANY_WRITES_EXPECTED: 1,
		  NO_NULL_TERMINATION: 2,
		  PRESERVE_ONE_BYTE_NULL: 4,
		  REPLACE_INVALID_UTF8: 8,
		  str_to_utf8ab: [Function: str_to_utf8ab],
		  str_to_utf16ab: [Function: str_to_utf16ab],
		  str_to_latin1ab: [Function: str_to_latin1ab]
		}

LICENSE

  • ISC