Skip to content

Commit

Permalink
Add @ as map operation prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
antonmedv committed Jan 8, 2020
1 parent 1744e17 commit 973ceb9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions reduce.js
Expand Up @@ -13,6 +13,12 @@ function reduce(json, code) {
return Object.keys(json) return Object.keys(json)
} }


if (/^@/.test(code)) {
return eval(`function fn() {
return Object.values(this).map(x => x${code.substring(1)})
}; fn`).call(json)
}

if (/^\.\[/.test(code)) { if (/^\.\[/.test(code)) {
return eval(`function fn() { return eval(`function fn() {
return this${code.substring(1)} return this${code.substring(1)}
Expand Down

0 comments on commit 973ceb9

Please sign in to comment.