Update index.js

pull/251/head
Anton Medvedev 1 year ago
parent 64d40d1a3f
commit 7a6318bca5
No known key found for this signature in database

@ -54,7 +54,9 @@ function transform(json, code) {
return Object.keys(json)
if (/^(\.\w*)+\[]/.test(code))
code = fold(code.split('[]'))
return eval(`(function () {
return (${fold(code.split('[]'))})(this)
})`).call(json)
if (/^\.\[/.test(code))
return eval(`(function () {
@ -90,3 +92,11 @@ function fold(s) {
obj = obj === '.' ? 'x' : 'x' + obj
return `x => Object.values(${obj}).flatMap(${fold(s)})`
}
function uniq(array) {
return [...new Set(array)]
}
function sort(array) {
return array.sort()
}

Loading…
Cancel
Save