@xyo-network/buffer-utils
Advanced tools
Comparing version 0.26.0 to 0.31.0
@@ -8,12 +8,9 @@ "use strict"; | ||
* @Last modified by: ryanxyo | ||
* @Last modified time: Tuesday, 11th December 2018 9:14:17 am | ||
* @Last modified time: Wednesday, 6th March 2019 4:42:51 pm | ||
* @License: All Rights Reserved | ||
* @Copyright: Copyright XY | The Findables Company | ||
*/ | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const errors_1 = require("@xyo-network/errors"); | ||
const bn_js_1 = __importDefault(require("bn.js")); | ||
const utils_1 = require("@xyo-network/utils"); | ||
/** A helper function to write a number to a buffer that supports multiple sizes and signings */ | ||
@@ -35,3 +32,3 @@ function writeIntegerToBuffer(numberToWrite, bytes, isSigned, buffer, offset) { | ||
default: | ||
throw new errors_1.XyoError(`Could not write number to buffer`, errors_1.XyoErrors.CRITICAL); | ||
throw new errors_1.XyoError(`Could not write number to buffer`); | ||
} | ||
@@ -50,6 +47,6 @@ } | ||
case 8: | ||
const bigNumberBuffer = new bn_js_1.default(numberToWrite).toBuffer('be', 8); | ||
const bnBuffer = new utils_1.BN(numberToWrite).toBuffer('be', 8); | ||
let i = 0; | ||
while (i < 8) { | ||
buf[i + bufOffset] = bigNumberBuffer[i]; | ||
buf[i + bufOffset] = bnBuffer[i]; | ||
i += 1; | ||
@@ -59,3 +56,3 @@ } | ||
default: | ||
throw new errors_1.XyoError(`Could not write number to buffer`, errors_1.XyoErrors.CRITICAL); | ||
throw new errors_1.XyoError(`Could not write number to buffer`); | ||
} | ||
@@ -76,3 +73,3 @@ } | ||
default: | ||
throw new errors_1.XyoError(`Could not read number from buffer`, errors_1.XyoErrors.CRITICAL); | ||
throw new errors_1.XyoError(`Could not read number from buffer`); | ||
} | ||
@@ -88,5 +85,5 @@ } | ||
case 8: | ||
return new bn_js_1.default(buffer.slice(bufOffset || 0, bufOffset + bytes)).toNumber(); | ||
return new utils_1.BN(buffer.slice(bufOffset || 0, bufOffset + bytes)).toNumber(); | ||
default: | ||
throw new errors_1.XyoError(`Could not read number from buffer`, errors_1.XyoErrors.CRITICAL); | ||
throw new errors_1.XyoError(`Could not read number from buffer`); | ||
} | ||
@@ -124,6 +121,6 @@ } | ||
else if (num > Math.pow(2, 32)) { | ||
buf = new bn_js_1.default(num).toBuffer('be'); | ||
buf = new utils_1.BN(num).toBuffer('be'); | ||
} | ||
else { | ||
throw new errors_1.XyoError('This should never happen', errors_1.XyoErrors.CRITICAL); | ||
throw new errors_1.XyoError('This should never happen'); | ||
} | ||
@@ -148,6 +145,6 @@ return buf; | ||
else if (num > Math.pow(2, 31)) { | ||
throw new errors_1.XyoError('This is not yet supported', errors_1.XyoErrors.CRITICAL); | ||
throw new errors_1.XyoError('This is not yet supported'); | ||
} | ||
else { | ||
throw new errors_1.XyoError('This should never happen', errors_1.XyoErrors.CRITICAL); | ||
throw new errors_1.XyoError('This should never happen'); | ||
} | ||
@@ -154,0 +151,0 @@ return buf; |
{ | ||
"name": "@xyo-network/buffer-utils", | ||
"version": "0.26.0", | ||
"version": "0.31.0", | ||
"description": "Utilities for dealing with buffers in the XYO network", | ||
@@ -10,7 +10,7 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@xyo-network/errors": "^0.26.0", | ||
"@xyo-network/errors": "^0.31.0", | ||
"@xyo-network/utils": "^0.31.0", | ||
"bn.js": "^4.11.8" | ||
}, | ||
"devDependencies": { | ||
"@types/bn.js": "^4.11.2", | ||
"@types/jest": "^23.3.1", | ||
@@ -24,3 +24,3 @@ "@types/node": "^10.7.1", | ||
}, | ||
"gitHead": "b86b8078d87e72f0a132bc5e1d6c87aa29e00b7b" | ||
"gitHead": "19f9752b9915e96430496a0adf86e5dc79c08ded" | ||
} |
@@ -7,3 +7,3 @@ /* | ||
* @Last modified by: ryanxyo | ||
* @Last modified time: Tuesday, 11th December 2018 9:14:17 am | ||
* @Last modified time: Wednesday, 6th March 2019 4:42:51 pm | ||
* @License: All Rights Reserved | ||
@@ -14,3 +14,3 @@ * @Copyright: Copyright XY | The Findables Company | ||
import { XyoError, XyoErrors } from "@xyo-network/errors" | ||
import BN from 'bn.js' | ||
import { BN } from "@xyo-network/utils" | ||
@@ -40,3 +40,3 @@ /** A helper function to write a number to a buffer that supports multiple sizes and signings */ | ||
default: | ||
throw new XyoError(`Could not write number to buffer`, XyoErrors.CRITICAL) | ||
throw new XyoError(`Could not write number to buffer`) | ||
} | ||
@@ -56,6 +56,6 @@ } | ||
case 8: | ||
const bigNumberBuffer = new BN(numberToWrite).toBuffer('be', 8) | ||
const bnBuffer = new BN(numberToWrite).toBuffer('be', 8) | ||
let i = 0 | ||
while (i < 8) { | ||
buf[i + bufOffset] = bigNumberBuffer[i] | ||
buf[i + bufOffset] = bnBuffer[i] | ||
i += 1 | ||
@@ -65,3 +65,3 @@ } | ||
default: | ||
throw new XyoError(`Could not write number to buffer`, XyoErrors.CRITICAL) | ||
throw new XyoError(`Could not write number to buffer`) | ||
} | ||
@@ -83,3 +83,3 @@ } | ||
default: | ||
throw new XyoError(`Could not read number from buffer`, XyoErrors.CRITICAL) | ||
throw new XyoError(`Could not read number from buffer`) | ||
} | ||
@@ -98,3 +98,3 @@ } | ||
default: | ||
throw new XyoError(`Could not read number from buffer`, XyoErrors.CRITICAL) | ||
throw new XyoError(`Could not read number from buffer`) | ||
} | ||
@@ -134,3 +134,3 @@ } | ||
} else { | ||
throw new XyoError('This should never happen', XyoErrors.CRITICAL) | ||
throw new XyoError('This should never happen') | ||
} | ||
@@ -154,5 +154,5 @@ | ||
} else if (num > Math.pow(2, 31)) { | ||
throw new XyoError('This is not yet supported', XyoErrors.CRITICAL) | ||
throw new XyoError('This is not yet supported') | ||
} else { | ||
throw new XyoError('This should never happen', XyoErrors.CRITICAL) | ||
throw new XyoError('This should never happen') | ||
} | ||
@@ -159,0 +159,0 @@ |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
7
0
17773
3
355
+ Added@xyo-network/utils@^0.31.0
+ Added@xyo-network/base@0.31.0(transitive)
+ Added@xyo-network/errors@0.31.0(transitive)
+ Added@xyo-network/meta-list@0.31.0(transitive)
+ Added@xyo-network/utils@0.31.0(transitive)
+ Addedbase-x@3.0.10(transitive)
+ Addedbs58@4.0.1(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
- Removed@xyo-network/base@0.26.0(transitive)
- Removed@xyo-network/errors@0.26.0(transitive)
Updated@xyo-network/errors@^0.31.0