1.0.1 • Published 11 months ago

nv-json-length v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
11 months ago

nv-json-length

  • get json's string-length AND buffer-size without stringify-it
  • its simple, just using a fixed length-lookup-array to increase the speed
  • slightly faster IF size < 1M; 30%~50% faster IF size >8M

install

  • npm install nv-json-length

splitted

usage

  const { 

        slen_aft_stringify,
        u8blen_aft_stringify     

  }   = require("nv-json-length");

example

small json 1-4k

		{
		  rounds: 1000000,
		  f: [Function: using_json_dot_stringify_dot_length],
		  costed: 6014.261669635773
		}
		{
		  rounds: 1000000,
		  f: [Function: using_slen_aft_stringify],
		  costed: 4571.413624763489
		}
		1606 1606
		{
		  rounds: 1000000,
		  f: [Function: using_buffer_from_json_dot_stringify_dot_length],
		  costed: 9921.201370716095
		}
		{
		  rounds: 1000000,
		  f: [Function: using_u8blen_aft_stringify],
		  costed: 4624.248408794403
		}

big json 16M

	15960001 15960001
	{
	  rounds: 100,
	  f: [Function: using_json_dot_stringify_dot_length],
	  costed: 7460.39946603775
	}
	{
	  rounds: 100,
	  f: [Function: using_slen_aft_stringify],
	  costed: 4608.779390335083
	}
	16010001 16010001
	{
	  rounds: 100,
	  f: [Function: using_buffer_from_json_dot_stringify_dot_length],
	  costed: 13716.670814037323
	}
	{
	  rounds: 100,
	  f: [Function: using_u8blen_aft_stringify],
	  costed: 4531.97597694397
	}

METHODS

APIS

	{
	  ndlen: [Function: ndlen],
	  AFT_JSTRINGIFY_SLEN_TBL: [
	    6, 6, 6, 6, 6, 6, 6, 6, 2, 2, 2, 6,
	    2, 2, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
	    6, 6, 6, 6, 6, 6, 6, 6, 1, 1, 2, 1,
	    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
	    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
	    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
	    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
	    1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1,
	    1, 1, 1, 1,
	    ... 65436 more items
	  ],
	  slen_aft_stringify_if_dtype_is_str: [Function: slen_aft_stringify_if_dtype_is_str],
	  slen_aft_stringify: [Function: slen_aft_stringify],
	  AFT_JSTRINGIFY_U8BLEN_TBL: [
	    6, 6, 6, 6, 6, 6, 6, 6, 2, 2, 2, 6,
	    2, 2, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
	    6, 6, 6, 6, 6, 6, 6, 6, 1, 1, 2, 1,
	    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
	    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
	    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
	    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
	    1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1,
	    1, 1, 1, 1,
	    ... 65436 more items
	  ],
	  u8blen_aft_stringify_if_dtype_is_str: [Function: u8blen_aft_stringify_if_dtype_is_str],
	  u8blen_aft_stringify: [Function: u8blen_aft_stringify]
	}

LICENSE

  • ISC