@jsonquerylang/jsonquery
Advanced tools
Comparing version 4.1.0 to 4.1.1
const A = (t) => Array.isArray(t), L = (t) => t && typeof t == "object" && !A(t), W = (t) => typeof t == "string"; | ||
function p(t) { | ||
function f(t) { | ||
return (...e) => { | ||
@@ -123,6 +123,8 @@ const n = e.map((c) => m(c)), r = n[0], s = n[1]; | ||
join: (t = "") => (e) => e.join(t), | ||
split: p( | ||
split: f( | ||
(t, e) => e !== void 0 ? t.split(e) : t.trim().split(/\s+/) | ||
), | ||
substring: (t, e) => (n) => n.slice(Math.max(t, 0), e), | ||
substring: f( | ||
(t, e, n) => t.slice(Math.max(e, 0), n) | ||
), | ||
uniq: () => (t) => [...new Set(t)], | ||
@@ -139,5 +141,5 @@ uniqBy: (t) => (e) => Object.values(x.keyBy(t)(e)), | ||
max: () => (t) => Math.max(...t), | ||
and: p((t, e) => !!(t && e)), | ||
or: p((t, e) => !!(t || e)), | ||
not: p((t) => !t), | ||
and: f((t, e) => !!(t && e)), | ||
or: f((t, e) => !!(t || e)), | ||
not: f((t) => !t), | ||
exists: (t) => { | ||
@@ -166,21 +168,21 @@ const e = t.slice(1), n = e.pop(), r = x.get(...e); | ||
}, | ||
eq: p((t, e) => t === e), | ||
gt: p((t, e) => t > e), | ||
gte: p((t, e) => t >= e), | ||
lt: p((t, e) => t < e), | ||
lte: p((t, e) => t <= e), | ||
ne: p((t, e) => t !== e), | ||
add: p((t, e) => t + e), | ||
subtract: p((t, e) => t - e), | ||
multiply: p((t, e) => t * e), | ||
divide: p((t, e) => t / e), | ||
pow: p((t, e) => t ** e), | ||
mod: p((t, e) => t % e), | ||
abs: p(Math.abs), | ||
round: p((t, e = 0) => +`${Math.round(+`${t}e${e}`)}e${-e}`), | ||
number: p((t) => { | ||
eq: f((t, e) => t === e), | ||
gt: f((t, e) => t > e), | ||
gte: f((t, e) => t >= e), | ||
lt: f((t, e) => t < e), | ||
lte: f((t, e) => t <= e), | ||
ne: f((t, e) => t !== e), | ||
add: f((t, e) => t + e), | ||
subtract: f((t, e) => t - e), | ||
multiply: f((t, e) => t * e), | ||
divide: f((t, e) => t / e), | ||
pow: f((t, e) => t ** e), | ||
mod: f((t, e) => t % e), | ||
abs: f(Math.abs), | ||
round: f((t, e = 0) => +`${Math.round(+`${t}e${e}`)}e${-e}`), | ||
number: f((t) => { | ||
const e = Number(t); | ||
return Number.isNaN(Number(t)) ? null : e; | ||
}), | ||
string: p(String) | ||
string: f(String) | ||
}, E = (t) => t !== null && t !== 0 && t !== !1, v = []; | ||
@@ -264,3 +266,3 @@ function m(t, e) { | ||
u++, o.push( | ||
l() ?? f() ?? j() ?? _("Property expected") | ||
l() ?? p() ?? j() ?? _("Property expected") | ||
); | ||
@@ -271,3 +273,3 @@ return ["get", ...o]; | ||
}, O = () => { | ||
const o = u, a = f(); | ||
const o = u, a = p(); | ||
if (g(), !a || t[u] !== "(") | ||
@@ -287,3 +289,3 @@ return u = o, h(); | ||
a ? a = !1 : (d(","), g()); | ||
const y = l() ?? f() ?? j() ?? _("Key expected"); | ||
const y = l() ?? p() ?? j() ?? _("Key expected"); | ||
g(), d(":"), o[y] = s(); | ||
@@ -304,3 +306,3 @@ } | ||
return l() ?? N() ?? w(); | ||
}, l = () => b(U, JSON.parse), f = () => b(T, (o) => o), N = () => b(z, JSON.parse), j = () => b(B, JSON.parse), w = () => { | ||
}, l = () => b(U, JSON.parse), p = () => b(T, (o) => o), N = () => b(z, JSON.parse), j = () => b(B, JSON.parse), w = () => { | ||
const o = b(K, JSON.parse); | ||
@@ -328,7 +330,7 @@ if (o !== void 0) | ||
var S; | ||
const [l, ...f] = h; | ||
if (l === "get" && f.length > 0) | ||
return $(f); | ||
const [l, ...p] = h; | ||
if (l === "get" && p.length > 0) | ||
return $(p); | ||
if (l === "pipe") { | ||
const b = f.map((g) => r(g, i + n)); | ||
const b = p.map((g) => r(g, i + n)); | ||
return O(b, ["", " | ", ""], ["", ` | ||
@@ -338,5 +340,5 @@ ${i + n}| `, ""]); | ||
if (l === "object") | ||
return c(f[0], i); | ||
return c(p[0], i); | ||
if (l === "array") { | ||
const b = f.map((g) => r(g, i)); | ||
const b = p.map((g) => r(g, i)); | ||
return O( | ||
@@ -352,11 +354,11 @@ b, | ||
const N = ((S = e == null ? void 0 : e.operators) == null ? void 0 : S[l]) ?? R[l]; | ||
if (N && f.length === 2) { | ||
const [b, g] = f, d = r(b, i), _ = r(g, i); | ||
if (N && p.length === 2) { | ||
const [b, g] = p, d = r(b, i), _ = r(g, i); | ||
return `(${d} ${N} ${_})`; | ||
} | ||
const j = f.length === 1 ? i : i + n, w = f.map((b) => r(b, j)); | ||
return f.length === 1 && w[0][0] === "(" ? `${l}${w[0]}` : O( | ||
const j = p.length === 1 ? i : i + n, w = p.map((b) => r(b, j)); | ||
return p.length === 1 && w[0][0] === "(" ? `${l}${w[0]}` : O( | ||
w, | ||
[`${l}(`, ", ", ")"], | ||
f.length === 1 ? [`${l}(`, `, | ||
p.length === 1 ? [`${l}(`, `, | ||
${i}`, ")"] : [`${l}( | ||
@@ -368,5 +370,5 @@ ${j}`, `, | ||
}, c = (h, i) => { | ||
const l = i + n, f = Object.entries(h).map(([N, j]) => `${k(N)}: ${r(j, l)}`); | ||
const l = i + n, p = Object.entries(h).map(([N, j]) => `${k(N)}: ${r(j, l)}`); | ||
return O( | ||
f, | ||
p, | ||
["{ ", ", ", " }"], | ||
@@ -378,3 +380,3 @@ [`{ | ||
); | ||
}, $ = (h) => h.map((i) => `.${k(i)}`).join(""), k = (h) => M.test(h) ? h : JSON.stringify(h), O = (h, [i, l, f], [N, j, w]) => i.length + h.reduce((b, g) => b + g.length + l.length, 0) - l.length + f.length <= ((e == null ? void 0 : e.maxLineLength) ?? C) ? i + h.join(l) + f : N + h.join(j) + w; | ||
}, $ = (h) => h.map((i) => `.${k(i)}`).join(""), k = (h) => M.test(h) ? h : JSON.stringify(h), O = (h, [i, l, p], [N, j, w]) => i.length + h.reduce((b, g) => b + g.length + l.length, 0) - l.length + p.length <= ((e == null ? void 0 : e.maxLineLength) ?? C) ? i + h.join(l) + p : N + h.join(j) + w; | ||
return r(t, ""); | ||
@@ -386,3 +388,3 @@ }; | ||
export { | ||
p as buildFunction, | ||
f as buildFunction, | ||
m as compile, | ||
@@ -389,0 +391,0 @@ H as jsonquery, |
{ | ||
"name": "@jsonquerylang/jsonquery", | ||
"version": "4.1.0", | ||
"version": "4.1.1", | ||
"description": "A small, flexible, and expandable JSON query language", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
90270
654