🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

nd-com-int

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nd-com-int

nd-com-int ======================= - simple wrap of https://github.com/lemire/streamvbyte - nv-lang USE https://github.com/lemire/streamvbyte FOR a i-ast compress

latest
npmnpm
Version
1.0.2
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

nd-com-int

  • simple wrap of https://github.com/lemire/streamvbyte
  • nv-lang USE https://github.com/lemire/streamvbyte FOR a i-ast compress

install

  • npm install nd-com-int

usage

  const {_encd,_decd,encd,decd}   = require("nd-com-int");

example

            var arr = Array.from({length:1000000}).map((r,i)=>i);
            var u32a = new Uint32Array(arr);

            > u32a.buffer.byteLength
            4000000
            > 

            var encded = encd(arr);
            /*
            > encded
            {
              cnt: 1000000,
              ab: ArrayBuffer {
                [Uint8Contents]: <00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 ... 3184108 more bytes>,
                byteLength: 3184208
              }
            }
            > 
            */
            > encded.ab.byteLength / u32a.buffer.byteLength
            0.796052
            > 


            > var decded = decd(encded)
            > decded
            Uint32Array(1000000) [
               0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
              12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
              24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
              36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
              48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
              60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71,
              72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
              84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
              96, 97, 98, 99,
              ... 999900 more items
            ]

METHODS

APIS

                    export interface Encoded {
                        cnt: number;                  //size_t  int-count
                        ei?: number;                  //size_t  used IN encd(o,minimize_if_not_support_resize=true)  only WHEN ArrayBuffer.prototype.resize NOT-EXIST and minimize_if_not_support_resize = false
                        ab: ArrayBuffer;
                    }

                    type Ablike =  ArrayBuffer | Array<number> | TypedArray;        // number must be ui32


                    export function _encd(cnt:number,ab:ArrayBuffer): [number,number,ArrayBuffer];         // [cnt,encoded-byte-size,to-be-encoded-array-buffer]
                    export function _decd(cnt:number,ab:ArrayBuffer): [number,number,ArrayBuffer];         // [cnt,decoded-byte-size,decoded-array-buffer]

                    export function encd(o:Ablike,minimize_if_not_support_resize:Boolean=true):Encoded;
                    export function decd(encded:Encoded): Uint32Array;

LICENSE

  • ISC

FAQs

Package last updated on 12 May 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts