@collabland/common
Advanced tools
Comparing version 0.23.0 to 0.23.1
@@ -77,2 +77,3 @@ "use strict"; | ||
function compare(a, b) { | ||
debug('$compare(%O,%O)', a, b); | ||
if (a === b) | ||
@@ -88,3 +89,5 @@ return 0; | ||
} | ||
return new bn_js_1.default(a).cmp(new bn_js_1.default(b)); | ||
const result = new bn_js_1.default(a).cmp(new bn_js_1.default(b)); | ||
debug('Result: %s', result); | ||
return result; | ||
} | ||
@@ -146,2 +149,12 @@ const compareTo = { | ||
}; | ||
const toString = { | ||
implementation: (value) => { | ||
const str = String(value); | ||
if (str === '[object Object]') { | ||
return JSON.stringify(value); | ||
} | ||
return str; | ||
}, | ||
signature: '<(snblo):s>', | ||
}; | ||
/** | ||
@@ -160,2 +173,3 @@ * Global jsonata functions | ||
lte, | ||
toString, // This is different from $string() which uses JSON.stringify | ||
}; | ||
@@ -183,3 +197,12 @@ /** | ||
} | ||
return exp.evaluate.bind(exp); | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
return (input, vars) => { | ||
if (debug.enabled) { | ||
debug('JSONdata input: %O, bindings: %O, query: %s, variables: %O', input, bindings, query, vars); | ||
debug('JSON input: %s', (0, debug_1.stringify)(input)); | ||
} | ||
const result = exp.evaluate(input, vars); | ||
debug('JSONata output: %O', result); | ||
return result; | ||
}; | ||
} | ||
@@ -186,0 +209,0 @@ exports.jsonQuery = jsonQuery; |
{ | ||
"name": "@collabland/common", | ||
"version": "0.23.0", | ||
"version": "0.23.1", | ||
"description": "CollabLand common utilities", | ||
@@ -62,3 +62,3 @@ "main": "dist/index.js", | ||
"author": "Abridged, Inc.", | ||
"gitHead": "e91992898ed6da83476c465e2df8783bc1b3c39a" | ||
"gitHead": "154108d67dcb9f75a4f884055a075e3c3a91933b" | ||
} |
@@ -9,3 +9,3 @@ // Copyright Abridged, Inc. 2021. All Rights Reserved. | ||
import lodash from 'lodash'; | ||
import {debugFactory} from './debug'; | ||
import {debugFactory, stringify} from './debug'; | ||
import {HttpErrors} from './http-client-fetch'; | ||
@@ -97,2 +97,3 @@ | ||
function compare(a: BNLike, b: BNLike) { | ||
debug('$compare(%O,%O)', a, b); | ||
if (a === b) return 0; | ||
@@ -106,3 +107,5 @@ if (a == null || b == null) return undefined; | ||
} | ||
return new BN(a).cmp(new BN(b)); | ||
const result = new BN(a).cmp(new BN(b)); | ||
debug('Result: %s', result); | ||
return result; | ||
} | ||
@@ -174,2 +177,13 @@ | ||
const toString: JsonQueryFunction = { | ||
implementation: (value: unknown) => { | ||
const str = String(value); | ||
if (str === '[object Object]') { | ||
return JSON.stringify(value); | ||
} | ||
return str; | ||
}, | ||
signature: '<(snblo):s>', | ||
}; | ||
/** | ||
@@ -188,2 +202,3 @@ * Global jsonata functions | ||
lte, | ||
toString, // This is different from $string() which uses JSON.stringify | ||
}; | ||
@@ -223,3 +238,18 @@ | ||
return exp.evaluate.bind(exp); | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
return (input: any, vars?: Record<string, any>) => { | ||
if (debug.enabled) { | ||
debug( | ||
'JSONdata input: %O, bindings: %O, query: %s, variables: %O', | ||
input, | ||
bindings, | ||
query, | ||
vars, | ||
); | ||
debug('JSON input: %s', stringify(input)); | ||
} | ||
const result = exp.evaluate(input, vars); | ||
debug('JSONata output: %O', result); | ||
return result; | ||
}; | ||
} | ||
@@ -226,0 +256,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
101257
2480