mirror of
https://github.com/snachodog/just-the-docs.git
synced 2025-09-12 21:03:32 -06:00
Initial commit
This commit is contained in:
1
node_modules/jsonfilter/.npmignore
generated
vendored
Normal file
1
node_modules/jsonfilter/.npmignore
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
node_modules
|
12
node_modules/jsonfilter/cli.js
generated
vendored
Executable file
12
node_modules/jsonfilter/cli.js
generated
vendored
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var fs = require('fs')
|
||||
var minimist = require('minimist')
|
||||
var args = minimist(process.argv.slice(2))
|
||||
var jsonfilter = require('./')
|
||||
var firstArg = args._[0]
|
||||
process.stdin.pipe(jsonfilter(firstArg, args)).on('data', function(o) {
|
||||
process.stdout.write(o)
|
||||
}).on('end', function() {
|
||||
console.log('') // trailing newline
|
||||
})
|
8
node_modules/jsonfilter/collaborators.md
generated
vendored
Normal file
8
node_modules/jsonfilter/collaborators.md
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
## Collaborators
|
||||
|
||||
jsonfilter is only possible due to the excellent work of the following collaborators:
|
||||
|
||||
<table><tbody><tr><th align="left">maxogden</th><td><a href="https://github.com/maxogden">GitHub/maxogden</a></td></tr>
|
||||
<tr><th align="left">jlord</th><td><a href="https://github.com/jlord">GitHub/jlord</a></td></tr>
|
||||
<tr><th align="left">groundwater</th><td><a href="https://github.com/groundwater">GitHub/groundwater</a></td></tr>
|
||||
</tbody></table>
|
37
node_modules/jsonfilter/index.js
generated
vendored
Normal file
37
node_modules/jsonfilter/index.js
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
var JSONStream = require('JSONStream')
|
||||
var combiner = require('stream-combiner')
|
||||
var through = require('through2')
|
||||
|
||||
module.exports = function(filter, opts) {
|
||||
if (!opts) opts = {}
|
||||
var pipeline = [
|
||||
JSONStream.parse(filter)
|
||||
]
|
||||
|
||||
if (opts.match) {
|
||||
pipeline.push(createFunctionStream(opts.match, function(output, object, next) {
|
||||
if (!!output) this.push(object)
|
||||
next()
|
||||
}))
|
||||
}
|
||||
|
||||
pipeline.push(JSONStream.stringify('', '\n', ''))
|
||||
return combiner.apply(null, pipeline)
|
||||
}
|
||||
|
||||
function createFunctionStream(func, customTransform) {
|
||||
var funcStr = 'var that = ' + func + ';\n return that;'
|
||||
var compiled = new Function(funcStr)
|
||||
|
||||
function transform(obj, enc, next) {
|
||||
var out = compiled.call(obj, obj)
|
||||
if (customTransform) {
|
||||
customTransform.call(this, out, obj, next)
|
||||
} else {
|
||||
this.push(out)
|
||||
next()
|
||||
}
|
||||
}
|
||||
|
||||
return through.obj(transform)
|
||||
}
|
91
node_modules/jsonfilter/package.json
generated
vendored
Normal file
91
node_modules/jsonfilter/package.json
generated
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"jsonfilter@^1.1.2",
|
||||
"/Users/pmarsceill/_projects/just-the-docs/node_modules/doiuse"
|
||||
]
|
||||
],
|
||||
"_from": "jsonfilter@>=1.1.2 <2.0.0",
|
||||
"_id": "jsonfilter@1.1.2",
|
||||
"_inCache": true,
|
||||
"_installable": true,
|
||||
"_location": "/jsonfilter",
|
||||
"_nodeVersion": "0.10.28",
|
||||
"_npmUser": {
|
||||
"email": "max+DONT+EMAIL+ME@maxogden.com",
|
||||
"name": "maxogden"
|
||||
},
|
||||
"_npmVersion": "2.1.6",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"name": "jsonfilter",
|
||||
"raw": "jsonfilter@^1.1.2",
|
||||
"rawSpec": "^1.1.2",
|
||||
"scope": null,
|
||||
"spec": ">=1.1.2 <2.0.0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/doiuse"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/jsonfilter/-/jsonfilter-1.1.2.tgz",
|
||||
"_shasum": "21ef7cedc75193813c75932e96a98be205ba5a11",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "jsonfilter@^1.1.2",
|
||||
"_where": "/Users/pmarsceill/_projects/just-the-docs/node_modules/doiuse",
|
||||
"author": {
|
||||
"name": "max ogden"
|
||||
},
|
||||
"bin": {
|
||||
"jsonfilter": "cli.js"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/maxogden/jsonfilter/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"JSONStream": "^0.8.4",
|
||||
"minimist": "^1.1.0",
|
||||
"stream-combiner": "^0.2.1",
|
||||
"through2": "^0.6.3"
|
||||
},
|
||||
"description": "Streaming JSON filtering on the command line",
|
||||
"devDependencies": {},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "21ef7cedc75193813c75932e96a98be205ba5a11",
|
||||
"tarball": "https://registry.npmjs.org/jsonfilter/-/jsonfilter-1.1.2.tgz"
|
||||
},
|
||||
"gitHead": "7180dfb6695cb4df7677a807c2fd79724154ce70",
|
||||
"homepage": "https://github.com/maxogden/jsonfilter",
|
||||
"license": "BSD",
|
||||
"main": "index.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "maxogden",
|
||||
"email": "max@maxogden.com"
|
||||
},
|
||||
{
|
||||
"name": "jlord",
|
||||
"email": "to.jlord@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "visnup",
|
||||
"email": "visnupx@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "groundwater",
|
||||
"email": "groundwater@gmail.com"
|
||||
}
|
||||
],
|
||||
"name": "jsonfilter",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/maxogden/jsonfilter.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "cat test.json | jsonfilter dog"
|
||||
},
|
||||
"version": "1.1.2"
|
||||
}
|
76
node_modules/jsonfilter/readme.md
generated
vendored
Normal file
76
node_modules/jsonfilter/readme.md
generated
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
# jsonfilter
|
||||
|
||||
Streaming JSON filtering on the command line. Supports JSON querying and expression based filtering.
|
||||
|
||||
Works great for JSON datasets that are too big to JSON.parse() or for situations where you want to start reading data immediately.
|
||||
|
||||
Powered by [JSONStream](https://www.npmjs.org/package/JSONStream) which is powered by [jsonparse](https://www.npmjs.org/package/jsonparse)
|
||||
|
||||
[](https://nodei.co/npm/jsonfilter/)
|
||||
|
||||
## usage
|
||||
|
||||
Pipe JSON data to stdin!
|
||||
|
||||
```
|
||||
jsonfilter <selector> [--match="filter expression"]
|
||||
```
|
||||
|
||||
`filter` is a string to 'query' your JSON with.
|
||||
|
||||
Matches will be printed as Newline Delimited JSON (NDJSON)
|
||||
|
||||
**some examples:**
|
||||
|
||||
Emit the value of a particular key by naming it, e.g. `"name"` matches the key `name` in an object and returns the value:
|
||||
|
||||
```
|
||||
$ echo '{"name": "Joe Blogs", "age": 28}' | jsonfilter "name"
|
||||
"Joe Blogs"
|
||||
```
|
||||
|
||||
`rows.*` matches any child elements of `rows`, e.g.:
|
||||
|
||||
```BASH
|
||||
$ echo '{"name": "foo", "type": "bar"}{"name": "foobar", "type": "barfoo"}' | jsonfilter "name"
|
||||
"foo"
|
||||
"foobar"
|
||||
```
|
||||
|
||||
`"rows.*"` matches any child elements (items inside the array) of `rows`, e.g.:
|
||||
|
||||
```BASH
|
||||
$ echo '{"rows": [ {"this object": "will be matched"}, {"so will": "this one"} ]}' | jsonfilter "rows.*"
|
||||
{"this object": "will be matched"}
|
||||
{"so will": "this one"}
|
||||
```
|
||||
|
||||
`"rows.*.doc"` matches all children of `rows` with key `doc`, e.g.:
|
||||
|
||||
```BASH
|
||||
$ echo '{"rows": [ {"doc": {"this object": "will be matched"}, "foo": "bar"} ]}' | jsonfilter "rows.*.doc"
|
||||
{'this object': 'will be matched'}
|
||||
```
|
||||
|
||||
`"rows..doc"` recursively matches all children of `rows` and emits all with key `doc`, e.g.:
|
||||
|
||||
```BASH
|
||||
$ echo '{"rows": [ {"foo": {"bar": {"baz": {"taco": {"doc": "woo"}}}}} ]}' | jsonfilter "rows..doc"
|
||||
"woo"
|
||||
```
|
||||
|
||||
## matching
|
||||
|
||||
by default all matched objects are emitted. You can supply a custom JS expression to filter out matching objects with the `--match` option.
|
||||
|
||||
```BASH
|
||||
$ echo '{"name": "foo", "type": "bar"}{"name": "foobar", "type": "barfoo"}' | jsonfilter "name" --match="this === 'foo'"
|
||||
"foo"
|
||||
|
||||
$ echo '{"name": "foo", "type": "bar"}{"name": "foobar", "type": "barfoo"}' | jsonfilter --match="this.name === 'foo'"
|
||||
{"name": "foo", "type": "bar"}
|
||||
|
||||
$ echo '{"name": "foo", "type": "bar"}{"name": "foobar", "type": "barfoo"}' | jsonfilter --match="this.name.indexOf('foo') > -1"
|
||||
{"name": "foo", "type": "bar"}
|
||||
{"name": "foobar", "type": "barfoo"}
|
||||
```
|
2
node_modules/jsonfilter/test.json
generated
vendored
Normal file
2
node_modules/jsonfilter/test.json
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
{"foo": "bar", "dog": 5}
|
||||
{"baz": "taco", "dog": 5}
|
Reference in New Issue
Block a user