biggystring
Advanced tools
Comparing version 1.0.5 to 1.0.6
@@ -118,2 +118,34 @@ /** | ||
function min(x, y, base = 10) { | ||
const xBase = isHex(x) ? 16 : 10; | ||
const yBase = isHex(y) ? 16 : 10; | ||
x = cropHex(x); | ||
y = cropHex(y); | ||
const xBN = new BN(x, xBase); | ||
const yBN = new BN(y, yBase); | ||
let out; | ||
if (xBN.lte(yBN)) { | ||
out = xBN.toString(base); | ||
} else { | ||
out = yBN.toString(base); | ||
} | ||
return base === 10 ? out : '0x' + out; | ||
} | ||
function max(x, y, base = 10) { | ||
const xBase = isHex(x) ? 16 : 10; | ||
const yBase = isHex(y) ? 16 : 10; | ||
x = cropHex(x); | ||
y = cropHex(y); | ||
const xBN = new BN(x, xBase); | ||
const yBN = new BN(y, yBase); | ||
let out; | ||
if (xBN.gte(yBN)) { | ||
out = xBN.toString(base); | ||
} else { | ||
out = yBN.toString(base); | ||
} | ||
return base === 10 ? out : '0x' + out; | ||
} | ||
function divf(x, y) { | ||
@@ -193,5 +225,5 @@ const shift = log10(y); | ||
const bns = { add, sub, mul, div, gt, lt, gte, lte, eq, mulf, divf }; | ||
const bns = { add, sub, mul, div, gt, lt, gte, lte, eq, mulf, divf, min, max }; | ||
export { add, sub, mul, div, gt, lt, gte, lte, eq, mulf, divf, bns }; | ||
export { add, sub, mul, div, gt, lt, gte, lte, eq, mulf, divf, min, max, bns }; | ||
//# sourceMappingURL=index.es.js.map |
@@ -122,2 +122,34 @@ 'use strict'; | ||
function min(x, y, base = 10) { | ||
const xBase = isHex(x) ? 16 : 10; | ||
const yBase = isHex(y) ? 16 : 10; | ||
x = cropHex(x); | ||
y = cropHex(y); | ||
const xBN = new BN(x, xBase); | ||
const yBN = new BN(y, yBase); | ||
let out; | ||
if (xBN.lte(yBN)) { | ||
out = xBN.toString(base); | ||
} else { | ||
out = yBN.toString(base); | ||
} | ||
return base === 10 ? out : '0x' + out; | ||
} | ||
function max(x, y, base = 10) { | ||
const xBase = isHex(x) ? 16 : 10; | ||
const yBase = isHex(y) ? 16 : 10; | ||
x = cropHex(x); | ||
y = cropHex(y); | ||
const xBN = new BN(x, xBase); | ||
const yBN = new BN(y, yBase); | ||
let out; | ||
if (xBN.gte(yBN)) { | ||
out = xBN.toString(base); | ||
} else { | ||
out = yBN.toString(base); | ||
} | ||
return base === 10 ? out : '0x' + out; | ||
} | ||
function divf(x, y) { | ||
@@ -197,3 +229,3 @@ const shift = log10(y); | ||
const bns = { add, sub, mul, div, gt, lt, gte, lte, eq, mulf, divf }; | ||
const bns = { add, sub, mul, div, gt, lt, gte, lte, eq, mulf, divf, min, max }; | ||
@@ -211,3 +243,5 @@ exports.add = add; | ||
exports.divf = divf; | ||
exports.min = min; | ||
exports.max = max; | ||
exports.bns = bns; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "biggystring", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "Wrapper for bn.js to directly operate on strings as big numbers", | ||
@@ -32,2 +32,4 @@ "main": "./lib/index.js", | ||
"flow-bin": "^0.49.1", | ||
"flow-copy-source": "^1.2.1", | ||
"husky": "^0.14.3", | ||
"mocha": "^3.1.2", | ||
@@ -47,6 +49,8 @@ "rollup": "^0.43.1", | ||
"rollup": "rollup -c", | ||
"build": "npm run lint && npm run prepare && npm run flow", | ||
"build": "npm run lint && npm run prepare && npm run build:flow", | ||
"build:flow": "npm run flow && flow-copy-source -v -i '**/test/**' src lib", | ||
"cover": "nyc --reporter=lcov --reporter=text --reporter=html --extension .js npm test", | ||
"lint --fix": "standard '*.js' 'src/**/*.js' --fix", | ||
"lint": "standard '*.js' 'src/**/*.js'", | ||
"precommit": "npm test", | ||
"prepare": "npm run rollup", | ||
@@ -53,0 +57,0 @@ "test": "npm run build && mocha" |
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
48403
7
425
11