Update toc

js-version
Anton Medvedev 5 years ago
parent 33f2e861ff
commit 1ecc258ca6

@ -1,23 +1,23 @@
# Documentation # Documentation
* [Getting started](#getting-started) * [Getting started](#getting-started)
* [Anonymous function](#anonymous-function) * [Usage](#usage)
* [Binding](#binding) + [Anonymous function](#anonymous-function)
* [Dot](#dot) + [Binding](#binding)
* [Chain](#chain) + [Dot](#dot)
* [Generator](#generator) + [Chaining](#chaining)
* [Update](#update) + [Generator](#generator)
* [Using packages](#using-packages) + [Updating](#updating)
+ [Using packages](#using-packages)
* [Using .fxrc](#using-fxrc) * [Using .fxrc](#using-fxrc)
* [Edit in place](#edit-in-place) + [Edit in place](#edit-in-place)
* [Formatting](#formatting) * [Formatting](#formatting)
* [Other examples](#other-examples) * [Other examples](#other-examples)
* [Streaming mode](#streaming-mode) * [Streaming mode](#streaming-mode)
* [Interactive mode](#interactive-mode) * [Interactive mode](#interactive-mode)
+ [Search](#search) + [Searching](#searching)
+ [Selecting text](#selecting-text) + [Selecting text](#selecting-text)
## Getting started ## Getting started
`fx` can work in two modes: cli and interactive. To start interactive mode pipe into `fx` any JSON: `fx` can work in two modes: cli and interactive. To start interactive mode pipe into `fx` any JSON:
@ -34,7 +34,9 @@ $ fx my.json
If any argument was passed, `fx` will apply it and prints to stdout. If any argument was passed, `fx` will apply it and prints to stdout.
## Anonymous function ## Usage
### Anonymous function
Use an anonymous function as reducer which gets JSON and processes it: Use an anonymous function as reducer which gets JSON and processes it:
```bash ```bash
@ -42,7 +44,7 @@ $ echo '{"foo": [{"bar": "value"}]}' | fx 'x => x.foo[0].bar'
value value
``` ```
## Binding ### Binding
If you don't pass anonymous function `param => ...`, code will be automatically transformed into anonymous function. If you don't pass anonymous function `param => ...`, code will be automatically transformed into anonymous function.
And you can get access to JSON by `this` keyword: And you can get access to JSON by `this` keyword:
@ -51,7 +53,7 @@ $ echo '{"foo": [{"bar": "value"}]}' | fx 'this.foo[0].bar'
value value
``` ```
## Dot ### Dot
It is possible to omit `this` keyword: It is possible to omit `this` keyword:
```bash ```bash
@ -67,7 +69,7 @@ $ echo '{"foo": "bar"}' | fx .
} }
``` ```
## Chain ### Chaining
You can pass any number of anonymous functions for reducing JSON: You can pass any number of anonymous functions for reducing JSON:
```bash ```bash
@ -75,7 +77,7 @@ $ echo '{"foo": [{"bar": "value"}]}' | fx 'x => x.foo' 'this[0]' 'this.bar'
value value
``` ```
## Generator ### Generator
If passed code contains `yield` keyword, [generator expression](https://github.com/sebmarkbage/ecmascript-generator-expression) If passed code contains `yield` keyword, [generator expression](https://github.com/sebmarkbage/ecmascript-generator-expression)
will be used: will be used:
@ -101,7 +103,7 @@ $ echo '["a", "b"]' | fx 'yield* this; yield "c";'
] ]
``` ```
## Update ### Updating
You can update existing JSON using spread operator: You can update existing JSON using spread operator:
@ -112,7 +114,7 @@ $ echo '{"count": 0}' | fx '{...this, count: 1}'
} }
``` ```
## Using packages ### Using packages
Use any npm package by installing it globally: Use any npm package by installing it globally:
```bash ```bash
@ -142,7 +144,7 @@ curl 'https://api.github.com/repos/facebook/react/commits?per_page=100' \
> export NODE_PATH=`npm root -g` > export NODE_PATH=`npm root -g`
> ``` > ```
## Edit in place ### Edit in place
Add next code to your _.fxrc_ file: Add next code to your _.fxrc_ file:
@ -235,7 +237,7 @@ These commands are available when editing the filter:
| `Ctrl`+`w` | Delete last part | | `Ctrl`+`w` | Delete last part |
| `up`/`down` | Select autocomplete | | `up`/`down` | Select autocomplete |
### Search ### Searching
Press `/` and type regexp pattern to search in current JSON. Search work with currently applied filter. Press `/` and type regexp pattern to search in current JSON. Search work with currently applied filter.

Loading…
Cancel
Save