mirror of
https://github.com/optim-enterprises-bv/control-pane.git
synced 2025-10-30 17:37:59 +00:00
wip
This commit is contained in:
5
.gitignore
vendored
5
.gitignore
vendored
@@ -1,4 +1,5 @@
|
|||||||
media_import/*.img
|
media_import/*.img
|
||||||
media_import/*.size
|
media_import/*.size
|
||||||
|
logs/*.log
|
||||||
|
logs/*.err
|
||||||
|
clonos/node/node_modules/*
|
||||||
|
|||||||
0
logs/placeholder
Normal file
0
logs/placeholder
Normal file
1
node/node_modules/.bin/esparse
generated
vendored
Symbolic link
1
node/node_modules/.bin/esparse
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../esprima/bin/esparse.js
|
||||||
1
node/node_modules/.bin/esvalidate
generated
vendored
Symbolic link
1
node/node_modules/.bin/esvalidate
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../esprima/bin/esvalidate.js
|
||||||
1
node/node_modules/.bin/js-yaml
generated
vendored
Symbolic link
1
node/node_modules/.bin/js-yaml
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../js-yaml/bin/js-yaml.js
|
||||||
185
node/node_modules/argparse/CHANGELOG.md
generated
vendored
Normal file
185
node/node_modules/argparse/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,185 @@
|
|||||||
|
1.0.10 / 2018-02-15
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Use .concat instead of + for arrays, #122.
|
||||||
|
|
||||||
|
|
||||||
|
1.0.9 / 2016-09-29
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Rerelease after 1.0.8 - deps cleanup.
|
||||||
|
|
||||||
|
|
||||||
|
1.0.8 / 2016-09-29
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Maintenance (deps bump, fix node 6.5+ tests, coverage report).
|
||||||
|
|
||||||
|
|
||||||
|
1.0.7 / 2016-03-17
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Teach `addArgument` to accept string arg names. #97, @tomxtobin.
|
||||||
|
|
||||||
|
|
||||||
|
1.0.6 / 2016-02-06
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Maintenance: moved to eslint & updated CS.
|
||||||
|
|
||||||
|
|
||||||
|
1.0.5 / 2016-02-05
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Removed lodash dependency to significantly reduce install size.
|
||||||
|
Thanks to @mourner.
|
||||||
|
|
||||||
|
|
||||||
|
1.0.4 / 2016-01-17
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Maintenance: lodash update to 4.0.0.
|
||||||
|
|
||||||
|
|
||||||
|
1.0.3 / 2015-10-27
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Fix parse `=` in args: `--examplepath="C:\myfolder\env=x64"`. #84, @CatWithApple.
|
||||||
|
|
||||||
|
|
||||||
|
1.0.2 / 2015-03-22
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Relaxed lodash version dependency.
|
||||||
|
|
||||||
|
|
||||||
|
1.0.1 / 2015-02-20
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Changed dependencies to be compatible with ancient nodejs.
|
||||||
|
|
||||||
|
|
||||||
|
1.0.0 / 2015-02-19
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Maintenance release.
|
||||||
|
- Replaced `underscore` with `lodash`.
|
||||||
|
- Bumped version to 1.0.0 to better reflect semver meaning.
|
||||||
|
- HISTORY.md -> CHANGELOG.md
|
||||||
|
|
||||||
|
|
||||||
|
0.1.16 / 2013-12-01
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
- Maintenance release. Updated dependencies and docs.
|
||||||
|
|
||||||
|
|
||||||
|
0.1.15 / 2013-05-13
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
- Fixed #55, @trebor89
|
||||||
|
|
||||||
|
|
||||||
|
0.1.14 / 2013-05-12
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
- Fixed #62, @maxtaco
|
||||||
|
|
||||||
|
|
||||||
|
0.1.13 / 2013-04-08
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
- Added `.npmignore` to reduce package size
|
||||||
|
|
||||||
|
|
||||||
|
0.1.12 / 2013-02-10
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
- Fixed conflictHandler (#46), @hpaulj
|
||||||
|
|
||||||
|
|
||||||
|
0.1.11 / 2013-02-07
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
- Multiple bugfixes, @hpaulj
|
||||||
|
- Added 70+ tests (ported from python), @hpaulj
|
||||||
|
- Added conflictHandler, @applepicke
|
||||||
|
- Added fromfilePrefixChar, @hpaulj
|
||||||
|
|
||||||
|
|
||||||
|
0.1.10 / 2012-12-30
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
- Added [mutual exclusion](http://docs.python.org/dev/library/argparse.html#mutual-exclusion)
|
||||||
|
support, thanks to @hpaulj
|
||||||
|
- Fixed options check for `storeConst` & `appendConst` actions, thanks to @hpaulj
|
||||||
|
|
||||||
|
|
||||||
|
0.1.9 / 2012-12-27
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Fixed option dest interferens with other options (issue #23), thanks to @hpaulj
|
||||||
|
- Fixed default value behavior with `*` positionals, thanks to @hpaulj
|
||||||
|
- Improve `getDefault()` behavior, thanks to @hpaulj
|
||||||
|
- Imrove negative argument parsing, thanks to @hpaulj
|
||||||
|
|
||||||
|
|
||||||
|
0.1.8 / 2012-12-01
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Fixed parser parents (issue #19), thanks to @hpaulj
|
||||||
|
- Fixed negative argument parse (issue #20), thanks to @hpaulj
|
||||||
|
|
||||||
|
|
||||||
|
0.1.7 / 2012-10-14
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Fixed 'choices' argument parse (issue #16)
|
||||||
|
- Fixed stderr output (issue #15)
|
||||||
|
|
||||||
|
|
||||||
|
0.1.6 / 2012-09-09
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Fixed check for conflict of options (thanks to @tomxtobin)
|
||||||
|
|
||||||
|
|
||||||
|
0.1.5 / 2012-09-03
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Fix parser #setDefaults method (thanks to @tomxtobin)
|
||||||
|
|
||||||
|
|
||||||
|
0.1.4 / 2012-07-30
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Fixed pseudo-argument support (thanks to @CGamesPlay)
|
||||||
|
- Fixed addHelp default (should be true), if not set (thanks to @benblank)
|
||||||
|
|
||||||
|
|
||||||
|
0.1.3 / 2012-06-27
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Fixed formatter api name: Formatter -> HelpFormatter
|
||||||
|
|
||||||
|
|
||||||
|
0.1.2 / 2012-05-29
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Added basic tests
|
||||||
|
- Removed excess whitespace in help
|
||||||
|
- Fixed error reporting, when parcer with subcommands
|
||||||
|
called with empty arguments
|
||||||
|
|
||||||
|
|
||||||
|
0.1.1 / 2012-05-23
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Fixed line wrapping in help formatter
|
||||||
|
- Added better error reporting on invalid arguments
|
||||||
|
|
||||||
|
|
||||||
|
0.1.0 / 2012-05-16
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- First release.
|
||||||
21
node/node_modules/argparse/LICENSE
generated
vendored
Normal file
21
node/node_modules/argparse/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
(The MIT License)
|
||||||
|
|
||||||
|
Copyright (C) 2012 by Vitaly Puzrin
|
||||||
|
|
||||||
|
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.
|
||||||
257
node/node_modules/argparse/README.md
generated
vendored
Normal file
257
node/node_modules/argparse/README.md
generated
vendored
Normal file
@@ -0,0 +1,257 @@
|
|||||||
|
argparse
|
||||||
|
========
|
||||||
|
|
||||||
|
[](http://travis-ci.org/nodeca/argparse)
|
||||||
|
[](https://www.npmjs.org/package/argparse)
|
||||||
|
|
||||||
|
CLI arguments parser for node.js. Javascript port of python's
|
||||||
|
[argparse](http://docs.python.org/dev/library/argparse.html) module
|
||||||
|
(original version 3.2). That's a full port, except some very rare options,
|
||||||
|
recorded in issue tracker.
|
||||||
|
|
||||||
|
**NB. Difference with original.**
|
||||||
|
|
||||||
|
- Method names changed to camelCase. See [generated docs](http://nodeca.github.com/argparse/).
|
||||||
|
- Use `defaultValue` instead of `default`.
|
||||||
|
- Use `argparse.Const.REMAINDER` instead of `argparse.REMAINDER`, and
|
||||||
|
similarly for constant values `OPTIONAL`, `ZERO_OR_MORE`, and `ONE_OR_MORE`
|
||||||
|
(aliases for `nargs` values `'?'`, `'*'`, `'+'`, respectively), and
|
||||||
|
`SUPPRESS`.
|
||||||
|
|
||||||
|
|
||||||
|
Example
|
||||||
|
=======
|
||||||
|
|
||||||
|
test.js file:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
#!/usr/bin/env node
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var ArgumentParser = require('../lib/argparse').ArgumentParser;
|
||||||
|
var parser = new ArgumentParser({
|
||||||
|
version: '0.0.1',
|
||||||
|
addHelp:true,
|
||||||
|
description: 'Argparse example'
|
||||||
|
});
|
||||||
|
parser.addArgument(
|
||||||
|
[ '-f', '--foo' ],
|
||||||
|
{
|
||||||
|
help: 'foo bar'
|
||||||
|
}
|
||||||
|
);
|
||||||
|
parser.addArgument(
|
||||||
|
[ '-b', '--bar' ],
|
||||||
|
{
|
||||||
|
help: 'bar foo'
|
||||||
|
}
|
||||||
|
);
|
||||||
|
parser.addArgument(
|
||||||
|
'--baz',
|
||||||
|
{
|
||||||
|
help: 'baz bar'
|
||||||
|
}
|
||||||
|
);
|
||||||
|
var args = parser.parseArgs();
|
||||||
|
console.dir(args);
|
||||||
|
```
|
||||||
|
|
||||||
|
Display help:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ ./test.js -h
|
||||||
|
usage: example.js [-h] [-v] [-f FOO] [-b BAR] [--baz BAZ]
|
||||||
|
|
||||||
|
Argparse example
|
||||||
|
|
||||||
|
Optional arguments:
|
||||||
|
-h, --help Show this help message and exit.
|
||||||
|
-v, --version Show program's version number and exit.
|
||||||
|
-f FOO, --foo FOO foo bar
|
||||||
|
-b BAR, --bar BAR bar foo
|
||||||
|
--baz BAZ baz bar
|
||||||
|
```
|
||||||
|
|
||||||
|
Parse arguments:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ ./test.js -f=3 --bar=4 --baz 5
|
||||||
|
{ foo: '3', bar: '4', baz: '5' }
|
||||||
|
```
|
||||||
|
|
||||||
|
More [examples](https://github.com/nodeca/argparse/tree/master/examples).
|
||||||
|
|
||||||
|
|
||||||
|
ArgumentParser objects
|
||||||
|
======================
|
||||||
|
|
||||||
|
```
|
||||||
|
new ArgumentParser({parameters hash});
|
||||||
|
```
|
||||||
|
|
||||||
|
Creates a new ArgumentParser object.
|
||||||
|
|
||||||
|
**Supported params:**
|
||||||
|
|
||||||
|
- ```description``` - Text to display before the argument help.
|
||||||
|
- ```epilog``` - Text to display after the argument help.
|
||||||
|
- ```addHelp``` - Add a -h/–help option to the parser. (default: true)
|
||||||
|
- ```argumentDefault``` - Set the global default value for arguments. (default: null)
|
||||||
|
- ```parents``` - A list of ArgumentParser objects whose arguments should also be included.
|
||||||
|
- ```prefixChars``` - The set of characters that prefix optional arguments. (default: ‘-‘)
|
||||||
|
- ```formatterClass``` - A class for customizing the help output.
|
||||||
|
- ```prog``` - The name of the program (default: `path.basename(process.argv[1])`)
|
||||||
|
- ```usage``` - The string describing the program usage (default: generated)
|
||||||
|
- ```conflictHandler``` - Usually unnecessary, defines strategy for resolving conflicting optionals.
|
||||||
|
|
||||||
|
**Not supported yet**
|
||||||
|
|
||||||
|
- ```fromfilePrefixChars``` - The set of characters that prefix files from which additional arguments should be read.
|
||||||
|
|
||||||
|
|
||||||
|
Details in [original ArgumentParser guide](http://docs.python.org/dev/library/argparse.html#argumentparser-objects)
|
||||||
|
|
||||||
|
|
||||||
|
addArgument() method
|
||||||
|
====================
|
||||||
|
|
||||||
|
```
|
||||||
|
ArgumentParser.addArgument(name or flag or [name] or [flags...], {options})
|
||||||
|
```
|
||||||
|
|
||||||
|
Defines how a single command-line argument should be parsed.
|
||||||
|
|
||||||
|
- ```name or flag or [name] or [flags...]``` - Either a positional name
|
||||||
|
(e.g., `'foo'`), a single option (e.g., `'-f'` or `'--foo'`), an array
|
||||||
|
of a single positional name (e.g., `['foo']`), or an array of options
|
||||||
|
(e.g., `['-f', '--foo']`).
|
||||||
|
|
||||||
|
Options:
|
||||||
|
|
||||||
|
- ```action``` - The basic type of action to be taken when this argument is encountered at the command line.
|
||||||
|
- ```nargs```- The number of command-line arguments that should be consumed.
|
||||||
|
- ```constant``` - A constant value required by some action and nargs selections.
|
||||||
|
- ```defaultValue``` - The value produced if the argument is absent from the command line.
|
||||||
|
- ```type``` - The type to which the command-line argument should be converted.
|
||||||
|
- ```choices``` - A container of the allowable values for the argument.
|
||||||
|
- ```required``` - Whether or not the command-line option may be omitted (optionals only).
|
||||||
|
- ```help``` - A brief description of what the argument does.
|
||||||
|
- ```metavar``` - A name for the argument in usage messages.
|
||||||
|
- ```dest``` - The name of the attribute to be added to the object returned by parseArgs().
|
||||||
|
|
||||||
|
Details in [original add_argument guide](http://docs.python.org/dev/library/argparse.html#the-add-argument-method)
|
||||||
|
|
||||||
|
|
||||||
|
Action (some details)
|
||||||
|
================
|
||||||
|
|
||||||
|
ArgumentParser objects associate command-line arguments with actions.
|
||||||
|
These actions can do just about anything with the command-line arguments associated
|
||||||
|
with them, though most actions simply add an attribute to the object returned by
|
||||||
|
parseArgs(). The action keyword argument specifies how the command-line arguments
|
||||||
|
should be handled. The supported actions are:
|
||||||
|
|
||||||
|
- ```store``` - Just stores the argument’s value. This is the default action.
|
||||||
|
- ```storeConst``` - Stores value, specified by the const keyword argument.
|
||||||
|
(Note that the const keyword argument defaults to the rather unhelpful None.)
|
||||||
|
The 'storeConst' action is most commonly used with optional arguments, that
|
||||||
|
specify some sort of flag.
|
||||||
|
- ```storeTrue``` and ```storeFalse``` - Stores values True and False
|
||||||
|
respectively. These are special cases of 'storeConst'.
|
||||||
|
- ```append``` - Stores a list, and appends each argument value to the list.
|
||||||
|
This is useful to allow an option to be specified multiple times.
|
||||||
|
- ```appendConst``` - Stores a list, and appends value, specified by the
|
||||||
|
const keyword argument to the list. (Note, that the const keyword argument defaults
|
||||||
|
is None.) The 'appendConst' action is typically used when multiple arguments need
|
||||||
|
to store constants to the same list.
|
||||||
|
- ```count``` - Counts the number of times a keyword argument occurs. For example,
|
||||||
|
used for increasing verbosity levels.
|
||||||
|
- ```help``` - Prints a complete help message for all the options in the current
|
||||||
|
parser and then exits. By default a help action is automatically added to the parser.
|
||||||
|
See ArgumentParser for details of how the output is created.
|
||||||
|
- ```version``` - Prints version information and exit. Expects a `version=`
|
||||||
|
keyword argument in the addArgument() call.
|
||||||
|
|
||||||
|
Details in [original action guide](http://docs.python.org/dev/library/argparse.html#action)
|
||||||
|
|
||||||
|
|
||||||
|
Sub-commands
|
||||||
|
============
|
||||||
|
|
||||||
|
ArgumentParser.addSubparsers()
|
||||||
|
|
||||||
|
Many programs split their functionality into a number of sub-commands, for
|
||||||
|
example, the svn program can invoke sub-commands like `svn checkout`, `svn update`,
|
||||||
|
and `svn commit`. Splitting up functionality this way can be a particularly good
|
||||||
|
idea when a program performs several different functions which require different
|
||||||
|
kinds of command-line arguments. `ArgumentParser` supports creation of such
|
||||||
|
sub-commands with `addSubparsers()` method. The `addSubparsers()` method is
|
||||||
|
normally called with no arguments and returns an special action object.
|
||||||
|
This object has a single method `addParser()`, which takes a command name and
|
||||||
|
any `ArgumentParser` constructor arguments, and returns an `ArgumentParser` object
|
||||||
|
that can be modified as usual.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
sub_commands.js
|
||||||
|
```javascript
|
||||||
|
#!/usr/bin/env node
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var ArgumentParser = require('../lib/argparse').ArgumentParser;
|
||||||
|
var parser = new ArgumentParser({
|
||||||
|
version: '0.0.1',
|
||||||
|
addHelp:true,
|
||||||
|
description: 'Argparse examples: sub-commands',
|
||||||
|
});
|
||||||
|
|
||||||
|
var subparsers = parser.addSubparsers({
|
||||||
|
title:'subcommands',
|
||||||
|
dest:"subcommand_name"
|
||||||
|
});
|
||||||
|
|
||||||
|
var bar = subparsers.addParser('c1', {addHelp:true});
|
||||||
|
bar.addArgument(
|
||||||
|
[ '-f', '--foo' ],
|
||||||
|
{
|
||||||
|
action: 'store',
|
||||||
|
help: 'foo3 bar3'
|
||||||
|
}
|
||||||
|
);
|
||||||
|
var bar = subparsers.addParser(
|
||||||
|
'c2',
|
||||||
|
{aliases:['co'], addHelp:true}
|
||||||
|
);
|
||||||
|
bar.addArgument(
|
||||||
|
[ '-b', '--bar' ],
|
||||||
|
{
|
||||||
|
action: 'store',
|
||||||
|
type: 'int',
|
||||||
|
help: 'foo3 bar3'
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
var args = parser.parseArgs();
|
||||||
|
console.dir(args);
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
Details in [original sub-commands guide](http://docs.python.org/dev/library/argparse.html#sub-commands)
|
||||||
|
|
||||||
|
|
||||||
|
Contributors
|
||||||
|
============
|
||||||
|
|
||||||
|
- [Eugene Shkuropat](https://github.com/shkuropat)
|
||||||
|
- [Paul Jacobson](https://github.com/hpaulj)
|
||||||
|
|
||||||
|
[others](https://github.com/nodeca/argparse/graphs/contributors)
|
||||||
|
|
||||||
|
License
|
||||||
|
=======
|
||||||
|
|
||||||
|
Copyright (c) 2012 [Vitaly Puzrin](https://github.com/puzrin).
|
||||||
|
Released under the MIT license. See
|
||||||
|
[LICENSE](https://github.com/nodeca/argparse/blob/master/LICENSE) for details.
|
||||||
|
|
||||||
|
|
||||||
3
node/node_modules/argparse/index.js
generated
vendored
Normal file
3
node/node_modules/argparse/index.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = require('./lib/argparse');
|
||||||
146
node/node_modules/argparse/lib/action.js
generated
vendored
Normal file
146
node/node_modules/argparse/lib/action.js
generated
vendored
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
/**
|
||||||
|
* class Action
|
||||||
|
*
|
||||||
|
* Base class for all actions
|
||||||
|
* Do not call in your code, use this class only for inherits your own action
|
||||||
|
*
|
||||||
|
* Information about how to convert command line strings to Javascript objects.
|
||||||
|
* Action objects are used by an ArgumentParser to represent the information
|
||||||
|
* needed to parse a single argument from one or more strings from the command
|
||||||
|
* line. The keyword arguments to the Action constructor are also all attributes
|
||||||
|
* of Action instances.
|
||||||
|
*
|
||||||
|
* ##### Allowed keywords:
|
||||||
|
*
|
||||||
|
* - `store`
|
||||||
|
* - `storeConstant`
|
||||||
|
* - `storeTrue`
|
||||||
|
* - `storeFalse`
|
||||||
|
* - `append`
|
||||||
|
* - `appendConstant`
|
||||||
|
* - `count`
|
||||||
|
* - `help`
|
||||||
|
* - `version`
|
||||||
|
*
|
||||||
|
* Information about action options see [[Action.new]]
|
||||||
|
*
|
||||||
|
* See also [original guide](http://docs.python.org/dev/library/argparse.html#action)
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
|
// Constants
|
||||||
|
var c = require('./const');
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* new Action(options)
|
||||||
|
*
|
||||||
|
* Base class for all actions. Used only for inherits
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* ##### Options:
|
||||||
|
*
|
||||||
|
* - `optionStrings` A list of command-line option strings for the action.
|
||||||
|
* - `dest` Attribute to hold the created object(s)
|
||||||
|
* - `nargs` The number of command-line arguments that should be consumed.
|
||||||
|
* By default, one argument will be consumed and a single value will be
|
||||||
|
* produced.
|
||||||
|
* - `constant` Default value for an action with no value.
|
||||||
|
* - `defaultValue` The value to be produced if the option is not specified.
|
||||||
|
* - `type` Cast to 'string'|'int'|'float'|'complex'|function (string). If
|
||||||
|
* None, 'string'.
|
||||||
|
* - `choices` The choices available.
|
||||||
|
* - `required` True if the action must always be specified at the command
|
||||||
|
* line.
|
||||||
|
* - `help` The help describing the argument.
|
||||||
|
* - `metavar` The name to be used for the option's argument with the help
|
||||||
|
* string. If None, the 'dest' value will be used as the name.
|
||||||
|
*
|
||||||
|
* ##### nargs supported values:
|
||||||
|
*
|
||||||
|
* - `N` (an integer) consumes N arguments (and produces a list)
|
||||||
|
* - `?` consumes zero or one arguments
|
||||||
|
* - `*` consumes zero or more arguments (and produces a list)
|
||||||
|
* - `+` consumes one or more arguments (and produces a list)
|
||||||
|
*
|
||||||
|
* Note: that the difference between the default and nargs=1 is that with the
|
||||||
|
* default, a single value will be produced, while with nargs=1, a list
|
||||||
|
* containing a single value will be produced.
|
||||||
|
**/
|
||||||
|
var Action = module.exports = function Action(options) {
|
||||||
|
options = options || {};
|
||||||
|
this.optionStrings = options.optionStrings || [];
|
||||||
|
this.dest = options.dest;
|
||||||
|
this.nargs = typeof options.nargs !== 'undefined' ? options.nargs : null;
|
||||||
|
this.constant = typeof options.constant !== 'undefined' ? options.constant : null;
|
||||||
|
this.defaultValue = options.defaultValue;
|
||||||
|
this.type = typeof options.type !== 'undefined' ? options.type : null;
|
||||||
|
this.choices = typeof options.choices !== 'undefined' ? options.choices : null;
|
||||||
|
this.required = typeof options.required !== 'undefined' ? options.required : false;
|
||||||
|
this.help = typeof options.help !== 'undefined' ? options.help : null;
|
||||||
|
this.metavar = typeof options.metavar !== 'undefined' ? options.metavar : null;
|
||||||
|
|
||||||
|
if (!(this.optionStrings instanceof Array)) {
|
||||||
|
throw new Error('optionStrings should be an array');
|
||||||
|
}
|
||||||
|
if (typeof this.required !== 'undefined' && typeof this.required !== 'boolean') {
|
||||||
|
throw new Error('required should be a boolean');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action#getName -> String
|
||||||
|
*
|
||||||
|
* Tells action name
|
||||||
|
**/
|
||||||
|
Action.prototype.getName = function () {
|
||||||
|
if (this.optionStrings.length > 0) {
|
||||||
|
return this.optionStrings.join('/');
|
||||||
|
} else if (this.metavar !== null && this.metavar !== c.SUPPRESS) {
|
||||||
|
return this.metavar;
|
||||||
|
} else if (typeof this.dest !== 'undefined' && this.dest !== c.SUPPRESS) {
|
||||||
|
return this.dest;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action#isOptional -> Boolean
|
||||||
|
*
|
||||||
|
* Return true if optional
|
||||||
|
**/
|
||||||
|
Action.prototype.isOptional = function () {
|
||||||
|
return !this.isPositional();
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action#isPositional -> Boolean
|
||||||
|
*
|
||||||
|
* Return true if positional
|
||||||
|
**/
|
||||||
|
Action.prototype.isPositional = function () {
|
||||||
|
return (this.optionStrings.length === 0);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action#call(parser, namespace, values, optionString) -> Void
|
||||||
|
* - parser (ArgumentParser): current parser
|
||||||
|
* - namespace (Namespace): namespace for output data
|
||||||
|
* - values (Array): parsed values
|
||||||
|
* - optionString (Array): input option string(not parsed)
|
||||||
|
*
|
||||||
|
* Call the action. Should be implemented in inherited classes
|
||||||
|
*
|
||||||
|
* ##### Example
|
||||||
|
*
|
||||||
|
* ActionCount.prototype.call = function (parser, namespace, values, optionString) {
|
||||||
|
* namespace.set(this.dest, (namespace[this.dest] || 0) + 1);
|
||||||
|
* };
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
Action.prototype.call = function () {
|
||||||
|
throw new Error('.call() not defined');// Not Implemented error
|
||||||
|
};
|
||||||
53
node/node_modules/argparse/lib/action/append.js
generated
vendored
Normal file
53
node/node_modules/argparse/lib/action/append.js
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
/*:nodoc:*
|
||||||
|
* class ActionAppend
|
||||||
|
*
|
||||||
|
* This action stores a list, and appends each argument value to the list.
|
||||||
|
* This is useful to allow an option to be specified multiple times.
|
||||||
|
* This class inherided from [[Action]]
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var util = require('util');
|
||||||
|
|
||||||
|
var Action = require('../action');
|
||||||
|
|
||||||
|
// Constants
|
||||||
|
var c = require('../const');
|
||||||
|
|
||||||
|
/*:nodoc:*
|
||||||
|
* new ActionAppend(options)
|
||||||
|
* - options (object): options hash see [[Action.new]]
|
||||||
|
*
|
||||||
|
* Note: options.nargs should be optional for constants
|
||||||
|
* and more then zero for other
|
||||||
|
**/
|
||||||
|
var ActionAppend = module.exports = function ActionAppend(options) {
|
||||||
|
options = options || {};
|
||||||
|
if (this.nargs <= 0) {
|
||||||
|
throw new Error('nargs for append actions must be > 0; if arg ' +
|
||||||
|
'strings are not supplying the value to append, ' +
|
||||||
|
'the append const action may be more appropriate');
|
||||||
|
}
|
||||||
|
if (!!this.constant && this.nargs !== c.OPTIONAL) {
|
||||||
|
throw new Error('nargs must be OPTIONAL to supply const');
|
||||||
|
}
|
||||||
|
Action.call(this, options);
|
||||||
|
};
|
||||||
|
util.inherits(ActionAppend, Action);
|
||||||
|
|
||||||
|
/*:nodoc:*
|
||||||
|
* ActionAppend#call(parser, namespace, values, optionString) -> Void
|
||||||
|
* - parser (ArgumentParser): current parser
|
||||||
|
* - namespace (Namespace): namespace for output data
|
||||||
|
* - values (Array): parsed values
|
||||||
|
* - optionString (Array): input option string(not parsed)
|
||||||
|
*
|
||||||
|
* Call the action. Save result in namespace object
|
||||||
|
**/
|
||||||
|
ActionAppend.prototype.call = function (parser, namespace, values) {
|
||||||
|
var items = (namespace[this.dest] || []).slice();
|
||||||
|
items.push(values);
|
||||||
|
namespace.set(this.dest, items);
|
||||||
|
};
|
||||||
47
node/node_modules/argparse/lib/action/append/constant.js
generated
vendored
Normal file
47
node/node_modules/argparse/lib/action/append/constant.js
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
/*:nodoc:*
|
||||||
|
* class ActionAppendConstant
|
||||||
|
*
|
||||||
|
* This stores a list, and appends the value specified by
|
||||||
|
* the const keyword argument to the list.
|
||||||
|
* (Note that the const keyword argument defaults to null.)
|
||||||
|
* The 'appendConst' action is typically useful when multiple
|
||||||
|
* arguments need to store constants to the same list.
|
||||||
|
*
|
||||||
|
* This class inherited from [[Action]]
|
||||||
|
**/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var util = require('util');
|
||||||
|
|
||||||
|
var Action = require('../../action');
|
||||||
|
|
||||||
|
/*:nodoc:*
|
||||||
|
* new ActionAppendConstant(options)
|
||||||
|
* - options (object): options hash see [[Action.new]]
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
var ActionAppendConstant = module.exports = function ActionAppendConstant(options) {
|
||||||
|
options = options || {};
|
||||||
|
options.nargs = 0;
|
||||||
|
if (typeof options.constant === 'undefined') {
|
||||||
|
throw new Error('constant option is required for appendAction');
|
||||||
|
}
|
||||||
|
Action.call(this, options);
|
||||||
|
};
|
||||||
|
util.inherits(ActionAppendConstant, Action);
|
||||||
|
|
||||||
|
/*:nodoc:*
|
||||||
|
* ActionAppendConstant#call(parser, namespace, values, optionString) -> Void
|
||||||
|
* - parser (ArgumentParser): current parser
|
||||||
|
* - namespace (Namespace): namespace for output data
|
||||||
|
* - values (Array): parsed values
|
||||||
|
* - optionString (Array): input option string(not parsed)
|
||||||
|
*
|
||||||
|
* Call the action. Save result in namespace object
|
||||||
|
**/
|
||||||
|
ActionAppendConstant.prototype.call = function (parser, namespace) {
|
||||||
|
var items = [].concat(namespace[this.dest] || []);
|
||||||
|
items.push(this.constant);
|
||||||
|
namespace.set(this.dest, items);
|
||||||
|
};
|
||||||
40
node/node_modules/argparse/lib/action/count.js
generated
vendored
Normal file
40
node/node_modules/argparse/lib/action/count.js
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
/*:nodoc:*
|
||||||
|
* class ActionCount
|
||||||
|
*
|
||||||
|
* This counts the number of times a keyword argument occurs.
|
||||||
|
* For example, this is useful for increasing verbosity levels
|
||||||
|
*
|
||||||
|
* This class inherided from [[Action]]
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var util = require('util');
|
||||||
|
|
||||||
|
var Action = require('../action');
|
||||||
|
|
||||||
|
/*:nodoc:*
|
||||||
|
* new ActionCount(options)
|
||||||
|
* - options (object): options hash see [[Action.new]]
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
var ActionCount = module.exports = function ActionCount(options) {
|
||||||
|
options = options || {};
|
||||||
|
options.nargs = 0;
|
||||||
|
|
||||||
|
Action.call(this, options);
|
||||||
|
};
|
||||||
|
util.inherits(ActionCount, Action);
|
||||||
|
|
||||||
|
/*:nodoc:*
|
||||||
|
* ActionCount#call(parser, namespace, values, optionString) -> Void
|
||||||
|
* - parser (ArgumentParser): current parser
|
||||||
|
* - namespace (Namespace): namespace for output data
|
||||||
|
* - values (Array): parsed values
|
||||||
|
* - optionString (Array): input option string(not parsed)
|
||||||
|
*
|
||||||
|
* Call the action. Save result in namespace object
|
||||||
|
**/
|
||||||
|
ActionCount.prototype.call = function (parser, namespace) {
|
||||||
|
namespace.set(this.dest, (namespace[this.dest] || 0) + 1);
|
||||||
|
};
|
||||||
47
node/node_modules/argparse/lib/action/help.js
generated
vendored
Normal file
47
node/node_modules/argparse/lib/action/help.js
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
/*:nodoc:*
|
||||||
|
* class ActionHelp
|
||||||
|
*
|
||||||
|
* Support action for printing help
|
||||||
|
* This class inherided from [[Action]]
|
||||||
|
**/
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var util = require('util');
|
||||||
|
|
||||||
|
var Action = require('../action');
|
||||||
|
|
||||||
|
// Constants
|
||||||
|
var c = require('../const');
|
||||||
|
|
||||||
|
/*:nodoc:*
|
||||||
|
* new ActionHelp(options)
|
||||||
|
* - options (object): options hash see [[Action.new]]
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
var ActionHelp = module.exports = function ActionHelp(options) {
|
||||||
|
options = options || {};
|
||||||
|
if (options.defaultValue !== null) {
|
||||||
|
options.defaultValue = options.defaultValue;
|
||||||
|
} else {
|
||||||
|
options.defaultValue = c.SUPPRESS;
|
||||||
|
}
|
||||||
|
options.dest = (options.dest !== null ? options.dest : c.SUPPRESS);
|
||||||
|
options.nargs = 0;
|
||||||
|
Action.call(this, options);
|
||||||
|
|
||||||
|
};
|
||||||
|
util.inherits(ActionHelp, Action);
|
||||||
|
|
||||||
|
/*:nodoc:*
|
||||||
|
* ActionHelp#call(parser, namespace, values, optionString)
|
||||||
|
* - parser (ArgumentParser): current parser
|
||||||
|
* - namespace (Namespace): namespace for output data
|
||||||
|
* - values (Array): parsed values
|
||||||
|
* - optionString (Array): input option string(not parsed)
|
||||||
|
*
|
||||||
|
* Print help and exit
|
||||||
|
**/
|
||||||
|
ActionHelp.prototype.call = function (parser) {
|
||||||
|
parser.printHelp();
|
||||||
|
parser.exit();
|
||||||
|
};
|
||||||
50
node/node_modules/argparse/lib/action/store.js
generated
vendored
Normal file
50
node/node_modules/argparse/lib/action/store.js
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
/*:nodoc:*
|
||||||
|
* class ActionStore
|
||||||
|
*
|
||||||
|
* This action just stores the argument’s value. This is the default action.
|
||||||
|
*
|
||||||
|
* This class inherited from [[Action]]
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var util = require('util');
|
||||||
|
|
||||||
|
var Action = require('../action');
|
||||||
|
|
||||||
|
// Constants
|
||||||
|
var c = require('../const');
|
||||||
|
|
||||||
|
|
||||||
|
/*:nodoc:*
|
||||||
|
* new ActionStore(options)
|
||||||
|
* - options (object): options hash see [[Action.new]]
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
var ActionStore = module.exports = function ActionStore(options) {
|
||||||
|
options = options || {};
|
||||||
|
if (this.nargs <= 0) {
|
||||||
|
throw new Error('nargs for store actions must be > 0; if you ' +
|
||||||
|
'have nothing to store, actions such as store ' +
|
||||||
|
'true or store const may be more appropriate');
|
||||||
|
|
||||||
|
}
|
||||||
|
if (typeof this.constant !== 'undefined' && this.nargs !== c.OPTIONAL) {
|
||||||
|
throw new Error('nargs must be OPTIONAL to supply const');
|
||||||
|
}
|
||||||
|
Action.call(this, options);
|
||||||
|
};
|
||||||
|
util.inherits(ActionStore, Action);
|
||||||
|
|
||||||
|
/*:nodoc:*
|
||||||
|
* ActionStore#call(parser, namespace, values, optionString) -> Void
|
||||||
|
* - parser (ArgumentParser): current parser
|
||||||
|
* - namespace (Namespace): namespace for output data
|
||||||
|
* - values (Array): parsed values
|
||||||
|
* - optionString (Array): input option string(not parsed)
|
||||||
|
*
|
||||||
|
* Call the action. Save result in namespace object
|
||||||
|
**/
|
||||||
|
ActionStore.prototype.call = function (parser, namespace, values) {
|
||||||
|
namespace.set(this.dest, values);
|
||||||
|
};
|
||||||
43
node/node_modules/argparse/lib/action/store/constant.js
generated
vendored
Normal file
43
node/node_modules/argparse/lib/action/store/constant.js
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
/*:nodoc:*
|
||||||
|
* class ActionStoreConstant
|
||||||
|
*
|
||||||
|
* This action stores the value specified by the const keyword argument.
|
||||||
|
* (Note that the const keyword argument defaults to the rather unhelpful null.)
|
||||||
|
* The 'store_const' action is most commonly used with optional
|
||||||
|
* arguments that specify some sort of flag.
|
||||||
|
*
|
||||||
|
* This class inherited from [[Action]]
|
||||||
|
**/
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var util = require('util');
|
||||||
|
|
||||||
|
var Action = require('../../action');
|
||||||
|
|
||||||
|
/*:nodoc:*
|
||||||
|
* new ActionStoreConstant(options)
|
||||||
|
* - options (object): options hash see [[Action.new]]
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
var ActionStoreConstant = module.exports = function ActionStoreConstant(options) {
|
||||||
|
options = options || {};
|
||||||
|
options.nargs = 0;
|
||||||
|
if (typeof options.constant === 'undefined') {
|
||||||
|
throw new Error('constant option is required for storeAction');
|
||||||
|
}
|
||||||
|
Action.call(this, options);
|
||||||
|
};
|
||||||
|
util.inherits(ActionStoreConstant, Action);
|
||||||
|
|
||||||
|
/*:nodoc:*
|
||||||
|
* ActionStoreConstant#call(parser, namespace, values, optionString) -> Void
|
||||||
|
* - parser (ArgumentParser): current parser
|
||||||
|
* - namespace (Namespace): namespace for output data
|
||||||
|
* - values (Array): parsed values
|
||||||
|
* - optionString (Array): input option string(not parsed)
|
||||||
|
*
|
||||||
|
* Call the action. Save result in namespace object
|
||||||
|
**/
|
||||||
|
ActionStoreConstant.prototype.call = function (parser, namespace) {
|
||||||
|
namespace.set(this.dest, this.constant);
|
||||||
|
};
|
||||||
27
node/node_modules/argparse/lib/action/store/false.js
generated
vendored
Normal file
27
node/node_modules/argparse/lib/action/store/false.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
/*:nodoc:*
|
||||||
|
* class ActionStoreFalse
|
||||||
|
*
|
||||||
|
* This action store the values False respectively.
|
||||||
|
* This is special cases of 'storeConst'
|
||||||
|
*
|
||||||
|
* This class inherited from [[Action]]
|
||||||
|
**/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var util = require('util');
|
||||||
|
|
||||||
|
var ActionStoreConstant = require('./constant');
|
||||||
|
|
||||||
|
/*:nodoc:*
|
||||||
|
* new ActionStoreFalse(options)
|
||||||
|
* - options (object): hash of options see [[Action.new]]
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
var ActionStoreFalse = module.exports = function ActionStoreFalse(options) {
|
||||||
|
options = options || {};
|
||||||
|
options.constant = false;
|
||||||
|
options.defaultValue = options.defaultValue !== null ? options.defaultValue : true;
|
||||||
|
ActionStoreConstant.call(this, options);
|
||||||
|
};
|
||||||
|
util.inherits(ActionStoreFalse, ActionStoreConstant);
|
||||||
26
node/node_modules/argparse/lib/action/store/true.js
generated
vendored
Normal file
26
node/node_modules/argparse/lib/action/store/true.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
/*:nodoc:*
|
||||||
|
* class ActionStoreTrue
|
||||||
|
*
|
||||||
|
* This action store the values True respectively.
|
||||||
|
* This isspecial cases of 'storeConst'
|
||||||
|
*
|
||||||
|
* This class inherited from [[Action]]
|
||||||
|
**/
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var util = require('util');
|
||||||
|
|
||||||
|
var ActionStoreConstant = require('./constant');
|
||||||
|
|
||||||
|
/*:nodoc:*
|
||||||
|
* new ActionStoreTrue(options)
|
||||||
|
* - options (object): options hash see [[Action.new]]
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
var ActionStoreTrue = module.exports = function ActionStoreTrue(options) {
|
||||||
|
options = options || {};
|
||||||
|
options.constant = true;
|
||||||
|
options.defaultValue = options.defaultValue !== null ? options.defaultValue : false;
|
||||||
|
ActionStoreConstant.call(this, options);
|
||||||
|
};
|
||||||
|
util.inherits(ActionStoreTrue, ActionStoreConstant);
|
||||||
149
node/node_modules/argparse/lib/action/subparsers.js
generated
vendored
Normal file
149
node/node_modules/argparse/lib/action/subparsers.js
generated
vendored
Normal file
@@ -0,0 +1,149 @@
|
|||||||
|
/** internal
|
||||||
|
* class ActionSubparsers
|
||||||
|
*
|
||||||
|
* Support the creation of such sub-commands with the addSubparsers()
|
||||||
|
*
|
||||||
|
* This class inherited from [[Action]]
|
||||||
|
**/
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var util = require('util');
|
||||||
|
var format = require('util').format;
|
||||||
|
|
||||||
|
|
||||||
|
var Action = require('../action');
|
||||||
|
|
||||||
|
// Constants
|
||||||
|
var c = require('../const');
|
||||||
|
|
||||||
|
// Errors
|
||||||
|
var argumentErrorHelper = require('../argument/error');
|
||||||
|
|
||||||
|
|
||||||
|
/*:nodoc:*
|
||||||
|
* new ChoicesPseudoAction(name, help)
|
||||||
|
*
|
||||||
|
* Create pseudo action for correct help text
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
function ChoicesPseudoAction(name, help) {
|
||||||
|
var options = {
|
||||||
|
optionStrings: [],
|
||||||
|
dest: name,
|
||||||
|
help: help
|
||||||
|
};
|
||||||
|
|
||||||
|
Action.call(this, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
util.inherits(ChoicesPseudoAction, Action);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* new ActionSubparsers(options)
|
||||||
|
* - options (object): options hash see [[Action.new]]
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
function ActionSubparsers(options) {
|
||||||
|
options = options || {};
|
||||||
|
options.dest = options.dest || c.SUPPRESS;
|
||||||
|
options.nargs = c.PARSER;
|
||||||
|
|
||||||
|
this.debug = (options.debug === true);
|
||||||
|
|
||||||
|
this._progPrefix = options.prog;
|
||||||
|
this._parserClass = options.parserClass;
|
||||||
|
this._nameParserMap = {};
|
||||||
|
this._choicesActions = [];
|
||||||
|
|
||||||
|
options.choices = this._nameParserMap;
|
||||||
|
Action.call(this, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
util.inherits(ActionSubparsers, Action);
|
||||||
|
|
||||||
|
/*:nodoc:*
|
||||||
|
* ActionSubparsers#addParser(name, options) -> ArgumentParser
|
||||||
|
* - name (string): sub-command name
|
||||||
|
* - options (object): see [[ArgumentParser.new]]
|
||||||
|
*
|
||||||
|
* Note:
|
||||||
|
* addParser supports an additional aliases option,
|
||||||
|
* which allows multiple strings to refer to the same subparser.
|
||||||
|
* This example, like svn, aliases co as a shorthand for checkout
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
ActionSubparsers.prototype.addParser = function (name, options) {
|
||||||
|
var parser;
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
options = options || {};
|
||||||
|
|
||||||
|
options.debug = (this.debug === true);
|
||||||
|
|
||||||
|
// set program from the existing prefix
|
||||||
|
if (!options.prog) {
|
||||||
|
options.prog = this._progPrefix + ' ' + name;
|
||||||
|
}
|
||||||
|
|
||||||
|
var aliases = options.aliases || [];
|
||||||
|
|
||||||
|
// create a pseudo-action to hold the choice help
|
||||||
|
if (!!options.help || typeof options.help === 'string') {
|
||||||
|
var help = options.help;
|
||||||
|
delete options.help;
|
||||||
|
|
||||||
|
var choiceAction = new ChoicesPseudoAction(name, help);
|
||||||
|
this._choicesActions.push(choiceAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
// create the parser and add it to the map
|
||||||
|
parser = new this._parserClass(options);
|
||||||
|
this._nameParserMap[name] = parser;
|
||||||
|
|
||||||
|
// make parser available under aliases also
|
||||||
|
aliases.forEach(function (alias) {
|
||||||
|
self._nameParserMap[alias] = parser;
|
||||||
|
});
|
||||||
|
|
||||||
|
return parser;
|
||||||
|
};
|
||||||
|
|
||||||
|
ActionSubparsers.prototype._getSubactions = function () {
|
||||||
|
return this._choicesActions;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*:nodoc:*
|
||||||
|
* ActionSubparsers#call(parser, namespace, values, optionString) -> Void
|
||||||
|
* - parser (ArgumentParser): current parser
|
||||||
|
* - namespace (Namespace): namespace for output data
|
||||||
|
* - values (Array): parsed values
|
||||||
|
* - optionString (Array): input option string(not parsed)
|
||||||
|
*
|
||||||
|
* Call the action. Parse input aguments
|
||||||
|
**/
|
||||||
|
ActionSubparsers.prototype.call = function (parser, namespace, values) {
|
||||||
|
var parserName = values[0];
|
||||||
|
var argStrings = values.slice(1);
|
||||||
|
|
||||||
|
// set the parser name if requested
|
||||||
|
if (this.dest !== c.SUPPRESS) {
|
||||||
|
namespace[this.dest] = parserName;
|
||||||
|
}
|
||||||
|
|
||||||
|
// select the parser
|
||||||
|
if (this._nameParserMap[parserName]) {
|
||||||
|
parser = this._nameParserMap[parserName];
|
||||||
|
} else {
|
||||||
|
throw argumentErrorHelper(format(
|
||||||
|
'Unknown parser "%s" (choices: [%s]).',
|
||||||
|
parserName,
|
||||||
|
Object.keys(this._nameParserMap).join(', ')
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
// parse all the remaining options into the namespace
|
||||||
|
parser.parseArgs(argStrings, namespace);
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = ActionSubparsers;
|
||||||
47
node/node_modules/argparse/lib/action/version.js
generated
vendored
Normal file
47
node/node_modules/argparse/lib/action/version.js
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
/*:nodoc:*
|
||||||
|
* class ActionVersion
|
||||||
|
*
|
||||||
|
* Support action for printing program version
|
||||||
|
* This class inherited from [[Action]]
|
||||||
|
**/
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var util = require('util');
|
||||||
|
|
||||||
|
var Action = require('../action');
|
||||||
|
|
||||||
|
//
|
||||||
|
// Constants
|
||||||
|
//
|
||||||
|
var c = require('../const');
|
||||||
|
|
||||||
|
/*:nodoc:*
|
||||||
|
* new ActionVersion(options)
|
||||||
|
* - options (object): options hash see [[Action.new]]
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
var ActionVersion = module.exports = function ActionVersion(options) {
|
||||||
|
options = options || {};
|
||||||
|
options.defaultValue = (options.defaultValue ? options.defaultValue : c.SUPPRESS);
|
||||||
|
options.dest = (options.dest || c.SUPPRESS);
|
||||||
|
options.nargs = 0;
|
||||||
|
this.version = options.version;
|
||||||
|
Action.call(this, options);
|
||||||
|
};
|
||||||
|
util.inherits(ActionVersion, Action);
|
||||||
|
|
||||||
|
/*:nodoc:*
|
||||||
|
* ActionVersion#call(parser, namespace, values, optionString) -> Void
|
||||||
|
* - parser (ArgumentParser): current parser
|
||||||
|
* - namespace (Namespace): namespace for output data
|
||||||
|
* - values (Array): parsed values
|
||||||
|
* - optionString (Array): input option string(not parsed)
|
||||||
|
*
|
||||||
|
* Print version and exit
|
||||||
|
**/
|
||||||
|
ActionVersion.prototype.call = function (parser) {
|
||||||
|
var version = this.version || parser.version;
|
||||||
|
var formatter = parser._getFormatter();
|
||||||
|
formatter.addText(version);
|
||||||
|
parser.exit(0, formatter.formatHelp());
|
||||||
|
};
|
||||||
482
node/node_modules/argparse/lib/action_container.js
generated
vendored
Normal file
482
node/node_modules/argparse/lib/action_container.js
generated
vendored
Normal file
@@ -0,0 +1,482 @@
|
|||||||
|
/** internal
|
||||||
|
* class ActionContainer
|
||||||
|
*
|
||||||
|
* Action container. Parent for [[ArgumentParser]] and [[ArgumentGroup]]
|
||||||
|
**/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var format = require('util').format;
|
||||||
|
|
||||||
|
// Constants
|
||||||
|
var c = require('./const');
|
||||||
|
|
||||||
|
var $$ = require('./utils');
|
||||||
|
|
||||||
|
//Actions
|
||||||
|
var ActionHelp = require('./action/help');
|
||||||
|
var ActionAppend = require('./action/append');
|
||||||
|
var ActionAppendConstant = require('./action/append/constant');
|
||||||
|
var ActionCount = require('./action/count');
|
||||||
|
var ActionStore = require('./action/store');
|
||||||
|
var ActionStoreConstant = require('./action/store/constant');
|
||||||
|
var ActionStoreTrue = require('./action/store/true');
|
||||||
|
var ActionStoreFalse = require('./action/store/false');
|
||||||
|
var ActionVersion = require('./action/version');
|
||||||
|
var ActionSubparsers = require('./action/subparsers');
|
||||||
|
|
||||||
|
// Errors
|
||||||
|
var argumentErrorHelper = require('./argument/error');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* new ActionContainer(options)
|
||||||
|
*
|
||||||
|
* Action container. Parent for [[ArgumentParser]] and [[ArgumentGroup]]
|
||||||
|
*
|
||||||
|
* ##### Options:
|
||||||
|
*
|
||||||
|
* - `description` -- A description of what the program does
|
||||||
|
* - `prefixChars` -- Characters that prefix optional arguments
|
||||||
|
* - `argumentDefault` -- The default value for all arguments
|
||||||
|
* - `conflictHandler` -- The conflict handler to use for duplicate arguments
|
||||||
|
**/
|
||||||
|
var ActionContainer = module.exports = function ActionContainer(options) {
|
||||||
|
options = options || {};
|
||||||
|
|
||||||
|
this.description = options.description;
|
||||||
|
this.argumentDefault = options.argumentDefault;
|
||||||
|
this.prefixChars = options.prefixChars || '';
|
||||||
|
this.conflictHandler = options.conflictHandler;
|
||||||
|
|
||||||
|
// set up registries
|
||||||
|
this._registries = {};
|
||||||
|
|
||||||
|
// register actions
|
||||||
|
this.register('action', null, ActionStore);
|
||||||
|
this.register('action', 'store', ActionStore);
|
||||||
|
this.register('action', 'storeConst', ActionStoreConstant);
|
||||||
|
this.register('action', 'storeTrue', ActionStoreTrue);
|
||||||
|
this.register('action', 'storeFalse', ActionStoreFalse);
|
||||||
|
this.register('action', 'append', ActionAppend);
|
||||||
|
this.register('action', 'appendConst', ActionAppendConstant);
|
||||||
|
this.register('action', 'count', ActionCount);
|
||||||
|
this.register('action', 'help', ActionHelp);
|
||||||
|
this.register('action', 'version', ActionVersion);
|
||||||
|
this.register('action', 'parsers', ActionSubparsers);
|
||||||
|
|
||||||
|
// raise an exception if the conflict handler is invalid
|
||||||
|
this._getHandler();
|
||||||
|
|
||||||
|
// action storage
|
||||||
|
this._actions = [];
|
||||||
|
this._optionStringActions = {};
|
||||||
|
|
||||||
|
// groups
|
||||||
|
this._actionGroups = [];
|
||||||
|
this._mutuallyExclusiveGroups = [];
|
||||||
|
|
||||||
|
// defaults storage
|
||||||
|
this._defaults = {};
|
||||||
|
|
||||||
|
// determines whether an "option" looks like a negative number
|
||||||
|
// -1, -1.5 -5e+4
|
||||||
|
this._regexpNegativeNumber = new RegExp('^[-]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?$');
|
||||||
|
|
||||||
|
// whether or not there are any optionals that look like negative
|
||||||
|
// numbers -- uses a list so it can be shared and edited
|
||||||
|
this._hasNegativeNumberOptionals = [];
|
||||||
|
};
|
||||||
|
|
||||||
|
// Groups must be required, then ActionContainer already defined
|
||||||
|
var ArgumentGroup = require('./argument/group');
|
||||||
|
var MutuallyExclusiveGroup = require('./argument/exclusive');
|
||||||
|
|
||||||
|
//
|
||||||
|
// Registration methods
|
||||||
|
//
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ActionContainer#register(registryName, value, object) -> Void
|
||||||
|
* - registryName (String) : object type action|type
|
||||||
|
* - value (string) : keyword
|
||||||
|
* - object (Object|Function) : handler
|
||||||
|
*
|
||||||
|
* Register handlers
|
||||||
|
**/
|
||||||
|
ActionContainer.prototype.register = function (registryName, value, object) {
|
||||||
|
this._registries[registryName] = this._registries[registryName] || {};
|
||||||
|
this._registries[registryName][value] = object;
|
||||||
|
};
|
||||||
|
|
||||||
|
ActionContainer.prototype._registryGet = function (registryName, value, defaultValue) {
|
||||||
|
if (arguments.length < 3) {
|
||||||
|
defaultValue = null;
|
||||||
|
}
|
||||||
|
return this._registries[registryName][value] || defaultValue;
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// Namespace default accessor methods
|
||||||
|
//
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ActionContainer#setDefaults(options) -> Void
|
||||||
|
* - options (object):hash of options see [[Action.new]]
|
||||||
|
*
|
||||||
|
* Set defaults
|
||||||
|
**/
|
||||||
|
ActionContainer.prototype.setDefaults = function (options) {
|
||||||
|
options = options || {};
|
||||||
|
for (var property in options) {
|
||||||
|
if ($$.has(options, property)) {
|
||||||
|
this._defaults[property] = options[property];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if these defaults match any existing arguments, replace the previous
|
||||||
|
// default on the object with the new one
|
||||||
|
this._actions.forEach(function (action) {
|
||||||
|
if ($$.has(options, action.dest)) {
|
||||||
|
action.defaultValue = options[action.dest];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ActionContainer#getDefault(dest) -> Mixed
|
||||||
|
* - dest (string): action destination
|
||||||
|
*
|
||||||
|
* Return action default value
|
||||||
|
**/
|
||||||
|
ActionContainer.prototype.getDefault = function (dest) {
|
||||||
|
var result = $$.has(this._defaults, dest) ? this._defaults[dest] : null;
|
||||||
|
|
||||||
|
this._actions.forEach(function (action) {
|
||||||
|
if (action.dest === dest && $$.has(action, 'defaultValue')) {
|
||||||
|
result = action.defaultValue;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
//
|
||||||
|
// Adding argument actions
|
||||||
|
//
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ActionContainer#addArgument(args, options) -> Object
|
||||||
|
* - args (String|Array): argument key, or array of argument keys
|
||||||
|
* - options (Object): action objects see [[Action.new]]
|
||||||
|
*
|
||||||
|
* #### Examples
|
||||||
|
* - addArgument([ '-f', '--foo' ], { action: 'store', defaultValue: 1, ... })
|
||||||
|
* - addArgument([ 'bar' ], { action: 'store', nargs: 1, ... })
|
||||||
|
* - addArgument('--baz', { action: 'store', nargs: 1, ... })
|
||||||
|
**/
|
||||||
|
ActionContainer.prototype.addArgument = function (args, options) {
|
||||||
|
args = args;
|
||||||
|
options = options || {};
|
||||||
|
|
||||||
|
if (typeof args === 'string') {
|
||||||
|
args = [ args ];
|
||||||
|
}
|
||||||
|
if (!Array.isArray(args)) {
|
||||||
|
throw new TypeError('addArgument first argument should be a string or an array');
|
||||||
|
}
|
||||||
|
if (typeof options !== 'object' || Array.isArray(options)) {
|
||||||
|
throw new TypeError('addArgument second argument should be a hash');
|
||||||
|
}
|
||||||
|
|
||||||
|
// if no positional args are supplied or only one is supplied and
|
||||||
|
// it doesn't look like an option string, parse a positional argument
|
||||||
|
if (!args || args.length === 1 && this.prefixChars.indexOf(args[0][0]) < 0) {
|
||||||
|
if (args && !!options.dest) {
|
||||||
|
throw new Error('dest supplied twice for positional argument');
|
||||||
|
}
|
||||||
|
options = this._getPositional(args, options);
|
||||||
|
|
||||||
|
// otherwise, we're adding an optional argument
|
||||||
|
} else {
|
||||||
|
options = this._getOptional(args, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
// if no default was supplied, use the parser-level default
|
||||||
|
if (typeof options.defaultValue === 'undefined') {
|
||||||
|
var dest = options.dest;
|
||||||
|
if ($$.has(this._defaults, dest)) {
|
||||||
|
options.defaultValue = this._defaults[dest];
|
||||||
|
} else if (typeof this.argumentDefault !== 'undefined') {
|
||||||
|
options.defaultValue = this.argumentDefault;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// create the action object, and add it to the parser
|
||||||
|
var ActionClass = this._popActionClass(options);
|
||||||
|
if (typeof ActionClass !== 'function') {
|
||||||
|
throw new Error(format('Unknown action "%s".', ActionClass));
|
||||||
|
}
|
||||||
|
var action = new ActionClass(options);
|
||||||
|
|
||||||
|
// throw an error if the action type is not callable
|
||||||
|
var typeFunction = this._registryGet('type', action.type, action.type);
|
||||||
|
if (typeof typeFunction !== 'function') {
|
||||||
|
throw new Error(format('"%s" is not callable', typeFunction));
|
||||||
|
}
|
||||||
|
|
||||||
|
return this._addAction(action);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ActionContainer#addArgumentGroup(options) -> ArgumentGroup
|
||||||
|
* - options (Object): hash of options see [[ArgumentGroup.new]]
|
||||||
|
*
|
||||||
|
* Create new arguments groups
|
||||||
|
**/
|
||||||
|
ActionContainer.prototype.addArgumentGroup = function (options) {
|
||||||
|
var group = new ArgumentGroup(this, options);
|
||||||
|
this._actionGroups.push(group);
|
||||||
|
return group;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ActionContainer#addMutuallyExclusiveGroup(options) -> ArgumentGroup
|
||||||
|
* - options (Object): {required: false}
|
||||||
|
*
|
||||||
|
* Create new mutual exclusive groups
|
||||||
|
**/
|
||||||
|
ActionContainer.prototype.addMutuallyExclusiveGroup = function (options) {
|
||||||
|
var group = new MutuallyExclusiveGroup(this, options);
|
||||||
|
this._mutuallyExclusiveGroups.push(group);
|
||||||
|
return group;
|
||||||
|
};
|
||||||
|
|
||||||
|
ActionContainer.prototype._addAction = function (action) {
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
// resolve any conflicts
|
||||||
|
this._checkConflict(action);
|
||||||
|
|
||||||
|
// add to actions list
|
||||||
|
this._actions.push(action);
|
||||||
|
action.container = this;
|
||||||
|
|
||||||
|
// index the action by any option strings it has
|
||||||
|
action.optionStrings.forEach(function (optionString) {
|
||||||
|
self._optionStringActions[optionString] = action;
|
||||||
|
});
|
||||||
|
|
||||||
|
// set the flag if any option strings look like negative numbers
|
||||||
|
action.optionStrings.forEach(function (optionString) {
|
||||||
|
if (optionString.match(self._regexpNegativeNumber)) {
|
||||||
|
if (!self._hasNegativeNumberOptionals.some(Boolean)) {
|
||||||
|
self._hasNegativeNumberOptionals.push(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// return the created action
|
||||||
|
return action;
|
||||||
|
};
|
||||||
|
|
||||||
|
ActionContainer.prototype._removeAction = function (action) {
|
||||||
|
var actionIndex = this._actions.indexOf(action);
|
||||||
|
if (actionIndex >= 0) {
|
||||||
|
this._actions.splice(actionIndex, 1);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ActionContainer.prototype._addContainerActions = function (container) {
|
||||||
|
// collect groups by titles
|
||||||
|
var titleGroupMap = {};
|
||||||
|
this._actionGroups.forEach(function (group) {
|
||||||
|
if (titleGroupMap[group.title]) {
|
||||||
|
throw new Error(format('Cannot merge actions - two groups are named "%s".', group.title));
|
||||||
|
}
|
||||||
|
titleGroupMap[group.title] = group;
|
||||||
|
});
|
||||||
|
|
||||||
|
// map each action to its group
|
||||||
|
var groupMap = {};
|
||||||
|
function actionHash(action) {
|
||||||
|
// unique (hopefully?) string suitable as dictionary key
|
||||||
|
return action.getName();
|
||||||
|
}
|
||||||
|
container._actionGroups.forEach(function (group) {
|
||||||
|
// if a group with the title exists, use that, otherwise
|
||||||
|
// create a new group matching the container's group
|
||||||
|
if (!titleGroupMap[group.title]) {
|
||||||
|
titleGroupMap[group.title] = this.addArgumentGroup({
|
||||||
|
title: group.title,
|
||||||
|
description: group.description
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// map the actions to their new group
|
||||||
|
group._groupActions.forEach(function (action) {
|
||||||
|
groupMap[actionHash(action)] = titleGroupMap[group.title];
|
||||||
|
});
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
// add container's mutually exclusive groups
|
||||||
|
// NOTE: if add_mutually_exclusive_group ever gains title= and
|
||||||
|
// description= then this code will need to be expanded as above
|
||||||
|
var mutexGroup;
|
||||||
|
container._mutuallyExclusiveGroups.forEach(function (group) {
|
||||||
|
mutexGroup = this.addMutuallyExclusiveGroup({
|
||||||
|
required: group.required
|
||||||
|
});
|
||||||
|
// map the actions to their new mutex group
|
||||||
|
group._groupActions.forEach(function (action) {
|
||||||
|
groupMap[actionHash(action)] = mutexGroup;
|
||||||
|
});
|
||||||
|
}, this); // forEach takes a 'this' argument
|
||||||
|
|
||||||
|
// add all actions to this container or their group
|
||||||
|
container._actions.forEach(function (action) {
|
||||||
|
var key = actionHash(action);
|
||||||
|
if (groupMap[key]) {
|
||||||
|
groupMap[key]._addAction(action);
|
||||||
|
} else {
|
||||||
|
this._addAction(action);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
ActionContainer.prototype._getPositional = function (dest, options) {
|
||||||
|
if (Array.isArray(dest)) {
|
||||||
|
dest = dest[0];
|
||||||
|
}
|
||||||
|
// make sure required is not specified
|
||||||
|
if (options.required) {
|
||||||
|
throw new Error('"required" is an invalid argument for positionals.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// mark positional arguments as required if at least one is
|
||||||
|
// always required
|
||||||
|
if (options.nargs !== c.OPTIONAL && options.nargs !== c.ZERO_OR_MORE) {
|
||||||
|
options.required = true;
|
||||||
|
}
|
||||||
|
if (options.nargs === c.ZERO_OR_MORE && typeof options.defaultValue === 'undefined') {
|
||||||
|
options.required = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// return the keyword arguments with no option strings
|
||||||
|
options.dest = dest;
|
||||||
|
options.optionStrings = [];
|
||||||
|
return options;
|
||||||
|
};
|
||||||
|
|
||||||
|
ActionContainer.prototype._getOptional = function (args, options) {
|
||||||
|
var prefixChars = this.prefixChars;
|
||||||
|
var optionStrings = [];
|
||||||
|
var optionStringsLong = [];
|
||||||
|
|
||||||
|
// determine short and long option strings
|
||||||
|
args.forEach(function (optionString) {
|
||||||
|
// error on strings that don't start with an appropriate prefix
|
||||||
|
if (prefixChars.indexOf(optionString[0]) < 0) {
|
||||||
|
throw new Error(format('Invalid option string "%s": must start with a "%s".',
|
||||||
|
optionString,
|
||||||
|
prefixChars
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
// strings starting with two prefix characters are long options
|
||||||
|
optionStrings.push(optionString);
|
||||||
|
if (optionString.length > 1 && prefixChars.indexOf(optionString[1]) >= 0) {
|
||||||
|
optionStringsLong.push(optionString);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// infer dest, '--foo-bar' -> 'foo_bar' and '-x' -> 'x'
|
||||||
|
var dest = options.dest || null;
|
||||||
|
delete options.dest;
|
||||||
|
|
||||||
|
if (!dest) {
|
||||||
|
var optionStringDest = optionStringsLong.length ? optionStringsLong[0] : optionStrings[0];
|
||||||
|
dest = $$.trimChars(optionStringDest, this.prefixChars);
|
||||||
|
|
||||||
|
if (dest.length === 0) {
|
||||||
|
throw new Error(
|
||||||
|
format('dest= is required for options like "%s"', optionStrings.join(', '))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
dest = dest.replace(/-/g, '_');
|
||||||
|
}
|
||||||
|
|
||||||
|
// return the updated keyword arguments
|
||||||
|
options.dest = dest;
|
||||||
|
options.optionStrings = optionStrings;
|
||||||
|
|
||||||
|
return options;
|
||||||
|
};
|
||||||
|
|
||||||
|
ActionContainer.prototype._popActionClass = function (options, defaultValue) {
|
||||||
|
defaultValue = defaultValue || null;
|
||||||
|
|
||||||
|
var action = (options.action || defaultValue);
|
||||||
|
delete options.action;
|
||||||
|
|
||||||
|
var actionClass = this._registryGet('action', action, action);
|
||||||
|
return actionClass;
|
||||||
|
};
|
||||||
|
|
||||||
|
ActionContainer.prototype._getHandler = function () {
|
||||||
|
var handlerString = this.conflictHandler;
|
||||||
|
var handlerFuncName = '_handleConflict' + $$.capitalize(handlerString);
|
||||||
|
var func = this[handlerFuncName];
|
||||||
|
if (typeof func === 'undefined') {
|
||||||
|
var msg = 'invalid conflict resolution value: ' + handlerString;
|
||||||
|
throw new Error(msg);
|
||||||
|
} else {
|
||||||
|
return func;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ActionContainer.prototype._checkConflict = function (action) {
|
||||||
|
var optionStringActions = this._optionStringActions;
|
||||||
|
var conflictOptionals = [];
|
||||||
|
|
||||||
|
// find all options that conflict with this option
|
||||||
|
// collect pairs, the string, and an existing action that it conflicts with
|
||||||
|
action.optionStrings.forEach(function (optionString) {
|
||||||
|
var conflOptional = optionStringActions[optionString];
|
||||||
|
if (typeof conflOptional !== 'undefined') {
|
||||||
|
conflictOptionals.push([ optionString, conflOptional ]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (conflictOptionals.length > 0) {
|
||||||
|
var conflictHandler = this._getHandler();
|
||||||
|
conflictHandler.call(this, action, conflictOptionals);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ActionContainer.prototype._handleConflictError = function (action, conflOptionals) {
|
||||||
|
var conflicts = conflOptionals.map(function (pair) { return pair[0]; });
|
||||||
|
conflicts = conflicts.join(', ');
|
||||||
|
throw argumentErrorHelper(
|
||||||
|
action,
|
||||||
|
format('Conflicting option string(s): %s', conflicts)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
ActionContainer.prototype._handleConflictResolve = function (action, conflOptionals) {
|
||||||
|
// remove all conflicting options
|
||||||
|
var self = this;
|
||||||
|
conflOptionals.forEach(function (pair) {
|
||||||
|
var optionString = pair[0];
|
||||||
|
var conflictingAction = pair[1];
|
||||||
|
// remove the conflicting option string
|
||||||
|
var i = conflictingAction.optionStrings.indexOf(optionString);
|
||||||
|
if (i >= 0) {
|
||||||
|
conflictingAction.optionStrings.splice(i, 1);
|
||||||
|
}
|
||||||
|
delete self._optionStringActions[optionString];
|
||||||
|
// if the option now has no option string, remove it from the
|
||||||
|
// container holding it
|
||||||
|
if (conflictingAction.optionStrings.length === 0) {
|
||||||
|
conflictingAction.container._removeAction(conflictingAction);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
14
node/node_modules/argparse/lib/argparse.js
generated
vendored
Normal file
14
node/node_modules/argparse/lib/argparse.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports.ArgumentParser = require('./argument_parser.js');
|
||||||
|
module.exports.Namespace = require('./namespace');
|
||||||
|
module.exports.Action = require('./action');
|
||||||
|
module.exports.HelpFormatter = require('./help/formatter.js');
|
||||||
|
module.exports.Const = require('./const.js');
|
||||||
|
|
||||||
|
module.exports.ArgumentDefaultsHelpFormatter =
|
||||||
|
require('./help/added_formatters.js').ArgumentDefaultsHelpFormatter;
|
||||||
|
module.exports.RawDescriptionHelpFormatter =
|
||||||
|
require('./help/added_formatters.js').RawDescriptionHelpFormatter;
|
||||||
|
module.exports.RawTextHelpFormatter =
|
||||||
|
require('./help/added_formatters.js').RawTextHelpFormatter;
|
||||||
50
node/node_modules/argparse/lib/argument/error.js
generated
vendored
Normal file
50
node/node_modules/argparse/lib/argument/error.js
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
|
var format = require('util').format;
|
||||||
|
|
||||||
|
|
||||||
|
var ERR_CODE = 'ARGError';
|
||||||
|
|
||||||
|
/*:nodoc:*
|
||||||
|
* argumentError(argument, message) -> TypeError
|
||||||
|
* - argument (Object): action with broken argument
|
||||||
|
* - message (String): error message
|
||||||
|
*
|
||||||
|
* Error format helper. An error from creating or using an argument
|
||||||
|
* (optional or positional). The string value of this exception
|
||||||
|
* is the message, augmented with information
|
||||||
|
* about the argument that caused it.
|
||||||
|
*
|
||||||
|
* #####Example
|
||||||
|
*
|
||||||
|
* var argumentErrorHelper = require('./argument/error');
|
||||||
|
* if (conflictOptionals.length > 0) {
|
||||||
|
* throw argumentErrorHelper(
|
||||||
|
* action,
|
||||||
|
* format('Conflicting option string(s): %s', conflictOptionals.join(', '))
|
||||||
|
* );
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
module.exports = function (argument, message) {
|
||||||
|
var argumentName = null;
|
||||||
|
var errMessage;
|
||||||
|
var err;
|
||||||
|
|
||||||
|
if (argument.getName) {
|
||||||
|
argumentName = argument.getName();
|
||||||
|
} else {
|
||||||
|
argumentName = '' + argument;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!argumentName) {
|
||||||
|
errMessage = message;
|
||||||
|
} else {
|
||||||
|
errMessage = format('argument "%s": %s', argumentName, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
err = new TypeError(errMessage);
|
||||||
|
err.code = ERR_CODE;
|
||||||
|
return err;
|
||||||
|
};
|
||||||
54
node/node_modules/argparse/lib/argument/exclusive.js
generated
vendored
Normal file
54
node/node_modules/argparse/lib/argument/exclusive.js
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
/** internal
|
||||||
|
* class MutuallyExclusiveGroup
|
||||||
|
*
|
||||||
|
* Group arguments.
|
||||||
|
* By default, ArgumentParser groups command-line arguments
|
||||||
|
* into “positional arguments” and “optional arguments”
|
||||||
|
* when displaying help messages. When there is a better
|
||||||
|
* conceptual grouping of arguments than this default one,
|
||||||
|
* appropriate groups can be created using the addArgumentGroup() method
|
||||||
|
*
|
||||||
|
* This class inherited from [[ArgumentContainer]]
|
||||||
|
**/
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var util = require('util');
|
||||||
|
|
||||||
|
var ArgumentGroup = require('./group');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* new MutuallyExclusiveGroup(container, options)
|
||||||
|
* - container (object): main container
|
||||||
|
* - options (object): options.required -> true/false
|
||||||
|
*
|
||||||
|
* `required` could be an argument itself, but making it a property of
|
||||||
|
* the options argument is more consistent with the JS adaptation of the Python)
|
||||||
|
**/
|
||||||
|
var MutuallyExclusiveGroup = module.exports = function MutuallyExclusiveGroup(container, options) {
|
||||||
|
var required;
|
||||||
|
options = options || {};
|
||||||
|
required = options.required || false;
|
||||||
|
ArgumentGroup.call(this, container);
|
||||||
|
this.required = required;
|
||||||
|
|
||||||
|
};
|
||||||
|
util.inherits(MutuallyExclusiveGroup, ArgumentGroup);
|
||||||
|
|
||||||
|
|
||||||
|
MutuallyExclusiveGroup.prototype._addAction = function (action) {
|
||||||
|
var msg;
|
||||||
|
if (action.required) {
|
||||||
|
msg = 'mutually exclusive arguments must be optional';
|
||||||
|
throw new Error(msg);
|
||||||
|
}
|
||||||
|
action = this._container._addAction(action);
|
||||||
|
this._groupActions.push(action);
|
||||||
|
return action;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
MutuallyExclusiveGroup.prototype._removeAction = function (action) {
|
||||||
|
this._container._removeAction(action);
|
||||||
|
this._groupActions.remove(action);
|
||||||
|
};
|
||||||
|
|
||||||
75
node/node_modules/argparse/lib/argument/group.js
generated
vendored
Normal file
75
node/node_modules/argparse/lib/argument/group.js
generated
vendored
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
/** internal
|
||||||
|
* class ArgumentGroup
|
||||||
|
*
|
||||||
|
* Group arguments.
|
||||||
|
* By default, ArgumentParser groups command-line arguments
|
||||||
|
* into “positional arguments” and “optional arguments”
|
||||||
|
* when displaying help messages. When there is a better
|
||||||
|
* conceptual grouping of arguments than this default one,
|
||||||
|
* appropriate groups can be created using the addArgumentGroup() method
|
||||||
|
*
|
||||||
|
* This class inherited from [[ArgumentContainer]]
|
||||||
|
**/
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var util = require('util');
|
||||||
|
|
||||||
|
var ActionContainer = require('../action_container');
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* new ArgumentGroup(container, options)
|
||||||
|
* - container (object): main container
|
||||||
|
* - options (object): hash of group options
|
||||||
|
*
|
||||||
|
* #### options
|
||||||
|
* - **prefixChars** group name prefix
|
||||||
|
* - **argumentDefault** default argument value
|
||||||
|
* - **title** group title
|
||||||
|
* - **description** group description
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
var ArgumentGroup = module.exports = function ArgumentGroup(container, options) {
|
||||||
|
|
||||||
|
options = options || {};
|
||||||
|
|
||||||
|
// add any missing keyword arguments by checking the container
|
||||||
|
options.conflictHandler = (options.conflictHandler || container.conflictHandler);
|
||||||
|
options.prefixChars = (options.prefixChars || container.prefixChars);
|
||||||
|
options.argumentDefault = (options.argumentDefault || container.argumentDefault);
|
||||||
|
|
||||||
|
ActionContainer.call(this, options);
|
||||||
|
|
||||||
|
// group attributes
|
||||||
|
this.title = options.title;
|
||||||
|
this._groupActions = [];
|
||||||
|
|
||||||
|
// share most attributes with the container
|
||||||
|
this._container = container;
|
||||||
|
this._registries = container._registries;
|
||||||
|
this._actions = container._actions;
|
||||||
|
this._optionStringActions = container._optionStringActions;
|
||||||
|
this._defaults = container._defaults;
|
||||||
|
this._hasNegativeNumberOptionals = container._hasNegativeNumberOptionals;
|
||||||
|
this._mutuallyExclusiveGroups = container._mutuallyExclusiveGroups;
|
||||||
|
};
|
||||||
|
util.inherits(ArgumentGroup, ActionContainer);
|
||||||
|
|
||||||
|
|
||||||
|
ArgumentGroup.prototype._addAction = function (action) {
|
||||||
|
// Parent add action
|
||||||
|
action = ActionContainer.prototype._addAction.call(this, action);
|
||||||
|
this._groupActions.push(action);
|
||||||
|
return action;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
ArgumentGroup.prototype._removeAction = function (action) {
|
||||||
|
// Parent remove action
|
||||||
|
ActionContainer.prototype._removeAction.call(this, action);
|
||||||
|
var actionIndex = this._groupActions.indexOf(action);
|
||||||
|
if (actionIndex >= 0) {
|
||||||
|
this._groupActions.splice(actionIndex, 1);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
1161
node/node_modules/argparse/lib/argument_parser.js
generated
vendored
Normal file
1161
node/node_modules/argparse/lib/argument_parser.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
21
node/node_modules/argparse/lib/const.js
generated
vendored
Normal file
21
node/node_modules/argparse/lib/const.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
//
|
||||||
|
// Constants
|
||||||
|
//
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports.EOL = '\n';
|
||||||
|
|
||||||
|
module.exports.SUPPRESS = '==SUPPRESS==';
|
||||||
|
|
||||||
|
module.exports.OPTIONAL = '?';
|
||||||
|
|
||||||
|
module.exports.ZERO_OR_MORE = '*';
|
||||||
|
|
||||||
|
module.exports.ONE_OR_MORE = '+';
|
||||||
|
|
||||||
|
module.exports.PARSER = 'A...';
|
||||||
|
|
||||||
|
module.exports.REMAINDER = '...';
|
||||||
|
|
||||||
|
module.exports._UNRECOGNIZED_ARGS_ATTR = '_unrecognized_args';
|
||||||
87
node/node_modules/argparse/lib/help/added_formatters.js
generated
vendored
Normal file
87
node/node_modules/argparse/lib/help/added_formatters.js
generated
vendored
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var util = require('util');
|
||||||
|
|
||||||
|
// Constants
|
||||||
|
var c = require('../const');
|
||||||
|
|
||||||
|
var $$ = require('../utils');
|
||||||
|
var HelpFormatter = require('./formatter.js');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* new RawDescriptionHelpFormatter(options)
|
||||||
|
* new ArgumentParser({formatterClass: argparse.RawDescriptionHelpFormatter, ...})
|
||||||
|
*
|
||||||
|
* Help message formatter which adds default values to argument help.
|
||||||
|
*
|
||||||
|
* Only the name of this class is considered a public API. All the methods
|
||||||
|
* provided by the class are considered an implementation detail.
|
||||||
|
**/
|
||||||
|
|
||||||
|
function ArgumentDefaultsHelpFormatter(options) {
|
||||||
|
HelpFormatter.call(this, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
util.inherits(ArgumentDefaultsHelpFormatter, HelpFormatter);
|
||||||
|
|
||||||
|
ArgumentDefaultsHelpFormatter.prototype._getHelpString = function (action) {
|
||||||
|
var help = action.help;
|
||||||
|
if (action.help.indexOf('%(defaultValue)s') === -1) {
|
||||||
|
if (action.defaultValue !== c.SUPPRESS) {
|
||||||
|
var defaulting_nargs = [ c.OPTIONAL, c.ZERO_OR_MORE ];
|
||||||
|
if (action.isOptional() || (defaulting_nargs.indexOf(action.nargs) >= 0)) {
|
||||||
|
help += ' (default: %(defaultValue)s)';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return help;
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.ArgumentDefaultsHelpFormatter = ArgumentDefaultsHelpFormatter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* new RawDescriptionHelpFormatter(options)
|
||||||
|
* new ArgumentParser({formatterClass: argparse.RawDescriptionHelpFormatter, ...})
|
||||||
|
*
|
||||||
|
* Help message formatter which retains any formatting in descriptions.
|
||||||
|
*
|
||||||
|
* Only the name of this class is considered a public API. All the methods
|
||||||
|
* provided by the class are considered an implementation detail.
|
||||||
|
**/
|
||||||
|
|
||||||
|
function RawDescriptionHelpFormatter(options) {
|
||||||
|
HelpFormatter.call(this, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
util.inherits(RawDescriptionHelpFormatter, HelpFormatter);
|
||||||
|
|
||||||
|
RawDescriptionHelpFormatter.prototype._fillText = function (text, width, indent) {
|
||||||
|
var lines = text.split('\n');
|
||||||
|
lines = lines.map(function (line) {
|
||||||
|
return $$.trimEnd(indent + line);
|
||||||
|
});
|
||||||
|
return lines.join('\n');
|
||||||
|
};
|
||||||
|
module.exports.RawDescriptionHelpFormatter = RawDescriptionHelpFormatter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* new RawTextHelpFormatter(options)
|
||||||
|
* new ArgumentParser({formatterClass: argparse.RawTextHelpFormatter, ...})
|
||||||
|
*
|
||||||
|
* Help message formatter which retains formatting of all help text.
|
||||||
|
*
|
||||||
|
* Only the name of this class is considered a public API. All the methods
|
||||||
|
* provided by the class are considered an implementation detail.
|
||||||
|
**/
|
||||||
|
|
||||||
|
function RawTextHelpFormatter(options) {
|
||||||
|
RawDescriptionHelpFormatter.call(this, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
util.inherits(RawTextHelpFormatter, RawDescriptionHelpFormatter);
|
||||||
|
|
||||||
|
RawTextHelpFormatter.prototype._splitLines = function (text) {
|
||||||
|
return text.split('\n');
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.RawTextHelpFormatter = RawTextHelpFormatter;
|
||||||
795
node/node_modules/argparse/lib/help/formatter.js
generated
vendored
Normal file
795
node/node_modules/argparse/lib/help/formatter.js
generated
vendored
Normal file
@@ -0,0 +1,795 @@
|
|||||||
|
/**
|
||||||
|
* class HelpFormatter
|
||||||
|
*
|
||||||
|
* Formatter for generating usage messages and argument help strings. Only the
|
||||||
|
* name of this class is considered a public API. All the methods provided by
|
||||||
|
* the class are considered an implementation detail.
|
||||||
|
*
|
||||||
|
* Do not call in your code, use this class only for inherits your own forvatter
|
||||||
|
*
|
||||||
|
* ToDo add [additonal formatters][1]
|
||||||
|
*
|
||||||
|
* [1]:http://docs.python.org/dev/library/argparse.html#formatter-class
|
||||||
|
**/
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var sprintf = require('sprintf-js').sprintf;
|
||||||
|
|
||||||
|
// Constants
|
||||||
|
var c = require('../const');
|
||||||
|
|
||||||
|
var $$ = require('../utils');
|
||||||
|
|
||||||
|
|
||||||
|
/*:nodoc:* internal
|
||||||
|
* new Support(parent, heding)
|
||||||
|
* - parent (object): parent section
|
||||||
|
* - heading (string): header string
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
function Section(parent, heading) {
|
||||||
|
this._parent = parent;
|
||||||
|
this._heading = heading;
|
||||||
|
this._items = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*:nodoc:* internal
|
||||||
|
* Section#addItem(callback) -> Void
|
||||||
|
* - callback (array): tuple with function and args
|
||||||
|
*
|
||||||
|
* Add function for single element
|
||||||
|
**/
|
||||||
|
Section.prototype.addItem = function (callback) {
|
||||||
|
this._items.push(callback);
|
||||||
|
};
|
||||||
|
|
||||||
|
/*:nodoc:* internal
|
||||||
|
* Section#formatHelp(formatter) -> string
|
||||||
|
* - formatter (HelpFormatter): current formatter
|
||||||
|
*
|
||||||
|
* Form help section string
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
Section.prototype.formatHelp = function (formatter) {
|
||||||
|
var itemHelp, heading;
|
||||||
|
|
||||||
|
// format the indented section
|
||||||
|
if (this._parent) {
|
||||||
|
formatter._indent();
|
||||||
|
}
|
||||||
|
|
||||||
|
itemHelp = this._items.map(function (item) {
|
||||||
|
var obj, func, args;
|
||||||
|
|
||||||
|
obj = formatter;
|
||||||
|
func = item[0];
|
||||||
|
args = item[1];
|
||||||
|
return func.apply(obj, args);
|
||||||
|
});
|
||||||
|
itemHelp = formatter._joinParts(itemHelp);
|
||||||
|
|
||||||
|
if (this._parent) {
|
||||||
|
formatter._dedent();
|
||||||
|
}
|
||||||
|
|
||||||
|
// return nothing if the section was empty
|
||||||
|
if (!itemHelp) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
// add the heading if the section was non-empty
|
||||||
|
heading = '';
|
||||||
|
if (this._heading && this._heading !== c.SUPPRESS) {
|
||||||
|
var currentIndent = formatter.currentIndent;
|
||||||
|
heading = $$.repeat(' ', currentIndent) + this._heading + ':' + c.EOL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// join the section-initialize newline, the heading and the help
|
||||||
|
return formatter._joinParts([ c.EOL, heading, itemHelp, c.EOL ]);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* new HelpFormatter(options)
|
||||||
|
*
|
||||||
|
* #### Options:
|
||||||
|
* - `prog`: program name
|
||||||
|
* - `indentIncriment`: indent step, default value 2
|
||||||
|
* - `maxHelpPosition`: max help position, default value = 24
|
||||||
|
* - `width`: line width
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
var HelpFormatter = module.exports = function HelpFormatter(options) {
|
||||||
|
options = options || {};
|
||||||
|
|
||||||
|
this._prog = options.prog;
|
||||||
|
|
||||||
|
this._maxHelpPosition = options.maxHelpPosition || 24;
|
||||||
|
this._width = (options.width || ((process.env.COLUMNS || 80) - 2));
|
||||||
|
|
||||||
|
this._currentIndent = 0;
|
||||||
|
this._indentIncriment = options.indentIncriment || 2;
|
||||||
|
this._level = 0;
|
||||||
|
this._actionMaxLength = 0;
|
||||||
|
|
||||||
|
this._rootSection = new Section(null);
|
||||||
|
this._currentSection = this._rootSection;
|
||||||
|
|
||||||
|
this._whitespaceMatcher = new RegExp('\\s+', 'g');
|
||||||
|
this._longBreakMatcher = new RegExp(c.EOL + c.EOL + c.EOL + '+', 'g');
|
||||||
|
};
|
||||||
|
|
||||||
|
HelpFormatter.prototype._indent = function () {
|
||||||
|
this._currentIndent += this._indentIncriment;
|
||||||
|
this._level += 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
HelpFormatter.prototype._dedent = function () {
|
||||||
|
this._currentIndent -= this._indentIncriment;
|
||||||
|
this._level -= 1;
|
||||||
|
if (this._currentIndent < 0) {
|
||||||
|
throw new Error('Indent decreased below 0.');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
HelpFormatter.prototype._addItem = function (func, args) {
|
||||||
|
this._currentSection.addItem([ func, args ]);
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// Message building methods
|
||||||
|
//
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HelpFormatter#startSection(heading) -> Void
|
||||||
|
* - heading (string): header string
|
||||||
|
*
|
||||||
|
* Start new help section
|
||||||
|
*
|
||||||
|
* See alse [code example][1]
|
||||||
|
*
|
||||||
|
* ##### Example
|
||||||
|
*
|
||||||
|
* formatter.startSection(actionGroup.title);
|
||||||
|
* formatter.addText(actionGroup.description);
|
||||||
|
* formatter.addArguments(actionGroup._groupActions);
|
||||||
|
* formatter.endSection();
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
HelpFormatter.prototype.startSection = function (heading) {
|
||||||
|
this._indent();
|
||||||
|
var section = new Section(this._currentSection, heading);
|
||||||
|
var func = section.formatHelp.bind(section);
|
||||||
|
this._addItem(func, [ this ]);
|
||||||
|
this._currentSection = section;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HelpFormatter#endSection -> Void
|
||||||
|
*
|
||||||
|
* End help section
|
||||||
|
*
|
||||||
|
* ##### Example
|
||||||
|
*
|
||||||
|
* formatter.startSection(actionGroup.title);
|
||||||
|
* formatter.addText(actionGroup.description);
|
||||||
|
* formatter.addArguments(actionGroup._groupActions);
|
||||||
|
* formatter.endSection();
|
||||||
|
**/
|
||||||
|
HelpFormatter.prototype.endSection = function () {
|
||||||
|
this._currentSection = this._currentSection._parent;
|
||||||
|
this._dedent();
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HelpFormatter#addText(text) -> Void
|
||||||
|
* - text (string): plain text
|
||||||
|
*
|
||||||
|
* Add plain text into current section
|
||||||
|
*
|
||||||
|
* ##### Example
|
||||||
|
*
|
||||||
|
* formatter.startSection(actionGroup.title);
|
||||||
|
* formatter.addText(actionGroup.description);
|
||||||
|
* formatter.addArguments(actionGroup._groupActions);
|
||||||
|
* formatter.endSection();
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
HelpFormatter.prototype.addText = function (text) {
|
||||||
|
if (text && text !== c.SUPPRESS) {
|
||||||
|
this._addItem(this._formatText, [ text ]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HelpFormatter#addUsage(usage, actions, groups, prefix) -> Void
|
||||||
|
* - usage (string): usage text
|
||||||
|
* - actions (array): actions list
|
||||||
|
* - groups (array): groups list
|
||||||
|
* - prefix (string): usage prefix
|
||||||
|
*
|
||||||
|
* Add usage data into current section
|
||||||
|
*
|
||||||
|
* ##### Example
|
||||||
|
*
|
||||||
|
* formatter.addUsage(this.usage, this._actions, []);
|
||||||
|
* return formatter.formatHelp();
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
HelpFormatter.prototype.addUsage = function (usage, actions, groups, prefix) {
|
||||||
|
if (usage !== c.SUPPRESS) {
|
||||||
|
this._addItem(this._formatUsage, [ usage, actions, groups, prefix ]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HelpFormatter#addArgument(action) -> Void
|
||||||
|
* - action (object): action
|
||||||
|
*
|
||||||
|
* Add argument into current section
|
||||||
|
*
|
||||||
|
* Single variant of [[HelpFormatter#addArguments]]
|
||||||
|
**/
|
||||||
|
HelpFormatter.prototype.addArgument = function (action) {
|
||||||
|
if (action.help !== c.SUPPRESS) {
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
// find all invocations
|
||||||
|
var invocations = [ this._formatActionInvocation(action) ];
|
||||||
|
var invocationLength = invocations[0].length;
|
||||||
|
|
||||||
|
var actionLength;
|
||||||
|
|
||||||
|
if (action._getSubactions) {
|
||||||
|
this._indent();
|
||||||
|
action._getSubactions().forEach(function (subaction) {
|
||||||
|
|
||||||
|
var invocationNew = self._formatActionInvocation(subaction);
|
||||||
|
invocations.push(invocationNew);
|
||||||
|
invocationLength = Math.max(invocationLength, invocationNew.length);
|
||||||
|
|
||||||
|
});
|
||||||
|
this._dedent();
|
||||||
|
}
|
||||||
|
|
||||||
|
// update the maximum item length
|
||||||
|
actionLength = invocationLength + this._currentIndent;
|
||||||
|
this._actionMaxLength = Math.max(this._actionMaxLength, actionLength);
|
||||||
|
|
||||||
|
// add the item to the list
|
||||||
|
this._addItem(this._formatAction, [ action ]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HelpFormatter#addArguments(actions) -> Void
|
||||||
|
* - actions (array): actions list
|
||||||
|
*
|
||||||
|
* Mass add arguments into current section
|
||||||
|
*
|
||||||
|
* ##### Example
|
||||||
|
*
|
||||||
|
* formatter.startSection(actionGroup.title);
|
||||||
|
* formatter.addText(actionGroup.description);
|
||||||
|
* formatter.addArguments(actionGroup._groupActions);
|
||||||
|
* formatter.endSection();
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
HelpFormatter.prototype.addArguments = function (actions) {
|
||||||
|
var self = this;
|
||||||
|
actions.forEach(function (action) {
|
||||||
|
self.addArgument(action);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// Help-formatting methods
|
||||||
|
//
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HelpFormatter#formatHelp -> string
|
||||||
|
*
|
||||||
|
* Format help
|
||||||
|
*
|
||||||
|
* ##### Example
|
||||||
|
*
|
||||||
|
* formatter.addText(this.epilog);
|
||||||
|
* return formatter.formatHelp();
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
HelpFormatter.prototype.formatHelp = function () {
|
||||||
|
var help = this._rootSection.formatHelp(this);
|
||||||
|
if (help) {
|
||||||
|
help = help.replace(this._longBreakMatcher, c.EOL + c.EOL);
|
||||||
|
help = $$.trimChars(help, c.EOL) + c.EOL;
|
||||||
|
}
|
||||||
|
return help;
|
||||||
|
};
|
||||||
|
|
||||||
|
HelpFormatter.prototype._joinParts = function (partStrings) {
|
||||||
|
return partStrings.filter(function (part) {
|
||||||
|
return (part && part !== c.SUPPRESS);
|
||||||
|
}).join('');
|
||||||
|
};
|
||||||
|
|
||||||
|
HelpFormatter.prototype._formatUsage = function (usage, actions, groups, prefix) {
|
||||||
|
if (!prefix && typeof prefix !== 'string') {
|
||||||
|
prefix = 'usage: ';
|
||||||
|
}
|
||||||
|
|
||||||
|
actions = actions || [];
|
||||||
|
groups = groups || [];
|
||||||
|
|
||||||
|
|
||||||
|
// if usage is specified, use that
|
||||||
|
if (usage) {
|
||||||
|
usage = sprintf(usage, { prog: this._prog });
|
||||||
|
|
||||||
|
// if no optionals or positionals are available, usage is just prog
|
||||||
|
} else if (!usage && actions.length === 0) {
|
||||||
|
usage = this._prog;
|
||||||
|
|
||||||
|
// if optionals and positionals are available, calculate usage
|
||||||
|
} else if (!usage) {
|
||||||
|
var prog = this._prog;
|
||||||
|
var optionals = [];
|
||||||
|
var positionals = [];
|
||||||
|
var actionUsage;
|
||||||
|
var textWidth;
|
||||||
|
|
||||||
|
// split optionals from positionals
|
||||||
|
actions.forEach(function (action) {
|
||||||
|
if (action.isOptional()) {
|
||||||
|
optionals.push(action);
|
||||||
|
} else {
|
||||||
|
positionals.push(action);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// build full usage string
|
||||||
|
actionUsage = this._formatActionsUsage([].concat(optionals, positionals), groups);
|
||||||
|
usage = [ prog, actionUsage ].join(' ');
|
||||||
|
|
||||||
|
// wrap the usage parts if it's too long
|
||||||
|
textWidth = this._width - this._currentIndent;
|
||||||
|
if ((prefix.length + usage.length) > textWidth) {
|
||||||
|
|
||||||
|
// break usage into wrappable parts
|
||||||
|
var regexpPart = new RegExp('\\(.*?\\)+|\\[.*?\\]+|\\S+', 'g');
|
||||||
|
var optionalUsage = this._formatActionsUsage(optionals, groups);
|
||||||
|
var positionalUsage = this._formatActionsUsage(positionals, groups);
|
||||||
|
|
||||||
|
|
||||||
|
var optionalParts = optionalUsage.match(regexpPart);
|
||||||
|
var positionalParts = positionalUsage.match(regexpPart) || [];
|
||||||
|
|
||||||
|
if (optionalParts.join(' ') !== optionalUsage) {
|
||||||
|
throw new Error('assert "optionalParts.join(\' \') === optionalUsage"');
|
||||||
|
}
|
||||||
|
if (positionalParts.join(' ') !== positionalUsage) {
|
||||||
|
throw new Error('assert "positionalParts.join(\' \') === positionalUsage"');
|
||||||
|
}
|
||||||
|
|
||||||
|
// helper for wrapping lines
|
||||||
|
/*eslint-disable func-style*/ // node 0.10 compat
|
||||||
|
var _getLines = function (parts, indent, prefix) {
|
||||||
|
var lines = [];
|
||||||
|
var line = [];
|
||||||
|
|
||||||
|
var lineLength = prefix ? prefix.length - 1 : indent.length - 1;
|
||||||
|
|
||||||
|
parts.forEach(function (part) {
|
||||||
|
if (lineLength + 1 + part.length > textWidth) {
|
||||||
|
lines.push(indent + line.join(' '));
|
||||||
|
line = [];
|
||||||
|
lineLength = indent.length - 1;
|
||||||
|
}
|
||||||
|
line.push(part);
|
||||||
|
lineLength += part.length + 1;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (line) {
|
||||||
|
lines.push(indent + line.join(' '));
|
||||||
|
}
|
||||||
|
if (prefix) {
|
||||||
|
lines[0] = lines[0].substr(indent.length);
|
||||||
|
}
|
||||||
|
return lines;
|
||||||
|
};
|
||||||
|
|
||||||
|
var lines, indent, parts;
|
||||||
|
// if prog is short, follow it with optionals or positionals
|
||||||
|
if (prefix.length + prog.length <= 0.75 * textWidth) {
|
||||||
|
indent = $$.repeat(' ', (prefix.length + prog.length + 1));
|
||||||
|
if (optionalParts) {
|
||||||
|
lines = [].concat(
|
||||||
|
_getLines([ prog ].concat(optionalParts), indent, prefix),
|
||||||
|
_getLines(positionalParts, indent)
|
||||||
|
);
|
||||||
|
} else if (positionalParts) {
|
||||||
|
lines = _getLines([ prog ].concat(positionalParts), indent, prefix);
|
||||||
|
} else {
|
||||||
|
lines = [ prog ];
|
||||||
|
}
|
||||||
|
|
||||||
|
// if prog is long, put it on its own line
|
||||||
|
} else {
|
||||||
|
indent = $$.repeat(' ', prefix.length);
|
||||||
|
parts = optionalParts.concat(positionalParts);
|
||||||
|
lines = _getLines(parts, indent);
|
||||||
|
if (lines.length > 1) {
|
||||||
|
lines = [].concat(
|
||||||
|
_getLines(optionalParts, indent),
|
||||||
|
_getLines(positionalParts, indent)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
lines = [ prog ].concat(lines);
|
||||||
|
}
|
||||||
|
// join lines into usage
|
||||||
|
usage = lines.join(c.EOL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// prefix with 'usage:'
|
||||||
|
return prefix + usage + c.EOL + c.EOL;
|
||||||
|
};
|
||||||
|
|
||||||
|
HelpFormatter.prototype._formatActionsUsage = function (actions, groups) {
|
||||||
|
// find group indices and identify actions in groups
|
||||||
|
var groupActions = [];
|
||||||
|
var inserts = [];
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
groups.forEach(function (group) {
|
||||||
|
var end;
|
||||||
|
var i;
|
||||||
|
|
||||||
|
var start = actions.indexOf(group._groupActions[0]);
|
||||||
|
if (start >= 0) {
|
||||||
|
end = start + group._groupActions.length;
|
||||||
|
|
||||||
|
//if (actions.slice(start, end) === group._groupActions) {
|
||||||
|
if ($$.arrayEqual(actions.slice(start, end), group._groupActions)) {
|
||||||
|
group._groupActions.forEach(function (action) {
|
||||||
|
groupActions.push(action);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!group.required) {
|
||||||
|
if (inserts[start]) {
|
||||||
|
inserts[start] += ' [';
|
||||||
|
} else {
|
||||||
|
inserts[start] = '[';
|
||||||
|
}
|
||||||
|
inserts[end] = ']';
|
||||||
|
} else {
|
||||||
|
if (inserts[start]) {
|
||||||
|
inserts[start] += ' (';
|
||||||
|
} else {
|
||||||
|
inserts[start] = '(';
|
||||||
|
}
|
||||||
|
inserts[end] = ')';
|
||||||
|
}
|
||||||
|
for (i = start + 1; i < end; i += 1) {
|
||||||
|
inserts[i] = '|';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// collect all actions format strings
|
||||||
|
var parts = [];
|
||||||
|
|
||||||
|
actions.forEach(function (action, actionIndex) {
|
||||||
|
var part;
|
||||||
|
var optionString;
|
||||||
|
var argsDefault;
|
||||||
|
var argsString;
|
||||||
|
|
||||||
|
// suppressed arguments are marked with None
|
||||||
|
// remove | separators for suppressed arguments
|
||||||
|
if (action.help === c.SUPPRESS) {
|
||||||
|
parts.push(null);
|
||||||
|
if (inserts[actionIndex] === '|') {
|
||||||
|
inserts.splice(actionIndex, actionIndex);
|
||||||
|
} else if (inserts[actionIndex + 1] === '|') {
|
||||||
|
inserts.splice(actionIndex + 1, actionIndex + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// produce all arg strings
|
||||||
|
} else if (!action.isOptional()) {
|
||||||
|
part = self._formatArgs(action, action.dest);
|
||||||
|
|
||||||
|
// if it's in a group, strip the outer []
|
||||||
|
if (groupActions.indexOf(action) >= 0) {
|
||||||
|
if (part[0] === '[' && part[part.length - 1] === ']') {
|
||||||
|
part = part.slice(1, -1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// add the action string to the list
|
||||||
|
parts.push(part);
|
||||||
|
|
||||||
|
// produce the first way to invoke the option in brackets
|
||||||
|
} else {
|
||||||
|
optionString = action.optionStrings[0];
|
||||||
|
|
||||||
|
// if the Optional doesn't take a value, format is: -s or --long
|
||||||
|
if (action.nargs === 0) {
|
||||||
|
part = '' + optionString;
|
||||||
|
|
||||||
|
// if the Optional takes a value, format is: -s ARGS or --long ARGS
|
||||||
|
} else {
|
||||||
|
argsDefault = action.dest.toUpperCase();
|
||||||
|
argsString = self._formatArgs(action, argsDefault);
|
||||||
|
part = optionString + ' ' + argsString;
|
||||||
|
}
|
||||||
|
// make it look optional if it's not required or in a group
|
||||||
|
if (!action.required && groupActions.indexOf(action) < 0) {
|
||||||
|
part = '[' + part + ']';
|
||||||
|
}
|
||||||
|
// add the action string to the list
|
||||||
|
parts.push(part);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// insert things at the necessary indices
|
||||||
|
for (var i = inserts.length - 1; i >= 0; --i) {
|
||||||
|
if (inserts[i] !== null) {
|
||||||
|
parts.splice(i, 0, inserts[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// join all the action items with spaces
|
||||||
|
var text = parts.filter(function (part) {
|
||||||
|
return !!part;
|
||||||
|
}).join(' ');
|
||||||
|
|
||||||
|
// clean up separators for mutually exclusive groups
|
||||||
|
text = text.replace(/([\[(]) /g, '$1'); // remove spaces
|
||||||
|
text = text.replace(/ ([\])])/g, '$1');
|
||||||
|
text = text.replace(/\[ *\]/g, ''); // remove empty groups
|
||||||
|
text = text.replace(/\( *\)/g, '');
|
||||||
|
text = text.replace(/\(([^|]*)\)/g, '$1'); // remove () from single action groups
|
||||||
|
|
||||||
|
text = text.trim();
|
||||||
|
|
||||||
|
// return the text
|
||||||
|
return text;
|
||||||
|
};
|
||||||
|
|
||||||
|
HelpFormatter.prototype._formatText = function (text) {
|
||||||
|
text = sprintf(text, { prog: this._prog });
|
||||||
|
var textWidth = this._width - this._currentIndent;
|
||||||
|
var indentIncriment = $$.repeat(' ', this._currentIndent);
|
||||||
|
return this._fillText(text, textWidth, indentIncriment) + c.EOL + c.EOL;
|
||||||
|
};
|
||||||
|
|
||||||
|
HelpFormatter.prototype._formatAction = function (action) {
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
var helpText;
|
||||||
|
var helpLines;
|
||||||
|
var parts;
|
||||||
|
var indentFirst;
|
||||||
|
|
||||||
|
// determine the required width and the entry label
|
||||||
|
var helpPosition = Math.min(this._actionMaxLength + 2, this._maxHelpPosition);
|
||||||
|
var helpWidth = this._width - helpPosition;
|
||||||
|
var actionWidth = helpPosition - this._currentIndent - 2;
|
||||||
|
var actionHeader = this._formatActionInvocation(action);
|
||||||
|
|
||||||
|
// no help; start on same line and add a final newline
|
||||||
|
if (!action.help) {
|
||||||
|
actionHeader = $$.repeat(' ', this._currentIndent) + actionHeader + c.EOL;
|
||||||
|
|
||||||
|
// short action name; start on the same line and pad two spaces
|
||||||
|
} else if (actionHeader.length <= actionWidth) {
|
||||||
|
actionHeader = $$.repeat(' ', this._currentIndent) +
|
||||||
|
actionHeader +
|
||||||
|
' ' +
|
||||||
|
$$.repeat(' ', actionWidth - actionHeader.length);
|
||||||
|
indentFirst = 0;
|
||||||
|
|
||||||
|
// long action name; start on the next line
|
||||||
|
} else {
|
||||||
|
actionHeader = $$.repeat(' ', this._currentIndent) + actionHeader + c.EOL;
|
||||||
|
indentFirst = helpPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
// collect the pieces of the action help
|
||||||
|
parts = [ actionHeader ];
|
||||||
|
|
||||||
|
// if there was help for the action, add lines of help text
|
||||||
|
if (action.help) {
|
||||||
|
helpText = this._expandHelp(action);
|
||||||
|
helpLines = this._splitLines(helpText, helpWidth);
|
||||||
|
parts.push($$.repeat(' ', indentFirst) + helpLines[0] + c.EOL);
|
||||||
|
helpLines.slice(1).forEach(function (line) {
|
||||||
|
parts.push($$.repeat(' ', helpPosition) + line + c.EOL);
|
||||||
|
});
|
||||||
|
|
||||||
|
// or add a newline if the description doesn't end with one
|
||||||
|
} else if (actionHeader.charAt(actionHeader.length - 1) !== c.EOL) {
|
||||||
|
parts.push(c.EOL);
|
||||||
|
}
|
||||||
|
// if there are any sub-actions, add their help as well
|
||||||
|
if (action._getSubactions) {
|
||||||
|
this._indent();
|
||||||
|
action._getSubactions().forEach(function (subaction) {
|
||||||
|
parts.push(self._formatAction(subaction));
|
||||||
|
});
|
||||||
|
this._dedent();
|
||||||
|
}
|
||||||
|
// return a single string
|
||||||
|
return this._joinParts(parts);
|
||||||
|
};
|
||||||
|
|
||||||
|
HelpFormatter.prototype._formatActionInvocation = function (action) {
|
||||||
|
if (!action.isOptional()) {
|
||||||
|
var format_func = this._metavarFormatter(action, action.dest);
|
||||||
|
var metavars = format_func(1);
|
||||||
|
return metavars[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
var parts = [];
|
||||||
|
var argsDefault;
|
||||||
|
var argsString;
|
||||||
|
|
||||||
|
// if the Optional doesn't take a value, format is: -s, --long
|
||||||
|
if (action.nargs === 0) {
|
||||||
|
parts = parts.concat(action.optionStrings);
|
||||||
|
|
||||||
|
// if the Optional takes a value, format is: -s ARGS, --long ARGS
|
||||||
|
} else {
|
||||||
|
argsDefault = action.dest.toUpperCase();
|
||||||
|
argsString = this._formatArgs(action, argsDefault);
|
||||||
|
action.optionStrings.forEach(function (optionString) {
|
||||||
|
parts.push(optionString + ' ' + argsString);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return parts.join(', ');
|
||||||
|
};
|
||||||
|
|
||||||
|
HelpFormatter.prototype._metavarFormatter = function (action, metavarDefault) {
|
||||||
|
var result;
|
||||||
|
|
||||||
|
if (action.metavar || action.metavar === '') {
|
||||||
|
result = action.metavar;
|
||||||
|
} else if (action.choices) {
|
||||||
|
var choices = action.choices;
|
||||||
|
|
||||||
|
if (typeof choices === 'string') {
|
||||||
|
choices = choices.split('').join(', ');
|
||||||
|
} else if (Array.isArray(choices)) {
|
||||||
|
choices = choices.join(',');
|
||||||
|
} else {
|
||||||
|
choices = Object.keys(choices).join(',');
|
||||||
|
}
|
||||||
|
result = '{' + choices + '}';
|
||||||
|
} else {
|
||||||
|
result = metavarDefault;
|
||||||
|
}
|
||||||
|
|
||||||
|
return function (size) {
|
||||||
|
if (Array.isArray(result)) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
var metavars = [];
|
||||||
|
for (var i = 0; i < size; i += 1) {
|
||||||
|
metavars.push(result);
|
||||||
|
}
|
||||||
|
return metavars;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
HelpFormatter.prototype._formatArgs = function (action, metavarDefault) {
|
||||||
|
var result;
|
||||||
|
var metavars;
|
||||||
|
|
||||||
|
var buildMetavar = this._metavarFormatter(action, metavarDefault);
|
||||||
|
|
||||||
|
switch (action.nargs) {
|
||||||
|
/*eslint-disable no-undefined*/
|
||||||
|
case undefined:
|
||||||
|
case null:
|
||||||
|
metavars = buildMetavar(1);
|
||||||
|
result = '' + metavars[0];
|
||||||
|
break;
|
||||||
|
case c.OPTIONAL:
|
||||||
|
metavars = buildMetavar(1);
|
||||||
|
result = '[' + metavars[0] + ']';
|
||||||
|
break;
|
||||||
|
case c.ZERO_OR_MORE:
|
||||||
|
metavars = buildMetavar(2);
|
||||||
|
result = '[' + metavars[0] + ' [' + metavars[1] + ' ...]]';
|
||||||
|
break;
|
||||||
|
case c.ONE_OR_MORE:
|
||||||
|
metavars = buildMetavar(2);
|
||||||
|
result = '' + metavars[0] + ' [' + metavars[1] + ' ...]';
|
||||||
|
break;
|
||||||
|
case c.REMAINDER:
|
||||||
|
result = '...';
|
||||||
|
break;
|
||||||
|
case c.PARSER:
|
||||||
|
metavars = buildMetavar(1);
|
||||||
|
result = metavars[0] + ' ...';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
metavars = buildMetavar(action.nargs);
|
||||||
|
result = metavars.join(' ');
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
HelpFormatter.prototype._expandHelp = function (action) {
|
||||||
|
var params = { prog: this._prog };
|
||||||
|
|
||||||
|
Object.keys(action).forEach(function (actionProperty) {
|
||||||
|
var actionValue = action[actionProperty];
|
||||||
|
|
||||||
|
if (actionValue !== c.SUPPRESS) {
|
||||||
|
params[actionProperty] = actionValue;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (params.choices) {
|
||||||
|
if (typeof params.choices === 'string') {
|
||||||
|
params.choices = params.choices.split('').join(', ');
|
||||||
|
} else if (Array.isArray(params.choices)) {
|
||||||
|
params.choices = params.choices.join(', ');
|
||||||
|
} else {
|
||||||
|
params.choices = Object.keys(params.choices).join(', ');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return sprintf(this._getHelpString(action), params);
|
||||||
|
};
|
||||||
|
|
||||||
|
HelpFormatter.prototype._splitLines = function (text, width) {
|
||||||
|
var lines = [];
|
||||||
|
var delimiters = [ ' ', '.', ',', '!', '?' ];
|
||||||
|
var re = new RegExp('[' + delimiters.join('') + '][^' + delimiters.join('') + ']*$');
|
||||||
|
|
||||||
|
text = text.replace(/[\n\|\t]/g, ' ');
|
||||||
|
|
||||||
|
text = text.trim();
|
||||||
|
text = text.replace(this._whitespaceMatcher, ' ');
|
||||||
|
|
||||||
|
// Wraps the single paragraph in text (a string) so every line
|
||||||
|
// is at most width characters long.
|
||||||
|
text.split(c.EOL).forEach(function (line) {
|
||||||
|
if (width >= line.length) {
|
||||||
|
lines.push(line);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var wrapStart = 0;
|
||||||
|
var wrapEnd = width;
|
||||||
|
var delimiterIndex = 0;
|
||||||
|
while (wrapEnd <= line.length) {
|
||||||
|
if (wrapEnd !== line.length && delimiters.indexOf(line[wrapEnd] < -1)) {
|
||||||
|
delimiterIndex = (re.exec(line.substring(wrapStart, wrapEnd)) || {}).index;
|
||||||
|
wrapEnd = wrapStart + delimiterIndex + 1;
|
||||||
|
}
|
||||||
|
lines.push(line.substring(wrapStart, wrapEnd));
|
||||||
|
wrapStart = wrapEnd;
|
||||||
|
wrapEnd += width;
|
||||||
|
}
|
||||||
|
if (wrapStart < line.length) {
|
||||||
|
lines.push(line.substring(wrapStart, wrapEnd));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return lines;
|
||||||
|
};
|
||||||
|
|
||||||
|
HelpFormatter.prototype._fillText = function (text, width, indent) {
|
||||||
|
var lines = this._splitLines(text, width);
|
||||||
|
lines = lines.map(function (line) {
|
||||||
|
return indent + line;
|
||||||
|
});
|
||||||
|
return lines.join(c.EOL);
|
||||||
|
};
|
||||||
|
|
||||||
|
HelpFormatter.prototype._getHelpString = function (action) {
|
||||||
|
return action.help;
|
||||||
|
};
|
||||||
76
node/node_modules/argparse/lib/namespace.js
generated
vendored
Normal file
76
node/node_modules/argparse/lib/namespace.js
generated
vendored
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
/**
|
||||||
|
* class Namespace
|
||||||
|
*
|
||||||
|
* Simple object for storing attributes. Implements equality by attribute names
|
||||||
|
* and values, and provides a simple string representation.
|
||||||
|
*
|
||||||
|
* See also [original guide][1]
|
||||||
|
*
|
||||||
|
* [1]:http://docs.python.org/dev/library/argparse.html#the-namespace-object
|
||||||
|
**/
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var $$ = require('./utils');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* new Namespace(options)
|
||||||
|
* - options(object): predefined propertis for result object
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
var Namespace = module.exports = function Namespace(options) {
|
||||||
|
$$.extend(this, options);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Namespace#isset(key) -> Boolean
|
||||||
|
* - key (string|number): property name
|
||||||
|
*
|
||||||
|
* Tells whenever `namespace` contains given `key` or not.
|
||||||
|
**/
|
||||||
|
Namespace.prototype.isset = function (key) {
|
||||||
|
return $$.has(this, key);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Namespace#set(key, value) -> self
|
||||||
|
* -key (string|number|object): propery name
|
||||||
|
* -value (mixed): new property value
|
||||||
|
*
|
||||||
|
* Set the property named key with value.
|
||||||
|
* If key object then set all key properties to namespace object
|
||||||
|
**/
|
||||||
|
Namespace.prototype.set = function (key, value) {
|
||||||
|
if (typeof (key) === 'object') {
|
||||||
|
$$.extend(this, key);
|
||||||
|
} else {
|
||||||
|
this[key] = value;
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Namespace#get(key, defaultValue) -> mixed
|
||||||
|
* - key (string|number): property name
|
||||||
|
* - defaultValue (mixed): default value
|
||||||
|
*
|
||||||
|
* Return the property key or defaulValue if not set
|
||||||
|
**/
|
||||||
|
Namespace.prototype.get = function (key, defaultValue) {
|
||||||
|
return !this[key] ? defaultValue : this[key];
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Namespace#unset(key, defaultValue) -> mixed
|
||||||
|
* - key (string|number): property name
|
||||||
|
* - defaultValue (mixed): default value
|
||||||
|
*
|
||||||
|
* Return data[key](and delete it) or defaultValue
|
||||||
|
**/
|
||||||
|
Namespace.prototype.unset = function (key, defaultValue) {
|
||||||
|
var value = this[key];
|
||||||
|
if (value !== null) {
|
||||||
|
delete this[key];
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
return defaultValue;
|
||||||
|
};
|
||||||
57
node/node_modules/argparse/lib/utils.js
generated
vendored
Normal file
57
node/node_modules/argparse/lib/utils.js
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
exports.repeat = function (str, num) {
|
||||||
|
var result = '';
|
||||||
|
for (var i = 0; i < num; i++) { result += str; }
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.arrayEqual = function (a, b) {
|
||||||
|
if (a.length !== b.length) { return false; }
|
||||||
|
for (var i = 0; i < a.length; i++) {
|
||||||
|
if (a[i] !== b[i]) { return false; }
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.trimChars = function (str, chars) {
|
||||||
|
var start = 0;
|
||||||
|
var end = str.length - 1;
|
||||||
|
while (chars.indexOf(str.charAt(start)) >= 0) { start++; }
|
||||||
|
while (chars.indexOf(str.charAt(end)) >= 0) { end--; }
|
||||||
|
return str.slice(start, end + 1);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.capitalize = function (str) {
|
||||||
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.arrayUnion = function () {
|
||||||
|
var result = [];
|
||||||
|
for (var i = 0, values = {}; i < arguments.length; i++) {
|
||||||
|
var arr = arguments[i];
|
||||||
|
for (var j = 0; j < arr.length; j++) {
|
||||||
|
if (!values[arr[j]]) {
|
||||||
|
values[arr[j]] = true;
|
||||||
|
result.push(arr[j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
function has(obj, key) {
|
||||||
|
return Object.prototype.hasOwnProperty.call(obj, key);
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.has = has;
|
||||||
|
|
||||||
|
exports.extend = function (dest, src) {
|
||||||
|
for (var i in src) {
|
||||||
|
if (has(src, i)) { dest[i] = src[i]; }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.trimEnd = function (str) {
|
||||||
|
return str.replace(/\s+$/g, '');
|
||||||
|
};
|
||||||
70
node/node_modules/argparse/package.json
generated
vendored
Normal file
70
node/node_modules/argparse/package.json
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
{
|
||||||
|
"_from": "argparse@~ 1.0.0",
|
||||||
|
"_id": "argparse@1.0.10",
|
||||||
|
"_inBundle": false,
|
||||||
|
"_integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
|
||||||
|
"_location": "/argparse",
|
||||||
|
"_phantomChildren": {},
|
||||||
|
"_requested": {
|
||||||
|
"type": "range",
|
||||||
|
"registry": true,
|
||||||
|
"raw": "argparse@~ 1.0.0",
|
||||||
|
"name": "argparse",
|
||||||
|
"escapedName": "argparse",
|
||||||
|
"rawSpec": "~ 1.0.0",
|
||||||
|
"saveSpec": null,
|
||||||
|
"fetchSpec": "~ 1.0.0"
|
||||||
|
},
|
||||||
|
"_requiredBy": [
|
||||||
|
"/js-yaml"
|
||||||
|
],
|
||||||
|
"_resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
|
||||||
|
"_shasum": "bcd6791ea5ae09725e17e5ad988134cd40b3d911",
|
||||||
|
"_spec": "argparse@~ 1.0.0",
|
||||||
|
"_where": "/usr/home/web/cp/clonos/node/node_modules/js-yaml",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/nodeca/argparse/issues"
|
||||||
|
},
|
||||||
|
"bundleDependencies": false,
|
||||||
|
"contributors": [
|
||||||
|
{
|
||||||
|
"name": "Eugene Shkuropat"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Paul Jacobson"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"dependencies": {
|
||||||
|
"sprintf-js": "~1.0.2"
|
||||||
|
},
|
||||||
|
"deprecated": false,
|
||||||
|
"description": "Very powerful CLI arguments parser. Native port of argparse - python's options parsing library",
|
||||||
|
"devDependencies": {
|
||||||
|
"eslint": "^2.13.1",
|
||||||
|
"istanbul": "^0.4.5",
|
||||||
|
"mocha": "^3.1.0",
|
||||||
|
"ndoc": "^5.0.1"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"index.js",
|
||||||
|
"lib/"
|
||||||
|
],
|
||||||
|
"homepage": "https://github.com/nodeca/argparse#readme",
|
||||||
|
"keywords": [
|
||||||
|
"cli",
|
||||||
|
"parser",
|
||||||
|
"argparse",
|
||||||
|
"option",
|
||||||
|
"args"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"name": "argparse",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/nodeca/argparse.git"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"test": "make test"
|
||||||
|
},
|
||||||
|
"version": "1.0.10"
|
||||||
|
}
|
||||||
7
node/node_modules/async-limiter/.travis.yml
generated
vendored
Normal file
7
node/node_modules/async-limiter/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
language: node_js
|
||||||
|
node_js:
|
||||||
|
- "6"
|
||||||
|
- "node"
|
||||||
|
script: npm run travis
|
||||||
|
cache:
|
||||||
|
yarn: true
|
||||||
8
node/node_modules/async-limiter/LICENSE
generated
vendored
Normal file
8
node/node_modules/async-limiter/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
Copyright (c) 2017 Samuel Reed <samuel.trace.reed@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.
|
||||||
1
node/node_modules/async-limiter/coverage/coverage.json
generated
vendored
Normal file
1
node/node_modules/async-limiter/coverage/coverage.json
generated
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"/Users/samuelreed/git/forks/async-throttle/index.js":{"path":"/Users/samuelreed/git/forks/async-throttle/index.js","s":{"1":1,"2":7,"3":1,"4":6,"5":6,"6":6,"7":6,"8":6,"9":6,"10":1,"11":1,"12":3,"13":13,"14":13,"15":13,"16":1,"17":19,"18":1,"19":45,"20":6,"21":39,"22":13,"23":13,"24":13,"25":13,"26":39,"27":18,"28":6,"29":6,"30":1,"31":6,"32":6,"33":6,"34":1,"35":13,"36":13,"37":1},"b":{"1":[1,6],"2":[6,5],"3":[6,5],"4":[6,39],"5":[13,26],"6":[18,21],"7":[6,0]},"f":{"1":7,"2":3,"3":13,"4":19,"5":45,"6":6,"7":13},"fnMap":{"1":{"name":"Queue","line":3,"loc":{"start":{"line":3,"column":0},"end":{"line":3,"column":24}}},"2":{"name":"(anonymous_2)","line":22,"loc":{"start":{"line":22,"column":24},"end":{"line":22,"column":41}}},"3":{"name":"(anonymous_3)","line":23,"loc":{"start":{"line":23,"column":28},"end":{"line":23,"column":39}}},"4":{"name":"(anonymous_4)","line":31,"loc":{"start":{"line":31,"column":7},"end":{"line":31,"column":18}}},"5":{"name":"(anonymous_5)","line":36,"loc":{"start":{"line":36,"column":23},"end":{"line":36,"column":34}}},"6":{"name":"(anonymous_6)","line":55,"loc":{"start":{"line":55,"column":25},"end":{"line":55,"column":38}}},"7":{"name":"done","line":62,"loc":{"start":{"line":62,"column":0},"end":{"line":62,"column":16}}}},"statementMap":{"1":{"start":{"line":3,"column":0},"end":{"line":14,"column":1}},"2":{"start":{"line":4,"column":2},"end":{"line":6,"column":3}},"3":{"start":{"line":5,"column":4},"end":{"line":5,"column":30}},"4":{"start":{"line":8,"column":2},"end":{"line":8,"column":26}},"5":{"start":{"line":9,"column":2},"end":{"line":9,"column":53}},"6":{"start":{"line":10,"column":2},"end":{"line":10,"column":19}},"7":{"start":{"line":11,"column":2},"end":{"line":11,"column":17}},"8":{"start":{"line":12,"column":2},"end":{"line":12,"column":16}},"9":{"start":{"line":13,"column":2},"end":{"line":13,"column":31}},"10":{"start":{"line":16,"column":0},"end":{"line":20,"column":2}},"11":{"start":{"line":22,"column":0},"end":{"line":28,"column":3}},"12":{"start":{"line":23,"column":2},"end":{"line":27,"column":4}},"13":{"start":{"line":24,"column":4},"end":{"line":24,"column":75}},"14":{"start":{"line":25,"column":4},"end":{"line":25,"column":16}},"15":{"start":{"line":26,"column":4},"end":{"line":26,"column":24}},"16":{"start":{"line":30,"column":0},"end":{"line":34,"column":3}},"17":{"start":{"line":32,"column":4},"end":{"line":32,"column":43}},"18":{"start":{"line":36,"column":0},"end":{"line":53,"column":2}},"19":{"start":{"line":37,"column":2},"end":{"line":39,"column":3}},"20":{"start":{"line":38,"column":4},"end":{"line":38,"column":11}},"21":{"start":{"line":40,"column":2},"end":{"line":45,"column":3}},"22":{"start":{"line":41,"column":4},"end":{"line":41,"column":32}},"23":{"start":{"line":42,"column":4},"end":{"line":42,"column":19}},"24":{"start":{"line":43,"column":4},"end":{"line":43,"column":20}},"25":{"start":{"line":44,"column":4},"end":{"line":44,"column":16}},"26":{"start":{"line":47,"column":2},"end":{"line":52,"column":3}},"27":{"start":{"line":48,"column":4},"end":{"line":51,"column":5}},"28":{"start":{"line":49,"column":6},"end":{"line":49,"column":30}},"29":{"start":{"line":50,"column":6},"end":{"line":50,"column":27}},"30":{"start":{"line":55,"column":0},"end":{"line":60,"column":2}},"31":{"start":{"line":56,"column":2},"end":{"line":59,"column":3}},"32":{"start":{"line":57,"column":4},"end":{"line":57,"column":22}},"33":{"start":{"line":58,"column":4},"end":{"line":58,"column":16}},"34":{"start":{"line":62,"column":0},"end":{"line":65,"column":1}},"35":{"start":{"line":63,"column":2},"end":{"line":63,"column":17}},"36":{"start":{"line":64,"column":2},"end":{"line":64,"column":14}},"37":{"start":{"line":67,"column":0},"end":{"line":67,"column":23}}},"branchMap":{"1":{"line":4,"type":"if","locations":[{"start":{"line":4,"column":2},"end":{"line":4,"column":2}},{"start":{"line":4,"column":2},"end":{"line":4,"column":2}}]},"2":{"line":8,"type":"binary-expr","locations":[{"start":{"line":8,"column":12},"end":{"line":8,"column":19}},{"start":{"line":8,"column":23},"end":{"line":8,"column":25}}]},"3":{"line":9,"type":"binary-expr","locations":[{"start":{"line":9,"column":21},"end":{"line":9,"column":40}},{"start":{"line":9,"column":44},"end":{"line":9,"column":52}}]},"4":{"line":37,"type":"if","locations":[{"start":{"line":37,"column":2},"end":{"line":37,"column":2}},{"start":{"line":37,"column":2},"end":{"line":37,"column":2}}]},"5":{"line":40,"type":"if","locations":[{"start":{"line":40,"column":2},"end":{"line":40,"column":2}},{"start":{"line":40,"column":2},"end":{"line":40,"column":2}}]},"6":{"line":47,"type":"if","locations":[{"start":{"line":47,"column":2},"end":{"line":47,"column":2}},{"start":{"line":47,"column":2},"end":{"line":47,"column":2}}]},"7":{"line":56,"type":"if","locations":[{"start":{"line":56,"column":2},"end":{"line":56,"column":2}},{"start":{"line":56,"column":2},"end":{"line":56,"column":2}}]}}}}
|
||||||
73
node/node_modules/async-limiter/coverage/lcov-report/async-throttle/index.html
generated
vendored
Normal file
73
node/node_modules/async-limiter/coverage/lcov-report/async-throttle/index.html
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<title>Code coverage report for async-throttle/</title>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<link rel="stylesheet" href="../prettify.css">
|
||||||
|
<link rel="stylesheet" href="../base.css">
|
||||||
|
<style type='text/css'>
|
||||||
|
div.coverage-summary .sorter {
|
||||||
|
background-image: url(../sort-arrow-sprite.png);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="header high">
|
||||||
|
<h1>Code coverage report for <span class="entity">async-throttle/</span></h1>
|
||||||
|
<h2>
|
||||||
|
Statements: <span class="metric">100% <small>(37 / 37)</small></span>
|
||||||
|
Branches: <span class="metric">92.86% <small>(13 / 14)</small></span>
|
||||||
|
Functions: <span class="metric">100% <small>(7 / 7)</small></span>
|
||||||
|
Lines: <span class="metric">100% <small>(37 / 37)</small></span>
|
||||||
|
Ignored: <span class="metric"><span class="ignore-none">none</span></span>
|
||||||
|
</h2>
|
||||||
|
<div class="path"><a href="../index.html">All files</a> » async-throttle/</div>
|
||||||
|
</div>
|
||||||
|
<div class="body">
|
||||||
|
<div class="coverage-summary">
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th data-col="file" data-fmt="html" data-html="true" class="file">File</th>
|
||||||
|
<th data-col="pic" data-type="number" data-fmt="html" data-html="true" class="pic"></th>
|
||||||
|
<th data-col="statements" data-type="number" data-fmt="pct" class="pct">Statements</th>
|
||||||
|
<th data-col="statements_raw" data-type="number" data-fmt="html" class="abs"></th>
|
||||||
|
<th data-col="branches" data-type="number" data-fmt="pct" class="pct">Branches</th>
|
||||||
|
<th data-col="branches_raw" data-type="number" data-fmt="html" class="abs"></th>
|
||||||
|
<th data-col="functions" data-type="number" data-fmt="pct" class="pct">Functions</th>
|
||||||
|
<th data-col="functions_raw" data-type="number" data-fmt="html" class="abs"></th>
|
||||||
|
<th data-col="lines" data-type="number" data-fmt="pct" class="pct">Lines</th>
|
||||||
|
<th data-col="lines_raw" data-type="number" data-fmt="html" class="abs"></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody><tr>
|
||||||
|
<td class="file high" data-value="index.js"><a href="index.js.html">index.js</a></td>
|
||||||
|
<td data-value="100" class="pic high"><span class="cover-fill cover-full" style="width: 100px;"></span><span class="cover-empty" style="width:0px;"></span></td>
|
||||||
|
<td data-value="100" class="pct high">100%</td>
|
||||||
|
<td data-value="37" class="abs high">(37 / 37)</td>
|
||||||
|
<td data-value="92.86" class="pct high">92.86%</td>
|
||||||
|
<td data-value="14" class="abs high">(13 / 14)</td>
|
||||||
|
<td data-value="100" class="pct high">100%</td>
|
||||||
|
<td data-value="7" class="abs high">(7 / 7)</td>
|
||||||
|
<td data-value="100" class="pct high">100%</td>
|
||||||
|
<td data-value="37" class="abs high">(37 / 37)</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="footer">
|
||||||
|
<div class="meta">Generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Mon Sep 11 2017 11:14:14 GMT-0500 (CDT)</div>
|
||||||
|
</div>
|
||||||
|
<script src="../prettify.js"></script>
|
||||||
|
<script>
|
||||||
|
window.onload = function () {
|
||||||
|
if (typeof prettyPrint === 'function') {
|
||||||
|
prettyPrint();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<script src="../sorter.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
246
node/node_modules/async-limiter/coverage/lcov-report/async-throttle/index.js.html
generated
vendored
Normal file
246
node/node_modules/async-limiter/coverage/lcov-report/async-throttle/index.js.html
generated
vendored
Normal file
@@ -0,0 +1,246 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<title>Code coverage report for async-throttle/index.js</title>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<link rel="stylesheet" href="../prettify.css">
|
||||||
|
<link rel="stylesheet" href="../base.css">
|
||||||
|
<style type='text/css'>
|
||||||
|
div.coverage-summary .sorter {
|
||||||
|
background-image: url(../sort-arrow-sprite.png);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="header high">
|
||||||
|
<h1>Code coverage report for <span class="entity">async-throttle/index.js</span></h1>
|
||||||
|
<h2>
|
||||||
|
Statements: <span class="metric">100% <small>(37 / 37)</small></span>
|
||||||
|
Branches: <span class="metric">92.86% <small>(13 / 14)</small></span>
|
||||||
|
Functions: <span class="metric">100% <small>(7 / 7)</small></span>
|
||||||
|
Lines: <span class="metric">100% <small>(37 / 37)</small></span>
|
||||||
|
Ignored: <span class="metric"><span class="ignore-none">none</span></span>
|
||||||
|
</h2>
|
||||||
|
<div class="path"><a href="../index.html">All files</a> » <a href="index.html">async-throttle/</a> » index.js</div>
|
||||||
|
</div>
|
||||||
|
<div class="body">
|
||||||
|
<pre><table class="coverage">
|
||||||
|
<tr><td class="line-count">1
|
||||||
|
2
|
||||||
|
3
|
||||||
|
4
|
||||||
|
5
|
||||||
|
6
|
||||||
|
7
|
||||||
|
8
|
||||||
|
9
|
||||||
|
10
|
||||||
|
11
|
||||||
|
12
|
||||||
|
13
|
||||||
|
14
|
||||||
|
15
|
||||||
|
16
|
||||||
|
17
|
||||||
|
18
|
||||||
|
19
|
||||||
|
20
|
||||||
|
21
|
||||||
|
22
|
||||||
|
23
|
||||||
|
24
|
||||||
|
25
|
||||||
|
26
|
||||||
|
27
|
||||||
|
28
|
||||||
|
29
|
||||||
|
30
|
||||||
|
31
|
||||||
|
32
|
||||||
|
33
|
||||||
|
34
|
||||||
|
35
|
||||||
|
36
|
||||||
|
37
|
||||||
|
38
|
||||||
|
39
|
||||||
|
40
|
||||||
|
41
|
||||||
|
42
|
||||||
|
43
|
||||||
|
44
|
||||||
|
45
|
||||||
|
46
|
||||||
|
47
|
||||||
|
48
|
||||||
|
49
|
||||||
|
50
|
||||||
|
51
|
||||||
|
52
|
||||||
|
53
|
||||||
|
54
|
||||||
|
55
|
||||||
|
56
|
||||||
|
57
|
||||||
|
58
|
||||||
|
59
|
||||||
|
60
|
||||||
|
61
|
||||||
|
62
|
||||||
|
63
|
||||||
|
64
|
||||||
|
65
|
||||||
|
66
|
||||||
|
67
|
||||||
|
68</td><td class="line-coverage"><span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">1</span>
|
||||||
|
<span class="cline-any cline-yes">7</span>
|
||||||
|
<span class="cline-any cline-yes">1</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">6</span>
|
||||||
|
<span class="cline-any cline-yes">6</span>
|
||||||
|
<span class="cline-any cline-yes">6</span>
|
||||||
|
<span class="cline-any cline-yes">6</span>
|
||||||
|
<span class="cline-any cline-yes">6</span>
|
||||||
|
<span class="cline-any cline-yes">6</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">1</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">1</span>
|
||||||
|
<span class="cline-any cline-yes">3</span>
|
||||||
|
<span class="cline-any cline-yes">13</span>
|
||||||
|
<span class="cline-any cline-yes">13</span>
|
||||||
|
<span class="cline-any cline-yes">13</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">1</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">19</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">1</span>
|
||||||
|
<span class="cline-any cline-yes">45</span>
|
||||||
|
<span class="cline-any cline-yes">6</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">39</span>
|
||||||
|
<span class="cline-any cline-yes">13</span>
|
||||||
|
<span class="cline-any cline-yes">13</span>
|
||||||
|
<span class="cline-any cline-yes">13</span>
|
||||||
|
<span class="cline-any cline-yes">13</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">39</span>
|
||||||
|
<span class="cline-any cline-yes">18</span>
|
||||||
|
<span class="cline-any cline-yes">6</span>
|
||||||
|
<span class="cline-any cline-yes">6</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">1</span>
|
||||||
|
<span class="cline-any cline-yes">6</span>
|
||||||
|
<span class="cline-any cline-yes">6</span>
|
||||||
|
<span class="cline-any cline-yes">6</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">1</span>
|
||||||
|
<span class="cline-any cline-yes">13</span>
|
||||||
|
<span class="cline-any cline-yes">13</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">1</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">'use strict';
|
||||||
|
|
||||||
|
function Queue(options) {
|
||||||
|
if (!(this instanceof Queue)) {
|
||||||
|
return new Queue(options);
|
||||||
|
}
|
||||||
|
|
||||||
|
options = options || {};
|
||||||
|
this.concurrency = options.concurrency || Infinity;
|
||||||
|
this.pending = 0;
|
||||||
|
this.jobs = [];
|
||||||
|
this.cbs = [];
|
||||||
|
this._done = done.bind(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
var arrayAddMethods = [
|
||||||
|
'push',
|
||||||
|
'unshift',
|
||||||
|
'splice'
|
||||||
|
];
|
||||||
|
|
||||||
|
arrayAddMethods.forEach(function(method) {
|
||||||
|
Queue.prototype[method] = function() {
|
||||||
|
var methodResult = Array.prototype[method].apply(this.jobs, arguments);
|
||||||
|
this._run();
|
||||||
|
return methodResult;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
Object.defineProperty(Queue.prototype, 'length', {
|
||||||
|
get: function() {
|
||||||
|
return this.pending + this.jobs.length;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Queue.prototype._run = function() {
|
||||||
|
if (this.pending === this.concurrency) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this.jobs.length) {
|
||||||
|
var job = this.jobs.shift();
|
||||||
|
this.pending++;
|
||||||
|
job(this._done);
|
||||||
|
this._run();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.pending === 0) {
|
||||||
|
while (this.cbs.length !== 0) {
|
||||||
|
var cb = this.cbs.pop();
|
||||||
|
process.nextTick(cb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Queue.prototype.onDone = function(cb) {
|
||||||
|
<span class="missing-if-branch" title="else path not taken" >E</span>if (typeof cb === 'function') {
|
||||||
|
this.cbs.push(cb);
|
||||||
|
this._run();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
function done() {
|
||||||
|
this.pending--;
|
||||||
|
this._run();
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = Queue;
|
||||||
|
</pre></td></tr>
|
||||||
|
</table></pre>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="footer">
|
||||||
|
<div class="meta">Generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Mon Sep 11 2017 11:14:14 GMT-0500 (CDT)</div>
|
||||||
|
</div>
|
||||||
|
<script src="../prettify.js"></script>
|
||||||
|
<script>
|
||||||
|
window.onload = function () {
|
||||||
|
if (typeof prettyPrint === 'function') {
|
||||||
|
prettyPrint();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<script src="../sorter.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
182
node/node_modules/async-limiter/coverage/lcov-report/base.css
generated
vendored
Normal file
182
node/node_modules/async-limiter/coverage/lcov-report/base.css
generated
vendored
Normal file
@@ -0,0 +1,182 @@
|
|||||||
|
body, html {
|
||||||
|
margin:0; padding: 0;
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
font-family: Helvetica Neue, Helvetica,Arial;
|
||||||
|
font-size: 10pt;
|
||||||
|
}
|
||||||
|
div.header, div.footer {
|
||||||
|
background: #eee;
|
||||||
|
padding: 1em;
|
||||||
|
}
|
||||||
|
div.header {
|
||||||
|
z-index: 100;
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
border-bottom: 1px solid #666;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
div.footer {
|
||||||
|
border-top: 1px solid #666;
|
||||||
|
}
|
||||||
|
div.body {
|
||||||
|
margin-top: 10em;
|
||||||
|
}
|
||||||
|
div.meta {
|
||||||
|
font-size: 90%;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
h1, h2, h3 {
|
||||||
|
font-weight: normal;
|
||||||
|
}
|
||||||
|
h1 {
|
||||||
|
font-size: 12pt;
|
||||||
|
}
|
||||||
|
h2 {
|
||||||
|
font-size: 10pt;
|
||||||
|
}
|
||||||
|
pre {
|
||||||
|
font-family: Consolas, Menlo, Monaco, monospace;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
line-height: 1.3;
|
||||||
|
font-size: 14px;
|
||||||
|
-moz-tab-size: 2;
|
||||||
|
-o-tab-size: 2;
|
||||||
|
tab-size: 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.path { font-size: 110%; }
|
||||||
|
div.path a:link, div.path a:visited { color: #000; }
|
||||||
|
table.coverage { border-collapse: collapse; margin:0; padding: 0 }
|
||||||
|
|
||||||
|
table.coverage td {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
color: #111;
|
||||||
|
vertical-align: top;
|
||||||
|
}
|
||||||
|
table.coverage td.line-count {
|
||||||
|
width: 50px;
|
||||||
|
text-align: right;
|
||||||
|
padding-right: 5px;
|
||||||
|
}
|
||||||
|
table.coverage td.line-coverage {
|
||||||
|
color: #777 !important;
|
||||||
|
text-align: right;
|
||||||
|
border-left: 1px solid #666;
|
||||||
|
border-right: 1px solid #666;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.coverage td.text {
|
||||||
|
}
|
||||||
|
|
||||||
|
table.coverage td span.cline-any {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 0 5px;
|
||||||
|
width: 40px;
|
||||||
|
}
|
||||||
|
table.coverage td span.cline-neutral {
|
||||||
|
background: #eee;
|
||||||
|
}
|
||||||
|
table.coverage td span.cline-yes {
|
||||||
|
background: #b5d592;
|
||||||
|
color: #999;
|
||||||
|
}
|
||||||
|
table.coverage td span.cline-no {
|
||||||
|
background: #fc8c84;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cstat-yes { color: #111; }
|
||||||
|
.cstat-no { background: #fc8c84; color: #111; }
|
||||||
|
.fstat-no { background: #ffc520; color: #111 !important; }
|
||||||
|
.cbranch-no { background: yellow !important; color: #111; }
|
||||||
|
|
||||||
|
.cstat-skip { background: #ddd; color: #111; }
|
||||||
|
.fstat-skip { background: #ddd; color: #111 !important; }
|
||||||
|
.cbranch-skip { background: #ddd !important; color: #111; }
|
||||||
|
|
||||||
|
.missing-if-branch {
|
||||||
|
display: inline-block;
|
||||||
|
margin-right: 10px;
|
||||||
|
position: relative;
|
||||||
|
padding: 0 4px;
|
||||||
|
background: black;
|
||||||
|
color: yellow;
|
||||||
|
}
|
||||||
|
|
||||||
|
.skip-if-branch {
|
||||||
|
display: none;
|
||||||
|
margin-right: 10px;
|
||||||
|
position: relative;
|
||||||
|
padding: 0 4px;
|
||||||
|
background: #ccc;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.missing-if-branch .typ, .skip-if-branch .typ {
|
||||||
|
color: inherit !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.entity, .metric { font-weight: bold; }
|
||||||
|
.metric { display: inline-block; border: 1px solid #333; padding: 0.3em; background: white; }
|
||||||
|
.metric small { font-size: 80%; font-weight: normal; color: #666; }
|
||||||
|
|
||||||
|
div.coverage-summary table { border-collapse: collapse; margin: 3em; font-size: 110%; }
|
||||||
|
div.coverage-summary td, div.coverage-summary table th { margin: 0; padding: 0.25em 1em; border-top: 1px solid #666; border-bottom: 1px solid #666; }
|
||||||
|
div.coverage-summary th { text-align: left; border: 1px solid #666; background: #eee; font-weight: normal; }
|
||||||
|
div.coverage-summary th.file { border-right: none !important; }
|
||||||
|
div.coverage-summary th.pic { border-left: none !important; text-align: right; }
|
||||||
|
div.coverage-summary th.pct { border-right: none !important; }
|
||||||
|
div.coverage-summary th.abs { border-left: none !important; text-align: right; }
|
||||||
|
div.coverage-summary td.pct { text-align: right; border-left: 1px solid #666; }
|
||||||
|
div.coverage-summary td.abs { text-align: right; font-size: 90%; color: #444; border-right: 1px solid #666; }
|
||||||
|
div.coverage-summary td.file { border-left: 1px solid #666; white-space: nowrap; }
|
||||||
|
div.coverage-summary td.pic { min-width: 120px !important; }
|
||||||
|
div.coverage-summary a:link { text-decoration: none; color: #000; }
|
||||||
|
div.coverage-summary a:visited { text-decoration: none; color: #777; }
|
||||||
|
div.coverage-summary a:hover { text-decoration: underline; }
|
||||||
|
div.coverage-summary tfoot td { border-top: 1px solid #666; }
|
||||||
|
|
||||||
|
div.coverage-summary .sorter {
|
||||||
|
height: 10px;
|
||||||
|
width: 7px;
|
||||||
|
display: inline-block;
|
||||||
|
margin-left: 0.5em;
|
||||||
|
background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent;
|
||||||
|
}
|
||||||
|
div.coverage-summary .sorted .sorter {
|
||||||
|
background-position: 0 -20px;
|
||||||
|
}
|
||||||
|
div.coverage-summary .sorted-desc .sorter {
|
||||||
|
background-position: 0 -10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.high { background: #b5d592 !important; }
|
||||||
|
.medium { background: #ffe87c !important; }
|
||||||
|
.low { background: #fc8c84 !important; }
|
||||||
|
|
||||||
|
span.cover-fill, span.cover-empty {
|
||||||
|
display:inline-block;
|
||||||
|
border:1px solid #444;
|
||||||
|
background: white;
|
||||||
|
height: 12px;
|
||||||
|
}
|
||||||
|
span.cover-fill {
|
||||||
|
background: #ccc;
|
||||||
|
border-right: 1px solid #444;
|
||||||
|
}
|
||||||
|
span.cover-empty {
|
||||||
|
background: white;
|
||||||
|
border-left: none;
|
||||||
|
}
|
||||||
|
span.cover-full {
|
||||||
|
border-right: none !important;
|
||||||
|
}
|
||||||
|
pre.prettyprint {
|
||||||
|
border: none !important;
|
||||||
|
padding: 0 !important;
|
||||||
|
margin: 0 !important;
|
||||||
|
}
|
||||||
|
.com { color: #999 !important; }
|
||||||
|
.ignore-none { color: #999; font-weight: normal; }
|
||||||
73
node/node_modules/async-limiter/coverage/lcov-report/index.html
generated
vendored
Normal file
73
node/node_modules/async-limiter/coverage/lcov-report/index.html
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<title>Code coverage report for All files</title>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<link rel="stylesheet" href="prettify.css">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<style type='text/css'>
|
||||||
|
div.coverage-summary .sorter {
|
||||||
|
background-image: url(sort-arrow-sprite.png);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="header high">
|
||||||
|
<h1>Code coverage report for <span class="entity">All files</span></h1>
|
||||||
|
<h2>
|
||||||
|
Statements: <span class="metric">100% <small>(37 / 37)</small></span>
|
||||||
|
Branches: <span class="metric">92.86% <small>(13 / 14)</small></span>
|
||||||
|
Functions: <span class="metric">100% <small>(7 / 7)</small></span>
|
||||||
|
Lines: <span class="metric">100% <small>(37 / 37)</small></span>
|
||||||
|
Ignored: <span class="metric"><span class="ignore-none">none</span></span>
|
||||||
|
</h2>
|
||||||
|
<div class="path"></div>
|
||||||
|
</div>
|
||||||
|
<div class="body">
|
||||||
|
<div class="coverage-summary">
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th data-col="file" data-fmt="html" data-html="true" class="file">File</th>
|
||||||
|
<th data-col="pic" data-type="number" data-fmt="html" data-html="true" class="pic"></th>
|
||||||
|
<th data-col="statements" data-type="number" data-fmt="pct" class="pct">Statements</th>
|
||||||
|
<th data-col="statements_raw" data-type="number" data-fmt="html" class="abs"></th>
|
||||||
|
<th data-col="branches" data-type="number" data-fmt="pct" class="pct">Branches</th>
|
||||||
|
<th data-col="branches_raw" data-type="number" data-fmt="html" class="abs"></th>
|
||||||
|
<th data-col="functions" data-type="number" data-fmt="pct" class="pct">Functions</th>
|
||||||
|
<th data-col="functions_raw" data-type="number" data-fmt="html" class="abs"></th>
|
||||||
|
<th data-col="lines" data-type="number" data-fmt="pct" class="pct">Lines</th>
|
||||||
|
<th data-col="lines_raw" data-type="number" data-fmt="html" class="abs"></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody><tr>
|
||||||
|
<td class="file high" data-value="async-throttle/"><a href="async-throttle/index.html">async-throttle/</a></td>
|
||||||
|
<td data-value="100" class="pic high"><span class="cover-fill cover-full" style="width: 100px;"></span><span class="cover-empty" style="width:0px;"></span></td>
|
||||||
|
<td data-value="100" class="pct high">100%</td>
|
||||||
|
<td data-value="37" class="abs high">(37 / 37)</td>
|
||||||
|
<td data-value="92.86" class="pct high">92.86%</td>
|
||||||
|
<td data-value="14" class="abs high">(13 / 14)</td>
|
||||||
|
<td data-value="100" class="pct high">100%</td>
|
||||||
|
<td data-value="7" class="abs high">(7 / 7)</td>
|
||||||
|
<td data-value="100" class="pct high">100%</td>
|
||||||
|
<td data-value="37" class="abs high">(37 / 37)</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="footer">
|
||||||
|
<div class="meta">Generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Mon Sep 11 2017 11:14:14 GMT-0500 (CDT)</div>
|
||||||
|
</div>
|
||||||
|
<script src="prettify.js"></script>
|
||||||
|
<script>
|
||||||
|
window.onload = function () {
|
||||||
|
if (typeof prettyPrint === 'function') {
|
||||||
|
prettyPrint();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<script src="sorter.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
1
node/node_modules/async-limiter/coverage/lcov-report/prettify.css
generated
vendored
Normal file
1
node/node_modules/async-limiter/coverage/lcov-report/prettify.css
generated
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee}
|
||||||
1
node/node_modules/async-limiter/coverage/lcov-report/prettify.js
generated
vendored
Normal file
1
node/node_modules/async-limiter/coverage/lcov-report/prettify.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
BIN
node/node_modules/async-limiter/coverage/lcov-report/sort-arrow-sprite.png
generated
vendored
Normal file
BIN
node/node_modules/async-limiter/coverage/lcov-report/sort-arrow-sprite.png
generated
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 209 B |
156
node/node_modules/async-limiter/coverage/lcov-report/sorter.js
generated
vendored
Normal file
156
node/node_modules/async-limiter/coverage/lcov-report/sorter.js
generated
vendored
Normal file
@@ -0,0 +1,156 @@
|
|||||||
|
var addSorting = (function () {
|
||||||
|
"use strict";
|
||||||
|
var cols,
|
||||||
|
currentSort = {
|
||||||
|
index: 0,
|
||||||
|
desc: false
|
||||||
|
};
|
||||||
|
|
||||||
|
// returns the summary table element
|
||||||
|
function getTable() { return document.querySelector('.coverage-summary table'); }
|
||||||
|
// returns the thead element of the summary table
|
||||||
|
function getTableHeader() { return getTable().querySelector('thead tr'); }
|
||||||
|
// returns the tbody element of the summary table
|
||||||
|
function getTableBody() { return getTable().querySelector('tbody'); }
|
||||||
|
// returns the th element for nth column
|
||||||
|
function getNthColumn(n) { return getTableHeader().querySelectorAll('th')[n]; }
|
||||||
|
|
||||||
|
// loads all columns
|
||||||
|
function loadColumns() {
|
||||||
|
var colNodes = getTableHeader().querySelectorAll('th'),
|
||||||
|
colNode,
|
||||||
|
cols = [],
|
||||||
|
col,
|
||||||
|
i;
|
||||||
|
|
||||||
|
for (i = 0; i < colNodes.length; i += 1) {
|
||||||
|
colNode = colNodes[i];
|
||||||
|
col = {
|
||||||
|
key: colNode.getAttribute('data-col'),
|
||||||
|
sortable: !colNode.getAttribute('data-nosort'),
|
||||||
|
type: colNode.getAttribute('data-type') || 'string'
|
||||||
|
};
|
||||||
|
cols.push(col);
|
||||||
|
if (col.sortable) {
|
||||||
|
col.defaultDescSort = col.type === 'number';
|
||||||
|
colNode.innerHTML = colNode.innerHTML + '<span class="sorter"></span>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cols;
|
||||||
|
}
|
||||||
|
// attaches a data attribute to every tr element with an object
|
||||||
|
// of data values keyed by column name
|
||||||
|
function loadRowData(tableRow) {
|
||||||
|
var tableCols = tableRow.querySelectorAll('td'),
|
||||||
|
colNode,
|
||||||
|
col,
|
||||||
|
data = {},
|
||||||
|
i,
|
||||||
|
val;
|
||||||
|
for (i = 0; i < tableCols.length; i += 1) {
|
||||||
|
colNode = tableCols[i];
|
||||||
|
col = cols[i];
|
||||||
|
val = colNode.getAttribute('data-value');
|
||||||
|
if (col.type === 'number') {
|
||||||
|
val = Number(val);
|
||||||
|
}
|
||||||
|
data[col.key] = val;
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
// loads all row data
|
||||||
|
function loadData() {
|
||||||
|
var rows = getTableBody().querySelectorAll('tr'),
|
||||||
|
i;
|
||||||
|
|
||||||
|
for (i = 0; i < rows.length; i += 1) {
|
||||||
|
rows[i].data = loadRowData(rows[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// sorts the table using the data for the ith column
|
||||||
|
function sortByIndex(index, desc) {
|
||||||
|
var key = cols[index].key,
|
||||||
|
sorter = function (a, b) {
|
||||||
|
a = a.data[key];
|
||||||
|
b = b.data[key];
|
||||||
|
return a < b ? -1 : a > b ? 1 : 0;
|
||||||
|
},
|
||||||
|
finalSorter = sorter,
|
||||||
|
tableBody = document.querySelector('.coverage-summary tbody'),
|
||||||
|
rowNodes = tableBody.querySelectorAll('tr'),
|
||||||
|
rows = [],
|
||||||
|
i;
|
||||||
|
|
||||||
|
if (desc) {
|
||||||
|
finalSorter = function (a, b) {
|
||||||
|
return -1 * sorter(a, b);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < rowNodes.length; i += 1) {
|
||||||
|
rows.push(rowNodes[i]);
|
||||||
|
tableBody.removeChild(rowNodes[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
rows.sort(finalSorter);
|
||||||
|
|
||||||
|
for (i = 0; i < rows.length; i += 1) {
|
||||||
|
tableBody.appendChild(rows[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// removes sort indicators for current column being sorted
|
||||||
|
function removeSortIndicators() {
|
||||||
|
var col = getNthColumn(currentSort.index),
|
||||||
|
cls = col.className;
|
||||||
|
|
||||||
|
cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, '');
|
||||||
|
col.className = cls;
|
||||||
|
}
|
||||||
|
// adds sort indicators for current column being sorted
|
||||||
|
function addSortIndicators() {
|
||||||
|
getNthColumn(currentSort.index).className += currentSort.desc ? ' sorted-desc' : ' sorted';
|
||||||
|
}
|
||||||
|
// adds event listeners for all sorter widgets
|
||||||
|
function enableUI() {
|
||||||
|
var i,
|
||||||
|
el,
|
||||||
|
ithSorter = function ithSorter(i) {
|
||||||
|
var col = cols[i];
|
||||||
|
|
||||||
|
return function () {
|
||||||
|
var desc = col.defaultDescSort;
|
||||||
|
|
||||||
|
if (currentSort.index === i) {
|
||||||
|
desc = !currentSort.desc;
|
||||||
|
}
|
||||||
|
sortByIndex(i, desc);
|
||||||
|
removeSortIndicators();
|
||||||
|
currentSort.index = i;
|
||||||
|
currentSort.desc = desc;
|
||||||
|
addSortIndicators();
|
||||||
|
};
|
||||||
|
};
|
||||||
|
for (i =0 ; i < cols.length; i += 1) {
|
||||||
|
if (cols[i].sortable) {
|
||||||
|
el = getNthColumn(i).querySelector('.sorter');
|
||||||
|
if (el.addEventListener) {
|
||||||
|
el.addEventListener('click', ithSorter(i));
|
||||||
|
} else {
|
||||||
|
el.attachEvent('onclick', ithSorter(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// adds sorting functionality to the UI
|
||||||
|
return function () {
|
||||||
|
if (!getTable()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cols = loadColumns();
|
||||||
|
loadData(cols);
|
||||||
|
addSortIndicators();
|
||||||
|
enableUI();
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
|
window.addEventListener('load', addSorting);
|
||||||
74
node/node_modules/async-limiter/coverage/lcov.info
generated
vendored
Normal file
74
node/node_modules/async-limiter/coverage/lcov.info
generated
vendored
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
TN:
|
||||||
|
SF:/Users/samuelreed/git/forks/async-throttle/index.js
|
||||||
|
FN:3,Queue
|
||||||
|
FN:22,(anonymous_2)
|
||||||
|
FN:23,(anonymous_3)
|
||||||
|
FN:31,(anonymous_4)
|
||||||
|
FN:36,(anonymous_5)
|
||||||
|
FN:55,(anonymous_6)
|
||||||
|
FN:62,done
|
||||||
|
FNF:7
|
||||||
|
FNH:7
|
||||||
|
FNDA:7,Queue
|
||||||
|
FNDA:3,(anonymous_2)
|
||||||
|
FNDA:13,(anonymous_3)
|
||||||
|
FNDA:19,(anonymous_4)
|
||||||
|
FNDA:45,(anonymous_5)
|
||||||
|
FNDA:6,(anonymous_6)
|
||||||
|
FNDA:13,done
|
||||||
|
DA:3,1
|
||||||
|
DA:4,7
|
||||||
|
DA:5,1
|
||||||
|
DA:8,6
|
||||||
|
DA:9,6
|
||||||
|
DA:10,6
|
||||||
|
DA:11,6
|
||||||
|
DA:12,6
|
||||||
|
DA:13,6
|
||||||
|
DA:16,1
|
||||||
|
DA:22,1
|
||||||
|
DA:23,3
|
||||||
|
DA:24,13
|
||||||
|
DA:25,13
|
||||||
|
DA:26,13
|
||||||
|
DA:30,1
|
||||||
|
DA:32,19
|
||||||
|
DA:36,1
|
||||||
|
DA:37,45
|
||||||
|
DA:38,6
|
||||||
|
DA:40,39
|
||||||
|
DA:41,13
|
||||||
|
DA:42,13
|
||||||
|
DA:43,13
|
||||||
|
DA:44,13
|
||||||
|
DA:47,39
|
||||||
|
DA:48,18
|
||||||
|
DA:49,6
|
||||||
|
DA:50,6
|
||||||
|
DA:55,1
|
||||||
|
DA:56,6
|
||||||
|
DA:57,6
|
||||||
|
DA:58,6
|
||||||
|
DA:62,1
|
||||||
|
DA:63,13
|
||||||
|
DA:64,13
|
||||||
|
DA:67,1
|
||||||
|
LF:37
|
||||||
|
LH:37
|
||||||
|
BRDA:4,1,0,1
|
||||||
|
BRDA:4,1,1,6
|
||||||
|
BRDA:8,2,0,6
|
||||||
|
BRDA:8,2,1,5
|
||||||
|
BRDA:9,3,0,6
|
||||||
|
BRDA:9,3,1,5
|
||||||
|
BRDA:37,4,0,6
|
||||||
|
BRDA:37,4,1,39
|
||||||
|
BRDA:40,5,0,13
|
||||||
|
BRDA:40,5,1,26
|
||||||
|
BRDA:47,6,0,18
|
||||||
|
BRDA:47,6,1,21
|
||||||
|
BRDA:56,7,0,6
|
||||||
|
BRDA:56,7,1,0
|
||||||
|
BRF:14
|
||||||
|
BRH:13
|
||||||
|
end_of_record
|
||||||
67
node/node_modules/async-limiter/index.js
generated
vendored
Normal file
67
node/node_modules/async-limiter/index.js
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
function Queue(options) {
|
||||||
|
if (!(this instanceof Queue)) {
|
||||||
|
return new Queue(options);
|
||||||
|
}
|
||||||
|
|
||||||
|
options = options || {};
|
||||||
|
this.concurrency = options.concurrency || Infinity;
|
||||||
|
this.pending = 0;
|
||||||
|
this.jobs = [];
|
||||||
|
this.cbs = [];
|
||||||
|
this._done = done.bind(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
var arrayAddMethods = [
|
||||||
|
'push',
|
||||||
|
'unshift',
|
||||||
|
'splice'
|
||||||
|
];
|
||||||
|
|
||||||
|
arrayAddMethods.forEach(function(method) {
|
||||||
|
Queue.prototype[method] = function() {
|
||||||
|
var methodResult = Array.prototype[method].apply(this.jobs, arguments);
|
||||||
|
this._run();
|
||||||
|
return methodResult;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
Object.defineProperty(Queue.prototype, 'length', {
|
||||||
|
get: function() {
|
||||||
|
return this.pending + this.jobs.length;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Queue.prototype._run = function() {
|
||||||
|
if (this.pending === this.concurrency) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this.jobs.length) {
|
||||||
|
var job = this.jobs.shift();
|
||||||
|
this.pending++;
|
||||||
|
job(this._done);
|
||||||
|
this._run();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.pending === 0) {
|
||||||
|
while (this.cbs.length !== 0) {
|
||||||
|
var cb = this.cbs.pop();
|
||||||
|
process.nextTick(cb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Queue.prototype.onDone = function(cb) {
|
||||||
|
if (typeof cb === 'function') {
|
||||||
|
this.cbs.push(cb);
|
||||||
|
this._run();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
function done() {
|
||||||
|
this.pending--;
|
||||||
|
this._run();
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = Queue;
|
||||||
69
node/node_modules/async-limiter/package.json
generated
vendored
Normal file
69
node/node_modules/async-limiter/package.json
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
{
|
||||||
|
"_from": "async-limiter@~1.0.0",
|
||||||
|
"_id": "async-limiter@1.0.0",
|
||||||
|
"_inBundle": false,
|
||||||
|
"_integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg==",
|
||||||
|
"_location": "/async-limiter",
|
||||||
|
"_phantomChildren": {},
|
||||||
|
"_requested": {
|
||||||
|
"type": "range",
|
||||||
|
"registry": true,
|
||||||
|
"raw": "async-limiter@~1.0.0",
|
||||||
|
"name": "async-limiter",
|
||||||
|
"escapedName": "async-limiter",
|
||||||
|
"rawSpec": "~1.0.0",
|
||||||
|
"saveSpec": null,
|
||||||
|
"fetchSpec": "~1.0.0"
|
||||||
|
},
|
||||||
|
"_requiredBy": [
|
||||||
|
"/ws"
|
||||||
|
],
|
||||||
|
"_resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz",
|
||||||
|
"_shasum": "78faed8c3d074ab81f22b4e985d79e8738f720f8",
|
||||||
|
"_spec": "async-limiter@~1.0.0",
|
||||||
|
"_where": "/usr/home/web/cp/clonos/node/node_modules/ws",
|
||||||
|
"author": {
|
||||||
|
"name": "Samuel Reed"
|
||||||
|
},
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/strml/async-limiter/issues"
|
||||||
|
},
|
||||||
|
"bundleDependencies": false,
|
||||||
|
"dependencies": {},
|
||||||
|
"deprecated": false,
|
||||||
|
"description": "asynchronous function queue with adjustable concurrency",
|
||||||
|
"devDependencies": {
|
||||||
|
"coveralls": "^2.11.2",
|
||||||
|
"eslint": "^4.6.1",
|
||||||
|
"eslint-plugin-mocha": "^4.11.0",
|
||||||
|
"intelli-espower-loader": "^1.0.1",
|
||||||
|
"istanbul": "^0.3.2",
|
||||||
|
"mocha": "^3.5.2",
|
||||||
|
"power-assert": "^1.4.4"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/strml/async-limiter#readme",
|
||||||
|
"keywords": [
|
||||||
|
"throttle",
|
||||||
|
"async",
|
||||||
|
"limiter",
|
||||||
|
"asynchronous",
|
||||||
|
"job",
|
||||||
|
"task",
|
||||||
|
"concurrency",
|
||||||
|
"concurrent"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"name": "async-limiter",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/strml/async-limiter.git"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"coverage": "istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | coveralls",
|
||||||
|
"example": "node example",
|
||||||
|
"lint": "eslint .",
|
||||||
|
"test": "mocha --R intelli-espower-loader test/",
|
||||||
|
"travis": "npm run lint && npm run coverage"
|
||||||
|
},
|
||||||
|
"version": "1.0.0"
|
||||||
|
}
|
||||||
132
node/node_modules/async-limiter/readme.md
generated
vendored
Normal file
132
node/node_modules/async-limiter/readme.md
generated
vendored
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
# Async-Limiter
|
||||||
|
|
||||||
|
A module for limiting concurrent asynchronous actions in flight. Forked from [queue](https://github.com/jessetane/queue).
|
||||||
|
|
||||||
|
[](http://www.npmjs.org/async-limiter)
|
||||||
|
[](https://travis-ci.org/STRML/async-limiter)
|
||||||
|
[](https://coveralls.io/r/STRML/async-limiter)
|
||||||
|
|
||||||
|
This module exports a class `Limiter` that implements some of the `Array` API.
|
||||||
|
Pass async functions (ones that accept a callback or return a promise) to an instance's additive array methods.
|
||||||
|
|
||||||
|
## Motivation
|
||||||
|
|
||||||
|
Certain functions, like `zlib`, have [undesirable behavior](https://github.com/nodejs/node/issues/8871#issuecomment-250915913) when
|
||||||
|
run at infinite concurrency.
|
||||||
|
|
||||||
|
In this case, it is actually faster, and takes far less memory, to limit concurrency.
|
||||||
|
|
||||||
|
This module should do the absolute minimum work necessary to queue up functions. PRs are welcome that would
|
||||||
|
make this module faster or lighter, but new functionality is not desired.
|
||||||
|
|
||||||
|
Style should confirm to nodejs/node style.
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
``` javascript
|
||||||
|
var Limiter = require('async-limiter')
|
||||||
|
|
||||||
|
var t = new Limiter({concurrency: 2});
|
||||||
|
var results = []
|
||||||
|
|
||||||
|
// add jobs using the familiar Array API
|
||||||
|
t.push(function (cb) {
|
||||||
|
results.push('two')
|
||||||
|
cb()
|
||||||
|
})
|
||||||
|
|
||||||
|
t.push(
|
||||||
|
function (cb) {
|
||||||
|
results.push('four')
|
||||||
|
cb()
|
||||||
|
},
|
||||||
|
function (cb) {
|
||||||
|
results.push('five')
|
||||||
|
cb()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
t.unshift(function (cb) {
|
||||||
|
results.push('one')
|
||||||
|
cb()
|
||||||
|
})
|
||||||
|
|
||||||
|
t.splice(2, 0, function (cb) {
|
||||||
|
results.push('three')
|
||||||
|
cb()
|
||||||
|
})
|
||||||
|
|
||||||
|
// Jobs run automatically. If you want a callback when all are done,
|
||||||
|
// call 'onDone()'.
|
||||||
|
t.onDone(function () {
|
||||||
|
console.log('all done:', results)
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
## Zlib Example
|
||||||
|
|
||||||
|
```js
|
||||||
|
const zlib = require('zlib');
|
||||||
|
const Limiter = require('async-limiter');
|
||||||
|
|
||||||
|
const message = {some: "data"};
|
||||||
|
const payload = new Buffer(JSON.stringify(message));
|
||||||
|
|
||||||
|
// Try with different concurrency values to see how this actually
|
||||||
|
// slows significantly with higher concurrency!
|
||||||
|
//
|
||||||
|
// 5: 1398.607ms
|
||||||
|
// 10: 1375.668ms
|
||||||
|
// Infinity: 4423.300ms
|
||||||
|
//
|
||||||
|
const t = new Limiter({concurrency: 5});
|
||||||
|
function deflate(payload, cb) {
|
||||||
|
t.push(function(done) {
|
||||||
|
zlib.deflate(payload, function(err, buffer) {
|
||||||
|
done();
|
||||||
|
cb(err, buffer);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
console.time('deflate');
|
||||||
|
for(let i = 0; i < 30000; ++i) {
|
||||||
|
deflate(payload, function (err, buffer) {});
|
||||||
|
}
|
||||||
|
q.onDone(function() {
|
||||||
|
console.timeEnd('deflate');
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
`npm install async-limiter`
|
||||||
|
|
||||||
|
## Test
|
||||||
|
|
||||||
|
`npm test`
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
### `var t = new Limiter([opts])`
|
||||||
|
Constructor. `opts` may contain inital values for:
|
||||||
|
* `q.concurrency`
|
||||||
|
|
||||||
|
## Instance methods
|
||||||
|
|
||||||
|
### `q.onDone(fn)`
|
||||||
|
`fn` will be called once and only once, when the queue is empty.
|
||||||
|
|
||||||
|
## Instance methods mixed in from `Array`
|
||||||
|
Mozilla has docs on how these methods work [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array).
|
||||||
|
### `q.push(element1, ..., elementN)`
|
||||||
|
### `q.unshift(element1, ..., elementN)`
|
||||||
|
### `q.splice(index , howMany[, element1[, ...[, elementN]]])`
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
### `q.concurrency`
|
||||||
|
Max number of jobs the queue should process concurrently, defaults to `Infinity`.
|
||||||
|
|
||||||
|
### `q.length`
|
||||||
|
Jobs pending + jobs to process (readonly).
|
||||||
|
|
||||||
24
node/node_modules/esprima/README.md
generated
vendored
Normal file
24
node/node_modules/esprima/README.md
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
**Esprima** ([esprima.org](http://esprima.org), BSD license) is a high performance,
|
||||||
|
standard-compliant [ECMAScript](http://www.ecma-international.org/publications/standards/Ecma-262.htm)
|
||||||
|
parser written in ECMAScript (also popularly known as
|
||||||
|
[JavaScript](http://en.wikipedia.org/wiki/JavaScript>JavaScript)).
|
||||||
|
Esprima is created and maintained by [Ariya Hidayat](http://twitter.com/ariyahidayat),
|
||||||
|
with the help of [many contributors](https://github.com/jquery/esprima/contributors).
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
- Full support for ECMAScript 5.1 ([ECMA-262](http://www.ecma-international.org/publications/standards/Ecma-262.htm))
|
||||||
|
- Sensible [syntax tree format](http://esprima.org/doc/index.html#ast) compatible with Mozilla
|
||||||
|
[Parser AST](https://developer.mozilla.org/en/SpiderMonkey/Parser_API)
|
||||||
|
- Optional tracking of syntax node location (index-based and line-column)
|
||||||
|
- Heavily tested (> 700 [unit tests](http://esprima.org/test/) with [full code coverage](http://esprima.org/test/coverage.html))
|
||||||
|
- [Partial support](http://esprima.org/doc/es6.html) for ECMAScript 6
|
||||||
|
|
||||||
|
Esprima serves as a **building block** for some JavaScript
|
||||||
|
language tools, from [code instrumentation](http://esprima.org/demo/functiontrace.html)
|
||||||
|
to [editor autocompletion](http://esprima.org/demo/autocomplete.html).
|
||||||
|
|
||||||
|
Esprima runs on many popular web browsers, as well as other ECMAScript platforms such as
|
||||||
|
[Rhino](http://www.mozilla.org/rhino), [Nashorn](http://openjdk.java.net/projects/nashorn/), and [Node.js](https://npmjs.org/package/esprima).
|
||||||
|
|
||||||
|
For more information, check the web site [esprima.org](http://esprima.org).
|
||||||
127
node/node_modules/esprima/bin/esparse.js
generated
vendored
Executable file
127
node/node_modules/esprima/bin/esparse.js
generated
vendored
Executable file
@@ -0,0 +1,127 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
/*
|
||||||
|
Copyright (C) 2012 Ariya Hidayat <ariya.hidayat@gmail.com>
|
||||||
|
Copyright (C) 2011 Ariya Hidayat <ariya.hidayat@gmail.com>
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||||
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*jslint sloppy:true node:true rhino:true */
|
||||||
|
|
||||||
|
var fs, esprima, fname, content, options, syntax;
|
||||||
|
|
||||||
|
if (typeof require === 'function') {
|
||||||
|
fs = require('fs');
|
||||||
|
esprima = require('esprima');
|
||||||
|
} else if (typeof load === 'function') {
|
||||||
|
try {
|
||||||
|
load('esprima.js');
|
||||||
|
} catch (e) {
|
||||||
|
load('../esprima.js');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Shims to Node.js objects when running under Rhino.
|
||||||
|
if (typeof console === 'undefined' && typeof process === 'undefined') {
|
||||||
|
console = { log: print };
|
||||||
|
fs = { readFileSync: readFile };
|
||||||
|
process = { argv: arguments, exit: quit };
|
||||||
|
process.argv.unshift('esparse.js');
|
||||||
|
process.argv.unshift('rhino');
|
||||||
|
}
|
||||||
|
|
||||||
|
function showUsage() {
|
||||||
|
console.log('Usage:');
|
||||||
|
console.log(' esparse [options] file.js');
|
||||||
|
console.log();
|
||||||
|
console.log('Available options:');
|
||||||
|
console.log();
|
||||||
|
console.log(' --comment Gather all line and block comments in an array');
|
||||||
|
console.log(' --loc Include line-column location info for each syntax node');
|
||||||
|
console.log(' --range Include index-based range for each syntax node');
|
||||||
|
console.log(' --raw Display the raw value of literals');
|
||||||
|
console.log(' --tokens List all tokens in an array');
|
||||||
|
console.log(' --tolerant Tolerate errors on a best-effort basis (experimental)');
|
||||||
|
console.log(' -v, --version Shows program version');
|
||||||
|
console.log();
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (process.argv.length <= 2) {
|
||||||
|
showUsage();
|
||||||
|
}
|
||||||
|
|
||||||
|
options = {};
|
||||||
|
|
||||||
|
process.argv.splice(2).forEach(function (entry) {
|
||||||
|
|
||||||
|
if (entry === '-h' || entry === '--help') {
|
||||||
|
showUsage();
|
||||||
|
} else if (entry === '-v' || entry === '--version') {
|
||||||
|
console.log('ECMAScript Parser (using Esprima version', esprima.version, ')');
|
||||||
|
console.log();
|
||||||
|
process.exit(0);
|
||||||
|
} else if (entry === '--comment') {
|
||||||
|
options.comment = true;
|
||||||
|
} else if (entry === '--loc') {
|
||||||
|
options.loc = true;
|
||||||
|
} else if (entry === '--range') {
|
||||||
|
options.range = true;
|
||||||
|
} else if (entry === '--raw') {
|
||||||
|
options.raw = true;
|
||||||
|
} else if (entry === '--tokens') {
|
||||||
|
options.tokens = true;
|
||||||
|
} else if (entry === '--tolerant') {
|
||||||
|
options.tolerant = true;
|
||||||
|
} else if (entry.slice(0, 2) === '--') {
|
||||||
|
console.log('Error: unknown option ' + entry + '.');
|
||||||
|
process.exit(1);
|
||||||
|
} else if (typeof fname === 'string') {
|
||||||
|
console.log('Error: more than one input file.');
|
||||||
|
process.exit(1);
|
||||||
|
} else {
|
||||||
|
fname = entry;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (typeof fname !== 'string') {
|
||||||
|
console.log('Error: no input file.');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Special handling for regular expression literal since we need to
|
||||||
|
// convert it to a string literal, otherwise it will be decoded
|
||||||
|
// as object "{}" and the regular expression would be lost.
|
||||||
|
function adjustRegexLiteral(key, value) {
|
||||||
|
if (key === 'value' && value instanceof RegExp) {
|
||||||
|
value = value.toString();
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
content = fs.readFileSync(fname, 'utf-8');
|
||||||
|
syntax = esprima.parse(content, options);
|
||||||
|
console.log(JSON.stringify(syntax, adjustRegexLiteral, 4));
|
||||||
|
} catch (e) {
|
||||||
|
console.log('Error: ' + e.message);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
199
node/node_modules/esprima/bin/esvalidate.js
generated
vendored
Executable file
199
node/node_modules/esprima/bin/esvalidate.js
generated
vendored
Executable file
@@ -0,0 +1,199 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
/*
|
||||||
|
Copyright (C) 2012 Ariya Hidayat <ariya.hidayat@gmail.com>
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||||
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*jslint sloppy:true plusplus:true node:true rhino:true */
|
||||||
|
/*global phantom:true */
|
||||||
|
|
||||||
|
var fs, system, esprima, options, fnames, count;
|
||||||
|
|
||||||
|
if (typeof esprima === 'undefined') {
|
||||||
|
// PhantomJS can only require() relative files
|
||||||
|
if (typeof phantom === 'object') {
|
||||||
|
fs = require('fs');
|
||||||
|
system = require('system');
|
||||||
|
esprima = require('./esprima');
|
||||||
|
} else if (typeof require === 'function') {
|
||||||
|
fs = require('fs');
|
||||||
|
esprima = require('esprima');
|
||||||
|
} else if (typeof load === 'function') {
|
||||||
|
try {
|
||||||
|
load('esprima.js');
|
||||||
|
} catch (e) {
|
||||||
|
load('../esprima.js');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Shims to Node.js objects when running under PhantomJS 1.7+.
|
||||||
|
if (typeof phantom === 'object') {
|
||||||
|
fs.readFileSync = fs.read;
|
||||||
|
process = {
|
||||||
|
argv: [].slice.call(system.args),
|
||||||
|
exit: phantom.exit
|
||||||
|
};
|
||||||
|
process.argv.unshift('phantomjs');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Shims to Node.js objects when running under Rhino.
|
||||||
|
if (typeof console === 'undefined' && typeof process === 'undefined') {
|
||||||
|
console = { log: print };
|
||||||
|
fs = { readFileSync: readFile };
|
||||||
|
process = { argv: arguments, exit: quit };
|
||||||
|
process.argv.unshift('esvalidate.js');
|
||||||
|
process.argv.unshift('rhino');
|
||||||
|
}
|
||||||
|
|
||||||
|
function showUsage() {
|
||||||
|
console.log('Usage:');
|
||||||
|
console.log(' esvalidate [options] file.js');
|
||||||
|
console.log();
|
||||||
|
console.log('Available options:');
|
||||||
|
console.log();
|
||||||
|
console.log(' --format=type Set the report format, plain (default) or junit');
|
||||||
|
console.log(' -v, --version Print program version');
|
||||||
|
console.log();
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (process.argv.length <= 2) {
|
||||||
|
showUsage();
|
||||||
|
}
|
||||||
|
|
||||||
|
options = {
|
||||||
|
format: 'plain'
|
||||||
|
};
|
||||||
|
|
||||||
|
fnames = [];
|
||||||
|
|
||||||
|
process.argv.splice(2).forEach(function (entry) {
|
||||||
|
|
||||||
|
if (entry === '-h' || entry === '--help') {
|
||||||
|
showUsage();
|
||||||
|
} else if (entry === '-v' || entry === '--version') {
|
||||||
|
console.log('ECMAScript Validator (using Esprima version', esprima.version, ')');
|
||||||
|
console.log();
|
||||||
|
process.exit(0);
|
||||||
|
} else if (entry.slice(0, 9) === '--format=') {
|
||||||
|
options.format = entry.slice(9);
|
||||||
|
if (options.format !== 'plain' && options.format !== 'junit') {
|
||||||
|
console.log('Error: unknown report format ' + options.format + '.');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
} else if (entry.slice(0, 2) === '--') {
|
||||||
|
console.log('Error: unknown option ' + entry + '.');
|
||||||
|
process.exit(1);
|
||||||
|
} else {
|
||||||
|
fnames.push(entry);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (fnames.length === 0) {
|
||||||
|
console.log('Error: no input file.');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.format === 'junit') {
|
||||||
|
console.log('<?xml version="1.0" encoding="UTF-8"?>');
|
||||||
|
console.log('<testsuites>');
|
||||||
|
}
|
||||||
|
|
||||||
|
count = 0;
|
||||||
|
fnames.forEach(function (fname) {
|
||||||
|
var content, timestamp, syntax, name;
|
||||||
|
try {
|
||||||
|
content = fs.readFileSync(fname, 'utf-8');
|
||||||
|
|
||||||
|
if (content[0] === '#' && content[1] === '!') {
|
||||||
|
content = '//' + content.substr(2, content.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
timestamp = Date.now();
|
||||||
|
syntax = esprima.parse(content, { tolerant: true });
|
||||||
|
|
||||||
|
if (options.format === 'junit') {
|
||||||
|
|
||||||
|
name = fname;
|
||||||
|
if (name.lastIndexOf('/') >= 0) {
|
||||||
|
name = name.slice(name.lastIndexOf('/') + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('<testsuite name="' + fname + '" errors="0" ' +
|
||||||
|
' failures="' + syntax.errors.length + '" ' +
|
||||||
|
' tests="' + syntax.errors.length + '" ' +
|
||||||
|
' time="' + Math.round((Date.now() - timestamp) / 1000) +
|
||||||
|
'">');
|
||||||
|
|
||||||
|
syntax.errors.forEach(function (error) {
|
||||||
|
var msg = error.message;
|
||||||
|
msg = msg.replace(/^Line\ [0-9]*\:\ /, '');
|
||||||
|
console.log(' <testcase name="Line ' + error.lineNumber + ': ' + msg + '" ' +
|
||||||
|
' time="0">');
|
||||||
|
console.log(' <error type="SyntaxError" message="' + error.message + '">' +
|
||||||
|
error.message + '(' + name + ':' + error.lineNumber + ')' +
|
||||||
|
'</error>');
|
||||||
|
console.log(' </testcase>');
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log('</testsuite>');
|
||||||
|
|
||||||
|
} else if (options.format === 'plain') {
|
||||||
|
|
||||||
|
syntax.errors.forEach(function (error) {
|
||||||
|
var msg = error.message;
|
||||||
|
msg = msg.replace(/^Line\ [0-9]*\:\ /, '');
|
||||||
|
msg = fname + ':' + error.lineNumber + ': ' + msg;
|
||||||
|
console.log(msg);
|
||||||
|
++count;
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
++count;
|
||||||
|
if (options.format === 'junit') {
|
||||||
|
console.log('<testsuite name="' + fname + '" errors="1" failures="0" tests="1" ' +
|
||||||
|
' time="' + Math.round((Date.now() - timestamp) / 1000) + '">');
|
||||||
|
console.log(' <testcase name="' + e.message + '" ' + ' time="0">');
|
||||||
|
console.log(' <error type="ParseError" message="' + e.message + '">' +
|
||||||
|
e.message + '(' + fname + ((e.lineNumber) ? ':' + e.lineNumber : '') +
|
||||||
|
')</error>');
|
||||||
|
console.log(' </testcase>');
|
||||||
|
console.log('</testsuite>');
|
||||||
|
} else {
|
||||||
|
console.log('Error: ' + e.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (options.format === 'junit') {
|
||||||
|
console.log('</testsuites>');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count > 0) {
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count === 0 && typeof phantom === 'object') {
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
4156
node/node_modules/esprima/esprima.js
generated
vendored
Normal file
4156
node/node_modules/esprima/esprima.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
104
node/node_modules/esprima/package.json
generated
vendored
Normal file
104
node/node_modules/esprima/package.json
generated
vendored
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
{
|
||||||
|
"_from": "esprima@~ 2.0.0",
|
||||||
|
"_id": "esprima@2.0.0",
|
||||||
|
"_inBundle": false,
|
||||||
|
"_integrity": "sha1-YJrFwmZ+rlQztB657OziMxtBSY8=",
|
||||||
|
"_location": "/esprima",
|
||||||
|
"_phantomChildren": {},
|
||||||
|
"_requested": {
|
||||||
|
"type": "range",
|
||||||
|
"registry": true,
|
||||||
|
"raw": "esprima@~ 2.0.0",
|
||||||
|
"name": "esprima",
|
||||||
|
"escapedName": "esprima",
|
||||||
|
"rawSpec": "~ 2.0.0",
|
||||||
|
"saveSpec": null,
|
||||||
|
"fetchSpec": "~ 2.0.0"
|
||||||
|
},
|
||||||
|
"_requiredBy": [
|
||||||
|
"/js-yaml"
|
||||||
|
],
|
||||||
|
"_resolved": "https://registry.npmjs.org/esprima/-/esprima-2.0.0.tgz",
|
||||||
|
"_shasum": "609ac5c2667eae5433b41eb9ecece2331b41498f",
|
||||||
|
"_spec": "esprima@~ 2.0.0",
|
||||||
|
"_where": "/usr/home/web/cp/clonos/node/node_modules/js-yaml",
|
||||||
|
"author": {
|
||||||
|
"name": "Ariya Hidayat",
|
||||||
|
"email": "ariya.hidayat@gmail.com"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"esparse": "./bin/esparse.js",
|
||||||
|
"esvalidate": "./bin/esvalidate.js"
|
||||||
|
},
|
||||||
|
"bugs": {
|
||||||
|
"url": "http://issues.esprima.org"
|
||||||
|
},
|
||||||
|
"bundleDependencies": false,
|
||||||
|
"deprecated": false,
|
||||||
|
"description": "ECMAScript parsing infrastructure for multipurpose analysis",
|
||||||
|
"devDependencies": {
|
||||||
|
"complexity-report": "~1.1.1",
|
||||||
|
"escomplex-js": "1.0.0",
|
||||||
|
"eslint": "~0.12.0",
|
||||||
|
"istanbul": "~0.2.6",
|
||||||
|
"jscs": "~1.10.0",
|
||||||
|
"json-diff": "~0.3.1",
|
||||||
|
"optimist": "~0.6.0",
|
||||||
|
"regenerate": "~0.6.2",
|
||||||
|
"unicode-7.0.0": "~0.1.5"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.4.0"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"bin",
|
||||||
|
"test/run.js",
|
||||||
|
"test/runner.js",
|
||||||
|
"test/test.js",
|
||||||
|
"test/compat.js",
|
||||||
|
"test/reflect.js",
|
||||||
|
"esprima.js"
|
||||||
|
],
|
||||||
|
"homepage": "http://esprima.org",
|
||||||
|
"keywords": [
|
||||||
|
"ast",
|
||||||
|
"ecmascript",
|
||||||
|
"javascript",
|
||||||
|
"parser",
|
||||||
|
"syntax"
|
||||||
|
],
|
||||||
|
"licenses": [
|
||||||
|
{
|
||||||
|
"type": "BSD",
|
||||||
|
"url": "https://github.com/jquery/esprima/raw/master/LICENSE.BSD"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"main": "esprima.js",
|
||||||
|
"maintainers": [
|
||||||
|
{
|
||||||
|
"name": "Ariya Hidayat",
|
||||||
|
"email": "ariya.hidayat@gmail.com",
|
||||||
|
"url": "http://ariya.ofilabs.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "esprima",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/jquery/esprima.git"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"analyze-coverage": "node node_modules/istanbul/lib/cli.js cover test/runner.js",
|
||||||
|
"benchmark": "node test/benchmarks.js",
|
||||||
|
"benchmark-quick": "node test/benchmarks.js quick",
|
||||||
|
"check-coverage": "node node_modules/istanbul/lib/cli.js check-coverage --statement 100 --branch 100 --function 100",
|
||||||
|
"check-version": "node tools/check-version.js",
|
||||||
|
"complexity": "node tools/list-complexity.js && cr -s -l -w --maxcyc 16 esprima.js",
|
||||||
|
"coverage": "npm run analyze-coverage && npm run check-coverage",
|
||||||
|
"eslint": "node node_modules/eslint/bin/eslint.js esprima.js",
|
||||||
|
"generate-regex": "node tools/generate-identifier-regex.js",
|
||||||
|
"jscs": "jscs esprima.js test/*test.js",
|
||||||
|
"lint": "npm run check-version && npm run eslint && npm run jscs && npm run complexity",
|
||||||
|
"test": "node test/run.js && npm run lint && npm run coverage"
|
||||||
|
},
|
||||||
|
"version": "2.0.0"
|
||||||
|
}
|
||||||
244
node/node_modules/esprima/test/compat.js
generated
vendored
Normal file
244
node/node_modules/esprima/test/compat.js
generated
vendored
Normal file
@@ -0,0 +1,244 @@
|
|||||||
|
/*
|
||||||
|
Copyright (C) 2012 Joost-Wim Boekesteijn <joost-wim@boekesteijn.nl>
|
||||||
|
Copyright (C) 2011 Ariya Hidayat <ariya.hidayat@gmail.com>
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||||
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*jslint node: true */
|
||||||
|
/*global document: true, window:true, esprima: true, testReflect: true */
|
||||||
|
|
||||||
|
var runTests;
|
||||||
|
|
||||||
|
function getContext(esprima, reportCase, reportFailure) {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var Reflect, Pattern;
|
||||||
|
|
||||||
|
// Maps Mozilla Reflect object to our Esprima parser.
|
||||||
|
Reflect = {
|
||||||
|
parse: function (code) {
|
||||||
|
var result;
|
||||||
|
|
||||||
|
reportCase(code);
|
||||||
|
|
||||||
|
try {
|
||||||
|
result = esprima.parse(code);
|
||||||
|
} catch (error) {
|
||||||
|
result = error;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// This is used by Reflect test suite to match a syntax tree.
|
||||||
|
Pattern = function (obj) {
|
||||||
|
var pattern;
|
||||||
|
|
||||||
|
// Poor man's deep object cloning.
|
||||||
|
pattern = JSON.parse(JSON.stringify(obj));
|
||||||
|
|
||||||
|
// Special handling for regular expression literal since we need to
|
||||||
|
// convert it to a string literal, otherwise it will be decoded
|
||||||
|
// as object "{}" and the regular expression would be lost.
|
||||||
|
if (obj.type && obj.type === 'Literal') {
|
||||||
|
if (obj.value instanceof RegExp) {
|
||||||
|
pattern = {
|
||||||
|
type: obj.type,
|
||||||
|
value: obj.value.toString()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Special handling for branch statement because SpiderMonkey
|
||||||
|
// prefers to put the 'alternate' property before 'consequent'.
|
||||||
|
if (obj.type && obj.type === 'IfStatement') {
|
||||||
|
pattern = {
|
||||||
|
type: pattern.type,
|
||||||
|
test: pattern.test,
|
||||||
|
consequent: pattern.consequent,
|
||||||
|
alternate: pattern.alternate
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Special handling for do while statement because SpiderMonkey
|
||||||
|
// prefers to put the 'test' property before 'body'.
|
||||||
|
if (obj.type && obj.type === 'DoWhileStatement') {
|
||||||
|
pattern = {
|
||||||
|
type: pattern.type,
|
||||||
|
body: pattern.body,
|
||||||
|
test: pattern.test
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function adjustRegexLiteralAndRaw(key, value) {
|
||||||
|
if (key === 'value' && value instanceof RegExp) {
|
||||||
|
value = value.toString();
|
||||||
|
} else if (key === 'raw' && typeof value === "string") {
|
||||||
|
// Ignore Esprima-specific 'raw' property.
|
||||||
|
return undefined;
|
||||||
|
} else if (key === 'regex' && typeof value === "object") {
|
||||||
|
// Ignore Esprima-specific 'regex' property.
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (obj.type && (obj.type === 'Program')) {
|
||||||
|
pattern.assert = function (tree) {
|
||||||
|
var actual, expected;
|
||||||
|
actual = JSON.stringify(tree, adjustRegexLiteralAndRaw, 4);
|
||||||
|
expected = JSON.stringify(obj, null, 4);
|
||||||
|
|
||||||
|
if (expected !== actual) {
|
||||||
|
reportFailure(expected, actual);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return pattern;
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
Reflect: Reflect,
|
||||||
|
Pattern: Pattern
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof window !== 'undefined') {
|
||||||
|
// Run all tests in a browser environment.
|
||||||
|
runTests = function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var total = 0,
|
||||||
|
failures = 0;
|
||||||
|
|
||||||
|
function setText(el, str) {
|
||||||
|
if (typeof el.innerText === 'string') {
|
||||||
|
el.innerText = str;
|
||||||
|
} else {
|
||||||
|
el.textContent = str;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function reportCase(code) {
|
||||||
|
var report, e;
|
||||||
|
report = document.getElementById('report');
|
||||||
|
e = document.createElement('pre');
|
||||||
|
e.setAttribute('class', 'code');
|
||||||
|
setText(e, code);
|
||||||
|
report.appendChild(e);
|
||||||
|
total += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
function reportFailure(expected, actual) {
|
||||||
|
var report, e;
|
||||||
|
|
||||||
|
failures += 1;
|
||||||
|
|
||||||
|
report = document.getElementById('report');
|
||||||
|
|
||||||
|
e = document.createElement('p');
|
||||||
|
setText(e, 'Expected');
|
||||||
|
report.appendChild(e);
|
||||||
|
|
||||||
|
e = document.createElement('pre');
|
||||||
|
e.setAttribute('class', 'expected');
|
||||||
|
setText(e, expected);
|
||||||
|
report.appendChild(e);
|
||||||
|
|
||||||
|
e = document.createElement('p');
|
||||||
|
setText(e, 'Actual');
|
||||||
|
report.appendChild(e);
|
||||||
|
|
||||||
|
e = document.createElement('pre');
|
||||||
|
e.setAttribute('class', 'actual');
|
||||||
|
setText(e, actual);
|
||||||
|
report.appendChild(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
setText(document.getElementById('version'), esprima.version);
|
||||||
|
|
||||||
|
window.setTimeout(function () {
|
||||||
|
var tick, context = getContext(esprima, reportCase, reportFailure);
|
||||||
|
|
||||||
|
tick = new Date();
|
||||||
|
testReflect(context.Reflect, context.Pattern);
|
||||||
|
tick = (new Date()) - tick;
|
||||||
|
|
||||||
|
if (failures > 0) {
|
||||||
|
document.getElementById('status').className = 'alert-box alert';
|
||||||
|
setText(document.getElementById('status'), total + ' tests. ' +
|
||||||
|
'Failures: ' + failures + '. ' + tick + ' ms');
|
||||||
|
} else {
|
||||||
|
document.getElementById('status').className = 'alert-box success';
|
||||||
|
setText(document.getElementById('status'), total + ' tests. ' +
|
||||||
|
'No failure. ' + tick + ' ms');
|
||||||
|
}
|
||||||
|
}, 11);
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
(function (global) {
|
||||||
|
'use strict';
|
||||||
|
var esprima = require('../esprima'),
|
||||||
|
tick,
|
||||||
|
total = 0,
|
||||||
|
failures = [],
|
||||||
|
header,
|
||||||
|
current,
|
||||||
|
context;
|
||||||
|
|
||||||
|
function reportCase(code) {
|
||||||
|
total += 1;
|
||||||
|
current = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
function reportFailure(expected, actual) {
|
||||||
|
failures.push({
|
||||||
|
source: current,
|
||||||
|
expected: expected.toString(),
|
||||||
|
actual: actual.toString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
context = getContext(esprima, reportCase, reportFailure);
|
||||||
|
|
||||||
|
tick = new Date();
|
||||||
|
require('./reflect').testReflect(context.Reflect, context.Pattern);
|
||||||
|
tick = (new Date()) - tick;
|
||||||
|
|
||||||
|
header = total + ' tests. ' + failures.length + ' failures. ' +
|
||||||
|
tick + ' ms';
|
||||||
|
if (failures.length) {
|
||||||
|
console.error(header);
|
||||||
|
failures.forEach(function (failure) {
|
||||||
|
console.error(failure.source + ': Expected\n ' +
|
||||||
|
failure.expected.split('\n').join('\n ') +
|
||||||
|
'\nto match\n ' + failure.actual);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
console.log(header);
|
||||||
|
}
|
||||||
|
process.exit(failures.length === 0 ? 0 : 1);
|
||||||
|
}(this));
|
||||||
|
}
|
||||||
|
/* vim: set sw=4 ts=4 et tw=80 : */
|
||||||
422
node/node_modules/esprima/test/reflect.js
generated
vendored
Normal file
422
node/node_modules/esprima/test/reflect.js
generated
vendored
Normal file
@@ -0,0 +1,422 @@
|
|||||||
|
// This is modified from Mozilla Reflect.parse test suite (the file is located
|
||||||
|
// at js/src/tests/js1_8_5/extensions/reflect-parse.js in the source tree).
|
||||||
|
//
|
||||||
|
// Some notable changes:
|
||||||
|
// * Removed unsupported features (destructuring, let, comprehensions...).
|
||||||
|
// * Removed tests for E4X (ECMAScript for XML).
|
||||||
|
// * Removed everything related to builder.
|
||||||
|
// * Enclosed every 'Pattern' construct with a scope.
|
||||||
|
// * Tweaked some expected tree to remove generator field.
|
||||||
|
// * Removed the test for bug 632030 and bug 632024.
|
||||||
|
|
||||||
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||||
|
/*
|
||||||
|
* Any copyright is dedicated to the Public Domain.
|
||||||
|
* http://creativecommons.org/licenses/publicdomain/
|
||||||
|
*/
|
||||||
|
|
||||||
|
(function (exports) {
|
||||||
|
|
||||||
|
function testReflect(Reflect, Pattern) {
|
||||||
|
|
||||||
|
function program(elts) { return Pattern({ type: "Program", body: elts }); }
|
||||||
|
function exprStmt(expr) { return Pattern({ type: "ExpressionStatement", expression: expr }); }
|
||||||
|
function throwStmt(expr) { return Pattern({ type: "ThrowStatement", argument: expr }); }
|
||||||
|
function returnStmt(expr) { return Pattern({ type: "ReturnStatement", argument: expr }); }
|
||||||
|
function yieldExpr(expr) { return Pattern({ type: "YieldExpression", argument: expr }); }
|
||||||
|
function lit(val) { return Pattern({ type: "Literal", value: val }); }
|
||||||
|
var thisExpr = Pattern({ type: "ThisExpression" });
|
||||||
|
function funDecl(id, params, body) { return Pattern({ type: "FunctionDeclaration",
|
||||||
|
id: id,
|
||||||
|
params: params,
|
||||||
|
defaults: [],
|
||||||
|
body: body,
|
||||||
|
rest: null,
|
||||||
|
generator: false,
|
||||||
|
expression: false
|
||||||
|
}); }
|
||||||
|
function genFunDecl(id, params, body) { return Pattern({ type: "FunctionDeclaration",
|
||||||
|
id: id,
|
||||||
|
params: params,
|
||||||
|
defaults: [],
|
||||||
|
body: body,
|
||||||
|
rest: null,
|
||||||
|
generator: false,
|
||||||
|
expression: false
|
||||||
|
}); }
|
||||||
|
function declarator(id, init) { return Pattern({ type: "VariableDeclarator", id: id, init: init }); }
|
||||||
|
function varDecl(decls) { return Pattern({ type: "VariableDeclaration", declarations: decls, kind: "var" }); }
|
||||||
|
function letDecl(decls) { return Pattern({ type: "VariableDeclaration", declarations: decls, kind: "let" }); }
|
||||||
|
function constDecl(decls) { return Pattern({ type: "VariableDeclaration", declarations: decls, kind: "const" }); }
|
||||||
|
function ident(name) { return Pattern({ type: "Identifier", name: name }); }
|
||||||
|
function dotExpr(obj, id) { return Pattern({ type: "MemberExpression", computed: false, object: obj, property: id }); }
|
||||||
|
function memExpr(obj, id) { return Pattern({ type: "MemberExpression", computed: true, object: obj, property: id }); }
|
||||||
|
function forStmt(init, test, update, body) { return Pattern({ type: "ForStatement", init: init, test: test, update: update, body: body }); }
|
||||||
|
function forInStmt(lhs, rhs, body) { return Pattern({ type: "ForInStatement", left: lhs, right: rhs, body: body, each: false }); }
|
||||||
|
function forEachInStmt(lhs, rhs, body) { return Pattern({ type: "ForInStatement", left: lhs, right: rhs, body: body, each: true }); }
|
||||||
|
function breakStmt(lab) { return Pattern({ type: "BreakStatement", label: lab }); }
|
||||||
|
function continueStmt(lab) { return Pattern({ type: "ContinueStatement", label: lab }); }
|
||||||
|
function blockStmt(body) { return Pattern({ type: "BlockStatement", body: body }); }
|
||||||
|
var emptyStmt = Pattern({ type: "EmptyStatement" });
|
||||||
|
function ifStmt(test, cons, alt) { return Pattern({ type: "IfStatement", test: test, alternate: alt, consequent: cons }); }
|
||||||
|
function labStmt(lab, stmt) { return Pattern({ type: "LabeledStatement", label: lab, body: stmt }); }
|
||||||
|
function withStmt(obj, stmt) { return Pattern({ type: "WithStatement", object: obj, body: stmt }); }
|
||||||
|
function whileStmt(test, stmt) { return Pattern({ type: "WhileStatement", test: test, body: stmt }); }
|
||||||
|
function doStmt(stmt, test) { return Pattern({ type: "DoWhileStatement", test: test, body: stmt }); }
|
||||||
|
function switchStmt(disc, cases) { return Pattern({ type: "SwitchStatement", discriminant: disc, cases: cases }); }
|
||||||
|
function caseClause(test, stmts) { return Pattern({ type: "SwitchCase", test: test, consequent: stmts }); }
|
||||||
|
function defaultClause(stmts) { return Pattern({ type: "SwitchCase", test: null, consequent: stmts }); }
|
||||||
|
function catchClause(id, guard, body) { if (guard) { return Pattern({ type: "GuardedCatchClause", param: id, guard: guard, body: body }) } else { return Pattern({ type: "CatchClause", param: id, body: body }); } }
|
||||||
|
function tryStmt(body, guarded, catches, fin) { return Pattern({ type: "TryStatement", block: body, guardedHandlers: guarded, handlers: catches, finalizer: fin }); }
|
||||||
|
function letStmt(head, body) { return Pattern({ type: "LetStatement", head: head, body: body }); }
|
||||||
|
function funExpr(id, args, body, gen) { return Pattern({ type: "FunctionExpression",
|
||||||
|
id: id,
|
||||||
|
params: args,
|
||||||
|
defaults: [],
|
||||||
|
body: body,
|
||||||
|
rest: null,
|
||||||
|
generator: false,
|
||||||
|
expression: false
|
||||||
|
}); }
|
||||||
|
function genFunExpr(id, args, body) { return Pattern({ type: "FunctionExpression",
|
||||||
|
id: id,
|
||||||
|
params: args,
|
||||||
|
defaults: [],
|
||||||
|
body: body,
|
||||||
|
rest: null,
|
||||||
|
generator: false,
|
||||||
|
expression: false
|
||||||
|
}); }
|
||||||
|
|
||||||
|
function unExpr(op, arg) { return Pattern({ type: "UnaryExpression", operator: op, argument: arg, prefix: true }); }
|
||||||
|
function binExpr(op, left, right) { return Pattern({ type: "BinaryExpression", operator: op, left: left, right: right }); }
|
||||||
|
function aExpr(op, left, right) { return Pattern({ type: "AssignmentExpression", operator: op, left: left, right: right }); }
|
||||||
|
function updExpr(op, arg, prefix) { return Pattern({ type: "UpdateExpression", operator: op, argument: arg, prefix: prefix }); }
|
||||||
|
function logExpr(op, left, right) { return Pattern({ type: "LogicalExpression", operator: op, left: left, right: right }); }
|
||||||
|
|
||||||
|
function condExpr(test, cons, alt) { return Pattern({ type: "ConditionalExpression", test: test, consequent: cons, alternate: alt }); }
|
||||||
|
function seqExpr(exprs) { return Pattern({ type: "SequenceExpression", expressions: exprs }); }
|
||||||
|
function newExpr(callee, args) { return Pattern({ type: "NewExpression", callee: callee, arguments: args }); }
|
||||||
|
function callExpr(callee, args) { return Pattern({ type: "CallExpression", callee: callee, arguments: args }); }
|
||||||
|
function arrExpr(elts) { return Pattern({ type: "ArrayExpression", elements: elts }); }
|
||||||
|
function objExpr(elts) { return Pattern({ type: "ObjectExpression", properties: elts }); }
|
||||||
|
function objProp(key, value, kind) { return Pattern({ type: "Property", key: key, value: value, kind: kind, method: false, shorthand: false }); }
|
||||||
|
|
||||||
|
function arrPatt(elts) { return Pattern({ type: "ArrayPattern", elements: elts }); }
|
||||||
|
function objPatt(elts) { return Pattern({ type: "ObjectPattern", properties: elts }); }
|
||||||
|
|
||||||
|
function localSrc(src) { return "(function(){ " + src + " })"; }
|
||||||
|
function localPatt(patt) { return program([exprStmt(funExpr(null, [], blockStmt([patt])))]); }
|
||||||
|
function blockSrc(src) { return "(function(){ { " + src + " } })"; }
|
||||||
|
function blockPatt(patt) { return program([exprStmt(funExpr(null, [], blockStmt([blockStmt([patt])])))]); }
|
||||||
|
|
||||||
|
function assertBlockStmt(src, patt) {
|
||||||
|
blockPatt(patt).assert(Reflect.parse(blockSrc(src)));
|
||||||
|
}
|
||||||
|
|
||||||
|
function assertBlockExpr(src, patt) {
|
||||||
|
assertBlockStmt(src, exprStmt(patt));
|
||||||
|
}
|
||||||
|
|
||||||
|
function assertBlockDecl(src, patt, builder) {
|
||||||
|
blockPatt(patt).assert(Reflect.parse(blockSrc(src), {builder: builder}));
|
||||||
|
}
|
||||||
|
|
||||||
|
function assertLocalStmt(src, patt) {
|
||||||
|
localPatt(patt).assert(Reflect.parse(localSrc(src)));
|
||||||
|
}
|
||||||
|
|
||||||
|
function assertLocalExpr(src, patt) {
|
||||||
|
assertLocalStmt(src, exprStmt(patt));
|
||||||
|
}
|
||||||
|
|
||||||
|
function assertLocalDecl(src, patt) {
|
||||||
|
localPatt(patt).assert(Reflect.parse(localSrc(src)));
|
||||||
|
}
|
||||||
|
|
||||||
|
function assertGlobalStmt(src, patt, builder) {
|
||||||
|
program([patt]).assert(Reflect.parse(src, {builder: builder}));
|
||||||
|
}
|
||||||
|
|
||||||
|
function assertGlobalExpr(src, patt, builder) {
|
||||||
|
program([exprStmt(patt)]).assert(Reflect.parse(src, {builder: builder}));
|
||||||
|
//assertStmt(src, exprStmt(patt));
|
||||||
|
}
|
||||||
|
|
||||||
|
function assertGlobalDecl(src, patt) {
|
||||||
|
program([patt]).assert(Reflect.parse(src));
|
||||||
|
}
|
||||||
|
|
||||||
|
function assertProg(src, patt) {
|
||||||
|
program(patt).assert(Reflect.parse(src));
|
||||||
|
}
|
||||||
|
|
||||||
|
function assertStmt(src, patt) {
|
||||||
|
assertLocalStmt(src, patt);
|
||||||
|
assertGlobalStmt(src, patt);
|
||||||
|
assertBlockStmt(src, patt);
|
||||||
|
}
|
||||||
|
|
||||||
|
function assertExpr(src, patt) {
|
||||||
|
assertLocalExpr(src, patt);
|
||||||
|
assertGlobalExpr(src, patt);
|
||||||
|
assertBlockExpr(src, patt);
|
||||||
|
}
|
||||||
|
|
||||||
|
function assertDecl(src, patt) {
|
||||||
|
assertLocalDecl(src, patt);
|
||||||
|
assertGlobalDecl(src, patt);
|
||||||
|
assertBlockDecl(src, patt);
|
||||||
|
}
|
||||||
|
|
||||||
|
function assertError(src, errorType) {
|
||||||
|
try {
|
||||||
|
Reflect.parse(src);
|
||||||
|
} catch (e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
throw new Error("expected " + errorType.name + " for " + uneval(src));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// general tests
|
||||||
|
|
||||||
|
// NB: These are useful but for now jit-test doesn't do I/O reliably.
|
||||||
|
|
||||||
|
//program(_).assert(Reflect.parse(snarf('data/flapjax.txt')));
|
||||||
|
//program(_).assert(Reflect.parse(snarf('data/jquery-1.4.2.txt')));
|
||||||
|
//program(_).assert(Reflect.parse(snarf('data/prototype.js')));
|
||||||
|
//program(_).assert(Reflect.parse(snarf('data/dojo.js.uncompressed.js')));
|
||||||
|
//program(_).assert(Reflect.parse(snarf('data/mootools-1.2.4-core-nc.js')));
|
||||||
|
|
||||||
|
|
||||||
|
// declarations
|
||||||
|
|
||||||
|
assertDecl("var x = 1, y = 2, z = 3",
|
||||||
|
varDecl([declarator(ident("x"), lit(1)),
|
||||||
|
declarator(ident("y"), lit(2)),
|
||||||
|
declarator(ident("z"), lit(3))]));
|
||||||
|
assertDecl("var x, y, z",
|
||||||
|
varDecl([declarator(ident("x"), null),
|
||||||
|
declarator(ident("y"), null),
|
||||||
|
declarator(ident("z"), null)]));
|
||||||
|
assertDecl("function foo() { }",
|
||||||
|
funDecl(ident("foo"), [], blockStmt([])));
|
||||||
|
assertDecl("function foo() { return 42 }",
|
||||||
|
funDecl(ident("foo"), [], blockStmt([returnStmt(lit(42))])));
|
||||||
|
|
||||||
|
|
||||||
|
// Bug 591437: rebound args have their defs turned into uses
|
||||||
|
assertDecl("function f(a) { function a() { } }",
|
||||||
|
funDecl(ident("f"), [ident("a")], blockStmt([funDecl(ident("a"), [], blockStmt([]))])));
|
||||||
|
assertDecl("function f(a,b,c) { function b() { } }",
|
||||||
|
funDecl(ident("f"), [ident("a"),ident("b"),ident("c")], blockStmt([funDecl(ident("b"), [], blockStmt([]))])));
|
||||||
|
|
||||||
|
// expressions
|
||||||
|
|
||||||
|
assertExpr("true", lit(true));
|
||||||
|
assertExpr("false", lit(false));
|
||||||
|
assertExpr("42", lit(42));
|
||||||
|
assertExpr("(/asdf/)", lit(/asdf/));
|
||||||
|
assertExpr("this", thisExpr);
|
||||||
|
assertExpr("foo", ident("foo"));
|
||||||
|
assertExpr("foo.bar", dotExpr(ident("foo"), ident("bar")));
|
||||||
|
assertExpr("foo[bar]", memExpr(ident("foo"), ident("bar")));
|
||||||
|
assertExpr("(function(){})", funExpr(null, [], blockStmt([])));
|
||||||
|
assertExpr("(function f() {})", funExpr(ident("f"), [], blockStmt([])));
|
||||||
|
assertExpr("(function f(x,y,z) {})", funExpr(ident("f"), [ident("x"),ident("y"),ident("z")], blockStmt([])));
|
||||||
|
assertExpr("(++x)", updExpr("++", ident("x"), true));
|
||||||
|
assertExpr("(x++)", updExpr("++", ident("x"), false));
|
||||||
|
assertExpr("(+x)", unExpr("+", ident("x")));
|
||||||
|
assertExpr("(-x)", unExpr("-", ident("x")));
|
||||||
|
assertExpr("(!x)", unExpr("!", ident("x")));
|
||||||
|
assertExpr("(~x)", unExpr("~", ident("x")));
|
||||||
|
assertExpr("(delete x)", unExpr("delete", ident("x")));
|
||||||
|
assertExpr("(typeof x)", unExpr("typeof", ident("x")));
|
||||||
|
assertExpr("(void x)", unExpr("void", ident("x")));
|
||||||
|
assertExpr("(x == y)", binExpr("==", ident("x"), ident("y")));
|
||||||
|
assertExpr("(x != y)", binExpr("!=", ident("x"), ident("y")));
|
||||||
|
assertExpr("(x === y)", binExpr("===", ident("x"), ident("y")));
|
||||||
|
assertExpr("(x !== y)", binExpr("!==", ident("x"), ident("y")));
|
||||||
|
assertExpr("(x < y)", binExpr("<", ident("x"), ident("y")));
|
||||||
|
assertExpr("(x <= y)", binExpr("<=", ident("x"), ident("y")));
|
||||||
|
assertExpr("(x > y)", binExpr(">", ident("x"), ident("y")));
|
||||||
|
assertExpr("(x >= y)", binExpr(">=", ident("x"), ident("y")));
|
||||||
|
assertExpr("(x << y)", binExpr("<<", ident("x"), ident("y")));
|
||||||
|
assertExpr("(x >> y)", binExpr(">>", ident("x"), ident("y")));
|
||||||
|
assertExpr("(x >>> y)", binExpr(">>>", ident("x"), ident("y")));
|
||||||
|
assertExpr("(x + y)", binExpr("+", ident("x"), ident("y")));
|
||||||
|
assertExpr("(w + x + y + z)", binExpr("+", binExpr("+", binExpr("+", ident("w"), ident("x")), ident("y")), ident("z")));
|
||||||
|
assertExpr("(x - y)", binExpr("-", ident("x"), ident("y")));
|
||||||
|
assertExpr("(w - x - y - z)", binExpr("-", binExpr("-", binExpr("-", ident("w"), ident("x")), ident("y")), ident("z")));
|
||||||
|
assertExpr("(x * y)", binExpr("*", ident("x"), ident("y")));
|
||||||
|
assertExpr("(x / y)", binExpr("/", ident("x"), ident("y")));
|
||||||
|
assertExpr("(x % y)", binExpr("%", ident("x"), ident("y")));
|
||||||
|
assertExpr("(x | y)", binExpr("|", ident("x"), ident("y")));
|
||||||
|
assertExpr("(x ^ y)", binExpr("^", ident("x"), ident("y")));
|
||||||
|
assertExpr("(x & y)", binExpr("&", ident("x"), ident("y")));
|
||||||
|
assertExpr("(x in y)", binExpr("in", ident("x"), ident("y")));
|
||||||
|
assertExpr("(x instanceof y)", binExpr("instanceof", ident("x"), ident("y")));
|
||||||
|
assertExpr("(x = y)", aExpr("=", ident("x"), ident("y")));
|
||||||
|
assertExpr("(x += y)", aExpr("+=", ident("x"), ident("y")));
|
||||||
|
assertExpr("(x -= y)", aExpr("-=", ident("x"), ident("y")));
|
||||||
|
assertExpr("(x *= y)", aExpr("*=", ident("x"), ident("y")));
|
||||||
|
assertExpr("(x /= y)", aExpr("/=", ident("x"), ident("y")));
|
||||||
|
assertExpr("(x %= y)", aExpr("%=", ident("x"), ident("y")));
|
||||||
|
assertExpr("(x <<= y)", aExpr("<<=", ident("x"), ident("y")));
|
||||||
|
assertExpr("(x >>= y)", aExpr(">>=", ident("x"), ident("y")));
|
||||||
|
assertExpr("(x >>>= y)", aExpr(">>>=", ident("x"), ident("y")));
|
||||||
|
assertExpr("(x |= y)", aExpr("|=", ident("x"), ident("y")));
|
||||||
|
assertExpr("(x ^= y)", aExpr("^=", ident("x"), ident("y")));
|
||||||
|
assertExpr("(x &= y)", aExpr("&=", ident("x"), ident("y")));
|
||||||
|
assertExpr("(x || y)", logExpr("||", ident("x"), ident("y")));
|
||||||
|
assertExpr("(x && y)", logExpr("&&", ident("x"), ident("y")));
|
||||||
|
assertExpr("(w || x || y || z)", logExpr("||", logExpr("||", logExpr("||", ident("w"), ident("x")), ident("y")), ident("z")));
|
||||||
|
assertExpr("(x ? y : z)", condExpr(ident("x"), ident("y"), ident("z")));
|
||||||
|
assertExpr("(x,y)", seqExpr([ident("x"),ident("y")]));
|
||||||
|
assertExpr("(x,y,z)", seqExpr([ident("x"),ident("y"),ident("z")]));
|
||||||
|
assertExpr("(a,b,c,d,e,f,g)", seqExpr([ident("a"),ident("b"),ident("c"),ident("d"),ident("e"),ident("f"),ident("g")]));
|
||||||
|
assertExpr("(new Object)", newExpr(ident("Object"), []));
|
||||||
|
assertExpr("(new Object())", newExpr(ident("Object"), []));
|
||||||
|
assertExpr("(new Object(42))", newExpr(ident("Object"), [lit(42)]));
|
||||||
|
assertExpr("(new Object(1,2,3))", newExpr(ident("Object"), [lit(1),lit(2),lit(3)]));
|
||||||
|
assertExpr("(String())", callExpr(ident("String"), []));
|
||||||
|
assertExpr("(String(42))", callExpr(ident("String"), [lit(42)]));
|
||||||
|
assertExpr("(String(1,2,3))", callExpr(ident("String"), [lit(1),lit(2),lit(3)]));
|
||||||
|
assertExpr("[]", arrExpr([]));
|
||||||
|
assertExpr("[1]", arrExpr([lit(1)]));
|
||||||
|
assertExpr("[1,2]", arrExpr([lit(1),lit(2)]));
|
||||||
|
assertExpr("[1,2,3]", arrExpr([lit(1),lit(2),lit(3)]));
|
||||||
|
assertExpr("[1,,2,3]", arrExpr([lit(1),,lit(2),lit(3)]));
|
||||||
|
assertExpr("[1,,,2,3]", arrExpr([lit(1),,,lit(2),lit(3)]));
|
||||||
|
assertExpr("[1,,,2,,3]", arrExpr([lit(1),,,lit(2),,lit(3)]));
|
||||||
|
assertExpr("[1,,,2,,,3]", arrExpr([lit(1),,,lit(2),,,lit(3)]));
|
||||||
|
assertExpr("[,1,2,3]", arrExpr([,lit(1),lit(2),lit(3)]));
|
||||||
|
assertExpr("[,,1,2,3]", arrExpr([,,lit(1),lit(2),lit(3)]));
|
||||||
|
assertExpr("[,,,1,2,3]", arrExpr([,,,lit(1),lit(2),lit(3)]));
|
||||||
|
assertExpr("[,,,1,2,3,]", arrExpr([,,,lit(1),lit(2),lit(3)]));
|
||||||
|
assertExpr("[,,,1,2,3,,]", arrExpr([,,,lit(1),lit(2),lit(3),undefined]));
|
||||||
|
assertExpr("[,,,1,2,3,,,]", arrExpr([,,,lit(1),lit(2),lit(3),undefined,undefined]));
|
||||||
|
assertExpr("[,,,,,]", arrExpr([undefined,undefined,undefined,undefined,undefined]));
|
||||||
|
assertExpr("({})", objExpr([]));
|
||||||
|
assertExpr("({x:1})", objExpr([objProp(ident("x"), lit(1), "init")]));
|
||||||
|
assertExpr("({x:1, y:2})", objExpr([objProp(ident("x"), lit(1), "init"),
|
||||||
|
objProp(ident("y"), lit(2), "init")]));
|
||||||
|
assertExpr("({x:1, y:2, z:3})", objExpr([objProp(ident("x"), lit(1), "init"),
|
||||||
|
objProp(ident("y"), lit(2), "init"),
|
||||||
|
objProp(ident("z"), lit(3), "init") ]));
|
||||||
|
assertExpr("({x:1, 'y':2, z:3})", objExpr([objProp(ident("x"), lit(1), "init"),
|
||||||
|
objProp(lit("y"), lit(2), "init"),
|
||||||
|
objProp(ident("z"), lit(3), "init") ]));
|
||||||
|
assertExpr("({'x':1, 'y':2, z:3})", objExpr([objProp(lit("x"), lit(1), "init"),
|
||||||
|
objProp(lit("y"), lit(2), "init"),
|
||||||
|
objProp(ident("z"), lit(3), "init") ]));
|
||||||
|
assertExpr("({'x':1, 'y':2, 3:3})", objExpr([objProp(lit("x"), lit(1), "init"),
|
||||||
|
objProp(lit("y"), lit(2), "init"),
|
||||||
|
objProp(lit(3), lit(3), "init") ]));
|
||||||
|
|
||||||
|
// Bug 571617: eliminate constant-folding
|
||||||
|
assertExpr("2 + 3", binExpr("+", lit(2), lit(3)));
|
||||||
|
|
||||||
|
// Bug 632026: constant-folding
|
||||||
|
assertExpr("typeof(0?0:a)", unExpr("typeof", condExpr(lit(0), lit(0), ident("a"))));
|
||||||
|
|
||||||
|
// Bug 632056: constant-folding
|
||||||
|
program([exprStmt(ident("f")),
|
||||||
|
ifStmt(lit(1),
|
||||||
|
funDecl(ident("f"), [], blockStmt([])),
|
||||||
|
null)]).assert(Reflect.parse("f; if (1) function f(){}"));
|
||||||
|
|
||||||
|
// statements
|
||||||
|
|
||||||
|
assertStmt("throw 42", throwStmt(lit(42)));
|
||||||
|
assertStmt("for (;;) break", forStmt(null, null, null, breakStmt(null)));
|
||||||
|
assertStmt("for (x; y; z) break", forStmt(ident("x"), ident("y"), ident("z"), breakStmt(null)));
|
||||||
|
assertStmt("for (var x; y; z) break", forStmt(varDecl([declarator(ident("x"), null)]), ident("y"), ident("z"), breakStmt(null)));
|
||||||
|
assertStmt("for (var x = 42; y; z) break", forStmt(varDecl([declarator(ident("x"), lit(42))]), ident("y"), ident("z"), breakStmt(null)));
|
||||||
|
assertStmt("for (x; ; z) break", forStmt(ident("x"), null, ident("z"), breakStmt(null)));
|
||||||
|
assertStmt("for (var x; ; z) break", forStmt(varDecl([declarator(ident("x"), null)]), null, ident("z"), breakStmt(null)));
|
||||||
|
assertStmt("for (var x = 42; ; z) break", forStmt(varDecl([declarator(ident("x"), lit(42))]), null, ident("z"), breakStmt(null)));
|
||||||
|
assertStmt("for (x; y; ) break", forStmt(ident("x"), ident("y"), null, breakStmt(null)));
|
||||||
|
assertStmt("for (var x; y; ) break", forStmt(varDecl([declarator(ident("x"), null)]), ident("y"), null, breakStmt(null)));
|
||||||
|
assertStmt("for (var x = 42; y; ) break", forStmt(varDecl([declarator(ident("x"),lit(42))]), ident("y"), null, breakStmt(null)));
|
||||||
|
assertStmt("for (var x in y) break", forInStmt(varDecl([declarator(ident("x"),null)]), ident("y"), breakStmt(null)));
|
||||||
|
assertStmt("for (x in y) break", forInStmt(ident("x"), ident("y"), breakStmt(null)));
|
||||||
|
assertStmt("{ }", blockStmt([]));
|
||||||
|
assertStmt("{ throw 1; throw 2; throw 3; }", blockStmt([ throwStmt(lit(1)), throwStmt(lit(2)), throwStmt(lit(3))]));
|
||||||
|
assertStmt(";", emptyStmt);
|
||||||
|
assertStmt("if (foo) throw 42;", ifStmt(ident("foo"), throwStmt(lit(42)), null));
|
||||||
|
assertStmt("if (foo) throw 42; else true;", ifStmt(ident("foo"), throwStmt(lit(42)), exprStmt(lit(true))));
|
||||||
|
assertStmt("if (foo) { throw 1; throw 2; throw 3; }",
|
||||||
|
ifStmt(ident("foo"),
|
||||||
|
blockStmt([throwStmt(lit(1)), throwStmt(lit(2)), throwStmt(lit(3))]),
|
||||||
|
null));
|
||||||
|
assertStmt("if (foo) { throw 1; throw 2; throw 3; } else true;",
|
||||||
|
ifStmt(ident("foo"),
|
||||||
|
blockStmt([throwStmt(lit(1)), throwStmt(lit(2)), throwStmt(lit(3))]),
|
||||||
|
exprStmt(lit(true))));
|
||||||
|
assertStmt("foo: for(;;) break foo;", labStmt(ident("foo"), forStmt(null, null, null, breakStmt(ident("foo")))));
|
||||||
|
assertStmt("foo: for(;;) continue foo;", labStmt(ident("foo"), forStmt(null, null, null, continueStmt(ident("foo")))));
|
||||||
|
assertStmt("with (obj) { }", withStmt(ident("obj"), blockStmt([])));
|
||||||
|
assertStmt("with (obj) { obj; }", withStmt(ident("obj"), blockStmt([exprStmt(ident("obj"))])));
|
||||||
|
assertStmt("while (foo) { }", whileStmt(ident("foo"), blockStmt([])));
|
||||||
|
assertStmt("while (foo) { foo; }", whileStmt(ident("foo"), blockStmt([exprStmt(ident("foo"))])));
|
||||||
|
assertStmt("do { } while (foo);", doStmt(blockStmt([]), ident("foo")));
|
||||||
|
assertStmt("do { foo; } while (foo)", doStmt(blockStmt([exprStmt(ident("foo"))]), ident("foo")));
|
||||||
|
assertStmt("switch (foo) { case 1: 1; break; case 2: 2; break; default: 3; }",
|
||||||
|
switchStmt(ident("foo"),
|
||||||
|
[ caseClause(lit(1), [ exprStmt(lit(1)), breakStmt(null) ]),
|
||||||
|
caseClause(lit(2), [ exprStmt(lit(2)), breakStmt(null) ]),
|
||||||
|
defaultClause([ exprStmt(lit(3)) ]) ]));
|
||||||
|
assertStmt("switch (foo) { case 1: 1; break; case 2: 2; break; default: 3; case 42: 42; }",
|
||||||
|
switchStmt(ident("foo"),
|
||||||
|
[ caseClause(lit(1), [ exprStmt(lit(1)), breakStmt(null) ]),
|
||||||
|
caseClause(lit(2), [ exprStmt(lit(2)), breakStmt(null) ]),
|
||||||
|
defaultClause([ exprStmt(lit(3)) ]),
|
||||||
|
caseClause(lit(42), [ exprStmt(lit(42)) ]) ]));
|
||||||
|
assertStmt("try { } catch (e) { }",
|
||||||
|
tryStmt(blockStmt([]),
|
||||||
|
[],
|
||||||
|
[ catchClause(ident("e"), null, blockStmt([])) ],
|
||||||
|
null));
|
||||||
|
assertStmt("try { } catch (e) { } finally { }",
|
||||||
|
tryStmt(blockStmt([]),
|
||||||
|
[],
|
||||||
|
[ catchClause(ident("e"), null, blockStmt([])) ],
|
||||||
|
blockStmt([])));
|
||||||
|
assertStmt("try { } finally { }",
|
||||||
|
tryStmt(blockStmt([]),
|
||||||
|
[],
|
||||||
|
[],
|
||||||
|
blockStmt([])));
|
||||||
|
|
||||||
|
// redeclarations (TOK_NAME nodes with lexdef)
|
||||||
|
|
||||||
|
assertStmt("function f() { function g() { } function g() { } }",
|
||||||
|
funDecl(ident("f"), [], blockStmt([funDecl(ident("g"), [], blockStmt([])),
|
||||||
|
funDecl(ident("g"), [], blockStmt([]))])));
|
||||||
|
|
||||||
|
assertStmt("function f() { function g() { } function g() { return 42 } }",
|
||||||
|
funDecl(ident("f"), [], blockStmt([funDecl(ident("g"), [], blockStmt([])),
|
||||||
|
funDecl(ident("g"), [], blockStmt([returnStmt(lit(42))]))])));
|
||||||
|
|
||||||
|
assertStmt("function f() { var x = 42; var x = 43; }",
|
||||||
|
funDecl(ident("f"), [], blockStmt([varDecl([declarator(ident("x"),lit(42))]),
|
||||||
|
varDecl([declarator(ident("x"),lit(43))])])));
|
||||||
|
|
||||||
|
// getters and setters
|
||||||
|
|
||||||
|
assertExpr("({ get x() { return 42 } })",
|
||||||
|
objExpr([ objProp(ident("x"),
|
||||||
|
funExpr(null, [], blockStmt([returnStmt(lit(42))])),
|
||||||
|
"get" ) ]));
|
||||||
|
assertExpr("({ set x(v) { return 42 } })",
|
||||||
|
objExpr([ objProp(ident("x"),
|
||||||
|
funExpr(null, [ident("v")], blockStmt([returnStmt(lit(42))])),
|
||||||
|
"set" ) ]));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.testReflect = testReflect;
|
||||||
|
|
||||||
|
}(typeof exports === 'undefined' ? this : exports));
|
||||||
67
node/node_modules/esprima/test/run.js
generated
vendored
Normal file
67
node/node_modules/esprima/test/run.js
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
Copyright (C) 2012 Yusuke Suzuki <utatane.tea@gmail.com>
|
||||||
|
Copyright (C) 2012 Ariya Hidayat <ariya.hidayat@gmail.com>
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||||
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*jslint node:true */
|
||||||
|
|
||||||
|
(function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var child = require('child_process'),
|
||||||
|
nodejs = '"' + process.execPath + '"',
|
||||||
|
ret = 0,
|
||||||
|
suites,
|
||||||
|
index;
|
||||||
|
|
||||||
|
suites = [
|
||||||
|
'runner',
|
||||||
|
'compat',
|
||||||
|
'parselibs'
|
||||||
|
];
|
||||||
|
|
||||||
|
function nextTest() {
|
||||||
|
var suite = suites[index];
|
||||||
|
|
||||||
|
if (index < suites.length) {
|
||||||
|
child.exec(nodejs + ' ./test/' + suite + '.js', function (err, stdout, stderr) {
|
||||||
|
if (stdout) {
|
||||||
|
process.stdout.write(suite + ': ' + stdout);
|
||||||
|
}
|
||||||
|
if (stderr) {
|
||||||
|
process.stderr.write(suite + ': ' + stderr);
|
||||||
|
}
|
||||||
|
if (err) {
|
||||||
|
ret = err.code;
|
||||||
|
}
|
||||||
|
index += 1;
|
||||||
|
nextTest();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
process.exit(ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
index = 0;
|
||||||
|
nextTest();
|
||||||
|
}());
|
||||||
494
node/node_modules/esprima/test/runner.js
generated
vendored
Normal file
494
node/node_modules/esprima/test/runner.js
generated
vendored
Normal file
@@ -0,0 +1,494 @@
|
|||||||
|
/*
|
||||||
|
Copyright (C) 2012 Ariya Hidayat <ariya.hidayat@gmail.com>
|
||||||
|
Copyright (C) 2012 Joost-Wim Boekesteijn <joost-wim@boekesteijn.nl>
|
||||||
|
Copyright (C) 2012 Yusuke Suzuki <utatane.tea@gmail.com>
|
||||||
|
Copyright (C) 2012 Arpad Borsos <arpad.borsos@googlemail.com>
|
||||||
|
Copyright (C) 2011 Ariya Hidayat <ariya.hidayat@gmail.com>
|
||||||
|
Copyright (C) 2011 Yusuke Suzuki <utatane.tea@gmail.com>
|
||||||
|
Copyright (C) 2011 Arpad Borsos <arpad.borsos@googlemail.com>
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||||
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*jslint browser:true node:true */
|
||||||
|
/*global esprima:true, testFixture:true */
|
||||||
|
|
||||||
|
var runTests;
|
||||||
|
|
||||||
|
// Special handling for regular expression literals: remove their `value`
|
||||||
|
// property since it may be `null` if it represents a regular expression
|
||||||
|
// that is not supported in the current environment. The `regex` property
|
||||||
|
// will be compared instead.
|
||||||
|
function adjustRegexLiteral(key, value) {
|
||||||
|
'use strict';
|
||||||
|
if (key === 'value' && value instanceof RegExp) {
|
||||||
|
value = value.toString();
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
function NotMatchingError(expected, actual) {
|
||||||
|
'use strict';
|
||||||
|
Error.call(this, 'Expected ');
|
||||||
|
this.expected = expected;
|
||||||
|
this.actual = actual;
|
||||||
|
}
|
||||||
|
NotMatchingError.prototype = new Error();
|
||||||
|
|
||||||
|
function errorToObject(e) {
|
||||||
|
'use strict';
|
||||||
|
var msg = e.toString();
|
||||||
|
|
||||||
|
// Opera 9.64 produces an non-standard string in toString().
|
||||||
|
if (msg.substr(0, 6) !== 'Error:') {
|
||||||
|
if (typeof e.message === 'string') {
|
||||||
|
msg = 'Error: ' + e.message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
index: e.index,
|
||||||
|
lineNumber: e.lineNumber,
|
||||||
|
column: e.column,
|
||||||
|
message: msg
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function sortedObject(o) {
|
||||||
|
if (o === null) {
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
if (o instanceof Array) {
|
||||||
|
return o.map(sortedObject);
|
||||||
|
}
|
||||||
|
if (typeof o !== 'object') {
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
if (o instanceof RegExp) {
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
var keys = Object.keys(o);
|
||||||
|
var result = {
|
||||||
|
range: undefined,
|
||||||
|
loc: undefined
|
||||||
|
};
|
||||||
|
keys.forEach(function (key) {
|
||||||
|
if (o.hasOwnProperty(key)){
|
||||||
|
result[key] = sortedObject(o[key]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function hasAttachedComment(syntax) {
|
||||||
|
var key;
|
||||||
|
for (key in syntax) {
|
||||||
|
if (key === 'leadingComments' || key === 'trailingComments') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (typeof syntax[key] === 'object' && syntax[key] !== null) {
|
||||||
|
if (hasAttachedComment(syntax[key])) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function testParse(esprima, code, syntax) {
|
||||||
|
'use strict';
|
||||||
|
var expected, tree, actual, options, StringObject, i, len;
|
||||||
|
|
||||||
|
// alias, so that JSLint does not complain.
|
||||||
|
StringObject = String;
|
||||||
|
|
||||||
|
options = {
|
||||||
|
comment: (typeof syntax.comments !== 'undefined'),
|
||||||
|
range: true,
|
||||||
|
loc: true,
|
||||||
|
tokens: (typeof syntax.tokens !== 'undefined'),
|
||||||
|
raw: true,
|
||||||
|
tolerant: (typeof syntax.errors !== 'undefined'),
|
||||||
|
source: null
|
||||||
|
};
|
||||||
|
|
||||||
|
if (options.comment) {
|
||||||
|
options.attachComment = hasAttachedComment(syntax);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof syntax.tokens !== 'undefined') {
|
||||||
|
if (syntax.tokens.length > 0) {
|
||||||
|
options.range = (typeof syntax.tokens[0].range !== 'undefined');
|
||||||
|
options.loc = (typeof syntax.tokens[0].loc !== 'undefined');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof syntax.comments !== 'undefined') {
|
||||||
|
if (syntax.comments.length > 0) {
|
||||||
|
options.range = (typeof syntax.comments[0].range !== 'undefined');
|
||||||
|
options.loc = (typeof syntax.comments[0].loc !== 'undefined');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.loc) {
|
||||||
|
options.source = syntax.loc.source;
|
||||||
|
}
|
||||||
|
|
||||||
|
syntax = sortedObject(syntax);
|
||||||
|
expected = JSON.stringify(syntax, adjustRegexLiteral, 4);
|
||||||
|
try {
|
||||||
|
// Some variations of the options.
|
||||||
|
tree = esprima.parse(code, { tolerant: options.tolerant });
|
||||||
|
tree = esprima.parse(code, { tolerant: options.tolerant, range: true });
|
||||||
|
tree = esprima.parse(code, { tolerant: options.tolerant, loc: true });
|
||||||
|
|
||||||
|
tree = esprima.parse(code, options);
|
||||||
|
tree = (options.comment || options.tokens || options.tolerant) ? tree : tree.body[0];
|
||||||
|
|
||||||
|
if (options.tolerant) {
|
||||||
|
for (i = 0, len = tree.errors.length; i < len; i += 1) {
|
||||||
|
tree.errors[i] = errorToObject(tree.errors[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tree = sortedObject(tree);
|
||||||
|
actual = JSON.stringify(tree, adjustRegexLiteral, 4);
|
||||||
|
|
||||||
|
// Only to ensure that there is no error when using string object.
|
||||||
|
esprima.parse(new StringObject(code), options);
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
throw new NotMatchingError(expected, e.toString());
|
||||||
|
}
|
||||||
|
if (expected !== actual) {
|
||||||
|
throw new NotMatchingError(expected, actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
function filter(key, value) {
|
||||||
|
if (key === 'value' && value instanceof RegExp) {
|
||||||
|
value = value.toString();
|
||||||
|
}
|
||||||
|
return (key === 'loc' || key === 'range') ? undefined : value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.tolerant) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Check again without any location info.
|
||||||
|
options.range = false;
|
||||||
|
options.loc = false;
|
||||||
|
syntax = sortedObject(syntax);
|
||||||
|
expected = JSON.stringify(syntax, filter, 4);
|
||||||
|
try {
|
||||||
|
tree = esprima.parse(code, options);
|
||||||
|
tree = (options.comment || options.tokens) ? tree : tree.body[0];
|
||||||
|
|
||||||
|
if (options.tolerant) {
|
||||||
|
for (i = 0, len = tree.errors.length; i < len; i += 1) {
|
||||||
|
tree.errors[i] = errorToObject(tree.errors[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tree = sortedObject(tree);
|
||||||
|
actual = JSON.stringify(tree, filter, 4);
|
||||||
|
} catch (e) {
|
||||||
|
throw new NotMatchingError(expected, e.toString());
|
||||||
|
}
|
||||||
|
if (expected !== actual) {
|
||||||
|
throw new NotMatchingError(expected, actual);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function testTokenize(esprima, code, tokens) {
|
||||||
|
'use strict';
|
||||||
|
var options, expected, actual, tree;
|
||||||
|
|
||||||
|
options = {
|
||||||
|
comment: true,
|
||||||
|
tolerant: true,
|
||||||
|
loc: true,
|
||||||
|
range: true
|
||||||
|
};
|
||||||
|
|
||||||
|
expected = JSON.stringify(tokens, null, 4);
|
||||||
|
|
||||||
|
try {
|
||||||
|
tree = esprima.tokenize(code, options);
|
||||||
|
actual = JSON.stringify(tree, null, 4);
|
||||||
|
} catch (e) {
|
||||||
|
throw new NotMatchingError(expected, e.toString());
|
||||||
|
}
|
||||||
|
if (expected !== actual) {
|
||||||
|
throw new NotMatchingError(expected, actual);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function testError(esprima, code, exception) {
|
||||||
|
'use strict';
|
||||||
|
var i, options, expected, actual, err, handleInvalidRegexFlag, tokenize;
|
||||||
|
|
||||||
|
// Different parsing options should give the same error.
|
||||||
|
options = [
|
||||||
|
{},
|
||||||
|
{ comment: true },
|
||||||
|
{ raw: true },
|
||||||
|
{ raw: true, comment: true }
|
||||||
|
];
|
||||||
|
|
||||||
|
// If handleInvalidRegexFlag is true, an invalid flag in a regular expression
|
||||||
|
// will throw an exception. In some old version of V8, this is not the case
|
||||||
|
// and hence handleInvalidRegexFlag is false.
|
||||||
|
handleInvalidRegexFlag = false;
|
||||||
|
try {
|
||||||
|
'test'.match(new RegExp('[a-z]', 'x'));
|
||||||
|
} catch (e) {
|
||||||
|
handleInvalidRegexFlag = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
exception.description = exception.message.replace(/Error: Line [0-9]+: /, '');
|
||||||
|
|
||||||
|
if (exception.tokenize) {
|
||||||
|
tokenize = true;
|
||||||
|
exception.tokenize = undefined;
|
||||||
|
}
|
||||||
|
expected = JSON.stringify(exception);
|
||||||
|
|
||||||
|
for (i = 0; i < options.length; i += 1) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (tokenize) {
|
||||||
|
esprima.tokenize(code, options[i]);
|
||||||
|
} else {
|
||||||
|
esprima.parse(code, options[i]);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
err = errorToObject(e);
|
||||||
|
err.description = e.description;
|
||||||
|
actual = JSON.stringify(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expected !== actual) {
|
||||||
|
|
||||||
|
// Compensate for old V8 which does not handle invalid flag.
|
||||||
|
if (exception.message.indexOf('Invalid regular expression') > 0) {
|
||||||
|
if (typeof actual === 'undefined' && !handleInvalidRegexFlag) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new NotMatchingError(expected, actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function testAPI(esprima, code, result) {
|
||||||
|
'use strict';
|
||||||
|
var expected, res, actual;
|
||||||
|
|
||||||
|
expected = JSON.stringify(result.result, null, 4);
|
||||||
|
try {
|
||||||
|
if (typeof result.property !== 'undefined') {
|
||||||
|
res = esprima[result.property];
|
||||||
|
} else {
|
||||||
|
res = esprima[result.call].apply(esprima, result.args);
|
||||||
|
}
|
||||||
|
actual = JSON.stringify(res, adjustRegexLiteral, 4);
|
||||||
|
} catch (e) {
|
||||||
|
throw new NotMatchingError(expected, e.toString());
|
||||||
|
}
|
||||||
|
if (expected !== actual) {
|
||||||
|
throw new NotMatchingError(expected, actual);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function runTest(esprima, code, result) {
|
||||||
|
'use strict';
|
||||||
|
if (result.hasOwnProperty('lineNumber')) {
|
||||||
|
testError(esprima, code, result);
|
||||||
|
} else if (result.hasOwnProperty('result')) {
|
||||||
|
testAPI(esprima, code, result);
|
||||||
|
} else if (result instanceof Array) {
|
||||||
|
testTokenize(esprima, code, result);
|
||||||
|
} else {
|
||||||
|
testParse(esprima, code, result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof window !== 'undefined') {
|
||||||
|
// Run all tests in a browser environment.
|
||||||
|
runTests = function () {
|
||||||
|
'use strict';
|
||||||
|
var total = 0,
|
||||||
|
failures = 0,
|
||||||
|
category,
|
||||||
|
fixture,
|
||||||
|
source,
|
||||||
|
tick,
|
||||||
|
expected;
|
||||||
|
|
||||||
|
function setText(el, str) {
|
||||||
|
if (typeof el.innerText === 'string') {
|
||||||
|
el.innerText = str;
|
||||||
|
} else {
|
||||||
|
el.textContent = str;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function startCategory(category) {
|
||||||
|
var report, e;
|
||||||
|
report = document.getElementById('report');
|
||||||
|
e = document.createElement('h4');
|
||||||
|
setText(e, category);
|
||||||
|
report.appendChild(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
function reportSuccess(code) {
|
||||||
|
var report, e;
|
||||||
|
report = document.getElementById('report');
|
||||||
|
e = document.createElement('pre');
|
||||||
|
e.setAttribute('class', 'code');
|
||||||
|
setText(e, code);
|
||||||
|
report.appendChild(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
function reportFailure(code, expected, actual) {
|
||||||
|
var report, e;
|
||||||
|
|
||||||
|
report = document.getElementById('report');
|
||||||
|
|
||||||
|
e = document.createElement('p');
|
||||||
|
setText(e, 'Code:');
|
||||||
|
report.appendChild(e);
|
||||||
|
|
||||||
|
e = document.createElement('pre');
|
||||||
|
e.setAttribute('class', 'code');
|
||||||
|
setText(e, code);
|
||||||
|
report.appendChild(e);
|
||||||
|
|
||||||
|
e = document.createElement('p');
|
||||||
|
setText(e, 'Expected');
|
||||||
|
report.appendChild(e);
|
||||||
|
|
||||||
|
e = document.createElement('pre');
|
||||||
|
e.setAttribute('class', 'expected');
|
||||||
|
setText(e, expected);
|
||||||
|
report.appendChild(e);
|
||||||
|
|
||||||
|
e = document.createElement('p');
|
||||||
|
setText(e, 'Actual');
|
||||||
|
report.appendChild(e);
|
||||||
|
|
||||||
|
e = document.createElement('pre');
|
||||||
|
e.setAttribute('class', 'actual');
|
||||||
|
setText(e, actual);
|
||||||
|
report.appendChild(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
setText(document.getElementById('version'), esprima.version);
|
||||||
|
|
||||||
|
tick = new Date();
|
||||||
|
for (category in testFixture) {
|
||||||
|
if (testFixture.hasOwnProperty(category)) {
|
||||||
|
startCategory(category);
|
||||||
|
fixture = testFixture[category];
|
||||||
|
for (source in fixture) {
|
||||||
|
if (fixture.hasOwnProperty(source)) {
|
||||||
|
expected = fixture[source];
|
||||||
|
total += 1;
|
||||||
|
try {
|
||||||
|
runTest(esprima, source, expected);
|
||||||
|
reportSuccess(source, JSON.stringify(expected, null, 4));
|
||||||
|
} catch (e) {
|
||||||
|
failures += 1;
|
||||||
|
reportFailure(source, e.expected, e.actual);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tick = (new Date()) - tick;
|
||||||
|
|
||||||
|
if (failures > 0) {
|
||||||
|
document.getElementById('status').className = 'alert-box alert';
|
||||||
|
setText(document.getElementById('status'), total + ' tests. ' +
|
||||||
|
'Failures: ' + failures + '. ' + tick + ' ms.');
|
||||||
|
} else {
|
||||||
|
document.getElementById('status').className = 'alert-box success';
|
||||||
|
setText(document.getElementById('status'), total + ' tests. ' +
|
||||||
|
'No failure. ' + tick + ' ms.');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
(function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var esprima = require('../esprima'),
|
||||||
|
vm = require('vm'),
|
||||||
|
fs = require('fs'),
|
||||||
|
diff = require('json-diff').diffString,
|
||||||
|
total = 0,
|
||||||
|
failures = [],
|
||||||
|
tick = new Date(),
|
||||||
|
expected,
|
||||||
|
header;
|
||||||
|
|
||||||
|
vm.runInThisContext(fs.readFileSync(__dirname + '/test.js', 'utf-8'));
|
||||||
|
|
||||||
|
Object.keys(testFixture).forEach(function (category) {
|
||||||
|
Object.keys(testFixture[category]).forEach(function (source) {
|
||||||
|
total += 1;
|
||||||
|
expected = testFixture[category][source];
|
||||||
|
try {
|
||||||
|
runTest(esprima, source, expected);
|
||||||
|
} catch (e) {
|
||||||
|
e.source = source;
|
||||||
|
failures.push(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
tick = (new Date()) - tick;
|
||||||
|
|
||||||
|
header = total + ' tests. ' + failures.length + ' failures. ' +
|
||||||
|
tick + ' ms';
|
||||||
|
if (failures.length) {
|
||||||
|
console.error(header);
|
||||||
|
failures.forEach(function (failure) {
|
||||||
|
try {
|
||||||
|
var expectedObject = JSON.parse(failure.expected);
|
||||||
|
var actualObject = JSON.parse(failure.actual);
|
||||||
|
|
||||||
|
console.error(failure.source + ': Expected\n ' +
|
||||||
|
failure.expected.split('\n').join('\n ') +
|
||||||
|
'\nto match\n ' + failure.actual + '\nDiff:\n' +
|
||||||
|
diff(expectedObject, actualObject));
|
||||||
|
} catch (ex) {
|
||||||
|
console.error(failure.source + ': Expected\n ' +
|
||||||
|
failure.expected.split('\n').join('\n ') +
|
||||||
|
'\nto match\n ' + failure.actual);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
console.log(header);
|
||||||
|
}
|
||||||
|
process.exit(failures.length === 0 ? 0 : 1);
|
||||||
|
}());
|
||||||
|
}
|
||||||
29995
node/node_modules/esprima/test/test.js
generated
vendored
Normal file
29995
node/node_modules/esprima/test/test.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
285
node/node_modules/js-yaml/CHANGELOG.md
generated
vendored
Normal file
285
node/node_modules/js-yaml/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,285 @@
|
|||||||
|
3.2.7 / 2015-02-19
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Maintenance release.
|
||||||
|
- Updated dependencies.
|
||||||
|
- HISTORY.md -> CHANGELOG.md
|
||||||
|
|
||||||
|
|
||||||
|
3.2.6 / 2015-02-07
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Fixed encoding of UTF-16 surrogate pairs. (e.g. "\U0001F431" CAT FACE).
|
||||||
|
- Fixed demo dates dump (#113, thanks to @Hypercubed).
|
||||||
|
|
||||||
|
|
||||||
|
3.2.5 / 2014-12-28
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Fixed resolving of all built-in types on empty nodes.
|
||||||
|
- Fixed invalid warning on empty lines within quoted scalars and flow collections.
|
||||||
|
- Fixed bug: Tag on an empty node didn't resolve in some cases.
|
||||||
|
|
||||||
|
|
||||||
|
3.2.4 / 2014-12-19
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Fixed resolving of !!null tag on an empty node.
|
||||||
|
|
||||||
|
|
||||||
|
3.2.3 / 2014-11-08
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Implemented dumping of objects with circular and cross references.
|
||||||
|
- Partially fixed aliasing of constructed objects. (see issue #141 for details)
|
||||||
|
|
||||||
|
|
||||||
|
3.2.2 / 2014-09-07
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Fixed infinite loop on unindented block scalars.
|
||||||
|
- Rewritten base64 encode/decode in binary type, to keep code licence clear.
|
||||||
|
|
||||||
|
|
||||||
|
3.2.1 / 2014-08-24
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Nothig new. Just fix npm publish error.
|
||||||
|
|
||||||
|
|
||||||
|
3.2.0 / 2014-08-24
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Added input piping support to CLI.
|
||||||
|
- Fixed typo, that could cause hand on initial indent (#139).
|
||||||
|
|
||||||
|
|
||||||
|
3.1.0 / 2014-07-07
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- 1.5x-2x speed boost.
|
||||||
|
- Removed deprecated `require('xxx.yml')` support.
|
||||||
|
- Significant code cleanup and refactoring.
|
||||||
|
- Internal API changed. If you used custom types - see updated examples.
|
||||||
|
Others are not affected.
|
||||||
|
- Even if the input string has no trailing line break character,
|
||||||
|
it will be parsed as if it has one.
|
||||||
|
- Added benchmark scripts.
|
||||||
|
- Moved bower files to /dist folder
|
||||||
|
- Bugfixes.
|
||||||
|
|
||||||
|
|
||||||
|
3.0.2 / 2014-02-27
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Fixed bug: "constructor" string parsed as `null`.
|
||||||
|
|
||||||
|
|
||||||
|
3.0.1 / 2013-12-22
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Fixed parsing of literal scalars. (issue #108)
|
||||||
|
- Prevented adding unnecessary spaces in object dumps. (issue #68)
|
||||||
|
- Fixed dumping of objects with very long (> 1024 in length) keys.
|
||||||
|
|
||||||
|
|
||||||
|
3.0.0 / 2013-12-16
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Refactored code. Changed API for custom types.
|
||||||
|
- Removed output colors in CLI, dump json by default.
|
||||||
|
- Removed big dependencies from browser version (esprima, buffer)
|
||||||
|
- load `esprima` manually, if !!js/function needed
|
||||||
|
- !!bin now returns Array in browser
|
||||||
|
- AMD support.
|
||||||
|
- Don't quote dumped strings because of `-` & `?` (if not first char).
|
||||||
|
- __Deprecated__ loading yaml files via `require()`, as not recommended
|
||||||
|
behaviour for node.
|
||||||
|
|
||||||
|
|
||||||
|
2.1.3 / 2013-10-16
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Fix wrong loading of empty block scalars.
|
||||||
|
|
||||||
|
|
||||||
|
2.1.2 / 2013-10-07
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Fix unwanted line breaks in folded scalars.
|
||||||
|
|
||||||
|
|
||||||
|
2.1.1 / 2013-10-02
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Dumper now respects deprecated booleans syntax from YAML 1.0/1.1
|
||||||
|
- Fixed reader bug in JSON-like sequences/mappings.
|
||||||
|
|
||||||
|
|
||||||
|
2.1.0 / 2013-06-05
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Add standard YAML schemas: Failsafe (`FAILSAFE_SCHEMA`),
|
||||||
|
JSON (`JSON_SCHEMA`) and Core (`CORE_SCHEMA`).
|
||||||
|
- Rename `DEFAULT_SCHEMA` to `DEFAULT_FULL_SCHEMA`
|
||||||
|
and `SAFE_SCHEMA` to `DEFAULT_SAFE_SCHEMA`.
|
||||||
|
- Bug fix: export `NIL` constant from the public interface.
|
||||||
|
- Add `skipInvalid` dumper option.
|
||||||
|
- Use `safeLoad` for `require` extension.
|
||||||
|
|
||||||
|
|
||||||
|
2.0.5 / 2013-04-26
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Close security issue in !!js/function constructor.
|
||||||
|
Big thanks to @nealpoole for security audit.
|
||||||
|
|
||||||
|
|
||||||
|
2.0.4 / 2013-04-08
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Updated .npmignore to reduce package size
|
||||||
|
|
||||||
|
|
||||||
|
2.0.3 / 2013-02-26
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Fixed dumping of empty arrays ans objects. ([] and {} instead of null)
|
||||||
|
|
||||||
|
|
||||||
|
2.0.2 / 2013-02-15
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Fixed input validation: tabs are printable characters.
|
||||||
|
|
||||||
|
|
||||||
|
2.0.1 / 2013-02-09
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Fixed error, when options not passed to function cass
|
||||||
|
|
||||||
|
|
||||||
|
2.0.0 / 2013-02-09
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Full rewrite. New architecture. Fast one-stage parsing.
|
||||||
|
- Changed custom types API.
|
||||||
|
- Added YAML dumper.
|
||||||
|
|
||||||
|
|
||||||
|
1.0.3 / 2012-11-05
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Fixed utf-8 files loading.
|
||||||
|
|
||||||
|
|
||||||
|
1.0.2 / 2012-08-02
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Pull out hand-written shims. Use ES5-Shims for old browsers support. See #44.
|
||||||
|
- Fix timstamps incorectly parsed in local time when no time part specified.
|
||||||
|
|
||||||
|
|
||||||
|
1.0.1 / 2012-07-07
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Fixes `TypeError: 'undefined' is not an object` under Safari. Thanks Phuong.
|
||||||
|
- Fix timestamps incorrectly parsed in local time. Thanks @caolan. Closes #46.
|
||||||
|
|
||||||
|
|
||||||
|
1.0.0 / 2012-07-01
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- `y`, `yes`, `n`, `no`, `on`, `off` are not converted to Booleans anymore.
|
||||||
|
Fixes #42.
|
||||||
|
- `require(filename)` now returns a single document and throws an Error if
|
||||||
|
file contains more than one document.
|
||||||
|
- CLI was merged back from js-yaml.bin
|
||||||
|
|
||||||
|
|
||||||
|
0.3.7 / 2012-02-28
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Fix export of `addConstructor()`. Closes #39.
|
||||||
|
|
||||||
|
|
||||||
|
0.3.6 / 2012-02-22
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Removed AMD parts - too buggy to use. Need help to rewrite from scratch
|
||||||
|
- Removed YUI compressor warning (renamed `double` variable). Closes #40.
|
||||||
|
|
||||||
|
|
||||||
|
0.3.5 / 2012-01-10
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Workagound for .npmignore fuckup under windows. Thanks to airportyh.
|
||||||
|
|
||||||
|
|
||||||
|
0.3.4 / 2011-12-24
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Fixes str[] for oldIEs support.
|
||||||
|
- Adds better has change support for browserified demo.
|
||||||
|
- improves compact output of Error. Closes #33.
|
||||||
|
|
||||||
|
|
||||||
|
0.3.3 / 2011-12-20
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- jsyaml executable moved to separate module.
|
||||||
|
- adds `compact` stringification of Errors.
|
||||||
|
|
||||||
|
|
||||||
|
0.3.2 / 2011-12-16
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Fixes ug with block style scalars. Closes #26.
|
||||||
|
- All sources are passing JSLint now.
|
||||||
|
- Fixes bug in Safari. Closes #28.
|
||||||
|
- Fixes bug in Opers. Closes #29.
|
||||||
|
- Improves browser support. Closes #20.
|
||||||
|
- Added jsyaml executable.
|
||||||
|
- Added !!js/function support. Closes #12.
|
||||||
|
|
||||||
|
|
||||||
|
0.3.1 / 2011-11-18
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Added AMD support for browserified version.
|
||||||
|
- Wrapped browserified js-yaml into closure.
|
||||||
|
- Fixed the resolvement of non-specific tags. Closes #17.
|
||||||
|
- Added permalinks for online demo YAML snippets. Now we have YPaste service, lol.
|
||||||
|
- Added !!js/regexp and !!js/undefined types. Partially solves #12.
|
||||||
|
- Fixed !!set mapping.
|
||||||
|
- Fixed month parse in dates. Closes #19.
|
||||||
|
|
||||||
|
|
||||||
|
0.3.0 / 2011-11-09
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Removed JS.Class dependency. Closes #3.
|
||||||
|
- Added browserified version. Closes #13.
|
||||||
|
- Added live demo of browserified version.
|
||||||
|
- Ported some of the PyYAML tests. See #14.
|
||||||
|
- Fixed timestamp bug when fraction was given.
|
||||||
|
|
||||||
|
|
||||||
|
0.2.2 / 2011-11-06
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Fixed crash on docs without ---. Closes #8.
|
||||||
|
- Fixed miltiline string parse
|
||||||
|
- Fixed tests/comments for using array as key
|
||||||
|
|
||||||
|
|
||||||
|
0.2.1 / 2011-11-02
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- Fixed short file read (<4k). Closes #9.
|
||||||
|
|
||||||
|
|
||||||
|
0.2.0 / 2011-11-02
|
||||||
|
------------------
|
||||||
|
|
||||||
|
- First public release
|
||||||
21
node/node_modules/js-yaml/LICENSE
generated
vendored
Normal file
21
node/node_modules/js-yaml/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
(The MIT License)
|
||||||
|
|
||||||
|
Copyright (C) 2011-2015 by Vitaly Puzrin
|
||||||
|
|
||||||
|
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.
|
||||||
288
node/node_modules/js-yaml/README.md
generated
vendored
Normal file
288
node/node_modules/js-yaml/README.md
generated
vendored
Normal file
@@ -0,0 +1,288 @@
|
|||||||
|
JS-YAML - YAML 1.2 parser and serializer for JavaScript
|
||||||
|
=======================================================
|
||||||
|
|
||||||
|
[](https://travis-ci.org/nodeca/js-yaml)
|
||||||
|
[](https://www.npmjs.org/package/js-yaml)
|
||||||
|
|
||||||
|
[Online Demo](http://nodeca.github.com/js-yaml/)
|
||||||
|
|
||||||
|
|
||||||
|
This is an implementation of [YAML](http://yaml.org/), a human friendly data
|
||||||
|
serialization language. Started as [PyYAML](http://pyyaml.org/) port, it was
|
||||||
|
completely rewritten from scratch. Now it's very fast, and supports 1.2 spec.
|
||||||
|
|
||||||
|
|
||||||
|
Installation
|
||||||
|
------------
|
||||||
|
|
||||||
|
### YAML module for node.js
|
||||||
|
|
||||||
|
```
|
||||||
|
npm install js-yaml
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### CLI executable
|
||||||
|
|
||||||
|
If you want to inspect your YAML files from CLI, install js-yaml globally:
|
||||||
|
|
||||||
|
```
|
||||||
|
npm install -g js-yaml
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Usage
|
||||||
|
|
||||||
|
```
|
||||||
|
usage: js-yaml [-h] [-v] [-c] [-t] file
|
||||||
|
|
||||||
|
Positional arguments:
|
||||||
|
file File with YAML document(s)
|
||||||
|
|
||||||
|
Optional arguments:
|
||||||
|
-h, --help Show this help message and exit.
|
||||||
|
-v, --version Show program's version number and exit.
|
||||||
|
-c, --compact Display errors in compact mode
|
||||||
|
-t, --trace Show stack trace on error
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Bundled YAML library for browsers
|
||||||
|
|
||||||
|
``` html
|
||||||
|
<!-- esprima required only for !!js/function -->
|
||||||
|
<script src="esprima.js"></script>
|
||||||
|
<script src="js-yaml.min.js"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
var doc = jsyaml.load('greeting: hello\nname: world');
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
Browser support was done mostly for online demo. If you find any errors - feel
|
||||||
|
free to send pull requests with fixes. Also note, that IE and other old browsers
|
||||||
|
needs [es5-shims](https://github.com/kriskowal/es5-shim) to operate.
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
|
||||||
|
1. We have no resourses to support browserified version. Don't expect it to be
|
||||||
|
well tested. Don't expect fast fixes if something goes wrong there.
|
||||||
|
2. `!!js/function` in browser bundle will not work by default. If you really need
|
||||||
|
it - load `esprima` parser first (via amd or directly).
|
||||||
|
3. `!!bin` in browser will return `Array`, because browsers do not support
|
||||||
|
node.js `Buffer` and adding Buffer shims is completely useless on practice.
|
||||||
|
|
||||||
|
|
||||||
|
API
|
||||||
|
---
|
||||||
|
|
||||||
|
Here we cover the most 'useful' methods. If you need advanced details (creating
|
||||||
|
your own tags), see [wiki](https://github.com/nodeca/js-yaml/wiki) and
|
||||||
|
[examples](https://github.com/nodeca/js-yaml/tree/master/examples) for more
|
||||||
|
info.
|
||||||
|
|
||||||
|
``` javascript
|
||||||
|
yaml = require('js-yaml');
|
||||||
|
fs = require('fs');
|
||||||
|
|
||||||
|
// Get document, or throw exception on error
|
||||||
|
try {
|
||||||
|
var doc = yaml.safeLoad(fs.readFileSync('/home/ixti/example.yml', 'utf8'));
|
||||||
|
console.log(doc);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### safeLoad (string [ , options ])
|
||||||
|
|
||||||
|
**Recommended loading way.** Parses `string` as single YAML document. Returns a JavaScript
|
||||||
|
object or throws `YAMLException` on error. By default, does not support regexps,
|
||||||
|
functions and undefined. This method is safe for untrusted data.
|
||||||
|
|
||||||
|
options:
|
||||||
|
|
||||||
|
- `filename` _(default: null)_ - string to be used as a file path in
|
||||||
|
error/warning messages.
|
||||||
|
- `onWarning` _(default: null)_ - function to call on warning messages.
|
||||||
|
Loader will throw on warnings if this function is not provided.
|
||||||
|
- `schema` _(default: `DEFAULT_SAFE_SCHEMA`)_ - specifies a schema to use.
|
||||||
|
- `FAILSAFE_SCHEMA` - only strings, arrays and plain objects:
|
||||||
|
http://www.yaml.org/spec/1.2/spec.html#id2802346
|
||||||
|
- `JSON_SCHEMA` - all JSON-supported types:
|
||||||
|
http://www.yaml.org/spec/1.2/spec.html#id2803231
|
||||||
|
- `CORE_SCHEMA` - same as `JSON_SCHEMA`:
|
||||||
|
http://www.yaml.org/spec/1.2/spec.html#id2804923
|
||||||
|
- `DEFAULT_SAFE_SCHEMA` - all supported YAML types, without unsafe ones
|
||||||
|
(`!!js/undefined`, `!!js/regexp` and `!!js/function`):
|
||||||
|
http://yaml.org/type/
|
||||||
|
- `DEFAULT_FULL_SCHEMA` - all supported YAML types.
|
||||||
|
|
||||||
|
NOTE: This function **does not** understand multi-document sources, it throws
|
||||||
|
exception on those.
|
||||||
|
|
||||||
|
NOTE: JS-YAML **does not** support schema-specific tag resolution restrictions.
|
||||||
|
So, JSON schema is not as strict as defined in the YAML specification.
|
||||||
|
It allows numbers in any notaion, use `Null` and `NULL` as `null`, etc.
|
||||||
|
Core schema also has no such restrictions. It allows binary notation for integers.
|
||||||
|
|
||||||
|
|
||||||
|
### load (string [ , options ])
|
||||||
|
|
||||||
|
**Use with care with untrusted sources**. The same as `safeLoad()` but uses
|
||||||
|
`DEFAULT_FULL_SCHEMA` by default - adds some JavaScript-specific types:
|
||||||
|
`!!js/function`, `!!js/regexp` and `!!js/undefined`. For untrusted sources you
|
||||||
|
must additionally validate object structure, to avoid injections:
|
||||||
|
|
||||||
|
``` javascript
|
||||||
|
var untrusted_code = '"toString": !<tag:yaml.org,2002:js/function> "function (){very_evil_thing();}"';
|
||||||
|
|
||||||
|
// I'm just converting that string, what could possibly go wrong?
|
||||||
|
require('js-yaml').load(untrusted_code) + ''
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### safeLoadAll (string, iterator [ , options ])
|
||||||
|
|
||||||
|
Same as `safeLoad()`, but understands multi-document sources and apply
|
||||||
|
`iterator` to each document.
|
||||||
|
|
||||||
|
``` javascript
|
||||||
|
var yaml = require('js-yaml');
|
||||||
|
|
||||||
|
yaml.safeLoadAll(data, function (doc) {
|
||||||
|
console.log(doc);
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### loadAll (string, iterator [ , options ])
|
||||||
|
|
||||||
|
Same as `safeLoadAll()` but uses `DEFAULT_FULL_SCHEMA` by default.
|
||||||
|
|
||||||
|
|
||||||
|
### safeDump (object [ , options ])
|
||||||
|
|
||||||
|
Serializes `object` as YAML document. Uses `DEFAULT_SAFE_SCHEMA`, so it will
|
||||||
|
throw exception if you try to dump regexps or functions. However, you can
|
||||||
|
disable exceptions by `skipInvalid` option.
|
||||||
|
|
||||||
|
options:
|
||||||
|
|
||||||
|
- `indent` _(default: 2)_ - indentation width to use (in spaces).
|
||||||
|
- `skipInvalid` _(default: false)_ - do not throw on invalid types (like function
|
||||||
|
in the safe schema) and skip pairs and single values with such types.
|
||||||
|
- `flowLevel` (default: -1) - specifies level of nesting, when to switch from
|
||||||
|
block to flow style for collections. -1 means block style everwhere
|
||||||
|
- `styles` - "tag" => "style" map. Each tag may have own set of styles.
|
||||||
|
- `schema` _(default: `DEFAULT_SAFE_SCHEMA`)_ specifies a schema to use.
|
||||||
|
|
||||||
|
styles:
|
||||||
|
|
||||||
|
``` none
|
||||||
|
!!null
|
||||||
|
"canonical" => "~"
|
||||||
|
|
||||||
|
!!int
|
||||||
|
"binary" => "0b1", "0b101010", "0b1110001111010"
|
||||||
|
"octal" => "01", "052", "016172"
|
||||||
|
"decimal" => "1", "42", "7290"
|
||||||
|
"hexadecimal" => "0x1", "0x2A", "0x1C7A"
|
||||||
|
|
||||||
|
!!null, !!bool, !!float
|
||||||
|
"lowercase" => "null", "true", "false", ".nan", '.inf'
|
||||||
|
"uppercase" => "NULL", "TRUE", "FALSE", ".NAN", '.INF'
|
||||||
|
"camelcase" => "Null", "True", "False", ".NaN", '.Inf'
|
||||||
|
```
|
||||||
|
|
||||||
|
By default, !!int uses `decimal`, and !!null, !!bool, !!float use `lowercase`.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### dump (object [ , options ])
|
||||||
|
|
||||||
|
Same as `safeDump()` but without limits (uses `DEFAULT_FULL_SCHEMA` by default).
|
||||||
|
|
||||||
|
|
||||||
|
Supported YAML types
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
The list of standard YAML tags and corresponding JavaScipt types. See also
|
||||||
|
[YAML tag discussion](http://pyyaml.org/wiki/YAMLTagDiscussion) and
|
||||||
|
[YAML types repository](http://yaml.org/type/).
|
||||||
|
|
||||||
|
```
|
||||||
|
!!null '' # null
|
||||||
|
!!bool 'yes' # bool
|
||||||
|
!!int '3...' # number
|
||||||
|
!!float '3.14...' # number
|
||||||
|
!!binary '...base64...' # buffer
|
||||||
|
!!timestamp 'YYYY-...' # date
|
||||||
|
!!omap [ ... ] # array of key-value pairs
|
||||||
|
!!pairs [ ... ] # array or array pairs
|
||||||
|
!!set { ... } # array of objects with given keys and null values
|
||||||
|
!!str '...' # string
|
||||||
|
!!seq [ ... ] # array
|
||||||
|
!!map { ... } # object
|
||||||
|
```
|
||||||
|
|
||||||
|
**JavaScript-specific tags**
|
||||||
|
|
||||||
|
```
|
||||||
|
!!js/regexp /pattern/gim # RegExp
|
||||||
|
!!js/undefined '' # Undefined
|
||||||
|
!!js/function 'function () {...}' # Function
|
||||||
|
```
|
||||||
|
|
||||||
|
Caveats
|
||||||
|
-------
|
||||||
|
|
||||||
|
Note, that you use arrays or objects as key in JS-YAML. JS do not allows objects
|
||||||
|
or array as keys, and stringifies (by calling .toString method) them at the
|
||||||
|
moment of adding them.
|
||||||
|
|
||||||
|
``` yaml
|
||||||
|
---
|
||||||
|
? [ foo, bar ]
|
||||||
|
: - baz
|
||||||
|
? { foo: bar }
|
||||||
|
: - baz
|
||||||
|
- baz
|
||||||
|
```
|
||||||
|
|
||||||
|
``` javascript
|
||||||
|
{ "foo,bar": ["baz"], "[object Object]": ["baz", "baz"] }
|
||||||
|
```
|
||||||
|
|
||||||
|
Also, reading of properties on implicit block mapping keys is not supported yet.
|
||||||
|
So, the following YAML document cannot be loaded.
|
||||||
|
|
||||||
|
``` yaml
|
||||||
|
&anchor foo:
|
||||||
|
foo: bar
|
||||||
|
*anchor: duplicate key
|
||||||
|
baz: bat
|
||||||
|
*anchor: duplicate key
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
Breaking changes in 2.x.x -> 3.x.x
|
||||||
|
----------------------------------
|
||||||
|
|
||||||
|
If your have not used __custom__ tags or loader classes and not loaded yaml
|
||||||
|
files via `require()` - no changes needed. Just upgrade library.
|
||||||
|
|
||||||
|
In other case, you should:
|
||||||
|
|
||||||
|
1. Replace all occurences of `require('xxxx.yml')` by `fs.readFileSync()` +
|
||||||
|
`yaml.safeLoad()`.
|
||||||
|
2. rewrite your custom tags constructors and custom loader
|
||||||
|
classes, to conform new API. See
|
||||||
|
[examples](https://github.com/nodeca/js-yaml/tree/master/examples) and
|
||||||
|
[wiki](https://github.com/nodeca/js-yaml/wiki) for details.
|
||||||
|
|
||||||
|
|
||||||
|
License
|
||||||
|
-------
|
||||||
|
|
||||||
|
View the [LICENSE](https://github.com/nodeca/js-yaml/blob/master/LICENSE) file
|
||||||
|
(MIT).
|
||||||
140
node/node_modules/js-yaml/bin/js-yaml.js
generated
vendored
Executable file
140
node/node_modules/js-yaml/bin/js-yaml.js
generated
vendored
Executable file
@@ -0,0 +1,140 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
|
// stdlib
|
||||||
|
var fs = require('fs');
|
||||||
|
|
||||||
|
|
||||||
|
// 3rd-party
|
||||||
|
var argparse = require('argparse');
|
||||||
|
|
||||||
|
|
||||||
|
// internal
|
||||||
|
var yaml = require('..');
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
var cli = new argparse.ArgumentParser({
|
||||||
|
prog: 'js-yaml',
|
||||||
|
version: require('../package.json').version,
|
||||||
|
addHelp: true
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
cli.addArgument(['-c', '--compact'], {
|
||||||
|
help: 'Display errors in compact mode',
|
||||||
|
action: 'storeTrue'
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// deprecated (not needed after we removed output colors)
|
||||||
|
// option suppressed, but not completely removed for compatibility
|
||||||
|
cli.addArgument(['-j', '--to-json'], {
|
||||||
|
help: argparse.Const.SUPPRESS,
|
||||||
|
dest: 'json',
|
||||||
|
action: 'storeTrue'
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
cli.addArgument(['-t', '--trace'], {
|
||||||
|
help: 'Show stack trace on error',
|
||||||
|
action: 'storeTrue'
|
||||||
|
});
|
||||||
|
|
||||||
|
cli.addArgument(['file'], {
|
||||||
|
help: 'File to read, utf-8 encoded without BOM',
|
||||||
|
nargs: '?',
|
||||||
|
defaultValue: '-'
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
var options = cli.parseArgs();
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
function readFile(filename, encoding, callback) {
|
||||||
|
if (options.file === '-') {
|
||||||
|
// read from stdin
|
||||||
|
|
||||||
|
var chunks = [];
|
||||||
|
|
||||||
|
process.stdin.on('data', function(chunk) {
|
||||||
|
chunks.push(chunk);
|
||||||
|
});
|
||||||
|
|
||||||
|
process.stdin.on('end', function() {
|
||||||
|
return callback(null, Buffer.concat(chunks).toString(encoding));
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
fs.readFile(filename, encoding, callback);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
readFile(options.file, 'utf8', function (error, input) {
|
||||||
|
var output, isYaml;
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
if ('ENOENT' === error.code) {
|
||||||
|
console.error('File not found: ' + options.file);
|
||||||
|
process.exit(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.error(
|
||||||
|
options.trace && error.stack ||
|
||||||
|
error.message ||
|
||||||
|
String(error));
|
||||||
|
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
output = JSON.parse(input);
|
||||||
|
isYaml = false;
|
||||||
|
} catch (error) {
|
||||||
|
if (error instanceof SyntaxError) {
|
||||||
|
try {
|
||||||
|
output = [];
|
||||||
|
yaml.loadAll(input, function (doc) { output.push(doc); }, {});
|
||||||
|
isYaml = true;
|
||||||
|
|
||||||
|
if (0 === output.length) {
|
||||||
|
output = null;
|
||||||
|
} else if (1 === output.length) {
|
||||||
|
output = output[0];
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
if (options.trace && error.stack) {
|
||||||
|
console.error(error.stack);
|
||||||
|
} else {
|
||||||
|
console.error(error.toString(options.compact));
|
||||||
|
}
|
||||||
|
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.error(
|
||||||
|
options.trace && error.stack ||
|
||||||
|
error.message ||
|
||||||
|
String(error));
|
||||||
|
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isYaml) {
|
||||||
|
console.log(JSON.stringify(output, null, ' '));
|
||||||
|
} else {
|
||||||
|
console.log(yaml.dump(output));
|
||||||
|
}
|
||||||
|
|
||||||
|
process.exit(0);
|
||||||
|
});
|
||||||
23
node/node_modules/js-yaml/bower.json
generated
vendored
Normal file
23
node/node_modules/js-yaml/bower.json
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
|
||||||
|
{
|
||||||
|
"name": "js-yaml",
|
||||||
|
"main": "dist/js-yaml.js",
|
||||||
|
"homepage": "https://github.com/nodeca/js-yaml",
|
||||||
|
"authors": [ "Dervus Grim <dervus.grim@gmail.com>",
|
||||||
|
"Vitaly Puzrin <vitaly@rcdesign.ru>",
|
||||||
|
"Aleksey V Zapparov <ixti@member.fsf.org>",
|
||||||
|
"Martin Grenfell <martin.grenfell@gmail.com>" ],
|
||||||
|
"description": "YAML 1.2 parser and serializer",
|
||||||
|
"keywords": ["yaml", "parser", "serializer", "pyyaml"],
|
||||||
|
"license": "MIT",
|
||||||
|
"ignore": [
|
||||||
|
"**/.*",
|
||||||
|
"node_modules",
|
||||||
|
"benchmark",
|
||||||
|
"bower_components",
|
||||||
|
"test",
|
||||||
|
"Makefile",
|
||||||
|
"index*",
|
||||||
|
"package.json"
|
||||||
|
]
|
||||||
|
}
|
||||||
3666
node/node_modules/js-yaml/dist/js-yaml.js
generated
vendored
Normal file
3666
node/node_modules/js-yaml/dist/js-yaml.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
3
node/node_modules/js-yaml/dist/js-yaml.min.js
generated
vendored
Normal file
3
node/node_modules/js-yaml/dist/js-yaml.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
102
node/node_modules/js-yaml/examples/custom_types.js
generated
vendored
Normal file
102
node/node_modules/js-yaml/examples/custom_types.js
generated
vendored
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
|
var fs = require('fs');
|
||||||
|
var path = require('path');
|
||||||
|
var util = require('util');
|
||||||
|
var yaml = require('../lib/js-yaml');
|
||||||
|
|
||||||
|
|
||||||
|
// Let's define a couple of classes.
|
||||||
|
|
||||||
|
function Point(x, y, z) {
|
||||||
|
this.klass = 'Point';
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.z = z;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function Space(height, width, points) {
|
||||||
|
if (points) {
|
||||||
|
if (!points.every(function (point) { return point instanceof Point; })) {
|
||||||
|
throw new Error('A non-Point inside a points array!');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.klass = 'Space';
|
||||||
|
this.height = height;
|
||||||
|
this.width = width;
|
||||||
|
this.points = points;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Then define YAML types to load and dump our Point/Space objects.
|
||||||
|
|
||||||
|
var PointYamlType = new yaml.Type('!point', {
|
||||||
|
// Loader must parse sequence nodes only for this type (i.e. arrays in JS terminology).
|
||||||
|
// Other available kinds are 'scalar' (string) and 'mapping' (object).
|
||||||
|
// http://www.yaml.org/spec/1.2/spec.html#kind//
|
||||||
|
kind: 'sequence',
|
||||||
|
|
||||||
|
// Loader must check if the input object is suitable for this type.
|
||||||
|
resolve: function (data) {
|
||||||
|
// `data` may be either:
|
||||||
|
// - Null in case of an "empty node" (http://www.yaml.org/spec/1.2/spec.html#id2786563)
|
||||||
|
// - Array since we specified `kind` to 'sequence'
|
||||||
|
return data !== null && data.length === 3;
|
||||||
|
},
|
||||||
|
|
||||||
|
// If a node is resolved, use it to create a Point instance.
|
||||||
|
construct: function (data) {
|
||||||
|
return new Point(data[0], data[1], data[2]);
|
||||||
|
},
|
||||||
|
|
||||||
|
// Dumper must process instances of Point by rules of this YAML type.
|
||||||
|
instanceOf: Point,
|
||||||
|
|
||||||
|
// Dumper must represent Point objects as three-element sequence in YAML.
|
||||||
|
represent: function (point) {
|
||||||
|
return [ point.x, point.y, point.z ];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
var SpaceYamlType = new yaml.Type('!space', {
|
||||||
|
kind: 'mapping',
|
||||||
|
construct: function (data) {
|
||||||
|
data = data || {}; // in case of empty node
|
||||||
|
return new Space(data.height || 0, data.width || 0, data.points || []);
|
||||||
|
},
|
||||||
|
instanceOf: Space
|
||||||
|
// `represent` is omitted here. So, Space objects will be dumped as is.
|
||||||
|
// That is regular mapping with three key-value pairs but with !space tag.
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// After our types are defined, it's time to join them into a schema.
|
||||||
|
|
||||||
|
var SPACE_SCHEMA = yaml.Schema.create([ SpaceYamlType, PointYamlType ]);
|
||||||
|
|
||||||
|
|
||||||
|
// And read a document using that schema.
|
||||||
|
|
||||||
|
fs.readFile(path.join(__dirname, 'custom_types.yml'), 'utf8', function (error, data) {
|
||||||
|
var loaded;
|
||||||
|
|
||||||
|
if (!error) {
|
||||||
|
loaded = yaml.load(data, { schema: SPACE_SCHEMA });
|
||||||
|
console.log(util.inspect(loaded, false, 20, true));
|
||||||
|
} else {
|
||||||
|
console.error(error.stack || error.message || String(error));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// There are some exports to play with this example interactively.
|
||||||
|
|
||||||
|
module.exports.Point = Point;
|
||||||
|
module.exports.Space = Space;
|
||||||
|
module.exports.PointYamlType = PointYamlType;
|
||||||
|
module.exports.SpaceYamlType = SpaceYamlType;
|
||||||
|
module.exports.SPACE_SCHEMA = SPACE_SCHEMA;
|
||||||
18
node/node_modules/js-yaml/examples/custom_types.yml
generated
vendored
Normal file
18
node/node_modules/js-yaml/examples/custom_types.yml
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
subject: Custom types in JS-YAML
|
||||||
|
spaces:
|
||||||
|
- !space
|
||||||
|
height: 1000
|
||||||
|
width: 1000
|
||||||
|
points:
|
||||||
|
- !point [ 10, 43, 23 ]
|
||||||
|
- !point [ 165, 0, 50 ]
|
||||||
|
- !point [ 100, 100, 100 ]
|
||||||
|
|
||||||
|
- !space
|
||||||
|
height: 64
|
||||||
|
width: 128
|
||||||
|
points:
|
||||||
|
- !point [ 12, 43, 0 ]
|
||||||
|
- !point [ 1, 4, 90 ]
|
||||||
|
|
||||||
|
- !space # An empty space
|
||||||
31
node/node_modules/js-yaml/examples/dumper.js
generated
vendored
Normal file
31
node/node_modules/js-yaml/examples/dumper.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
|
var yaml = require('../lib/js-yaml');
|
||||||
|
var object = require('./dumper.json');
|
||||||
|
|
||||||
|
|
||||||
|
console.log(yaml.dump(object, {
|
||||||
|
flowLevel: 3,
|
||||||
|
styles: {
|
||||||
|
'!!int' : 'hexadecimal',
|
||||||
|
'!!null' : 'camelcase'
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
// Output:
|
||||||
|
//==============================================================================
|
||||||
|
// name: Wizzard
|
||||||
|
// level: 0x11
|
||||||
|
// sanity: Null
|
||||||
|
// inventory:
|
||||||
|
// - name: Hat
|
||||||
|
// features: [magic, pointed]
|
||||||
|
// traits: {}
|
||||||
|
// - name: Staff
|
||||||
|
// features: []
|
||||||
|
// traits: {damage: 0xA}
|
||||||
|
// - name: Cloak
|
||||||
|
// features: [old]
|
||||||
|
// traits: {defence: 0x0, comfort: 0x3}
|
||||||
22
node/node_modules/js-yaml/examples/dumper.json
generated
vendored
Normal file
22
node/node_modules/js-yaml/examples/dumper.json
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"name" : "Wizzard",
|
||||||
|
"level" : 17,
|
||||||
|
"sanity" : null,
|
||||||
|
"inventory" : [
|
||||||
|
{
|
||||||
|
"name" : "Hat",
|
||||||
|
"features" : [ "magic", "pointed" ],
|
||||||
|
"traits" : {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name" : "Staff",
|
||||||
|
"features" : [],
|
||||||
|
"traits" : { "damage" : 10 }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name" : "Cloak",
|
||||||
|
"features" : [ "old" ],
|
||||||
|
"traits" : { "defence" : 0, "comfort" : 3 }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
18
node/node_modules/js-yaml/examples/sample_document.js
generated
vendored
Normal file
18
node/node_modules/js-yaml/examples/sample_document.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
|
var fs = require('fs');
|
||||||
|
var path = require('path');
|
||||||
|
var util = require('util');
|
||||||
|
var yaml = require('../lib/js-yaml');
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
var filename = path.join(__dirname, 'sample_document.yml'),
|
||||||
|
contents = fs.readFileSync(filename, 'utf8'),
|
||||||
|
data = yaml.load(contents);
|
||||||
|
|
||||||
|
console.log(util.inspect(data, false, 10, true));
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err.stack || String(err));
|
||||||
|
}
|
||||||
197
node/node_modules/js-yaml/examples/sample_document.yml
generated
vendored
Normal file
197
node/node_modules/js-yaml/examples/sample_document.yml
generated
vendored
Normal file
@@ -0,0 +1,197 @@
|
|||||||
|
---
|
||||||
|
# Collection Types #############################################################
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# http://yaml.org/type/map.html -----------------------------------------------#
|
||||||
|
|
||||||
|
map:
|
||||||
|
# Unordered set of key: value pairs.
|
||||||
|
Block style: !!map
|
||||||
|
Clark : Evans
|
||||||
|
Ingy : döt Net
|
||||||
|
Oren : Ben-Kiki
|
||||||
|
Flow style: !!map { Clark: Evans, Ingy: döt Net, Oren: Ben-Kiki }
|
||||||
|
|
||||||
|
# http://yaml.org/type/omap.html ----------------------------------------------#
|
||||||
|
|
||||||
|
omap:
|
||||||
|
# Explicitly typed ordered map (dictionary).
|
||||||
|
Bestiary: !!omap
|
||||||
|
- aardvark: African pig-like ant eater. Ugly.
|
||||||
|
- anteater: South-American ant eater. Two species.
|
||||||
|
- anaconda: South-American constrictor snake. Scaly.
|
||||||
|
# Etc.
|
||||||
|
# Flow style
|
||||||
|
Numbers: !!omap [ one: 1, two: 2, three : 3 ]
|
||||||
|
|
||||||
|
# http://yaml.org/type/pairs.html ---------------------------------------------#
|
||||||
|
|
||||||
|
pairs:
|
||||||
|
# Explicitly typed pairs.
|
||||||
|
Block tasks: !!pairs
|
||||||
|
- meeting: with team.
|
||||||
|
- meeting: with boss.
|
||||||
|
- break: lunch.
|
||||||
|
- meeting: with client.
|
||||||
|
Flow tasks: !!pairs [ meeting: with team, meeting: with boss ]
|
||||||
|
|
||||||
|
# http://yaml.org/type/set.html -----------------------------------------------#
|
||||||
|
|
||||||
|
set:
|
||||||
|
# Explicitly typed set.
|
||||||
|
baseball players: !!set
|
||||||
|
? Mark McGwire
|
||||||
|
? Sammy Sosa
|
||||||
|
? Ken Griffey
|
||||||
|
# Flow style
|
||||||
|
baseball teams: !!set { Boston Red Sox, Detroit Tigers, New York Yankees }
|
||||||
|
|
||||||
|
# http://yaml.org/type/seq.html -----------------------------------------------#
|
||||||
|
|
||||||
|
seq:
|
||||||
|
# Ordered sequence of nodes
|
||||||
|
Block style: !!seq
|
||||||
|
- Mercury # Rotates - no light/dark sides.
|
||||||
|
- Venus # Deadliest. Aptly named.
|
||||||
|
- Earth # Mostly dirt.
|
||||||
|
- Mars # Seems empty.
|
||||||
|
- Jupiter # The king.
|
||||||
|
- Saturn # Pretty.
|
||||||
|
- Uranus # Where the sun hardly shines.
|
||||||
|
- Neptune # Boring. No rings.
|
||||||
|
- Pluto # You call this a planet?
|
||||||
|
Flow style: !!seq [ Mercury, Venus, Earth, Mars, # Rocks
|
||||||
|
Jupiter, Saturn, Uranus, Neptune, # Gas
|
||||||
|
Pluto ] # Overrated
|
||||||
|
|
||||||
|
|
||||||
|
# Scalar Types #################################################################
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# http://yaml.org/type/binary.html --------------------------------------------#
|
||||||
|
|
||||||
|
binary:
|
||||||
|
canonical: !!binary "\
|
||||||
|
R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5\
|
||||||
|
OTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/+\
|
||||||
|
+f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLC\
|
||||||
|
AgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs="
|
||||||
|
generic: !!binary |
|
||||||
|
R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5
|
||||||
|
OTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/+
|
||||||
|
+f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLC
|
||||||
|
AgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs=
|
||||||
|
description:
|
||||||
|
The binary value above is a tiny arrow encoded as a gif image.
|
||||||
|
|
||||||
|
# http://yaml.org/type/bool.html ----------------------------------------------#
|
||||||
|
|
||||||
|
bool:
|
||||||
|
- true
|
||||||
|
- True
|
||||||
|
- TRUE
|
||||||
|
- false
|
||||||
|
- False
|
||||||
|
- FALSE
|
||||||
|
|
||||||
|
# http://yaml.org/type/float.html ---------------------------------------------#
|
||||||
|
|
||||||
|
float:
|
||||||
|
canonical: 6.8523015e+5
|
||||||
|
exponentioal: 685.230_15e+03
|
||||||
|
fixed: 685_230.15
|
||||||
|
sexagesimal: 190:20:30.15
|
||||||
|
negative infinity: -.inf
|
||||||
|
not a number: .NaN
|
||||||
|
|
||||||
|
# http://yaml.org/type/int.html -----------------------------------------------#
|
||||||
|
|
||||||
|
int:
|
||||||
|
canonical: 685230
|
||||||
|
decimal: +685_230
|
||||||
|
octal: 02472256
|
||||||
|
hexadecimal: 0x_0A_74_AE
|
||||||
|
binary: 0b1010_0111_0100_1010_1110
|
||||||
|
sexagesimal: 190:20:30
|
||||||
|
|
||||||
|
# http://yaml.org/type/merge.html ---------------------------------------------#
|
||||||
|
|
||||||
|
merge:
|
||||||
|
- &CENTER { x: 1, y: 2 }
|
||||||
|
- &LEFT { x: 0, y: 2 }
|
||||||
|
- &BIG { r: 10 }
|
||||||
|
- &SMALL { r: 1 }
|
||||||
|
|
||||||
|
# All the following maps are equal:
|
||||||
|
|
||||||
|
- # Explicit keys
|
||||||
|
x: 1
|
||||||
|
y: 2
|
||||||
|
r: 10
|
||||||
|
label: nothing
|
||||||
|
|
||||||
|
- # Merge one map
|
||||||
|
<< : *CENTER
|
||||||
|
r: 10
|
||||||
|
label: center
|
||||||
|
|
||||||
|
- # Merge multiple maps
|
||||||
|
<< : [ *CENTER, *BIG ]
|
||||||
|
label: center/big
|
||||||
|
|
||||||
|
- # Override
|
||||||
|
<< : [ *BIG, *LEFT, *SMALL ]
|
||||||
|
x: 1
|
||||||
|
label: big/left/small
|
||||||
|
|
||||||
|
# http://yaml.org/type/null.html ----------------------------------------------#
|
||||||
|
|
||||||
|
null:
|
||||||
|
# This mapping has four keys,
|
||||||
|
# one has a value.
|
||||||
|
empty:
|
||||||
|
canonical: ~
|
||||||
|
english: null
|
||||||
|
~: null key
|
||||||
|
# This sequence has five
|
||||||
|
# entries, two have values.
|
||||||
|
sparse:
|
||||||
|
- ~
|
||||||
|
- 2nd entry
|
||||||
|
-
|
||||||
|
- 4th entry
|
||||||
|
- Null
|
||||||
|
|
||||||
|
# http://yaml.org/type/str.html -----------------------------------------------#
|
||||||
|
|
||||||
|
string: abcd
|
||||||
|
|
||||||
|
# http://yaml.org/type/timestamp.html -----------------------------------------#
|
||||||
|
|
||||||
|
timestamp:
|
||||||
|
canonical: 2001-12-15T02:59:43.1Z
|
||||||
|
valid iso8601: 2001-12-14t21:59:43.10-05:00
|
||||||
|
space separated: 2001-12-14 21:59:43.10 -5
|
||||||
|
no time zone (Z): 2001-12-15 2:59:43.10
|
||||||
|
date (00:00:00Z): 2002-12-14
|
||||||
|
|
||||||
|
|
||||||
|
# JavaScript Specific Types ####################################################
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/RegExp
|
||||||
|
|
||||||
|
regexp:
|
||||||
|
simple: !!js/regexp foobar
|
||||||
|
modifiers: !!js/regexp /foobar/mi
|
||||||
|
|
||||||
|
# https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/undefined
|
||||||
|
|
||||||
|
undefined: !!js/undefined ~
|
||||||
|
|
||||||
|
# https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function
|
||||||
|
|
||||||
|
function: !!js/function >
|
||||||
|
function foobar() {
|
||||||
|
return 'Wow! JS-YAML Rocks!';
|
||||||
|
}
|
||||||
7
node/node_modules/js-yaml/index.js
generated
vendored
Normal file
7
node/node_modules/js-yaml/index.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
|
var yaml = require('./lib/js-yaml.js');
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = yaml;
|
||||||
39
node/node_modules/js-yaml/lib/js-yaml.js
generated
vendored
Normal file
39
node/node_modules/js-yaml/lib/js-yaml.js
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
|
var loader = require('./js-yaml/loader');
|
||||||
|
var dumper = require('./js-yaml/dumper');
|
||||||
|
|
||||||
|
|
||||||
|
function deprecated(name) {
|
||||||
|
return function () {
|
||||||
|
throw new Error('Function ' + name + ' is deprecated and cannot be used.');
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
module.exports.Type = require('./js-yaml/type');
|
||||||
|
module.exports.Schema = require('./js-yaml/schema');
|
||||||
|
module.exports.FAILSAFE_SCHEMA = require('./js-yaml/schema/failsafe');
|
||||||
|
module.exports.JSON_SCHEMA = require('./js-yaml/schema/json');
|
||||||
|
module.exports.CORE_SCHEMA = require('./js-yaml/schema/core');
|
||||||
|
module.exports.DEFAULT_SAFE_SCHEMA = require('./js-yaml/schema/default_safe');
|
||||||
|
module.exports.DEFAULT_FULL_SCHEMA = require('./js-yaml/schema/default_full');
|
||||||
|
module.exports.load = loader.load;
|
||||||
|
module.exports.loadAll = loader.loadAll;
|
||||||
|
module.exports.safeLoad = loader.safeLoad;
|
||||||
|
module.exports.safeLoadAll = loader.safeLoadAll;
|
||||||
|
module.exports.dump = dumper.dump;
|
||||||
|
module.exports.safeDump = dumper.safeDump;
|
||||||
|
module.exports.YAMLException = require('./js-yaml/exception');
|
||||||
|
|
||||||
|
// Deprecared schema names from JS-YAML 2.0.x
|
||||||
|
module.exports.MINIMAL_SCHEMA = require('./js-yaml/schema/failsafe');
|
||||||
|
module.exports.SAFE_SCHEMA = require('./js-yaml/schema/default_safe');
|
||||||
|
module.exports.DEFAULT_SCHEMA = require('./js-yaml/schema/default_full');
|
||||||
|
|
||||||
|
// Deprecated functions from JS-YAML 1.x.x
|
||||||
|
module.exports.scan = deprecated('scan');
|
||||||
|
module.exports.parse = deprecated('parse');
|
||||||
|
module.exports.compose = deprecated('compose');
|
||||||
|
module.exports.addConstructor = deprecated('addConstructor');
|
||||||
62
node/node_modules/js-yaml/lib/js-yaml/common.js
generated
vendored
Normal file
62
node/node_modules/js-yaml/lib/js-yaml/common.js
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
|
function isNothing(subject) {
|
||||||
|
return (undefined === subject) || (null === subject);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function isObject(subject) {
|
||||||
|
return ('object' === typeof subject) && (null !== subject);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function toArray(sequence) {
|
||||||
|
if (Array.isArray(sequence)) {
|
||||||
|
return sequence;
|
||||||
|
} else if (isNothing(sequence)) {
|
||||||
|
return [];
|
||||||
|
} else {
|
||||||
|
return [ sequence ];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function extend(target, source) {
|
||||||
|
var index, length, key, sourceKeys;
|
||||||
|
|
||||||
|
if (source) {
|
||||||
|
sourceKeys = Object.keys(source);
|
||||||
|
|
||||||
|
for (index = 0, length = sourceKeys.length; index < length; index += 1) {
|
||||||
|
key = sourceKeys[index];
|
||||||
|
target[key] = source[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function repeat(string, count) {
|
||||||
|
var result = '', cycle;
|
||||||
|
|
||||||
|
for (cycle = 0; cycle < count; cycle += 1) {
|
||||||
|
result += string;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function isNegativeZero(number) {
|
||||||
|
return (0 === number) && (Number.NEGATIVE_INFINITY === 1 / number);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
module.exports.isNothing = isNothing;
|
||||||
|
module.exports.isObject = isObject;
|
||||||
|
module.exports.toArray = toArray;
|
||||||
|
module.exports.repeat = repeat;
|
||||||
|
module.exports.isNegativeZero = isNegativeZero;
|
||||||
|
module.exports.extend = extend;
|
||||||
554
node/node_modules/js-yaml/lib/js-yaml/dumper.js
generated
vendored
Normal file
554
node/node_modules/js-yaml/lib/js-yaml/dumper.js
generated
vendored
Normal file
@@ -0,0 +1,554 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
|
var common = require('./common');
|
||||||
|
var YAMLException = require('./exception');
|
||||||
|
var DEFAULT_FULL_SCHEMA = require('./schema/default_full');
|
||||||
|
var DEFAULT_SAFE_SCHEMA = require('./schema/default_safe');
|
||||||
|
|
||||||
|
|
||||||
|
var _toString = Object.prototype.toString;
|
||||||
|
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||||
|
|
||||||
|
|
||||||
|
var CHAR_TAB = 0x09; /* Tab */
|
||||||
|
var CHAR_LINE_FEED = 0x0A; /* LF */
|
||||||
|
var CHAR_CARRIAGE_RETURN = 0x0D; /* CR */
|
||||||
|
var CHAR_SPACE = 0x20; /* Space */
|
||||||
|
var CHAR_EXCLAMATION = 0x21; /* ! */
|
||||||
|
var CHAR_DOUBLE_QUOTE = 0x22; /* " */
|
||||||
|
var CHAR_SHARP = 0x23; /* # */
|
||||||
|
var CHAR_PERCENT = 0x25; /* % */
|
||||||
|
var CHAR_AMPERSAND = 0x26; /* & */
|
||||||
|
var CHAR_SINGLE_QUOTE = 0x27; /* ' */
|
||||||
|
var CHAR_ASTERISK = 0x2A; /* * */
|
||||||
|
var CHAR_COMMA = 0x2C; /* , */
|
||||||
|
var CHAR_MINUS = 0x2D; /* - */
|
||||||
|
var CHAR_COLON = 0x3A; /* : */
|
||||||
|
var CHAR_GREATER_THAN = 0x3E; /* > */
|
||||||
|
var CHAR_QUESTION = 0x3F; /* ? */
|
||||||
|
var CHAR_COMMERCIAL_AT = 0x40; /* @ */
|
||||||
|
var CHAR_LEFT_SQUARE_BRACKET = 0x5B; /* [ */
|
||||||
|
var CHAR_RIGHT_SQUARE_BRACKET = 0x5D; /* ] */
|
||||||
|
var CHAR_GRAVE_ACCENT = 0x60; /* ` */
|
||||||
|
var CHAR_LEFT_CURLY_BRACKET = 0x7B; /* { */
|
||||||
|
var CHAR_VERTICAL_LINE = 0x7C; /* | */
|
||||||
|
var CHAR_RIGHT_CURLY_BRACKET = 0x7D; /* } */
|
||||||
|
|
||||||
|
|
||||||
|
var ESCAPE_SEQUENCES = {};
|
||||||
|
|
||||||
|
ESCAPE_SEQUENCES[0x00] = '\\0';
|
||||||
|
ESCAPE_SEQUENCES[0x07] = '\\a';
|
||||||
|
ESCAPE_SEQUENCES[0x08] = '\\b';
|
||||||
|
ESCAPE_SEQUENCES[0x09] = '\\t';
|
||||||
|
ESCAPE_SEQUENCES[0x0A] = '\\n';
|
||||||
|
ESCAPE_SEQUENCES[0x0B] = '\\v';
|
||||||
|
ESCAPE_SEQUENCES[0x0C] = '\\f';
|
||||||
|
ESCAPE_SEQUENCES[0x0D] = '\\r';
|
||||||
|
ESCAPE_SEQUENCES[0x1B] = '\\e';
|
||||||
|
ESCAPE_SEQUENCES[0x22] = '\\"';
|
||||||
|
ESCAPE_SEQUENCES[0x5C] = '\\\\';
|
||||||
|
ESCAPE_SEQUENCES[0x85] = '\\N';
|
||||||
|
ESCAPE_SEQUENCES[0xA0] = '\\_';
|
||||||
|
ESCAPE_SEQUENCES[0x2028] = '\\L';
|
||||||
|
ESCAPE_SEQUENCES[0x2029] = '\\P';
|
||||||
|
|
||||||
|
|
||||||
|
var DEPRECATED_BOOLEANS_SYNTAX = [
|
||||||
|
'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON',
|
||||||
|
'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF'
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
function compileStyleMap(schema, map) {
|
||||||
|
var result, keys, index, length, tag, style, type;
|
||||||
|
|
||||||
|
if (null === map) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
result = {};
|
||||||
|
keys = Object.keys(map);
|
||||||
|
|
||||||
|
for (index = 0, length = keys.length; index < length; index += 1) {
|
||||||
|
tag = keys[index];
|
||||||
|
style = String(map[tag]);
|
||||||
|
|
||||||
|
if ('!!' === tag.slice(0, 2)) {
|
||||||
|
tag = 'tag:yaml.org,2002:' + tag.slice(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
type = schema.compiledTypeMap[tag];
|
||||||
|
|
||||||
|
if (type && _hasOwnProperty.call(type.styleAliases, style)) {
|
||||||
|
style = type.styleAliases[style];
|
||||||
|
}
|
||||||
|
|
||||||
|
result[tag] = style;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function encodeHex(character) {
|
||||||
|
var string, handle, length;
|
||||||
|
|
||||||
|
string = character.toString(16).toUpperCase();
|
||||||
|
|
||||||
|
if (character <= 0xFF) {
|
||||||
|
handle = 'x';
|
||||||
|
length = 2;
|
||||||
|
} else if (character <= 0xFFFF) {
|
||||||
|
handle = 'u';
|
||||||
|
length = 4;
|
||||||
|
} else if (character <= 0xFFFFFFFF) {
|
||||||
|
handle = 'U';
|
||||||
|
length = 8;
|
||||||
|
} else {
|
||||||
|
throw new YAMLException('code point within a string may not be greater than 0xFFFFFFFF');
|
||||||
|
}
|
||||||
|
|
||||||
|
return '\\' + handle + common.repeat('0', length - string.length) + string;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function State(options) {
|
||||||
|
this.schema = options['schema'] || DEFAULT_FULL_SCHEMA;
|
||||||
|
this.indent = Math.max(1, (options['indent'] || 2));
|
||||||
|
this.skipInvalid = options['skipInvalid'] || false;
|
||||||
|
this.flowLevel = (common.isNothing(options['flowLevel']) ? -1 : options['flowLevel']);
|
||||||
|
this.styleMap = compileStyleMap(this.schema, options['styles'] || null);
|
||||||
|
|
||||||
|
this.implicitTypes = this.schema.compiledImplicit;
|
||||||
|
this.explicitTypes = this.schema.compiledExplicit;
|
||||||
|
|
||||||
|
this.tag = null;
|
||||||
|
this.result = '';
|
||||||
|
|
||||||
|
this.duplicates = [];
|
||||||
|
this.usedDuplicates = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function generateNextLine(state, level) {
|
||||||
|
return '\n' + common.repeat(' ', state.indent * level);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testImplicitResolving(state, str) {
|
||||||
|
var index, length, type;
|
||||||
|
|
||||||
|
for (index = 0, length = state.implicitTypes.length; index < length; index += 1) {
|
||||||
|
type = state.implicitTypes[index];
|
||||||
|
|
||||||
|
if (type.resolve(str)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function writeScalar(state, object) {
|
||||||
|
var isQuoted, checkpoint, position, length, character, first;
|
||||||
|
|
||||||
|
state.dump = '';
|
||||||
|
isQuoted = false;
|
||||||
|
checkpoint = 0;
|
||||||
|
first = object.charCodeAt(0) || 0;
|
||||||
|
|
||||||
|
if (-1 !== DEPRECATED_BOOLEANS_SYNTAX.indexOf(object)) {
|
||||||
|
// Ensure compatibility with YAML 1.0/1.1 loaders.
|
||||||
|
isQuoted = true;
|
||||||
|
} else if (0 === object.length) {
|
||||||
|
// Quote empty string
|
||||||
|
isQuoted = true;
|
||||||
|
} else if (CHAR_SPACE === first ||
|
||||||
|
CHAR_SPACE === object.charCodeAt(object.length - 1)) {
|
||||||
|
isQuoted = true;
|
||||||
|
} else if (CHAR_MINUS === first ||
|
||||||
|
CHAR_QUESTION === first) {
|
||||||
|
// Don't check second symbol for simplicity
|
||||||
|
isQuoted = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (position = 0, length = object.length; position < length; position += 1) {
|
||||||
|
character = object.charCodeAt(position);
|
||||||
|
|
||||||
|
if (!isQuoted) {
|
||||||
|
if (CHAR_TAB === character ||
|
||||||
|
CHAR_LINE_FEED === character ||
|
||||||
|
CHAR_CARRIAGE_RETURN === character ||
|
||||||
|
CHAR_COMMA === character ||
|
||||||
|
CHAR_LEFT_SQUARE_BRACKET === character ||
|
||||||
|
CHAR_RIGHT_SQUARE_BRACKET === character ||
|
||||||
|
CHAR_LEFT_CURLY_BRACKET === character ||
|
||||||
|
CHAR_RIGHT_CURLY_BRACKET === character ||
|
||||||
|
CHAR_SHARP === character ||
|
||||||
|
CHAR_AMPERSAND === character ||
|
||||||
|
CHAR_ASTERISK === character ||
|
||||||
|
CHAR_EXCLAMATION === character ||
|
||||||
|
CHAR_VERTICAL_LINE === character ||
|
||||||
|
CHAR_GREATER_THAN === character ||
|
||||||
|
CHAR_SINGLE_QUOTE === character ||
|
||||||
|
CHAR_DOUBLE_QUOTE === character ||
|
||||||
|
CHAR_PERCENT === character ||
|
||||||
|
CHAR_COMMERCIAL_AT === character ||
|
||||||
|
CHAR_COLON === character ||
|
||||||
|
CHAR_GRAVE_ACCENT === character) {
|
||||||
|
isQuoted = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ESCAPE_SEQUENCES[character] ||
|
||||||
|
!((0x00020 <= character && character <= 0x00007E) ||
|
||||||
|
(0x00085 === character) ||
|
||||||
|
(0x000A0 <= character && character <= 0x00D7FF) ||
|
||||||
|
(0x0E000 <= character && character <= 0x00FFFD) ||
|
||||||
|
(0x10000 <= character && character <= 0x10FFFF))) {
|
||||||
|
state.dump += object.slice(checkpoint, position);
|
||||||
|
state.dump += ESCAPE_SEQUENCES[character] || encodeHex(character);
|
||||||
|
checkpoint = position + 1;
|
||||||
|
isQuoted = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (checkpoint < position) {
|
||||||
|
state.dump += object.slice(checkpoint, position);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isQuoted && testImplicitResolving(state, state.dump)) {
|
||||||
|
isQuoted = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isQuoted) {
|
||||||
|
state.dump = '"' + state.dump + '"';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function writeFlowSequence(state, level, object) {
|
||||||
|
var _result = '',
|
||||||
|
_tag = state.tag,
|
||||||
|
index,
|
||||||
|
length;
|
||||||
|
|
||||||
|
for (index = 0, length = object.length; index < length; index += 1) {
|
||||||
|
// Write only valid elements.
|
||||||
|
if (writeNode(state, level, object[index], false, false)) {
|
||||||
|
if (0 !== index) {
|
||||||
|
_result += ', ';
|
||||||
|
}
|
||||||
|
_result += state.dump;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
state.tag = _tag;
|
||||||
|
state.dump = '[' + _result + ']';
|
||||||
|
}
|
||||||
|
|
||||||
|
function writeBlockSequence(state, level, object, compact) {
|
||||||
|
var _result = '',
|
||||||
|
_tag = state.tag,
|
||||||
|
index,
|
||||||
|
length;
|
||||||
|
|
||||||
|
for (index = 0, length = object.length; index < length; index += 1) {
|
||||||
|
// Write only valid elements.
|
||||||
|
if (writeNode(state, level + 1, object[index], true, true)) {
|
||||||
|
if (!compact || 0 !== index) {
|
||||||
|
_result += generateNextLine(state, level);
|
||||||
|
}
|
||||||
|
_result += '- ' + state.dump;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
state.tag = _tag;
|
||||||
|
state.dump = _result || '[]'; // Empty sequence if no valid values.
|
||||||
|
}
|
||||||
|
|
||||||
|
function writeFlowMapping(state, level, object) {
|
||||||
|
var _result = '',
|
||||||
|
_tag = state.tag,
|
||||||
|
objectKeyList = Object.keys(object),
|
||||||
|
index,
|
||||||
|
length,
|
||||||
|
objectKey,
|
||||||
|
objectValue,
|
||||||
|
pairBuffer;
|
||||||
|
|
||||||
|
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
||||||
|
pairBuffer = '';
|
||||||
|
|
||||||
|
if (0 !== index) {
|
||||||
|
pairBuffer += ', ';
|
||||||
|
}
|
||||||
|
|
||||||
|
objectKey = objectKeyList[index];
|
||||||
|
objectValue = object[objectKey];
|
||||||
|
|
||||||
|
if (!writeNode(state, level, objectKey, false, false)) {
|
||||||
|
continue; // Skip this pair because of invalid key;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state.dump.length > 1024) {
|
||||||
|
pairBuffer += '? ';
|
||||||
|
}
|
||||||
|
|
||||||
|
pairBuffer += state.dump + ': ';
|
||||||
|
|
||||||
|
if (!writeNode(state, level, objectValue, false, false)) {
|
||||||
|
continue; // Skip this pair because of invalid value.
|
||||||
|
}
|
||||||
|
|
||||||
|
pairBuffer += state.dump;
|
||||||
|
|
||||||
|
// Both key and value are valid.
|
||||||
|
_result += pairBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
state.tag = _tag;
|
||||||
|
state.dump = '{' + _result + '}';
|
||||||
|
}
|
||||||
|
|
||||||
|
function writeBlockMapping(state, level, object, compact) {
|
||||||
|
var _result = '',
|
||||||
|
_tag = state.tag,
|
||||||
|
objectKeyList = Object.keys(object),
|
||||||
|
index,
|
||||||
|
length,
|
||||||
|
objectKey,
|
||||||
|
objectValue,
|
||||||
|
explicitPair,
|
||||||
|
pairBuffer;
|
||||||
|
|
||||||
|
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
||||||
|
pairBuffer = '';
|
||||||
|
|
||||||
|
if (!compact || 0 !== index) {
|
||||||
|
pairBuffer += generateNextLine(state, level);
|
||||||
|
}
|
||||||
|
|
||||||
|
objectKey = objectKeyList[index];
|
||||||
|
objectValue = object[objectKey];
|
||||||
|
|
||||||
|
if (!writeNode(state, level + 1, objectKey, true, true)) {
|
||||||
|
continue; // Skip this pair because of invalid key.
|
||||||
|
}
|
||||||
|
|
||||||
|
explicitPair = (null !== state.tag && '?' !== state.tag) ||
|
||||||
|
(state.dump && state.dump.length > 1024);
|
||||||
|
|
||||||
|
if (explicitPair) {
|
||||||
|
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
||||||
|
pairBuffer += '?';
|
||||||
|
} else {
|
||||||
|
pairBuffer += '? ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pairBuffer += state.dump;
|
||||||
|
|
||||||
|
if (explicitPair) {
|
||||||
|
pairBuffer += generateNextLine(state, level);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
|
||||||
|
continue; // Skip this pair because of invalid value.
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
||||||
|
pairBuffer += ':';
|
||||||
|
} else {
|
||||||
|
pairBuffer += ': ';
|
||||||
|
}
|
||||||
|
|
||||||
|
pairBuffer += state.dump;
|
||||||
|
|
||||||
|
// Both key and value are valid.
|
||||||
|
_result += pairBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
state.tag = _tag;
|
||||||
|
state.dump = _result || '{}'; // Empty mapping if no valid pairs.
|
||||||
|
}
|
||||||
|
|
||||||
|
function detectType(state, object, explicit) {
|
||||||
|
var _result, typeList, index, length, type, style;
|
||||||
|
|
||||||
|
typeList = explicit ? state.explicitTypes : state.implicitTypes;
|
||||||
|
|
||||||
|
for (index = 0, length = typeList.length; index < length; index += 1) {
|
||||||
|
type = typeList[index];
|
||||||
|
|
||||||
|
if ((type.instanceOf || type.predicate) &&
|
||||||
|
(!type.instanceOf || (('object' === typeof object) && (object instanceof type.instanceOf))) &&
|
||||||
|
(!type.predicate || type.predicate(object))) {
|
||||||
|
|
||||||
|
state.tag = explicit ? type.tag : '?';
|
||||||
|
|
||||||
|
if (type.represent) {
|
||||||
|
style = state.styleMap[type.tag] || type.defaultStyle;
|
||||||
|
|
||||||
|
if ('[object Function]' === _toString.call(type.represent)) {
|
||||||
|
_result = type.represent(object, style);
|
||||||
|
} else if (_hasOwnProperty.call(type.represent, style)) {
|
||||||
|
_result = type.represent[style](object, style);
|
||||||
|
} else {
|
||||||
|
throw new YAMLException('!<' + type.tag + '> tag resolver accepts not "' + style + '" style');
|
||||||
|
}
|
||||||
|
|
||||||
|
state.dump = _result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Serializes `object` and writes it to global `result`.
|
||||||
|
// Returns true on success, or false on invalid object.
|
||||||
|
//
|
||||||
|
function writeNode(state, level, object, block, compact) {
|
||||||
|
state.tag = null;
|
||||||
|
state.dump = object;
|
||||||
|
|
||||||
|
if (!detectType(state, object, false)) {
|
||||||
|
detectType(state, object, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
var type = _toString.call(state.dump);
|
||||||
|
|
||||||
|
if (block) {
|
||||||
|
block = (0 > state.flowLevel || state.flowLevel > level);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((null !== state.tag && '?' !== state.tag) || (2 !== state.indent && level > 0)) {
|
||||||
|
compact = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var objectOrArray = '[object Object]' === type || '[object Array]' === type,
|
||||||
|
duplicateIndex,
|
||||||
|
duplicate;
|
||||||
|
|
||||||
|
if (objectOrArray) {
|
||||||
|
duplicateIndex = state.duplicates.indexOf(object);
|
||||||
|
duplicate = duplicateIndex !== -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (duplicate && state.usedDuplicates[duplicateIndex]) {
|
||||||
|
state.dump = '*ref_' + duplicateIndex;
|
||||||
|
} else {
|
||||||
|
if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
|
||||||
|
state.usedDuplicates[duplicateIndex] = true;
|
||||||
|
}
|
||||||
|
if ('[object Object]' === type) {
|
||||||
|
if (block && (0 !== Object.keys(state.dump).length)) {
|
||||||
|
writeBlockMapping(state, level, state.dump, compact);
|
||||||
|
if (duplicate) {
|
||||||
|
state.dump = '&ref_' + duplicateIndex + (0 === level ? '\n' : '') + state.dump;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
writeFlowMapping(state, level, state.dump);
|
||||||
|
if (duplicate) {
|
||||||
|
state.dump = '&ref_' + duplicateIndex + ' ' + state.dump;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if ('[object Array]' === type) {
|
||||||
|
if (block && (0 !== state.dump.length)) {
|
||||||
|
writeBlockSequence(state, level, state.dump, compact);
|
||||||
|
if (duplicate) {
|
||||||
|
state.dump = '&ref_' + duplicateIndex + (0 === level ? '\n' : '') + state.dump;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
writeFlowSequence(state, level, state.dump);
|
||||||
|
if (duplicate) {
|
||||||
|
state.dump = '&ref_' + duplicateIndex + ' ' + state.dump;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if ('[object String]' === type) {
|
||||||
|
if ('?' !== state.tag) {
|
||||||
|
writeScalar(state, state.dump);
|
||||||
|
}
|
||||||
|
} else if (state.skipInvalid) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
throw new YAMLException('unacceptable kind of an object to dump ' + type);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null !== state.tag && '?' !== state.tag) {
|
||||||
|
state.dump = '!<' + state.tag + '> ' + state.dump;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDuplicateReferences(object, state) {
|
||||||
|
var objects = [],
|
||||||
|
duplicatesIndexes = [],
|
||||||
|
index,
|
||||||
|
length;
|
||||||
|
|
||||||
|
inspectNode(object, objects, duplicatesIndexes);
|
||||||
|
|
||||||
|
for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) {
|
||||||
|
state.duplicates.push(objects[duplicatesIndexes[index]]);
|
||||||
|
}
|
||||||
|
state.usedDuplicates = new Array(length);
|
||||||
|
}
|
||||||
|
|
||||||
|
function inspectNode(object, objects, duplicatesIndexes) {
|
||||||
|
var type = _toString.call(object),
|
||||||
|
objectKeyList,
|
||||||
|
index,
|
||||||
|
length;
|
||||||
|
|
||||||
|
if (null !== object && 'object' === typeof object) {
|
||||||
|
index = objects.indexOf(object);
|
||||||
|
if (-1 !== index) {
|
||||||
|
if (-1 === duplicatesIndexes.indexOf(index)) {
|
||||||
|
duplicatesIndexes.push(index);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
objects.push(object);
|
||||||
|
|
||||||
|
if(Array.isArray(object)) {
|
||||||
|
for (index = 0, length = object.length; index < length; index += 1) {
|
||||||
|
inspectNode(object[index], objects, duplicatesIndexes);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
objectKeyList = Object.keys(object);
|
||||||
|
|
||||||
|
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
||||||
|
inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function dump(input, options) {
|
||||||
|
options = options || {};
|
||||||
|
|
||||||
|
var state = new State(options);
|
||||||
|
|
||||||
|
getDuplicateReferences(input, state);
|
||||||
|
|
||||||
|
if (writeNode(state, 0, input, true, true)) {
|
||||||
|
return state.dump + '\n';
|
||||||
|
} else {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function safeDump(input, options) {
|
||||||
|
return dump(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
module.exports.dump = dump;
|
||||||
|
module.exports.safeDump = safeDump;
|
||||||
25
node/node_modules/js-yaml/lib/js-yaml/exception.js
generated
vendored
Normal file
25
node/node_modules/js-yaml/lib/js-yaml/exception.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
|
function YAMLException(reason, mark) {
|
||||||
|
this.name = 'YAMLException';
|
||||||
|
this.reason = reason;
|
||||||
|
this.mark = mark;
|
||||||
|
this.message = this.toString(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
YAMLException.prototype.toString = function toString(compact) {
|
||||||
|
var result;
|
||||||
|
|
||||||
|
result = 'JS-YAML: ' + (this.reason || '(unknown reason)');
|
||||||
|
|
||||||
|
if (!compact && this.mark) {
|
||||||
|
result += ' ' + this.mark.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = YAMLException;
|
||||||
1581
node/node_modules/js-yaml/lib/js-yaml/loader.js
generated
vendored
Normal file
1581
node/node_modules/js-yaml/lib/js-yaml/loader.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
78
node/node_modules/js-yaml/lib/js-yaml/mark.js
generated
vendored
Normal file
78
node/node_modules/js-yaml/lib/js-yaml/mark.js
generated
vendored
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
|
var common = require('./common');
|
||||||
|
|
||||||
|
|
||||||
|
function Mark(name, buffer, position, line, column) {
|
||||||
|
this.name = name;
|
||||||
|
this.buffer = buffer;
|
||||||
|
this.position = position;
|
||||||
|
this.line = line;
|
||||||
|
this.column = column;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Mark.prototype.getSnippet = function getSnippet(indent, maxLength) {
|
||||||
|
var head, start, tail, end, snippet;
|
||||||
|
|
||||||
|
if (!this.buffer) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
indent = indent || 4;
|
||||||
|
maxLength = maxLength || 75;
|
||||||
|
|
||||||
|
head = '';
|
||||||
|
start = this.position;
|
||||||
|
|
||||||
|
while (start > 0 && -1 === '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(start - 1))) {
|
||||||
|
start -= 1;
|
||||||
|
if (this.position - start > (maxLength / 2 - 1)) {
|
||||||
|
head = ' ... ';
|
||||||
|
start += 5;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tail = '';
|
||||||
|
end = this.position;
|
||||||
|
|
||||||
|
while (end < this.buffer.length && -1 === '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(end))) {
|
||||||
|
end += 1;
|
||||||
|
if (end - this.position > (maxLength / 2 - 1)) {
|
||||||
|
tail = ' ... ';
|
||||||
|
end -= 5;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
snippet = this.buffer.slice(start, end);
|
||||||
|
|
||||||
|
return common.repeat(' ', indent) + head + snippet + tail + '\n' +
|
||||||
|
common.repeat(' ', indent + this.position - start + head.length) + '^';
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Mark.prototype.toString = function toString(compact) {
|
||||||
|
var snippet, where = '';
|
||||||
|
|
||||||
|
if (this.name) {
|
||||||
|
where += 'in "' + this.name + '" ';
|
||||||
|
}
|
||||||
|
|
||||||
|
where += 'at line ' + (this.line + 1) + ', column ' + (this.column + 1);
|
||||||
|
|
||||||
|
if (!compact) {
|
||||||
|
snippet = this.getSnippet();
|
||||||
|
|
||||||
|
if (snippet) {
|
||||||
|
where += ':\n' + snippet;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return where;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = Mark;
|
||||||
103
node/node_modules/js-yaml/lib/js-yaml/schema.js
generated
vendored
Normal file
103
node/node_modules/js-yaml/lib/js-yaml/schema.js
generated
vendored
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
|
var common = require('./common');
|
||||||
|
var YAMLException = require('./exception');
|
||||||
|
var Type = require('./type');
|
||||||
|
|
||||||
|
|
||||||
|
function compileList(schema, name, result) {
|
||||||
|
var exclude = [];
|
||||||
|
|
||||||
|
schema.include.forEach(function (includedSchema) {
|
||||||
|
result = compileList(includedSchema, name, result);
|
||||||
|
});
|
||||||
|
|
||||||
|
schema[name].forEach(function (currentType) {
|
||||||
|
result.forEach(function (previousType, previousIndex) {
|
||||||
|
if (previousType.tag === currentType.tag) {
|
||||||
|
exclude.push(previousIndex);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
result.push(currentType);
|
||||||
|
});
|
||||||
|
|
||||||
|
return result.filter(function (type, index) {
|
||||||
|
return -1 === exclude.indexOf(index);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function compileMap(/* lists... */) {
|
||||||
|
var result = {}, index, length;
|
||||||
|
|
||||||
|
function collectType(type) {
|
||||||
|
result[type.tag] = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (index = 0, length = arguments.length; index < length; index += 1) {
|
||||||
|
arguments[index].forEach(collectType);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function Schema(definition) {
|
||||||
|
this.include = definition.include || [];
|
||||||
|
this.implicit = definition.implicit || [];
|
||||||
|
this.explicit = definition.explicit || [];
|
||||||
|
|
||||||
|
this.implicit.forEach(function (type) {
|
||||||
|
if (type.loadKind && 'scalar' !== type.loadKind) {
|
||||||
|
throw new YAMLException('There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.compiledImplicit = compileList(this, 'implicit', []);
|
||||||
|
this.compiledExplicit = compileList(this, 'explicit', []);
|
||||||
|
this.compiledTypeMap = compileMap(this.compiledImplicit, this.compiledExplicit);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Schema.DEFAULT = null;
|
||||||
|
|
||||||
|
|
||||||
|
Schema.create = function createSchema() {
|
||||||
|
var schemas, types;
|
||||||
|
|
||||||
|
switch (arguments.length) {
|
||||||
|
case 1:
|
||||||
|
schemas = Schema.DEFAULT;
|
||||||
|
types = arguments[0];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
schemas = arguments[0];
|
||||||
|
types = arguments[1];
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new YAMLException('Wrong number of arguments for Schema.create function');
|
||||||
|
}
|
||||||
|
|
||||||
|
schemas = common.toArray(schemas);
|
||||||
|
types = common.toArray(types);
|
||||||
|
|
||||||
|
if (!schemas.every(function (schema) { return schema instanceof Schema; })) {
|
||||||
|
throw new YAMLException('Specified list of super schemas (or a single Schema object) contains a non-Schema object.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!types.every(function (type) { return type instanceof Type; })) {
|
||||||
|
throw new YAMLException('Specified list of YAML types (or a single Type object) contains a non-Type object.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Schema({
|
||||||
|
include: schemas,
|
||||||
|
explicit: types
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = Schema;
|
||||||
18
node/node_modules/js-yaml/lib/js-yaml/schema/core.js
generated
vendored
Normal file
18
node/node_modules/js-yaml/lib/js-yaml/schema/core.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
// Standard YAML's Core schema.
|
||||||
|
// http://www.yaml.org/spec/1.2/spec.html#id2804923
|
||||||
|
//
|
||||||
|
// NOTE: JS-YAML does not support schema-specific tag resolution restrictions.
|
||||||
|
// So, Core schema has no distinctions from JSON schema is JS-YAML.
|
||||||
|
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
|
var Schema = require('../schema');
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = new Schema({
|
||||||
|
include: [
|
||||||
|
require('./json')
|
||||||
|
]
|
||||||
|
});
|
||||||
25
node/node_modules/js-yaml/lib/js-yaml/schema/default_full.js
generated
vendored
Normal file
25
node/node_modules/js-yaml/lib/js-yaml/schema/default_full.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
// JS-YAML's default schema for `load` function.
|
||||||
|
// It is not described in the YAML specification.
|
||||||
|
//
|
||||||
|
// This schema is based on JS-YAML's default safe schema and includes
|
||||||
|
// JavaScript-specific types: !!js/undefined, !!js/regexp and !!js/function.
|
||||||
|
//
|
||||||
|
// Also this schema is used as default base schema at `Schema.create` function.
|
||||||
|
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
|
var Schema = require('../schema');
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = Schema.DEFAULT = new Schema({
|
||||||
|
include: [
|
||||||
|
require('./default_safe')
|
||||||
|
],
|
||||||
|
explicit: [
|
||||||
|
require('../type/js/undefined'),
|
||||||
|
require('../type/js/regexp'),
|
||||||
|
require('../type/js/function')
|
||||||
|
]
|
||||||
|
});
|
||||||
28
node/node_modules/js-yaml/lib/js-yaml/schema/default_safe.js
generated
vendored
Normal file
28
node/node_modules/js-yaml/lib/js-yaml/schema/default_safe.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
// JS-YAML's default schema for `safeLoad` function.
|
||||||
|
// It is not described in the YAML specification.
|
||||||
|
//
|
||||||
|
// This schema is based on standard YAML's Core schema and includes most of
|
||||||
|
// extra types described at YAML tag repository. (http://yaml.org/type/)
|
||||||
|
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
|
var Schema = require('../schema');
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = new Schema({
|
||||||
|
include: [
|
||||||
|
require('./core')
|
||||||
|
],
|
||||||
|
implicit: [
|
||||||
|
require('../type/timestamp'),
|
||||||
|
require('../type/merge')
|
||||||
|
],
|
||||||
|
explicit: [
|
||||||
|
require('../type/binary'),
|
||||||
|
require('../type/omap'),
|
||||||
|
require('../type/pairs'),
|
||||||
|
require('../type/set')
|
||||||
|
]
|
||||||
|
});
|
||||||
17
node/node_modules/js-yaml/lib/js-yaml/schema/failsafe.js
generated
vendored
Normal file
17
node/node_modules/js-yaml/lib/js-yaml/schema/failsafe.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
// Standard YAML's Failsafe schema.
|
||||||
|
// http://www.yaml.org/spec/1.2/spec.html#id2802346
|
||||||
|
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
|
var Schema = require('../schema');
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = new Schema({
|
||||||
|
explicit: [
|
||||||
|
require('../type/str'),
|
||||||
|
require('../type/seq'),
|
||||||
|
require('../type/map')
|
||||||
|
]
|
||||||
|
});
|
||||||
25
node/node_modules/js-yaml/lib/js-yaml/schema/json.js
generated
vendored
Normal file
25
node/node_modules/js-yaml/lib/js-yaml/schema/json.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
// Standard YAML's JSON schema.
|
||||||
|
// http://www.yaml.org/spec/1.2/spec.html#id2803231
|
||||||
|
//
|
||||||
|
// NOTE: JS-YAML does not support schema-specific tag resolution restrictions.
|
||||||
|
// So, this schema is not such strict as defined in the YAML specification.
|
||||||
|
// It allows numbers in binary notaion, use `Null` and `NULL` as `null`, etc.
|
||||||
|
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
|
var Schema = require('../schema');
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = new Schema({
|
||||||
|
include: [
|
||||||
|
require('./failsafe')
|
||||||
|
],
|
||||||
|
implicit: [
|
||||||
|
require('../type/null'),
|
||||||
|
require('../type/bool'),
|
||||||
|
require('../type/int'),
|
||||||
|
require('../type/float')
|
||||||
|
]
|
||||||
|
});
|
||||||
61
node/node_modules/js-yaml/lib/js-yaml/type.js
generated
vendored
Normal file
61
node/node_modules/js-yaml/lib/js-yaml/type.js
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var YAMLException = require('./exception');
|
||||||
|
|
||||||
|
var TYPE_CONSTRUCTOR_OPTIONS = [
|
||||||
|
'kind',
|
||||||
|
'resolve',
|
||||||
|
'construct',
|
||||||
|
'instanceOf',
|
||||||
|
'predicate',
|
||||||
|
'represent',
|
||||||
|
'defaultStyle',
|
||||||
|
'styleAliases'
|
||||||
|
];
|
||||||
|
|
||||||
|
var YAML_NODE_KINDS = [
|
||||||
|
'scalar',
|
||||||
|
'sequence',
|
||||||
|
'mapping'
|
||||||
|
];
|
||||||
|
|
||||||
|
function compileStyleAliases(map) {
|
||||||
|
var result = {};
|
||||||
|
|
||||||
|
if (null !== map) {
|
||||||
|
Object.keys(map).forEach(function (style) {
|
||||||
|
map[style].forEach(function (alias) {
|
||||||
|
result[String(alias)] = style;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function Type(tag, options) {
|
||||||
|
options = options || {};
|
||||||
|
|
||||||
|
Object.keys(options).forEach(function (name) {
|
||||||
|
if (-1 === TYPE_CONSTRUCTOR_OPTIONS.indexOf(name)) {
|
||||||
|
throw new YAMLException('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// TODO: Add tag format check.
|
||||||
|
this.tag = tag;
|
||||||
|
this.kind = options['kind'] || null;
|
||||||
|
this.resolve = options['resolve'] || function () { return true; };
|
||||||
|
this.construct = options['construct'] || function (data) { return data; };
|
||||||
|
this.instanceOf = options['instanceOf'] || null;
|
||||||
|
this.predicate = options['predicate'] || null;
|
||||||
|
this.represent = options['represent'] || null;
|
||||||
|
this.defaultStyle = options['defaultStyle'] || null;
|
||||||
|
this.styleAliases = compileStyleAliases(options['styleAliases'] || null);
|
||||||
|
|
||||||
|
if (-1 === YAML_NODE_KINDS.indexOf(this.kind)) {
|
||||||
|
throw new YAMLException('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = Type;
|
||||||
133
node/node_modules/js-yaml/lib/js-yaml/type/binary.js
generated
vendored
Normal file
133
node/node_modules/js-yaml/lib/js-yaml/type/binary.js
generated
vendored
Normal file
@@ -0,0 +1,133 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
|
// A trick for browserified version.
|
||||||
|
// Since we make browserifier to ignore `buffer` module, NodeBuffer will be undefined
|
||||||
|
var NodeBuffer = require('buffer').Buffer;
|
||||||
|
var Type = require('../type');
|
||||||
|
|
||||||
|
|
||||||
|
// [ 64, 65, 66 ] -> [ padding, CR, LF ]
|
||||||
|
var BASE64_MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r';
|
||||||
|
|
||||||
|
|
||||||
|
function resolveYamlBinary(data) {
|
||||||
|
if (null === data) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var code, idx, bitlen = 0, len = 0, max = data.length, map = BASE64_MAP;
|
||||||
|
|
||||||
|
// Convert one by one.
|
||||||
|
for (idx = 0; idx < max; idx ++) {
|
||||||
|
code = map.indexOf(data.charAt(idx));
|
||||||
|
|
||||||
|
// Skip CR/LF
|
||||||
|
if (code > 64) { continue; }
|
||||||
|
|
||||||
|
// Fail on illegal characters
|
||||||
|
if (code < 0) { return false; }
|
||||||
|
|
||||||
|
bitlen += 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If there are any bits left, source was corrupted
|
||||||
|
return (bitlen % 8) === 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function constructYamlBinary(data) {
|
||||||
|
var code, idx, tailbits,
|
||||||
|
input = data.replace(/[\r\n=]/g, ''), // remove CR/LF & padding to simplify scan
|
||||||
|
max = input.length,
|
||||||
|
map = BASE64_MAP,
|
||||||
|
bits = 0,
|
||||||
|
result = [];
|
||||||
|
|
||||||
|
// Collect by 6*4 bits (3 bytes)
|
||||||
|
|
||||||
|
for (idx = 0; idx < max; idx++) {
|
||||||
|
if ((idx % 4 === 0) && idx) {
|
||||||
|
result.push((bits >> 16) & 0xFF);
|
||||||
|
result.push((bits >> 8) & 0xFF);
|
||||||
|
result.push(bits & 0xFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
bits = (bits << 6) | map.indexOf(input.charAt(idx));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dump tail
|
||||||
|
|
||||||
|
tailbits = (max % 4)*6;
|
||||||
|
|
||||||
|
if (tailbits === 0) {
|
||||||
|
result.push((bits >> 16) & 0xFF);
|
||||||
|
result.push((bits >> 8) & 0xFF);
|
||||||
|
result.push(bits & 0xFF);
|
||||||
|
} else if (tailbits === 18) {
|
||||||
|
result.push((bits >> 10) & 0xFF);
|
||||||
|
result.push((bits >> 2) & 0xFF);
|
||||||
|
} else if (tailbits === 12) {
|
||||||
|
result.push((bits >> 4) & 0xFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wrap into Buffer for NodeJS and leave Array for browser
|
||||||
|
if (NodeBuffer) {
|
||||||
|
return new NodeBuffer(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function representYamlBinary(object /*, style*/) {
|
||||||
|
var result = '', bits = 0, idx, tail,
|
||||||
|
max = object.length,
|
||||||
|
map = BASE64_MAP;
|
||||||
|
|
||||||
|
// Convert every three bytes to 4 ASCII characters.
|
||||||
|
|
||||||
|
for (idx = 0; idx < max; idx++) {
|
||||||
|
if ((idx % 3 === 0) && idx) {
|
||||||
|
result += map[(bits >> 18) & 0x3F];
|
||||||
|
result += map[(bits >> 12) & 0x3F];
|
||||||
|
result += map[(bits >> 6) & 0x3F];
|
||||||
|
result += map[bits & 0x3F];
|
||||||
|
}
|
||||||
|
|
||||||
|
bits = (bits << 8) + object[idx];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dump tail
|
||||||
|
|
||||||
|
tail = max % 3;
|
||||||
|
|
||||||
|
if (tail === 0) {
|
||||||
|
result += map[(bits >> 18) & 0x3F];
|
||||||
|
result += map[(bits >> 12) & 0x3F];
|
||||||
|
result += map[(bits >> 6) & 0x3F];
|
||||||
|
result += map[bits & 0x3F];
|
||||||
|
} else if (tail === 2) {
|
||||||
|
result += map[(bits >> 10) & 0x3F];
|
||||||
|
result += map[(bits >> 4) & 0x3F];
|
||||||
|
result += map[(bits << 2) & 0x3F];
|
||||||
|
result += map[64];
|
||||||
|
} else if (tail === 1) {
|
||||||
|
result += map[(bits >> 2) & 0x3F];
|
||||||
|
result += map[(bits << 4) & 0x3F];
|
||||||
|
result += map[64];
|
||||||
|
result += map[64];
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isBinary(object) {
|
||||||
|
return NodeBuffer && NodeBuffer.isBuffer(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = new Type('tag:yaml.org,2002:binary', {
|
||||||
|
kind: 'scalar',
|
||||||
|
resolve: resolveYamlBinary,
|
||||||
|
construct: constructYamlBinary,
|
||||||
|
predicate: isBinary,
|
||||||
|
represent: representYamlBinary
|
||||||
|
});
|
||||||
37
node/node_modules/js-yaml/lib/js-yaml/type/bool.js
generated
vendored
Normal file
37
node/node_modules/js-yaml/lib/js-yaml/type/bool.js
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var Type = require('../type');
|
||||||
|
|
||||||
|
function resolveYamlBoolean(data) {
|
||||||
|
if (null === data) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var max = data.length;
|
||||||
|
|
||||||
|
return (max === 4 && (data === 'true' || data === 'True' || data === 'TRUE')) ||
|
||||||
|
(max === 5 && (data === 'false' || data === 'False' || data === 'FALSE'));
|
||||||
|
}
|
||||||
|
|
||||||
|
function constructYamlBoolean(data) {
|
||||||
|
return data === 'true' ||
|
||||||
|
data === 'True' ||
|
||||||
|
data === 'TRUE';
|
||||||
|
}
|
||||||
|
|
||||||
|
function isBoolean(object) {
|
||||||
|
return '[object Boolean]' === Object.prototype.toString.call(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = new Type('tag:yaml.org,2002:bool', {
|
||||||
|
kind: 'scalar',
|
||||||
|
resolve: resolveYamlBoolean,
|
||||||
|
construct: constructYamlBoolean,
|
||||||
|
predicate: isBoolean,
|
||||||
|
represent: {
|
||||||
|
lowercase: function (object) { return object ? 'true' : 'false'; },
|
||||||
|
uppercase: function (object) { return object ? 'TRUE' : 'FALSE'; },
|
||||||
|
camelcase: function (object) { return object ? 'True' : 'False'; }
|
||||||
|
},
|
||||||
|
defaultStyle: 'lowercase'
|
||||||
|
});
|
||||||
110
node/node_modules/js-yaml/lib/js-yaml/type/float.js
generated
vendored
Normal file
110
node/node_modules/js-yaml/lib/js-yaml/type/float.js
generated
vendored
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var common = require('../common');
|
||||||
|
var Type = require('../type');
|
||||||
|
|
||||||
|
var YAML_FLOAT_PATTERN = new RegExp(
|
||||||
|
'^(?:[-+]?(?:[0-9][0-9_]*)\\.[0-9_]*(?:[eE][-+][0-9]+)?' +
|
||||||
|
'|\\.[0-9_]+(?:[eE][-+][0-9]+)?' +
|
||||||
|
'|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*' +
|
||||||
|
'|[-+]?\\.(?:inf|Inf|INF)' +
|
||||||
|
'|\\.(?:nan|NaN|NAN))$');
|
||||||
|
|
||||||
|
function resolveYamlFloat(data) {
|
||||||
|
if (null === data) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var value, sign, base, digits;
|
||||||
|
|
||||||
|
if (!YAML_FLOAT_PATTERN.test(data)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function constructYamlFloat(data) {
|
||||||
|
var value, sign, base, digits;
|
||||||
|
|
||||||
|
value = data.replace(/_/g, '').toLowerCase();
|
||||||
|
sign = '-' === value[0] ? -1 : 1;
|
||||||
|
digits = [];
|
||||||
|
|
||||||
|
if (0 <= '+-'.indexOf(value[0])) {
|
||||||
|
value = value.slice(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('.inf' === value) {
|
||||||
|
return (1 === sign) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
|
||||||
|
|
||||||
|
} else if ('.nan' === value) {
|
||||||
|
return NaN;
|
||||||
|
|
||||||
|
} else if (0 <= value.indexOf(':')) {
|
||||||
|
value.split(':').forEach(function (v) {
|
||||||
|
digits.unshift(parseFloat(v, 10));
|
||||||
|
});
|
||||||
|
|
||||||
|
value = 0.0;
|
||||||
|
base = 1;
|
||||||
|
|
||||||
|
digits.forEach(function (d) {
|
||||||
|
value += d * base;
|
||||||
|
base *= 60;
|
||||||
|
});
|
||||||
|
|
||||||
|
return sign * value;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return sign * parseFloat(value, 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function representYamlFloat(object, style) {
|
||||||
|
if (isNaN(object)) {
|
||||||
|
switch (style) {
|
||||||
|
case 'lowercase':
|
||||||
|
return '.nan';
|
||||||
|
case 'uppercase':
|
||||||
|
return '.NAN';
|
||||||
|
case 'camelcase':
|
||||||
|
return '.NaN';
|
||||||
|
}
|
||||||
|
} else if (Number.POSITIVE_INFINITY === object) {
|
||||||
|
switch (style) {
|
||||||
|
case 'lowercase':
|
||||||
|
return '.inf';
|
||||||
|
case 'uppercase':
|
||||||
|
return '.INF';
|
||||||
|
case 'camelcase':
|
||||||
|
return '.Inf';
|
||||||
|
}
|
||||||
|
} else if (Number.NEGATIVE_INFINITY === object) {
|
||||||
|
switch (style) {
|
||||||
|
case 'lowercase':
|
||||||
|
return '-.inf';
|
||||||
|
case 'uppercase':
|
||||||
|
return '-.INF';
|
||||||
|
case 'camelcase':
|
||||||
|
return '-.Inf';
|
||||||
|
}
|
||||||
|
} else if (common.isNegativeZero(object)) {
|
||||||
|
return '-0.0';
|
||||||
|
} else {
|
||||||
|
return object.toString(10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function isFloat(object) {
|
||||||
|
return ('[object Number]' === Object.prototype.toString.call(object)) &&
|
||||||
|
(0 !== object % 1 || common.isNegativeZero(object));
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = new Type('tag:yaml.org,2002:float', {
|
||||||
|
kind: 'scalar',
|
||||||
|
resolve: resolveYamlFloat,
|
||||||
|
construct: constructYamlFloat,
|
||||||
|
predicate: isFloat,
|
||||||
|
represent: representYamlFloat,
|
||||||
|
defaultStyle: 'lowercase'
|
||||||
|
});
|
||||||
183
node/node_modules/js-yaml/lib/js-yaml/type/int.js
generated
vendored
Normal file
183
node/node_modules/js-yaml/lib/js-yaml/type/int.js
generated
vendored
Normal file
@@ -0,0 +1,183 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var common = require('../common');
|
||||||
|
var Type = require('../type');
|
||||||
|
|
||||||
|
function isHexCode(c) {
|
||||||
|
return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) ||
|
||||||
|
((0x41/* A */ <= c) && (c <= 0x46/* F */)) ||
|
||||||
|
((0x61/* a */ <= c) && (c <= 0x66/* f */));
|
||||||
|
}
|
||||||
|
|
||||||
|
function isOctCode(c) {
|
||||||
|
return ((0x30/* 0 */ <= c) && (c <= 0x37/* 7 */));
|
||||||
|
}
|
||||||
|
|
||||||
|
function isDecCode(c) {
|
||||||
|
return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */));
|
||||||
|
}
|
||||||
|
|
||||||
|
function resolveYamlInteger(data) {
|
||||||
|
if (null === data) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var max = data.length,
|
||||||
|
index = 0,
|
||||||
|
hasDigits = false,
|
||||||
|
ch;
|
||||||
|
|
||||||
|
if (!max) { return false; }
|
||||||
|
|
||||||
|
ch = data[index];
|
||||||
|
|
||||||
|
// sign
|
||||||
|
if (ch === '-' || ch === '+') {
|
||||||
|
ch = data[++index];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ch === '0') {
|
||||||
|
// 0
|
||||||
|
if (index+1 === max) { return true; }
|
||||||
|
ch = data[++index];
|
||||||
|
|
||||||
|
// base 2, base 8, base 16
|
||||||
|
|
||||||
|
if (ch === 'b') {
|
||||||
|
// base 2
|
||||||
|
index++;
|
||||||
|
|
||||||
|
for (; index < max; index++) {
|
||||||
|
ch = data[index];
|
||||||
|
if (ch === '_') { continue; }
|
||||||
|
if (ch !== '0' && ch !== '1') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
hasDigits = true;
|
||||||
|
}
|
||||||
|
return hasDigits;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (ch === 'x') {
|
||||||
|
// base 16
|
||||||
|
index++;
|
||||||
|
|
||||||
|
for (; index < max; index++) {
|
||||||
|
ch = data[index];
|
||||||
|
if (ch === '_') { continue; }
|
||||||
|
if (!isHexCode(data.charCodeAt(index))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
hasDigits = true;
|
||||||
|
}
|
||||||
|
return hasDigits;
|
||||||
|
}
|
||||||
|
|
||||||
|
// base 8
|
||||||
|
for (; index < max; index++) {
|
||||||
|
ch = data[index];
|
||||||
|
if (ch === '_') { continue; }
|
||||||
|
if (!isOctCode(data.charCodeAt(index))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
hasDigits = true;
|
||||||
|
}
|
||||||
|
return hasDigits;
|
||||||
|
}
|
||||||
|
|
||||||
|
// base 10 (except 0) or base 60
|
||||||
|
|
||||||
|
for (; index < max; index++) {
|
||||||
|
ch = data[index];
|
||||||
|
if (ch === '_') { continue; }
|
||||||
|
if (ch === ':') { break; }
|
||||||
|
if (!isDecCode(data.charCodeAt(index))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
hasDigits = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hasDigits) { return false; }
|
||||||
|
|
||||||
|
// if !base60 - done;
|
||||||
|
if (ch !== ':') { return true; }
|
||||||
|
|
||||||
|
// base60 almost not used, no needs to optimize
|
||||||
|
return /^(:[0-5]?[0-9])+$/.test(data.slice(index));
|
||||||
|
}
|
||||||
|
|
||||||
|
function constructYamlInteger(data) {
|
||||||
|
var value = data, sign = 1, ch, base, digits = [];
|
||||||
|
|
||||||
|
if (value.indexOf('_') !== -1) {
|
||||||
|
value = value.replace(/_/g, '');
|
||||||
|
}
|
||||||
|
|
||||||
|
ch = value[0];
|
||||||
|
|
||||||
|
if (ch === '-' || ch === '+') {
|
||||||
|
if (ch === '-') { sign = -1; }
|
||||||
|
value = value.slice(1);
|
||||||
|
ch = value[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('0' === value) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ch === '0') {
|
||||||
|
if (value[1] === 'b') {
|
||||||
|
return sign * parseInt(value.slice(2), 2);
|
||||||
|
}
|
||||||
|
if (value[1] === 'x') {
|
||||||
|
return sign * parseInt(value, 16);
|
||||||
|
}
|
||||||
|
return sign * parseInt(value, 8);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value.indexOf(':') !== -1) {
|
||||||
|
value.split(':').forEach(function (v) {
|
||||||
|
digits.unshift(parseInt(v, 10));
|
||||||
|
});
|
||||||
|
|
||||||
|
value = 0;
|
||||||
|
base = 1;
|
||||||
|
|
||||||
|
digits.forEach(function (d) {
|
||||||
|
value += (d * base);
|
||||||
|
base *= 60;
|
||||||
|
});
|
||||||
|
|
||||||
|
return sign * value;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return sign * parseInt(value, 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
function isInteger(object) {
|
||||||
|
return ('[object Number]' === Object.prototype.toString.call(object)) &&
|
||||||
|
(0 === object % 1 && !common.isNegativeZero(object));
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = new Type('tag:yaml.org,2002:int', {
|
||||||
|
kind: 'scalar',
|
||||||
|
resolve: resolveYamlInteger,
|
||||||
|
construct: constructYamlInteger,
|
||||||
|
predicate: isInteger,
|
||||||
|
represent: {
|
||||||
|
binary: function (object) { return '0b' + object.toString(2); },
|
||||||
|
octal: function (object) { return '0' + object.toString(8); },
|
||||||
|
decimal: function (object) { return object.toString(10); },
|
||||||
|
hexadecimal: function (object) { return '0x' + object.toString(16).toUpperCase(); }
|
||||||
|
},
|
||||||
|
defaultStyle: 'decimal',
|
||||||
|
styleAliases: {
|
||||||
|
binary: [ 2, 'bin' ],
|
||||||
|
octal: [ 8, 'oct' ],
|
||||||
|
decimal: [ 10, 'dec' ],
|
||||||
|
hexadecimal: [ 16, 'hex' ]
|
||||||
|
}
|
||||||
|
});
|
||||||
85
node/node_modules/js-yaml/lib/js-yaml/type/js/function.js
generated
vendored
Normal file
85
node/node_modules/js-yaml/lib/js-yaml/type/js/function.js
generated
vendored
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var esprima;
|
||||||
|
|
||||||
|
// Browserified version does not have esprima
|
||||||
|
//
|
||||||
|
// 1. For node.js just require module as deps
|
||||||
|
// 2. For browser try to require mudule via external AMD system.
|
||||||
|
// If not found - try to fallback to window.esprima. If not
|
||||||
|
// found too - then fail to parse.
|
||||||
|
//
|
||||||
|
try {
|
||||||
|
esprima = require('esprima');
|
||||||
|
} catch (_) {
|
||||||
|
/*global window */
|
||||||
|
if (typeof window !== 'undefined') { esprima = window.esprima; }
|
||||||
|
}
|
||||||
|
|
||||||
|
var Type = require('../../type');
|
||||||
|
|
||||||
|
function resolveJavascriptFunction(data) {
|
||||||
|
if (null === data) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
var source = '(' + data + ')',
|
||||||
|
ast = esprima.parse(source, { range: true }),
|
||||||
|
params = [],
|
||||||
|
body;
|
||||||
|
|
||||||
|
if ('Program' !== ast.type ||
|
||||||
|
1 !== ast.body.length ||
|
||||||
|
'ExpressionStatement' !== ast.body[0].type ||
|
||||||
|
'FunctionExpression' !== ast.body[0].expression.type) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} catch (err) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function constructJavascriptFunction(data) {
|
||||||
|
/*jslint evil:true*/
|
||||||
|
|
||||||
|
var source = '(' + data + ')',
|
||||||
|
ast = esprima.parse(source, { range: true }),
|
||||||
|
params = [],
|
||||||
|
body;
|
||||||
|
|
||||||
|
if ('Program' !== ast.type ||
|
||||||
|
1 !== ast.body.length ||
|
||||||
|
'ExpressionStatement' !== ast.body[0].type ||
|
||||||
|
'FunctionExpression' !== ast.body[0].expression.type) {
|
||||||
|
throw new Error('Failed to resolve function');
|
||||||
|
}
|
||||||
|
|
||||||
|
ast.body[0].expression.params.forEach(function (param) {
|
||||||
|
params.push(param.name);
|
||||||
|
});
|
||||||
|
|
||||||
|
body = ast.body[0].expression.body.range;
|
||||||
|
|
||||||
|
// Esprima's ranges include the first '{' and the last '}' characters on
|
||||||
|
// function expressions. So cut them out.
|
||||||
|
return new Function(params, source.slice(body[0]+1, body[1]-1));
|
||||||
|
}
|
||||||
|
|
||||||
|
function representJavascriptFunction(object /*, style*/) {
|
||||||
|
return object.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
function isFunction(object) {
|
||||||
|
return '[object Function]' === Object.prototype.toString.call(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = new Type('tag:yaml.org,2002:js/function', {
|
||||||
|
kind: 'scalar',
|
||||||
|
resolve: resolveJavascriptFunction,
|
||||||
|
construct: constructJavascriptFunction,
|
||||||
|
predicate: isFunction,
|
||||||
|
represent: representJavascriptFunction
|
||||||
|
});
|
||||||
84
node/node_modules/js-yaml/lib/js-yaml/type/js/regexp.js
generated
vendored
Normal file
84
node/node_modules/js-yaml/lib/js-yaml/type/js/regexp.js
generated
vendored
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var Type = require('../../type');
|
||||||
|
|
||||||
|
function resolveJavascriptRegExp(data) {
|
||||||
|
if (null === data) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (0 === data.length) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var regexp = data,
|
||||||
|
tail = /\/([gim]*)$/.exec(data),
|
||||||
|
modifiers = '';
|
||||||
|
|
||||||
|
// if regexp starts with '/' it can have modifiers and must be properly closed
|
||||||
|
// `/foo/gim` - modifiers tail can be maximum 3 chars
|
||||||
|
if ('/' === regexp[0]) {
|
||||||
|
if (tail) {
|
||||||
|
modifiers = tail[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (modifiers.length > 3) { return false; }
|
||||||
|
// if expression starts with /, is should be properly terminated
|
||||||
|
if (regexp[regexp.length - modifiers.length - 1] !== '/') { return false; }
|
||||||
|
|
||||||
|
regexp = regexp.slice(1, regexp.length - modifiers.length - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
var dummy = new RegExp(regexp, modifiers);
|
||||||
|
return true;
|
||||||
|
} catch (error) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function constructJavascriptRegExp(data) {
|
||||||
|
var regexp = data,
|
||||||
|
tail = /\/([gim]*)$/.exec(data),
|
||||||
|
modifiers = '';
|
||||||
|
|
||||||
|
// `/foo/gim` - tail can be maximum 4 chars
|
||||||
|
if ('/' === regexp[0]) {
|
||||||
|
if (tail) {
|
||||||
|
modifiers = tail[1];
|
||||||
|
}
|
||||||
|
regexp = regexp.slice(1, regexp.length - modifiers.length - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new RegExp(regexp, modifiers);
|
||||||
|
}
|
||||||
|
|
||||||
|
function representJavascriptRegExp(object /*, style*/) {
|
||||||
|
var result = '/' + object.source + '/';
|
||||||
|
|
||||||
|
if (object.global) {
|
||||||
|
result += 'g';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (object.multiline) {
|
||||||
|
result += 'm';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (object.ignoreCase) {
|
||||||
|
result += 'i';
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isRegExp(object) {
|
||||||
|
return '[object RegExp]' === Object.prototype.toString.call(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = new Type('tag:yaml.org,2002:js/regexp', {
|
||||||
|
kind: 'scalar',
|
||||||
|
resolve: resolveJavascriptRegExp,
|
||||||
|
construct: constructJavascriptRegExp,
|
||||||
|
predicate: isRegExp,
|
||||||
|
represent: representJavascriptRegExp
|
||||||
|
});
|
||||||
27
node/node_modules/js-yaml/lib/js-yaml/type/js/undefined.js
generated
vendored
Normal file
27
node/node_modules/js-yaml/lib/js-yaml/type/js/undefined.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var Type = require('../../type');
|
||||||
|
|
||||||
|
function resolveJavascriptUndefined() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function constructJavascriptUndefined() {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
function representJavascriptUndefined() {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
function isUndefined(object) {
|
||||||
|
return 'undefined' === typeof object;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = new Type('tag:yaml.org,2002:js/undefined', {
|
||||||
|
kind: 'scalar',
|
||||||
|
resolve: resolveJavascriptUndefined,
|
||||||
|
construct: constructJavascriptUndefined,
|
||||||
|
predicate: isUndefined,
|
||||||
|
represent: representJavascriptUndefined
|
||||||
|
});
|
||||||
8
node/node_modules/js-yaml/lib/js-yaml/type/map.js
generated
vendored
Normal file
8
node/node_modules/js-yaml/lib/js-yaml/type/map.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var Type = require('../type');
|
||||||
|
|
||||||
|
module.exports = new Type('tag:yaml.org,2002:map', {
|
||||||
|
kind: 'mapping',
|
||||||
|
construct: function (data) { return null !== data ? data : {}; }
|
||||||
|
});
|
||||||
12
node/node_modules/js-yaml/lib/js-yaml/type/merge.js
generated
vendored
Normal file
12
node/node_modules/js-yaml/lib/js-yaml/type/merge.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var Type = require('../type');
|
||||||
|
|
||||||
|
function resolveYamlMerge(data) {
|
||||||
|
return '<<' === data || null === data;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = new Type('tag:yaml.org,2002:merge', {
|
||||||
|
kind: 'scalar',
|
||||||
|
resolve: resolveYamlMerge
|
||||||
|
});
|
||||||
36
node/node_modules/js-yaml/lib/js-yaml/type/null.js
generated
vendored
Normal file
36
node/node_modules/js-yaml/lib/js-yaml/type/null.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var Type = require('../type');
|
||||||
|
|
||||||
|
function resolveYamlNull(data) {
|
||||||
|
if (null === data) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
var max = data.length;
|
||||||
|
|
||||||
|
return (max === 1 && data === '~') ||
|
||||||
|
(max === 4 && (data === 'null' || data === 'Null' || data === 'NULL'));
|
||||||
|
}
|
||||||
|
|
||||||
|
function constructYamlNull() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isNull(object) {
|
||||||
|
return null === object;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = new Type('tag:yaml.org,2002:null', {
|
||||||
|
kind: 'scalar',
|
||||||
|
resolve: resolveYamlNull,
|
||||||
|
construct: constructYamlNull,
|
||||||
|
predicate: isNull,
|
||||||
|
represent: {
|
||||||
|
canonical: function () { return '~'; },
|
||||||
|
lowercase: function () { return 'null'; },
|
||||||
|
uppercase: function () { return 'NULL'; },
|
||||||
|
camelcase: function () { return 'Null'; }
|
||||||
|
},
|
||||||
|
defaultStyle: 'lowercase'
|
||||||
|
});
|
||||||
56
node/node_modules/js-yaml/lib/js-yaml/type/omap.js
generated
vendored
Normal file
56
node/node_modules/js-yaml/lib/js-yaml/type/omap.js
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var Type = require('../type');
|
||||||
|
|
||||||
|
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||||
|
var _toString = Object.prototype.toString;
|
||||||
|
|
||||||
|
function resolveYamlOmap(data) {
|
||||||
|
if (null === data) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
var objectKeys = [], index, length, pair, pairKey, pairHasKey,
|
||||||
|
object = data;
|
||||||
|
|
||||||
|
for (index = 0, length = object.length; index < length; index += 1) {
|
||||||
|
pair = object[index];
|
||||||
|
pairHasKey = false;
|
||||||
|
|
||||||
|
if ('[object Object]' !== _toString.call(pair)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (pairKey in pair) {
|
||||||
|
if (_hasOwnProperty.call(pair, pairKey)) {
|
||||||
|
if (!pairHasKey) {
|
||||||
|
pairHasKey = true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!pairHasKey) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-1 === objectKeys.indexOf(pairKey)) {
|
||||||
|
objectKeys.push(pairKey);
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function constructYamlOmap(data) {
|
||||||
|
return null !== data ? data : [];
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = new Type('tag:yaml.org,2002:omap', {
|
||||||
|
kind: 'sequence',
|
||||||
|
resolve: resolveYamlOmap,
|
||||||
|
construct: constructYamlOmap
|
||||||
|
});
|
||||||
61
node/node_modules/js-yaml/lib/js-yaml/type/pairs.js
generated
vendored
Normal file
61
node/node_modules/js-yaml/lib/js-yaml/type/pairs.js
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var Type = require('../type');
|
||||||
|
|
||||||
|
var _toString = Object.prototype.toString;
|
||||||
|
|
||||||
|
function resolveYamlPairs(data) {
|
||||||
|
if (null === data) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
var index, length, pair, keys, result,
|
||||||
|
object = data;
|
||||||
|
|
||||||
|
result = new Array(object.length);
|
||||||
|
|
||||||
|
for (index = 0, length = object.length; index < length; index += 1) {
|
||||||
|
pair = object[index];
|
||||||
|
|
||||||
|
if ('[object Object]' !== _toString.call(pair)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
keys = Object.keys(pair);
|
||||||
|
|
||||||
|
if (1 !== keys.length) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
result[index] = [ keys[0], pair[keys[0]] ];
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function constructYamlPairs(data) {
|
||||||
|
if (null === data) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
var index, length, pair, keys, result,
|
||||||
|
object = data;
|
||||||
|
|
||||||
|
result = new Array(object.length);
|
||||||
|
|
||||||
|
for (index = 0, length = object.length; index < length; index += 1) {
|
||||||
|
pair = object[index];
|
||||||
|
|
||||||
|
keys = Object.keys(pair);
|
||||||
|
|
||||||
|
result[index] = [ keys[0], pair[keys[0]] ];
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = new Type('tag:yaml.org,2002:pairs', {
|
||||||
|
kind: 'sequence',
|
||||||
|
resolve: resolveYamlPairs,
|
||||||
|
construct: constructYamlPairs
|
||||||
|
});
|
||||||
8
node/node_modules/js-yaml/lib/js-yaml/type/seq.js
generated
vendored
Normal file
8
node/node_modules/js-yaml/lib/js-yaml/type/seq.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var Type = require('../type');
|
||||||
|
|
||||||
|
module.exports = new Type('tag:yaml.org,2002:seq', {
|
||||||
|
kind: 'sequence',
|
||||||
|
construct: function (data) { return null !== data ? data : []; }
|
||||||
|
});
|
||||||
33
node/node_modules/js-yaml/lib/js-yaml/type/set.js
generated
vendored
Normal file
33
node/node_modules/js-yaml/lib/js-yaml/type/set.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var Type = require('../type');
|
||||||
|
|
||||||
|
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||||
|
|
||||||
|
function resolveYamlSet(data) {
|
||||||
|
if (null === data) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
var key, object = data;
|
||||||
|
|
||||||
|
for (key in object) {
|
||||||
|
if (_hasOwnProperty.call(object, key)) {
|
||||||
|
if (null !== object[key]) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function constructYamlSet(data) {
|
||||||
|
return null !== data ? data : {};
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = new Type('tag:yaml.org,2002:set', {
|
||||||
|
kind: 'mapping',
|
||||||
|
resolve: resolveYamlSet,
|
||||||
|
construct: constructYamlSet
|
||||||
|
});
|
||||||
8
node/node_modules/js-yaml/lib/js-yaml/type/str.js
generated
vendored
Normal file
8
node/node_modules/js-yaml/lib/js-yaml/type/str.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var Type = require('../type');
|
||||||
|
|
||||||
|
module.exports = new Type('tag:yaml.org,2002:str', {
|
||||||
|
kind: 'scalar',
|
||||||
|
construct: function (data) { return null !== data ? data : ''; }
|
||||||
|
});
|
||||||
98
node/node_modules/js-yaml/lib/js-yaml/type/timestamp.js
generated
vendored
Normal file
98
node/node_modules/js-yaml/lib/js-yaml/type/timestamp.js
generated
vendored
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var Type = require('../type');
|
||||||
|
|
||||||
|
var YAML_TIMESTAMP_REGEXP = new RegExp(
|
||||||
|
'^([0-9][0-9][0-9][0-9])' + // [1] year
|
||||||
|
'-([0-9][0-9]?)' + // [2] month
|
||||||
|
'-([0-9][0-9]?)' + // [3] day
|
||||||
|
'(?:(?:[Tt]|[ \\t]+)' + // ...
|
||||||
|
'([0-9][0-9]?)' + // [4] hour
|
||||||
|
':([0-9][0-9])' + // [5] minute
|
||||||
|
':([0-9][0-9])' + // [6] second
|
||||||
|
'(?:\\.([0-9]*))?' + // [7] fraction
|
||||||
|
'(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + // [8] tz [9] tz_sign [10] tz_hour
|
||||||
|
'(?::([0-9][0-9]))?))?)?$'); // [11] tz_minute
|
||||||
|
|
||||||
|
function resolveYamlTimestamp(data) {
|
||||||
|
if (null === data) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var match, year, month, day, hour, minute, second, fraction = 0,
|
||||||
|
delta = null, tz_hour, tz_minute, date;
|
||||||
|
|
||||||
|
match = YAML_TIMESTAMP_REGEXP.exec(data);
|
||||||
|
|
||||||
|
if (null === match) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function constructYamlTimestamp(data) {
|
||||||
|
var match, year, month, day, hour, minute, second, fraction = 0,
|
||||||
|
delta = null, tz_hour, tz_minute, date;
|
||||||
|
|
||||||
|
match = YAML_TIMESTAMP_REGEXP.exec(data);
|
||||||
|
|
||||||
|
if (null === match) {
|
||||||
|
throw new Error('Date resolve error');
|
||||||
|
}
|
||||||
|
|
||||||
|
// match: [1] year [2] month [3] day
|
||||||
|
|
||||||
|
year = +(match[1]);
|
||||||
|
month = +(match[2]) - 1; // JS month starts with 0
|
||||||
|
day = +(match[3]);
|
||||||
|
|
||||||
|
if (!match[4]) { // no hour
|
||||||
|
return new Date(Date.UTC(year, month, day));
|
||||||
|
}
|
||||||
|
|
||||||
|
// match: [4] hour [5] minute [6] second [7] fraction
|
||||||
|
|
||||||
|
hour = +(match[4]);
|
||||||
|
minute = +(match[5]);
|
||||||
|
second = +(match[6]);
|
||||||
|
|
||||||
|
if (match[7]) {
|
||||||
|
fraction = match[7].slice(0, 3);
|
||||||
|
while (fraction.length < 3) { // milli-seconds
|
||||||
|
fraction += '0';
|
||||||
|
}
|
||||||
|
fraction = +fraction;
|
||||||
|
}
|
||||||
|
|
||||||
|
// match: [8] tz [9] tz_sign [10] tz_hour [11] tz_minute
|
||||||
|
|
||||||
|
if (match[9]) {
|
||||||
|
tz_hour = +(match[10]);
|
||||||
|
tz_minute = +(match[11] || 0);
|
||||||
|
delta = (tz_hour * 60 + tz_minute) * 60000; // delta in mili-seconds
|
||||||
|
if ('-' === match[9]) {
|
||||||
|
delta = -delta;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
|
||||||
|
|
||||||
|
if (delta) {
|
||||||
|
date.setTime(date.getTime() - delta);
|
||||||
|
}
|
||||||
|
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
|
||||||
|
function representYamlTimestamp(object /*, style*/) {
|
||||||
|
return object.toISOString();
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = new Type('tag:yaml.org,2002:timestamp', {
|
||||||
|
kind: 'scalar',
|
||||||
|
resolve: resolveYamlTimestamp,
|
||||||
|
construct: constructYamlTimestamp,
|
||||||
|
instanceOf: Date,
|
||||||
|
represent: representYamlTimestamp
|
||||||
|
});
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user