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-facutil-bufa

v1.0.3

Published

nv-facutil-bufa ======================= - a buffer support append |prepend | insert before index | insert after index | replace from index to index | remove from index to index | splice

Downloads

4

Readme

nv-facutil-bufa

  • a buffer support append |prepend | insert before index | insert after index | replace from index to index | remove from index to index | splice

install

  • npm install nv-facutil-bufa

splitted

usage

  const { creat, Buf }   = require("nv-facutil-bufa");

example

apend

  apend(ArrayBuffer|Uint8Array|Array<uint8_t>|Buf) -> ei

	var buf = creat(10)

	/*
	> buf
	Buf {
	  ei: 0,
	  u8a: Uint8Array(10) [
	    0, 0, 0, 0, 0,
	    0, 0, 0, 0, 0
	  ],
	  segsz: 10
	}
	> buf.apend([1,2,3,4,5])
	5
	> buf
	Buf {
	  ei: 5,
	  u8a: Uint8Array(10) [
	    1, 2, 3, 4, 5,
	    0, 0, 0, 0, 0
	  ],
	  segsz: 10
	}
	> buf.apend([1,2,3,4,5,6,7])
	12
	> buf
	Buf {
	  ei: 12,
	  u8a: Uint8Array(20) [
	    1, 2, 3, 4, 5, 1, 2,
	    3, 4, 5, 6, 7, 0, 0,
	    0, 0, 0, 0, 0, 0
	  ],
	  segsz: 10
	}
	> buf.cp_data()
	Uint8Array(12) [
	  1, 2, 3, 4, 5,
	  1, 2, 3, 4, 5,
	  6, 7
	]
	> 
	*/

ppend

  ppend(ArrayBuffer|Uint8Array|Array<uint8_t>|Buf) -> ei

	> buf.ppend([1,2,3,4,5])
	5
	> buf
	Buf {
	  ei: 5,
	  u8a: Uint8Array(10) [
	    1, 2, 3, 4, 5,
	    0, 0, 0, 0, 0
	  ],
	  segsz: 10
	}
	> buf.ppend([1,2,3,4,5,6])
	11
	> buf
	Buf {
	  ei: 11,
	  u8a: Uint8Array(20) [
	    1, 2, 3, 4, 5, 6, 1,
	    2, 3, 4, 5, 0, 0, 0,
	    0, 0, 0, 0, 0, 0
	  ],
	  segsz: 10
	}
	> buf.cp_data()
	Uint8Array(11) [
	  1, 2, 3, 4, 5,
	  6, 1, 2, 3, 4,
	  5
	]
	> 
	> buf.data_
	Uint8Array(11) [
	  1, 2, 3, 4, 5,
	  6, 1, 2, 3, 4,
	  5
	]
	> 

insert before

.insert_bfr(Index, ArrayBuffer|Uint8Array|Array<uint8_t>|Buf) -> ei

		var buf = creat(10)

		> buf.apend([0,1,2,3,4,5])
		6
		> buf
		Buf {
		  ei: 6,
		  u8a: Uint8Array(10) [
		    0, 1, 2, 3, 4,
		    5, 0, 0, 0, 0
		  ],
		  segsz: 10
		}
		> buf.insert_bfr(2,[11,22,33]) 
		9
		> buf 
		Buf {
		  ei: 9,
		  u8a: Uint8Array(10) [
		    0, 1, 11, 22, 33,
		    2, 3,  4,  5,  0
		  ],
		  segsz: 10
		}
		> buf.insert_bfr(2,[21,22,23,24,25,26,27,28])
		17
		> buf
		Buf {
		  ei: 17,
		  u8a: Uint8Array(20) [
		     0,  1, 21, 22, 23, 24, 25,
		    26, 27, 28, 11, 22, 33,  2,
		     3,  4,  5,  0,  0,  0
		  ],
		  segsz: 10
		}
		> buf.data_
		Uint8Array(17) [
		   0,  1, 21, 22, 23, 24, 25,
		  26, 27, 28, 11, 22, 33,  2,
		   3,  4,  5
		]
		> buf.cp_data()
		Uint8Array(17) [
		   0,  1, 21, 22, 23, 24, 25,
		  26, 27, 28, 11, 22, 33,  2,
		   3,  4,  5
		]
		> 

insert after

.insert_aft(Index, ArrayBuffer|Uint8Array|Array<uint8_t>|Buf) -> ei

same as  .insert_bfr(Index+1, ArrayBuffer|Uint8Array|Array<uint8_t>|Buf)

replace

.rplc_rng(si,ei, ArrayBuffer|Uint8Array|Array<uint8_t>|Buf) -> ei

//same as .splice(si, ei-si, ArrayBuffer|Uint8Array|Array<uint8_t>|Buf) 


	> var u8a = new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11])
	> var buf = creat(10) 
	> buf.apend(u8a)
	12
	> buf
	Buf {
	  ei: 12,
	  u8a: Uint8Array(20) [
	    0, 1, 2,  3,  4, 5, 6,
	    7, 8, 9, 10, 11, 0, 0,
	    0, 0, 0,  0,  0, 0
	  ],
	  segsz: 10
	}
	> buf.rplc_rng(3,9,[255,255,255])
	9
	> buf
	Buf {
	  ei: 9,
	  u8a: Uint8Array(20) [
	     0,  1, 2, 255, 255, 255, 9,
	    10, 11, 9,  10,  11,   0, 0,
	     0,  0, 0,   0,   0,   0
	  ],
	  segsz: 10
	}
	> buf.data_
	Uint8Array(9) [
	    0, 1,  2, 255, 255,
	  255, 9, 10,  11
	]
	> buf.cp_data()
	Uint8Array(9) [
	    0, 1,  2, 255, 255,
	  255, 9, 10,  11
	]
	> 

remove

.rm_rng(si,ei) -> ei;

	> var buf = creat(10)
	> 
	> buf.apend([0,1,2,3,4,5,6,7])
	8
	> buf
	Buf {
	  ei: 8,
	  u8a: Uint8Array(10) [
	    0, 1, 2, 3, 4,
	    5, 6, 7, 0, 0
	  ],
	  segsz: 10
	}
	> buf.rm_rng(2,4)
	6
	> buf
	Buf {
	  ei: 6,
	  u8a: Uint8Array(10) [
	    0, 1, 4, 5, 6,
	    7, 6, 7, 0, 0
	  ],
	  segsz: 10
	}
	> buf.data_
	Uint8Array(6) [ 0, 1, 4, 5, 6, 7 ]
	> 
	> buf.cp_data()
	Uint8Array(6) [ 0, 1, 4, 5, 6, 7 ]
	> 
	> 

splice

.splice(Index,remove_count, ArrayBuffer|Uint8Array|Array<uint8_t>|Buf) ->ei

	> var buf = creat(10) 
	> buf.apend([0,1,2,3,4,5,6,7,8,9,10,11])
	12
	> buf
	Buf {
	  ei: 12,
	  u8a: Uint8Array(20) [
	    0, 1, 2,  3,  4, 5, 6,
	    7, 8, 9, 10, 11, 0, 0,
	    0, 0, 0,  0,  0, 0
	  ],
	  segsz: 10
	}
	> buf.splice(2,3,[11,22,33,44])
	13
	> buf
	Buf {
	  ei: 13,
	  u8a: Uint8Array(20) [
	    0, 1, 11, 22, 33, 44, 5,
	    6, 7,  8,  9, 10, 11, 0,
	    0, 0,  0,  0,  0,  0
	  ],
	  segsz: 10
	}
	> buf.splice(2,0,[11,22,33,44])
	17
	> buf
	Buf {
	  ei: 17,
	  u8a: Uint8Array(20) [
	     0,  1, 11, 22, 33, 44, 11,
	    22, 33, 44,  5,  6,  7,  8,
	     9, 10, 11,  0,  0,  0
	  ],
	  segsz: 10
	}
	> buf.splice(2,4,[])
	13
	> buf
	Buf {
	  ei: 13,
	  u8a: Uint8Array(20) [
	    0,  1, 11, 22, 33, 44, 5,
	    6,  7,  8,  9, 10, 11, 8,
	    9, 10, 11,  0,  0,  0
	  ],
	  segsz: 10
	}
	> 

METHODS

 //methods:
     .apend(ArrayBuffer|Uint8Array|Array<uint8_t>|Buf)                      ->ei
     .ppend(ArrayBuffer|Uint8Array|Array<uint8_t>|Buf)                      ->ei 
     .insert_bfr(Index, ArrayBuffer|Uint8Array|Array<uint8_t>|Buf)          ->ei
     .insert_aft(Index, ArrayBuffer|Uint8Array|Array<uint8_t>|Buf)          ->ei
     .rplc_rng(si,ei, ArrayBuffer|Uint8Array|Array<uint8_t>|Buf)            ->ei
     .rm_rng(si,ei)                                                         ->ei
     .splice(Index,remove_count, ArrayBuffer|Uint8Array|Array<uint8_t>|Buf) ->ei

     .cp_data() -> Uint8Array
     .clone()   -> Buf

 //getters
     .data_                (subarray)
     .ei                   
     .segsz     

APIS

    creat(segment_size=10)->Buf

LICENSE

  • ISC