WIP - add extractor, generate snippet_data
This commit is contained in:
21
node_modules/unist-util-visit-children/index.js
generated
vendored
Normal file
21
node_modules/unist-util-visit-children/index.js
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = visitChildren
|
||||
|
||||
function visitChildren(callback) {
|
||||
return visitor
|
||||
|
||||
// Visit `parent`, invoking `callback` for each child.
|
||||
function visitor(parent) {
|
||||
var index = -1
|
||||
var children = parent && parent.children
|
||||
|
||||
if (!children) {
|
||||
throw new Error('Missing children in `parent` for `visitor`')
|
||||
}
|
||||
|
||||
while (++index in children) {
|
||||
callback(children[index], index, parent)
|
||||
}
|
||||
}
|
||||
}
|
||||
22
node_modules/unist-util-visit-children/license
generated
vendored
Normal file
22
node_modules/unist-util-visit-children/license
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2015 Titus Wormer <tituswormer@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
111
node_modules/unist-util-visit-children/package.json
generated
vendored
Normal file
111
node_modules/unist-util-visit-children/package.json
generated
vendored
Normal file
@ -0,0 +1,111 @@
|
||||
{
|
||||
"_from": "unist-util-visit-children@^1.0.0",
|
||||
"_id": "unist-util-visit-children@1.1.3",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-/GQ8KNRrG+qD30H76FZNc6Ok+8XTu8lxJByN5LnQ4eQfqxda2gP0CPsCX63BRB26ZRMNf6i1c+jlvNlqysEoFg==",
|
||||
"_location": "/unist-util-visit-children",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "unist-util-visit-children@^1.0.0",
|
||||
"name": "unist-util-visit-children",
|
||||
"escapedName": "unist-util-visit-children",
|
||||
"rawSpec": "^1.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/parse-english",
|
||||
"/parse-latin"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/unist-util-visit-children/-/unist-util-visit-children-1.1.3.tgz",
|
||||
"_shasum": "92ba5807e3f54637be5de950263f9468942e7503",
|
||||
"_spec": "unist-util-visit-children@^1.0.0",
|
||||
"_where": "/Users/stefanfejes/Projects/30-seconds-of-python-code/node_modules/parse-english",
|
||||
"author": {
|
||||
"name": "Titus Wormer",
|
||||
"email": "tituswormer@gmail.com",
|
||||
"url": "https://wooorm.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/syntax-tree/unist-util-visit-children/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Titus Wormer",
|
||||
"email": "tituswormer@gmail.com",
|
||||
"url": "https://wooorm.com"
|
||||
}
|
||||
],
|
||||
"dependencies": {},
|
||||
"deprecated": false,
|
||||
"description": "Unist utility to visit direct children of a parent",
|
||||
"devDependencies": {
|
||||
"browserify": "^16.0.0",
|
||||
"nyc": "^14.0.0",
|
||||
"prettier": "^1.0.0",
|
||||
"remark-cli": "^6.0.0",
|
||||
"remark-preset-wooorm": "^5.0.0",
|
||||
"tape": "^4.0.0",
|
||||
"tinyify": "^2.5.0",
|
||||
"xo": "^0.24.0"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/syntax-tree/unist-util-visit-children#readme",
|
||||
"keywords": [
|
||||
"unist",
|
||||
"util",
|
||||
"utility",
|
||||
"visit",
|
||||
"children"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "unist-util-visit-children",
|
||||
"nyc": {
|
||||
"check-coverage": true,
|
||||
"lines": 100,
|
||||
"functions": 100,
|
||||
"branches": 100
|
||||
},
|
||||
"prettier": {
|
||||
"tabWidth": 2,
|
||||
"useTabs": false,
|
||||
"singleQuote": true,
|
||||
"bracketSpacing": false,
|
||||
"semi": false,
|
||||
"trailingComma": "none"
|
||||
},
|
||||
"remarkConfig": {
|
||||
"plugins": [
|
||||
"preset-wooorm"
|
||||
]
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/syntax-tree/unist-util-visit-children.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "npm run build-bundle && npm run build-mangle",
|
||||
"build-bundle": "browserify . -s unistUtilVisitChildren -o unist-util-visit-children.js",
|
||||
"build-mangle": "browserify . -s unistUtilVisitChildren -p tinyify -o unist-util-visit-children.min.js",
|
||||
"format": "remark . -qfo && prettier --write \"**/*.js\" && xo --fix",
|
||||
"test": "npm run format && npm run build && npm run test-coverage",
|
||||
"test-api": "node test",
|
||||
"test-coverage": "nyc --reporter lcov tape test.js"
|
||||
},
|
||||
"version": "1.1.3",
|
||||
"xo": {
|
||||
"prettier": true,
|
||||
"esnext": false,
|
||||
"rules": {
|
||||
"guard-for-in": "off"
|
||||
},
|
||||
"ignores": [
|
||||
"unist-util-visit-children.js"
|
||||
]
|
||||
}
|
||||
}
|
||||
135
node_modules/unist-util-visit-children/readme.md
generated
vendored
Normal file
135
node_modules/unist-util-visit-children/readme.md
generated
vendored
Normal file
@ -0,0 +1,135 @@
|
||||
# unist-util-visit-children
|
||||
|
||||
[![Build][build-badge]][build]
|
||||
[![Coverage][coverage-badge]][coverage]
|
||||
[![Downloads][downloads-badge]][downloads]
|
||||
[![Size][size-badge]][size]
|
||||
|
||||
[**unist**][unist] direct child visitor.
|
||||
|
||||
## Install
|
||||
|
||||
[npm][]:
|
||||
|
||||
```sh
|
||||
npm install unist-util-visit-children
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var u = require('unist-builder')
|
||||
var visitChildren = require('unist-util-visit-children')
|
||||
|
||||
var visit = visitChildren(function(node) {
|
||||
console.log(node)
|
||||
})
|
||||
|
||||
var tree = u('tree', [
|
||||
u('leaf', 'leaf 1'),
|
||||
u('node', [u('leaf', 'leaf 2'), u('leaf', 'leaf 3')]),
|
||||
u('leaf', 'leaf 4'),
|
||||
u('void')
|
||||
])
|
||||
|
||||
visit(tree)
|
||||
```
|
||||
|
||||
Yields:
|
||||
|
||||
```js
|
||||
{ type: 'leaf', value: 'leaf 1' }
|
||||
{
|
||||
type: 'node',
|
||||
children: [
|
||||
{ type: 'leaf', value: 'leaf 2' },
|
||||
{ type: 'leaf', value: 'leaf 3' }
|
||||
]
|
||||
}
|
||||
{ type: 'leaf', value: 'leaf 4' }
|
||||
{ type: 'void' }
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### `visit = visitChildren(visitor)`
|
||||
|
||||
Wrap [`visitor`][visitor] to be invoked for each [child][] in the nodes later
|
||||
given to [`visit`][visit].
|
||||
|
||||
#### `function visitor(child, index, parent)`
|
||||
|
||||
Invoked if [`visit`][visit] is called on a [parent][] node for each [child][].
|
||||
|
||||
#### `function visit(parent)`
|
||||
|
||||
Invoke [`visitor`][visitor] for each [child][] of the [parent][].
|
||||
|
||||
## Related
|
||||
|
||||
* [`unist-util-visit`](https://github.com/syntax-tree/unist-util-visit)
|
||||
— Recursively walk over nodes
|
||||
* [`unist-util-visit-parents`](https://github.com/syntax-tree/unist-util-visit-parents)
|
||||
— Like `visit`, but with a stack of parents
|
||||
* [`unist-util-filter`](https://github.com/eush77/unist-util-filter)
|
||||
— Create a new tree with all nodes that pass a test
|
||||
* [`unist-util-map`](https://github.com/syntax-tree/unist-util-map)
|
||||
— Create a new tree with all nodes mapped by a given function
|
||||
* [`unist-util-remove`](https://github.com/eush77/unist-util-remove)
|
||||
— Remove nodes from a tree that pass a test
|
||||
* [`unist-util-select`](https://github.com/eush77/unist-util-select)
|
||||
— Select nodes with CSS-like selectors
|
||||
|
||||
## Contribute
|
||||
|
||||
See [`contributing.md` in `syntax-tree/.github`][contributing] for ways to get
|
||||
started.
|
||||
See [`support.md`][support] for ways to get help.
|
||||
|
||||
This project has a [Code of Conduct][coc].
|
||||
By interacting with this repository, organisation, or community you agree to
|
||||
abide by its terms.
|
||||
|
||||
## License
|
||||
|
||||
[MIT][license] © [Titus Wormer][author]
|
||||
|
||||
<!-- Definition -->
|
||||
|
||||
[build-badge]: https://img.shields.io/travis/syntax-tree/unist-util-visit-children.svg
|
||||
|
||||
[build]: https://travis-ci.org/syntax-tree/unist-util-visit-children
|
||||
|
||||
[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/unist-util-visit-children.svg
|
||||
|
||||
[coverage]: https://codecov.io/github/syntax-tree/unist-util-visit-children
|
||||
|
||||
[downloads-badge]: https://img.shields.io/npm/dm/unist-util-visit-children.svg
|
||||
|
||||
[downloads]: https://www.npmjs.com/package/unist-util-visit-children
|
||||
|
||||
[size-badge]: https://img.shields.io/bundlephobia/minzip/unist-util-visit-children.svg
|
||||
|
||||
[size]: https://bundlephobia.com/result?p=unist-util-visit-children
|
||||
|
||||
[npm]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[license]: license
|
||||
|
||||
[author]: https://wooorm.com
|
||||
|
||||
[unist]: https://github.com/syntax-tree/unist
|
||||
|
||||
[parent]: https://github.com/syntax-tree/unist#parent-1
|
||||
|
||||
[child]: https://github.com/syntax-tree/unist#child
|
||||
|
||||
[visit]: #function-visitparent
|
||||
|
||||
[visitor]: #function-visitorchild-index-parent
|
||||
|
||||
[contributing]: https://github.com/syntax-tree/.github/blob/master/contributing.md
|
||||
|
||||
[support]: https://github.com/syntax-tree/.github/blob/master/support.md
|
||||
|
||||
[coc]: https://github.com/syntax-tree/.github/blob/master/code-of-conduct.md
|
||||
Reference in New Issue
Block a user