Add node modules and compiled JavaScript from main
This commit is contained in:
parent
8bccaeaf7c
commit
4181bfdf50
7465 changed files with 1775003 additions and 2 deletions
21
node_modules/snapdragon/LICENSE
generated
vendored
Normal file
21
node_modules/snapdragon/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015-2016, Jon Schlinkert.
|
||||
|
||||
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.
|
321
node_modules/snapdragon/README.md
generated
vendored
Normal file
321
node_modules/snapdragon/README.md
generated
vendored
Normal file
|
@ -0,0 +1,321 @@
|
|||
# snapdragon [](https://www.npmjs.com/package/snapdragon) [](https://npmjs.org/package/snapdragon) [](https://travis-ci.org/jonschlinkert/snapdragon)
|
||||
|
||||
> Fast, pluggable and easy-to-use parser-renderer factory.
|
||||
|
||||
## Install
|
||||
|
||||
Install with [npm](https://www.npmjs.com/):
|
||||
|
||||
```sh
|
||||
$ npm install --save snapdragon
|
||||
```
|
||||
|
||||
Created by [jonschlinkert](https://github.com/jonschlinkert) and [doowb](https://github.com/doowb).
|
||||
|
||||
**Features**
|
||||
|
||||
* Bootstrap your own parser, get sourcemap support for free
|
||||
* All parsing and compiling is handled by simple, reusable middleware functions
|
||||
* Inspired by the parsers in [pug](http://jade-lang.com) and [css](https://github.com/reworkcss/css).
|
||||
|
||||
## History
|
||||
|
||||
### v0.5.0
|
||||
|
||||
**Breaking changes**
|
||||
|
||||
Substantial breaking changes were made in v0.5.0! Most of these changes are part of a larger refactor that will be finished in 0.6.0, including the introduction of a `Lexer` class.
|
||||
|
||||
* Renderer was renamed to `Compiler`
|
||||
* the `.render` method was renamed to `.compile`
|
||||
* Many other smaller changes. A more detailed overview will be provided in 0.6.0. If you don't have to time review code, I recommend you wait for the 0.6.0 release.
|
||||
|
||||
## Usage examples
|
||||
|
||||
```js
|
||||
var Snapdragon = require('snapdragon');
|
||||
var snapdragon = new Snapdragon();
|
||||
```
|
||||
|
||||
**Parse**
|
||||
|
||||
```js
|
||||
var ast = snapdragon.parser('some string', options)
|
||||
// parser middleware that can be called by other middleware
|
||||
.set('foo', function () {})
|
||||
// parser middleware, runs immediately in the order defined
|
||||
.use(bar())
|
||||
.use(baz())
|
||||
```
|
||||
|
||||
**Render**
|
||||
|
||||
```js
|
||||
// pass the `ast` from the parse method
|
||||
var res = snapdragon.compiler(ast)
|
||||
// compiler middleware, called when the name of the middleware
|
||||
// matches the `node.type` (defined in a parser middleware)
|
||||
.set('bar', function () {})
|
||||
.set('baz', function () {})
|
||||
.compile()
|
||||
```
|
||||
|
||||
See the [examples](./examples/).
|
||||
|
||||
## Getting started
|
||||
|
||||
**Parsers**
|
||||
|
||||
Parsers are middleware functions used for parsing a string into an ast node.
|
||||
|
||||
```js
|
||||
var ast = snapdragon.parser(str, options)
|
||||
.use(function() {
|
||||
var pos = this.position();
|
||||
var m = this.match(/^\./);
|
||||
if (!m) return;
|
||||
return pos({
|
||||
// `type` specifies the compiler to use
|
||||
type: 'dot',
|
||||
val: m[0]
|
||||
});
|
||||
})
|
||||
```
|
||||
|
||||
**AST node**
|
||||
|
||||
When the parser finds a match, `pos()` is called, pushing a token for that node onto the ast that looks something like:
|
||||
|
||||
```js
|
||||
{ type: 'dot',
|
||||
val: '.',
|
||||
position:
|
||||
{ start: { lineno: 1, column: 1 },
|
||||
end: { lineno: 1, column: 2 } }}
|
||||
```
|
||||
|
||||
**Renderers**
|
||||
|
||||
Renderers are _named_ middleware functions that visit over an array of ast nodes to compile a string.
|
||||
|
||||
```js
|
||||
var res = snapdragon.compiler(ast)
|
||||
.set('dot', function (node) {
|
||||
console.log(node.val)
|
||||
//=> '.'
|
||||
return this.emit(node.val);
|
||||
})
|
||||
```
|
||||
|
||||
**Source maps**
|
||||
|
||||
If you want source map support, make sure to emit the position as well.
|
||||
|
||||
```js
|
||||
var res = snapdragon.compiler(ast)
|
||||
.set('dot', function (node) {
|
||||
return this.emit(node.val, node.position);
|
||||
})
|
||||
```
|
||||
|
||||
## Docs
|
||||
|
||||
### Parser middleware
|
||||
|
||||
A parser middleware is a function that returns an abject called a `token`. This token is pushed onto the AST as a node.
|
||||
|
||||
**Example token**
|
||||
|
||||
```js
|
||||
{ type: 'dot',
|
||||
val: '.',
|
||||
position:
|
||||
{ start: { lineno: 1, column: 1 },
|
||||
end: { lineno: 1, column: 2 } }}
|
||||
```
|
||||
|
||||
**Example parser middleware**
|
||||
|
||||
Match a single `.` in a string:
|
||||
|
||||
1. Get the starting position by calling `this.position()`
|
||||
2. pass a regex for matching a single dot to the `.match` method
|
||||
3. if **no match** is found, return `undefined`
|
||||
4. if a **match** is found, `pos()` is called, which returns a token with:
|
||||
- `type`: the name of the [compiler] to use
|
||||
- `val`: The actual value captured by the regex. In this case, a `.`. Note that you can capture and return whatever will be needed by the corresponding [compiler].
|
||||
- The ending position: automatically calculated by adding the length of the first capture group to the starting position.
|
||||
|
||||
## Renderer middleware
|
||||
|
||||
Renderers are run when the name of the compiler middleware matches the `type` defined on an ast `node` (which is defined in a parser).
|
||||
|
||||
**Example**
|
||||
|
||||
Exercise: Parse a dot, then compile it as an escaped dot.
|
||||
|
||||
```js
|
||||
var ast = snapdragon.parser('.')
|
||||
.use(function () {
|
||||
var pos = this.position();
|
||||
var m = this.match(/^\./);
|
||||
if (!m) return;
|
||||
return pos({
|
||||
// define the `type` of compiler to use
|
||||
type: 'dot',
|
||||
val: m[0]
|
||||
})
|
||||
})
|
||||
|
||||
var result = snapdragon.compiler(ast)
|
||||
.set('dot', function (node) {
|
||||
return this.emit('\\' + node.val);
|
||||
})
|
||||
.compile()
|
||||
|
||||
console.log(result.output);
|
||||
//=> '\.'
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### [Parser](lib/parser.js#L19)
|
||||
|
||||
Create a new `Parser` with the given `input` and `options`.
|
||||
|
||||
**Params**
|
||||
|
||||
* `input` **{String}**
|
||||
* `options` **{Object}**
|
||||
|
||||
### [.define](lib/parser.js#L103)
|
||||
|
||||
Define a non-enumberable property on the `Parser` instance.
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
parser.define('foo', 'bar');
|
||||
```
|
||||
|
||||
**Params**
|
||||
|
||||
* `key` **{String}**: propery name
|
||||
* `val` **{any}**: property value
|
||||
* `returns` **{Object}**: Returns the Parser instance for chaining.
|
||||
|
||||
Set parser `name` with the given `fn`
|
||||
|
||||
**Params**
|
||||
|
||||
* `name` **{String}**
|
||||
* `fn` **{Function}**
|
||||
|
||||
Get parser `name`
|
||||
|
||||
**Params**
|
||||
|
||||
* `name` **{String}**
|
||||
|
||||
Push a `token` onto the `type` stack.
|
||||
|
||||
**Params**
|
||||
|
||||
* `type` **{String}**
|
||||
* `returns` **{Object}** `token`
|
||||
|
||||
Pop a token off of the `type` stack
|
||||
|
||||
**Params**
|
||||
|
||||
* `type` **{String}**
|
||||
* `returns` **{Object}**: Returns a token
|
||||
|
||||
Return true if inside a `stack` node. Types are `braces`, `parens` or `brackets`.
|
||||
|
||||
**Params**
|
||||
|
||||
* `type` **{String}**
|
||||
* `returns` **{Boolean}**
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
parser.isType(node, 'brace');
|
||||
```
|
||||
|
||||
**Params**
|
||||
|
||||
* `node` **{Object}**
|
||||
* `type` **{String}**
|
||||
* `returns` **{Boolean}**
|
||||
|
||||
### [.define](lib/compiler.js#L71)
|
||||
|
||||
Define a non-enumberable property on the `Compiler` instance.
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
compiler.define('foo', 'bar');
|
||||
```
|
||||
|
||||
**Params**
|
||||
|
||||
* `key` **{String}**: propery name
|
||||
* `val` **{any}**: property value
|
||||
* `returns` **{Object}**: Returns the Compiler instance for chaining.
|
||||
|
||||
## About
|
||||
|
||||
### Related projects
|
||||
|
||||
* [braces](https://www.npmjs.com/package/braces): Fastest brace expansion for node.js, with the most complete support for the Bash 4.3 braces… [more](https://github.com/jonschlinkert/braces) | [homepage](https://github.com/jonschlinkert/braces "Fastest brace expansion for node.js, with the most complete support for the Bash 4.3 braces specification.")
|
||||
* [expand-brackets](https://www.npmjs.com/package/expand-brackets): Expand POSIX bracket expressions (character classes) in glob patterns. | [homepage](https://github.com/jonschlinkert/expand-brackets "Expand POSIX bracket expressions (character classes) in glob patterns.")
|
||||
* [extglob](https://www.npmjs.com/package/extglob): Convert extended globs to regex-compatible strings. Add (almost) the expressive power of regular expressions to… [more](https://github.com/jonschlinkert/extglob) | [homepage](https://github.com/jonschlinkert/extglob "Convert extended globs to regex-compatible strings. Add (almost) the expressive power of regular expressions to glob patterns.")
|
||||
* [micromatch](https://www.npmjs.com/package/micromatch): Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch. | [homepage](https://github.com/jonschlinkert/micromatch "Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch.")
|
||||
|
||||
### Contributing
|
||||
|
||||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
|
||||
|
||||
### Contributors
|
||||
|
||||
| **Commits** | **Contributor**<br/> |
|
||||
| --- | --- |
|
||||
| 106 | [jonschlinkert](https://github.com/jonschlinkert) |
|
||||
| 2 | [doowb](https://github.com/doowb) |
|
||||
|
||||
### Building docs
|
||||
|
||||
_(This document was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme) (a [verb](https://github.com/verbose/verb) generator), please don't edit the readme directly. Any changes to the readme must be made in [.verb.md](.verb.md).)_
|
||||
|
||||
To generate the readme and API documentation with [verb](https://github.com/verbose/verb):
|
||||
|
||||
```sh
|
||||
$ npm install -g verb verb-generate-readme && verb
|
||||
```
|
||||
|
||||
### Running tests
|
||||
|
||||
Install dev dependencies:
|
||||
|
||||
```sh
|
||||
$ npm install -d && npm test
|
||||
```
|
||||
|
||||
### Author
|
||||
|
||||
**Jon Schlinkert**
|
||||
|
||||
* [github/jonschlinkert](https://github.com/jonschlinkert)
|
||||
* [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
|
||||
|
||||
### License
|
||||
|
||||
Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert).
|
||||
Released under the [MIT license](https://github.com/jonschlinkert/snapdragon/blob/master/LICENSE).
|
||||
|
||||
***
|
||||
|
||||
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.1.31, on October 10, 2016._
|
174
node_modules/snapdragon/index.js
generated
vendored
Normal file
174
node_modules/snapdragon/index.js
generated
vendored
Normal file
|
@ -0,0 +1,174 @@
|
|||
'use strict';
|
||||
|
||||
var Base = require('base');
|
||||
var define = require('define-property');
|
||||
var Compiler = require('./lib/compiler');
|
||||
var Parser = require('./lib/parser');
|
||||
var utils = require('./lib/utils');
|
||||
var regexCache = {};
|
||||
var cache = {};
|
||||
|
||||
/**
|
||||
* Create a new instance of `Snapdragon` with the given `options`.
|
||||
*
|
||||
* ```js
|
||||
* var snapdragon = new Snapdragon();
|
||||
* ```
|
||||
*
|
||||
* @param {Object} `options`
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function Snapdragon(options) {
|
||||
Base.call(this, null, options);
|
||||
this.options = utils.extend({source: 'string'}, this.options);
|
||||
this.compiler = new Compiler(this.options);
|
||||
this.parser = new Parser(this.options);
|
||||
|
||||
Object.defineProperty(this, 'compilers', {
|
||||
get: function() {
|
||||
return this.compiler.compilers;
|
||||
}
|
||||
});
|
||||
|
||||
Object.defineProperty(this, 'parsers', {
|
||||
get: function() {
|
||||
return this.parser.parsers;
|
||||
}
|
||||
});
|
||||
|
||||
Object.defineProperty(this, 'regex', {
|
||||
get: function() {
|
||||
return this.parser.regex;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Inherit Base
|
||||
*/
|
||||
|
||||
Base.extend(Snapdragon);
|
||||
|
||||
/**
|
||||
* Add a parser to `snapdragon.parsers` for capturing the given `type` using
|
||||
* the specified regex or parser function. A function is useful if you need
|
||||
* to customize how the token is created and/or have access to the parser
|
||||
* instance to check options, etc.
|
||||
*
|
||||
* ```js
|
||||
* snapdragon
|
||||
* .capture('slash', /^\//)
|
||||
* .capture('dot', function() {
|
||||
* var pos = this.position();
|
||||
* var m = this.match(/^\./);
|
||||
* if (!m) return;
|
||||
* return pos({
|
||||
* type: 'dot',
|
||||
* val: m[0]
|
||||
* });
|
||||
* });
|
||||
* ```
|
||||
* @param {String} `type`
|
||||
* @param {RegExp|Function} `regex`
|
||||
* @return {Object} Returns the parser instance for chaining
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Snapdragon.prototype.capture = function() {
|
||||
return this.parser.capture.apply(this.parser, arguments);
|
||||
};
|
||||
|
||||
/**
|
||||
* Register a plugin `fn`.
|
||||
*
|
||||
* ```js
|
||||
* var snapdragon = new Snapdgragon([options]);
|
||||
* snapdragon.use(function() {
|
||||
* console.log(this); //<= snapdragon instance
|
||||
* console.log(this.parser); //<= parser instance
|
||||
* console.log(this.compiler); //<= compiler instance
|
||||
* });
|
||||
* ```
|
||||
* @param {Object} `fn`
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Snapdragon.prototype.use = function(fn) {
|
||||
fn.call(this, this);
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Parse the given `str`.
|
||||
*
|
||||
* ```js
|
||||
* var snapdragon = new Snapdgragon([options]);
|
||||
* // register parsers
|
||||
* snapdragon.parser.use(function() {});
|
||||
*
|
||||
* // parse
|
||||
* var ast = snapdragon.parse('foo/bar');
|
||||
* console.log(ast);
|
||||
* ```
|
||||
* @param {String} `str`
|
||||
* @param {Object} `options` Set `options.sourcemap` to true to enable source maps.
|
||||
* @return {Object} Returns an AST.
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Snapdragon.prototype.parse = function(str, options) {
|
||||
this.options = utils.extend({}, this.options, options);
|
||||
var parsed = this.parser.parse(str, this.options);
|
||||
|
||||
// add non-enumerable parser reference
|
||||
define(parsed, 'parser', this.parser);
|
||||
return parsed;
|
||||
};
|
||||
|
||||
/**
|
||||
* Compile the given `AST`.
|
||||
*
|
||||
* ```js
|
||||
* var snapdragon = new Snapdgragon([options]);
|
||||
* // register plugins
|
||||
* snapdragon.use(function() {});
|
||||
* // register parser plugins
|
||||
* snapdragon.parser.use(function() {});
|
||||
* // register compiler plugins
|
||||
* snapdragon.compiler.use(function() {});
|
||||
*
|
||||
* // parse
|
||||
* var ast = snapdragon.parse('foo/bar');
|
||||
*
|
||||
* // compile
|
||||
* var res = snapdragon.compile(ast);
|
||||
* console.log(res.output);
|
||||
* ```
|
||||
* @param {Object} `ast`
|
||||
* @param {Object} `options`
|
||||
* @return {Object} Returns an object with an `output` property with the rendered string.
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Snapdragon.prototype.compile = function(ast, options) {
|
||||
this.options = utils.extend({}, this.options, options);
|
||||
var compiled = this.compiler.compile(ast, this.options);
|
||||
|
||||
// add non-enumerable compiler reference
|
||||
define(compiled, 'compiler', this.compiler);
|
||||
return compiled;
|
||||
};
|
||||
|
||||
/**
|
||||
* Expose `Snapdragon`
|
||||
*/
|
||||
|
||||
module.exports = Snapdragon;
|
||||
|
||||
/**
|
||||
* Expose `Parser` and `Compiler`
|
||||
*/
|
||||
|
||||
module.exports.Compiler = Compiler;
|
||||
module.exports.Parser = Parser;
|
177
node_modules/snapdragon/lib/compiler.js
generated
vendored
Normal file
177
node_modules/snapdragon/lib/compiler.js
generated
vendored
Normal file
|
@ -0,0 +1,177 @@
|
|||
'use strict';
|
||||
|
||||
var use = require('use');
|
||||
var define = require('define-property');
|
||||
var debug = require('debug')('snapdragon:compiler');
|
||||
var utils = require('./utils');
|
||||
|
||||
/**
|
||||
* Create a new `Compiler` with the given `options`.
|
||||
* @param {Object} `options`
|
||||
*/
|
||||
|
||||
function Compiler(options, state) {
|
||||
debug('initializing', __filename);
|
||||
this.options = utils.extend({source: 'string'}, options);
|
||||
this.state = state || {};
|
||||
this.compilers = {};
|
||||
this.output = '';
|
||||
this.set('eos', function(node) {
|
||||
return this.emit(node.val, node);
|
||||
});
|
||||
this.set('noop', function(node) {
|
||||
return this.emit(node.val, node);
|
||||
});
|
||||
this.set('bos', function(node) {
|
||||
return this.emit(node.val, node);
|
||||
});
|
||||
use(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prototype methods
|
||||
*/
|
||||
|
||||
Compiler.prototype = {
|
||||
|
||||
/**
|
||||
* Throw an error message with details including the cursor position.
|
||||
* @param {String} `msg` Message to use in the Error.
|
||||
*/
|
||||
|
||||
error: function(msg, node) {
|
||||
var pos = node.position || {start: {column: 0}};
|
||||
var message = this.options.source + ' column:' + pos.start.column + ': ' + msg;
|
||||
|
||||
var err = new Error(message);
|
||||
err.reason = msg;
|
||||
err.column = pos.start.column;
|
||||
err.source = this.pattern;
|
||||
|
||||
if (this.options.silent) {
|
||||
this.errors.push(err);
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Define a non-enumberable property on the `Compiler` instance.
|
||||
*
|
||||
* ```js
|
||||
* compiler.define('foo', 'bar');
|
||||
* ```
|
||||
* @name .define
|
||||
* @param {String} `key` propery name
|
||||
* @param {any} `val` property value
|
||||
* @return {Object} Returns the Compiler instance for chaining.
|
||||
* @api public
|
||||
*/
|
||||
|
||||
define: function(key, val) {
|
||||
define(this, key, val);
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Emit `node.val`
|
||||
*/
|
||||
|
||||
emit: function(str, node) {
|
||||
this.output += str;
|
||||
return str;
|
||||
},
|
||||
|
||||
/**
|
||||
* Add a compiler `fn` with the given `name`
|
||||
*/
|
||||
|
||||
set: function(name, fn) {
|
||||
this.compilers[name] = fn;
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Get compiler `name`.
|
||||
*/
|
||||
|
||||
get: function(name) {
|
||||
return this.compilers[name];
|
||||
},
|
||||
|
||||
/**
|
||||
* Get the previous AST node.
|
||||
*/
|
||||
|
||||
prev: function(n) {
|
||||
return this.ast.nodes[this.idx - (n || 1)] || { type: 'bos', val: '' };
|
||||
},
|
||||
|
||||
/**
|
||||
* Get the next AST node.
|
||||
*/
|
||||
|
||||
next: function(n) {
|
||||
return this.ast.nodes[this.idx + (n || 1)] || { type: 'eos', val: '' };
|
||||
},
|
||||
|
||||
/**
|
||||
* Visit `node`.
|
||||
*/
|
||||
|
||||
visit: function(node, nodes, i) {
|
||||
var fn = this.compilers[node.type];
|
||||
this.idx = i;
|
||||
|
||||
if (typeof fn !== 'function') {
|
||||
throw this.error('compiler "' + node.type + '" is not registered', node);
|
||||
}
|
||||
return fn.call(this, node, nodes, i);
|
||||
},
|
||||
|
||||
/**
|
||||
* Map visit over array of `nodes`.
|
||||
*/
|
||||
|
||||
mapVisit: function(nodes) {
|
||||
if (!Array.isArray(nodes)) {
|
||||
throw new TypeError('expected an array');
|
||||
}
|
||||
var len = nodes.length;
|
||||
var idx = -1;
|
||||
while (++idx < len) {
|
||||
this.visit(nodes[idx], nodes, idx);
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Compile `ast`.
|
||||
*/
|
||||
|
||||
compile: function(ast, options) {
|
||||
var opts = utils.extend({}, this.options, options);
|
||||
this.ast = ast;
|
||||
this.parsingErrors = this.ast.errors;
|
||||
this.output = '';
|
||||
|
||||
// source map support
|
||||
if (opts.sourcemap) {
|
||||
var sourcemaps = require('./source-maps');
|
||||
sourcemaps(this);
|
||||
this.mapVisit(this.ast.nodes);
|
||||
this.applySourceMaps();
|
||||
this.map = opts.sourcemap === 'generator' ? this.map : this.map.toJSON();
|
||||
return this;
|
||||
}
|
||||
|
||||
this.mapVisit(this.ast.nodes);
|
||||
return this;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Expose `Compiler`
|
||||
*/
|
||||
|
||||
module.exports = Compiler;
|
533
node_modules/snapdragon/lib/parser.js
generated
vendored
Normal file
533
node_modules/snapdragon/lib/parser.js
generated
vendored
Normal file
|
@ -0,0 +1,533 @@
|
|||
'use strict';
|
||||
|
||||
var use = require('use');
|
||||
var util = require('util');
|
||||
var Cache = require('map-cache');
|
||||
var define = require('define-property');
|
||||
var debug = require('debug')('snapdragon:parser');
|
||||
var Position = require('./position');
|
||||
var utils = require('./utils');
|
||||
|
||||
/**
|
||||
* Create a new `Parser` with the given `input` and `options`.
|
||||
* @param {String} `input`
|
||||
* @param {Object} `options`
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function Parser(options) {
|
||||
debug('initializing', __filename);
|
||||
this.options = utils.extend({source: 'string'}, options);
|
||||
this.init(this.options);
|
||||
use(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prototype methods
|
||||
*/
|
||||
|
||||
Parser.prototype = {
|
||||
constructor: Parser,
|
||||
|
||||
init: function(options) {
|
||||
this.orig = '';
|
||||
this.input = '';
|
||||
this.parsed = '';
|
||||
|
||||
this.column = 1;
|
||||
this.line = 1;
|
||||
|
||||
this.regex = new Cache();
|
||||
this.errors = this.errors || [];
|
||||
this.parsers = this.parsers || {};
|
||||
this.types = this.types || [];
|
||||
this.sets = this.sets || {};
|
||||
this.fns = this.fns || [];
|
||||
this.currentType = 'root';
|
||||
|
||||
var pos = this.position();
|
||||
this.bos = pos({type: 'bos', val: ''});
|
||||
|
||||
this.ast = {
|
||||
type: 'root',
|
||||
errors: this.errors,
|
||||
nodes: [this.bos]
|
||||
};
|
||||
|
||||
define(this.bos, 'parent', this.ast);
|
||||
this.nodes = [this.ast];
|
||||
|
||||
this.count = 0;
|
||||
this.setCount = 0;
|
||||
this.stack = [];
|
||||
},
|
||||
|
||||
/**
|
||||
* Throw a formatted error with the cursor column and `msg`.
|
||||
* @param {String} `msg` Message to use in the Error.
|
||||
*/
|
||||
|
||||
error: function(msg, node) {
|
||||
var pos = node.position || {start: {column: 0, line: 0}};
|
||||
var line = pos.start.line;
|
||||
var column = pos.start.column;
|
||||
var source = this.options.source;
|
||||
|
||||
var message = source + ' <line:' + line + ' column:' + column + '>: ' + msg;
|
||||
var err = new Error(message);
|
||||
err.source = source;
|
||||
err.reason = msg;
|
||||
err.pos = pos;
|
||||
|
||||
if (this.options.silent) {
|
||||
this.errors.push(err);
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Define a non-enumberable property on the `Parser` instance.
|
||||
*
|
||||
* ```js
|
||||
* parser.define('foo', 'bar');
|
||||
* ```
|
||||
* @name .define
|
||||
* @param {String} `key` propery name
|
||||
* @param {any} `val` property value
|
||||
* @return {Object} Returns the Parser instance for chaining.
|
||||
* @api public
|
||||
*/
|
||||
|
||||
define: function(key, val) {
|
||||
define(this, key, val);
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Mark position and patch `node.position`.
|
||||
*/
|
||||
|
||||
position: function() {
|
||||
var start = { line: this.line, column: this.column };
|
||||
var self = this;
|
||||
|
||||
return function(node) {
|
||||
define(node, 'position', new Position(start, self));
|
||||
return node;
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Set parser `name` with the given `fn`
|
||||
* @param {String} `name`
|
||||
* @param {Function} `fn`
|
||||
* @api public
|
||||
*/
|
||||
|
||||
set: function(type, fn) {
|
||||
if (this.types.indexOf(type) === -1) {
|
||||
this.types.push(type);
|
||||
}
|
||||
this.parsers[type] = fn.bind(this);
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Get parser `name`
|
||||
* @param {String} `name`
|
||||
* @api public
|
||||
*/
|
||||
|
||||
get: function(name) {
|
||||
return this.parsers[name];
|
||||
},
|
||||
|
||||
/**
|
||||
* Push a `token` onto the `type` stack.
|
||||
*
|
||||
* @param {String} `type`
|
||||
* @return {Object} `token`
|
||||
* @api public
|
||||
*/
|
||||
|
||||
push: function(type, token) {
|
||||
this.sets[type] = this.sets[type] || [];
|
||||
this.count++;
|
||||
this.stack.push(token);
|
||||
return this.sets[type].push(token);
|
||||
},
|
||||
|
||||
/**
|
||||
* Pop a token off of the `type` stack
|
||||
* @param {String} `type`
|
||||
* @returns {Object} Returns a token
|
||||
* @api public
|
||||
*/
|
||||
|
||||
pop: function(type) {
|
||||
this.sets[type] = this.sets[type] || [];
|
||||
this.count--;
|
||||
this.stack.pop();
|
||||
return this.sets[type].pop();
|
||||
},
|
||||
|
||||
/**
|
||||
* Return true if inside a `stack` node. Types are `braces`, `parens` or `brackets`.
|
||||
*
|
||||
* @param {String} `type`
|
||||
* @return {Boolean}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
isInside: function(type) {
|
||||
this.sets[type] = this.sets[type] || [];
|
||||
return this.sets[type].length > 0;
|
||||
},
|
||||
|
||||
/**
|
||||
* Return true if `node` is the given `type`.
|
||||
*
|
||||
* ```js
|
||||
* parser.isType(node, 'brace');
|
||||
* ```
|
||||
* @param {Object} `node`
|
||||
* @param {String} `type`
|
||||
* @return {Boolean}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
isType: function(node, type) {
|
||||
return node && node.type === type;
|
||||
},
|
||||
|
||||
/**
|
||||
* Get the previous AST node
|
||||
* @return {Object}
|
||||
*/
|
||||
|
||||
prev: function(n) {
|
||||
return this.stack.length > 0
|
||||
? utils.last(this.stack, n)
|
||||
: utils.last(this.nodes, n);
|
||||
},
|
||||
|
||||
/**
|
||||
* Update line and column based on `str`.
|
||||
*/
|
||||
|
||||
consume: function(len) {
|
||||
this.input = this.input.substr(len);
|
||||
},
|
||||
|
||||
/**
|
||||
* Update column based on `str`.
|
||||
*/
|
||||
|
||||
updatePosition: function(str, len) {
|
||||
var lines = str.match(/\n/g);
|
||||
if (lines) this.line += lines.length;
|
||||
var i = str.lastIndexOf('\n');
|
||||
this.column = ~i ? len - i : this.column + len;
|
||||
this.parsed += str;
|
||||
this.consume(len);
|
||||
},
|
||||
|
||||
/**
|
||||
* Match `regex`, return captures, and update the cursor position by `match[0]` length.
|
||||
* @param {RegExp} `regex`
|
||||
* @return {Object}
|
||||
*/
|
||||
|
||||
match: function(regex) {
|
||||
var m = regex.exec(this.input);
|
||||
if (m) {
|
||||
this.updatePosition(m[0], m[0].length);
|
||||
return m;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Capture `type` with the given regex.
|
||||
* @param {String} `type`
|
||||
* @param {RegExp} `regex`
|
||||
* @return {Function}
|
||||
*/
|
||||
|
||||
capture: function(type, regex) {
|
||||
if (typeof regex === 'function') {
|
||||
return this.set.apply(this, arguments);
|
||||
}
|
||||
|
||||
this.regex.set(type, regex);
|
||||
this.set(type, function() {
|
||||
var parsed = this.parsed;
|
||||
var pos = this.position();
|
||||
var m = this.match(regex);
|
||||
if (!m || !m[0]) return;
|
||||
|
||||
var prev = this.prev();
|
||||
var node = pos({
|
||||
type: type,
|
||||
val: m[0],
|
||||
parsed: parsed,
|
||||
rest: this.input
|
||||
});
|
||||
|
||||
if (m[1]) {
|
||||
node.inner = m[1];
|
||||
}
|
||||
|
||||
define(node, 'inside', this.stack.length > 0);
|
||||
define(node, 'parent', prev);
|
||||
prev.nodes.push(node);
|
||||
}.bind(this));
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Create a parser with open and close for parens,
|
||||
* brackets or braces
|
||||
*/
|
||||
|
||||
capturePair: function(type, openRegex, closeRegex, fn) {
|
||||
this.sets[type] = this.sets[type] || [];
|
||||
|
||||
/**
|
||||
* Open
|
||||
*/
|
||||
|
||||
this.set(type + '.open', function() {
|
||||
var parsed = this.parsed;
|
||||
var pos = this.position();
|
||||
var m = this.match(openRegex);
|
||||
if (!m || !m[0]) return;
|
||||
|
||||
var val = m[0];
|
||||
this.setCount++;
|
||||
this.specialChars = true;
|
||||
var open = pos({
|
||||
type: type + '.open',
|
||||
val: val,
|
||||
rest: this.input
|
||||
});
|
||||
|
||||
if (typeof m[1] !== 'undefined') {
|
||||
open.inner = m[1];
|
||||
}
|
||||
|
||||
var prev = this.prev();
|
||||
var node = pos({
|
||||
type: type,
|
||||
nodes: [open]
|
||||
});
|
||||
|
||||
define(node, 'rest', this.input);
|
||||
define(node, 'parsed', parsed);
|
||||
define(node, 'prefix', m[1]);
|
||||
define(node, 'parent', prev);
|
||||
define(open, 'parent', node);
|
||||
|
||||
if (typeof fn === 'function') {
|
||||
fn.call(this, open, node);
|
||||
}
|
||||
|
||||
this.push(type, node);
|
||||
prev.nodes.push(node);
|
||||
});
|
||||
|
||||
/**
|
||||
* Close
|
||||
*/
|
||||
|
||||
this.set(type + '.close', function() {
|
||||
var pos = this.position();
|
||||
var m = this.match(closeRegex);
|
||||
if (!m || !m[0]) return;
|
||||
|
||||
var parent = this.pop(type);
|
||||
var node = pos({
|
||||
type: type + '.close',
|
||||
rest: this.input,
|
||||
suffix: m[1],
|
||||
val: m[0]
|
||||
});
|
||||
|
||||
if (!this.isType(parent, type)) {
|
||||
if (this.options.strict) {
|
||||
throw new Error('missing opening "' + type + '"');
|
||||
}
|
||||
|
||||
this.setCount--;
|
||||
node.escaped = true;
|
||||
return node;
|
||||
}
|
||||
|
||||
if (node.suffix === '\\') {
|
||||
parent.escaped = true;
|
||||
node.escaped = true;
|
||||
}
|
||||
|
||||
parent.nodes.push(node);
|
||||
define(node, 'parent', parent);
|
||||
});
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Capture end-of-string
|
||||
*/
|
||||
|
||||
eos: function() {
|
||||
var pos = this.position();
|
||||
if (this.input) return;
|
||||
var prev = this.prev();
|
||||
|
||||
while (prev.type !== 'root' && !prev.visited) {
|
||||
if (this.options.strict === true) {
|
||||
throw new SyntaxError('invalid syntax:' + util.inspect(prev, null, 2));
|
||||
}
|
||||
|
||||
if (!hasDelims(prev)) {
|
||||
prev.parent.escaped = true;
|
||||
prev.escaped = true;
|
||||
}
|
||||
|
||||
visit(prev, function(node) {
|
||||
if (!hasDelims(node.parent)) {
|
||||
node.parent.escaped = true;
|
||||
node.escaped = true;
|
||||
}
|
||||
});
|
||||
|
||||
prev = prev.parent;
|
||||
}
|
||||
|
||||
var tok = pos({
|
||||
type: 'eos',
|
||||
val: this.append || ''
|
||||
});
|
||||
|
||||
define(tok, 'parent', this.ast);
|
||||
return tok;
|
||||
},
|
||||
|
||||
/**
|
||||
* Run parsers to advance the cursor position
|
||||
*/
|
||||
|
||||
next: function() {
|
||||
var parsed = this.parsed;
|
||||
var len = this.types.length;
|
||||
var idx = -1;
|
||||
var tok;
|
||||
|
||||
while (++idx < len) {
|
||||
if ((tok = this.parsers[this.types[idx]].call(this))) {
|
||||
define(tok, 'rest', this.input);
|
||||
define(tok, 'parsed', parsed);
|
||||
this.last = tok;
|
||||
return tok;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Parse the given string.
|
||||
* @return {Array}
|
||||
*/
|
||||
|
||||
parse: function(input) {
|
||||
if (typeof input !== 'string') {
|
||||
throw new TypeError('expected a string');
|
||||
}
|
||||
|
||||
this.init(this.options);
|
||||
this.orig = input;
|
||||
this.input = input;
|
||||
var self = this;
|
||||
|
||||
function parse() {
|
||||
// check input before calling `.next()`
|
||||
input = self.input;
|
||||
|
||||
// get the next AST ndoe
|
||||
var node = self.next();
|
||||
if (node) {
|
||||
var prev = self.prev();
|
||||
if (prev) {
|
||||
define(node, 'parent', prev);
|
||||
if (prev.nodes) {
|
||||
prev.nodes.push(node);
|
||||
}
|
||||
}
|
||||
|
||||
if (self.sets.hasOwnProperty(prev.type)) {
|
||||
self.currentType = prev.type;
|
||||
}
|
||||
}
|
||||
|
||||
// if we got here but input is not changed, throw an error
|
||||
if (self.input && input === self.input) {
|
||||
throw new Error('no parsers registered for: "' + self.input.slice(0, 5) + '"');
|
||||
}
|
||||
}
|
||||
|
||||
while (this.input) parse();
|
||||
if (this.stack.length && this.options.strict) {
|
||||
var node = this.stack.pop();
|
||||
throw this.error('missing opening ' + node.type + ': "' + this.orig + '"');
|
||||
}
|
||||
|
||||
var eos = this.eos();
|
||||
var tok = this.prev();
|
||||
if (tok.type !== 'eos') {
|
||||
this.ast.nodes.push(eos);
|
||||
}
|
||||
|
||||
return this.ast;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Visit `node` with the given `fn`
|
||||
*/
|
||||
|
||||
function visit(node, fn) {
|
||||
if (!node.visited) {
|
||||
define(node, 'visited', true);
|
||||
return node.nodes ? mapVisit(node.nodes, fn) : fn(node);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Map visit over array of `nodes`.
|
||||
*/
|
||||
|
||||
function mapVisit(nodes, fn) {
|
||||
var len = nodes.length;
|
||||
var idx = -1;
|
||||
while (++idx < len) {
|
||||
visit(nodes[idx], fn);
|
||||
}
|
||||
}
|
||||
|
||||
function hasOpen(node) {
|
||||
return node.nodes && node.nodes[0].type === (node.type + '.open');
|
||||
}
|
||||
|
||||
function hasClose(node) {
|
||||
return node.nodes && utils.last(node.nodes).type === (node.type + '.close');
|
||||
}
|
||||
|
||||
function hasDelims(node) {
|
||||
return hasOpen(node) && hasClose(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Expose `Parser`
|
||||
*/
|
||||
|
||||
module.exports = Parser;
|
14
node_modules/snapdragon/lib/position.js
generated
vendored
Normal file
14
node_modules/snapdragon/lib/position.js
generated
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
'use strict';
|
||||
|
||||
var define = require('define-property');
|
||||
|
||||
/**
|
||||
* Store position for a node
|
||||
*/
|
||||
|
||||
module.exports = function Position(start, parser) {
|
||||
this.start = start;
|
||||
this.end = { line: parser.line, column: parser.column };
|
||||
define(this, 'content', parser.orig);
|
||||
define(this, 'source', parser.options.source);
|
||||
};
|
145
node_modules/snapdragon/lib/source-maps.js
generated
vendored
Normal file
145
node_modules/snapdragon/lib/source-maps.js
generated
vendored
Normal file
|
@ -0,0 +1,145 @@
|
|||
'use strict';
|
||||
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var define = require('define-property');
|
||||
var utils = require('./utils');
|
||||
|
||||
/**
|
||||
* Expose `mixin()`.
|
||||
* This code is based on `source-maps-support.js` in reworkcss/css
|
||||
* https://github.com/reworkcss/css/blob/master/lib/stringify/source-map-support.js
|
||||
* Copyright (c) 2012 TJ Holowaychuk <tj@vision-media.ca>
|
||||
*/
|
||||
|
||||
module.exports = mixin;
|
||||
|
||||
/**
|
||||
* Mixin source map support into `compiler`.
|
||||
*
|
||||
* @param {Object} `compiler`
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function mixin(compiler) {
|
||||
define(compiler, '_comment', compiler.comment);
|
||||
compiler.map = new utils.SourceMap.SourceMapGenerator();
|
||||
compiler.position = { line: 1, column: 1 };
|
||||
compiler.content = {};
|
||||
compiler.files = {};
|
||||
|
||||
for (var key in exports) {
|
||||
define(compiler, key, exports[key]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update position.
|
||||
*
|
||||
* @param {String} str
|
||||
*/
|
||||
|
||||
exports.updatePosition = function(str) {
|
||||
var lines = str.match(/\n/g);
|
||||
if (lines) this.position.line += lines.length;
|
||||
var i = str.lastIndexOf('\n');
|
||||
this.position.column = ~i ? str.length - i : this.position.column + str.length;
|
||||
};
|
||||
|
||||
/**
|
||||
* Emit `str` with `position`.
|
||||
*
|
||||
* @param {String} str
|
||||
* @param {Object} [pos]
|
||||
* @return {String}
|
||||
*/
|
||||
|
||||
exports.emit = function(str, node) {
|
||||
var position = node.position || {};
|
||||
var source = position.source;
|
||||
if (source) {
|
||||
if (position.filepath) {
|
||||
source = utils.unixify(position.filepath);
|
||||
}
|
||||
|
||||
this.map.addMapping({
|
||||
source: source,
|
||||
generated: {
|
||||
line: this.position.line,
|
||||
column: Math.max(this.position.column - 1, 0)
|
||||
},
|
||||
original: {
|
||||
line: position.start.line,
|
||||
column: position.start.column - 1
|
||||
}
|
||||
});
|
||||
|
||||
if (position.content) {
|
||||
this.addContent(source, position);
|
||||
}
|
||||
if (position.filepath) {
|
||||
this.addFile(source, position);
|
||||
}
|
||||
|
||||
this.updatePosition(str);
|
||||
this.output += str;
|
||||
}
|
||||
return str;
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds a file to the source map output if it has not already been added
|
||||
* @param {String} `file`
|
||||
* @param {Object} `pos`
|
||||
*/
|
||||
|
||||
exports.addFile = function(file, position) {
|
||||
if (typeof position.content !== 'string') return;
|
||||
if (Object.prototype.hasOwnProperty.call(this.files, file)) return;
|
||||
this.files[file] = position.content;
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds a content source to the source map output if it has not already been added
|
||||
* @param {String} `source`
|
||||
* @param {Object} `position`
|
||||
*/
|
||||
|
||||
exports.addContent = function(source, position) {
|
||||
if (typeof position.content !== 'string') return;
|
||||
if (Object.prototype.hasOwnProperty.call(this.content, source)) return;
|
||||
this.map.setSourceContent(source, position.content);
|
||||
};
|
||||
|
||||
/**
|
||||
* Applies any original source maps to the output and embeds the source file
|
||||
* contents in the source map.
|
||||
*/
|
||||
|
||||
exports.applySourceMaps = function() {
|
||||
Object.keys(this.files).forEach(function(file) {
|
||||
var content = this.files[file];
|
||||
this.map.setSourceContent(file, content);
|
||||
|
||||
if (this.options.inputSourcemaps === true) {
|
||||
var originalMap = utils.sourceMapResolve.resolveSync(content, file, fs.readFileSync);
|
||||
if (originalMap) {
|
||||
var map = new utils.SourceMap.SourceMapConsumer(originalMap.map);
|
||||
var relativeTo = originalMap.sourcesRelativeTo;
|
||||
this.map.applySourceMap(map, file, utils.unixify(path.dirname(relativeTo)));
|
||||
}
|
||||
}
|
||||
}, this);
|
||||
};
|
||||
|
||||
/**
|
||||
* Process comments, drops sourceMap comments.
|
||||
* @param {Object} node
|
||||
*/
|
||||
|
||||
exports.comment = function(node) {
|
||||
if (/^# sourceMappingURL=/.test(node.comment)) {
|
||||
return this.emit('', node.position);
|
||||
}
|
||||
return this._comment(node);
|
||||
};
|
48
node_modules/snapdragon/lib/utils.js
generated
vendored
Normal file
48
node_modules/snapdragon/lib/utils.js
generated
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
'use strict';
|
||||
|
||||
/**
|
||||
* Module dependencies
|
||||
*/
|
||||
|
||||
exports.extend = require('extend-shallow');
|
||||
exports.SourceMap = require('source-map');
|
||||
exports.sourceMapResolve = require('source-map-resolve');
|
||||
|
||||
/**
|
||||
* Convert backslash in the given string to forward slashes
|
||||
*/
|
||||
|
||||
exports.unixify = function(fp) {
|
||||
return fp.split(/\\+/).join('/');
|
||||
};
|
||||
|
||||
/**
|
||||
* Return true if `val` is a non-empty string
|
||||
*
|
||||
* @param {String} `str`
|
||||
* @return {Boolean}
|
||||
*/
|
||||
|
||||
exports.isString = function(str) {
|
||||
return str && typeof str === 'string';
|
||||
};
|
||||
|
||||
/**
|
||||
* Cast `val` to an array
|
||||
* @return {Array}
|
||||
*/
|
||||
|
||||
exports.arrayify = function(val) {
|
||||
if (typeof val === 'string') return [val];
|
||||
return val ? (Array.isArray(val) ? val : [val]) : [];
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the last `n` element from the given `array`
|
||||
* @param {Array} `array`
|
||||
* @return {*}
|
||||
*/
|
||||
|
||||
exports.last = function(arr, n) {
|
||||
return arr[arr.length - (n || 1)];
|
||||
};
|
21
node_modules/snapdragon/node_modules/define-property/LICENSE
generated
vendored
Normal file
21
node_modules/snapdragon/node_modules/define-property/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015, Jon Schlinkert.
|
||||
|
||||
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.
|
77
node_modules/snapdragon/node_modules/define-property/README.md
generated
vendored
Normal file
77
node_modules/snapdragon/node_modules/define-property/README.md
generated
vendored
Normal file
|
@ -0,0 +1,77 @@
|
|||
# define-property [](http://badge.fury.io/js/define-property)
|
||||
|
||||
> Define a non-enumerable property on an object.
|
||||
|
||||
## Install
|
||||
|
||||
Install with [npm](https://www.npmjs.com/)
|
||||
|
||||
```sh
|
||||
$ npm i define-property --save
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
**Params**
|
||||
|
||||
* `obj`: The object on which to define the property.
|
||||
* `prop`: The name of the property to be defined or modified.
|
||||
* `descriptor`: The descriptor for the property being defined or modified.
|
||||
|
||||
```js
|
||||
var define = require('define-property');
|
||||
var obj = {};
|
||||
define(obj, 'foo', function(val) {
|
||||
return val.toUpperCase();
|
||||
});
|
||||
|
||||
console.log(obj);
|
||||
//=> {}
|
||||
|
||||
console.log(obj.foo('bar'));
|
||||
//=> 'BAR'
|
||||
```
|
||||
|
||||
**get/set**
|
||||
|
||||
```js
|
||||
define(obj, 'foo', {
|
||||
get: function() {},
|
||||
set: function() {}
|
||||
});
|
||||
```
|
||||
|
||||
## Related projects
|
||||
|
||||
* [delegate-object](https://www.npmjs.com/package/delegate-object): Copy properties from an object to another object, where properties with function values will be… [more](https://www.npmjs.com/package/delegate-object) | [homepage](https://github.com/doowb/delegate-object)
|
||||
* [forward-object](https://www.npmjs.com/package/forward-object): Copy properties from an object to another object, where properties with function values will be… [more](https://www.npmjs.com/package/forward-object) | [homepage](https://github.com/doowb/forward-object)
|
||||
* [mixin-deep](https://www.npmjs.com/package/mixin-deep): Deeply mix the properties of objects into the first object. Like merge-deep, but doesn't clone. | [homepage](https://github.com/jonschlinkert/mixin-deep)
|
||||
* [mixin-object](https://www.npmjs.com/package/mixin-object): Mixin the own and inherited properties of other objects onto the first object. Pass an… [more](https://www.npmjs.com/package/mixin-object) | [homepage](https://github.com/jonschlinkert/mixin-object)
|
||||
|
||||
## Running tests
|
||||
|
||||
Install dev dependencies:
|
||||
|
||||
```sh
|
||||
$ npm i -d && npm test
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/define-property/issues/new).
|
||||
|
||||
## Author
|
||||
|
||||
**Jon Schlinkert**
|
||||
|
||||
+ [github/jonschlinkert](https://github.com/jonschlinkert)
|
||||
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
|
||||
|
||||
## License
|
||||
|
||||
Copyright © 2015 Jon Schlinkert
|
||||
Released under the MIT license.
|
||||
|
||||
***
|
||||
|
||||
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on August 31, 2015._
|
31
node_modules/snapdragon/node_modules/define-property/index.js
generated
vendored
Normal file
31
node_modules/snapdragon/node_modules/define-property/index.js
generated
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*!
|
||||
* define-property <https://github.com/jonschlinkert/define-property>
|
||||
*
|
||||
* Copyright (c) 2015, Jon Schlinkert.
|
||||
* Licensed under the MIT License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var isDescriptor = require('is-descriptor');
|
||||
|
||||
module.exports = function defineProperty(obj, prop, val) {
|
||||
if (typeof obj !== 'object' && typeof obj !== 'function') {
|
||||
throw new TypeError('expected an object or function.');
|
||||
}
|
||||
|
||||
if (typeof prop !== 'string') {
|
||||
throw new TypeError('expected `prop` to be a string.');
|
||||
}
|
||||
|
||||
if (isDescriptor(val) && ('set' in val || 'get' in val)) {
|
||||
return Object.defineProperty(obj, prop, val);
|
||||
}
|
||||
|
||||
return Object.defineProperty(obj, prop, {
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
value: val
|
||||
});
|
||||
};
|
51
node_modules/snapdragon/node_modules/define-property/package.json
generated
vendored
Normal file
51
node_modules/snapdragon/node_modules/define-property/package.json
generated
vendored
Normal file
|
@ -0,0 +1,51 @@
|
|||
{
|
||||
"name": "define-property",
|
||||
"description": "Define a non-enumerable property on an object.",
|
||||
"version": "0.2.5",
|
||||
"homepage": "https://github.com/jonschlinkert/define-property",
|
||||
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
|
||||
"repository": "jonschlinkert/define-property",
|
||||
"bugs": {
|
||||
"url": "https://github.com/jonschlinkert/define-property/issues"
|
||||
},
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"main": "index.js",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"devDependencies": {
|
||||
"mocha": "*",
|
||||
"should": "^7.0.4"
|
||||
},
|
||||
"keywords": [
|
||||
"define",
|
||||
"define-property",
|
||||
"enumerable",
|
||||
"key",
|
||||
"non",
|
||||
"non-enumerable",
|
||||
"object",
|
||||
"prop",
|
||||
"property",
|
||||
"value"
|
||||
],
|
||||
"verb": {
|
||||
"related": {
|
||||
"list": [
|
||||
"mixin-deep",
|
||||
"mixin-object",
|
||||
"delegate-object",
|
||||
"forward-object"
|
||||
]
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"is-descriptor": "^0.1.0"
|
||||
}
|
||||
}
|
21
node_modules/snapdragon/node_modules/extend-shallow/LICENSE
generated
vendored
Normal file
21
node_modules/snapdragon/node_modules/extend-shallow/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014-2015, Jon Schlinkert.
|
||||
|
||||
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.
|
61
node_modules/snapdragon/node_modules/extend-shallow/README.md
generated
vendored
Normal file
61
node_modules/snapdragon/node_modules/extend-shallow/README.md
generated
vendored
Normal file
|
@ -0,0 +1,61 @@
|
|||
# extend-shallow [](http://badge.fury.io/js/extend-shallow) [](https://travis-ci.org/jonschlinkert/extend-shallow)
|
||||
|
||||
> Extend an object with the properties of additional objects. node.js/javascript util.
|
||||
|
||||
## Install
|
||||
|
||||
Install with [npm](https://www.npmjs.com/)
|
||||
|
||||
```sh
|
||||
$ npm i extend-shallow --save
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var extend = require('extend-shallow');
|
||||
|
||||
extend({a: 'b'}, {c: 'd'})
|
||||
//=> {a: 'b', c: 'd'}
|
||||
```
|
||||
|
||||
Pass an empty object to shallow clone:
|
||||
|
||||
```js
|
||||
var obj = {};
|
||||
extend(obj, {a: 'b'}, {c: 'd'})
|
||||
//=> {a: 'b', c: 'd'}
|
||||
```
|
||||
|
||||
## Related
|
||||
|
||||
* [extend-shallow](https://github.com/jonschlinkert/extend-shallow): Extend an object with the properties of additional objects. node.js/javascript util.
|
||||
* [for-own](https://github.com/jonschlinkert/for-own): Iterate over the own enumerable properties of an object, and return an object with properties… [more](https://github.com/jonschlinkert/for-own)
|
||||
* [for-in](https://github.com/jonschlinkert/for-in): Iterate over the own and inherited enumerable properties of an objecte, and return an object… [more](https://github.com/jonschlinkert/for-in)
|
||||
* [is-plain-object](https://github.com/jonschlinkert/is-plain-object): Returns true if an object was created by the `Object` constructor.
|
||||
* [isobject](https://github.com/jonschlinkert/isobject): Returns true if the value is an object and not an array or null.
|
||||
* [kind-of](https://github.com/jonschlinkert/kind-of): Get the native type of a value.
|
||||
|
||||
## Running tests
|
||||
|
||||
Install dev dependencies:
|
||||
|
||||
```sh
|
||||
$ npm i -d && npm test
|
||||
```
|
||||
|
||||
## Author
|
||||
|
||||
**Jon Schlinkert**
|
||||
|
||||
+ [github/jonschlinkert](https://github.com/jonschlinkert)
|
||||
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
|
||||
|
||||
## License
|
||||
|
||||
Copyright © 2015 Jon Schlinkert
|
||||
Released under the MIT license.
|
||||
|
||||
***
|
||||
|
||||
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on June 29, 2015._
|
33
node_modules/snapdragon/node_modules/extend-shallow/index.js
generated
vendored
Normal file
33
node_modules/snapdragon/node_modules/extend-shallow/index.js
generated
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
'use strict';
|
||||
|
||||
var isObject = require('is-extendable');
|
||||
|
||||
module.exports = function extend(o/*, objects*/) {
|
||||
if (!isObject(o)) { o = {}; }
|
||||
|
||||
var len = arguments.length;
|
||||
for (var i = 1; i < len; i++) {
|
||||
var obj = arguments[i];
|
||||
|
||||
if (isObject(obj)) {
|
||||
assign(o, obj);
|
||||
}
|
||||
}
|
||||
return o;
|
||||
};
|
||||
|
||||
function assign(a, b) {
|
||||
for (var key in b) {
|
||||
if (hasOwn(b, key)) {
|
||||
a[key] = b[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given `key` is an own property of `obj`.
|
||||
*/
|
||||
|
||||
function hasOwn(obj, key) {
|
||||
return Object.prototype.hasOwnProperty.call(obj, key);
|
||||
}
|
56
node_modules/snapdragon/node_modules/extend-shallow/package.json
generated
vendored
Normal file
56
node_modules/snapdragon/node_modules/extend-shallow/package.json
generated
vendored
Normal file
|
@ -0,0 +1,56 @@
|
|||
{
|
||||
"name": "extend-shallow",
|
||||
"description": "Extend an object with the properties of additional objects. node.js/javascript util.",
|
||||
"version": "2.0.1",
|
||||
"homepage": "https://github.com/jonschlinkert/extend-shallow",
|
||||
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
|
||||
"repository": "jonschlinkert/extend-shallow",
|
||||
"bugs": {
|
||||
"url": "https://github.com/jonschlinkert/extend-shallow/issues"
|
||||
},
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"main": "index.js",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"dependencies": {
|
||||
"is-extendable": "^0.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"array-slice": "^0.2.3",
|
||||
"benchmarked": "^0.1.4",
|
||||
"chalk": "^1.0.0",
|
||||
"for-own": "^0.1.3",
|
||||
"glob": "^5.0.12",
|
||||
"is-plain-object": "^2.0.1",
|
||||
"kind-of": "^2.0.0",
|
||||
"minimist": "^1.1.1",
|
||||
"mocha": "^2.2.5",
|
||||
"should": "^7.0.1"
|
||||
},
|
||||
"keywords": [
|
||||
"assign",
|
||||
"extend",
|
||||
"javascript",
|
||||
"js",
|
||||
"keys",
|
||||
"merge",
|
||||
"obj",
|
||||
"object",
|
||||
"prop",
|
||||
"properties",
|
||||
"property",
|
||||
"props",
|
||||
"shallow",
|
||||
"util",
|
||||
"utility",
|
||||
"utils",
|
||||
"value"
|
||||
]
|
||||
}
|
21
node_modules/snapdragon/node_modules/is-accessor-descriptor/LICENSE
generated
vendored
Normal file
21
node_modules/snapdragon/node_modules/is-accessor-descriptor/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015, Jon Schlinkert.
|
||||
|
||||
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.
|
123
node_modules/snapdragon/node_modules/is-accessor-descriptor/README.md
generated
vendored
Normal file
123
node_modules/snapdragon/node_modules/is-accessor-descriptor/README.md
generated
vendored
Normal file
|
@ -0,0 +1,123 @@
|
|||
# is-accessor-descriptor [](https://www.npmjs.com/package/is-accessor-descriptor) [](https://travis-ci.org/jonschlinkert/is-accessor-descriptor)
|
||||
|
||||
> Returns true if a value has the characteristics of a valid JavaScript accessor descriptor.
|
||||
|
||||
- [Install](#install)
|
||||
- [Usage](#usage)
|
||||
- [Examples](#examples)
|
||||
- [API](#api)
|
||||
- [Related projects](#related-projects)
|
||||
- [Running tests](#running-tests)
|
||||
- [Contributing](#contributing)
|
||||
- [Author](#author)
|
||||
- [License](#license)
|
||||
|
||||
_(TOC generated by [verb](https://github.com/verbose/verb) using [markdown-toc](https://github.com/jonschlinkert/markdown-toc))_
|
||||
|
||||
## Install
|
||||
|
||||
Install with [npm](https://www.npmjs.com/):
|
||||
|
||||
```sh
|
||||
$ npm i is-accessor-descriptor --save
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var isAccessor = require('is-accessor-descriptor');
|
||||
|
||||
isAccessor({get: function() {}});
|
||||
//=> true
|
||||
```
|
||||
|
||||
You may also pass an object and property name to check if the property is an accessor:
|
||||
|
||||
```js
|
||||
isAccessor(foo, 'bar');
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
`false` when not an object
|
||||
|
||||
```js
|
||||
isAccessor('a')
|
||||
isAccessor(null)
|
||||
isAccessor([])
|
||||
//=> false
|
||||
```
|
||||
|
||||
`true` when the object has valid properties
|
||||
|
||||
and the properties all have the correct JavaScript types:
|
||||
|
||||
```js
|
||||
isAccessor({get: noop, set: noop})
|
||||
isAccessor({get: noop})
|
||||
isAccessor({set: noop})
|
||||
//=> true
|
||||
```
|
||||
|
||||
`false` when the object has invalid properties
|
||||
|
||||
```js
|
||||
isAccessor({get: noop, set: noop, bar: 'baz'})
|
||||
isAccessor({get: noop, writable: true})
|
||||
isAccessor({get: noop, value: true})
|
||||
//=> false
|
||||
```
|
||||
|
||||
`false` when an accessor is not a function
|
||||
|
||||
```js
|
||||
isAccessor({get: noop, set: 'baz'})
|
||||
isAccessor({get: 'foo', set: noop})
|
||||
isAccessor({get: 'foo', bar: 'baz'})
|
||||
isAccessor({get: 'foo', set: 'baz'})
|
||||
//=> false
|
||||
```
|
||||
|
||||
`false` when a value is not the correct type
|
||||
|
||||
```js
|
||||
isAccessor({get: noop, set: noop, enumerable: 'foo'})
|
||||
isAccessor({set: noop, configurable: 'foo'})
|
||||
isAccessor({get: noop, configurable: 'foo'})
|
||||
//=> false
|
||||
```
|
||||
|
||||
## Related projects
|
||||
|
||||
* [is-accessor-descriptor](https://www.npmjs.com/package/is-accessor-descriptor): Returns true if a value has the characteristics of a valid JavaScript accessor descriptor. | [homepage](https://github.com/jonschlinkert/is-accessor-descriptor)
|
||||
* [is-data-descriptor](https://www.npmjs.com/package/is-data-descriptor): Returns true if a value has the characteristics of a valid JavaScript data descriptor. | [homepage](https://github.com/jonschlinkert/is-data-descriptor)
|
||||
* [is-descriptor](https://www.npmjs.com/package/is-descriptor): Returns true if a value has the characteristics of a valid JavaScript descriptor. Works for… [more](https://www.npmjs.com/package/is-descriptor) | [homepage](https://github.com/jonschlinkert/is-descriptor)
|
||||
* [isobject](https://www.npmjs.com/package/isobject): Returns true if the value is an object and not an array or null. | [homepage](https://github.com/jonschlinkert/isobject)
|
||||
|
||||
## Running tests
|
||||
|
||||
Install dev dependencies:
|
||||
|
||||
```sh
|
||||
$ npm i -d && npm test
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/is-accessor-descriptor/issues/new).
|
||||
|
||||
## Author
|
||||
|
||||
**Jon Schlinkert**
|
||||
|
||||
* [github/jonschlinkert](https://github.com/jonschlinkert)
|
||||
* [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
|
||||
|
||||
## License
|
||||
|
||||
Copyright © 2015 [Jon Schlinkert](https://github.com/jonschlinkert)
|
||||
Released under the MIT license.
|
||||
|
||||
***
|
||||
|
||||
_This file was generated by [verb](https://github.com/verbose/verb) on December 28, 2015._
|
69
node_modules/snapdragon/node_modules/is-accessor-descriptor/index.js
generated
vendored
Normal file
69
node_modules/snapdragon/node_modules/is-accessor-descriptor/index.js
generated
vendored
Normal file
|
@ -0,0 +1,69 @@
|
|||
/*!
|
||||
* is-accessor-descriptor <https://github.com/jonschlinkert/is-accessor-descriptor>
|
||||
*
|
||||
* Copyright (c) 2015, Jon Schlinkert.
|
||||
* Licensed under the MIT License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var typeOf = require('kind-of');
|
||||
|
||||
// accessor descriptor properties
|
||||
var accessor = {
|
||||
get: 'function',
|
||||
set: 'function',
|
||||
configurable: 'boolean',
|
||||
enumerable: 'boolean'
|
||||
};
|
||||
|
||||
function isAccessorDescriptor(obj, prop) {
|
||||
if (typeof prop === 'string') {
|
||||
var val = Object.getOwnPropertyDescriptor(obj, prop);
|
||||
return typeof val !== 'undefined';
|
||||
}
|
||||
|
||||
if (typeOf(obj) !== 'object') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (has(obj, 'value') || has(obj, 'writable')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!has(obj, 'get') || typeof obj.get !== 'function') {
|
||||
return false;
|
||||
}
|
||||
|
||||
// tldr: it's valid to have "set" be undefined
|
||||
// "set" might be undefined if `Object.getOwnPropertyDescriptor`
|
||||
// was used to get the value, and only `get` was defined by the user
|
||||
if (has(obj, 'set') && typeof obj[key] !== 'function' && typeof obj[key] !== 'undefined') {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (var key in obj) {
|
||||
if (!accessor.hasOwnProperty(key)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (typeOf(obj[key]) === accessor[key]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (typeof obj[key] !== 'undefined') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function has(obj, key) {
|
||||
return {}.hasOwnProperty.call(obj, key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Expose `isAccessorDescriptor`
|
||||
*/
|
||||
|
||||
module.exports = isAccessorDescriptor;
|
21
node_modules/snapdragon/node_modules/is-accessor-descriptor/node_modules/kind-of/LICENSE
generated
vendored
Normal file
21
node_modules/snapdragon/node_modules/is-accessor-descriptor/node_modules/kind-of/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014-2017, Jon Schlinkert
|
||||
|
||||
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.
|
261
node_modules/snapdragon/node_modules/is-accessor-descriptor/node_modules/kind-of/README.md
generated
vendored
Normal file
261
node_modules/snapdragon/node_modules/is-accessor-descriptor/node_modules/kind-of/README.md
generated
vendored
Normal file
|
@ -0,0 +1,261 @@
|
|||
# kind-of [](https://www.npmjs.com/package/kind-of) [](https://npmjs.org/package/kind-of) [](https://npmjs.org/package/kind-of) [](https://travis-ci.org/jonschlinkert/kind-of)
|
||||
|
||||
> Get the native type of a value.
|
||||
|
||||
## Install
|
||||
|
||||
Install with [npm](https://www.npmjs.com/):
|
||||
|
||||
```sh
|
||||
$ npm install --save kind-of
|
||||
```
|
||||
|
||||
## Install
|
||||
|
||||
Install with [bower](https://bower.io/)
|
||||
|
||||
```sh
|
||||
$ bower install kind-of --save
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
> es5, browser and es6 ready
|
||||
|
||||
```js
|
||||
var kindOf = require('kind-of');
|
||||
|
||||
kindOf(undefined);
|
||||
//=> 'undefined'
|
||||
|
||||
kindOf(null);
|
||||
//=> 'null'
|
||||
|
||||
kindOf(true);
|
||||
//=> 'boolean'
|
||||
|
||||
kindOf(false);
|
||||
//=> 'boolean'
|
||||
|
||||
kindOf(new Boolean(true));
|
||||
//=> 'boolean'
|
||||
|
||||
kindOf(new Buffer(''));
|
||||
//=> 'buffer'
|
||||
|
||||
kindOf(42);
|
||||
//=> 'number'
|
||||
|
||||
kindOf(new Number(42));
|
||||
//=> 'number'
|
||||
|
||||
kindOf('str');
|
||||
//=> 'string'
|
||||
|
||||
kindOf(new String('str'));
|
||||
//=> 'string'
|
||||
|
||||
kindOf(arguments);
|
||||
//=> 'arguments'
|
||||
|
||||
kindOf({});
|
||||
//=> 'object'
|
||||
|
||||
kindOf(Object.create(null));
|
||||
//=> 'object'
|
||||
|
||||
kindOf(new Test());
|
||||
//=> 'object'
|
||||
|
||||
kindOf(new Date());
|
||||
//=> 'date'
|
||||
|
||||
kindOf([]);
|
||||
//=> 'array'
|
||||
|
||||
kindOf([1, 2, 3]);
|
||||
//=> 'array'
|
||||
|
||||
kindOf(new Array());
|
||||
//=> 'array'
|
||||
|
||||
kindOf(/foo/);
|
||||
//=> 'regexp'
|
||||
|
||||
kindOf(new RegExp('foo'));
|
||||
//=> 'regexp'
|
||||
|
||||
kindOf(function () {});
|
||||
//=> 'function'
|
||||
|
||||
kindOf(function * () {});
|
||||
//=> 'function'
|
||||
|
||||
kindOf(new Function());
|
||||
//=> 'function'
|
||||
|
||||
kindOf(new Map());
|
||||
//=> 'map'
|
||||
|
||||
kindOf(new WeakMap());
|
||||
//=> 'weakmap'
|
||||
|
||||
kindOf(new Set());
|
||||
//=> 'set'
|
||||
|
||||
kindOf(new WeakSet());
|
||||
//=> 'weakset'
|
||||
|
||||
kindOf(Symbol('str'));
|
||||
//=> 'symbol'
|
||||
|
||||
kindOf(new Int8Array());
|
||||
//=> 'int8array'
|
||||
|
||||
kindOf(new Uint8Array());
|
||||
//=> 'uint8array'
|
||||
|
||||
kindOf(new Uint8ClampedArray());
|
||||
//=> 'uint8clampedarray'
|
||||
|
||||
kindOf(new Int16Array());
|
||||
//=> 'int16array'
|
||||
|
||||
kindOf(new Uint16Array());
|
||||
//=> 'uint16array'
|
||||
|
||||
kindOf(new Int32Array());
|
||||
//=> 'int32array'
|
||||
|
||||
kindOf(new Uint32Array());
|
||||
//=> 'uint32array'
|
||||
|
||||
kindOf(new Float32Array());
|
||||
//=> 'float32array'
|
||||
|
||||
kindOf(new Float64Array());
|
||||
//=> 'float64array'
|
||||
```
|
||||
|
||||
## Benchmarks
|
||||
|
||||
Benchmarked against [typeof](http://github.com/CodingFu/typeof) and [type-of](https://github.com/ForbesLindesay/type-of).
|
||||
Note that performaces is slower for es6 features `Map`, `WeakMap`, `Set` and `WeakSet`.
|
||||
|
||||
```bash
|
||||
#1: array
|
||||
current x 23,329,397 ops/sec ±0.82% (94 runs sampled)
|
||||
lib-type-of x 4,170,273 ops/sec ±0.55% (94 runs sampled)
|
||||
lib-typeof x 9,686,935 ops/sec ±0.59% (98 runs sampled)
|
||||
|
||||
#2: boolean
|
||||
current x 27,197,115 ops/sec ±0.85% (94 runs sampled)
|
||||
lib-type-of x 3,145,791 ops/sec ±0.73% (97 runs sampled)
|
||||
lib-typeof x 9,199,562 ops/sec ±0.44% (99 runs sampled)
|
||||
|
||||
#3: date
|
||||
current x 20,190,117 ops/sec ±0.86% (92 runs sampled)
|
||||
lib-type-of x 5,166,970 ops/sec ±0.74% (94 runs sampled)
|
||||
lib-typeof x 9,610,821 ops/sec ±0.50% (96 runs sampled)
|
||||
|
||||
#4: function
|
||||
current x 23,855,460 ops/sec ±0.60% (97 runs sampled)
|
||||
lib-type-of x 5,667,740 ops/sec ±0.54% (100 runs sampled)
|
||||
lib-typeof x 10,010,644 ops/sec ±0.44% (100 runs sampled)
|
||||
|
||||
#5: null
|
||||
current x 27,061,047 ops/sec ±0.97% (96 runs sampled)
|
||||
lib-type-of x 13,965,573 ops/sec ±0.62% (97 runs sampled)
|
||||
lib-typeof x 8,460,194 ops/sec ±0.61% (97 runs sampled)
|
||||
|
||||
#6: number
|
||||
current x 25,075,682 ops/sec ±0.53% (99 runs sampled)
|
||||
lib-type-of x 2,266,405 ops/sec ±0.41% (98 runs sampled)
|
||||
lib-typeof x 9,821,481 ops/sec ±0.45% (99 runs sampled)
|
||||
|
||||
#7: object
|
||||
current x 3,348,980 ops/sec ±0.49% (99 runs sampled)
|
||||
lib-type-of x 3,245,138 ops/sec ±0.60% (94 runs sampled)
|
||||
lib-typeof x 9,262,952 ops/sec ±0.59% (99 runs sampled)
|
||||
|
||||
#8: regex
|
||||
current x 21,284,827 ops/sec ±0.72% (96 runs sampled)
|
||||
lib-type-of x 4,689,241 ops/sec ±0.43% (100 runs sampled)
|
||||
lib-typeof x 8,957,593 ops/sec ±0.62% (98 runs sampled)
|
||||
|
||||
#9: string
|
||||
current x 25,379,234 ops/sec ±0.58% (96 runs sampled)
|
||||
lib-type-of x 3,635,148 ops/sec ±0.76% (93 runs sampled)
|
||||
lib-typeof x 9,494,134 ops/sec ±0.49% (98 runs sampled)
|
||||
|
||||
#10: undef
|
||||
current x 27,459,221 ops/sec ±1.01% (93 runs sampled)
|
||||
lib-type-of x 14,360,433 ops/sec ±0.52% (99 runs sampled)
|
||||
lib-typeof x 23,202,868 ops/sec ±0.59% (94 runs sampled)
|
||||
|
||||
```
|
||||
|
||||
## Optimizations
|
||||
|
||||
In 7 out of 8 cases, this library is 2x-10x faster than other top libraries included in the benchmarks. There are a few things that lead to this performance advantage, none of them hard and fast rules, but all of them simple and repeatable in almost any code library:
|
||||
|
||||
1. Optimize around the fastest and most common use cases first. Of course, this will change from project-to-project, but I took some time to understand how and why `typeof` checks were being used in my own libraries and other libraries I use a lot.
|
||||
2. Optimize around bottlenecks - In other words, the order in which conditionals are implemented is significant, because each check is only as fast as the failing checks that came before it. Here, the biggest bottleneck by far is checking for plain objects (an object that was created by the `Object` constructor). I opted to make this check happen by process of elimination rather than brute force up front (e.g. by using something like `val.constructor.name`), so that every other type check would not be penalized it.
|
||||
3. Don't do uneccessary processing - why do `.slice(8, -1).toLowerCase();` just to get the word `regex`? It's much faster to do `if (type === '[object RegExp]') return 'regex'`
|
||||
|
||||
## About
|
||||
|
||||
### Related projects
|
||||
|
||||
* [is-glob](https://www.npmjs.com/package/is-glob): Returns `true` if the given string looks like a glob pattern or an extglob pattern… [more](https://github.com/jonschlinkert/is-glob) | [homepage](https://github.com/jonschlinkert/is-glob "Returns `true` if the given string looks like a glob pattern or an extglob pattern. This makes it easy to create code that only uses external modules like node-glob when necessary, resulting in much faster code execution and initialization time, and a bet")
|
||||
* [is-number](https://www.npmjs.com/package/is-number): Returns true if the value is a number. comprehensive tests. | [homepage](https://github.com/jonschlinkert/is-number "Returns true if the value is a number. comprehensive tests.")
|
||||
* [is-primitive](https://www.npmjs.com/package/is-primitive): Returns `true` if the value is a primitive. | [homepage](https://github.com/jonschlinkert/is-primitive "Returns `true` if the value is a primitive. ")
|
||||
|
||||
### Contributing
|
||||
|
||||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
|
||||
|
||||
### Contributors
|
||||
|
||||
| **Commits** | **Contributor** |
|
||||
| --- | --- |
|
||||
| 59 | [jonschlinkert](https://github.com/jonschlinkert) |
|
||||
| 2 | [miguelmota](https://github.com/miguelmota) |
|
||||
| 1 | [dtothefp](https://github.com/dtothefp) |
|
||||
| 1 | [ksheedlo](https://github.com/ksheedlo) |
|
||||
| 1 | [pdehaan](https://github.com/pdehaan) |
|
||||
| 1 | [laggingreflex](https://github.com/laggingreflex) |
|
||||
|
||||
### Building docs
|
||||
|
||||
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
|
||||
|
||||
To generate the readme, run the following command:
|
||||
|
||||
```sh
|
||||
$ npm install -g verbose/verb#dev verb-generate-readme && verb
|
||||
```
|
||||
|
||||
### Running tests
|
||||
|
||||
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
|
||||
|
||||
```sh
|
||||
$ npm install && npm test
|
||||
```
|
||||
|
||||
### Author
|
||||
|
||||
**Jon Schlinkert**
|
||||
|
||||
* [github/jonschlinkert](https://github.com/jonschlinkert)
|
||||
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
|
||||
|
||||
### License
|
||||
|
||||
Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
|
||||
Released under the [MIT License](LICENSE).
|
||||
|
||||
***
|
||||
|
||||
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on May 16, 2017._
|
116
node_modules/snapdragon/node_modules/is-accessor-descriptor/node_modules/kind-of/index.js
generated
vendored
Normal file
116
node_modules/snapdragon/node_modules/is-accessor-descriptor/node_modules/kind-of/index.js
generated
vendored
Normal file
|
@ -0,0 +1,116 @@
|
|||
var isBuffer = require('is-buffer');
|
||||
var toString = Object.prototype.toString;
|
||||
|
||||
/**
|
||||
* Get the native `typeof` a value.
|
||||
*
|
||||
* @param {*} `val`
|
||||
* @return {*} Native javascript type
|
||||
*/
|
||||
|
||||
module.exports = function kindOf(val) {
|
||||
// primitivies
|
||||
if (typeof val === 'undefined') {
|
||||
return 'undefined';
|
||||
}
|
||||
if (val === null) {
|
||||
return 'null';
|
||||
}
|
||||
if (val === true || val === false || val instanceof Boolean) {
|
||||
return 'boolean';
|
||||
}
|
||||
if (typeof val === 'string' || val instanceof String) {
|
||||
return 'string';
|
||||
}
|
||||
if (typeof val === 'number' || val instanceof Number) {
|
||||
return 'number';
|
||||
}
|
||||
|
||||
// functions
|
||||
if (typeof val === 'function' || val instanceof Function) {
|
||||
return 'function';
|
||||
}
|
||||
|
||||
// array
|
||||
if (typeof Array.isArray !== 'undefined' && Array.isArray(val)) {
|
||||
return 'array';
|
||||
}
|
||||
|
||||
// check for instances of RegExp and Date before calling `toString`
|
||||
if (val instanceof RegExp) {
|
||||
return 'regexp';
|
||||
}
|
||||
if (val instanceof Date) {
|
||||
return 'date';
|
||||
}
|
||||
|
||||
// other objects
|
||||
var type = toString.call(val);
|
||||
|
||||
if (type === '[object RegExp]') {
|
||||
return 'regexp';
|
||||
}
|
||||
if (type === '[object Date]') {
|
||||
return 'date';
|
||||
}
|
||||
if (type === '[object Arguments]') {
|
||||
return 'arguments';
|
||||
}
|
||||
if (type === '[object Error]') {
|
||||
return 'error';
|
||||
}
|
||||
|
||||
// buffer
|
||||
if (isBuffer(val)) {
|
||||
return 'buffer';
|
||||
}
|
||||
|
||||
// es6: Map, WeakMap, Set, WeakSet
|
||||
if (type === '[object Set]') {
|
||||
return 'set';
|
||||
}
|
||||
if (type === '[object WeakSet]') {
|
||||
return 'weakset';
|
||||
}
|
||||
if (type === '[object Map]') {
|
||||
return 'map';
|
||||
}
|
||||
if (type === '[object WeakMap]') {
|
||||
return 'weakmap';
|
||||
}
|
||||
if (type === '[object Symbol]') {
|
||||
return 'symbol';
|
||||
}
|
||||
|
||||
// typed arrays
|
||||
if (type === '[object Int8Array]') {
|
||||
return 'int8array';
|
||||
}
|
||||
if (type === '[object Uint8Array]') {
|
||||
return 'uint8array';
|
||||
}
|
||||
if (type === '[object Uint8ClampedArray]') {
|
||||
return 'uint8clampedarray';
|
||||
}
|
||||
if (type === '[object Int16Array]') {
|
||||
return 'int16array';
|
||||
}
|
||||
if (type === '[object Uint16Array]') {
|
||||
return 'uint16array';
|
||||
}
|
||||
if (type === '[object Int32Array]') {
|
||||
return 'int32array';
|
||||
}
|
||||
if (type === '[object Uint32Array]') {
|
||||
return 'uint32array';
|
||||
}
|
||||
if (type === '[object Float32Array]') {
|
||||
return 'float32array';
|
||||
}
|
||||
if (type === '[object Float64Array]') {
|
||||
return 'float64array';
|
||||
}
|
||||
|
||||
// must be a plain object
|
||||
return 'object';
|
||||
};
|
90
node_modules/snapdragon/node_modules/is-accessor-descriptor/node_modules/kind-of/package.json
generated
vendored
Normal file
90
node_modules/snapdragon/node_modules/is-accessor-descriptor/node_modules/kind-of/package.json
generated
vendored
Normal file
|
@ -0,0 +1,90 @@
|
|||
{
|
||||
"name": "kind-of",
|
||||
"description": "Get the native type of a value.",
|
||||
"version": "3.2.2",
|
||||
"homepage": "https://github.com/jonschlinkert/kind-of",
|
||||
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
|
||||
"contributors": [
|
||||
"David Fox-Powell (https://dtothefp.github.io/me)",
|
||||
"Jon Schlinkert (http://twitter.com/jonschlinkert)",
|
||||
"Ken Sheedlo (kensheedlo.com)",
|
||||
"laggingreflex (https://github.com/laggingreflex)",
|
||||
"Miguel Mota (https://miguelmota.com)",
|
||||
"Peter deHaan (http://about.me/peterdehaan)"
|
||||
],
|
||||
"repository": "jonschlinkert/kind-of",
|
||||
"bugs": {
|
||||
"url": "https://github.com/jonschlinkert/kind-of/issues"
|
||||
},
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"main": "index.js",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha",
|
||||
"prepublish": "browserify -o browser.js -e index.js -s index --bare"
|
||||
},
|
||||
"dependencies": {
|
||||
"is-buffer": "^1.1.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ansi-bold": "^0.1.1",
|
||||
"benchmarked": "^1.0.0",
|
||||
"browserify": "^14.3.0",
|
||||
"glob": "^7.1.1",
|
||||
"gulp-format-md": "^0.1.12",
|
||||
"mocha": "^3.3.0",
|
||||
"type-of": "^2.0.1",
|
||||
"typeof": "^1.0.0"
|
||||
},
|
||||
"keywords": [
|
||||
"arguments",
|
||||
"array",
|
||||
"boolean",
|
||||
"check",
|
||||
"date",
|
||||
"function",
|
||||
"is",
|
||||
"is-type",
|
||||
"is-type-of",
|
||||
"kind",
|
||||
"kind-of",
|
||||
"number",
|
||||
"object",
|
||||
"of",
|
||||
"regexp",
|
||||
"string",
|
||||
"test",
|
||||
"type",
|
||||
"type-of",
|
||||
"typeof",
|
||||
"types"
|
||||
],
|
||||
"verb": {
|
||||
"related": {
|
||||
"list": [
|
||||
"is-glob",
|
||||
"is-number",
|
||||
"is-primitive"
|
||||
]
|
||||
},
|
||||
"toc": false,
|
||||
"layout": "default",
|
||||
"tasks": [
|
||||
"readme"
|
||||
],
|
||||
"plugins": [
|
||||
"gulp-format-md"
|
||||
],
|
||||
"lint": {
|
||||
"reflinks": true
|
||||
},
|
||||
"reflinks": [
|
||||
"verb"
|
||||
]
|
||||
}
|
||||
}
|
61
node_modules/snapdragon/node_modules/is-accessor-descriptor/package.json
generated
vendored
Normal file
61
node_modules/snapdragon/node_modules/is-accessor-descriptor/package.json
generated
vendored
Normal file
|
@ -0,0 +1,61 @@
|
|||
{
|
||||
"name": "is-accessor-descriptor",
|
||||
"description": "Returns true if a value has the characteristics of a valid JavaScript accessor descriptor.",
|
||||
"version": "0.1.6",
|
||||
"homepage": "https://github.com/jonschlinkert/is-accessor-descriptor",
|
||||
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
|
||||
"repository": "jonschlinkert/is-accessor-descriptor",
|
||||
"bugs": {
|
||||
"url": "https://github.com/jonschlinkert/is-accessor-descriptor/issues"
|
||||
},
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"main": "index.js",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"dependencies": {
|
||||
"kind-of": "^3.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"mocha": "*",
|
||||
"should": "*"
|
||||
},
|
||||
"keywords": [
|
||||
"accessor",
|
||||
"check",
|
||||
"data",
|
||||
"descriptor",
|
||||
"get",
|
||||
"getter",
|
||||
"is",
|
||||
"keys",
|
||||
"object",
|
||||
"properties",
|
||||
"property",
|
||||
"set",
|
||||
"setter",
|
||||
"type",
|
||||
"valid",
|
||||
"value"
|
||||
],
|
||||
"verb": {
|
||||
"related": {
|
||||
"list": [
|
||||
"is-accessor-descriptor",
|
||||
"is-data-descriptor",
|
||||
"is-descriptor",
|
||||
"isobject"
|
||||
]
|
||||
},
|
||||
"plugins": [
|
||||
"gulp-format-md"
|
||||
],
|
||||
"layout": "default"
|
||||
}
|
||||
}
|
21
node_modules/snapdragon/node_modules/is-data-descriptor/LICENSE
generated
vendored
Normal file
21
node_modules/snapdragon/node_modules/is-data-descriptor/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015, Jon Schlinkert.
|
||||
|
||||
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.
|
128
node_modules/snapdragon/node_modules/is-data-descriptor/README.md
generated
vendored
Normal file
128
node_modules/snapdragon/node_modules/is-data-descriptor/README.md
generated
vendored
Normal file
|
@ -0,0 +1,128 @@
|
|||
# is-data-descriptor [](https://www.npmjs.com/package/is-data-descriptor) [](https://travis-ci.org/jonschlinkert/is-data-descriptor)
|
||||
|
||||
> Returns true if a value has the characteristics of a valid JavaScript data descriptor.
|
||||
|
||||
## Install
|
||||
|
||||
Install with [npm](https://www.npmjs.com/):
|
||||
|
||||
```sh
|
||||
$ npm i is-data-descriptor --save
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var isDataDesc = require('is-data-descriptor');
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
`true` when the descriptor has valid properties with valid values.
|
||||
|
||||
```js
|
||||
// `value` can be anything
|
||||
isDataDesc({value: 'foo'})
|
||||
isDataDesc({value: function() {}})
|
||||
isDataDesc({value: true})
|
||||
//=> true
|
||||
```
|
||||
|
||||
`false` when not an object
|
||||
|
||||
```js
|
||||
isDataDesc('a')
|
||||
//=> false
|
||||
isDataDesc(null)
|
||||
//=> false
|
||||
isDataDesc([])
|
||||
//=> false
|
||||
```
|
||||
|
||||
`false` when the object has invalid properties
|
||||
|
||||
```js
|
||||
isDataDesc({value: 'foo', bar: 'baz'})
|
||||
//=> false
|
||||
isDataDesc({value: 'foo', bar: 'baz'})
|
||||
//=> false
|
||||
isDataDesc({value: 'foo', get: function(){}})
|
||||
//=> false
|
||||
isDataDesc({get: function(){}, value: 'foo'})
|
||||
//=> false
|
||||
```
|
||||
|
||||
`false` when a value is not the correct type
|
||||
|
||||
```js
|
||||
isDataDesc({value: 'foo', enumerable: 'foo'})
|
||||
//=> false
|
||||
isDataDesc({value: 'foo', configurable: 'foo'})
|
||||
//=> false
|
||||
isDataDesc({value: 'foo', writable: 'foo'})
|
||||
//=> false
|
||||
```
|
||||
|
||||
## Valid properties
|
||||
|
||||
The only valid data descriptor properties are the following:
|
||||
|
||||
* `configurable` (required)
|
||||
* `enumerable` (required)
|
||||
* `value` (optional)
|
||||
* `writable` (optional)
|
||||
|
||||
To be a valid data descriptor, either `value` or `writable` must be defined.
|
||||
|
||||
**Invalid properties**
|
||||
|
||||
A descriptor may have additional _invalid_ properties (an error will **not** be thrown).
|
||||
|
||||
```js
|
||||
var foo = {};
|
||||
|
||||
Object.defineProperty(foo, 'bar', {
|
||||
enumerable: true,
|
||||
whatever: 'blah', // invalid, but doesn't cause an error
|
||||
get: function() {
|
||||
return 'baz';
|
||||
}
|
||||
});
|
||||
|
||||
console.log(foo.bar);
|
||||
//=> 'baz'
|
||||
```
|
||||
|
||||
## Related projects
|
||||
|
||||
* [is-accessor-descriptor](https://www.npmjs.com/package/is-accessor-descriptor): Returns true if a value has the characteristics of a valid JavaScript accessor descriptor. | [homepage](https://github.com/jonschlinkert/is-accessor-descriptor)
|
||||
* [is-descriptor](https://www.npmjs.com/package/is-descriptor): Returns true if a value has the characteristics of a valid JavaScript descriptor. Works for… [more](https://www.npmjs.com/package/is-descriptor) | [homepage](https://github.com/jonschlinkert/is-descriptor)
|
||||
* [isobject](https://www.npmjs.com/package/isobject): Returns true if the value is an object and not an array or null. | [homepage](https://github.com/jonschlinkert/isobject)
|
||||
|
||||
## Running tests
|
||||
|
||||
Install dev dependencies:
|
||||
|
||||
```sh
|
||||
$ npm i -d && npm test
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/is-data-descriptor/issues/new).
|
||||
|
||||
## Author
|
||||
|
||||
**Jon Schlinkert**
|
||||
|
||||
* [github/jonschlinkert](https://github.com/jonschlinkert)
|
||||
* [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
|
||||
|
||||
## License
|
||||
|
||||
Copyright © 2015 [Jon Schlinkert](https://github.com/jonschlinkert)
|
||||
Released under the MIT license.
|
||||
|
||||
***
|
||||
|
||||
_This file was generated by [verb](https://github.com/verbose/verb) on December 28, 2015._
|
55
node_modules/snapdragon/node_modules/is-data-descriptor/index.js
generated
vendored
Normal file
55
node_modules/snapdragon/node_modules/is-data-descriptor/index.js
generated
vendored
Normal file
|
@ -0,0 +1,55 @@
|
|||
/*!
|
||||
* is-data-descriptor <https://github.com/jonschlinkert/is-data-descriptor>
|
||||
*
|
||||
* Copyright (c) 2015, Jon Schlinkert.
|
||||
* Licensed under the MIT License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var typeOf = require('kind-of');
|
||||
|
||||
// data descriptor properties
|
||||
var data = {
|
||||
configurable: 'boolean',
|
||||
enumerable: 'boolean',
|
||||
writable: 'boolean'
|
||||
};
|
||||
|
||||
function isDataDescriptor(obj, prop) {
|
||||
if (typeOf(obj) !== 'object') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (typeof prop === 'string') {
|
||||
var val = Object.getOwnPropertyDescriptor(obj, prop);
|
||||
return typeof val !== 'undefined';
|
||||
}
|
||||
|
||||
if (!('value' in obj) && !('writable' in obj)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (var key in obj) {
|
||||
if (key === 'value') continue;
|
||||
|
||||
if (!data.hasOwnProperty(key)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (typeOf(obj[key]) === data[key]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (typeof obj[key] !== 'undefined') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expose `isDataDescriptor`
|
||||
*/
|
||||
|
||||
module.exports = isDataDescriptor;
|
21
node_modules/snapdragon/node_modules/is-data-descriptor/node_modules/kind-of/LICENSE
generated
vendored
Normal file
21
node_modules/snapdragon/node_modules/is-data-descriptor/node_modules/kind-of/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014-2017, Jon Schlinkert
|
||||
|
||||
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.
|
261
node_modules/snapdragon/node_modules/is-data-descriptor/node_modules/kind-of/README.md
generated
vendored
Normal file
261
node_modules/snapdragon/node_modules/is-data-descriptor/node_modules/kind-of/README.md
generated
vendored
Normal file
|
@ -0,0 +1,261 @@
|
|||
# kind-of [](https://www.npmjs.com/package/kind-of) [](https://npmjs.org/package/kind-of) [](https://npmjs.org/package/kind-of) [](https://travis-ci.org/jonschlinkert/kind-of)
|
||||
|
||||
> Get the native type of a value.
|
||||
|
||||
## Install
|
||||
|
||||
Install with [npm](https://www.npmjs.com/):
|
||||
|
||||
```sh
|
||||
$ npm install --save kind-of
|
||||
```
|
||||
|
||||
## Install
|
||||
|
||||
Install with [bower](https://bower.io/)
|
||||
|
||||
```sh
|
||||
$ bower install kind-of --save
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
> es5, browser and es6 ready
|
||||
|
||||
```js
|
||||
var kindOf = require('kind-of');
|
||||
|
||||
kindOf(undefined);
|
||||
//=> 'undefined'
|
||||
|
||||
kindOf(null);
|
||||
//=> 'null'
|
||||
|
||||
kindOf(true);
|
||||
//=> 'boolean'
|
||||
|
||||
kindOf(false);
|
||||
//=> 'boolean'
|
||||
|
||||
kindOf(new Boolean(true));
|
||||
//=> 'boolean'
|
||||
|
||||
kindOf(new Buffer(''));
|
||||
//=> 'buffer'
|
||||
|
||||
kindOf(42);
|
||||
//=> 'number'
|
||||
|
||||
kindOf(new Number(42));
|
||||
//=> 'number'
|
||||
|
||||
kindOf('str');
|
||||
//=> 'string'
|
||||
|
||||
kindOf(new String('str'));
|
||||
//=> 'string'
|
||||
|
||||
kindOf(arguments);
|
||||
//=> 'arguments'
|
||||
|
||||
kindOf({});
|
||||
//=> 'object'
|
||||
|
||||
kindOf(Object.create(null));
|
||||
//=> 'object'
|
||||
|
||||
kindOf(new Test());
|
||||
//=> 'object'
|
||||
|
||||
kindOf(new Date());
|
||||
//=> 'date'
|
||||
|
||||
kindOf([]);
|
||||
//=> 'array'
|
||||
|
||||
kindOf([1, 2, 3]);
|
||||
//=> 'array'
|
||||
|
||||
kindOf(new Array());
|
||||
//=> 'array'
|
||||
|
||||
kindOf(/foo/);
|
||||
//=> 'regexp'
|
||||
|
||||
kindOf(new RegExp('foo'));
|
||||
//=> 'regexp'
|
||||
|
||||
kindOf(function () {});
|
||||
//=> 'function'
|
||||
|
||||
kindOf(function * () {});
|
||||
//=> 'function'
|
||||
|
||||
kindOf(new Function());
|
||||
//=> 'function'
|
||||
|
||||
kindOf(new Map());
|
||||
//=> 'map'
|
||||
|
||||
kindOf(new WeakMap());
|
||||
//=> 'weakmap'
|
||||
|
||||
kindOf(new Set());
|
||||
//=> 'set'
|
||||
|
||||
kindOf(new WeakSet());
|
||||
//=> 'weakset'
|
||||
|
||||
kindOf(Symbol('str'));
|
||||
//=> 'symbol'
|
||||
|
||||
kindOf(new Int8Array());
|
||||
//=> 'int8array'
|
||||
|
||||
kindOf(new Uint8Array());
|
||||
//=> 'uint8array'
|
||||
|
||||
kindOf(new Uint8ClampedArray());
|
||||
//=> 'uint8clampedarray'
|
||||
|
||||
kindOf(new Int16Array());
|
||||
//=> 'int16array'
|
||||
|
||||
kindOf(new Uint16Array());
|
||||
//=> 'uint16array'
|
||||
|
||||
kindOf(new Int32Array());
|
||||
//=> 'int32array'
|
||||
|
||||
kindOf(new Uint32Array());
|
||||
//=> 'uint32array'
|
||||
|
||||
kindOf(new Float32Array());
|
||||
//=> 'float32array'
|
||||
|
||||
kindOf(new Float64Array());
|
||||
//=> 'float64array'
|
||||
```
|
||||
|
||||
## Benchmarks
|
||||
|
||||
Benchmarked against [typeof](http://github.com/CodingFu/typeof) and [type-of](https://github.com/ForbesLindesay/type-of).
|
||||
Note that performaces is slower for es6 features `Map`, `WeakMap`, `Set` and `WeakSet`.
|
||||
|
||||
```bash
|
||||
#1: array
|
||||
current x 23,329,397 ops/sec ±0.82% (94 runs sampled)
|
||||
lib-type-of x 4,170,273 ops/sec ±0.55% (94 runs sampled)
|
||||
lib-typeof x 9,686,935 ops/sec ±0.59% (98 runs sampled)
|
||||
|
||||
#2: boolean
|
||||
current x 27,197,115 ops/sec ±0.85% (94 runs sampled)
|
||||
lib-type-of x 3,145,791 ops/sec ±0.73% (97 runs sampled)
|
||||
lib-typeof x 9,199,562 ops/sec ±0.44% (99 runs sampled)
|
||||
|
||||
#3: date
|
||||
current x 20,190,117 ops/sec ±0.86% (92 runs sampled)
|
||||
lib-type-of x 5,166,970 ops/sec ±0.74% (94 runs sampled)
|
||||
lib-typeof x 9,610,821 ops/sec ±0.50% (96 runs sampled)
|
||||
|
||||
#4: function
|
||||
current x 23,855,460 ops/sec ±0.60% (97 runs sampled)
|
||||
lib-type-of x 5,667,740 ops/sec ±0.54% (100 runs sampled)
|
||||
lib-typeof x 10,010,644 ops/sec ±0.44% (100 runs sampled)
|
||||
|
||||
#5: null
|
||||
current x 27,061,047 ops/sec ±0.97% (96 runs sampled)
|
||||
lib-type-of x 13,965,573 ops/sec ±0.62% (97 runs sampled)
|
||||
lib-typeof x 8,460,194 ops/sec ±0.61% (97 runs sampled)
|
||||
|
||||
#6: number
|
||||
current x 25,075,682 ops/sec ±0.53% (99 runs sampled)
|
||||
lib-type-of x 2,266,405 ops/sec ±0.41% (98 runs sampled)
|
||||
lib-typeof x 9,821,481 ops/sec ±0.45% (99 runs sampled)
|
||||
|
||||
#7: object
|
||||
current x 3,348,980 ops/sec ±0.49% (99 runs sampled)
|
||||
lib-type-of x 3,245,138 ops/sec ±0.60% (94 runs sampled)
|
||||
lib-typeof x 9,262,952 ops/sec ±0.59% (99 runs sampled)
|
||||
|
||||
#8: regex
|
||||
current x 21,284,827 ops/sec ±0.72% (96 runs sampled)
|
||||
lib-type-of x 4,689,241 ops/sec ±0.43% (100 runs sampled)
|
||||
lib-typeof x 8,957,593 ops/sec ±0.62% (98 runs sampled)
|
||||
|
||||
#9: string
|
||||
current x 25,379,234 ops/sec ±0.58% (96 runs sampled)
|
||||
lib-type-of x 3,635,148 ops/sec ±0.76% (93 runs sampled)
|
||||
lib-typeof x 9,494,134 ops/sec ±0.49% (98 runs sampled)
|
||||
|
||||
#10: undef
|
||||
current x 27,459,221 ops/sec ±1.01% (93 runs sampled)
|
||||
lib-type-of x 14,360,433 ops/sec ±0.52% (99 runs sampled)
|
||||
lib-typeof x 23,202,868 ops/sec ±0.59% (94 runs sampled)
|
||||
|
||||
```
|
||||
|
||||
## Optimizations
|
||||
|
||||
In 7 out of 8 cases, this library is 2x-10x faster than other top libraries included in the benchmarks. There are a few things that lead to this performance advantage, none of them hard and fast rules, but all of them simple and repeatable in almost any code library:
|
||||
|
||||
1. Optimize around the fastest and most common use cases first. Of course, this will change from project-to-project, but I took some time to understand how and why `typeof` checks were being used in my own libraries and other libraries I use a lot.
|
||||
2. Optimize around bottlenecks - In other words, the order in which conditionals are implemented is significant, because each check is only as fast as the failing checks that came before it. Here, the biggest bottleneck by far is checking for plain objects (an object that was created by the `Object` constructor). I opted to make this check happen by process of elimination rather than brute force up front (e.g. by using something like `val.constructor.name`), so that every other type check would not be penalized it.
|
||||
3. Don't do uneccessary processing - why do `.slice(8, -1).toLowerCase();` just to get the word `regex`? It's much faster to do `if (type === '[object RegExp]') return 'regex'`
|
||||
|
||||
## About
|
||||
|
||||
### Related projects
|
||||
|
||||
* [is-glob](https://www.npmjs.com/package/is-glob): Returns `true` if the given string looks like a glob pattern or an extglob pattern… [more](https://github.com/jonschlinkert/is-glob) | [homepage](https://github.com/jonschlinkert/is-glob "Returns `true` if the given string looks like a glob pattern or an extglob pattern. This makes it easy to create code that only uses external modules like node-glob when necessary, resulting in much faster code execution and initialization time, and a bet")
|
||||
* [is-number](https://www.npmjs.com/package/is-number): Returns true if the value is a number. comprehensive tests. | [homepage](https://github.com/jonschlinkert/is-number "Returns true if the value is a number. comprehensive tests.")
|
||||
* [is-primitive](https://www.npmjs.com/package/is-primitive): Returns `true` if the value is a primitive. | [homepage](https://github.com/jonschlinkert/is-primitive "Returns `true` if the value is a primitive. ")
|
||||
|
||||
### Contributing
|
||||
|
||||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
|
||||
|
||||
### Contributors
|
||||
|
||||
| **Commits** | **Contributor** |
|
||||
| --- | --- |
|
||||
| 59 | [jonschlinkert](https://github.com/jonschlinkert) |
|
||||
| 2 | [miguelmota](https://github.com/miguelmota) |
|
||||
| 1 | [dtothefp](https://github.com/dtothefp) |
|
||||
| 1 | [ksheedlo](https://github.com/ksheedlo) |
|
||||
| 1 | [pdehaan](https://github.com/pdehaan) |
|
||||
| 1 | [laggingreflex](https://github.com/laggingreflex) |
|
||||
|
||||
### Building docs
|
||||
|
||||
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
|
||||
|
||||
To generate the readme, run the following command:
|
||||
|
||||
```sh
|
||||
$ npm install -g verbose/verb#dev verb-generate-readme && verb
|
||||
```
|
||||
|
||||
### Running tests
|
||||
|
||||
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
|
||||
|
||||
```sh
|
||||
$ npm install && npm test
|
||||
```
|
||||
|
||||
### Author
|
||||
|
||||
**Jon Schlinkert**
|
||||
|
||||
* [github/jonschlinkert](https://github.com/jonschlinkert)
|
||||
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
|
||||
|
||||
### License
|
||||
|
||||
Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
|
||||
Released under the [MIT License](LICENSE).
|
||||
|
||||
***
|
||||
|
||||
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on May 16, 2017._
|
116
node_modules/snapdragon/node_modules/is-data-descriptor/node_modules/kind-of/index.js
generated
vendored
Normal file
116
node_modules/snapdragon/node_modules/is-data-descriptor/node_modules/kind-of/index.js
generated
vendored
Normal file
|
@ -0,0 +1,116 @@
|
|||
var isBuffer = require('is-buffer');
|
||||
var toString = Object.prototype.toString;
|
||||
|
||||
/**
|
||||
* Get the native `typeof` a value.
|
||||
*
|
||||
* @param {*} `val`
|
||||
* @return {*} Native javascript type
|
||||
*/
|
||||
|
||||
module.exports = function kindOf(val) {
|
||||
// primitivies
|
||||
if (typeof val === 'undefined') {
|
||||
return 'undefined';
|
||||
}
|
||||
if (val === null) {
|
||||
return 'null';
|
||||
}
|
||||
if (val === true || val === false || val instanceof Boolean) {
|
||||
return 'boolean';
|
||||
}
|
||||
if (typeof val === 'string' || val instanceof String) {
|
||||
return 'string';
|
||||
}
|
||||
if (typeof val === 'number' || val instanceof Number) {
|
||||
return 'number';
|
||||
}
|
||||
|
||||
// functions
|
||||
if (typeof val === 'function' || val instanceof Function) {
|
||||
return 'function';
|
||||
}
|
||||
|
||||
// array
|
||||
if (typeof Array.isArray !== 'undefined' && Array.isArray(val)) {
|
||||
return 'array';
|
||||
}
|
||||
|
||||
// check for instances of RegExp and Date before calling `toString`
|
||||
if (val instanceof RegExp) {
|
||||
return 'regexp';
|
||||
}
|
||||
if (val instanceof Date) {
|
||||
return 'date';
|
||||
}
|
||||
|
||||
// other objects
|
||||
var type = toString.call(val);
|
||||
|
||||
if (type === '[object RegExp]') {
|
||||
return 'regexp';
|
||||
}
|
||||
if (type === '[object Date]') {
|
||||
return 'date';
|
||||
}
|
||||
if (type === '[object Arguments]') {
|
||||
return 'arguments';
|
||||
}
|
||||
if (type === '[object Error]') {
|
||||
return 'error';
|
||||
}
|
||||
|
||||
// buffer
|
||||
if (isBuffer(val)) {
|
||||
return 'buffer';
|
||||
}
|
||||
|
||||
// es6: Map, WeakMap, Set, WeakSet
|
||||
if (type === '[object Set]') {
|
||||
return 'set';
|
||||
}
|
||||
if (type === '[object WeakSet]') {
|
||||
return 'weakset';
|
||||
}
|
||||
if (type === '[object Map]') {
|
||||
return 'map';
|
||||
}
|
||||
if (type === '[object WeakMap]') {
|
||||
return 'weakmap';
|
||||
}
|
||||
if (type === '[object Symbol]') {
|
||||
return 'symbol';
|
||||
}
|
||||
|
||||
// typed arrays
|
||||
if (type === '[object Int8Array]') {
|
||||
return 'int8array';
|
||||
}
|
||||
if (type === '[object Uint8Array]') {
|
||||
return 'uint8array';
|
||||
}
|
||||
if (type === '[object Uint8ClampedArray]') {
|
||||
return 'uint8clampedarray';
|
||||
}
|
||||
if (type === '[object Int16Array]') {
|
||||
return 'int16array';
|
||||
}
|
||||
if (type === '[object Uint16Array]') {
|
||||
return 'uint16array';
|
||||
}
|
||||
if (type === '[object Int32Array]') {
|
||||
return 'int32array';
|
||||
}
|
||||
if (type === '[object Uint32Array]') {
|
||||
return 'uint32array';
|
||||
}
|
||||
if (type === '[object Float32Array]') {
|
||||
return 'float32array';
|
||||
}
|
||||
if (type === '[object Float64Array]') {
|
||||
return 'float64array';
|
||||
}
|
||||
|
||||
// must be a plain object
|
||||
return 'object';
|
||||
};
|
90
node_modules/snapdragon/node_modules/is-data-descriptor/node_modules/kind-of/package.json
generated
vendored
Normal file
90
node_modules/snapdragon/node_modules/is-data-descriptor/node_modules/kind-of/package.json
generated
vendored
Normal file
|
@ -0,0 +1,90 @@
|
|||
{
|
||||
"name": "kind-of",
|
||||
"description": "Get the native type of a value.",
|
||||
"version": "3.2.2",
|
||||
"homepage": "https://github.com/jonschlinkert/kind-of",
|
||||
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
|
||||
"contributors": [
|
||||
"David Fox-Powell (https://dtothefp.github.io/me)",
|
||||
"Jon Schlinkert (http://twitter.com/jonschlinkert)",
|
||||
"Ken Sheedlo (kensheedlo.com)",
|
||||
"laggingreflex (https://github.com/laggingreflex)",
|
||||
"Miguel Mota (https://miguelmota.com)",
|
||||
"Peter deHaan (http://about.me/peterdehaan)"
|
||||
],
|
||||
"repository": "jonschlinkert/kind-of",
|
||||
"bugs": {
|
||||
"url": "https://github.com/jonschlinkert/kind-of/issues"
|
||||
},
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"main": "index.js",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha",
|
||||
"prepublish": "browserify -o browser.js -e index.js -s index --bare"
|
||||
},
|
||||
"dependencies": {
|
||||
"is-buffer": "^1.1.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ansi-bold": "^0.1.1",
|
||||
"benchmarked": "^1.0.0",
|
||||
"browserify": "^14.3.0",
|
||||
"glob": "^7.1.1",
|
||||
"gulp-format-md": "^0.1.12",
|
||||
"mocha": "^3.3.0",
|
||||
"type-of": "^2.0.1",
|
||||
"typeof": "^1.0.0"
|
||||
},
|
||||
"keywords": [
|
||||
"arguments",
|
||||
"array",
|
||||
"boolean",
|
||||
"check",
|
||||
"date",
|
||||
"function",
|
||||
"is",
|
||||
"is-type",
|
||||
"is-type-of",
|
||||
"kind",
|
||||
"kind-of",
|
||||
"number",
|
||||
"object",
|
||||
"of",
|
||||
"regexp",
|
||||
"string",
|
||||
"test",
|
||||
"type",
|
||||
"type-of",
|
||||
"typeof",
|
||||
"types"
|
||||
],
|
||||
"verb": {
|
||||
"related": {
|
||||
"list": [
|
||||
"is-glob",
|
||||
"is-number",
|
||||
"is-primitive"
|
||||
]
|
||||
},
|
||||
"toc": false,
|
||||
"layout": "default",
|
||||
"tasks": [
|
||||
"readme"
|
||||
],
|
||||
"plugins": [
|
||||
"gulp-format-md"
|
||||
],
|
||||
"lint": {
|
||||
"reflinks": true
|
||||
},
|
||||
"reflinks": [
|
||||
"verb"
|
||||
]
|
||||
}
|
||||
}
|
60
node_modules/snapdragon/node_modules/is-data-descriptor/package.json
generated
vendored
Normal file
60
node_modules/snapdragon/node_modules/is-data-descriptor/package.json
generated
vendored
Normal file
|
@ -0,0 +1,60 @@
|
|||
{
|
||||
"name": "is-data-descriptor",
|
||||
"description": "Returns true if a value has the characteristics of a valid JavaScript data descriptor.",
|
||||
"version": "0.1.4",
|
||||
"homepage": "https://github.com/jonschlinkert/is-data-descriptor",
|
||||
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
|
||||
"repository": "jonschlinkert/is-data-descriptor",
|
||||
"bugs": {
|
||||
"url": "https://github.com/jonschlinkert/is-data-descriptor/issues"
|
||||
},
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"main": "index.js",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"dependencies": {
|
||||
"kind-of": "^3.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"mocha": "*",
|
||||
"should": "*"
|
||||
},
|
||||
"keywords": [
|
||||
"accessor",
|
||||
"check",
|
||||
"data",
|
||||
"descriptor",
|
||||
"get",
|
||||
"getter",
|
||||
"is",
|
||||
"keys",
|
||||
"object",
|
||||
"properties",
|
||||
"property",
|
||||
"set",
|
||||
"setter",
|
||||
"type",
|
||||
"valid",
|
||||
"value"
|
||||
],
|
||||
"verb": {
|
||||
"related": {
|
||||
"list": [
|
||||
"is-accessor-descriptor",
|
||||
"is-data-descriptor",
|
||||
"is-descriptor",
|
||||
"isobject"
|
||||
]
|
||||
},
|
||||
"plugins": [
|
||||
"gulp-format-md"
|
||||
]
|
||||
}
|
||||
}
|
21
node_modules/snapdragon/node_modules/is-descriptor/LICENSE
generated
vendored
Normal file
21
node_modules/snapdragon/node_modules/is-descriptor/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015-2017, Jon Schlinkert.
|
||||
|
||||
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.
|
193
node_modules/snapdragon/node_modules/is-descriptor/README.md
generated
vendored
Normal file
193
node_modules/snapdragon/node_modules/is-descriptor/README.md
generated
vendored
Normal file
|
@ -0,0 +1,193 @@
|
|||
# is-descriptor [](https://www.npmjs.com/package/is-descriptor) [](https://npmjs.org/package/is-descriptor) [](https://npmjs.org/package/is-descriptor) [](https://travis-ci.org/jonschlinkert/is-descriptor)
|
||||
|
||||
> Returns true if a value has the characteristics of a valid JavaScript descriptor. Works for data descriptors and accessor descriptors.
|
||||
|
||||
## Install
|
||||
|
||||
Install with [npm](https://www.npmjs.com/):
|
||||
|
||||
```sh
|
||||
$ npm install --save is-descriptor
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var isDescriptor = require('is-descriptor');
|
||||
|
||||
isDescriptor({value: 'foo'})
|
||||
//=> true
|
||||
isDescriptor({get: function(){}, set: function(){}})
|
||||
//=> true
|
||||
isDescriptor({get: 'foo', set: function(){}})
|
||||
//=> false
|
||||
```
|
||||
|
||||
You may also check for a descriptor by passing an object as the first argument and property name (`string`) as the second argument.
|
||||
|
||||
```js
|
||||
var obj = {};
|
||||
obj.foo = 'abc';
|
||||
|
||||
Object.defineProperty(obj, 'bar', {
|
||||
value: 'xyz'
|
||||
});
|
||||
|
||||
isDescriptor(obj, 'foo');
|
||||
//=> true
|
||||
isDescriptor(obj, 'bar');
|
||||
//=> true
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
### value type
|
||||
|
||||
`false` when not an object
|
||||
|
||||
```js
|
||||
isDescriptor('a');
|
||||
//=> false
|
||||
isDescriptor(null);
|
||||
//=> false
|
||||
isDescriptor([]);
|
||||
//=> false
|
||||
```
|
||||
|
||||
### data descriptor
|
||||
|
||||
`true` when the object has valid properties with valid values.
|
||||
|
||||
```js
|
||||
isDescriptor({value: 'foo'});
|
||||
//=> true
|
||||
isDescriptor({value: noop});
|
||||
//=> true
|
||||
```
|
||||
|
||||
`false` when the object has invalid properties
|
||||
|
||||
```js
|
||||
isDescriptor({value: 'foo', bar: 'baz'});
|
||||
//=> false
|
||||
isDescriptor({value: 'foo', bar: 'baz'});
|
||||
//=> false
|
||||
isDescriptor({value: 'foo', get: noop});
|
||||
//=> false
|
||||
isDescriptor({get: noop, value: noop});
|
||||
//=> false
|
||||
```
|
||||
|
||||
`false` when a value is not the correct type
|
||||
|
||||
```js
|
||||
isDescriptor({value: 'foo', enumerable: 'foo'});
|
||||
//=> false
|
||||
isDescriptor({value: 'foo', configurable: 'foo'});
|
||||
//=> false
|
||||
isDescriptor({value: 'foo', writable: 'foo'});
|
||||
//=> false
|
||||
```
|
||||
|
||||
### accessor descriptor
|
||||
|
||||
`true` when the object has valid properties with valid values.
|
||||
|
||||
```js
|
||||
isDescriptor({get: noop, set: noop});
|
||||
//=> true
|
||||
isDescriptor({get: noop});
|
||||
//=> true
|
||||
isDescriptor({set: noop});
|
||||
//=> true
|
||||
```
|
||||
|
||||
`false` when the object has invalid properties
|
||||
|
||||
```js
|
||||
isDescriptor({get: noop, set: noop, bar: 'baz'});
|
||||
//=> false
|
||||
isDescriptor({get: noop, writable: true});
|
||||
//=> false
|
||||
isDescriptor({get: noop, value: true});
|
||||
//=> false
|
||||
```
|
||||
|
||||
`false` when an accessor is not a function
|
||||
|
||||
```js
|
||||
isDescriptor({get: noop, set: 'baz'});
|
||||
//=> false
|
||||
isDescriptor({get: 'foo', set: noop});
|
||||
//=> false
|
||||
isDescriptor({get: 'foo', bar: 'baz'});
|
||||
//=> false
|
||||
isDescriptor({get: 'foo', set: 'baz'});
|
||||
//=> false
|
||||
```
|
||||
|
||||
`false` when a value is not the correct type
|
||||
|
||||
```js
|
||||
isDescriptor({get: noop, set: noop, enumerable: 'foo'});
|
||||
//=> false
|
||||
isDescriptor({set: noop, configurable: 'foo'});
|
||||
//=> false
|
||||
isDescriptor({get: noop, configurable: 'foo'});
|
||||
//=> false
|
||||
```
|
||||
|
||||
## About
|
||||
|
||||
### Related projects
|
||||
|
||||
* [is-accessor-descriptor](https://www.npmjs.com/package/is-accessor-descriptor): Returns true if a value has the characteristics of a valid JavaScript accessor descriptor. | [homepage](https://github.com/jonschlinkert/is-accessor-descriptor "Returns true if a value has the characteristics of a valid JavaScript accessor descriptor.")
|
||||
* [is-data-descriptor](https://www.npmjs.com/package/is-data-descriptor): Returns true if a value has the characteristics of a valid JavaScript data descriptor. | [homepage](https://github.com/jonschlinkert/is-data-descriptor "Returns true if a value has the characteristics of a valid JavaScript data descriptor.")
|
||||
* [is-descriptor](https://www.npmjs.com/package/is-descriptor): Returns true if a value has the characteristics of a valid JavaScript descriptor. Works for… [more](https://github.com/jonschlinkert/is-descriptor) | [homepage](https://github.com/jonschlinkert/is-descriptor "Returns true if a value has the characteristics of a valid JavaScript descriptor. Works for data descriptors and accessor descriptors.")
|
||||
* [isobject](https://www.npmjs.com/package/isobject): Returns true if the value is an object and not an array or null. | [homepage](https://github.com/jonschlinkert/isobject "Returns true if the value is an object and not an array or null.")
|
||||
|
||||
### Contributing
|
||||
|
||||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
|
||||
|
||||
### Contributors
|
||||
|
||||
| **Commits** | **Contributor** |
|
||||
| --- | --- |
|
||||
| 24 | [jonschlinkert](https://github.com/jonschlinkert) |
|
||||
| 1 | [doowb](https://github.com/doowb) |
|
||||
| 1 | [wtgtybhertgeghgtwtg](https://github.com/wtgtybhertgeghgtwtg) |
|
||||
|
||||
### Building docs
|
||||
|
||||
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
|
||||
|
||||
To generate the readme, run the following command:
|
||||
|
||||
```sh
|
||||
$ npm install -g verbose/verb#dev verb-generate-readme && verb
|
||||
```
|
||||
|
||||
### Running tests
|
||||
|
||||
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
|
||||
|
||||
```sh
|
||||
$ npm install && npm test
|
||||
```
|
||||
|
||||
### Author
|
||||
|
||||
**Jon Schlinkert**
|
||||
|
||||
* [github/jonschlinkert](https://github.com/jonschlinkert)
|
||||
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
|
||||
|
||||
### License
|
||||
|
||||
Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
|
||||
Released under the [MIT License](LICENSE).
|
||||
|
||||
***
|
||||
|
||||
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on July 22, 2017._
|
22
node_modules/snapdragon/node_modules/is-descriptor/index.js
generated
vendored
Normal file
22
node_modules/snapdragon/node_modules/is-descriptor/index.js
generated
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
/*!
|
||||
* is-descriptor <https://github.com/jonschlinkert/is-descriptor>
|
||||
*
|
||||
* Copyright (c) 2015-2017, Jon Schlinkert.
|
||||
* Released under the MIT License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var typeOf = require('kind-of');
|
||||
var isAccessor = require('is-accessor-descriptor');
|
||||
var isData = require('is-data-descriptor');
|
||||
|
||||
module.exports = function isDescriptor(obj, key) {
|
||||
if (typeOf(obj) !== 'object') {
|
||||
return false;
|
||||
}
|
||||
if ('get' in obj) {
|
||||
return isAccessor(obj, key);
|
||||
}
|
||||
return isData(obj, key);
|
||||
};
|
75
node_modules/snapdragon/node_modules/is-descriptor/package.json
generated
vendored
Normal file
75
node_modules/snapdragon/node_modules/is-descriptor/package.json
generated
vendored
Normal file
|
@ -0,0 +1,75 @@
|
|||
{
|
||||
"name": "is-descriptor",
|
||||
"description": "Returns true if a value has the characteristics of a valid JavaScript descriptor. Works for data descriptors and accessor descriptors.",
|
||||
"version": "0.1.6",
|
||||
"homepage": "https://github.com/jonschlinkert/is-descriptor",
|
||||
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
|
||||
"contributors": [
|
||||
"Brian Woodward (https://twitter.com/doowb)",
|
||||
"Jon Schlinkert (http://twitter.com/jonschlinkert)",
|
||||
"(https://github.com/wtgtybhertgeghgtwtg)"
|
||||
],
|
||||
"repository": "jonschlinkert/is-descriptor",
|
||||
"bugs": {
|
||||
"url": "https://github.com/jonschlinkert/is-descriptor/issues"
|
||||
},
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"main": "index.js",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"dependencies": {
|
||||
"is-accessor-descriptor": "^0.1.6",
|
||||
"is-data-descriptor": "^0.1.4",
|
||||
"kind-of": "^5.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"gulp-format-md": "^1.0.0",
|
||||
"mocha": "^3.4.2"
|
||||
},
|
||||
"keywords": [
|
||||
"accessor",
|
||||
"check",
|
||||
"data",
|
||||
"descriptor",
|
||||
"get",
|
||||
"getter",
|
||||
"is",
|
||||
"keys",
|
||||
"object",
|
||||
"properties",
|
||||
"property",
|
||||
"set",
|
||||
"setter",
|
||||
"type",
|
||||
"valid",
|
||||
"value"
|
||||
],
|
||||
"verb": {
|
||||
"related": {
|
||||
"list": [
|
||||
"is-accessor-descriptor",
|
||||
"is-data-descriptor",
|
||||
"is-descriptor",
|
||||
"isobject"
|
||||
]
|
||||
},
|
||||
"plugins": [
|
||||
"gulp-format-md"
|
||||
],
|
||||
"toc": false,
|
||||
"layout": "default",
|
||||
"tasks": [
|
||||
"readme"
|
||||
],
|
||||
"lint": {
|
||||
"reflinks": true
|
||||
}
|
||||
}
|
||||
}
|
21
node_modules/snapdragon/node_modules/is-extendable/LICENSE
generated
vendored
Normal file
21
node_modules/snapdragon/node_modules/is-extendable/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015, Jon Schlinkert.
|
||||
|
||||
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.
|
72
node_modules/snapdragon/node_modules/is-extendable/README.md
generated
vendored
Normal file
72
node_modules/snapdragon/node_modules/is-extendable/README.md
generated
vendored
Normal file
|
@ -0,0 +1,72 @@
|
|||
# is-extendable [](http://badge.fury.io/js/is-extendable)
|
||||
|
||||
> Returns true if a value is any of the object types: array, regexp, plain object, function or date. This is useful for determining if a value can be extended, e.g. "can the value have keys?"
|
||||
|
||||
## Install
|
||||
|
||||
Install with [npm](https://www.npmjs.com/)
|
||||
|
||||
```sh
|
||||
$ npm i is-extendable --save
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var isExtendable = require('is-extendable');
|
||||
```
|
||||
|
||||
Returns true if the value is any of the following:
|
||||
|
||||
* `array`
|
||||
* `regexp`
|
||||
* `plain object`
|
||||
* `function`
|
||||
* `date`
|
||||
* `error`
|
||||
|
||||
## Notes
|
||||
|
||||
All objects in JavaScript can have keys, but it's a pain to check for this, since we ether need to verify that the value is not `null` or `undefined` and:
|
||||
|
||||
* the value is not a primitive, or
|
||||
* that the object is an `object`, `function`
|
||||
|
||||
Also note that an `extendable` object is not the same as an [extensible object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isExtensible), which is one that (in es6) is not sealed, frozen, or marked as non-extensible using `preventExtensions`.
|
||||
|
||||
## Related projects
|
||||
|
||||
* [assign-deep](https://github.com/jonschlinkert/assign-deep): Deeply assign the enumerable properties of source objects to a destination object.
|
||||
* [extend-shallow](https://github.com/jonschlinkert/extend-shallow): Extend an object with the properties of additional objects. node.js/javascript util.
|
||||
* [isobject](https://github.com/jonschlinkert/isobject): Returns true if the value is an object and not an array or null.
|
||||
* [is-plain-object](https://github.com/jonschlinkert/is-plain-object): Returns true if an object was created by the `Object` constructor.
|
||||
* [is-equal-shallow](https://github.com/jonschlinkert/is-equal-shallow): Does a shallow comparison of two objects, returning false if the keys or values differ.
|
||||
* [kind-of](https://github.com/jonschlinkert/kind-of): Get the native type of a value.
|
||||
|
||||
## Running tests
|
||||
|
||||
Install dev dependencies:
|
||||
|
||||
```sh
|
||||
$ npm i -d && npm test
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/is-extendable/issues/new)
|
||||
|
||||
## Author
|
||||
|
||||
**Jon Schlinkert**
|
||||
|
||||
+ [github/jonschlinkert](https://github.com/jonschlinkert)
|
||||
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
|
||||
|
||||
## License
|
||||
|
||||
Copyright © 2015 Jon Schlinkert
|
||||
Released under the MIT license.
|
||||
|
||||
***
|
||||
|
||||
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on July 04, 2015._
|
13
node_modules/snapdragon/node_modules/is-extendable/index.js
generated
vendored
Normal file
13
node_modules/snapdragon/node_modules/is-extendable/index.js
generated
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
/*!
|
||||
* is-extendable <https://github.com/jonschlinkert/is-extendable>
|
||||
*
|
||||
* Copyright (c) 2015, Jon Schlinkert.
|
||||
* Licensed under the MIT License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = function isExtendable(val) {
|
||||
return typeof val !== 'undefined' && val !== null
|
||||
&& (typeof val === 'object' || typeof val === 'function');
|
||||
};
|
51
node_modules/snapdragon/node_modules/is-extendable/package.json
generated
vendored
Normal file
51
node_modules/snapdragon/node_modules/is-extendable/package.json
generated
vendored
Normal file
|
@ -0,0 +1,51 @@
|
|||
{
|
||||
"name": "is-extendable",
|
||||
"description": "Returns true if a value is any of the object types: array, regexp, plain object, function or date. This is useful for determining if a value can be extended, e.g. \"can the value have keys?\"",
|
||||
"version": "0.1.1",
|
||||
"homepage": "https://github.com/jonschlinkert/is-extendable",
|
||||
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
|
||||
"repository": "jonschlinkert/is-extendable",
|
||||
"bugs": {
|
||||
"url": "https://github.com/jonschlinkert/is-extendable/issues"
|
||||
},
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"main": "index.js",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"devDependencies": {
|
||||
"mocha": "*"
|
||||
},
|
||||
"keywords": [
|
||||
"array",
|
||||
"assign",
|
||||
"check",
|
||||
"date",
|
||||
"extend",
|
||||
"extensible",
|
||||
"function",
|
||||
"is",
|
||||
"object",
|
||||
"regex",
|
||||
"test"
|
||||
],
|
||||
"verbiage": {
|
||||
"related": {
|
||||
"list": [
|
||||
"isobject",
|
||||
"is-plain-object",
|
||||
"kind-of",
|
||||
"is-extendable",
|
||||
"is-equal-shallow",
|
||||
"extend-shallow",
|
||||
"assign-deep"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
21
node_modules/snapdragon/node_modules/kind-of/LICENSE
generated
vendored
Normal file
21
node_modules/snapdragon/node_modules/kind-of/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014-2017, Jon Schlinkert.
|
||||
|
||||
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.
|
342
node_modules/snapdragon/node_modules/kind-of/README.md
generated
vendored
Normal file
342
node_modules/snapdragon/node_modules/kind-of/README.md
generated
vendored
Normal file
|
@ -0,0 +1,342 @@
|
|||
# kind-of [](https://www.npmjs.com/package/kind-of) [](https://npmjs.org/package/kind-of) [](https://npmjs.org/package/kind-of) [](https://travis-ci.org/jonschlinkert/kind-of)
|
||||
|
||||
> Get the native type of a value.
|
||||
|
||||
Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.
|
||||
|
||||
## Install
|
||||
|
||||
Install with [npm](https://www.npmjs.com/):
|
||||
|
||||
```sh
|
||||
$ npm install --save kind-of
|
||||
```
|
||||
|
||||
Install with [bower](https://bower.io/)
|
||||
|
||||
```sh
|
||||
$ bower install kind-of --save
|
||||
```
|
||||
|
||||
## Why use this?
|
||||
|
||||
1. [it's fast](#benchmarks) | [optimizations](#optimizations)
|
||||
2. [better type checking](#better-type-checking)
|
||||
|
||||
## Usage
|
||||
|
||||
> es5, browser and es6 ready
|
||||
|
||||
```js
|
||||
var kindOf = require('kind-of');
|
||||
|
||||
kindOf(undefined);
|
||||
//=> 'undefined'
|
||||
|
||||
kindOf(null);
|
||||
//=> 'null'
|
||||
|
||||
kindOf(true);
|
||||
//=> 'boolean'
|
||||
|
||||
kindOf(false);
|
||||
//=> 'boolean'
|
||||
|
||||
kindOf(new Boolean(true));
|
||||
//=> 'boolean'
|
||||
|
||||
kindOf(new Buffer(''));
|
||||
//=> 'buffer'
|
||||
|
||||
kindOf(42);
|
||||
//=> 'number'
|
||||
|
||||
kindOf(new Number(42));
|
||||
//=> 'number'
|
||||
|
||||
kindOf('str');
|
||||
//=> 'string'
|
||||
|
||||
kindOf(new String('str'));
|
||||
//=> 'string'
|
||||
|
||||
kindOf(arguments);
|
||||
//=> 'arguments'
|
||||
|
||||
kindOf({});
|
||||
//=> 'object'
|
||||
|
||||
kindOf(Object.create(null));
|
||||
//=> 'object'
|
||||
|
||||
kindOf(new Test());
|
||||
//=> 'object'
|
||||
|
||||
kindOf(new Date());
|
||||
//=> 'date'
|
||||
|
||||
kindOf([]);
|
||||
//=> 'array'
|
||||
|
||||
kindOf([1, 2, 3]);
|
||||
//=> 'array'
|
||||
|
||||
kindOf(new Array());
|
||||
//=> 'array'
|
||||
|
||||
kindOf(/foo/);
|
||||
//=> 'regexp'
|
||||
|
||||
kindOf(new RegExp('foo'));
|
||||
//=> 'regexp'
|
||||
|
||||
kindOf(function () {});
|
||||
//=> 'function'
|
||||
|
||||
kindOf(function * () {});
|
||||
//=> 'function'
|
||||
|
||||
kindOf(new Function());
|
||||
//=> 'function'
|
||||
|
||||
kindOf(new Map());
|
||||
//=> 'map'
|
||||
|
||||
kindOf(new WeakMap());
|
||||
//=> 'weakmap'
|
||||
|
||||
kindOf(new Set());
|
||||
//=> 'set'
|
||||
|
||||
kindOf(new WeakSet());
|
||||
//=> 'weakset'
|
||||
|
||||
kindOf(Symbol('str'));
|
||||
//=> 'symbol'
|
||||
|
||||
kindOf(new Int8Array());
|
||||
//=> 'int8array'
|
||||
|
||||
kindOf(new Uint8Array());
|
||||
//=> 'uint8array'
|
||||
|
||||
kindOf(new Uint8ClampedArray());
|
||||
//=> 'uint8clampedarray'
|
||||
|
||||
kindOf(new Int16Array());
|
||||
//=> 'int16array'
|
||||
|
||||
kindOf(new Uint16Array());
|
||||
//=> 'uint16array'
|
||||
|
||||
kindOf(new Int32Array());
|
||||
//=> 'int32array'
|
||||
|
||||
kindOf(new Uint32Array());
|
||||
//=> 'uint32array'
|
||||
|
||||
kindOf(new Float32Array());
|
||||
//=> 'float32array'
|
||||
|
||||
kindOf(new Float64Array());
|
||||
//=> 'float64array'
|
||||
```
|
||||
|
||||
## Release history
|
||||
|
||||
### v4.0.0
|
||||
|
||||
**Added**
|
||||
|
||||
* `promise` support
|
||||
|
||||
### v5.0.0
|
||||
|
||||
**Added**
|
||||
|
||||
* `Set Iterator` and `Map Iterator` support
|
||||
|
||||
**Fixed**
|
||||
|
||||
* Now returns `generatorfunction` for generator functions
|
||||
|
||||
## Benchmarks
|
||||
|
||||
Benchmarked against [typeof](http://github.com/CodingFu/typeof) and [type-of](https://github.com/ForbesLindesay/type-of).
|
||||
Note that performaces is slower for es6 features `Map`, `WeakMap`, `Set` and `WeakSet`.
|
||||
|
||||
```bash
|
||||
#1: array
|
||||
current x 23,329,397 ops/sec ±0.82% (94 runs sampled)
|
||||
lib-type-of x 4,170,273 ops/sec ±0.55% (94 runs sampled)
|
||||
lib-typeof x 9,686,935 ops/sec ±0.59% (98 runs sampled)
|
||||
|
||||
#2: boolean
|
||||
current x 27,197,115 ops/sec ±0.85% (94 runs sampled)
|
||||
lib-type-of x 3,145,791 ops/sec ±0.73% (97 runs sampled)
|
||||
lib-typeof x 9,199,562 ops/sec ±0.44% (99 runs sampled)
|
||||
|
||||
#3: date
|
||||
current x 20,190,117 ops/sec ±0.86% (92 runs sampled)
|
||||
lib-type-of x 5,166,970 ops/sec ±0.74% (94 runs sampled)
|
||||
lib-typeof x 9,610,821 ops/sec ±0.50% (96 runs sampled)
|
||||
|
||||
#4: function
|
||||
current x 23,855,460 ops/sec ±0.60% (97 runs sampled)
|
||||
lib-type-of x 5,667,740 ops/sec ±0.54% (100 runs sampled)
|
||||
lib-typeof x 10,010,644 ops/sec ±0.44% (100 runs sampled)
|
||||
|
||||
#5: null
|
||||
current x 27,061,047 ops/sec ±0.97% (96 runs sampled)
|
||||
lib-type-of x 13,965,573 ops/sec ±0.62% (97 runs sampled)
|
||||
lib-typeof x 8,460,194 ops/sec ±0.61% (97 runs sampled)
|
||||
|
||||
#6: number
|
||||
current x 25,075,682 ops/sec ±0.53% (99 runs sampled)
|
||||
lib-type-of x 2,266,405 ops/sec ±0.41% (98 runs sampled)
|
||||
lib-typeof x 9,821,481 ops/sec ±0.45% (99 runs sampled)
|
||||
|
||||
#7: object
|
||||
current x 3,348,980 ops/sec ±0.49% (99 runs sampled)
|
||||
lib-type-of x 3,245,138 ops/sec ±0.60% (94 runs sampled)
|
||||
lib-typeof x 9,262,952 ops/sec ±0.59% (99 runs sampled)
|
||||
|
||||
#8: regex
|
||||
current x 21,284,827 ops/sec ±0.72% (96 runs sampled)
|
||||
lib-type-of x 4,689,241 ops/sec ±0.43% (100 runs sampled)
|
||||
lib-typeof x 8,957,593 ops/sec ±0.62% (98 runs sampled)
|
||||
|
||||
#9: string
|
||||
current x 25,379,234 ops/sec ±0.58% (96 runs sampled)
|
||||
lib-type-of x 3,635,148 ops/sec ±0.76% (93 runs sampled)
|
||||
lib-typeof x 9,494,134 ops/sec ±0.49% (98 runs sampled)
|
||||
|
||||
#10: undef
|
||||
current x 27,459,221 ops/sec ±1.01% (93 runs sampled)
|
||||
lib-type-of x 14,360,433 ops/sec ±0.52% (99 runs sampled)
|
||||
lib-typeof x 23,202,868 ops/sec ±0.59% (94 runs sampled)
|
||||
|
||||
```
|
||||
|
||||
## Optimizations
|
||||
|
||||
In 7 out of 8 cases, this library is 2x-10x faster than other top libraries included in the benchmarks. There are a few things that lead to this performance advantage, none of them hard and fast rules, but all of them simple and repeatable in almost any code library:
|
||||
|
||||
1. Optimize around the fastest and most common use cases first. Of course, this will change from project-to-project, but I took some time to understand how and why `typeof` checks were being used in my own libraries and other libraries I use a lot.
|
||||
2. Optimize around bottlenecks - In other words, the order in which conditionals are implemented is significant, because each check is only as fast as the failing checks that came before it. Here, the biggest bottleneck by far is checking for plain objects (an object that was created by the `Object` constructor). I opted to make this check happen by process of elimination rather than brute force up front (e.g. by using something like `val.constructor.name`), so that every other type check would not be penalized it.
|
||||
3. Don't do uneccessary processing - why do `.slice(8, -1).toLowerCase();` just to get the word `regex`? It's much faster to do `if (type === '[object RegExp]') return 'regex'`
|
||||
4. There is no reason to make the code in a microlib as terse as possible, just to win points for making it shorter. It's always better to favor performant code over terse code. You will always only be using a single `require()` statement to use the library anyway, regardless of how the code is written.
|
||||
|
||||
## Better type checking
|
||||
|
||||
kind-of is more correct than other type checking libs I've looked at. For example, here are some differing results from other popular libs:
|
||||
|
||||
### [typeof](https://github.com/CodingFu/typeof) lib
|
||||
|
||||
Incorrectly tests instances of custom constructors (pretty common):
|
||||
|
||||
```js
|
||||
var typeOf = require('typeof');
|
||||
function Test() {}
|
||||
console.log(typeOf(new Test()));
|
||||
//=> 'test'
|
||||
```
|
||||
|
||||
Returns `object` instead of `arguments`:
|
||||
|
||||
```js
|
||||
function foo() {
|
||||
console.log(typeOf(arguments)) //=> 'object'
|
||||
}
|
||||
foo();
|
||||
```
|
||||
|
||||
### [type-of](https://github.com/ForbesLindesay/type-of) lib
|
||||
|
||||
Incorrectly returns `object` for generator functions, buffers, `Map`, `Set`, `WeakMap` and `WeakSet`:
|
||||
|
||||
```js
|
||||
function * foo() {}
|
||||
console.log(typeOf(foo));
|
||||
//=> 'object'
|
||||
console.log(typeOf(new Buffer('')));
|
||||
//=> 'object'
|
||||
console.log(typeOf(new Map()));
|
||||
//=> 'object'
|
||||
console.log(typeOf(new Set()));
|
||||
//=> 'object'
|
||||
console.log(typeOf(new WeakMap()));
|
||||
//=> 'object'
|
||||
console.log(typeOf(new WeakSet()));
|
||||
//=> 'object'
|
||||
```
|
||||
|
||||
## About
|
||||
|
||||
<details>
|
||||
<summary><strong>Contributing</strong></summary>
|
||||
|
||||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
|
||||
|
||||
<details>
|
||||
|
||||
<details>
|
||||
<summary><strong>Running Tests</strong></summary>
|
||||
|
||||
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
|
||||
|
||||
```sh
|
||||
$ npm install && npm test
|
||||
```
|
||||
|
||||
<details>
|
||||
|
||||
<details>
|
||||
<summary><strong>Building docs</strong></summary>
|
||||
|
||||
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
|
||||
|
||||
To generate the readme, run the following command:
|
||||
|
||||
```sh
|
||||
$ npm install -g verbose/verb#dev verb-generate-readme && verb
|
||||
```
|
||||
|
||||
<details>
|
||||
|
||||
### Related projects
|
||||
|
||||
You might also be interested in these projects:
|
||||
|
||||
* [is-glob](https://www.npmjs.com/package/is-glob): Returns `true` if the given string looks like a glob pattern or an extglob pattern… [more](https://github.com/jonschlinkert/is-glob) | [homepage](https://github.com/jonschlinkert/is-glob "Returns `true` if the given string looks like a glob pattern or an extglob pattern. This makes it easy to create code that only uses external modules like node-glob when necessary, resulting in much faster code execution and initialization time, and a bet")
|
||||
* [is-number](https://www.npmjs.com/package/is-number): Returns true if the value is a number. comprehensive tests. | [homepage](https://github.com/jonschlinkert/is-number "Returns true if the value is a number. comprehensive tests.")
|
||||
* [is-primitive](https://www.npmjs.com/package/is-primitive): Returns `true` if the value is a primitive. | [homepage](https://github.com/jonschlinkert/is-primitive "Returns `true` if the value is a primitive. ")
|
||||
|
||||
### Contributors
|
||||
|
||||
| **Commits** | **Contributor** |
|
||||
| --- | --- |
|
||||
| 82 | [jonschlinkert](https://github.com/jonschlinkert) |
|
||||
| 3 | [aretecode](https://github.com/aretecode) |
|
||||
| 2 | [miguelmota](https://github.com/miguelmota) |
|
||||
| 1 | [dtothefp](https://github.com/dtothefp) |
|
||||
| 1 | [ksheedlo](https://github.com/ksheedlo) |
|
||||
| 1 | [pdehaan](https://github.com/pdehaan) |
|
||||
| 1 | [laggingreflex](https://github.com/laggingreflex) |
|
||||
| 1 | [charlike](https://github.com/charlike) |
|
||||
|
||||
### Author
|
||||
|
||||
**Jon Schlinkert**
|
||||
|
||||
* [github/jonschlinkert](https://github.com/jonschlinkert)
|
||||
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
|
||||
|
||||
### License
|
||||
|
||||
Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
|
||||
Released under the [MIT License](LICENSE).
|
||||
|
||||
***
|
||||
|
||||
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on October 13, 2017._
|
147
node_modules/snapdragon/node_modules/kind-of/index.js
generated
vendored
Normal file
147
node_modules/snapdragon/node_modules/kind-of/index.js
generated
vendored
Normal file
|
@ -0,0 +1,147 @@
|
|||
var toString = Object.prototype.toString;
|
||||
|
||||
/**
|
||||
* Get the native `typeof` a value.
|
||||
*
|
||||
* @param {*} `val`
|
||||
* @return {*} Native javascript type
|
||||
*/
|
||||
|
||||
module.exports = function kindOf(val) {
|
||||
var type = typeof val;
|
||||
|
||||
// primitivies
|
||||
if (type === 'undefined') {
|
||||
return 'undefined';
|
||||
}
|
||||
if (val === null) {
|
||||
return 'null';
|
||||
}
|
||||
if (val === true || val === false || val instanceof Boolean) {
|
||||
return 'boolean';
|
||||
}
|
||||
if (type === 'string' || val instanceof String) {
|
||||
return 'string';
|
||||
}
|
||||
if (type === 'number' || val instanceof Number) {
|
||||
return 'number';
|
||||
}
|
||||
|
||||
// functions
|
||||
if (type === 'function' || val instanceof Function) {
|
||||
if (typeof val.constructor.name !== 'undefined' && val.constructor.name.slice(0, 9) === 'Generator') {
|
||||
return 'generatorfunction';
|
||||
}
|
||||
return 'function';
|
||||
}
|
||||
|
||||
// array
|
||||
if (typeof Array.isArray !== 'undefined' && Array.isArray(val)) {
|
||||
return 'array';
|
||||
}
|
||||
|
||||
// check for instances of RegExp and Date before calling `toString`
|
||||
if (val instanceof RegExp) {
|
||||
return 'regexp';
|
||||
}
|
||||
if (val instanceof Date) {
|
||||
return 'date';
|
||||
}
|
||||
|
||||
// other objects
|
||||
type = toString.call(val);
|
||||
|
||||
if (type === '[object RegExp]') {
|
||||
return 'regexp';
|
||||
}
|
||||
if (type === '[object Date]') {
|
||||
return 'date';
|
||||
}
|
||||
if (type === '[object Arguments]') {
|
||||
return 'arguments';
|
||||
}
|
||||
if (type === '[object Error]') {
|
||||
return 'error';
|
||||
}
|
||||
if (type === '[object Promise]') {
|
||||
return 'promise';
|
||||
}
|
||||
|
||||
// buffer
|
||||
if (isBuffer(val)) {
|
||||
return 'buffer';
|
||||
}
|
||||
|
||||
// es6: Map, WeakMap, Set, WeakSet
|
||||
if (type === '[object Set]') {
|
||||
return 'set';
|
||||
}
|
||||
if (type === '[object WeakSet]') {
|
||||
return 'weakset';
|
||||
}
|
||||
if (type === '[object Map]') {
|
||||
return 'map';
|
||||
}
|
||||
if (type === '[object WeakMap]') {
|
||||
return 'weakmap';
|
||||
}
|
||||
if (type === '[object Symbol]') {
|
||||
return 'symbol';
|
||||
}
|
||||
|
||||
if (type === '[object Map Iterator]') {
|
||||
return 'mapiterator';
|
||||
}
|
||||
if (type === '[object Set Iterator]') {
|
||||
return 'setiterator';
|
||||
}
|
||||
if (type === '[object String Iterator]') {
|
||||
return 'stringiterator';
|
||||
}
|
||||
if (type === '[object Array Iterator]') {
|
||||
return 'arrayiterator';
|
||||
}
|
||||
|
||||
// typed arrays
|
||||
if (type === '[object Int8Array]') {
|
||||
return 'int8array';
|
||||
}
|
||||
if (type === '[object Uint8Array]') {
|
||||
return 'uint8array';
|
||||
}
|
||||
if (type === '[object Uint8ClampedArray]') {
|
||||
return 'uint8clampedarray';
|
||||
}
|
||||
if (type === '[object Int16Array]') {
|
||||
return 'int16array';
|
||||
}
|
||||
if (type === '[object Uint16Array]') {
|
||||
return 'uint16array';
|
||||
}
|
||||
if (type === '[object Int32Array]') {
|
||||
return 'int32array';
|
||||
}
|
||||
if (type === '[object Uint32Array]') {
|
||||
return 'uint32array';
|
||||
}
|
||||
if (type === '[object Float32Array]') {
|
||||
return 'float32array';
|
||||
}
|
||||
if (type === '[object Float64Array]') {
|
||||
return 'float64array';
|
||||
}
|
||||
|
||||
// must be a plain object
|
||||
return 'object';
|
||||
};
|
||||
|
||||
/**
|
||||
* If you need to support Safari 5-7 (8-10 yr-old browser),
|
||||
* take a look at https://github.com/feross/is-buffer
|
||||
*/
|
||||
|
||||
function isBuffer(val) {
|
||||
return val.constructor
|
||||
&& typeof val.constructor.isBuffer === 'function'
|
||||
&& val.constructor.isBuffer(val);
|
||||
}
|
91
node_modules/snapdragon/node_modules/kind-of/package.json
generated
vendored
Normal file
91
node_modules/snapdragon/node_modules/kind-of/package.json
generated
vendored
Normal file
|
@ -0,0 +1,91 @@
|
|||
{
|
||||
"name": "kind-of",
|
||||
"description": "Get the native type of a value.",
|
||||
"version": "5.1.0",
|
||||
"homepage": "https://github.com/jonschlinkert/kind-of",
|
||||
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
|
||||
"contributors": [
|
||||
"David Fox-Powell (https://dtothefp.github.io/me)",
|
||||
"James (https://twitter.com/aretecode)",
|
||||
"Jon Schlinkert (http://twitter.com/jonschlinkert)",
|
||||
"Ken Sheedlo (kensheedlo.com)",
|
||||
"laggingreflex (https://github.com/laggingreflex)",
|
||||
"Miguel Mota (https://miguelmota.com)",
|
||||
"Peter deHaan (http://about.me/peterdehaan)",
|
||||
"tunnckoCore (https://i.am.charlike.online)"
|
||||
],
|
||||
"repository": "jonschlinkert/kind-of",
|
||||
"bugs": {
|
||||
"url": "https://github.com/jonschlinkert/kind-of/issues"
|
||||
},
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"main": "index.js",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha",
|
||||
"prepublish": "browserify -o browser.js -e index.js -s index --bare"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ansi-bold": "^0.1.1",
|
||||
"benchmarked": "^1.1.1",
|
||||
"browserify": "^14.4.0",
|
||||
"gulp-format-md": "^0.1.12",
|
||||
"matched": "^0.4.4",
|
||||
"mocha": "^3.4.2",
|
||||
"type-of": "^2.0.1",
|
||||
"typeof": "^1.0.0"
|
||||
},
|
||||
"keywords": [
|
||||
"arguments",
|
||||
"array",
|
||||
"boolean",
|
||||
"check",
|
||||
"date",
|
||||
"function",
|
||||
"is",
|
||||
"is-type",
|
||||
"is-type-of",
|
||||
"kind",
|
||||
"kind-of",
|
||||
"number",
|
||||
"object",
|
||||
"of",
|
||||
"regexp",
|
||||
"string",
|
||||
"test",
|
||||
"type",
|
||||
"type-of",
|
||||
"typeof",
|
||||
"types"
|
||||
],
|
||||
"verb": {
|
||||
"related": {
|
||||
"list": [
|
||||
"is-glob",
|
||||
"is-number",
|
||||
"is-primitive"
|
||||
]
|
||||
},
|
||||
"toc": false,
|
||||
"layout": "default",
|
||||
"tasks": [
|
||||
"readme"
|
||||
],
|
||||
"plugins": [
|
||||
"gulp-format-md"
|
||||
],
|
||||
"lint": {
|
||||
"reflinks": true
|
||||
},
|
||||
"reflinks": [
|
||||
"type-of",
|
||||
"typeof",
|
||||
"verb"
|
||||
]
|
||||
}
|
||||
}
|
152
node_modules/snapdragon/node_modules/ms/index.js
generated
vendored
Normal file
152
node_modules/snapdragon/node_modules/ms/index.js
generated
vendored
Normal file
|
@ -0,0 +1,152 @@
|
|||
/**
|
||||
* Helpers.
|
||||
*/
|
||||
|
||||
var s = 1000;
|
||||
var m = s * 60;
|
||||
var h = m * 60;
|
||||
var d = h * 24;
|
||||
var y = d * 365.25;
|
||||
|
||||
/**
|
||||
* Parse or format the given `val`.
|
||||
*
|
||||
* Options:
|
||||
*
|
||||
* - `long` verbose formatting [false]
|
||||
*
|
||||
* @param {String|Number} val
|
||||
* @param {Object} [options]
|
||||
* @throws {Error} throw an error if val is not a non-empty string or a number
|
||||
* @return {String|Number}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
module.exports = function(val, options) {
|
||||
options = options || {};
|
||||
var type = typeof val;
|
||||
if (type === 'string' && val.length > 0) {
|
||||
return parse(val);
|
||||
} else if (type === 'number' && isNaN(val) === false) {
|
||||
return options.long ? fmtLong(val) : fmtShort(val);
|
||||
}
|
||||
throw new Error(
|
||||
'val is not a non-empty string or a valid number. val=' +
|
||||
JSON.stringify(val)
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Parse the given `str` and return milliseconds.
|
||||
*
|
||||
* @param {String} str
|
||||
* @return {Number}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function parse(str) {
|
||||
str = String(str);
|
||||
if (str.length > 100) {
|
||||
return;
|
||||
}
|
||||
var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(
|
||||
str
|
||||
);
|
||||
if (!match) {
|
||||
return;
|
||||
}
|
||||
var n = parseFloat(match[1]);
|
||||
var type = (match[2] || 'ms').toLowerCase();
|
||||
switch (type) {
|
||||
case 'years':
|
||||
case 'year':
|
||||
case 'yrs':
|
||||
case 'yr':
|
||||
case 'y':
|
||||
return n * y;
|
||||
case 'days':
|
||||
case 'day':
|
||||
case 'd':
|
||||
return n * d;
|
||||
case 'hours':
|
||||
case 'hour':
|
||||
case 'hrs':
|
||||
case 'hr':
|
||||
case 'h':
|
||||
return n * h;
|
||||
case 'minutes':
|
||||
case 'minute':
|
||||
case 'mins':
|
||||
case 'min':
|
||||
case 'm':
|
||||
return n * m;
|
||||
case 'seconds':
|
||||
case 'second':
|
||||
case 'secs':
|
||||
case 'sec':
|
||||
case 's':
|
||||
return n * s;
|
||||
case 'milliseconds':
|
||||
case 'millisecond':
|
||||
case 'msecs':
|
||||
case 'msec':
|
||||
case 'ms':
|
||||
return n;
|
||||
default:
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Short format for `ms`.
|
||||
*
|
||||
* @param {Number} ms
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function fmtShort(ms) {
|
||||
if (ms >= d) {
|
||||
return Math.round(ms / d) + 'd';
|
||||
}
|
||||
if (ms >= h) {
|
||||
return Math.round(ms / h) + 'h';
|
||||
}
|
||||
if (ms >= m) {
|
||||
return Math.round(ms / m) + 'm';
|
||||
}
|
||||
if (ms >= s) {
|
||||
return Math.round(ms / s) + 's';
|
||||
}
|
||||
return ms + 'ms';
|
||||
}
|
||||
|
||||
/**
|
||||
* Long format for `ms`.
|
||||
*
|
||||
* @param {Number} ms
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function fmtLong(ms) {
|
||||
return plural(ms, d, 'day') ||
|
||||
plural(ms, h, 'hour') ||
|
||||
plural(ms, m, 'minute') ||
|
||||
plural(ms, s, 'second') ||
|
||||
ms + ' ms';
|
||||
}
|
||||
|
||||
/**
|
||||
* Pluralization helper.
|
||||
*/
|
||||
|
||||
function plural(ms, n, name) {
|
||||
if (ms < n) {
|
||||
return;
|
||||
}
|
||||
if (ms < n * 1.5) {
|
||||
return Math.floor(ms / n) + ' ' + name;
|
||||
}
|
||||
return Math.ceil(ms / n) + ' ' + name + 's';
|
||||
}
|
21
node_modules/snapdragon/node_modules/ms/license.md
generated
vendored
Normal file
21
node_modules/snapdragon/node_modules/ms/license.md
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Zeit, Inc.
|
||||
|
||||
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.
|
37
node_modules/snapdragon/node_modules/ms/package.json
generated
vendored
Normal file
37
node_modules/snapdragon/node_modules/ms/package.json
generated
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
{
|
||||
"name": "ms",
|
||||
"version": "2.0.0",
|
||||
"description": "Tiny milisecond conversion utility",
|
||||
"repository": "zeit/ms",
|
||||
"main": "./index",
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"scripts": {
|
||||
"precommit": "lint-staged",
|
||||
"lint": "eslint lib/* bin/*",
|
||||
"test": "mocha tests.js"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": "eslint:recommended",
|
||||
"env": {
|
||||
"node": true,
|
||||
"es6": true
|
||||
}
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.js": [
|
||||
"npm run lint",
|
||||
"prettier --single-quote --write",
|
||||
"git add"
|
||||
]
|
||||
},
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"eslint": "3.19.0",
|
||||
"expect.js": "0.3.1",
|
||||
"husky": "0.13.3",
|
||||
"lint-staged": "3.4.1",
|
||||
"mocha": "3.4.1"
|
||||
}
|
||||
}
|
51
node_modules/snapdragon/node_modules/ms/readme.md
generated
vendored
Normal file
51
node_modules/snapdragon/node_modules/ms/readme.md
generated
vendored
Normal file
|
@ -0,0 +1,51 @@
|
|||
# ms
|
||||
|
||||
[](https://travis-ci.org/zeit/ms)
|
||||
[](https://zeit.chat/)
|
||||
|
||||
Use this package to easily convert various time formats to milliseconds.
|
||||
|
||||
## Examples
|
||||
|
||||
```js
|
||||
ms('2 days') // 172800000
|
||||
ms('1d') // 86400000
|
||||
ms('10h') // 36000000
|
||||
ms('2.5 hrs') // 9000000
|
||||
ms('2h') // 7200000
|
||||
ms('1m') // 60000
|
||||
ms('5s') // 5000
|
||||
ms('1y') // 31557600000
|
||||
ms('100') // 100
|
||||
```
|
||||
|
||||
### Convert from milliseconds
|
||||
|
||||
```js
|
||||
ms(60000) // "1m"
|
||||
ms(2 * 60000) // "2m"
|
||||
ms(ms('10 hours')) // "10h"
|
||||
```
|
||||
|
||||
### Time format written-out
|
||||
|
||||
```js
|
||||
ms(60000, { long: true }) // "1 minute"
|
||||
ms(2 * 60000, { long: true }) // "2 minutes"
|
||||
ms(ms('10 hours'), { long: true }) // "10 hours"
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
- Works both in [node](https://nodejs.org) and in the browser.
|
||||
- If a number is supplied to `ms`, a string with a unit is returned.
|
||||
- If a string that contains the number is supplied, it returns it as a number (e.g.: it returns `100` for `'100'`).
|
||||
- If you pass a string with a number and a valid unit, the number of equivalent ms is returned.
|
||||
|
||||
## Caught a bug?
|
||||
|
||||
1. [Fork](https://help.github.com/articles/fork-a-repo/) this repository to your own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local device
|
||||
2. Link the package to the global module directory: `npm link`
|
||||
3. Within the module you want to test your local development instance of ms, just link it to the dependencies: `npm link ms`. Instead of the default one from npm, node will now use your clone of ms!
|
||||
|
||||
As always, you can run the tests using: `npm test`
|
301
node_modules/snapdragon/node_modules/source-map/CHANGELOG.md
generated
vendored
Normal file
301
node_modules/snapdragon/node_modules/source-map/CHANGELOG.md
generated
vendored
Normal file
|
@ -0,0 +1,301 @@
|
|||
# Change Log
|
||||
|
||||
## 0.5.6
|
||||
|
||||
* Fix for regression when people were using numbers as names in source maps. See
|
||||
#236.
|
||||
|
||||
## 0.5.5
|
||||
|
||||
* Fix "regression" of unsupported, implementation behavior that half the world
|
||||
happens to have come to depend on. See #235.
|
||||
|
||||
* Fix regression involving function hoisting in SpiderMonkey. See #233.
|
||||
|
||||
## 0.5.4
|
||||
|
||||
* Large performance improvements to source-map serialization. See #228 and #229.
|
||||
|
||||
## 0.5.3
|
||||
|
||||
* Do not include unnecessary distribution files. See
|
||||
commit ef7006f8d1647e0a83fdc60f04f5a7ca54886f86.
|
||||
|
||||
## 0.5.2
|
||||
|
||||
* Include browser distributions of the library in package.json's `files`. See
|
||||
issue #212.
|
||||
|
||||
## 0.5.1
|
||||
|
||||
* Fix latent bugs in IndexedSourceMapConsumer.prototype._parseMappings. See
|
||||
ff05274becc9e6e1295ed60f3ea090d31d843379.
|
||||
|
||||
## 0.5.0
|
||||
|
||||
* Node 0.8 is no longer supported.
|
||||
|
||||
* Use webpack instead of dryice for bundling.
|
||||
|
||||
* Big speedups serializing source maps. See pull request #203.
|
||||
|
||||
* Fix a bug with `SourceMapConsumer.prototype.sourceContentFor` and sources that
|
||||
explicitly start with the source root. See issue #199.
|
||||
|
||||
## 0.4.4
|
||||
|
||||
* Fix an issue where using a `SourceMapGenerator` after having created a
|
||||
`SourceMapConsumer` from it via `SourceMapConsumer.fromSourceMap` failed. See
|
||||
issue #191.
|
||||
|
||||
* Fix an issue with where `SourceMapGenerator` would mistakenly consider
|
||||
different mappings as duplicates of each other and avoid generating them. See
|
||||
issue #192.
|
||||
|
||||
## 0.4.3
|
||||
|
||||
* A very large number of performance improvements, particularly when parsing
|
||||
source maps. Collectively about 75% of time shaved off of the source map
|
||||
parsing benchmark!
|
||||
|
||||
* Fix a bug in `SourceMapConsumer.prototype.allGeneratedPositionsFor` and fuzzy
|
||||
searching in the presence of a column option. See issue #177.
|
||||
|
||||
* Fix a bug with joining a source and its source root when the source is above
|
||||
the root. See issue #182.
|
||||
|
||||
* Add the `SourceMapConsumer.prototype.hasContentsOfAllSources` method to
|
||||
determine when all sources' contents are inlined into the source map. See
|
||||
issue #190.
|
||||
|
||||
## 0.4.2
|
||||
|
||||
* Add an `.npmignore` file so that the benchmarks aren't pulled down by
|
||||
dependent projects. Issue #169.
|
||||
|
||||
* Add an optional `column` argument to
|
||||
`SourceMapConsumer.prototype.allGeneratedPositionsFor` and better handle lines
|
||||
with no mappings. Issues #172 and #173.
|
||||
|
||||
## 0.4.1
|
||||
|
||||
* Fix accidentally defining a global variable. #170.
|
||||
|
||||
## 0.4.0
|
||||
|
||||
* The default direction for fuzzy searching was changed back to its original
|
||||
direction. See #164.
|
||||
|
||||
* There is now a `bias` option you can supply to `SourceMapConsumer` to control
|
||||
the fuzzy searching direction. See #167.
|
||||
|
||||
* About an 8% speed up in parsing source maps. See #159.
|
||||
|
||||
* Added a benchmark for parsing and generating source maps.
|
||||
|
||||
## 0.3.0
|
||||
|
||||
* Change the default direction that searching for positions fuzzes when there is
|
||||
not an exact match. See #154.
|
||||
|
||||
* Support for environments using json2.js for JSON serialization. See #156.
|
||||
|
||||
## 0.2.0
|
||||
|
||||
* Support for consuming "indexed" source maps which do not have any remote
|
||||
sections. See pull request #127. This introduces a minor backwards
|
||||
incompatibility if you are monkey patching `SourceMapConsumer.prototype`
|
||||
methods.
|
||||
|
||||
## 0.1.43
|
||||
|
||||
* Performance improvements for `SourceMapGenerator` and `SourceNode`. See issue
|
||||
#148 for some discussion and issues #150, #151, and #152 for implementations.
|
||||
|
||||
## 0.1.42
|
||||
|
||||
* Fix an issue where `SourceNode`s from different versions of the source-map
|
||||
library couldn't be used in conjunction with each other. See issue #142.
|
||||
|
||||
## 0.1.41
|
||||
|
||||
* Fix a bug with getting the source content of relative sources with a "./"
|
||||
prefix. See issue #145 and [Bug 1090768](bugzil.la/1090768).
|
||||
|
||||
* Add the `SourceMapConsumer.prototype.computeColumnSpans` method to compute the
|
||||
column span of each mapping.
|
||||
|
||||
* Add the `SourceMapConsumer.prototype.allGeneratedPositionsFor` method to find
|
||||
all generated positions associated with a given original source and line.
|
||||
|
||||
## 0.1.40
|
||||
|
||||
* Performance improvements for parsing source maps in SourceMapConsumer.
|
||||
|
||||
## 0.1.39
|
||||
|
||||
* Fix a bug where setting a source's contents to null before any source content
|
||||
had been set before threw a TypeError. See issue #131.
|
||||
|
||||
## 0.1.38
|
||||
|
||||
* Fix a bug where finding relative paths from an empty path were creating
|
||||
absolute paths. See issue #129.
|
||||
|
||||
## 0.1.37
|
||||
|
||||
* Fix a bug where if the source root was an empty string, relative source paths
|
||||
would turn into absolute source paths. Issue #124.
|
||||
|
||||
## 0.1.36
|
||||
|
||||
* Allow the `names` mapping property to be an empty string. Issue #121.
|
||||
|
||||
## 0.1.35
|
||||
|
||||
* A third optional parameter was added to `SourceNode.fromStringWithSourceMap`
|
||||
to specify a path that relative sources in the second parameter should be
|
||||
relative to. Issue #105.
|
||||
|
||||
* If no file property is given to a `SourceMapGenerator`, then the resulting
|
||||
source map will no longer have a `null` file property. The property will
|
||||
simply not exist. Issue #104.
|
||||
|
||||
* Fixed a bug where consecutive newlines were ignored in `SourceNode`s.
|
||||
Issue #116.
|
||||
|
||||
## 0.1.34
|
||||
|
||||
* Make `SourceNode` work with windows style ("\r\n") newlines. Issue #103.
|
||||
|
||||
* Fix bug involving source contents and the
|
||||
`SourceMapGenerator.prototype.applySourceMap`. Issue #100.
|
||||
|
||||
## 0.1.33
|
||||
|
||||
* Fix some edge cases surrounding path joining and URL resolution.
|
||||
|
||||
* Add a third parameter for relative path to
|
||||
`SourceMapGenerator.prototype.applySourceMap`.
|
||||
|
||||
* Fix issues with mappings and EOLs.
|
||||
|
||||
## 0.1.32
|
||||
|
||||
* Fixed a bug where SourceMapConsumer couldn't handle negative relative columns
|
||||
(issue 92).
|
||||
|
||||
* Fixed test runner to actually report number of failed tests as its process
|
||||
exit code.
|
||||
|
||||
* Fixed a typo when reporting bad mappings (issue 87).
|
||||
|
||||
## 0.1.31
|
||||
|
||||
* Delay parsing the mappings in SourceMapConsumer until queried for a source
|
||||
location.
|
||||
|
||||
* Support Sass source maps (which at the time of writing deviate from the spec
|
||||
in small ways) in SourceMapConsumer.
|
||||
|
||||
## 0.1.30
|
||||
|
||||
* Do not join source root with a source, when the source is a data URI.
|
||||
|
||||
* Extend the test runner to allow running single specific test files at a time.
|
||||
|
||||
* Performance improvements in `SourceNode.prototype.walk` and
|
||||
`SourceMapConsumer.prototype.eachMapping`.
|
||||
|
||||
* Source map browser builds will now work inside Workers.
|
||||
|
||||
* Better error messages when attempting to add an invalid mapping to a
|
||||
`SourceMapGenerator`.
|
||||
|
||||
## 0.1.29
|
||||
|
||||
* Allow duplicate entries in the `names` and `sources` arrays of source maps
|
||||
(usually from TypeScript) we are parsing. Fixes github issue 72.
|
||||
|
||||
## 0.1.28
|
||||
|
||||
* Skip duplicate mappings when creating source maps from SourceNode; github
|
||||
issue 75.
|
||||
|
||||
## 0.1.27
|
||||
|
||||
* Don't throw an error when the `file` property is missing in SourceMapConsumer,
|
||||
we don't use it anyway.
|
||||
|
||||
## 0.1.26
|
||||
|
||||
* Fix SourceNode.fromStringWithSourceMap for empty maps. Fixes github issue 70.
|
||||
|
||||
## 0.1.25
|
||||
|
||||
* Make compatible with browserify
|
||||
|
||||
## 0.1.24
|
||||
|
||||
* Fix issue with absolute paths and `file://` URIs. See
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=885597
|
||||
|
||||
## 0.1.23
|
||||
|
||||
* Fix issue with absolute paths and sourcesContent, github issue 64.
|
||||
|
||||
## 0.1.22
|
||||
|
||||
* Ignore duplicate mappings in SourceMapGenerator. Fixes github issue 21.
|
||||
|
||||
## 0.1.21
|
||||
|
||||
* Fixed handling of sources that start with a slash so that they are relative to
|
||||
the source root's host.
|
||||
|
||||
## 0.1.20
|
||||
|
||||
* Fixed github issue #43: absolute URLs aren't joined with the source root
|
||||
anymore.
|
||||
|
||||
## 0.1.19
|
||||
|
||||
* Using Travis CI to run tests.
|
||||
|
||||
## 0.1.18
|
||||
|
||||
* Fixed a bug in the handling of sourceRoot.
|
||||
|
||||
## 0.1.17
|
||||
|
||||
* Added SourceNode.fromStringWithSourceMap.
|
||||
|
||||
## 0.1.16
|
||||
|
||||
* Added missing documentation.
|
||||
|
||||
* Fixed the generating of empty mappings in SourceNode.
|
||||
|
||||
## 0.1.15
|
||||
|
||||
* Added SourceMapGenerator.applySourceMap.
|
||||
|
||||
## 0.1.14
|
||||
|
||||
* The sourceRoot is now handled consistently.
|
||||
|
||||
## 0.1.13
|
||||
|
||||
* Added SourceMapGenerator.fromSourceMap.
|
||||
|
||||
## 0.1.12
|
||||
|
||||
* SourceNode now generates empty mappings too.
|
||||
|
||||
## 0.1.11
|
||||
|
||||
* Added name support to SourceNode.
|
||||
|
||||
## 0.1.10
|
||||
|
||||
* Added sourcesContent support to the customer and generator.
|
28
node_modules/snapdragon/node_modules/source-map/LICENSE
generated
vendored
Normal file
28
node_modules/snapdragon/node_modules/source-map/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
|
||||
Copyright (c) 2009-2011, Mozilla Foundation and contributors
|
||||
All rights reserved.
|
||||
|
||||
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.
|
||||
|
||||
* Neither the names of the Mozilla Foundation nor the names of project
|
||||
contributors may be used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
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 THE COPYRIGHT HOLDER OR CONTRIBUTORS 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.
|
729
node_modules/snapdragon/node_modules/source-map/README.md
generated
vendored
Normal file
729
node_modules/snapdragon/node_modules/source-map/README.md
generated
vendored
Normal file
|
@ -0,0 +1,729 @@
|
|||
# Source Map
|
||||
|
||||
[](https://travis-ci.org/mozilla/source-map)
|
||||
|
||||
[](https://www.npmjs.com/package/source-map)
|
||||
|
||||
This is a library to generate and consume the source map format
|
||||
[described here][format].
|
||||
|
||||
[format]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit
|
||||
|
||||
## Use with Node
|
||||
|
||||
$ npm install source-map
|
||||
|
||||
## Use on the Web
|
||||
|
||||
<script src="https://raw.githubusercontent.com/mozilla/source-map/master/dist/source-map.min.js" defer></script>
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
<!-- `npm run toc` to regenerate the Table of Contents -->
|
||||
|
||||
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
||||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
||||
## Table of Contents
|
||||
|
||||
- [Examples](#examples)
|
||||
- [Consuming a source map](#consuming-a-source-map)
|
||||
- [Generating a source map](#generating-a-source-map)
|
||||
- [With SourceNode (high level API)](#with-sourcenode-high-level-api)
|
||||
- [With SourceMapGenerator (low level API)](#with-sourcemapgenerator-low-level-api)
|
||||
- [API](#api)
|
||||
- [SourceMapConsumer](#sourcemapconsumer)
|
||||
- [new SourceMapConsumer(rawSourceMap)](#new-sourcemapconsumerrawsourcemap)
|
||||
- [SourceMapConsumer.prototype.computeColumnSpans()](#sourcemapconsumerprototypecomputecolumnspans)
|
||||
- [SourceMapConsumer.prototype.originalPositionFor(generatedPosition)](#sourcemapconsumerprototypeoriginalpositionforgeneratedposition)
|
||||
- [SourceMapConsumer.prototype.generatedPositionFor(originalPosition)](#sourcemapconsumerprototypegeneratedpositionfororiginalposition)
|
||||
- [SourceMapConsumer.prototype.allGeneratedPositionsFor(originalPosition)](#sourcemapconsumerprototypeallgeneratedpositionsfororiginalposition)
|
||||
- [SourceMapConsumer.prototype.hasContentsOfAllSources()](#sourcemapconsumerprototypehascontentsofallsources)
|
||||
- [SourceMapConsumer.prototype.sourceContentFor(source[, returnNullOnMissing])](#sourcemapconsumerprototypesourcecontentforsource-returnnullonmissing)
|
||||
- [SourceMapConsumer.prototype.eachMapping(callback, context, order)](#sourcemapconsumerprototypeeachmappingcallback-context-order)
|
||||
- [SourceMapGenerator](#sourcemapgenerator)
|
||||
- [new SourceMapGenerator([startOfSourceMap])](#new-sourcemapgeneratorstartofsourcemap)
|
||||
- [SourceMapGenerator.fromSourceMap(sourceMapConsumer)](#sourcemapgeneratorfromsourcemapsourcemapconsumer)
|
||||
- [SourceMapGenerator.prototype.addMapping(mapping)](#sourcemapgeneratorprototypeaddmappingmapping)
|
||||
- [SourceMapGenerator.prototype.setSourceContent(sourceFile, sourceContent)](#sourcemapgeneratorprototypesetsourcecontentsourcefile-sourcecontent)
|
||||
- [SourceMapGenerator.prototype.applySourceMap(sourceMapConsumer[, sourceFile[, sourceMapPath]])](#sourcemapgeneratorprototypeapplysourcemapsourcemapconsumer-sourcefile-sourcemappath)
|
||||
- [SourceMapGenerator.prototype.toString()](#sourcemapgeneratorprototypetostring)
|
||||
- [SourceNode](#sourcenode)
|
||||
- [new SourceNode([line, column, source[, chunk[, name]]])](#new-sourcenodeline-column-source-chunk-name)
|
||||
- [SourceNode.fromStringWithSourceMap(code, sourceMapConsumer[, relativePath])](#sourcenodefromstringwithsourcemapcode-sourcemapconsumer-relativepath)
|
||||
- [SourceNode.prototype.add(chunk)](#sourcenodeprototypeaddchunk)
|
||||
- [SourceNode.prototype.prepend(chunk)](#sourcenodeprototypeprependchunk)
|
||||
- [SourceNode.prototype.setSourceContent(sourceFile, sourceContent)](#sourcenodeprototypesetsourcecontentsourcefile-sourcecontent)
|
||||
- [SourceNode.prototype.walk(fn)](#sourcenodeprototypewalkfn)
|
||||
- [SourceNode.prototype.walkSourceContents(fn)](#sourcenodeprototypewalksourcecontentsfn)
|
||||
- [SourceNode.prototype.join(sep)](#sourcenodeprototypejoinsep)
|
||||
- [SourceNode.prototype.replaceRight(pattern, replacement)](#sourcenodeprototypereplacerightpattern-replacement)
|
||||
- [SourceNode.prototype.toString()](#sourcenodeprototypetostring)
|
||||
- [SourceNode.prototype.toStringWithSourceMap([startOfSourceMap])](#sourcenodeprototypetostringwithsourcemapstartofsourcemap)
|
||||
|
||||
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
||||
|
||||
## Examples
|
||||
|
||||
### Consuming a source map
|
||||
|
||||
```js
|
||||
var rawSourceMap = {
|
||||
version: 3,
|
||||
file: 'min.js',
|
||||
names: ['bar', 'baz', 'n'],
|
||||
sources: ['one.js', 'two.js'],
|
||||
sourceRoot: 'http://example.com/www/js/',
|
||||
mappings: 'CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID;CCDb,IAAI,IAAM,SAAUE,GAClB,OAAOA'
|
||||
};
|
||||
|
||||
var smc = new SourceMapConsumer(rawSourceMap);
|
||||
|
||||
console.log(smc.sources);
|
||||
// [ 'http://example.com/www/js/one.js',
|
||||
// 'http://example.com/www/js/two.js' ]
|
||||
|
||||
console.log(smc.originalPositionFor({
|
||||
line: 2,
|
||||
column: 28
|
||||
}));
|
||||
// { source: 'http://example.com/www/js/two.js',
|
||||
// line: 2,
|
||||
// column: 10,
|
||||
// name: 'n' }
|
||||
|
||||
console.log(smc.generatedPositionFor({
|
||||
source: 'http://example.com/www/js/two.js',
|
||||
line: 2,
|
||||
column: 10
|
||||
}));
|
||||
// { line: 2, column: 28 }
|
||||
|
||||
smc.eachMapping(function (m) {
|
||||
// ...
|
||||
});
|
||||
```
|
||||
|
||||
### Generating a source map
|
||||
|
||||
In depth guide:
|
||||
[**Compiling to JavaScript, and Debugging with Source Maps**](https://hacks.mozilla.org/2013/05/compiling-to-javascript-and-debugging-with-source-maps/)
|
||||
|
||||
#### With SourceNode (high level API)
|
||||
|
||||
```js
|
||||
function compile(ast) {
|
||||
switch (ast.type) {
|
||||
case 'BinaryExpression':
|
||||
return new SourceNode(
|
||||
ast.location.line,
|
||||
ast.location.column,
|
||||
ast.location.source,
|
||||
[compile(ast.left), " + ", compile(ast.right)]
|
||||
);
|
||||
case 'Literal':
|
||||
return new SourceNode(
|
||||
ast.location.line,
|
||||
ast.location.column,
|
||||
ast.location.source,
|
||||
String(ast.value)
|
||||
);
|
||||
// ...
|
||||
default:
|
||||
throw new Error("Bad AST");
|
||||
}
|
||||
}
|
||||
|
||||
var ast = parse("40 + 2", "add.js");
|
||||
console.log(compile(ast).toStringWithSourceMap({
|
||||
file: 'add.js'
|
||||
}));
|
||||
// { code: '40 + 2',
|
||||
// map: [object SourceMapGenerator] }
|
||||
```
|
||||
|
||||
#### With SourceMapGenerator (low level API)
|
||||
|
||||
```js
|
||||
var map = new SourceMapGenerator({
|
||||
file: "source-mapped.js"
|
||||
});
|
||||
|
||||
map.addMapping({
|
||||
generated: {
|
||||
line: 10,
|
||||
column: 35
|
||||
},
|
||||
source: "foo.js",
|
||||
original: {
|
||||
line: 33,
|
||||
column: 2
|
||||
},
|
||||
name: "christopher"
|
||||
});
|
||||
|
||||
console.log(map.toString());
|
||||
// '{"version":3,"file":"source-mapped.js","sources":["foo.js"],"names":["christopher"],"mappings":";;;;;;;;;mCAgCEA"}'
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
Get a reference to the module:
|
||||
|
||||
```js
|
||||
// Node.js
|
||||
var sourceMap = require('source-map');
|
||||
|
||||
// Browser builds
|
||||
var sourceMap = window.sourceMap;
|
||||
|
||||
// Inside Firefox
|
||||
const sourceMap = require("devtools/toolkit/sourcemap/source-map.js");
|
||||
```
|
||||
|
||||
### SourceMapConsumer
|
||||
|
||||
A SourceMapConsumer instance represents a parsed source map which we can query
|
||||
for information about the original file positions by giving it a file position
|
||||
in the generated source.
|
||||
|
||||
#### new SourceMapConsumer(rawSourceMap)
|
||||
|
||||
The only parameter is the raw source map (either as a string which can be
|
||||
`JSON.parse`'d, or an object). According to the spec, source maps have the
|
||||
following attributes:
|
||||
|
||||
* `version`: Which version of the source map spec this map is following.
|
||||
|
||||
* `sources`: An array of URLs to the original source files.
|
||||
|
||||
* `names`: An array of identifiers which can be referenced by individual
|
||||
mappings.
|
||||
|
||||
* `sourceRoot`: Optional. The URL root from which all sources are relative.
|
||||
|
||||
* `sourcesContent`: Optional. An array of contents of the original source files.
|
||||
|
||||
* `mappings`: A string of base64 VLQs which contain the actual mappings.
|
||||
|
||||
* `file`: Optional. The generated filename this source map is associated with.
|
||||
|
||||
```js
|
||||
var consumer = new sourceMap.SourceMapConsumer(rawSourceMapJsonData);
|
||||
```
|
||||
|
||||
#### SourceMapConsumer.prototype.computeColumnSpans()
|
||||
|
||||
Compute the last column for each generated mapping. The last column is
|
||||
inclusive.
|
||||
|
||||
```js
|
||||
// Before:
|
||||
consumer.allGeneratedPositionsFor({ line: 2, source: "foo.coffee" })
|
||||
// [ { line: 2,
|
||||
// column: 1 },
|
||||
// { line: 2,
|
||||
// column: 10 },
|
||||
// { line: 2,
|
||||
// column: 20 } ]
|
||||
|
||||
consumer.computeColumnSpans();
|
||||
|
||||
// After:
|
||||
consumer.allGeneratedPositionsFor({ line: 2, source: "foo.coffee" })
|
||||
// [ { line: 2,
|
||||
// column: 1,
|
||||
// lastColumn: 9 },
|
||||
// { line: 2,
|
||||
// column: 10,
|
||||
// lastColumn: 19 },
|
||||
// { line: 2,
|
||||
// column: 20,
|
||||
// lastColumn: Infinity } ]
|
||||
|
||||
```
|
||||
|
||||
#### SourceMapConsumer.prototype.originalPositionFor(generatedPosition)
|
||||
|
||||
Returns the original source, line, and column information for the generated
|
||||
source's line and column positions provided. The only argument is an object with
|
||||
the following properties:
|
||||
|
||||
* `line`: The line number in the generated source.
|
||||
|
||||
* `column`: The column number in the generated source.
|
||||
|
||||
* `bias`: Either `SourceMapConsumer.GREATEST_LOWER_BOUND` or
|
||||
`SourceMapConsumer.LEAST_UPPER_BOUND`. Specifies whether to return the closest
|
||||
element that is smaller than or greater than the one we are searching for,
|
||||
respectively, if the exact element cannot be found. Defaults to
|
||||
`SourceMapConsumer.GREATEST_LOWER_BOUND`.
|
||||
|
||||
and an object is returned with the following properties:
|
||||
|
||||
* `source`: The original source file, or null if this information is not
|
||||
available.
|
||||
|
||||
* `line`: The line number in the original source, or null if this information is
|
||||
not available.
|
||||
|
||||
* `column`: The column number in the original source, or null if this
|
||||
information is not available.
|
||||
|
||||
* `name`: The original identifier, or null if this information is not available.
|
||||
|
||||
```js
|
||||
consumer.originalPositionFor({ line: 2, column: 10 })
|
||||
// { source: 'foo.coffee',
|
||||
// line: 2,
|
||||
// column: 2,
|
||||
// name: null }
|
||||
|
||||
consumer.originalPositionFor({ line: 99999999999999999, column: 999999999999999 })
|
||||
// { source: null,
|
||||
// line: null,
|
||||
// column: null,
|
||||
// name: null }
|
||||
```
|
||||
|
||||
#### SourceMapConsumer.prototype.generatedPositionFor(originalPosition)
|
||||
|
||||
Returns the generated line and column information for the original source,
|
||||
line, and column positions provided. The only argument is an object with
|
||||
the following properties:
|
||||
|
||||
* `source`: The filename of the original source.
|
||||
|
||||
* `line`: The line number in the original source.
|
||||
|
||||
* `column`: The column number in the original source.
|
||||
|
||||
and an object is returned with the following properties:
|
||||
|
||||
* `line`: The line number in the generated source, or null.
|
||||
|
||||
* `column`: The column number in the generated source, or null.
|
||||
|
||||
```js
|
||||
consumer.generatedPositionFor({ source: "example.js", line: 2, column: 10 })
|
||||
// { line: 1,
|
||||
// column: 56 }
|
||||
```
|
||||
|
||||
#### SourceMapConsumer.prototype.allGeneratedPositionsFor(originalPosition)
|
||||
|
||||
Returns all generated line and column information for the original source, line,
|
||||
and column provided. If no column is provided, returns all mappings
|
||||
corresponding to a either the line we are searching for or the next closest line
|
||||
that has any mappings. Otherwise, returns all mappings corresponding to the
|
||||
given line and either the column we are searching for or the next closest column
|
||||
that has any offsets.
|
||||
|
||||
The only argument is an object with the following properties:
|
||||
|
||||
* `source`: The filename of the original source.
|
||||
|
||||
* `line`: The line number in the original source.
|
||||
|
||||
* `column`: Optional. The column number in the original source.
|
||||
|
||||
and an array of objects is returned, each with the following properties:
|
||||
|
||||
* `line`: The line number in the generated source, or null.
|
||||
|
||||
* `column`: The column number in the generated source, or null.
|
||||
|
||||
```js
|
||||
consumer.allGeneratedpositionsfor({ line: 2, source: "foo.coffee" })
|
||||
// [ { line: 2,
|
||||
// column: 1 },
|
||||
// { line: 2,
|
||||
// column: 10 },
|
||||
// { line: 2,
|
||||
// column: 20 } ]
|
||||
```
|
||||
|
||||
#### SourceMapConsumer.prototype.hasContentsOfAllSources()
|
||||
|
||||
Return true if we have the embedded source content for every source listed in
|
||||
the source map, false otherwise.
|
||||
|
||||
In other words, if this method returns `true`, then
|
||||
`consumer.sourceContentFor(s)` will succeed for every source `s` in
|
||||
`consumer.sources`.
|
||||
|
||||
```js
|
||||
// ...
|
||||
if (consumer.hasContentsOfAllSources()) {
|
||||
consumerReadyCallback(consumer);
|
||||
} else {
|
||||
fetchSources(consumer, consumerReadyCallback);
|
||||
}
|
||||
// ...
|
||||
```
|
||||
|
||||
#### SourceMapConsumer.prototype.sourceContentFor(source[, returnNullOnMissing])
|
||||
|
||||
Returns the original source content for the source provided. The only
|
||||
argument is the URL of the original source file.
|
||||
|
||||
If the source content for the given source is not found, then an error is
|
||||
thrown. Optionally, pass `true` as the second param to have `null` returned
|
||||
instead.
|
||||
|
||||
```js
|
||||
consumer.sources
|
||||
// [ "my-cool-lib.clj" ]
|
||||
|
||||
consumer.sourceContentFor("my-cool-lib.clj")
|
||||
// "..."
|
||||
|
||||
consumer.sourceContentFor("this is not in the source map");
|
||||
// Error: "this is not in the source map" is not in the source map
|
||||
|
||||
consumer.sourceContentFor("this is not in the source map", true);
|
||||
// null
|
||||
```
|
||||
|
||||
#### SourceMapConsumer.prototype.eachMapping(callback, context, order)
|
||||
|
||||
Iterate over each mapping between an original source/line/column and a
|
||||
generated line/column in this source map.
|
||||
|
||||
* `callback`: The function that is called with each mapping. Mappings have the
|
||||
form `{ source, generatedLine, generatedColumn, originalLine, originalColumn,
|
||||
name }`
|
||||
|
||||
* `context`: Optional. If specified, this object will be the value of `this`
|
||||
every time that `callback` is called.
|
||||
|
||||
* `order`: Either `SourceMapConsumer.GENERATED_ORDER` or
|
||||
`SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to iterate over
|
||||
the mappings sorted by the generated file's line/column order or the
|
||||
original's source/line/column order, respectively. Defaults to
|
||||
`SourceMapConsumer.GENERATED_ORDER`.
|
||||
|
||||
```js
|
||||
consumer.eachMapping(function (m) { console.log(m); })
|
||||
// ...
|
||||
// { source: 'illmatic.js',
|
||||
// generatedLine: 1,
|
||||
// generatedColumn: 0,
|
||||
// originalLine: 1,
|
||||
// originalColumn: 0,
|
||||
// name: null }
|
||||
// { source: 'illmatic.js',
|
||||
// generatedLine: 2,
|
||||
// generatedColumn: 0,
|
||||
// originalLine: 2,
|
||||
// originalColumn: 0,
|
||||
// name: null }
|
||||
// ...
|
||||
```
|
||||
### SourceMapGenerator
|
||||
|
||||
An instance of the SourceMapGenerator represents a source map which is being
|
||||
built incrementally.
|
||||
|
||||
#### new SourceMapGenerator([startOfSourceMap])
|
||||
|
||||
You may pass an object with the following properties:
|
||||
|
||||
* `file`: The filename of the generated source that this source map is
|
||||
associated with.
|
||||
|
||||
* `sourceRoot`: A root for all relative URLs in this source map.
|
||||
|
||||
* `skipValidation`: Optional. When `true`, disables validation of mappings as
|
||||
they are added. This can improve performance but should be used with
|
||||
discretion, as a last resort. Even then, one should avoid using this flag when
|
||||
running tests, if possible.
|
||||
|
||||
```js
|
||||
var generator = new sourceMap.SourceMapGenerator({
|
||||
file: "my-generated-javascript-file.js",
|
||||
sourceRoot: "http://example.com/app/js/"
|
||||
});
|
||||
```
|
||||
|
||||
#### SourceMapGenerator.fromSourceMap(sourceMapConsumer)
|
||||
|
||||
Creates a new `SourceMapGenerator` from an existing `SourceMapConsumer` instance.
|
||||
|
||||
* `sourceMapConsumer` The SourceMap.
|
||||
|
||||
```js
|
||||
var generator = sourceMap.SourceMapGenerator.fromSourceMap(consumer);
|
||||
```
|
||||
|
||||
#### SourceMapGenerator.prototype.addMapping(mapping)
|
||||
|
||||
Add a single mapping from original source line and column to the generated
|
||||
source's line and column for this source map being created. The mapping object
|
||||
should have the following properties:
|
||||
|
||||
* `generated`: An object with the generated line and column positions.
|
||||
|
||||
* `original`: An object with the original line and column positions.
|
||||
|
||||
* `source`: The original source file (relative to the sourceRoot).
|
||||
|
||||
* `name`: An optional original token name for this mapping.
|
||||
|
||||
```js
|
||||
generator.addMapping({
|
||||
source: "module-one.scm",
|
||||
original: { line: 128, column: 0 },
|
||||
generated: { line: 3, column: 456 }
|
||||
})
|
||||
```
|
||||
|
||||
#### SourceMapGenerator.prototype.setSourceContent(sourceFile, sourceContent)
|
||||
|
||||
Set the source content for an original source file.
|
||||
|
||||
* `sourceFile` the URL of the original source file.
|
||||
|
||||
* `sourceContent` the content of the source file.
|
||||
|
||||
```js
|
||||
generator.setSourceContent("module-one.scm",
|
||||
fs.readFileSync("path/to/module-one.scm"))
|
||||
```
|
||||
|
||||
#### SourceMapGenerator.prototype.applySourceMap(sourceMapConsumer[, sourceFile[, sourceMapPath]])
|
||||
|
||||
Applies a SourceMap for a source file to the SourceMap.
|
||||
Each mapping to the supplied source file is rewritten using the
|
||||
supplied SourceMap. Note: The resolution for the resulting mappings
|
||||
is the minimum of this map and the supplied map.
|
||||
|
||||
* `sourceMapConsumer`: The SourceMap to be applied.
|
||||
|
||||
* `sourceFile`: Optional. The filename of the source file.
|
||||
If omitted, sourceMapConsumer.file will be used, if it exists.
|
||||
Otherwise an error will be thrown.
|
||||
|
||||
* `sourceMapPath`: Optional. The dirname of the path to the SourceMap
|
||||
to be applied. If relative, it is relative to the SourceMap.
|
||||
|
||||
This parameter is needed when the two SourceMaps aren't in the same
|
||||
directory, and the SourceMap to be applied contains relative source
|
||||
paths. If so, those relative source paths need to be rewritten
|
||||
relative to the SourceMap.
|
||||
|
||||
If omitted, it is assumed that both SourceMaps are in the same directory,
|
||||
thus not needing any rewriting. (Supplying `'.'` has the same effect.)
|
||||
|
||||
#### SourceMapGenerator.prototype.toString()
|
||||
|
||||
Renders the source map being generated to a string.
|
||||
|
||||
```js
|
||||
generator.toString()
|
||||
// '{"version":3,"sources":["module-one.scm"],"names":[],"mappings":"...snip...","file":"my-generated-javascript-file.js","sourceRoot":"http://example.com/app/js/"}'
|
||||
```
|
||||
|
||||
### SourceNode
|
||||
|
||||
SourceNodes provide a way to abstract over interpolating and/or concatenating
|
||||
snippets of generated JavaScript source code, while maintaining the line and
|
||||
column information associated between those snippets and the original source
|
||||
code. This is useful as the final intermediate representation a compiler might
|
||||
use before outputting the generated JS and source map.
|
||||
|
||||
#### new SourceNode([line, column, source[, chunk[, name]]])
|
||||
|
||||
* `line`: The original line number associated with this source node, or null if
|
||||
it isn't associated with an original line.
|
||||
|
||||
* `column`: The original column number associated with this source node, or null
|
||||
if it isn't associated with an original column.
|
||||
|
||||
* `source`: The original source's filename; null if no filename is provided.
|
||||
|
||||
* `chunk`: Optional. Is immediately passed to `SourceNode.prototype.add`, see
|
||||
below.
|
||||
|
||||
* `name`: Optional. The original identifier.
|
||||
|
||||
```js
|
||||
var node = new SourceNode(1, 2, "a.cpp", [
|
||||
new SourceNode(3, 4, "b.cpp", "extern int status;\n"),
|
||||
new SourceNode(5, 6, "c.cpp", "std::string* make_string(size_t n);\n"),
|
||||
new SourceNode(7, 8, "d.cpp", "int main(int argc, char** argv) {}\n"),
|
||||
]);
|
||||
```
|
||||
|
||||
#### SourceNode.fromStringWithSourceMap(code, sourceMapConsumer[, relativePath])
|
||||
|
||||
Creates a SourceNode from generated code and a SourceMapConsumer.
|
||||
|
||||
* `code`: The generated code
|
||||
|
||||
* `sourceMapConsumer` The SourceMap for the generated code
|
||||
|
||||
* `relativePath` The optional path that relative sources in `sourceMapConsumer`
|
||||
should be relative to.
|
||||
|
||||
```js
|
||||
var consumer = new SourceMapConsumer(fs.readFileSync("path/to/my-file.js.map", "utf8"));
|
||||
var node = SourceNode.fromStringWithSourceMap(fs.readFileSync("path/to/my-file.js"),
|
||||
consumer);
|
||||
```
|
||||
|
||||
#### SourceNode.prototype.add(chunk)
|
||||
|
||||
Add a chunk of generated JS to this source node.
|
||||
|
||||
* `chunk`: A string snippet of generated JS code, another instance of
|
||||
`SourceNode`, or an array where each member is one of those things.
|
||||
|
||||
```js
|
||||
node.add(" + ");
|
||||
node.add(otherNode);
|
||||
node.add([leftHandOperandNode, " + ", rightHandOperandNode]);
|
||||
```
|
||||
|
||||
#### SourceNode.prototype.prepend(chunk)
|
||||
|
||||
Prepend a chunk of generated JS to this source node.
|
||||
|
||||
* `chunk`: A string snippet of generated JS code, another instance of
|
||||
`SourceNode`, or an array where each member is one of those things.
|
||||
|
||||
```js
|
||||
node.prepend("/** Build Id: f783haef86324gf **/\n\n");
|
||||
```
|
||||
|
||||
#### SourceNode.prototype.setSourceContent(sourceFile, sourceContent)
|
||||
|
||||
Set the source content for a source file. This will be added to the
|
||||
`SourceMap` in the `sourcesContent` field.
|
||||
|
||||
* `sourceFile`: The filename of the source file
|
||||
|
||||
* `sourceContent`: The content of the source file
|
||||
|
||||
```js
|
||||
node.setSourceContent("module-one.scm",
|
||||
fs.readFileSync("path/to/module-one.scm"))
|
||||
```
|
||||
|
||||
#### SourceNode.prototype.walk(fn)
|
||||
|
||||
Walk over the tree of JS snippets in this node and its children. The walking
|
||||
function is called once for each snippet of JS and is passed that snippet and
|
||||
the its original associated source's line/column location.
|
||||
|
||||
* `fn`: The traversal function.
|
||||
|
||||
```js
|
||||
var node = new SourceNode(1, 2, "a.js", [
|
||||
new SourceNode(3, 4, "b.js", "uno"),
|
||||
"dos",
|
||||
[
|
||||
"tres",
|
||||
new SourceNode(5, 6, "c.js", "quatro")
|
||||
]
|
||||
]);
|
||||
|
||||
node.walk(function (code, loc) { console.log("WALK:", code, loc); })
|
||||
// WALK: uno { source: 'b.js', line: 3, column: 4, name: null }
|
||||
// WALK: dos { source: 'a.js', line: 1, column: 2, name: null }
|
||||
// WALK: tres { source: 'a.js', line: 1, column: 2, name: null }
|
||||
// WALK: quatro { source: 'c.js', line: 5, column: 6, name: null }
|
||||
```
|
||||
|
||||
#### SourceNode.prototype.walkSourceContents(fn)
|
||||
|
||||
Walk over the tree of SourceNodes. The walking function is called for each
|
||||
source file content and is passed the filename and source content.
|
||||
|
||||
* `fn`: The traversal function.
|
||||
|
||||
```js
|
||||
var a = new SourceNode(1, 2, "a.js", "generated from a");
|
||||
a.setSourceContent("a.js", "original a");
|
||||
var b = new SourceNode(1, 2, "b.js", "generated from b");
|
||||
b.setSourceContent("b.js", "original b");
|
||||
var c = new SourceNode(1, 2, "c.js", "generated from c");
|
||||
c.setSourceContent("c.js", "original c");
|
||||
|
||||
var node = new SourceNode(null, null, null, [a, b, c]);
|
||||
node.walkSourceContents(function (source, contents) { console.log("WALK:", source, ":", contents); })
|
||||
// WALK: a.js : original a
|
||||
// WALK: b.js : original b
|
||||
// WALK: c.js : original c
|
||||
```
|
||||
|
||||
#### SourceNode.prototype.join(sep)
|
||||
|
||||
Like `Array.prototype.join` except for SourceNodes. Inserts the separator
|
||||
between each of this source node's children.
|
||||
|
||||
* `sep`: The separator.
|
||||
|
||||
```js
|
||||
var lhs = new SourceNode(1, 2, "a.rs", "my_copy");
|
||||
var operand = new SourceNode(3, 4, "a.rs", "=");
|
||||
var rhs = new SourceNode(5, 6, "a.rs", "orig.clone()");
|
||||
|
||||
var node = new SourceNode(null, null, null, [ lhs, operand, rhs ]);
|
||||
var joinedNode = node.join(" ");
|
||||
```
|
||||
|
||||
#### SourceNode.prototype.replaceRight(pattern, replacement)
|
||||
|
||||
Call `String.prototype.replace` on the very right-most source snippet. Useful
|
||||
for trimming white space from the end of a source node, etc.
|
||||
|
||||
* `pattern`: The pattern to replace.
|
||||
|
||||
* `replacement`: The thing to replace the pattern with.
|
||||
|
||||
```js
|
||||
// Trim trailing white space.
|
||||
node.replaceRight(/\s*$/, "");
|
||||
```
|
||||
|
||||
#### SourceNode.prototype.toString()
|
||||
|
||||
Return the string representation of this source node. Walks over the tree and
|
||||
concatenates all the various snippets together to one string.
|
||||
|
||||
```js
|
||||
var node = new SourceNode(1, 2, "a.js", [
|
||||
new SourceNode(3, 4, "b.js", "uno"),
|
||||
"dos",
|
||||
[
|
||||
"tres",
|
||||
new SourceNode(5, 6, "c.js", "quatro")
|
||||
]
|
||||
]);
|
||||
|
||||
node.toString()
|
||||
// 'unodostresquatro'
|
||||
```
|
||||
|
||||
#### SourceNode.prototype.toStringWithSourceMap([startOfSourceMap])
|
||||
|
||||
Returns the string representation of this tree of source nodes, plus a
|
||||
SourceMapGenerator which contains all the mappings between the generated and
|
||||
original sources.
|
||||
|
||||
The arguments are the same as those to `new SourceMapGenerator`.
|
||||
|
||||
```js
|
||||
var node = new SourceNode(1, 2, "a.js", [
|
||||
new SourceNode(3, 4, "b.js", "uno"),
|
||||
"dos",
|
||||
[
|
||||
"tres",
|
||||
new SourceNode(5, 6, "c.js", "quatro")
|
||||
]
|
||||
]);
|
||||
|
||||
node.toStringWithSourceMap({ file: "my-output-file.js" })
|
||||
// { code: 'unodostresquatro',
|
||||
// map: [object SourceMapGenerator] }
|
||||
```
|
3091
node_modules/snapdragon/node_modules/source-map/dist/source-map.debug.js
generated
vendored
Normal file
3091
node_modules/snapdragon/node_modules/source-map/dist/source-map.debug.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
3090
node_modules/snapdragon/node_modules/source-map/dist/source-map.js
generated
vendored
Normal file
3090
node_modules/snapdragon/node_modules/source-map/dist/source-map.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
2
node_modules/snapdragon/node_modules/source-map/dist/source-map.min.js
generated
vendored
Normal file
2
node_modules/snapdragon/node_modules/source-map/dist/source-map.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/snapdragon/node_modules/source-map/dist/source-map.min.js.map
generated
vendored
Normal file
1
node_modules/snapdragon/node_modules/source-map/dist/source-map.min.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
121
node_modules/snapdragon/node_modules/source-map/lib/array-set.js
generated
vendored
Normal file
121
node_modules/snapdragon/node_modules/source-map/lib/array-set.js
generated
vendored
Normal file
|
@ -0,0 +1,121 @@
|
|||
/* -*- Mode: js; js-indent-level: 2; -*- */
|
||||
/*
|
||||
* Copyright 2011 Mozilla Foundation and contributors
|
||||
* Licensed under the New BSD license. See LICENSE or:
|
||||
* http://opensource.org/licenses/BSD-3-Clause
|
||||
*/
|
||||
|
||||
var util = require('./util');
|
||||
var has = Object.prototype.hasOwnProperty;
|
||||
var hasNativeMap = typeof Map !== "undefined";
|
||||
|
||||
/**
|
||||
* A data structure which is a combination of an array and a set. Adding a new
|
||||
* member is O(1), testing for membership is O(1), and finding the index of an
|
||||
* element is O(1). Removing elements from the set is not supported. Only
|
||||
* strings are supported for membership.
|
||||
*/
|
||||
function ArraySet() {
|
||||
this._array = [];
|
||||
this._set = hasNativeMap ? new Map() : Object.create(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Static method for creating ArraySet instances from an existing array.
|
||||
*/
|
||||
ArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) {
|
||||
var set = new ArraySet();
|
||||
for (var i = 0, len = aArray.length; i < len; i++) {
|
||||
set.add(aArray[i], aAllowDuplicates);
|
||||
}
|
||||
return set;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return how many unique items are in this ArraySet. If duplicates have been
|
||||
* added, than those do not count towards the size.
|
||||
*
|
||||
* @returns Number
|
||||
*/
|
||||
ArraySet.prototype.size = function ArraySet_size() {
|
||||
return hasNativeMap ? this._set.size : Object.getOwnPropertyNames(this._set).length;
|
||||
};
|
||||
|
||||
/**
|
||||
* Add the given string to this set.
|
||||
*
|
||||
* @param String aStr
|
||||
*/
|
||||
ArraySet.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) {
|
||||
var sStr = hasNativeMap ? aStr : util.toSetString(aStr);
|
||||
var isDuplicate = hasNativeMap ? this.has(aStr) : has.call(this._set, sStr);
|
||||
var idx = this._array.length;
|
||||
if (!isDuplicate || aAllowDuplicates) {
|
||||
this._array.push(aStr);
|
||||
}
|
||||
if (!isDuplicate) {
|
||||
if (hasNativeMap) {
|
||||
this._set.set(aStr, idx);
|
||||
} else {
|
||||
this._set[sStr] = idx;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Is the given string a member of this set?
|
||||
*
|
||||
* @param String aStr
|
||||
*/
|
||||
ArraySet.prototype.has = function ArraySet_has(aStr) {
|
||||
if (hasNativeMap) {
|
||||
return this._set.has(aStr);
|
||||
} else {
|
||||
var sStr = util.toSetString(aStr);
|
||||
return has.call(this._set, sStr);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* What is the index of the given string in the array?
|
||||
*
|
||||
* @param String aStr
|
||||
*/
|
||||
ArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) {
|
||||
if (hasNativeMap) {
|
||||
var idx = this._set.get(aStr);
|
||||
if (idx >= 0) {
|
||||
return idx;
|
||||
}
|
||||
} else {
|
||||
var sStr = util.toSetString(aStr);
|
||||
if (has.call(this._set, sStr)) {
|
||||
return this._set[sStr];
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error('"' + aStr + '" is not in the set.');
|
||||
};
|
||||
|
||||
/**
|
||||
* What is the element at the given index?
|
||||
*
|
||||
* @param Number aIdx
|
||||
*/
|
||||
ArraySet.prototype.at = function ArraySet_at(aIdx) {
|
||||
if (aIdx >= 0 && aIdx < this._array.length) {
|
||||
return this._array[aIdx];
|
||||
}
|
||||
throw new Error('No element indexed by ' + aIdx);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the array representation of this set (which has the proper indices
|
||||
* indicated by indexOf). Note that this is a copy of the internal array used
|
||||
* for storing the members so that no one can mess with internal state.
|
||||
*/
|
||||
ArraySet.prototype.toArray = function ArraySet_toArray() {
|
||||
return this._array.slice();
|
||||
};
|
||||
|
||||
exports.ArraySet = ArraySet;
|
140
node_modules/snapdragon/node_modules/source-map/lib/base64-vlq.js
generated
vendored
Normal file
140
node_modules/snapdragon/node_modules/source-map/lib/base64-vlq.js
generated
vendored
Normal file
|
@ -0,0 +1,140 @@
|
|||
/* -*- Mode: js; js-indent-level: 2; -*- */
|
||||
/*
|
||||
* Copyright 2011 Mozilla Foundation and contributors
|
||||
* Licensed under the New BSD license. See LICENSE or:
|
||||
* http://opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
* Based on the Base 64 VLQ implementation in Closure Compiler:
|
||||
* https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java
|
||||
*
|
||||
* Copyright 2011 The Closure Compiler Authors. All rights reserved.
|
||||
* 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.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 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 THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS 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.
|
||||
*/
|
||||
|
||||
var base64 = require('./base64');
|
||||
|
||||
// A single base 64 digit can contain 6 bits of data. For the base 64 variable
|
||||
// length quantities we use in the source map spec, the first bit is the sign,
|
||||
// the next four bits are the actual value, and the 6th bit is the
|
||||
// continuation bit. The continuation bit tells us whether there are more
|
||||
// digits in this value following this digit.
|
||||
//
|
||||
// Continuation
|
||||
// | Sign
|
||||
// | |
|
||||
// V V
|
||||
// 101011
|
||||
|
||||
var VLQ_BASE_SHIFT = 5;
|
||||
|
||||
// binary: 100000
|
||||
var VLQ_BASE = 1 << VLQ_BASE_SHIFT;
|
||||
|
||||
// binary: 011111
|
||||
var VLQ_BASE_MASK = VLQ_BASE - 1;
|
||||
|
||||
// binary: 100000
|
||||
var VLQ_CONTINUATION_BIT = VLQ_BASE;
|
||||
|
||||
/**
|
||||
* Converts from a two-complement value to a value where the sign bit is
|
||||
* placed in the least significant bit. For example, as decimals:
|
||||
* 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)
|
||||
* 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
|
||||
*/
|
||||
function toVLQSigned(aValue) {
|
||||
return aValue < 0
|
||||
? ((-aValue) << 1) + 1
|
||||
: (aValue << 1) + 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts to a two-complement value from a value where the sign bit is
|
||||
* placed in the least significant bit. For example, as decimals:
|
||||
* 2 (10 binary) becomes 1, 3 (11 binary) becomes -1
|
||||
* 4 (100 binary) becomes 2, 5 (101 binary) becomes -2
|
||||
*/
|
||||
function fromVLQSigned(aValue) {
|
||||
var isNegative = (aValue & 1) === 1;
|
||||
var shifted = aValue >> 1;
|
||||
return isNegative
|
||||
? -shifted
|
||||
: shifted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the base 64 VLQ encoded value.
|
||||
*/
|
||||
exports.encode = function base64VLQ_encode(aValue) {
|
||||
var encoded = "";
|
||||
var digit;
|
||||
|
||||
var vlq = toVLQSigned(aValue);
|
||||
|
||||
do {
|
||||
digit = vlq & VLQ_BASE_MASK;
|
||||
vlq >>>= VLQ_BASE_SHIFT;
|
||||
if (vlq > 0) {
|
||||
// There are still more digits in this value, so we must make sure the
|
||||
// continuation bit is marked.
|
||||
digit |= VLQ_CONTINUATION_BIT;
|
||||
}
|
||||
encoded += base64.encode(digit);
|
||||
} while (vlq > 0);
|
||||
|
||||
return encoded;
|
||||
};
|
||||
|
||||
/**
|
||||
* Decodes the next base 64 VLQ value from the given string and returns the
|
||||
* value and the rest of the string via the out parameter.
|
||||
*/
|
||||
exports.decode = function base64VLQ_decode(aStr, aIndex, aOutParam) {
|
||||
var strLen = aStr.length;
|
||||
var result = 0;
|
||||
var shift = 0;
|
||||
var continuation, digit;
|
||||
|
||||
do {
|
||||
if (aIndex >= strLen) {
|
||||
throw new Error("Expected more digits in base 64 VLQ value.");
|
||||
}
|
||||
|
||||
digit = base64.decode(aStr.charCodeAt(aIndex++));
|
||||
if (digit === -1) {
|
||||
throw new Error("Invalid base64 digit: " + aStr.charAt(aIndex - 1));
|
||||
}
|
||||
|
||||
continuation = !!(digit & VLQ_CONTINUATION_BIT);
|
||||
digit &= VLQ_BASE_MASK;
|
||||
result = result + (digit << shift);
|
||||
shift += VLQ_BASE_SHIFT;
|
||||
} while (continuation);
|
||||
|
||||
aOutParam.value = fromVLQSigned(result);
|
||||
aOutParam.rest = aIndex;
|
||||
};
|
67
node_modules/snapdragon/node_modules/source-map/lib/base64.js
generated
vendored
Normal file
67
node_modules/snapdragon/node_modules/source-map/lib/base64.js
generated
vendored
Normal file
|
@ -0,0 +1,67 @@
|
|||
/* -*- Mode: js; js-indent-level: 2; -*- */
|
||||
/*
|
||||
* Copyright 2011 Mozilla Foundation and contributors
|
||||
* Licensed under the New BSD license. See LICENSE or:
|
||||
* http://opensource.org/licenses/BSD-3-Clause
|
||||
*/
|
||||
|
||||
var intToCharMap = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');
|
||||
|
||||
/**
|
||||
* Encode an integer in the range of 0 to 63 to a single base 64 digit.
|
||||
*/
|
||||
exports.encode = function (number) {
|
||||
if (0 <= number && number < intToCharMap.length) {
|
||||
return intToCharMap[number];
|
||||
}
|
||||
throw new TypeError("Must be between 0 and 63: " + number);
|
||||
};
|
||||
|
||||
/**
|
||||
* Decode a single base 64 character code digit to an integer. Returns -1 on
|
||||
* failure.
|
||||
*/
|
||||
exports.decode = function (charCode) {
|
||||
var bigA = 65; // 'A'
|
||||
var bigZ = 90; // 'Z'
|
||||
|
||||
var littleA = 97; // 'a'
|
||||
var littleZ = 122; // 'z'
|
||||
|
||||
var zero = 48; // '0'
|
||||
var nine = 57; // '9'
|
||||
|
||||
var plus = 43; // '+'
|
||||
var slash = 47; // '/'
|
||||
|
||||
var littleOffset = 26;
|
||||
var numberOffset = 52;
|
||||
|
||||
// 0 - 25: ABCDEFGHIJKLMNOPQRSTUVWXYZ
|
||||
if (bigA <= charCode && charCode <= bigZ) {
|
||||
return (charCode - bigA);
|
||||
}
|
||||
|
||||
// 26 - 51: abcdefghijklmnopqrstuvwxyz
|
||||
if (littleA <= charCode && charCode <= littleZ) {
|
||||
return (charCode - littleA + littleOffset);
|
||||
}
|
||||
|
||||
// 52 - 61: 0123456789
|
||||
if (zero <= charCode && charCode <= nine) {
|
||||
return (charCode - zero + numberOffset);
|
||||
}
|
||||
|
||||
// 62: +
|
||||
if (charCode == plus) {
|
||||
return 62;
|
||||
}
|
||||
|
||||
// 63: /
|
||||
if (charCode == slash) {
|
||||
return 63;
|
||||
}
|
||||
|
||||
// Invalid base64 digit.
|
||||
return -1;
|
||||
};
|
111
node_modules/snapdragon/node_modules/source-map/lib/binary-search.js
generated
vendored
Normal file
111
node_modules/snapdragon/node_modules/source-map/lib/binary-search.js
generated
vendored
Normal file
|
@ -0,0 +1,111 @@
|
|||
/* -*- Mode: js; js-indent-level: 2; -*- */
|
||||
/*
|
||||
* Copyright 2011 Mozilla Foundation and contributors
|
||||
* Licensed under the New BSD license. See LICENSE or:
|
||||
* http://opensource.org/licenses/BSD-3-Clause
|
||||
*/
|
||||
|
||||
exports.GREATEST_LOWER_BOUND = 1;
|
||||
exports.LEAST_UPPER_BOUND = 2;
|
||||
|
||||
/**
|
||||
* Recursive implementation of binary search.
|
||||
*
|
||||
* @param aLow Indices here and lower do not contain the needle.
|
||||
* @param aHigh Indices here and higher do not contain the needle.
|
||||
* @param aNeedle The element being searched for.
|
||||
* @param aHaystack The non-empty array being searched.
|
||||
* @param aCompare Function which takes two elements and returns -1, 0, or 1.
|
||||
* @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
|
||||
* 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
|
||||
* closest element that is smaller than or greater than the one we are
|
||||
* searching for, respectively, if the exact element cannot be found.
|
||||
*/
|
||||
function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) {
|
||||
// This function terminates when one of the following is true:
|
||||
//
|
||||
// 1. We find the exact element we are looking for.
|
||||
//
|
||||
// 2. We did not find the exact element, but we can return the index of
|
||||
// the next-closest element.
|
||||
//
|
||||
// 3. We did not find the exact element, and there is no next-closest
|
||||
// element than the one we are searching for, so we return -1.
|
||||
var mid = Math.floor((aHigh - aLow) / 2) + aLow;
|
||||
var cmp = aCompare(aNeedle, aHaystack[mid], true);
|
||||
if (cmp === 0) {
|
||||
// Found the element we are looking for.
|
||||
return mid;
|
||||
}
|
||||
else if (cmp > 0) {
|
||||
// Our needle is greater than aHaystack[mid].
|
||||
if (aHigh - mid > 1) {
|
||||
// The element is in the upper half.
|
||||
return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare, aBias);
|
||||
}
|
||||
|
||||
// The exact needle element was not found in this haystack. Determine if
|
||||
// we are in termination case (3) or (2) and return the appropriate thing.
|
||||
if (aBias == exports.LEAST_UPPER_BOUND) {
|
||||
return aHigh < aHaystack.length ? aHigh : -1;
|
||||
} else {
|
||||
return mid;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Our needle is less than aHaystack[mid].
|
||||
if (mid - aLow > 1) {
|
||||
// The element is in the lower half.
|
||||
return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias);
|
||||
}
|
||||
|
||||
// we are in termination case (3) or (2) and return the appropriate thing.
|
||||
if (aBias == exports.LEAST_UPPER_BOUND) {
|
||||
return mid;
|
||||
} else {
|
||||
return aLow < 0 ? -1 : aLow;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This is an implementation of binary search which will always try and return
|
||||
* the index of the closest element if there is no exact hit. This is because
|
||||
* mappings between original and generated line/col pairs are single points,
|
||||
* and there is an implicit region between each of them, so a miss just means
|
||||
* that you aren't on the very start of a region.
|
||||
*
|
||||
* @param aNeedle The element you are looking for.
|
||||
* @param aHaystack The array that is being searched.
|
||||
* @param aCompare A function which takes the needle and an element in the
|
||||
* array and returns -1, 0, or 1 depending on whether the needle is less
|
||||
* than, equal to, or greater than the element, respectively.
|
||||
* @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
|
||||
* 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
|
||||
* closest element that is smaller than or greater than the one we are
|
||||
* searching for, respectively, if the exact element cannot be found.
|
||||
* Defaults to 'binarySearch.GREATEST_LOWER_BOUND'.
|
||||
*/
|
||||
exports.search = function search(aNeedle, aHaystack, aCompare, aBias) {
|
||||
if (aHaystack.length === 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
var index = recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack,
|
||||
aCompare, aBias || exports.GREATEST_LOWER_BOUND);
|
||||
if (index < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// We have found either the exact element, or the next-closest element than
|
||||
// the one we are searching for. However, there may be more than one such
|
||||
// element. Make sure we always return the smallest of these.
|
||||
while (index - 1 >= 0) {
|
||||
if (aCompare(aHaystack[index], aHaystack[index - 1], true) !== 0) {
|
||||
break;
|
||||
}
|
||||
--index;
|
||||
}
|
||||
|
||||
return index;
|
||||
};
|
79
node_modules/snapdragon/node_modules/source-map/lib/mapping-list.js
generated
vendored
Normal file
79
node_modules/snapdragon/node_modules/source-map/lib/mapping-list.js
generated
vendored
Normal file
|
@ -0,0 +1,79 @@
|
|||
/* -*- Mode: js; js-indent-level: 2; -*- */
|
||||
/*
|
||||
* Copyright 2014 Mozilla Foundation and contributors
|
||||
* Licensed under the New BSD license. See LICENSE or:
|
||||
* http://opensource.org/licenses/BSD-3-Clause
|
||||
*/
|
||||
|
||||
var util = require('./util');
|
||||
|
||||
/**
|
||||
* Determine whether mappingB is after mappingA with respect to generated
|
||||
* position.
|
||||
*/
|
||||
function generatedPositionAfter(mappingA, mappingB) {
|
||||
// Optimized for most common case
|
||||
var lineA = mappingA.generatedLine;
|
||||
var lineB = mappingB.generatedLine;
|
||||
var columnA = mappingA.generatedColumn;
|
||||
var columnB = mappingB.generatedColumn;
|
||||
return lineB > lineA || lineB == lineA && columnB >= columnA ||
|
||||
util.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* A data structure to provide a sorted view of accumulated mappings in a
|
||||
* performance conscious manner. It trades a neglibable overhead in general
|
||||
* case for a large speedup in case of mappings being added in order.
|
||||
*/
|
||||
function MappingList() {
|
||||
this._array = [];
|
||||
this._sorted = true;
|
||||
// Serves as infimum
|
||||
this._last = {generatedLine: -1, generatedColumn: 0};
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterate through internal items. This method takes the same arguments that
|
||||
* `Array.prototype.forEach` takes.
|
||||
*
|
||||
* NOTE: The order of the mappings is NOT guaranteed.
|
||||
*/
|
||||
MappingList.prototype.unsortedForEach =
|
||||
function MappingList_forEach(aCallback, aThisArg) {
|
||||
this._array.forEach(aCallback, aThisArg);
|
||||
};
|
||||
|
||||
/**
|
||||
* Add the given source mapping.
|
||||
*
|
||||
* @param Object aMapping
|
||||
*/
|
||||
MappingList.prototype.add = function MappingList_add(aMapping) {
|
||||
if (generatedPositionAfter(this._last, aMapping)) {
|
||||
this._last = aMapping;
|
||||
this._array.push(aMapping);
|
||||
} else {
|
||||
this._sorted = false;
|
||||
this._array.push(aMapping);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the flat, sorted array of mappings. The mappings are sorted by
|
||||
* generated position.
|
||||
*
|
||||
* WARNING: This method returns internal data without copying, for
|
||||
* performance. The return value must NOT be mutated, and should be treated as
|
||||
* an immutable borrow. If you want to take ownership, you must make your own
|
||||
* copy.
|
||||
*/
|
||||
MappingList.prototype.toArray = function MappingList_toArray() {
|
||||
if (!this._sorted) {
|
||||
this._array.sort(util.compareByGeneratedPositionsInflated);
|
||||
this._sorted = true;
|
||||
}
|
||||
return this._array;
|
||||
};
|
||||
|
||||
exports.MappingList = MappingList;
|
114
node_modules/snapdragon/node_modules/source-map/lib/quick-sort.js
generated
vendored
Normal file
114
node_modules/snapdragon/node_modules/source-map/lib/quick-sort.js
generated
vendored
Normal file
|
@ -0,0 +1,114 @@
|
|||
/* -*- Mode: js; js-indent-level: 2; -*- */
|
||||
/*
|
||||
* Copyright 2011 Mozilla Foundation and contributors
|
||||
* Licensed under the New BSD license. See LICENSE or:
|
||||
* http://opensource.org/licenses/BSD-3-Clause
|
||||
*/
|
||||
|
||||
// It turns out that some (most?) JavaScript engines don't self-host
|
||||
// `Array.prototype.sort`. This makes sense because C++ will likely remain
|
||||
// faster than JS when doing raw CPU-intensive sorting. However, when using a
|
||||
// custom comparator function, calling back and forth between the VM's C++ and
|
||||
// JIT'd JS is rather slow *and* loses JIT type information, resulting in
|
||||
// worse generated code for the comparator function than would be optimal. In
|
||||
// fact, when sorting with a comparator, these costs outweigh the benefits of
|
||||
// sorting in C++. By using our own JS-implemented Quick Sort (below), we get
|
||||
// a ~3500ms mean speed-up in `bench/bench.html`.
|
||||
|
||||
/**
|
||||
* Swap the elements indexed by `x` and `y` in the array `ary`.
|
||||
*
|
||||
* @param {Array} ary
|
||||
* The array.
|
||||
* @param {Number} x
|
||||
* The index of the first item.
|
||||
* @param {Number} y
|
||||
* The index of the second item.
|
||||
*/
|
||||
function swap(ary, x, y) {
|
||||
var temp = ary[x];
|
||||
ary[x] = ary[y];
|
||||
ary[y] = temp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a random integer within the range `low .. high` inclusive.
|
||||
*
|
||||
* @param {Number} low
|
||||
* The lower bound on the range.
|
||||
* @param {Number} high
|
||||
* The upper bound on the range.
|
||||
*/
|
||||
function randomIntInRange(low, high) {
|
||||
return Math.round(low + (Math.random() * (high - low)));
|
||||
}
|
||||
|
||||
/**
|
||||
* The Quick Sort algorithm.
|
||||
*
|
||||
* @param {Array} ary
|
||||
* An array to sort.
|
||||
* @param {function} comparator
|
||||
* Function to use to compare two items.
|
||||
* @param {Number} p
|
||||
* Start index of the array
|
||||
* @param {Number} r
|
||||
* End index of the array
|
||||
*/
|
||||
function doQuickSort(ary, comparator, p, r) {
|
||||
// If our lower bound is less than our upper bound, we (1) partition the
|
||||
// array into two pieces and (2) recurse on each half. If it is not, this is
|
||||
// the empty array and our base case.
|
||||
|
||||
if (p < r) {
|
||||
// (1) Partitioning.
|
||||
//
|
||||
// The partitioning chooses a pivot between `p` and `r` and moves all
|
||||
// elements that are less than or equal to the pivot to the before it, and
|
||||
// all the elements that are greater than it after it. The effect is that
|
||||
// once partition is done, the pivot is in the exact place it will be when
|
||||
// the array is put in sorted order, and it will not need to be moved
|
||||
// again. This runs in O(n) time.
|
||||
|
||||
// Always choose a random pivot so that an input array which is reverse
|
||||
// sorted does not cause O(n^2) running time.
|
||||
var pivotIndex = randomIntInRange(p, r);
|
||||
var i = p - 1;
|
||||
|
||||
swap(ary, pivotIndex, r);
|
||||
var pivot = ary[r];
|
||||
|
||||
// Immediately after `j` is incremented in this loop, the following hold
|
||||
// true:
|
||||
//
|
||||
// * Every element in `ary[p .. i]` is less than or equal to the pivot.
|
||||
//
|
||||
// * Every element in `ary[i+1 .. j-1]` is greater than the pivot.
|
||||
for (var j = p; j < r; j++) {
|
||||
if (comparator(ary[j], pivot) <= 0) {
|
||||
i += 1;
|
||||
swap(ary, i, j);
|
||||
}
|
||||
}
|
||||
|
||||
swap(ary, i + 1, j);
|
||||
var q = i + 1;
|
||||
|
||||
// (2) Recurse on each half.
|
||||
|
||||
doQuickSort(ary, comparator, p, q - 1);
|
||||
doQuickSort(ary, comparator, q + 1, r);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort the given array in-place with the given comparator function.
|
||||
*
|
||||
* @param {Array} ary
|
||||
* An array to sort.
|
||||
* @param {function} comparator
|
||||
* Function to use to compare two items.
|
||||
*/
|
||||
exports.quickSort = function (ary, comparator) {
|
||||
doQuickSort(ary, comparator, 0, ary.length - 1);
|
||||
};
|
1082
node_modules/snapdragon/node_modules/source-map/lib/source-map-consumer.js
generated
vendored
Normal file
1082
node_modules/snapdragon/node_modules/source-map/lib/source-map-consumer.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
416
node_modules/snapdragon/node_modules/source-map/lib/source-map-generator.js
generated
vendored
Normal file
416
node_modules/snapdragon/node_modules/source-map/lib/source-map-generator.js
generated
vendored
Normal file
|
@ -0,0 +1,416 @@
|
|||
/* -*- Mode: js; js-indent-level: 2; -*- */
|
||||
/*
|
||||
* Copyright 2011 Mozilla Foundation and contributors
|
||||
* Licensed under the New BSD license. See LICENSE or:
|
||||
* http://opensource.org/licenses/BSD-3-Clause
|
||||
*/
|
||||
|
||||
var base64VLQ = require('./base64-vlq');
|
||||
var util = require('./util');
|
||||
var ArraySet = require('./array-set').ArraySet;
|
||||
var MappingList = require('./mapping-list').MappingList;
|
||||
|
||||
/**
|
||||
* An instance of the SourceMapGenerator represents a source map which is
|
||||
* being built incrementally. You may pass an object with the following
|
||||
* properties:
|
||||
*
|
||||
* - file: The filename of the generated source.
|
||||
* - sourceRoot: A root for all relative URLs in this source map.
|
||||
*/
|
||||
function SourceMapGenerator(aArgs) {
|
||||
if (!aArgs) {
|
||||
aArgs = {};
|
||||
}
|
||||
this._file = util.getArg(aArgs, 'file', null);
|
||||
this._sourceRoot = util.getArg(aArgs, 'sourceRoot', null);
|
||||
this._skipValidation = util.getArg(aArgs, 'skipValidation', false);
|
||||
this._sources = new ArraySet();
|
||||
this._names = new ArraySet();
|
||||
this._mappings = new MappingList();
|
||||
this._sourcesContents = null;
|
||||
}
|
||||
|
||||
SourceMapGenerator.prototype._version = 3;
|
||||
|
||||
/**
|
||||
* Creates a new SourceMapGenerator based on a SourceMapConsumer
|
||||
*
|
||||
* @param aSourceMapConsumer The SourceMap.
|
||||
*/
|
||||
SourceMapGenerator.fromSourceMap =
|
||||
function SourceMapGenerator_fromSourceMap(aSourceMapConsumer) {
|
||||
var sourceRoot = aSourceMapConsumer.sourceRoot;
|
||||
var generator = new SourceMapGenerator({
|
||||
file: aSourceMapConsumer.file,
|
||||
sourceRoot: sourceRoot
|
||||
});
|
||||
aSourceMapConsumer.eachMapping(function (mapping) {
|
||||
var newMapping = {
|
||||
generated: {
|
||||
line: mapping.generatedLine,
|
||||
column: mapping.generatedColumn
|
||||
}
|
||||
};
|
||||
|
||||
if (mapping.source != null) {
|
||||
newMapping.source = mapping.source;
|
||||
if (sourceRoot != null) {
|
||||
newMapping.source = util.relative(sourceRoot, newMapping.source);
|
||||
}
|
||||
|
||||
newMapping.original = {
|
||||
line: mapping.originalLine,
|
||||
column: mapping.originalColumn
|
||||
};
|
||||
|
||||
if (mapping.name != null) {
|
||||
newMapping.name = mapping.name;
|
||||
}
|
||||
}
|
||||
|
||||
generator.addMapping(newMapping);
|
||||
});
|
||||
aSourceMapConsumer.sources.forEach(function (sourceFile) {
|
||||
var content = aSourceMapConsumer.sourceContentFor(sourceFile);
|
||||
if (content != null) {
|
||||
generator.setSourceContent(sourceFile, content);
|
||||
}
|
||||
});
|
||||
return generator;
|
||||
};
|
||||
|
||||
/**
|
||||
* Add a single mapping from original source line and column to the generated
|
||||
* source's line and column for this source map being created. The mapping
|
||||
* object should have the following properties:
|
||||
*
|
||||
* - generated: An object with the generated line and column positions.
|
||||
* - original: An object with the original line and column positions.
|
||||
* - source: The original source file (relative to the sourceRoot).
|
||||
* - name: An optional original token name for this mapping.
|
||||
*/
|
||||
SourceMapGenerator.prototype.addMapping =
|
||||
function SourceMapGenerator_addMapping(aArgs) {
|
||||
var generated = util.getArg(aArgs, 'generated');
|
||||
var original = util.getArg(aArgs, 'original', null);
|
||||
var source = util.getArg(aArgs, 'source', null);
|
||||
var name = util.getArg(aArgs, 'name', null);
|
||||
|
||||
if (!this._skipValidation) {
|
||||
this._validateMapping(generated, original, source, name);
|
||||
}
|
||||
|
||||
if (source != null) {
|
||||
source = String(source);
|
||||
if (!this._sources.has(source)) {
|
||||
this._sources.add(source);
|
||||
}
|
||||
}
|
||||
|
||||
if (name != null) {
|
||||
name = String(name);
|
||||
if (!this._names.has(name)) {
|
||||
this._names.add(name);
|
||||
}
|
||||
}
|
||||
|
||||
this._mappings.add({
|
||||
generatedLine: generated.line,
|
||||
generatedColumn: generated.column,
|
||||
originalLine: original != null && original.line,
|
||||
originalColumn: original != null && original.column,
|
||||
source: source,
|
||||
name: name
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the source content for a source file.
|
||||
*/
|
||||
SourceMapGenerator.prototype.setSourceContent =
|
||||
function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) {
|
||||
var source = aSourceFile;
|
||||
if (this._sourceRoot != null) {
|
||||
source = util.relative(this._sourceRoot, source);
|
||||
}
|
||||
|
||||
if (aSourceContent != null) {
|
||||
// Add the source content to the _sourcesContents map.
|
||||
// Create a new _sourcesContents map if the property is null.
|
||||
if (!this._sourcesContents) {
|
||||
this._sourcesContents = Object.create(null);
|
||||
}
|
||||
this._sourcesContents[util.toSetString(source)] = aSourceContent;
|
||||
} else if (this._sourcesContents) {
|
||||
// Remove the source file from the _sourcesContents map.
|
||||
// If the _sourcesContents map is empty, set the property to null.
|
||||
delete this._sourcesContents[util.toSetString(source)];
|
||||
if (Object.keys(this._sourcesContents).length === 0) {
|
||||
this._sourcesContents = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Applies the mappings of a sub-source-map for a specific source file to the
|
||||
* source map being generated. Each mapping to the supplied source file is
|
||||
* rewritten using the supplied source map. Note: The resolution for the
|
||||
* resulting mappings is the minimium of this map and the supplied map.
|
||||
*
|
||||
* @param aSourceMapConsumer The source map to be applied.
|
||||
* @param aSourceFile Optional. The filename of the source file.
|
||||
* If omitted, SourceMapConsumer's file property will be used.
|
||||
* @param aSourceMapPath Optional. The dirname of the path to the source map
|
||||
* to be applied. If relative, it is relative to the SourceMapConsumer.
|
||||
* This parameter is needed when the two source maps aren't in the same
|
||||
* directory, and the source map to be applied contains relative source
|
||||
* paths. If so, those relative source paths need to be rewritten
|
||||
* relative to the SourceMapGenerator.
|
||||
*/
|
||||
SourceMapGenerator.prototype.applySourceMap =
|
||||
function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) {
|
||||
var sourceFile = aSourceFile;
|
||||
// If aSourceFile is omitted, we will use the file property of the SourceMap
|
||||
if (aSourceFile == null) {
|
||||
if (aSourceMapConsumer.file == null) {
|
||||
throw new Error(
|
||||
'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' +
|
||||
'or the source map\'s "file" property. Both were omitted.'
|
||||
);
|
||||
}
|
||||
sourceFile = aSourceMapConsumer.file;
|
||||
}
|
||||
var sourceRoot = this._sourceRoot;
|
||||
// Make "sourceFile" relative if an absolute Url is passed.
|
||||
if (sourceRoot != null) {
|
||||
sourceFile = util.relative(sourceRoot, sourceFile);
|
||||
}
|
||||
// Applying the SourceMap can add and remove items from the sources and
|
||||
// the names array.
|
||||
var newSources = new ArraySet();
|
||||
var newNames = new ArraySet();
|
||||
|
||||
// Find mappings for the "sourceFile"
|
||||
this._mappings.unsortedForEach(function (mapping) {
|
||||
if (mapping.source === sourceFile && mapping.originalLine != null) {
|
||||
// Check if it can be mapped by the source map, then update the mapping.
|
||||
var original = aSourceMapConsumer.originalPositionFor({
|
||||
line: mapping.originalLine,
|
||||
column: mapping.originalColumn
|
||||
});
|
||||
if (original.source != null) {
|
||||
// Copy mapping
|
||||
mapping.source = original.source;
|
||||
if (aSourceMapPath != null) {
|
||||
mapping.source = util.join(aSourceMapPath, mapping.source)
|
||||
}
|
||||
if (sourceRoot != null) {
|
||||
mapping.source = util.relative(sourceRoot, mapping.source);
|
||||
}
|
||||
mapping.originalLine = original.line;
|
||||
mapping.originalColumn = original.column;
|
||||
if (original.name != null) {
|
||||
mapping.name = original.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var source = mapping.source;
|
||||
if (source != null && !newSources.has(source)) {
|
||||
newSources.add(source);
|
||||
}
|
||||
|
||||
var name = mapping.name;
|
||||
if (name != null && !newNames.has(name)) {
|
||||
newNames.add(name);
|
||||
}
|
||||
|
||||
}, this);
|
||||
this._sources = newSources;
|
||||
this._names = newNames;
|
||||
|
||||
// Copy sourcesContents of applied map.
|
||||
aSourceMapConsumer.sources.forEach(function (sourceFile) {
|
||||
var content = aSourceMapConsumer.sourceContentFor(sourceFile);
|
||||
if (content != null) {
|
||||
if (aSourceMapPath != null) {
|
||||
sourceFile = util.join(aSourceMapPath, sourceFile);
|
||||
}
|
||||
if (sourceRoot != null) {
|
||||
sourceFile = util.relative(sourceRoot, sourceFile);
|
||||
}
|
||||
this.setSourceContent(sourceFile, content);
|
||||
}
|
||||
}, this);
|
||||
};
|
||||
|
||||
/**
|
||||
* A mapping can have one of the three levels of data:
|
||||
*
|
||||
* 1. Just the generated position.
|
||||
* 2. The Generated position, original position, and original source.
|
||||
* 3. Generated and original position, original source, as well as a name
|
||||
* token.
|
||||
*
|
||||
* To maintain consistency, we validate that any new mapping being added falls
|
||||
* in to one of these categories.
|
||||
*/
|
||||
SourceMapGenerator.prototype._validateMapping =
|
||||
function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource,
|
||||
aName) {
|
||||
// When aOriginal is truthy but has empty values for .line and .column,
|
||||
// it is most likely a programmer error. In this case we throw a very
|
||||
// specific error message to try to guide them the right way.
|
||||
// For example: https://github.com/Polymer/polymer-bundler/pull/519
|
||||
if (aOriginal && typeof aOriginal.line !== 'number' && typeof aOriginal.column !== 'number') {
|
||||
throw new Error(
|
||||
'original.line and original.column are not numbers -- you probably meant to omit ' +
|
||||
'the original mapping entirely and only map the generated position. If so, pass ' +
|
||||
'null for the original mapping instead of an object with empty or null values.'
|
||||
);
|
||||
}
|
||||
|
||||
if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
|
||||
&& aGenerated.line > 0 && aGenerated.column >= 0
|
||||
&& !aOriginal && !aSource && !aName) {
|
||||
// Case 1.
|
||||
return;
|
||||
}
|
||||
else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
|
||||
&& aOriginal && 'line' in aOriginal && 'column' in aOriginal
|
||||
&& aGenerated.line > 0 && aGenerated.column >= 0
|
||||
&& aOriginal.line > 0 && aOriginal.column >= 0
|
||||
&& aSource) {
|
||||
// Cases 2 and 3.
|
||||
return;
|
||||
}
|
||||
else {
|
||||
throw new Error('Invalid mapping: ' + JSON.stringify({
|
||||
generated: aGenerated,
|
||||
source: aSource,
|
||||
original: aOriginal,
|
||||
name: aName
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Serialize the accumulated mappings in to the stream of base 64 VLQs
|
||||
* specified by the source map format.
|
||||
*/
|
||||
SourceMapGenerator.prototype._serializeMappings =
|
||||
function SourceMapGenerator_serializeMappings() {
|
||||
var previousGeneratedColumn = 0;
|
||||
var previousGeneratedLine = 1;
|
||||
var previousOriginalColumn = 0;
|
||||
var previousOriginalLine = 0;
|
||||
var previousName = 0;
|
||||
var previousSource = 0;
|
||||
var result = '';
|
||||
var next;
|
||||
var mapping;
|
||||
var nameIdx;
|
||||
var sourceIdx;
|
||||
|
||||
var mappings = this._mappings.toArray();
|
||||
for (var i = 0, len = mappings.length; i < len; i++) {
|
||||
mapping = mappings[i];
|
||||
next = ''
|
||||
|
||||
if (mapping.generatedLine !== previousGeneratedLine) {
|
||||
previousGeneratedColumn = 0;
|
||||
while (mapping.generatedLine !== previousGeneratedLine) {
|
||||
next += ';';
|
||||
previousGeneratedLine++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (i > 0) {
|
||||
if (!util.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) {
|
||||
continue;
|
||||
}
|
||||
next += ',';
|
||||
}
|
||||
}
|
||||
|
||||
next += base64VLQ.encode(mapping.generatedColumn
|
||||
- previousGeneratedColumn);
|
||||
previousGeneratedColumn = mapping.generatedColumn;
|
||||
|
||||
if (mapping.source != null) {
|
||||
sourceIdx = this._sources.indexOf(mapping.source);
|
||||
next += base64VLQ.encode(sourceIdx - previousSource);
|
||||
previousSource = sourceIdx;
|
||||
|
||||
// lines are stored 0-based in SourceMap spec version 3
|
||||
next += base64VLQ.encode(mapping.originalLine - 1
|
||||
- previousOriginalLine);
|
||||
previousOriginalLine = mapping.originalLine - 1;
|
||||
|
||||
next += base64VLQ.encode(mapping.originalColumn
|
||||
- previousOriginalColumn);
|
||||
previousOriginalColumn = mapping.originalColumn;
|
||||
|
||||
if (mapping.name != null) {
|
||||
nameIdx = this._names.indexOf(mapping.name);
|
||||
next += base64VLQ.encode(nameIdx - previousName);
|
||||
previousName = nameIdx;
|
||||
}
|
||||
}
|
||||
|
||||
result += next;
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
SourceMapGenerator.prototype._generateSourcesContent =
|
||||
function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) {
|
||||
return aSources.map(function (source) {
|
||||
if (!this._sourcesContents) {
|
||||
return null;
|
||||
}
|
||||
if (aSourceRoot != null) {
|
||||
source = util.relative(aSourceRoot, source);
|
||||
}
|
||||
var key = util.toSetString(source);
|
||||
return Object.prototype.hasOwnProperty.call(this._sourcesContents, key)
|
||||
? this._sourcesContents[key]
|
||||
: null;
|
||||
}, this);
|
||||
};
|
||||
|
||||
/**
|
||||
* Externalize the source map.
|
||||
*/
|
||||
SourceMapGenerator.prototype.toJSON =
|
||||
function SourceMapGenerator_toJSON() {
|
||||
var map = {
|
||||
version: this._version,
|
||||
sources: this._sources.toArray(),
|
||||
names: this._names.toArray(),
|
||||
mappings: this._serializeMappings()
|
||||
};
|
||||
if (this._file != null) {
|
||||
map.file = this._file;
|
||||
}
|
||||
if (this._sourceRoot != null) {
|
||||
map.sourceRoot = this._sourceRoot;
|
||||
}
|
||||
if (this._sourcesContents) {
|
||||
map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);
|
||||
}
|
||||
|
||||
return map;
|
||||
};
|
||||
|
||||
/**
|
||||
* Render the source map being generated to a string.
|
||||
*/
|
||||
SourceMapGenerator.prototype.toString =
|
||||
function SourceMapGenerator_toString() {
|
||||
return JSON.stringify(this.toJSON());
|
||||
};
|
||||
|
||||
exports.SourceMapGenerator = SourceMapGenerator;
|
413
node_modules/snapdragon/node_modules/source-map/lib/source-node.js
generated
vendored
Normal file
413
node_modules/snapdragon/node_modules/source-map/lib/source-node.js
generated
vendored
Normal file
|
@ -0,0 +1,413 @@
|
|||
/* -*- Mode: js; js-indent-level: 2; -*- */
|
||||
/*
|
||||
* Copyright 2011 Mozilla Foundation and contributors
|
||||
* Licensed under the New BSD license. See LICENSE or:
|
||||
* http://opensource.org/licenses/BSD-3-Clause
|
||||
*/
|
||||
|
||||
var SourceMapGenerator = require('./source-map-generator').SourceMapGenerator;
|
||||
var util = require('./util');
|
||||
|
||||
// Matches a Windows-style `\r\n` newline or a `\n` newline used by all other
|
||||
// operating systems these days (capturing the result).
|
||||
var REGEX_NEWLINE = /(\r?\n)/;
|
||||
|
||||
// Newline character code for charCodeAt() comparisons
|
||||
var NEWLINE_CODE = 10;
|
||||
|
||||
// Private symbol for identifying `SourceNode`s when multiple versions of
|
||||
// the source-map library are loaded. This MUST NOT CHANGE across
|
||||
// versions!
|
||||
var isSourceNode = "$$$isSourceNode$$$";
|
||||
|
||||
/**
|
||||
* SourceNodes provide a way to abstract over interpolating/concatenating
|
||||
* snippets of generated JavaScript source code while maintaining the line and
|
||||
* column information associated with the original source code.
|
||||
*
|
||||
* @param aLine The original line number.
|
||||
* @param aColumn The original column number.
|
||||
* @param aSource The original source's filename.
|
||||
* @param aChunks Optional. An array of strings which are snippets of
|
||||
* generated JS, or other SourceNodes.
|
||||
* @param aName The original identifier.
|
||||
*/
|
||||
function SourceNode(aLine, aColumn, aSource, aChunks, aName) {
|
||||
this.children = [];
|
||||
this.sourceContents = {};
|
||||
this.line = aLine == null ? null : aLine;
|
||||
this.column = aColumn == null ? null : aColumn;
|
||||
this.source = aSource == null ? null : aSource;
|
||||
this.name = aName == null ? null : aName;
|
||||
this[isSourceNode] = true;
|
||||
if (aChunks != null) this.add(aChunks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a SourceNode from generated code and a SourceMapConsumer.
|
||||
*
|
||||
* @param aGeneratedCode The generated code
|
||||
* @param aSourceMapConsumer The SourceMap for the generated code
|
||||
* @param aRelativePath Optional. The path that relative sources in the
|
||||
* SourceMapConsumer should be relative to.
|
||||
*/
|
||||
SourceNode.fromStringWithSourceMap =
|
||||
function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) {
|
||||
// The SourceNode we want to fill with the generated code
|
||||
// and the SourceMap
|
||||
var node = new SourceNode();
|
||||
|
||||
// All even indices of this array are one line of the generated code,
|
||||
// while all odd indices are the newlines between two adjacent lines
|
||||
// (since `REGEX_NEWLINE` captures its match).
|
||||
// Processed fragments are accessed by calling `shiftNextLine`.
|
||||
var remainingLines = aGeneratedCode.split(REGEX_NEWLINE);
|
||||
var remainingLinesIndex = 0;
|
||||
var shiftNextLine = function() {
|
||||
var lineContents = getNextLine();
|
||||
// The last line of a file might not have a newline.
|
||||
var newLine = getNextLine() || "";
|
||||
return lineContents + newLine;
|
||||
|
||||
function getNextLine() {
|
||||
return remainingLinesIndex < remainingLines.length ?
|
||||
remainingLines[remainingLinesIndex++] : undefined;
|
||||
}
|
||||
};
|
||||
|
||||
// We need to remember the position of "remainingLines"
|
||||
var lastGeneratedLine = 1, lastGeneratedColumn = 0;
|
||||
|
||||
// The generate SourceNodes we need a code range.
|
||||
// To extract it current and last mapping is used.
|
||||
// Here we store the last mapping.
|
||||
var lastMapping = null;
|
||||
|
||||
aSourceMapConsumer.eachMapping(function (mapping) {
|
||||
if (lastMapping !== null) {
|
||||
// We add the code from "lastMapping" to "mapping":
|
||||
// First check if there is a new line in between.
|
||||
if (lastGeneratedLine < mapping.generatedLine) {
|
||||
// Associate first line with "lastMapping"
|
||||
addMappingWithCode(lastMapping, shiftNextLine());
|
||||
lastGeneratedLine++;
|
||||
lastGeneratedColumn = 0;
|
||||
// The remaining code is added without mapping
|
||||
} else {
|
||||
// There is no new line in between.
|
||||
// Associate the code between "lastGeneratedColumn" and
|
||||
// "mapping.generatedColumn" with "lastMapping"
|
||||
var nextLine = remainingLines[remainingLinesIndex];
|
||||
var code = nextLine.substr(0, mapping.generatedColumn -
|
||||
lastGeneratedColumn);
|
||||
remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn -
|
||||
lastGeneratedColumn);
|
||||
lastGeneratedColumn = mapping.generatedColumn;
|
||||
addMappingWithCode(lastMapping, code);
|
||||
// No more remaining code, continue
|
||||
lastMapping = mapping;
|
||||
return;
|
||||
}
|
||||
}
|
||||
// We add the generated code until the first mapping
|
||||
// to the SourceNode without any mapping.
|
||||
// Each line is added as separate string.
|
||||
while (lastGeneratedLine < mapping.generatedLine) {
|
||||
node.add(shiftNextLine());
|
||||
lastGeneratedLine++;
|
||||
}
|
||||
if (lastGeneratedColumn < mapping.generatedColumn) {
|
||||
var nextLine = remainingLines[remainingLinesIndex];
|
||||
node.add(nextLine.substr(0, mapping.generatedColumn));
|
||||
remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn);
|
||||
lastGeneratedColumn = mapping.generatedColumn;
|
||||
}
|
||||
lastMapping = mapping;
|
||||
}, this);
|
||||
// We have processed all mappings.
|
||||
if (remainingLinesIndex < remainingLines.length) {
|
||||
if (lastMapping) {
|
||||
// Associate the remaining code in the current line with "lastMapping"
|
||||
addMappingWithCode(lastMapping, shiftNextLine());
|
||||
}
|
||||
// and add the remaining lines without any mapping
|
||||
node.add(remainingLines.splice(remainingLinesIndex).join(""));
|
||||
}
|
||||
|
||||
// Copy sourcesContent into SourceNode
|
||||
aSourceMapConsumer.sources.forEach(function (sourceFile) {
|
||||
var content = aSourceMapConsumer.sourceContentFor(sourceFile);
|
||||
if (content != null) {
|
||||
if (aRelativePath != null) {
|
||||
sourceFile = util.join(aRelativePath, sourceFile);
|
||||
}
|
||||
node.setSourceContent(sourceFile, content);
|
||||
}
|
||||
});
|
||||
|
||||
return node;
|
||||
|
||||
function addMappingWithCode(mapping, code) {
|
||||
if (mapping === null || mapping.source === undefined) {
|
||||
node.add(code);
|
||||
} else {
|
||||
var source = aRelativePath
|
||||
? util.join(aRelativePath, mapping.source)
|
||||
: mapping.source;
|
||||
node.add(new SourceNode(mapping.originalLine,
|
||||
mapping.originalColumn,
|
||||
source,
|
||||
code,
|
||||
mapping.name));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Add a chunk of generated JS to this source node.
|
||||
*
|
||||
* @param aChunk A string snippet of generated JS code, another instance of
|
||||
* SourceNode, or an array where each member is one of those things.
|
||||
*/
|
||||
SourceNode.prototype.add = function SourceNode_add(aChunk) {
|
||||
if (Array.isArray(aChunk)) {
|
||||
aChunk.forEach(function (chunk) {
|
||||
this.add(chunk);
|
||||
}, this);
|
||||
}
|
||||
else if (aChunk[isSourceNode] || typeof aChunk === "string") {
|
||||
if (aChunk) {
|
||||
this.children.push(aChunk);
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new TypeError(
|
||||
"Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
|
||||
);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Add a chunk of generated JS to the beginning of this source node.
|
||||
*
|
||||
* @param aChunk A string snippet of generated JS code, another instance of
|
||||
* SourceNode, or an array where each member is one of those things.
|
||||
*/
|
||||
SourceNode.prototype.prepend = function SourceNode_prepend(aChunk) {
|
||||
if (Array.isArray(aChunk)) {
|
||||
for (var i = aChunk.length-1; i >= 0; i--) {
|
||||
this.prepend(aChunk[i]);
|
||||
}
|
||||
}
|
||||
else if (aChunk[isSourceNode] || typeof aChunk === "string") {
|
||||
this.children.unshift(aChunk);
|
||||
}
|
||||
else {
|
||||
throw new TypeError(
|
||||
"Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
|
||||
);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Walk over the tree of JS snippets in this node and its children. The
|
||||
* walking function is called once for each snippet of JS and is passed that
|
||||
* snippet and the its original associated source's line/column location.
|
||||
*
|
||||
* @param aFn The traversal function.
|
||||
*/
|
||||
SourceNode.prototype.walk = function SourceNode_walk(aFn) {
|
||||
var chunk;
|
||||
for (var i = 0, len = this.children.length; i < len; i++) {
|
||||
chunk = this.children[i];
|
||||
if (chunk[isSourceNode]) {
|
||||
chunk.walk(aFn);
|
||||
}
|
||||
else {
|
||||
if (chunk !== '') {
|
||||
aFn(chunk, { source: this.source,
|
||||
line: this.line,
|
||||
column: this.column,
|
||||
name: this.name });
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between
|
||||
* each of `this.children`.
|
||||
*
|
||||
* @param aSep The separator.
|
||||
*/
|
||||
SourceNode.prototype.join = function SourceNode_join(aSep) {
|
||||
var newChildren;
|
||||
var i;
|
||||
var len = this.children.length;
|
||||
if (len > 0) {
|
||||
newChildren = [];
|
||||
for (i = 0; i < len-1; i++) {
|
||||
newChildren.push(this.children[i]);
|
||||
newChildren.push(aSep);
|
||||
}
|
||||
newChildren.push(this.children[i]);
|
||||
this.children = newChildren;
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Call String.prototype.replace on the very right-most source snippet. Useful
|
||||
* for trimming whitespace from the end of a source node, etc.
|
||||
*
|
||||
* @param aPattern The pattern to replace.
|
||||
* @param aReplacement The thing to replace the pattern with.
|
||||
*/
|
||||
SourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) {
|
||||
var lastChild = this.children[this.children.length - 1];
|
||||
if (lastChild[isSourceNode]) {
|
||||
lastChild.replaceRight(aPattern, aReplacement);
|
||||
}
|
||||
else if (typeof lastChild === 'string') {
|
||||
this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement);
|
||||
}
|
||||
else {
|
||||
this.children.push(''.replace(aPattern, aReplacement));
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the source content for a source file. This will be added to the SourceMapGenerator
|
||||
* in the sourcesContent field.
|
||||
*
|
||||
* @param aSourceFile The filename of the source file
|
||||
* @param aSourceContent The content of the source file
|
||||
*/
|
||||
SourceNode.prototype.setSourceContent =
|
||||
function SourceNode_setSourceContent(aSourceFile, aSourceContent) {
|
||||
this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent;
|
||||
};
|
||||
|
||||
/**
|
||||
* Walk over the tree of SourceNodes. The walking function is called for each
|
||||
* source file content and is passed the filename and source content.
|
||||
*
|
||||
* @param aFn The traversal function.
|
||||
*/
|
||||
SourceNode.prototype.walkSourceContents =
|
||||
function SourceNode_walkSourceContents(aFn) {
|
||||
for (var i = 0, len = this.children.length; i < len; i++) {
|
||||
if (this.children[i][isSourceNode]) {
|
||||
this.children[i].walkSourceContents(aFn);
|
||||
}
|
||||
}
|
||||
|
||||
var sources = Object.keys(this.sourceContents);
|
||||
for (var i = 0, len = sources.length; i < len; i++) {
|
||||
aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Return the string representation of this source node. Walks over the tree
|
||||
* and concatenates all the various snippets together to one string.
|
||||
*/
|
||||
SourceNode.prototype.toString = function SourceNode_toString() {
|
||||
var str = "";
|
||||
this.walk(function (chunk) {
|
||||
str += chunk;
|
||||
});
|
||||
return str;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the string representation of this source node along with a source
|
||||
* map.
|
||||
*/
|
||||
SourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) {
|
||||
var generated = {
|
||||
code: "",
|
||||
line: 1,
|
||||
column: 0
|
||||
};
|
||||
var map = new SourceMapGenerator(aArgs);
|
||||
var sourceMappingActive = false;
|
||||
var lastOriginalSource = null;
|
||||
var lastOriginalLine = null;
|
||||
var lastOriginalColumn = null;
|
||||
var lastOriginalName = null;
|
||||
this.walk(function (chunk, original) {
|
||||
generated.code += chunk;
|
||||
if (original.source !== null
|
||||
&& original.line !== null
|
||||
&& original.column !== null) {
|
||||
if(lastOriginalSource !== original.source
|
||||
|| lastOriginalLine !== original.line
|
||||
|| lastOriginalColumn !== original.column
|
||||
|| lastOriginalName !== original.name) {
|
||||
map.addMapping({
|
||||
source: original.source,
|
||||
original: {
|
||||
line: original.line,
|
||||
column: original.column
|
||||
},
|
||||
generated: {
|
||||
line: generated.line,
|
||||
column: generated.column
|
||||
},
|
||||
name: original.name
|
||||
});
|
||||
}
|
||||
lastOriginalSource = original.source;
|
||||
lastOriginalLine = original.line;
|
||||
lastOriginalColumn = original.column;
|
||||
lastOriginalName = original.name;
|
||||
sourceMappingActive = true;
|
||||
} else if (sourceMappingActive) {
|
||||
map.addMapping({
|
||||
generated: {
|
||||
line: generated.line,
|
||||
column: generated.column
|
||||
}
|
||||
});
|
||||
lastOriginalSource = null;
|
||||
sourceMappingActive = false;
|
||||
}
|
||||
for (var idx = 0, length = chunk.length; idx < length; idx++) {
|
||||
if (chunk.charCodeAt(idx) === NEWLINE_CODE) {
|
||||
generated.line++;
|
||||
generated.column = 0;
|
||||
// Mappings end at eol
|
||||
if (idx + 1 === length) {
|
||||
lastOriginalSource = null;
|
||||
sourceMappingActive = false;
|
||||
} else if (sourceMappingActive) {
|
||||
map.addMapping({
|
||||
source: original.source,
|
||||
original: {
|
||||
line: original.line,
|
||||
column: original.column
|
||||
},
|
||||
generated: {
|
||||
line: generated.line,
|
||||
column: generated.column
|
||||
},
|
||||
name: original.name
|
||||
});
|
||||
}
|
||||
} else {
|
||||
generated.column++;
|
||||
}
|
||||
}
|
||||
});
|
||||
this.walkSourceContents(function (sourceFile, sourceContent) {
|
||||
map.setSourceContent(sourceFile, sourceContent);
|
||||
});
|
||||
|
||||
return { code: generated.code, map: map };
|
||||
};
|
||||
|
||||
exports.SourceNode = SourceNode;
|
417
node_modules/snapdragon/node_modules/source-map/lib/util.js
generated
vendored
Normal file
417
node_modules/snapdragon/node_modules/source-map/lib/util.js
generated
vendored
Normal file
|
@ -0,0 +1,417 @@
|
|||
/* -*- Mode: js; js-indent-level: 2; -*- */
|
||||
/*
|
||||
* Copyright 2011 Mozilla Foundation and contributors
|
||||
* Licensed under the New BSD license. See LICENSE or:
|
||||
* http://opensource.org/licenses/BSD-3-Clause
|
||||
*/
|
||||
|
||||
/**
|
||||
* This is a helper function for getting values from parameter/options
|
||||
* objects.
|
||||
*
|
||||
* @param args The object we are extracting values from
|
||||
* @param name The name of the property we are getting.
|
||||
* @param defaultValue An optional value to return if the property is missing
|
||||
* from the object. If this is not specified and the property is missing, an
|
||||
* error will be thrown.
|
||||
*/
|
||||
function getArg(aArgs, aName, aDefaultValue) {
|
||||
if (aName in aArgs) {
|
||||
return aArgs[aName];
|
||||
} else if (arguments.length === 3) {
|
||||
return aDefaultValue;
|
||||
} else {
|
||||
throw new Error('"' + aName + '" is a required argument.');
|
||||
}
|
||||
}
|
||||
exports.getArg = getArg;
|
||||
|
||||
var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.]*)(?::(\d+))?(\S*)$/;
|
||||
var dataUrlRegexp = /^data:.+\,.+$/;
|
||||
|
||||
function urlParse(aUrl) {
|
||||
var match = aUrl.match(urlRegexp);
|
||||
if (!match) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
scheme: match[1],
|
||||
auth: match[2],
|
||||
host: match[3],
|
||||
port: match[4],
|
||||
path: match[5]
|
||||
};
|
||||
}
|
||||
exports.urlParse = urlParse;
|
||||
|
||||
function urlGenerate(aParsedUrl) {
|
||||
var url = '';
|
||||
if (aParsedUrl.scheme) {
|
||||
url += aParsedUrl.scheme + ':';
|
||||
}
|
||||
url += '//';
|
||||
if (aParsedUrl.auth) {
|
||||
url += aParsedUrl.auth + '@';
|
||||
}
|
||||
if (aParsedUrl.host) {
|
||||
url += aParsedUrl.host;
|
||||
}
|
||||
if (aParsedUrl.port) {
|
||||
url += ":" + aParsedUrl.port
|
||||
}
|
||||
if (aParsedUrl.path) {
|
||||
url += aParsedUrl.path;
|
||||
}
|
||||
return url;
|
||||
}
|
||||
exports.urlGenerate = urlGenerate;
|
||||
|
||||
/**
|
||||
* Normalizes a path, or the path portion of a URL:
|
||||
*
|
||||
* - Replaces consecutive slashes with one slash.
|
||||
* - Removes unnecessary '.' parts.
|
||||
* - Removes unnecessary '<dir>/..' parts.
|
||||
*
|
||||
* Based on code in the Node.js 'path' core module.
|
||||
*
|
||||
* @param aPath The path or url to normalize.
|
||||
*/
|
||||
function normalize(aPath) {
|
||||
var path = aPath;
|
||||
var url = urlParse(aPath);
|
||||
if (url) {
|
||||
if (!url.path) {
|
||||
return aPath;
|
||||
}
|
||||
path = url.path;
|
||||
}
|
||||
var isAbsolute = exports.isAbsolute(path);
|
||||
|
||||
var parts = path.split(/\/+/);
|
||||
for (var part, up = 0, i = parts.length - 1; i >= 0; i--) {
|
||||
part = parts[i];
|
||||
if (part === '.') {
|
||||
parts.splice(i, 1);
|
||||
} else if (part === '..') {
|
||||
up++;
|
||||
} else if (up > 0) {
|
||||
if (part === '') {
|
||||
// The first part is blank if the path is absolute. Trying to go
|
||||
// above the root is a no-op. Therefore we can remove all '..' parts
|
||||
// directly after the root.
|
||||
parts.splice(i + 1, up);
|
||||
up = 0;
|
||||
} else {
|
||||
parts.splice(i, 2);
|
||||
up--;
|
||||
}
|
||||
}
|
||||
}
|
||||
path = parts.join('/');
|
||||
|
||||
if (path === '') {
|
||||
path = isAbsolute ? '/' : '.';
|
||||
}
|
||||
|
||||
if (url) {
|
||||
url.path = path;
|
||||
return urlGenerate(url);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
exports.normalize = normalize;
|
||||
|
||||
/**
|
||||
* Joins two paths/URLs.
|
||||
*
|
||||
* @param aRoot The root path or URL.
|
||||
* @param aPath The path or URL to be joined with the root.
|
||||
*
|
||||
* - If aPath is a URL or a data URI, aPath is returned, unless aPath is a
|
||||
* scheme-relative URL: Then the scheme of aRoot, if any, is prepended
|
||||
* first.
|
||||
* - Otherwise aPath is a path. If aRoot is a URL, then its path portion
|
||||
* is updated with the result and aRoot is returned. Otherwise the result
|
||||
* is returned.
|
||||
* - If aPath is absolute, the result is aPath.
|
||||
* - Otherwise the two paths are joined with a slash.
|
||||
* - Joining for example 'http://' and 'www.example.com' is also supported.
|
||||
*/
|
||||
function join(aRoot, aPath) {
|
||||
if (aRoot === "") {
|
||||
aRoot = ".";
|
||||
}
|
||||
if (aPath === "") {
|
||||
aPath = ".";
|
||||
}
|
||||
var aPathUrl = urlParse(aPath);
|
||||
var aRootUrl = urlParse(aRoot);
|
||||
if (aRootUrl) {
|
||||
aRoot = aRootUrl.path || '/';
|
||||
}
|
||||
|
||||
// `join(foo, '//www.example.org')`
|
||||
if (aPathUrl && !aPathUrl.scheme) {
|
||||
if (aRootUrl) {
|
||||
aPathUrl.scheme = aRootUrl.scheme;
|
||||
}
|
||||
return urlGenerate(aPathUrl);
|
||||
}
|
||||
|
||||
if (aPathUrl || aPath.match(dataUrlRegexp)) {
|
||||
return aPath;
|
||||
}
|
||||
|
||||
// `join('http://', 'www.example.com')`
|
||||
if (aRootUrl && !aRootUrl.host && !aRootUrl.path) {
|
||||
aRootUrl.host = aPath;
|
||||
return urlGenerate(aRootUrl);
|
||||
}
|
||||
|
||||
var joined = aPath.charAt(0) === '/'
|
||||
? aPath
|
||||
: normalize(aRoot.replace(/\/+$/, '') + '/' + aPath);
|
||||
|
||||
if (aRootUrl) {
|
||||
aRootUrl.path = joined;
|
||||
return urlGenerate(aRootUrl);
|
||||
}
|
||||
return joined;
|
||||
}
|
||||
exports.join = join;
|
||||
|
||||
exports.isAbsolute = function (aPath) {
|
||||
return aPath.charAt(0) === '/' || !!aPath.match(urlRegexp);
|
||||
};
|
||||
|
||||
/**
|
||||
* Make a path relative to a URL or another path.
|
||||
*
|
||||
* @param aRoot The root path or URL.
|
||||
* @param aPath The path or URL to be made relative to aRoot.
|
||||
*/
|
||||
function relative(aRoot, aPath) {
|
||||
if (aRoot === "") {
|
||||
aRoot = ".";
|
||||
}
|
||||
|
||||
aRoot = aRoot.replace(/\/$/, '');
|
||||
|
||||
// It is possible for the path to be above the root. In this case, simply
|
||||
// checking whether the root is a prefix of the path won't work. Instead, we
|
||||
// need to remove components from the root one by one, until either we find
|
||||
// a prefix that fits, or we run out of components to remove.
|
||||
var level = 0;
|
||||
while (aPath.indexOf(aRoot + '/') !== 0) {
|
||||
var index = aRoot.lastIndexOf("/");
|
||||
if (index < 0) {
|
||||
return aPath;
|
||||
}
|
||||
|
||||
// If the only part of the root that is left is the scheme (i.e. http://,
|
||||
// file:///, etc.), one or more slashes (/), or simply nothing at all, we
|
||||
// have exhausted all components, so the path is not relative to the root.
|
||||
aRoot = aRoot.slice(0, index);
|
||||
if (aRoot.match(/^([^\/]+:\/)?\/*$/)) {
|
||||
return aPath;
|
||||
}
|
||||
|
||||
++level;
|
||||
}
|
||||
|
||||
// Make sure we add a "../" for each component we removed from the root.
|
||||
return Array(level + 1).join("../") + aPath.substr(aRoot.length + 1);
|
||||
}
|
||||
exports.relative = relative;
|
||||
|
||||
var supportsNullProto = (function () {
|
||||
var obj = Object.create(null);
|
||||
return !('__proto__' in obj);
|
||||
}());
|
||||
|
||||
function identity (s) {
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Because behavior goes wacky when you set `__proto__` on objects, we
|
||||
* have to prefix all the strings in our set with an arbitrary character.
|
||||
*
|
||||
* See https://github.com/mozilla/source-map/pull/31 and
|
||||
* https://github.com/mozilla/source-map/issues/30
|
||||
*
|
||||
* @param String aStr
|
||||
*/
|
||||
function toSetString(aStr) {
|
||||
if (isProtoString(aStr)) {
|
||||
return '$' + aStr;
|
||||
}
|
||||
|
||||
return aStr;
|
||||
}
|
||||
exports.toSetString = supportsNullProto ? identity : toSetString;
|
||||
|
||||
function fromSetString(aStr) {
|
||||
if (isProtoString(aStr)) {
|
||||
return aStr.slice(1);
|
||||
}
|
||||
|
||||
return aStr;
|
||||
}
|
||||
exports.fromSetString = supportsNullProto ? identity : fromSetString;
|
||||
|
||||
function isProtoString(s) {
|
||||
if (!s) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var length = s.length;
|
||||
|
||||
if (length < 9 /* "__proto__".length */) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (s.charCodeAt(length - 1) !== 95 /* '_' */ ||
|
||||
s.charCodeAt(length - 2) !== 95 /* '_' */ ||
|
||||
s.charCodeAt(length - 3) !== 111 /* 'o' */ ||
|
||||
s.charCodeAt(length - 4) !== 116 /* 't' */ ||
|
||||
s.charCodeAt(length - 5) !== 111 /* 'o' */ ||
|
||||
s.charCodeAt(length - 6) !== 114 /* 'r' */ ||
|
||||
s.charCodeAt(length - 7) !== 112 /* 'p' */ ||
|
||||
s.charCodeAt(length - 8) !== 95 /* '_' */ ||
|
||||
s.charCodeAt(length - 9) !== 95 /* '_' */) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (var i = length - 10; i >= 0; i--) {
|
||||
if (s.charCodeAt(i) !== 36 /* '$' */) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Comparator between two mappings where the original positions are compared.
|
||||
*
|
||||
* Optionally pass in `true` as `onlyCompareGenerated` to consider two
|
||||
* mappings with the same original source/line/column, but different generated
|
||||
* line and column the same. Useful when searching for a mapping with a
|
||||
* stubbed out mapping.
|
||||
*/
|
||||
function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {
|
||||
var cmp = mappingA.source - mappingB.source;
|
||||
if (cmp !== 0) {
|
||||
return cmp;
|
||||
}
|
||||
|
||||
cmp = mappingA.originalLine - mappingB.originalLine;
|
||||
if (cmp !== 0) {
|
||||
return cmp;
|
||||
}
|
||||
|
||||
cmp = mappingA.originalColumn - mappingB.originalColumn;
|
||||
if (cmp !== 0 || onlyCompareOriginal) {
|
||||
return cmp;
|
||||
}
|
||||
|
||||
cmp = mappingA.generatedColumn - mappingB.generatedColumn;
|
||||
if (cmp !== 0) {
|
||||
return cmp;
|
||||
}
|
||||
|
||||
cmp = mappingA.generatedLine - mappingB.generatedLine;
|
||||
if (cmp !== 0) {
|
||||
return cmp;
|
||||
}
|
||||
|
||||
return mappingA.name - mappingB.name;
|
||||
}
|
||||
exports.compareByOriginalPositions = compareByOriginalPositions;
|
||||
|
||||
/**
|
||||
* Comparator between two mappings with deflated source and name indices where
|
||||
* the generated positions are compared.
|
||||
*
|
||||
* Optionally pass in `true` as `onlyCompareGenerated` to consider two
|
||||
* mappings with the same generated line and column, but different
|
||||
* source/name/original line and column the same. Useful when searching for a
|
||||
* mapping with a stubbed out mapping.
|
||||
*/
|
||||
function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGenerated) {
|
||||
var cmp = mappingA.generatedLine - mappingB.generatedLine;
|
||||
if (cmp !== 0) {
|
||||
return cmp;
|
||||
}
|
||||
|
||||
cmp = mappingA.generatedColumn - mappingB.generatedColumn;
|
||||
if (cmp !== 0 || onlyCompareGenerated) {
|
||||
return cmp;
|
||||
}
|
||||
|
||||
cmp = mappingA.source - mappingB.source;
|
||||
if (cmp !== 0) {
|
||||
return cmp;
|
||||
}
|
||||
|
||||
cmp = mappingA.originalLine - mappingB.originalLine;
|
||||
if (cmp !== 0) {
|
||||
return cmp;
|
||||
}
|
||||
|
||||
cmp = mappingA.originalColumn - mappingB.originalColumn;
|
||||
if (cmp !== 0) {
|
||||
return cmp;
|
||||
}
|
||||
|
||||
return mappingA.name - mappingB.name;
|
||||
}
|
||||
exports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated;
|
||||
|
||||
function strcmp(aStr1, aStr2) {
|
||||
if (aStr1 === aStr2) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (aStr1 > aStr2) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Comparator between two mappings with inflated source and name strings where
|
||||
* the generated positions are compared.
|
||||
*/
|
||||
function compareByGeneratedPositionsInflated(mappingA, mappingB) {
|
||||
var cmp = mappingA.generatedLine - mappingB.generatedLine;
|
||||
if (cmp !== 0) {
|
||||
return cmp;
|
||||
}
|
||||
|
||||
cmp = mappingA.generatedColumn - mappingB.generatedColumn;
|
||||
if (cmp !== 0) {
|
||||
return cmp;
|
||||
}
|
||||
|
||||
cmp = strcmp(mappingA.source, mappingB.source);
|
||||
if (cmp !== 0) {
|
||||
return cmp;
|
||||
}
|
||||
|
||||
cmp = mappingA.originalLine - mappingB.originalLine;
|
||||
if (cmp !== 0) {
|
||||
return cmp;
|
||||
}
|
||||
|
||||
cmp = mappingA.originalColumn - mappingB.originalColumn;
|
||||
if (cmp !== 0) {
|
||||
return cmp;
|
||||
}
|
||||
|
||||
return strcmp(mappingA.name, mappingB.name);
|
||||
}
|
||||
exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated;
|
72
node_modules/snapdragon/node_modules/source-map/package.json
generated
vendored
Normal file
72
node_modules/snapdragon/node_modules/source-map/package.json
generated
vendored
Normal file
|
@ -0,0 +1,72 @@
|
|||
{
|
||||
"name": "source-map",
|
||||
"description": "Generates and consumes source maps",
|
||||
"version": "0.5.7",
|
||||
"homepage": "https://github.com/mozilla/source-map",
|
||||
"author": "Nick Fitzgerald <nfitzgerald@mozilla.com>",
|
||||
"contributors": [
|
||||
"Tobias Koppers <tobias.koppers@googlemail.com>",
|
||||
"Duncan Beevers <duncan@dweebd.com>",
|
||||
"Stephen Crane <scrane@mozilla.com>",
|
||||
"Ryan Seddon <seddon.ryan@gmail.com>",
|
||||
"Miles Elam <miles.elam@deem.com>",
|
||||
"Mihai Bazon <mihai.bazon@gmail.com>",
|
||||
"Michael Ficarra <github.public.email@michael.ficarra.me>",
|
||||
"Todd Wolfson <todd@twolfson.com>",
|
||||
"Alexander Solovyov <alexander@solovyov.net>",
|
||||
"Felix Gnass <fgnass@gmail.com>",
|
||||
"Conrad Irwin <conrad.irwin@gmail.com>",
|
||||
"usrbincc <usrbincc@yahoo.com>",
|
||||
"David Glasser <glasser@davidglasser.net>",
|
||||
"Chase Douglas <chase@newrelic.com>",
|
||||
"Evan Wallace <evan.exe@gmail.com>",
|
||||
"Heather Arthur <fayearthur@gmail.com>",
|
||||
"Hugh Kennedy <hughskennedy@gmail.com>",
|
||||
"David Glasser <glasser@davidglasser.net>",
|
||||
"Simon Lydell <simon.lydell@gmail.com>",
|
||||
"Jmeas Smith <jellyes2@gmail.com>",
|
||||
"Michael Z Goddard <mzgoddard@gmail.com>",
|
||||
"azu <azu@users.noreply.github.com>",
|
||||
"John Gozde <john@gozde.ca>",
|
||||
"Adam Kirkton <akirkton@truefitinnovation.com>",
|
||||
"Chris Montgomery <christopher.montgomery@dowjones.com>",
|
||||
"J. Ryan Stinnett <jryans@gmail.com>",
|
||||
"Jack Herrington <jherrington@walmartlabs.com>",
|
||||
"Chris Truter <jeffpalentine@gmail.com>",
|
||||
"Daniel Espeset <daniel@danielespeset.com>",
|
||||
"Jamie Wong <jamie.lf.wong@gmail.com>",
|
||||
"Eddy Bruël <ejpbruel@mozilla.com>",
|
||||
"Hawken Rives <hawkrives@gmail.com>",
|
||||
"Gilad Peleg <giladp007@gmail.com>",
|
||||
"djchie <djchie.dev@gmail.com>",
|
||||
"Gary Ye <garysye@gmail.com>",
|
||||
"Nicolas Lalevée <nicolas.lalevee@hibnet.org>"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "http://github.com/mozilla/source-map.git"
|
||||
},
|
||||
"main": "./source-map.js",
|
||||
"files": [
|
||||
"source-map.js",
|
||||
"lib/",
|
||||
"dist/source-map.debug.js",
|
||||
"dist/source-map.js",
|
||||
"dist/source-map.min.js",
|
||||
"dist/source-map.min.js.map"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"license": "BSD-3-Clause",
|
||||
"scripts": {
|
||||
"test": "npm run build && node test/run-tests.js",
|
||||
"build": "webpack --color",
|
||||
"toc": "doctoc --title '## Table of Contents' README.md && doctoc --title '## Table of Contents' CONTRIBUTING.md"
|
||||
},
|
||||
"devDependencies": {
|
||||
"doctoc": "^0.15.0",
|
||||
"webpack": "^1.12.0"
|
||||
},
|
||||
"typings": "source-map"
|
||||
}
|
8
node_modules/snapdragon/node_modules/source-map/source-map.js
generated
vendored
Normal file
8
node_modules/snapdragon/node_modules/source-map/source-map.js
generated
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
/*
|
||||
* Copyright 2009-2011 Mozilla Foundation and contributors
|
||||
* Licensed under the New BSD license. See LICENSE.txt or:
|
||||
* http://opensource.org/licenses/BSD-3-Clause
|
||||
*/
|
||||
exports.SourceMapGenerator = require('./lib/source-map-generator').SourceMapGenerator;
|
||||
exports.SourceMapConsumer = require('./lib/source-map-consumer').SourceMapConsumer;
|
||||
exports.SourceNode = require('./lib/source-node').SourceNode;
|
79
node_modules/snapdragon/package.json
generated
vendored
Normal file
79
node_modules/snapdragon/package.json
generated
vendored
Normal file
|
@ -0,0 +1,79 @@
|
|||
{
|
||||
"name": "snapdragon",
|
||||
"description": "Fast, pluggable and easy-to-use parser-renderer factory.",
|
||||
"version": "0.8.2",
|
||||
"homepage": "https://github.com/jonschlinkert/snapdragon",
|
||||
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
|
||||
"contributors": [
|
||||
"Brian Woodward (https://twitter.com/doowb)",
|
||||
"Edward Betts (http://edwardbetts.com)",
|
||||
"Jon Schlinkert (http://twitter.com/jonschlinkert)"
|
||||
],
|
||||
"repository": "jonschlinkert/snapdragon",
|
||||
"bugs": {
|
||||
"url": "https://github.com/jonschlinkert/snapdragon/issues"
|
||||
},
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"index.js",
|
||||
"lib"
|
||||
],
|
||||
"main": "index.js",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"dependencies": {
|
||||
"base": "^0.11.1",
|
||||
"debug": "^2.2.0",
|
||||
"define-property": "^0.2.5",
|
||||
"extend-shallow": "^2.0.1",
|
||||
"map-cache": "^0.2.2",
|
||||
"source-map": "^0.5.6",
|
||||
"source-map-resolve": "^0.5.0",
|
||||
"use": "^3.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"gulp": "^3.9.1",
|
||||
"gulp-eslint": "^3.0.1",
|
||||
"gulp-format-md": "^0.1.10",
|
||||
"gulp-istanbul": "^1.1.1",
|
||||
"gulp-mocha": "^3.0.1",
|
||||
"gulp-unused": "^0.2.0",
|
||||
"mocha": "^3.0.2"
|
||||
},
|
||||
"keywords": [
|
||||
"lexer",
|
||||
"snapdragon"
|
||||
],
|
||||
"verb": {
|
||||
"toc": false,
|
||||
"layout": "default",
|
||||
"tasks": [
|
||||
"readme"
|
||||
],
|
||||
"plugins": [
|
||||
"gulp-format-md"
|
||||
],
|
||||
"related": {
|
||||
"description": "These libraries use snapdragon:",
|
||||
"list": [
|
||||
"braces",
|
||||
"expand-brackets",
|
||||
"extglob",
|
||||
"micromatch"
|
||||
]
|
||||
},
|
||||
"reflinks": [
|
||||
"css",
|
||||
"pug",
|
||||
"verb",
|
||||
"verb-generate-readme"
|
||||
],
|
||||
"lint": {
|
||||
"reflinks": true
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue