Gathering detailed insights and metrics for int64-buffer
Gathering detailed insights and metrics for int64-buffer
Gathering detailed insights and metrics for int64-buffer
Gathering detailed insights and metrics for int64-buffer
64bit Long Integer on Buffer/ArrayBuffer in Pure JavaScript
npm install int64-buffer
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
78 Stars
117 Commits
9 Forks
4 Watching
3 Branches
4 Contributors
Updated on 05 Feb 2024
JavaScript (96.63%)
Makefile (1.83%)
HTML (1.53%)
Cumulative downloads
Total Downloads
Last day
-26.4%
500,187
Compared to previous day
Last week
1.2%
3,318,809
Compared to previous week
Last month
7.6%
13,680,381
Compared to previous month
Last year
217.5%
113,469,238
Compared to previous year
64bit Long Integer on Buffer/Array/ArrayBuffer in Pure JavaScript
JavaScript's number based on IEEE-754 could only handle 53 bits precision.
This module provides two pair of classes: Int64BE
/Uint64BE
and Int64LE
/Uint64LE
which could hold 64 bits long integer and loose no bit.
Int64BE
/Int64LE
for signed integer, Uint64BE
/Uint64LE
for unsigned.Int64BE
/Uint64BE
for big-endian, Int64LE
/Uint64LE
for little-endian.Buffer
/Uint8Array
/Array
/Array
-like storage of 8 bytes length with offset.add()
, sub()
, mul()
, div()
etc.Int64BE
is the class to host a 64 bit signed long integer int64_t
.
1const {Int64BE} = require("int64-buffer"); 2 3const big = new Int64BE(-1); 4 5console.log(big - 0); // -1 6 7console.log(big.toBuffer()); // <Buffer ff ff ff ff ff ff ff ff>
It uses Buffer
on Node.js and Uint8Array
on modern Web browsers.
Uint64BE
is the class to host a 64 bit unsigned positive long integer uint64_t
.
1const {Uint64BE} = require("int64-buffer"); 2 3const big = new Uint64BE(Math.pow(2, 63)); // a big number with 64 bits 4 5console.log(big - 0); // 9223372036854776000 = IEEE-754 loses last bits 6 7console.log(big + ""); // "9223372036854775808" = perfectly correct
Int64LE
and Uint64LE
work as same as above but with little-endian storage.
1const big = new Uint64BE(1234567890); 2console.log(big - 0); // 1234567890
1const big = new Uint64BE(0x12345678, 0x9abcdef0); 2console.log(big.toString(16)); // "123456789abcdef0"
1const big = new Uint64BE("123456789abcdef0", 16); 2console.log(big.toString(16)); // "123456789abcdef0"
1const buffer = Buffer.from([1,2,3,4,5,6,7,8]); 2const big = new Uint64BE(buffer); 3console.log(big.toString(16)); // "102030405060708"
1const uint8array = new Uint8Array([1,2,3,4,5,6,7,8]); 2const big = new Uint64BE(uint8array); 3console.log(big.toString(16)); // "102030405060708"
1const arraybuffer = (new Uint8Array([1,2,3,4,5,6,7,8])).buffer; 2const big = new Uint64BE(arraybuffer); 3console.log(big.toString(16)); // "102030405060708"
1const array = [1,2,3,4,5,6,7,8]; 2const big = new Uint64BE(array); 3console.log(big.toString(16)); // "102030405060708"
1const buffer = Buffer.from([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]); 2const big = new Uint64BE(buffer, 8); 3console.log(big.toString(16)); // "90a0b0c0d0e0f10"
1const buffer = Buffer.from(16);
2const big = new Uint64BE(buffer, 8, 0x1234567890);
3console.log(big.toString(16)); // "1234567890"
4console.log(buffer[15].toString(16)); // "90"
1const buffer = new Uint8Array(16); 2const big = new Uint64BE(buffer, 8, 0x12345678, 0x9abcdef0); 3console.log(big.toString(16)); // "123456789abcdef0" 4console.log(buffer[15].toString(16)); // "f0"
1const buffer = new Array(16); 2const big = new Uint64BE(buffer, 8, "123456789abcdef0", 16); 3console.log(big.toString(16)); // "123456789abcdef0" 4console.log(buffer[15].toString(16)); // "f0"
1const big = new Uint64BE(1234567890); 2console.log(big - 0); // 1234567890
1const big = new Uint64BE(1234567890);
2console.log(big.toNumber()); // 1234567890
1const big = new Uint64BE(0x1234567890); 2console.log(big.toString()); // "78187493520" 3console.log(big.toString(16)); // "1234567890"
1const big = new Uint64BE([1,2,3,4,5,6,7,8]); 2console.log(big.toBuffer()); // <Buffer 01 02 03 04 05 06 07 08>
1const big = new Uint64BE(0); 2const buf = new Int8Array(big.toArrayBuffer()); 3console.log(buf); // Int8Array { '0': 1, '1': 2, '2': 3, '3': 4, '4': 5, '5': 6, '6': 7, '7': 8 }
1const big = new Uint64BE([1,2,3,4,5,6,7,8]); 2console.log(big.toArray()); // [ 1, 2, 3, 4, 5, 6, 7, 8 ]
1<meta http-equiv="X-UA-Compatible" content="IE=edge"> 2<script src="https://cdn.jsdelivr.net/npm/int64-buffer/dist/int64-buffer.min.js"></script> 3<script> 4 5 const i = new Int64BE("1234567890123456789"); 6 console.log(i.toString(10)); // "1234567890123456789" 7 8 const u = new Uint64BE([0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF]); 9 console.log(u.toString(16)); // "123456789abcdef" 10 11</script>
Copyright (c) 2015-2021 Yusuke Kawasaki
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
Found 1/18 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More