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

nv-buf-jstr-pool

v1.0.1

Published

nv-buf-jstr-pool ======================= - a utf-16 buffer - for test string transfer in nvlang. normally USELESS. - nvlang NOT support full-utf-16 AND utf-8; ONLY support ascii | latin-1 | utf-32 | partly support utf16(without surrogate) | and-speci

Downloads

5

Readme

nv-buf-jstr-pool

  • a utf-16 buffer
  • for test string transfer in nvlang. normally USELESS.
  • nvlang NOT support full-utf-16 AND utf-8; ONLY support ascii | latin-1 | utf-32 | partly support utf16(without surrogate) | and-special-format-1byte-str: /<ascii + 256-chinese-character/>

install

  • npm install nv-buf-jstr-pool

splitted

usage

  const { creat }   = require("nv-buf-jstr-pool");

example

creat

      creat(ab:ArrayBuffer, from_offset_at_ab:Uint, byte_length:Uint, is_le=true ) : Spool


			var ab = new ArrayBuffer(1024*1024*8);

			var s1 = "abcd"
			var s2 = "ÿ我𝑒"
			var s3 = "\b\t\n\f\r"
			var s4= "\x00\x01\x02\x03\x04\x05\x06\x07\b\t\n\x0B\f\r\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F"

			var spool = creat(ab,1024*1024*4, 4096)

add new

    Spool'add(s:String): Uint 

			var id1 = spool.add(s1);
			var id2 = spool.add(s2);
			var id3 = spool.add(s3);
			var id4 = spool.add(s4);

	/*
	  1,2,3,4    id is always from 1, for compatible with nvlang, 0 is used as none .
	*/

		/*
		> spool.buf_str_cnt_
		4
		> spool.buf_ch16_cnt_
		45
		> spool.buf_byte_cnt_
		90
		> 
		*/

get

   Spool'get(id:Uint): String

	/* ---- slow  will be copied

	> spool.get(1)
	'abcd'
	> spool.get(2)
	'ÿ我𝑒'
	> spool.get(3)
	'\b\t\n\f\r'
	> spool.get(4)
	'\x00\x01\x02\x03\x04\x05\x06\x07\b\t\n\x0B\f\r\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F'
	> 
	> 
	> 
	*/

set

  Spool'set(id:Uint, s:String): [Boolean,<string-reason-if-failed>| <null-if-success>]
       IF    utf16-byte-length OF the new s:String  IS <=  the-max-permiter-size(which decided by add operation) : success
       ELSE                                                                                                      :  failed


	/*  slow   u16-by-u16 to write to buf

	> spool.get_curr_sz(1)
	8
	> 

	> spool.set(1,"xyz")
	[ true, 1 ]
	> 
	> spool.get(1)               // 2*3 <=8 IF size <= the original("abcd")  can update
	'xyz'
	> 

	> spool.get_curr_sz(1)
	6
	> 

	> spool.get_max_sz(1)
	8
	> 

	spool.set(1,"vwxyz")       //   cant,  2*5 > 8 
	[ false, 'orig_str_length_not_enough' ]
	> 

	spool.set(1,"abcd")

	*/

ser

        Spool'ser(id:Uint) : Uint8Array

			/* --- fast  just read not copy
			> spool.ser(2)
			Uint8Array(8) [
			  255,   0, 17,  98,
			   53, 216, 82, 220
			]
			> 

			> (new TextDecoder("utf-16")).decode(spool.ser(2))
			'ÿ我𝑒'
			> 

			*/

others

			/*  "ÿ我𝑒"     \u00ff\u6211   "\ud835\udc52"

			> spool.get_byte_cnt(2)    // same as   .length *2
			8
			> spool.get_ch16_cnt(2)    // same as  .length
			4
			> spool.get_char_cnt(2)    // same as  Array.from(s).length
			3
			> 

			> spool.get_char_codes(2)
			[ 255, 25105, 55349, 56402 ]
			> 
			> for(let i=0;i<"ÿ我𝑒".length;++i) {console.log("ÿ我𝑒".charCodeAt(i))}
			255
			25105
			55349
			56402

			> spool.get_code_points(2)
			[ 255, 25105, 119890 ]
			> 

			> for(let ch of "ÿ我𝑒") {console.log(ch.codePointAt(0))}
			255
			25105
			119890

			*/

METHODS

	spool.add                   spool.back_store_ei_        spool.back_store_si_        spool.buf_byte_cnt_         spool.buf_ch16_cnt_         spool.buf_str_cnt_          spool.capacity_             
	spool.cursor_               spool.get                   spool.get_byte_cnt          spool.get_ch16_cnt          spool.get_char_cnt          spool.get_char_codes        spool.get_code_points       spool.get_curr_sz
	spool.get_max_sz            spool.is_le                 spool.meta_                 spool.ser                   spool.set

APIS

  • creat(ab:ArrayBuffer, from_offset_at_ab:Uint, byte_length:Uint, is_le=true ) : Spool

LICENSE

  • ISC