Skip to content

Commit

Permalink
Add ? shortcut
Browse files Browse the repository at this point in the history
  • Loading branch information
antonmedv committed Mar 19, 2018
1 parent 0f0bcb4 commit cf81a94
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ $ cat package.json | fx 'Object.keys(this.dependencies)'
]
```

By the way, fx has shortcut for `Object.keys(this)`. Previous example can be rewritten as:

```
$ cat package.json | fx this.dependencies ?
```


## Related

Expand Down
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ function reduce(json, code) {
}; fn
`)
return fx.call(json)
} else if (/^\?$/.test(code)) {
return Object.keys(json)
} else {
const fx = eval(`function fn() { return ${code} }; fn`)
return fx.call(json)
Expand Down

0 comments on commit cf81a94

Please sign in to comment.