Comparing version 0.9.4 to 0.9.5
@@ -0,5 +1,6 @@ | ||
export declare function longToNByteArray(N: number, long: number): Uint8Array; | ||
export declare function longTo8ByteArray(long: number): Uint8Array; | ||
export declare function shortTo2ByteArray(long: number): Uint8Array; | ||
export declare function longTo16ByteArray(long: number): number[]; | ||
export declare function shortTo2ByteArray(short: number): Uint8Array; | ||
export declare function longTo16ByteArray(long: number): Uint8Array; | ||
export declare function longTo32ByteArray(long: number): Uint8Array; | ||
export declare function byteArrayToLong(byteArray: Uint8Array): number; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.byteArrayToLong = exports.longTo32ByteArray = exports.longTo16ByteArray = exports.shortTo2ByteArray = exports.longTo8ByteArray = void 0; | ||
function longTo8ByteArray(long) { | ||
// we want to represent the input as a 8-bytes array | ||
const byteArray = [0, 0, 0, 0, 0, 0, 0, 0]; | ||
exports.byteArrayToLong = exports.longTo32ByteArray = exports.longTo16ByteArray = exports.shortTo2ByteArray = exports.longTo8ByteArray = exports.longToNByteArray = void 0; | ||
function longToNByteArray(N, long) { | ||
const byteArray = new Uint8Array(N); | ||
if (long < 0) | ||
throw new Error("Array is unsigned, cannot represent -ve numbers"); | ||
if (long > Math.pow(2, (N * 8)) - 1) | ||
throw new Error(`Number ${long} is too large for an array of ${N} bytes`); | ||
for (let index = 0; index < byteArray.length; index++) { | ||
@@ -12,38 +15,19 @@ const byte = long & 0xff; | ||
} | ||
return Uint8Array.from(byteArray); | ||
return byteArray; | ||
} | ||
exports.longToNByteArray = longToNByteArray; | ||
function longTo8ByteArray(long) { | ||
return longToNByteArray(8, long); | ||
} | ||
exports.longTo8ByteArray = longTo8ByteArray; | ||
function shortTo2ByteArray(long) { | ||
if (long > (2 ^ (32 - 1))) | ||
throw new Error("Short too long"); | ||
// we want to represent the input as a 8-bytes array | ||
const byteArray = [0, 0]; | ||
for (let index = 0; index < byteArray.length; index++) { | ||
const byte = long & 0xff; | ||
byteArray[index] = byte; | ||
long = (long - byte) / 256; | ||
} | ||
return Uint8Array.from(byteArray); | ||
function shortTo2ByteArray(short) { | ||
return longToNByteArray(2, short); | ||
} | ||
exports.shortTo2ByteArray = shortTo2ByteArray; | ||
function longTo16ByteArray(long) { | ||
// we want to represent the input as a 8-bytes array | ||
const byteArray = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; | ||
for (let index = 0; index < byteArray.length; index++) { | ||
const byte = long & 0xff; | ||
byteArray[index] = byte; | ||
long = (long - byte) / 256; | ||
} | ||
return byteArray; | ||
return longToNByteArray(16, long); | ||
} | ||
exports.longTo16ByteArray = longTo16ByteArray; | ||
function longTo32ByteArray(long) { | ||
// we want to represent the input as a 8-bytes array | ||
const byteArray = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; | ||
for (let index = 0; index < byteArray.length; index++) { | ||
const byte = long & 0xff; | ||
byteArray[index] = byte; | ||
long = (long - byte) / 256; | ||
} | ||
return Uint8Array.from(byteArray); | ||
return longToNByteArray(32, long); | ||
} | ||
@@ -50,0 +34,0 @@ exports.longTo32ByteArray = longTo32ByteArray; |
@@ -46,5 +46,6 @@ /// <reference types="node" /> | ||
AVSCTap: typeof arbundlesSrc.AVSCTap; | ||
longToNByteArray(N: number, long: number): Uint8Array; | ||
longTo8ByteArray(long: number): Uint8Array; | ||
shortTo2ByteArray(long: number): Uint8Array; | ||
longTo16ByteArray(long: number): number[]; | ||
shortTo2ByteArray(short: number): Uint8Array; | ||
longTo16ByteArray(long: number): Uint8Array; | ||
longTo32ByteArray(long: number): Uint8Array; | ||
@@ -103,5 +104,6 @@ byteArrayToLong(byteArray: Uint8Array): number; | ||
AVSCTap: typeof arbundlesSrc.AVSCTap; | ||
longToNByteArray(N: number, long: number): Uint8Array; | ||
longTo8ByteArray(long: number): Uint8Array; | ||
shortTo2ByteArray(long: number): Uint8Array; | ||
longTo16ByteArray(long: number): number[]; | ||
shortTo2ByteArray(short: number): Uint8Array; | ||
longTo16ByteArray(long: number): Uint8Array; | ||
longTo32ByteArray(long: number): Uint8Array; | ||
@@ -108,0 +110,0 @@ byteArrayToLong(byteArray: Uint8Array): number; |
@@ -0,5 +1,6 @@ | ||
export declare function longToNByteArray(N: number, long: number): Uint8Array; | ||
export declare function longTo8ByteArray(long: number): Uint8Array; | ||
export declare function shortTo2ByteArray(long: number): Uint8Array; | ||
export declare function longTo16ByteArray(long: number): number[]; | ||
export declare function shortTo2ByteArray(short: number): Uint8Array; | ||
export declare function longTo16ByteArray(long: number): Uint8Array; | ||
export declare function longTo32ByteArray(long: number): Uint8Array; | ||
export declare function byteArrayToLong(byteArray: Uint8Array): number; |
@@ -1,4 +0,7 @@ | ||
export function longTo8ByteArray(long) { | ||
// we want to represent the input as a 8-bytes array | ||
const byteArray = [0, 0, 0, 0, 0, 0, 0, 0]; | ||
export function longToNByteArray(N, long) { | ||
const byteArray = new Uint8Array(N); | ||
if (long < 0) | ||
throw new Error("Array is unsigned, cannot represent -ve numbers"); | ||
if (long > 2 ** (N * 8) - 1) | ||
throw new Error(`Number ${long} is too large for an array of ${N} bytes`); | ||
for (let index = 0; index < byteArray.length; index++) { | ||
@@ -9,35 +12,15 @@ const byte = long & 0xff; | ||
} | ||
return Uint8Array.from(byteArray); | ||
return byteArray; | ||
} | ||
export function shortTo2ByteArray(long) { | ||
if (long > (2 ^ (32 - 1))) | ||
throw new Error("Short too long"); | ||
// we want to represent the input as a 8-bytes array | ||
const byteArray = [0, 0]; | ||
for (let index = 0; index < byteArray.length; index++) { | ||
const byte = long & 0xff; | ||
byteArray[index] = byte; | ||
long = (long - byte) / 256; | ||
} | ||
return Uint8Array.from(byteArray); | ||
export function longTo8ByteArray(long) { | ||
return longToNByteArray(8, long); | ||
} | ||
export function shortTo2ByteArray(short) { | ||
return longToNByteArray(2, short); | ||
} | ||
export function longTo16ByteArray(long) { | ||
// we want to represent the input as a 8-bytes array | ||
const byteArray = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; | ||
for (let index = 0; index < byteArray.length; index++) { | ||
const byte = long & 0xff; | ||
byteArray[index] = byte; | ||
long = (long - byte) / 256; | ||
} | ||
return byteArray; | ||
return longToNByteArray(16, long); | ||
} | ||
export function longTo32ByteArray(long) { | ||
// we want to represent the input as a 8-bytes array | ||
const byteArray = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; | ||
for (let index = 0; index < byteArray.length; index++) { | ||
const byte = long & 0xff; | ||
byteArray[index] = byte; | ||
long = (long - byte) / 256; | ||
} | ||
return Uint8Array.from(byteArray); | ||
return longToNByteArray(32, long); | ||
} | ||
@@ -44,0 +27,0 @@ export function byteArrayToLong(byteArray) { |
@@ -46,5 +46,6 @@ /// <reference types="node" /> | ||
AVSCTap: typeof arbundlesSrc.AVSCTap; | ||
longToNByteArray(N: number, long: number): Uint8Array; | ||
longTo8ByteArray(long: number): Uint8Array; | ||
shortTo2ByteArray(long: number): Uint8Array; | ||
longTo16ByteArray(long: number): number[]; | ||
shortTo2ByteArray(short: number): Uint8Array; | ||
longTo16ByteArray(long: number): Uint8Array; | ||
longTo32ByteArray(long: number): Uint8Array; | ||
@@ -103,5 +104,6 @@ byteArrayToLong(byteArray: Uint8Array): number; | ||
AVSCTap: typeof arbundlesSrc.AVSCTap; | ||
longToNByteArray(N: number, long: number): Uint8Array; | ||
longTo8ByteArray(long: number): Uint8Array; | ||
shortTo2ByteArray(long: number): Uint8Array; | ||
longTo16ByteArray(long: number): number[]; | ||
shortTo2ByteArray(short: number): Uint8Array; | ||
longTo16ByteArray(long: number): Uint8Array; | ||
longTo32ByteArray(long: number): Uint8Array; | ||
@@ -108,0 +110,0 @@ byteArrayToLong(byteArray: Uint8Array): number; |
@@ -0,5 +1,6 @@ | ||
export declare function longToNByteArray(N: number, long: number): Uint8Array; | ||
export declare function longTo8ByteArray(long: number): Uint8Array; | ||
export declare function shortTo2ByteArray(long: number): Uint8Array; | ||
export declare function longTo16ByteArray(long: number): number[]; | ||
export declare function shortTo2ByteArray(short: number): Uint8Array; | ||
export declare function longTo16ByteArray(long: number): Uint8Array; | ||
export declare function longTo32ByteArray(long: number): Uint8Array; | ||
export declare function byteArrayToLong(byteArray: Uint8Array): number; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.byteArrayToLong = exports.longTo32ByteArray = exports.longTo16ByteArray = exports.shortTo2ByteArray = exports.longTo8ByteArray = void 0; | ||
function longTo8ByteArray(long) { | ||
// we want to represent the input as a 8-bytes array | ||
const byteArray = [0, 0, 0, 0, 0, 0, 0, 0]; | ||
exports.byteArrayToLong = exports.longTo32ByteArray = exports.longTo16ByteArray = exports.shortTo2ByteArray = exports.longTo8ByteArray = exports.longToNByteArray = void 0; | ||
function longToNByteArray(N, long) { | ||
const byteArray = new Uint8Array(N); | ||
if (long < 0) | ||
throw new Error("Array is unsigned, cannot represent -ve numbers"); | ||
if (long > Math.pow(2, (N * 8)) - 1) | ||
throw new Error(`Number ${long} is too large for an array of ${N} bytes`); | ||
for (let index = 0; index < byteArray.length; index++) { | ||
@@ -12,38 +15,19 @@ const byte = long & 0xff; | ||
} | ||
return Uint8Array.from(byteArray); | ||
return byteArray; | ||
} | ||
exports.longToNByteArray = longToNByteArray; | ||
function longTo8ByteArray(long) { | ||
return longToNByteArray(8, long); | ||
} | ||
exports.longTo8ByteArray = longTo8ByteArray; | ||
function shortTo2ByteArray(long) { | ||
if (long > (2 ^ (32 - 1))) | ||
throw new Error("Short too long"); | ||
// we want to represent the input as a 8-bytes array | ||
const byteArray = [0, 0]; | ||
for (let index = 0; index < byteArray.length; index++) { | ||
const byte = long & 0xff; | ||
byteArray[index] = byte; | ||
long = (long - byte) / 256; | ||
} | ||
return Uint8Array.from(byteArray); | ||
function shortTo2ByteArray(short) { | ||
return longToNByteArray(2, short); | ||
} | ||
exports.shortTo2ByteArray = shortTo2ByteArray; | ||
function longTo16ByteArray(long) { | ||
// we want to represent the input as a 8-bytes array | ||
const byteArray = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; | ||
for (let index = 0; index < byteArray.length; index++) { | ||
const byte = long & 0xff; | ||
byteArray[index] = byte; | ||
long = (long - byte) / 256; | ||
} | ||
return byteArray; | ||
return longToNByteArray(16, long); | ||
} | ||
exports.longTo16ByteArray = longTo16ByteArray; | ||
function longTo32ByteArray(long) { | ||
// we want to represent the input as a 8-bytes array | ||
const byteArray = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; | ||
for (let index = 0; index < byteArray.length; index++) { | ||
const byte = long & 0xff; | ||
byteArray[index] = byte; | ||
long = (long - byte) / 256; | ||
} | ||
return Uint8Array.from(byteArray); | ||
return longToNByteArray(32, long); | ||
} | ||
@@ -50,0 +34,0 @@ exports.longTo32ByteArray = longTo32ByteArray; |
@@ -46,5 +46,6 @@ /// <reference types="node" /> | ||
AVSCTap: typeof arbundlesSrc.AVSCTap; | ||
longToNByteArray(N: number, long: number): Uint8Array; | ||
longTo8ByteArray(long: number): Uint8Array; | ||
shortTo2ByteArray(long: number): Uint8Array; | ||
longTo16ByteArray(long: number): number[]; | ||
shortTo2ByteArray(short: number): Uint8Array; | ||
longTo16ByteArray(long: number): Uint8Array; | ||
longTo32ByteArray(long: number): Uint8Array; | ||
@@ -103,5 +104,6 @@ byteArrayToLong(byteArray: Uint8Array): number; | ||
AVSCTap: typeof arbundlesSrc.AVSCTap; | ||
longToNByteArray(N: number, long: number): Uint8Array; | ||
longTo8ByteArray(long: number): Uint8Array; | ||
shortTo2ByteArray(long: number): Uint8Array; | ||
longTo16ByteArray(long: number): number[]; | ||
shortTo2ByteArray(short: number): Uint8Array; | ||
longTo16ByteArray(long: number): Uint8Array; | ||
longTo32ByteArray(long: number): Uint8Array; | ||
@@ -108,0 +110,0 @@ byteArrayToLong(byteArray: Uint8Array): number; |
@@ -0,5 +1,6 @@ | ||
export declare function longToNByteArray(N: number, long: number): Uint8Array; | ||
export declare function longTo8ByteArray(long: number): Uint8Array; | ||
export declare function shortTo2ByteArray(long: number): Uint8Array; | ||
export declare function longTo16ByteArray(long: number): number[]; | ||
export declare function shortTo2ByteArray(short: number): Uint8Array; | ||
export declare function longTo16ByteArray(long: number): Uint8Array; | ||
export declare function longTo32ByteArray(long: number): Uint8Array; | ||
export declare function byteArrayToLong(byteArray: Uint8Array): number; |
@@ -1,4 +0,7 @@ | ||
export function longTo8ByteArray(long) { | ||
// we want to represent the input as a 8-bytes array | ||
const byteArray = [0, 0, 0, 0, 0, 0, 0, 0]; | ||
export function longToNByteArray(N, long) { | ||
const byteArray = new Uint8Array(N); | ||
if (long < 0) | ||
throw new Error("Array is unsigned, cannot represent -ve numbers"); | ||
if (long > 2 ** (N * 8) - 1) | ||
throw new Error(`Number ${long} is too large for an array of ${N} bytes`); | ||
for (let index = 0; index < byteArray.length; index++) { | ||
@@ -9,35 +12,15 @@ const byte = long & 0xff; | ||
} | ||
return Uint8Array.from(byteArray); | ||
return byteArray; | ||
} | ||
export function shortTo2ByteArray(long) { | ||
if (long > (2 ^ (32 - 1))) | ||
throw new Error("Short too long"); | ||
// we want to represent the input as a 8-bytes array | ||
const byteArray = [0, 0]; | ||
for (let index = 0; index < byteArray.length; index++) { | ||
const byte = long & 0xff; | ||
byteArray[index] = byte; | ||
long = (long - byte) / 256; | ||
} | ||
return Uint8Array.from(byteArray); | ||
export function longTo8ByteArray(long) { | ||
return longToNByteArray(8, long); | ||
} | ||
export function shortTo2ByteArray(short) { | ||
return longToNByteArray(2, short); | ||
} | ||
export function longTo16ByteArray(long) { | ||
// we want to represent the input as a 8-bytes array | ||
const byteArray = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; | ||
for (let index = 0; index < byteArray.length; index++) { | ||
const byte = long & 0xff; | ||
byteArray[index] = byte; | ||
long = (long - byte) / 256; | ||
} | ||
return byteArray; | ||
return longToNByteArray(16, long); | ||
} | ||
export function longTo32ByteArray(long) { | ||
// we want to represent the input as a 8-bytes array | ||
const byteArray = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; | ||
for (let index = 0; index < byteArray.length; index++) { | ||
const byte = long & 0xff; | ||
byteArray[index] = byte; | ||
long = (long - byte) / 256; | ||
} | ||
return Uint8Array.from(byteArray); | ||
return longToNByteArray(32, long); | ||
} | ||
@@ -44,0 +27,0 @@ export function byteArrayToLong(byteArray) { |
@@ -46,5 +46,6 @@ /// <reference types="node" /> | ||
AVSCTap: typeof arbundlesSrc.AVSCTap; | ||
longToNByteArray(N: number, long: number): Uint8Array; | ||
longTo8ByteArray(long: number): Uint8Array; | ||
shortTo2ByteArray(long: number): Uint8Array; | ||
longTo16ByteArray(long: number): number[]; | ||
shortTo2ByteArray(short: number): Uint8Array; | ||
longTo16ByteArray(long: number): Uint8Array; | ||
longTo32ByteArray(long: number): Uint8Array; | ||
@@ -102,5 +103,6 @@ byteArrayToLong(byteArray: Uint8Array): number; | ||
AVSCTap: typeof arbundlesSrc.AVSCTap; | ||
longToNByteArray(N: number, long: number): Uint8Array; | ||
longTo8ByteArray(long: number): Uint8Array; | ||
shortTo2ByteArray(long: number): Uint8Array; | ||
longTo16ByteArray(long: number): number[]; | ||
shortTo2ByteArray(short: number): Uint8Array; | ||
longTo16ByteArray(long: number): Uint8Array; | ||
longTo32ByteArray(long: number): Uint8Array; | ||
@@ -107,0 +109,0 @@ byteArrayToLong(byteArray: Uint8Array): number; |
{ | ||
"name": "arbundles", | ||
"version": "0.9.4", | ||
"version": "0.9.5", | ||
"description": "Arweave bundling library", | ||
@@ -5,0 +5,0 @@ "author": "Josh Benaron <joshbenaron@gmail.com>", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25
4441882
607
17693