@collabland/common
Advanced tools
Comparing version 0.23.2 to 0.24.0
@@ -76,2 +76,34 @@ "use strict"; | ||
}; | ||
function _add(a, b) { | ||
debug('$add(%s,%s)', a, b); | ||
a = a !== null && a !== void 0 ? a : '0'; | ||
b = b !== null && b !== void 0 ? b : '0'; | ||
if (typeof a === 'bigint' || (typeof a === 'object' && !(a instanceof bn_js_1.default))) { | ||
a = a.toString(); | ||
} | ||
if (typeof b === 'bigint' || (typeof b === 'object' && !(b instanceof bn_js_1.default))) { | ||
b = b.toString(); | ||
} | ||
return new bn_js_1.default(a !== null && a !== void 0 ? a : 0).add(new bn_js_1.default(b !== null && b !== void 0 ? b : 0)); | ||
} | ||
function _sub(a, b) { | ||
debug('$sub(%s,%s)', a, b); | ||
a = a !== null && a !== void 0 ? a : '0'; | ||
b = b !== null && b !== void 0 ? b : '0'; | ||
if (typeof a === 'bigint' || (typeof a === 'object' && !(a instanceof bn_js_1.default))) { | ||
a = a.toString(); | ||
} | ||
if (typeof b === 'bigint' || (typeof b === 'object' && !(b instanceof bn_js_1.default))) { | ||
b = b.toString(); | ||
} | ||
return new bn_js_1.default(a !== null && a !== void 0 ? a : 0).sub(new bn_js_1.default(b !== null && b !== void 0 ? b : 0)); | ||
} | ||
const add = { | ||
implementation: _add, | ||
signature: '<(snlo)(snlo):o>', | ||
}; | ||
const sub = { | ||
implementation: _sub, | ||
signature: '<(snlo)(snlo):o>', | ||
}; | ||
function compare(a, b) { | ||
@@ -171,2 +203,4 @@ debug('$compare(%O,%O)', a, b); | ||
lte, | ||
add, | ||
sub, | ||
toString, // This is different from $string() which uses JSON.stringify | ||
@@ -173,0 +207,0 @@ }; |
{ | ||
"name": "@collabland/common", | ||
"version": "0.23.2", | ||
"version": "0.24.0", | ||
"description": "CollabLand common utilities", | ||
@@ -62,3 +62,3 @@ "main": "dist/index.js", | ||
"author": "Abridged, Inc.", | ||
"gitHead": "e5ad9ea01438af9dc8fcb8a2690cb9a27b052fde" | ||
"gitHead": "bc079a4c43e8b849abc563b3ff5841b25fdf7028" | ||
} |
@@ -95,2 +95,38 @@ // Copyright Abridged, Inc. 2021. All Rights Reserved. | ||
function _add(a: BNLike, b: BNLike) { | ||
debug('$add(%s,%s)', a, b); | ||
a = a ?? '0'; | ||
b = b ?? '0'; | ||
if (typeof a === 'bigint' || (typeof a === 'object' && !(a instanceof BN))) { | ||
a = a.toString(); | ||
} | ||
if (typeof b === 'bigint' || (typeof b === 'object' && !(b instanceof BN))) { | ||
b = b.toString(); | ||
} | ||
return new BN(a ?? 0).add(new BN(b ?? 0)); | ||
} | ||
function _sub(a: BNLike, b: BNLike) { | ||
debug('$sub(%s,%s)', a, b); | ||
a = a ?? '0'; | ||
b = b ?? '0'; | ||
if (typeof a === 'bigint' || (typeof a === 'object' && !(a instanceof BN))) { | ||
a = a.toString(); | ||
} | ||
if (typeof b === 'bigint' || (typeof b === 'object' && !(b instanceof BN))) { | ||
b = b.toString(); | ||
} | ||
return new BN(a ?? 0).sub(new BN(b ?? 0)); | ||
} | ||
const add: JsonQueryFunction = { | ||
implementation: _add, | ||
signature: '<(snlo)(snlo):o>', | ||
}; | ||
const sub: JsonQueryFunction = { | ||
implementation: _sub, | ||
signature: '<(snlo)(snlo):o>', | ||
}; | ||
function compare(a: BNLike, b: BNLike) { | ||
@@ -199,2 +235,4 @@ debug('$compare(%O,%O)', a, b); | ||
lte, | ||
add, | ||
sub, | ||
toString, // This is different from $string() which uses JSON.stringify | ||
@@ -201,0 +239,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
105179
2554