diff --git a/Makefile b/Makefile index 31e964d080835c..1251b54edb71c4 100644 --- a/Makefile +++ b/Makefile @@ -90,6 +90,7 @@ cctest: all test: | cctest # Depends on 'all'. $(PYTHON) tools/test.py --mode=release message parallel sequential -J $(MAKE) jslint + $(MAKE) jslint-docs $(MAKE) cpplint test-parallel: all @@ -519,6 +520,9 @@ bench-idle: jslint: $(NODE) tools/eslint/bin/eslint.js lib src test tools/doc tools/eslint-rules \ --rulesdir tools/eslint-rules --quiet +jslint-docs: + $(NODE) tools/eslint/bin/eslint.js --plugin eslint-plugin-markdown --ext markdown doc/api/ \ + --rulesdir tools/eslint-rules --quiet CPPLINT_EXCLUDE ?= CPPLINT_EXCLUDE += src/node_lttng.cc @@ -545,11 +549,11 @@ CPPLINT_FILES = $(filter-out $(CPPLINT_EXCLUDE), $(wildcard \ cpplint: @$(PYTHON) tools/cpplint.py $(CPPLINT_FILES) -lint: jslint cpplint +lint: jslint jslint-docs cpplint -.PHONY: lint cpplint jslint bench clean docopen docclean doc dist distclean \ +.PHONY: lint cpplint jslint jslint-docs bench clean docopen docclean doc \ check uninstall install install-includes install-bin all staticlib \ dynamiclib test test-all test-addons build-addons website-upload pkg \ blog blogclean tar binary release-only bench-http-simple bench-idle \ bench-all bench bench-misc bench-array bench-buffer bench-net \ - bench-http bench-fs bench-tls cctest run-ci + bench-http bench-fs bench-tls cctest run-ci distclean dist diff --git a/doc/api/.eslintrc b/doc/api/.eslintrc new file mode 100644 index 00000000000000..f3d756112ae85b --- /dev/null +++ b/doc/api/.eslintrc @@ -0,0 +1,5 @@ +## Documentation-specific linter rules + +rules: + strict: 0 + eol-last: 0 diff --git a/doc/api/addons.markdown b/doc/api/addons.markdown index 12b035ad020372..d6fc01b0caad7a 100644 --- a/doc/api/addons.markdown +++ b/doc/api/addons.markdown @@ -318,7 +318,7 @@ Once compiled, the example Addon can be required and used from within Node.js: // test.js const addon = require('./build/Release/addon'); -console.log('This should be eight:', addon.add(3,5)); +console.log('This should be eight:', addon.add(3, 5)); ``` @@ -423,7 +423,7 @@ const addon = require('./build/Release/addon'); var obj1 = addon('hello'); var obj2 = addon('world'); -console.log(obj1.msg+' '+obj2.msg); // 'hello world' +console.log(obj1.msg + ' ' + obj2.msg); // 'hello world' ``` @@ -638,9 +638,9 @@ Test it with: const addon = require('./build/Release/addon'); var obj = new addon.MyObject(10); -console.log( obj.plusOne() ); // 11 -console.log( obj.plusOne() ); // 12 -console.log( obj.plusOne() ); // 13 +console.log(obj.plusOne()); // 11 +console.log(obj.plusOne()); // 12 +console.log(obj.plusOne()); // 13 ``` ### Factory of wrapped objects @@ -649,6 +649,7 @@ Alternatively, it is possible to use a factory pattern to avoid explicitly creating object instances using the JavaScript `new` operator: ```js +/* eslint no-unused-vars:0, no-undef:0 */ var obj = addon.createObject(); // instead of: // var obj = new addon.Object(); @@ -824,14 +825,14 @@ Test it with: const createObject = require('./build/Release/addon'); var obj = createObject(10); -console.log( obj.plusOne() ); // 11 -console.log( obj.plusOne() ); // 12 -console.log( obj.plusOne() ); // 13 +console.log(obj.plusOne()); // 11 +console.log(obj.plusOne()); // 12 +console.log(obj.plusOne()); // 13 var obj2 = createObject(20); -console.log( obj2.plusOne() ); // 21 -console.log( obj2.plusOne() ); // 22 -console.log( obj2.plusOne() ); // 23 +console.log(obj2.plusOne()); // 21 +console.log(obj2.plusOne()); // 22 +console.log(obj2.plusOne()); // 23 ``` @@ -1075,6 +1076,7 @@ Test in JavaScript by running: ```js // test.js +/* eslint no-unused-vars:0 */ const addon = require('./build/Release/addon'); ``` diff --git a/doc/api/assert.markdown b/doc/api/assert.markdown index f0bc4fbd0a5e8e..fad3402cabb895 100644 --- a/doc/api/assert.markdown +++ b/doc/api/assert.markdown @@ -41,6 +41,8 @@ results. For example, the following example does not throw an `AssertionError` because the properties on the [`Error`][] object are non-enumerable: ```js +const assert = require('assert'); + // WARNING: This does not throw an AssertionError! assert.deepEqual(Error('a'), Error('b')); ``` @@ -65,7 +67,7 @@ const obj3 = { a : { b : 1 } -} +}; const obj4 = Object.create(obj1); assert.deepEqual(obj1, obj1); @@ -124,6 +126,8 @@ The following, for instance, will throw the [`TypeError`][] because there is no matching error type in the assertion: ```js +const assert = require('assert'); + assert.doesNotThrow( () => { throw new TypeError('Wrong value'); @@ -136,6 +140,8 @@ However, the following will result in an `AssertionError` with the message 'Got unwanted exception (TypeError)..': ```js +const assert = require('assert'); + assert.doesNotThrow( () => { throw new TypeError('Wrong value'); @@ -149,6 +155,8 @@ parameter, the value of `message` will be appended to the `AssertionError` message: ```js +const assert = require('assert'); + assert.doesNotThrow( () => { throw new TypeError('Wrong value'); @@ -208,7 +216,7 @@ const assert = require('assert'); assert.ifError(0); // OK assert.ifError(1); // Throws 1 -assert.ifError('error') // Throws 'error' +assert.ifError('error'); // Throws 'error' assert.ifError(new Error()); // Throws Error ``` @@ -233,7 +241,7 @@ const obj3 = { a : { b : 1 } -} +}; const obj4 = Object.create(obj1); assert.notDeepEqual(obj1, obj1); @@ -366,6 +374,8 @@ constructor, [`RegExp`][], or validation function. Validate instanceof using constructor: ```js +const assert = require('assert'); + assert.throws( () => { throw new Error('Wrong value'); @@ -377,6 +387,8 @@ assert.throws( Validate error message using [`RegExp`][]: ```js +const assert = require('assert'); + assert.throws( () => { throw new Error('Wrong value'); @@ -388,12 +400,14 @@ assert.throws( Custom error validation: ```js +const assert = require('assert'); + assert.throws( () => { throw new Error('Wrong value'); }, function(err) { - if ( (err instanceof Error) && /value/.test(err) ) { + if ((err instanceof Error) && /value/.test(err)) { return true; } }, diff --git a/doc/api/buffer.markdown b/doc/api/buffer.markdown index 1da5bb83cb4303..f8fc28cc2b30e6 100644 --- a/doc/api/buffer.markdown +++ b/doc/api/buffer.markdown @@ -21,10 +21,13 @@ The `Buffer` class is a global within Node.js, making it unlikely that one would need to ever use `require('buffer')`. ```js +const Buffer = require('buffer').Buffer; + +/* eslint no-unused-vars:0 */ const buf1 = new Buffer(10); // creates a buffer of length 10 -const buf2 = new Buffer([1,2,3]); +const buf2 = new Buffer([1, 2, 3]); // creates a buffer containing [01, 02, 03] const buf3 = new Buffer('test'); @@ -42,6 +45,7 @@ convert back and forth between Buffers and ordinary JavaScript string objects by using an explicit encoding method. ```js +const Buffer = require('buffer').Buffer; const buf = new Buffer('hello world', 'ascii'); console.log(buf.toString('hex')); // prints: 68656c6c6f20776f726c64 @@ -93,6 +97,7 @@ It is possible to create a new Buffer that shares the same allocated memory as a TypedArray instance by using the TypeArray objects `.buffer` property: ```js +const Buffer = require('buffer').Buffer; const arr = new Uint16Array(2); arr[0] = 5000; arr[1] = 4000; @@ -118,6 +123,7 @@ create a Buffer that uses only a part of the `ArrayBuffer`, use the [`buf.slice()`][] function after the Buffer is created: ```js +const Buffer = require('buffer').Buffer; const arr = new Uint16Array(20); const buf = new Buffer(arr.buffer).slice(0, 16); console.log(buf.length); @@ -129,10 +135,11 @@ console.log(buf.length); Buffers can be iterated over using the ECMAScript 2015 (ES6) `for..of` syntax: ```js +const Buffer = require('buffer').Buffer; const buf = new Buffer([1, 2, 3]); for (var b of buf) - console.log(b) + console.log(b); // Prints: // 1 @@ -155,7 +162,9 @@ It can be constructed in a variety of ways. Allocates a new Buffer using an `array` of octets. ```js -const buf = new Buffer([0x62,0x75,0x66,0x66,0x65,0x72]); +const Buffer = require('buffer').Buffer; +/* eslint no-unused-vars:0 */ +const buf = new Buffer([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]); // creates a new Buffer containing ASCII bytes // ['b','u','f','f','e','r'] ``` @@ -167,6 +176,7 @@ const buf = new Buffer([0x62,0x75,0x66,0x66,0x65,0x72]); Copies the passed `buffer` data onto a new `Buffer` instance. ```js +const Buffer = require('buffer').Buffer; const buf1 = new Buffer('buffer'); const buf2 = new Buffer(buf1); @@ -187,6 +197,7 @@ the newly created Buffer will share the same allocated memory as the TypedArray. ```js +const Buffer = require('buffer').Buffer; const arr = new Uint16Array(2); arr[0] = 5000; arr[1] = 4000; @@ -219,6 +230,7 @@ unknown and could contain sensitive data. Use [`buf.fill(0)`][] to initialize a Buffer to zeroes. ```js +const Buffer = require('buffer').Buffer; const buf = new Buffer(5); console.log(buf); // @@ -237,6 +249,7 @@ Creates a new Buffer containing the given JavaScript string `str`. If provided, the `encoding` parameter identifies the strings character encoding. ```js +const Buffer = require('buffer').Buffer; const buf1 = new Buffer('this is a tést'); console.log(buf1.toString()); // prints: this is a tést @@ -261,6 +274,7 @@ a string. Example: ```js +const Buffer = require('buffer').Buffer; const str = '\u00bd + \u00bc = \u00be'; console.log(`${str}: ${str.length} characters, ` + @@ -279,6 +293,7 @@ Compares `buf1` to `buf2` typically for the purpose of sorting arrays of Buffers. This is equivalent is calling [`buf1.compare(buf2)`][]. ```js +const Buffer = require('buffer').Buffer; const arr = [Buffer('1234'), Buffer('0123')]; arr.sort(Buffer.compare); ``` @@ -302,6 +317,7 @@ to provide the length explicitly. Example: build a single Buffer from a list of three Buffers: ```js +const Buffer = require('buffer').Buffer; const buf1 = new Buffer(10).fill(0); const buf2 = new Buffer(14).fill(0); const buf3 = new Buffer(18).fill(0); @@ -344,7 +360,8 @@ range is between `0x00` and `0xFF` (hex) or `0` and `255` (decimal). Example: copy an ASCII string into a Buffer, one byte at a time: ```js -const str = "Node.js"; +const Buffer = require('buffer').Buffer; +const str = 'Node.js'; const buf = new Buffer(str.length); for (var i = 0; i < str.length ; i++) { @@ -369,6 +386,7 @@ Comparison is based on the actual sequence of bytes in each Buffer. * `-1` is returned if `otherBuffer` should come *after* `buf` when sorted. ```js +const Buffer = require('buffer').Buffer; const buf1 = new Buffer('ABC'); const buf2 = new Buffer('BCD'); const buf3 = new Buffer('ABCD'); @@ -403,6 +421,7 @@ Example: build two Buffers, then copy `buf1` from byte 16 through byte 19 into `buf2`, starting at the 8th byte in `buf2`. ```js +const Buffer = require('buffer').Buffer; const buf1 = new Buffer(26); const buf2 = new Buffer(26).fill('!'); @@ -419,6 +438,7 @@ Example: Build a single Buffer, then copy data from one region to an overlapping region in the same Buffer ```js +const Buffer = require('buffer').Buffer; const buf = new Buffer(26); for (var i = 0 ; i < 26 ; i++) { @@ -439,6 +459,7 @@ Creates and returns an [iterator][] of `[index, byte]` pairs from the Buffer contents. ```js +const Buffer = require('buffer').Buffer; const buf = new Buffer('buffer'); for (var pair of buf.entries()) { console.log(pair); @@ -461,6 +482,7 @@ Returns a boolean indicating whether `this` and `otherBuffer` have exactly the same bytes. ```js +const Buffer = require('buffer').Buffer; const buf1 = new Buffer('ABC'); const buf2 = new Buffer('414243', 'hex'); const buf3 = new Buffer('ABCD'); @@ -483,6 +505,7 @@ given it will fill the entire Buffer. The method returns a reference to the Buffer so calls can be chained. ```js +const Buffer = require('buffer').Buffer; const b = new Buffer(50).fill('h'); console.log(b.toString()); // Prints: hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh @@ -502,6 +525,7 @@ default interpreted as UTF8. Buffers will use the entire Buffer (to compare a partial Buffer use [`buf.slice()`][]). Numbers can range from 0 to 255. ```js +const Buffer = require('buffer').Buffer; const buf = new Buffer('this is a buffer'); buf.indexOf('this'); @@ -514,7 +538,7 @@ buf.indexOf(97); // ascii for 'a' // returns 8 buf.indexOf(new Buffer('a buffer example')); // returns -1 -buf.indexOf(new Buffer('a buffer example').slice(0,8)); +buf.indexOf(new Buffer('a buffer example').slice(0, 8)); // returns 8 const utf16Buffer = new Buffer('\u039a\u0391\u03a3\u03a3\u0395', 'ucs2'); @@ -540,6 +564,7 @@ Buffer use [`buf.slice()`][]). Numbers can range from 0 to 255. The `byteOffset` indicates the index in `buf` where searching begins. ```js +const Buffer = require('buffer').Buffer; const buf = new Buffer('this is a buffer'); buf.includes('this'); @@ -552,7 +577,7 @@ buf.includes(97); // ascii for 'a' // returns true buf.includes(new Buffer('a buffer example')); // returns false -buf.includes(new Buffer('a buffer example').slice(0,8)); +buf.includes(new Buffer('a buffer example').slice(0, 8)); // returns true buf.includes('this', 4); // returns false @@ -565,6 +590,7 @@ buf.includes('this', 4); Creates and returns an [iterator][] of Buffer keys (indices). ```js +const Buffer = require('buffer').Buffer; const buf = new Buffer('buffer'); for (var key of buf.keys()) { console.log(key); @@ -588,6 +614,7 @@ Buffer. For instance, in the example below, a Buffer with 1234 bytes is allocated, but only 11 ASCII bytes are written. ```js +const Buffer = require('buffer').Buffer; const buf = new Buffer(1234); console.log(buf.length); @@ -604,11 +631,12 @@ modify the length of a Buffer should therefore treat `length` as read-only and use [`buf.slice()`][] to create a new Buffer. ```js +const Buffer = require('buffer').Buffer; const buf = new Buffer(10); buf.write('abcdefghj', 0, 'ascii'); console.log(buf.length); // Prints: 10 -buf = buf.slice(0,5); +buf = buf.slice(0, 5); console.log(buf.length); // Prints: 5 ``` @@ -628,7 +656,8 @@ Setting `noAssert` to `true` skips validation of the `offset`. This allows the `offset` to be beyond the end of the Buffer. ```js -const buf = new Buffer([1,2,3,4,5,6,7,8]); +const Buffer = require('buffer').Buffer; +const buf = new Buffer([1, 2, 3, 4, 5, 6, 7, 8]); buf.readDoubleBE(); // Returns: 8.20788039913184e-304 @@ -656,7 +685,8 @@ Setting `noAssert` to `true` skips validation of the `offset`. This allows the `offset` to be beyond the end of the Buffer. ```js -const buf = new Buffer([1,2,3,4]); +const Buffer = require('buffer').Buffer; +const buf = new Buffer([1, 2, 3, 4]); buf.readFloatBE(); // Returns: 2.387939260590663e-38 @@ -683,7 +713,8 @@ Setting `noAssert` to `true` skips validation of the `offset`. This allows the Integers read from the Buffer are interpreted as two's complement signed values. ```js -const buf = new Buffer([1,-2,3,4]); +const Buffer = require('buffer').Buffer; +const buf = new Buffer([1, -2, 3, 4]); buf.readInt8(0); // returns 1 @@ -708,7 +739,8 @@ Setting `noAssert` to `true` skips validation of the `offset`. This allows the Integers read from the Buffer are interpreted as two's complement signed values. ```js -const buf = new Buffer([1,-2,3,4]); +const Buffer = require('buffer').Buffer; +const buf = new Buffer([1, -2, 3, 4]); buf.readInt16BE(); // returns 510 @@ -733,7 +765,8 @@ Setting `noAssert` to `true` skips validation of the `offset`. This allows the Integers read from the Buffer are interpreted as two's complement signed values. ```js -const buf = new Buffer([1,-2,3,4]); +const Buffer = require('buffer').Buffer; +const buf = new Buffer([1, -2, 3, 4]); buf.readInt32BE(); // returns 33424132 @@ -754,6 +787,7 @@ and interprets the result as a two's complement signed value. Supports up to 48 bits of accuracy. For example: ```js +const Buffer = require('buffer').Buffer; const buf = new Buffer(6); buf.writeUInt16LE(0x90ab, 0); buf.writeUInt32LE(0x12345678, 2); @@ -779,7 +813,8 @@ Setting `noAssert` to `true` skips validation of the `offset`. This allows the `offset` to be beyond the end of the Buffer. ```js -const buf = new Buffer([1,-2,3,4]); +const Buffer = require('buffer').Buffer; +const buf = new Buffer([1, -2, 3, 4]); buf.readUInt8(0); // returns 1 @@ -804,6 +839,7 @@ Setting `noAssert` to `true` skips validation of the `offset`. This allows the Example: ```js +const Buffer = require('buffer').Buffer; const buf = new Buffer([0x3, 0x4, 0x23, 0x42]); buf.readUInt16BE(0); @@ -837,6 +873,7 @@ Setting `noAssert` to `true` skips validation of the `offset`. This allows the Example: ```js +const Buffer = require('buffer').Buffer; const buf = new Buffer([0x3, 0x4, 0x23, 0x42]); buf.readUInt32BE(0); @@ -858,6 +895,7 @@ and interprets the result as an unsigned integer. Supports up to 48 bits of accuracy. For example: ```js +const Buffer = require('buffer').Buffer; const buf = new Buffer(6); buf.writeUInt16LE(0x90ab, 0); buf.writeUInt32LE(0x12345678, 2); @@ -887,6 +925,7 @@ Example: build a Buffer with the ASCII alphabet, take a slice, then modify one byte from the original Buffer. ```js +const Buffer = require('buffer').Buffer; const buf1 = new Buffer(26); for (var i = 0 ; i < 26 ; i++) { @@ -905,6 +944,7 @@ Specifying negative indexes causes the slice to be generated relative to the end of the Buffer rather than the beginning. ```js +const Buffer = require('buffer').Buffer; const buf = new Buffer('buffer'); buf.slice(-6, -1).toString(); @@ -926,17 +966,18 @@ Decodes and returns a string from the Buffer data using the specified character set `encoding`. ```js +const Buffer = require('buffer').Buffer; const buf = new Buffer(26); for (var i = 0 ; i < 26 ; i++) { buf[i] = i + 97; // 97 is ASCII a } buf.toString('ascii'); // Returns: 'abcdefghijklmnopqrstuvwxyz' -buf.toString('ascii',0,5); +buf.toString('ascii', 0, 5); // Returns: 'abcde' -buf.toString('utf8',0,5); +buf.toString('utf8', 0, 5); // Returns: 'abcde' -buf.toString(undefined,0,5); +buf.toString(undefined, 0, 5); // Returns: 'abcde', encoding defaults to 'utf8' ``` @@ -950,6 +991,7 @@ implicitly calls this function when stringifying a Buffer instance. Example: ```js +const Buffer = require('buffer').Buffer; const buf = new Buffer('test'); const json = JSON.stringify(buf); @@ -957,10 +999,10 @@ console.log(json); // Prints: '{"type":"Buffer","data":[116,101,115,116]}' const copy = JSON.parse(json, (key, value) => { - return value && value.type === 'Buffer' - ? new Buffer(value.data) - : value; - }); + return value && value.type === 'Buffer' + ? new Buffer(value.data) + : value; +}); console.log(copy.toString()); // Prints: 'test' @@ -974,8 +1016,9 @@ Creates and returns an [iterator][] for Buffer values (bytes). This function is called automatically when the Buffer is used in a `for..of` statement. ```js +const Buffer = require('buffer').Buffer; const buf = new Buffer('buffer'); -for (var value of buf.values()) { +for (const value of buf.values()) { console.log(value); } // prints: @@ -985,8 +1028,12 @@ for (var value of buf.values()) { // 102 // 101 // 114 +``` -for (var value of buf) { +```js +const Buffer = require('buffer').Buffer; +const buf = new Buffer('buffer'); +for (const value of buf) { console.log(value); } // prints: @@ -1013,6 +1060,7 @@ string will be written however, it will not write only partially encoded characters. ```js +const Buffer = require('buffer').Buffer; const buf = new Buffer(256); const len = buf.write('\u00bd + \u00bc = \u00be', 0); console.log(`${len} bytes: ${buf.toString('utf8', 0, len)}`); @@ -1039,6 +1087,7 @@ should not be used unless you are certain of correctness. Example: ```js +const Buffer = require('buffer').Buffer; const buf = new Buffer(8); buf.writeDoubleBE(0xdeadbeefcafebabe, 0); @@ -1072,6 +1121,7 @@ should not be used unless you are certain of correctness. Example: ```js +const Buffer = require('buffer').Buffer; const buf = new Buffer(4); buf.writeFloatBE(0xcafebabe, 0); @@ -1102,6 +1152,7 @@ should not be used unless you are certain of correctness. The `value` is interpreted and written as a two's complement signed integer. ```js +const Buffer = require('buffer').Buffer; const buf = new Buffer(2); buf.writeInt8(2, 0); buf.writeInt8(-2, 1); @@ -1129,9 +1180,10 @@ should not be used unless you are certain of correctness. The `value` is interpreted and written as a two's complement signed integer. ```js +const Buffer = require('buffer').Buffer; const buf = new Buffer(4); -buf.writeInt16BE(0x0102,0); -buf.writeInt16LE(0x0304,2); +buf.writeInt16BE(0x0102, 0); +buf.writeInt16LE(0x0304, 2); console.log(buf); // Prints: ``` @@ -1156,9 +1208,10 @@ should not be used unless you are certain of correctness. The `value` is interpreted and written as a two's complement signed integer. ```js +const Buffer = require('buffer').Buffer; const buf = new Buffer(8); -buf.writeInt32BE(0x01020304,0); -buf.writeInt32LE(0x05060708,4); +buf.writeInt32BE(0x01020304, 0); +buf.writeInt32LE(0x05060708, 4); console.log(buf); // Prints: ``` @@ -1176,6 +1229,7 @@ Writes `value` to the Buffer at the specified `offset` and `byteLength`. Supports up to 48 bits of accuracy. For example: ```js +const Buffer = require('buffer').Buffer; const buf1 = new Buffer(6); buf1.writeUIntBE(0x1234567890ab, 0, 6); console.log(buf1); @@ -1210,6 +1264,7 @@ should not be used unless you are certain of correctness. Example: ```js +const Buffer = require('buffer').Buffer; const buf = new Buffer(4); buf.writeUInt8(0x3, 0); buf.writeUInt8(0x4, 1); @@ -1240,6 +1295,7 @@ should not be used unless you are certain of correctness. Example: ```js +const Buffer = require('buffer').Buffer; const buf = new Buffer(4); buf.writeUInt16BE(0xdead, 0); buf.writeUInt16BE(0xbeef, 2); @@ -1274,6 +1330,7 @@ should not be used unless you are certain of correctness. Example: ```js +const Buffer = require('buffer').Buffer; const buf = new Buffer(4); buf.writeUInt32BE(0xfeedface, 0); @@ -1299,6 +1356,7 @@ Writes `value` to the Buffer at the specified `offset` and `byteLength`. Supports up to 48 bits of accuracy. For example: ```js +const Buffer = require('buffer').Buffer; const buf = new Buffer(6); buf.writeUIntBE(0x1234567890ab, 0, 6); console.log(buf); @@ -1336,8 +1394,10 @@ un-pooled Buffer instance using `SlowBuffer` then copy out the relevant bits. ```js // need to keep around a few small chunks of memory +const SlowBuffer = require('buffer').SlowBuffer; const store = []; +/* eslint no-undef:0 */ socket.on('readable', () => { var data = socket.read(); // allocate for retained data diff --git a/doc/api/child_process.markdown b/doc/api/child_process.markdown index 3096fbb641b14f..74e3b8229a878a 100644 --- a/doc/api/child_process.markdown +++ b/doc/api/child_process.markdown @@ -140,6 +140,7 @@ generated output. ```js const exec = require('child_process').exec; +/* eslint no-unused-vars:0 */ const child = exec('cat *.js bad_file | wc -l', (error, stdout, stderr) => { console.log(`stdout: ${stdout}`); @@ -147,7 +148,8 @@ const child = exec('cat *.js bad_file | wc -l', if (error !== null) { console.log(`exec error: ${error}`); } -}); + } +); ``` If a `callback` function is provided, it is called with the arguments @@ -160,7 +162,7 @@ to be an error. The `options` argument may be passed as the second argument to customize how the process is spawned. The default options are: -```js +``` { encoding: 'utf8', timeout: 0, @@ -212,6 +214,7 @@ spawned, behaviors such as I/O redirection and file globbing are not supported. ```js const execFile = require('child_process').execFile; +/* eslint no-unused-vars:0 */ const child = execFile('node', ['--version'], (error, stdout, stderr) => { if (error) { throw error; @@ -290,7 +293,7 @@ to an empty array. A third argument may be used to specify additional options, with these defaults: -```js +``` { cwd: undefined, env: process.env @@ -401,8 +404,8 @@ const out = fs.openSync('./out.log', 'a'); const err = fs.openSync('./out.log', 'a'); const child = spawn('prg', [], { - detached: true, - stdio: [ 'ignore', out, err ] + detached: true, + stdio: [ 'ignore', out, err ] }); child.unref(); @@ -940,11 +943,11 @@ const fs = require('fs'); const child_process = require('child_process'); const child = child_process.spawn('ls', { - stdio: [ - 0, // Use parents stdin for child - 'pipe', // Pipe child's stdout to parent - fs.openSync('err.out', 'w') // Direct child's stderr to a file - ] + stdio: [ + 0, // Use parents stdin for child + 'pipe', // Pipe child's stdout to parent + fs.openSync('err.out', 'w') // Direct child's stderr to a file + ] }); assert.equal(child.stdio[0], null); diff --git a/doc/api/cluster.markdown b/doc/api/cluster.markdown index 215e48b12a4286..c2f8da620dd985 100644 --- a/doc/api/cluster.markdown +++ b/doc/api/cluster.markdown @@ -118,6 +118,8 @@ it can be obtained using `cluster.worker`. Similar to the `cluster.on('disconnect')` event, but specific to this worker. ```js +const cluster = require('cluster'); + cluster.fork().on('disconnect', () => { // Worker has disconnected }); @@ -138,11 +140,12 @@ In a worker you can also use `process.on('error')`. Similar to the `cluster.on('exit')` event, but specific to this worker. ```js +const cluster = require('cluster'); const worker = cluster.fork(); worker.on('exit', (code, signal) => { - if( signal ) { + if (signal) { console.log(`worker was killed by signal: ${signal}`); - } else if( code !== 0 ) { + } else if (code !== 0) { console.log(`worker exited with error code: ${code}`); } else { console.log('worker success!'); @@ -157,6 +160,8 @@ worker.on('exit', (code, signal) => { Similar to the `cluster.on('listening')` event, but specific to this worker. ```js +const cluster = require('cluster'); + cluster.fork().on('listening', (address) => { // Worker is listening }); @@ -224,6 +229,8 @@ if (cluster.isMaster) { Similar to the `cluster.on('online')` event, but specific to this worker. ```js +const cluster = require('cluster'); + cluster.fork().on('online', () => { // Worker is online }); @@ -260,6 +267,8 @@ close them. It also may be useful to implement a timeout, killing a worker if the `'disconnect'` event has not been emitted after some time. ```js +const cluster = require('cluster'); + if (cluster.isMaster) { var worker = cluster.fork(); var timeout; @@ -285,7 +294,7 @@ if (cluster.isMaster) { server.listen(8000); process.on('message', (msg) => { - if(msg === 'shutdown') { + if (msg === 'shutdown') { // initiate graceful close of any connections to server } }); @@ -361,6 +370,8 @@ In a worker this sends a message to the master. It is identical to This example will echo back all messages from the master: ```js +const cluster = require('cluster'); + if (cluster.isMaster) { var worker = cluster.fork(); worker.send('hi there'); @@ -382,13 +393,16 @@ The boolean `worker.suicide` lets you distinguish between voluntary and accident exit, the master may choose not to respawn a worker based on this value. ```js +const cluster = require('cluster'); + cluster.on('exit', (worker, code, signal) => { if (worker.suicide === true) { - console.log('Oh, it was just suicide\' – no need to worry'). + console.log('Oh, it was just suicide\' – no need to worry'); } }); // kill worker +/* eslint no-undef:0 */ worker.kill(); ``` @@ -405,6 +419,8 @@ can be used to detect if the process is stuck in a cleanup or if there are long-living connections. ```js +const cluster = require('cluster'); + cluster.on('disconnect', (worker) => { console.log(`The worker #${worker.id} has disconnected`); }); @@ -422,6 +438,8 @@ When any of the workers die the cluster module will emit the `'exit'` event. This can be used to restart the worker by calling `.fork()` again. ```js +const cluster = require('cluster'); + cluster.on('exit', (worker, code, signal) => { console.log('worker %d died (%s). restarting...', worker.process.pid, signal || code); @@ -439,6 +457,8 @@ When a new worker is forked the cluster module will emit a `'fork'` event. This can be used to log worker activity, and create your own timeout. ```js +const cluster = require('cluster'); + var timeouts = []; function errorMsg() { console.error('Something must be wrong with the connection ...'); @@ -470,6 +490,8 @@ object and the `address` object contains the following connection properties: on more than one address. ```js +const cluster = require('cluster'); + cluster.on('listening', (worker, address) => { console.log( `A worker is now connected to ${address.address}:${address.port}`); @@ -502,6 +524,8 @@ The difference between `'fork'` and `'online'` is that fork is emitted when the master forks a worker, and 'online' is emitted when the worker is running. ```js +const cluster = require('cluster'); + cluster.on('online', (worker) => { console.log('Yay, the worker responded after it was forked'); }); @@ -663,6 +687,8 @@ However, it is guaranteed that the removal from the cluster.workers list happens before last `'disconnect'` or `'exit'` event is emitted. ```js +const cluster = require('cluster'); + // Go through all workers function eachWorker(callback) { for (var id in cluster.workers) { @@ -678,6 +704,9 @@ Should you wish to reference a worker over a communication channel, using the worker's unique id is the easiest way to find the worker. ```js +const cluster = require('cluster'); + +/* eslint no-undef:0, no-unused-vars:0 */ socket.on('data', (id) => { var worker = cluster.workers[id]; }); diff --git a/doc/api/console.markdown b/doc/api/console.markdown index 5ca6ddc149e5f8..220bcbd7781a87 100644 --- a/doc/api/console.markdown +++ b/doc/api/console.markdown @@ -31,6 +31,7 @@ console.warn(`Danger ${name}! Danger!`); Example using the `Console` class: ```js +/* eslint no-undef:0 */ const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); @@ -67,7 +68,9 @@ output streams and can be accessed using either `require('console').Console` or `console.Console`: ```js +/* eslint no-unused-vars:0 */ const Console = require('console').Console; +/* eslint no-redeclare:0 */ const Console = console.Console; ``` @@ -79,6 +82,8 @@ is used for warning or error output. If `stderr` isn't passed, the warning and error output will be sent to the `stdout`. ```js +const fs = require('fs'); +const Console = require('console').Console; const output = fs.createWriteStream('./stdout.log'); const errorOutput = fs.createWriteStream('./stderr.log'); // custom simple logger @@ -93,6 +98,8 @@ The global `console` is a special `Console` whose output is sent to `process.stdout` and `process.stderr`. It is equivalent to calling: ```js +/* eslint no-unused-vars:0 */ +const Console = require('console').Console; new Console(process.stdout, process.stderr); ``` @@ -184,7 +191,7 @@ prints the result to stdout: ```js console.time('100-elements'); for (var i = 0; i < 100; i++) { - ; + // Do Nothing } console.timeEnd('100-elements'); // prints 100-elements: 225.438ms diff --git a/doc/api/crypto.markdown b/doc/api/crypto.markdown index 72f241b03acb19..829f5f30c4dfce 100644 --- a/doc/api/crypto.markdown +++ b/doc/api/crypto.markdown @@ -36,6 +36,7 @@ or by calling `crypto.Certificate()` as a function: ```js const crypto = require('crypto'); +/* eslint no-unused-vars:0 */ const cert1 = new crypto.Certificate(); const cert2 = crypto.Certificate(); ``` @@ -49,6 +50,7 @@ or a [`Buffer`][]. ```js const cert = require('crypto').Certificate(); +/* eslint no-undef:0 */ const spkac = getSpkacSomehow(); const challenge = cert.exportChallenge(spkac); console.log(challenge.toString('utf8')); @@ -64,6 +66,7 @@ or a [`Buffer`][]. ```js const cert = require('crypto').Certificate(); +/* eslint no-undef:0 */ const spkac = getSpkacSomehow(); const publicKey = cert.exportPublicKey(spkac); console.log(publicKey); @@ -76,7 +79,9 @@ Returns `true` if the given `spkac` data structure is valid, `false` otherwise. The `spkac` argument must be a Node.js [`Buffer`][]. ```js +const Buffer = require('buffer').Buffer; const cert = require('crypto').Certificate(); +/* eslint no-undef:0 */ const spkac = getSpkacSomehow(); console.log(cert.verifySpkac(new Buffer(spkac))); // Prints true or false @@ -221,14 +226,15 @@ var decrypted = ''; decipher.on('readable', () => { var data = decipher.read(); if (data) - decrypted += data.toString('utf8'); + decrypted += data.toString('utf8'); }); decipher.on('end', () => { console.log(decrypted); // Prints: some clear text data }); -var encrypted = 'ca981be48e90867604588e75d04feabb63cc007a8f8ad89b10616ed84d815504'; +var encrypted = + 'ca981be48e90867604588e75d04feabb63cc007a8f8ad89b10616ed84d815504'; decipher.write(encrypted, 'hex'); decipher.end(); ``` @@ -252,7 +258,8 @@ Example: Using the `decipher.update()` and `decipher.final()` methods: const crypto = require('crypto'); const decipher = crypto.createDecipher('aes192', 'a password'); -var encrypted = 'ca981be48e90867604588e75d04feabb63cc007a8f8ad89b10616ed84d815504'; +var encrypted = + 'ca981be48e90867604588e75d04feabb63cc007a8f8ad89b10616ed84d815504'; var decrypted = decipher.update(encrypted, 'hex', 'utf8'); decrypted += decipher.final('utf8'); console.log(decrypted); @@ -695,6 +702,7 @@ const sign = crypto.createSign('RSA-SHA256'); sign.write('some data to sign'); sign.end(); +/* eslint no-undef:0 */ const private_key = getPrivateKeySomehow(); console.log(sign.sign(private_key, 'hex')); // Prints the calculated signature @@ -708,6 +716,7 @@ const sign = crypto.createSign('RSA-SHA256'); sign.update('some data to sign'); +/* eslint no-undef:0 */ const private_key = getPrivateKeySomehow(); console.log(sign.sign(private_key, 'hex')); // Prints the calculated signature @@ -759,6 +768,7 @@ const verify = crypto.createVerify('RSA-SHA256'); verify.write('some data to sign'); verify.end(); +/* eslint no-undef:0 */ const public_key = getPublicKeySomehow(); const signature = getSignatureToVerify(); console.log(sign.verify(public_key, signature)); @@ -773,6 +783,7 @@ const verify = crypto.createVerify('RSA-SHA256'); verify.update('some data to sign'); +/* eslint no-undef:0 */ const public_key = getPublicKeySomehow(); const signature = getSignatureToVerify(); console.log(verify.verify(public_key, signature)); @@ -1018,6 +1029,7 @@ Returns an array with the names of the supported cipher algorithms. Example: ```js +const crypto = require('crypto'); const ciphers = crypto.getCiphers(); console.log(ciphers); // ['aes-128-cbc', 'aes-128-ccm', ...] ``` @@ -1029,6 +1041,7 @@ Returns an array with the names of the supported elliptic curves. Example: ```js +const crypto = require('crypto'); const curves = crypto.getCurves(); console.log(curves); // ['secp256k1', 'secp384r1', ...] ``` @@ -1070,6 +1083,7 @@ Returns an array with the names of the supported hash algorithms. Example: ```js +const crypto = require('crypto'); const hashes = crypto.getHashes(); console.log(hashes); // ['sha', 'sha1', 'sha1WithRSAEncryption', ...] ``` @@ -1229,7 +1243,7 @@ const crypto = require('crypto'); crypto.randomBytes(256, (err, buf) => { if (err) throw err; console.log( - `${buf.length}` bytes of random data: ${buf.toString('hex')}); + `${buf.length} bytes of random data: ${buf.toString('hex')}`); }); ``` @@ -1239,9 +1253,10 @@ there is a problem generating the bytes. ```js // Synchronous +const crypto = require('crypto'); const buf = crypto.randomBytes(256); console.log( - `${buf.length}` bytes of random data: ${buf.toString('hex')}); + `${buf.length} bytes of random data: ${buf.toString('hex')}`); ``` The `crypto.randomBytes()` method will block until there is sufficient entropy. diff --git a/doc/api/debugger.markdown b/doc/api/debugger.markdown index 2bbaf9049eb5fb..d602255822c2f7 100644 --- a/doc/api/debugger.markdown +++ b/doc/api/debugger.markdown @@ -30,8 +30,10 @@ For example, suppose `myscript.js` is written as: ```js // myscript.js -x = 5; +/* eslint no-unused-vars:0 */ +const x = 5; setTimeout(() => { +/* eslint no-debugger:0 */ debugger; console.log('world'); }, 1000); diff --git a/doc/api/dgram.markdown b/doc/api/dgram.markdown index fc6e256c70b1a7..02af00853f1040 100644 --- a/doc/api/dgram.markdown +++ b/doc/api/dgram.markdown @@ -64,6 +64,7 @@ The event handler function is passed two arguments: `msg` and `rinfo`. The address information provided by the `address`, `family` and `port` properties: ```js +/* eslint no-undef:0 */ socket.on('message', (msg, rinfo) => { console.log('Received %d bytes from %s:%d\n', msg.length, rinfo.address, rinfo.port); @@ -160,6 +161,7 @@ port sharing results in an error. An example socket listening on an exclusive port is shown below. ```js +/* eslint no-undef:0 */ socket.bind({ address: 'localhost', port: 8000, @@ -236,6 +238,7 @@ Example of sending a UDP packet to a random port on `localhost`; ```js const dgram = require('dgram'); +const Buffer = require('buffer').Buffer; const message = new Buffer('Some bytes'); const client = dgram.createSocket('udp4'); client.send(message, 41234, 'localhost', (err) => { @@ -247,6 +250,7 @@ Example of sending a UDP packet composed of multiple buffers to a random port on ```js const dgram = require('dgram'); +const Buffer = require('buffer').Buffer; const buf1 = new Buffer('Some '); const buf2 = new Buffer('bytes'); const client = dgram.createSocket('udp4'); @@ -358,6 +362,7 @@ execution model. Legacy code that assumes synchronous behavior, as in the following example: ```js +const dgram = require('dgram'); const s = dgram.createSocket('udp4'); s.bind(1234); s.addMembership('224.0.0.114'); @@ -367,6 +372,7 @@ Must be changed to pass a callback function to the [`dgram.Socket#bind()`][] function: ```js +const dgram = require('dgram'); const s = dgram.createSocket('udp4'); s.bind(1234, () => { s.addMembership('224.0.0.114'); diff --git a/doc/api/domain.markdown b/doc/api/domain.markdown index 41d27c5625f896..753ff7a5031913 100644 --- a/doc/api/domain.markdown +++ b/doc/api/domain.markdown @@ -46,6 +46,7 @@ For example, this is not a good idea: ```js // XXX WARNING! BAD IDEA! +const PORT = 8000; var d = require('domain').create(); d.on('error', (er) => { @@ -57,6 +58,7 @@ d.on('error', (er) => { }); d.run(() => { require('http').createServer((req, res) => { +/* eslint no-undef:0 */ handleRequest(req, res); }).listen(PORT); }); @@ -156,11 +158,12 @@ if (cluster.isMaster) { // This part isn't important. Just an example routing thing. // You'd put your fancy application logic here. function handleRequest(req, res) { - switch(req.url) { + switch (req.url) { case '/error': // We do some async stuff, and then... setTimeout(() => { // Whoops! +/* eslint no-undef:0 */ flerb.bark(); }); break; @@ -346,8 +349,11 @@ thrown will be routed to the domain's `'error'` event. #### Example ```js +const fs = require('fs'); +const domain = require('domain'); const d = domain.create(); +/* eslint no-unused-vars:0 */ function readSomeFile(filename, cb) { fs.readFile(filename, 'utf8', d.bind((er, data) => { // if this throws, it will also be passed to the domain @@ -377,8 +383,11 @@ with a single error handler in a single place. #### Example ```js +const fs = require('fs'); +const domain = require('domain'); const d = domain.create(); +/* eslint no-unused-vars:0 */ function readSomeFile(filename, cb) { fs.readFile(filename, 'utf8', d.intercept((data) => { // note, the first argument is never passed to the diff --git a/doc/api/errors.markdown b/doc/api/errors.markdown index 342fd9710ed2ac..a0d6716efdd89e 100644 --- a/doc/api/errors.markdown +++ b/doc/api/errors.markdown @@ -42,6 +42,7 @@ language. ```js // Throws with a ReferenceError because z is undefined try { +/* eslint no-unused-vars:0, no-undef:0 */ const m = 1; const n = m + z; } catch (err) { @@ -141,15 +142,15 @@ the first argument will be passed as `null`. const fs = require('fs'); function nodeStyleCallback(err, data) { - if (err) { - console.error('There was an error', err); - return; - } - console.log(data); + if (err) { + console.error('There was an error', err); + return; + } + console.log(data); } fs.readFile('/some/file/that/does-not-exist', nodeStyleCallback); -fs.readFile('/some/file/that/does-exist', nodeStyleCallback) +fs.readFile('/some/file/that/does-exist', nodeStyleCallback); ``` The JavaScript `try / catch` mechanism **cannot** be used to intercept errors @@ -167,7 +168,7 @@ try { throw err; } }); -} catch(err) { +} catch (err) { // This will not catch the throw! console.log(err); } @@ -212,7 +213,7 @@ a string representing the location in the code at which ```js const myObject = {}; Error.captureStackTrace(myObject); -myObject.stack // similar to `new Error().stack` +myObject.stack; // similar to `new Error().stack` ``` The first line of the trace, instead of being prefixed with `ErrorType: @@ -233,7 +234,7 @@ function MyError() { // Without passing MyError to captureStackTrace, the MyError // frame would should up in the .stack property. by passing // the constructor, we omit that frame and all frames above it. -new MyError().stack +new MyError().stack; ``` ### Error.stackTraceLimit @@ -363,6 +364,7 @@ While client code may generate and propagate these errors, in practice, only V8 will do so. ```js +/* eslint no-undef:0 */ doesNotExist; // throws ReferenceError, doesNotExist is not a variable in this program. ``` @@ -374,8 +376,9 @@ that was not defined. ```js const assert = require('assert'); try { +/* eslint no-undef:0 */ doesNotExist; -} catch(err) { +} catch (err) { assert(err.arguments[0], 'doesNotExist'); } ``` @@ -395,7 +398,7 @@ program. ```js try { require('vm').runInThisContext('binary ! isNotOk'); -} catch(err) { +} catch (err) { // err will be a SyntaxError } ``` diff --git a/doc/api/events.markdown b/doc/api/events.markdown index 0afd583ebc35d7..16fb9c34fd59c4 100644 --- a/doc/api/events.markdown +++ b/doc/api/events.markdown @@ -69,6 +69,14 @@ keyword is intentionally set to reference the `EventEmitter` to which the listener is attached. ```js +const EventEmitter = require('events'); +const util = require('util'); + +function MyEmitter() { + EventEmitter.call(this); +} +util.inherits(MyEmitter, EventEmitter); + const myEmitter = new MyEmitter(); myEmitter.on('event', function(a, b) { console.log(a, b, this); @@ -86,6 +94,14 @@ It is possible to use ES6 Arrow Functions as listeners, however, when doing so, the `this` keyword will no longer reference the `EventEmitter` instance: ```js +const EventEmitter = require('events'); +const util = require('util'); + +function MyEmitter() { + EventEmitter.call(this); +} +util.inherits(MyEmitter, EventEmitter); + const myEmitter = new MyEmitter(); myEmitter.on('event', (a, b) => { console.log(a, b, this); @@ -103,6 +119,14 @@ listener functions can switch to an asynchronous mode of operation using the `setImmediate()` or `process.nextTick()` methods: ```js +const EventEmitter = require('events'); +const util = require('util'); + +function MyEmitter() { + EventEmitter.call(this); +} +util.inherits(MyEmitter, EventEmitter); + const myEmitter = new MyEmitter(); myEmitter.on('event', (a, b) => { setImmediate(() => { @@ -118,6 +142,14 @@ When a listener is registered using the `eventEmitter.on()` method, that listener will be invoked _every time_ the named event is emitted. ```js +const EventEmitter = require('events'); +const util = require('util'); + +function MyEmitter() { + EventEmitter.call(this); +} +util.inherits(MyEmitter, EventEmitter); + const myEmitter = new MyEmitter(); var m = 0; myEmitter.on('event', () => { @@ -133,6 +165,14 @@ Using the `eventEmitter.once()` method, it is possible to register a listener that is immediately unregistered after it is called. ```js +const EventEmitter = require('events'); +const util = require('util'); + +function MyEmitter() { + EventEmitter.call(this); +} +util.inherits(MyEmitter, EventEmitter); + const myEmitter = new MyEmitter(); var m = 0; myEmitter.once('event', () => { @@ -155,6 +195,14 @@ If an `EventEmitter` does _not_ have at least one listener registered for the stack trace is printed, and the Node.js process exits. ```js +const EventEmitter = require('events'); +const util = require('util'); + +function MyEmitter() { + EventEmitter.call(this); +} +util.inherits(MyEmitter, EventEmitter); + const myEmitter = new MyEmitter(); myEmitter.emit('error', new Error('whoops!')); // Throws and crashes Node.js @@ -166,6 +214,14 @@ a listener for the `process.on('uncaughtException')` event or use the deprecated_). ```js +const EventEmitter = require('events'); +const util = require('util'); + +function MyEmitter() { + EventEmitter.call(this); +} +util.inherits(MyEmitter, EventEmitter); + const myEmitter = new MyEmitter(); process.on('uncaughtException', (err) => { @@ -180,6 +236,14 @@ As a best practice, developers should always register listeners for the `'error'` event: ```js +const EventEmitter = require('events'); +const util = require('util'); + +function MyEmitter() { + EventEmitter.call(this); +} +util.inherits(MyEmitter, EventEmitter); + const myEmitter = new MyEmitter(); myEmitter.on('error', (err) => { console.log('whoops! there was an error'); @@ -193,6 +257,7 @@ myEmitter.emit('error', new Error('whoops!')); The `EventEmitter` class is defined and exposed by the `events` module: ```js +/* eslint no-unused-vars:0 */ const EventEmitter = require('events'); ``` @@ -216,6 +281,14 @@ but important side effect: any *additional* listeners registered to the same listener that is in the process of being added. ```js +const EventEmitter = require('events'); +const util = require('util'); + +function MyEmitter() { + EventEmitter.call(this); +} +util.inherits(MyEmitter, EventEmitter); + const myEmitter = new MyEmitter(); // Only do this once so we don't loop forever myEmitter.once('newListener', (event, listener) => { @@ -250,6 +323,14 @@ A class method that returns the number of listeners for the given `event` registered on the given `emitter`. ```js +const EventEmitter = require('events'); +const util = require('util'); + +function MyEmitter() { + EventEmitter.call(this); +} +util.inherits(MyEmitter, EventEmitter); + const myEmitter = new MyEmitter(); myEmitter.on('event', () => {}); myEmitter.on('event', () => {}); @@ -277,6 +358,15 @@ that a `possible EventEmitter memory leak` has been detected. For any single methods can be used to temporarily avoid this warning: ```js +const EventEmitter = require('events'); +const util = require('util'); + +function MyEmitter() { + EventEmitter.call(this); +} +util.inherits(MyEmitter, EventEmitter); + +const emitter = new MyEmitter(); emitter.setMaxListeners(emitter.getMaxListeners() + 1); emitter.once('event', () => { // do stuff @@ -312,6 +402,9 @@ Returns the number of listeners listening to the `event` type. Returns a copy of the array of listeners for the specified `event`. ```js +const util = require('util'); + +/* eslint no-undef:0 */ server.on('connection', (stream) => { console.log('someone connected!'); }); @@ -328,6 +421,7 @@ been added. Multiple calls passing the same combination of `event` and times. ```js +/* eslint no-undef:0 */ server.on('connection', (stream) => { console.log('someone connected!'); }); @@ -341,6 +435,7 @@ Adds a **one time** `listener` function for the `event`. This listener is invoked only the next time `event` is triggered, after which it is removed. ```js +/* eslint no-undef:0 */ server.once('connection', (stream) => { console.log('Ah, we have our first user!'); }); @@ -367,6 +462,7 @@ Removes the specified `listener` from the listener array for the specified var callback = (stream) => { console.log('someone connected!'); }; +/* eslint no-undef:0 */ server.on('connection', callback); // ... server.removeListener('connection', callback); diff --git a/doc/api/fs.markdown b/doc/api/fs.markdown index 0740fda91b110b..3bcbcd717b0105 100644 --- a/doc/api/fs.markdown +++ b/doc/api/fs.markdown @@ -40,6 +40,8 @@ With the asynchronous methods there is no guaranteed ordering. So the following is prone to error: ```js +const fs = require('fs'); + fs.rename('/tmp/hello', '/tmp/world', (err) => { if (err) throw err; console.log('renamed complete'); @@ -54,6 +56,8 @@ It could be that `fs.stat` is executed before `fs.rename`. The correct way to do this is to chain the callbacks. ```js +const fs = require('fs'); + fs.rename('/tmp/hello', '/tmp/world', (err) => { if (err) throw err; fs.stat('/tmp/world', (err, stats) => { @@ -146,7 +150,7 @@ synchronous counterparts are of this type. For a regular file [`util.inspect(stats)`][] would return a string very similar to this: -```js +``` { dev: 2114, ino: 48064969, @@ -239,6 +243,8 @@ argument will be populated. The following example checks if the file `/etc/passwd` can be read and written by the current process. ```js +const fs = require('fs'); + fs.access('/etc/passwd', fs.R_OK | fs.W_OK, (err) => { console.log(err ? 'no access!' : 'can read/write'); }); @@ -265,6 +271,8 @@ Asynchronously append data to a file, creating the file if it does not yet exist Example: ```js +const fs = require('fs'); + fs.appendFile('message.txt', 'data to append', (err) => { if (err) throw err; console.log('The "data to append" was appended to file!'); @@ -274,6 +282,9 @@ fs.appendFile('message.txt', 'data to append', (err) => { If `options` is a string, then it specifies the encoding. Example: ```js +const fs = require('fs'); + +/* eslint no-undef:0 */ fs.appendFile('message.txt', 'data to append', 'utf8', callback); ``` @@ -322,7 +333,7 @@ default value of 64 kb for the same parameter. `options` is an object or string with the following defaults: -```js +``` { flags: 'r', encoding: null, @@ -353,6 +364,8 @@ file was created. An example to read the last 10 bytes of a file which is 100 bytes long: ```js +const fs = require('fs'); + fs.createReadStream('sample.txt', {start: 90, end: 99}); ``` @@ -364,7 +377,7 @@ Returns a new [`WriteStream`][] object. (See [Writable Stream][]). `options` is an object or string with the following defaults: -```js +``` { flags: 'w', defaultEncoding: 'utf8', @@ -400,6 +413,8 @@ Test whether or not the given path exists by checking with the file system. Then call the `callback` argument with either true or false. Example: ```js +const fs = require('fs'); + fs.exists('/etc/passwd', (exists) => { console.log(exists ? 'it\'s there' : 'no passwd!'); }); @@ -626,6 +641,8 @@ Synchronous readdir(3). Returns an array of filenames excluding `'.'` and Asynchronously reads the entire contents of a file. Example: ```js +const fs = require('fs'); + fs.readFile('/etc/passwd', (err, data) => { if (err) throw err; console.log(data); @@ -640,6 +657,9 @@ If no encoding is specified, then the raw buffer is returned. If `options` is a string, then it specifies the encoding. Example: ```js +const fs = require('fs'); + +/* eslint no-undef:0 */ fs.readFile('/etc/passwd', 'utf8', callback); ``` @@ -673,6 +693,8 @@ resolution or avoid additional `fs.stat` calls for known real paths. Example: ```js +const fs = require('fs'); + var cache = {'/etc':'/private/etc'}; fs.realpath('/etc/passwd', cache, (err, resolvedPath) => { if (err) throw err; @@ -730,6 +752,8 @@ Note that Windows junction points require the destination path to be absolute. Here is an example below: ```js +const fs = require('fs'); + fs.symlink('./foo', './new-port'); ``` @@ -845,6 +869,8 @@ be provided. Therefore, don't assume that `filename` argument is always provided in the callback, and have some fallback logic if it is null. ```js +const fs = require('fs'); + fs.watch('somedir', (event, filename) => { console.log(`event is: ${event}`); if (filename) { @@ -871,6 +897,8 @@ The `listener` gets two arguments the current stat object and the previous stat object: ```js +const fs = require('fs'); + fs.watchFile('message.text', (curr, prev) => { console.log(`the current mtime is: ${curr.mtime}`); console.log(`the previous mtime was: ${prev.mtime}`); @@ -959,6 +987,8 @@ to `'utf8'`. Example: ```js +const fs = require('fs'); + fs.writeFile('message.txt', 'Hello Node.js', (err) => { if (err) throw err; console.log('It\'s saved!'); @@ -968,6 +998,9 @@ fs.writeFile('message.txt', 'Hello Node.js', (err) => { If `options` is a string, then it specifies the encoding. Example: ```js +const fs = require('fs'); + +/* eslint no-undef:0 */ fs.writeFile('message.txt', 'Hello Node.js', 'utf8', callback); ``` diff --git a/doc/api/http.markdown b/doc/api/http.markdown index 8dfde77524ffb7..78c20947268e8d 100644 --- a/doc/api/http.markdown +++ b/doc/api/http.markdown @@ -69,6 +69,10 @@ you intend to keep one HTTP request open for a long time and don't want it to stay in the pool you can do something along the lines of: ```js +const http = require('http'); + +const options = { /* ... */ }; + http.get(options, (res) => { // Do stuff }).on('socket', (socket) => { @@ -80,6 +84,8 @@ Alternatively, you could just opt out of pooling entirely using `agent:false`: ```js +const http = require('http'); + http.get({ hostname: 'localhost', port: 80, @@ -87,7 +93,7 @@ http.get({ agent: false // create a new agent just for this one request }, (res) => { // Do stuff with response -}) +}); ``` ### new Agent([options]) @@ -113,8 +119,11 @@ To configure any of them, you must create your own [`http.Agent`][] object. ```js const http = require('http'); var keepAliveAgent = new http.Agent({ keepAlive: true }); +var options = { /* ... */ }; options.agent = keepAliveAgent; -http.request(options, onResponseCallback); +http.request(options, (res) => { + /* ... */ +}); ``` ### agent.destroy() @@ -227,7 +236,7 @@ const net = require('net'); const url = require('url'); // Create an HTTP tunneling proxy -var proxy = http.createServer( (req, res) => { +var proxy = http.createServer((req, res) => { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('okay'); }); @@ -317,7 +326,7 @@ A client server pair that show you how to listen for the `'upgrade'` event. const http = require('http'); // Create an HTTP server -var srv = http.createServer( (req, res) => { +var srv = http.createServer((req, res) => { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('okay'); }); @@ -642,6 +651,7 @@ Note that HTTP requires the `Trailer` header to be sent if you intend to emit trailers, with a list of the header fields in its value. E.g., ```js +/* eslint no-undef:0 */ response.writeHead(200, { 'Content-Type': 'text/plain', 'Trailer': 'Content-MD5' }); response.write(fileData); @@ -678,6 +688,7 @@ implicitly flushed. Example: ```js +/* eslint no-unused-vars:0, no-undef:0 */ var contentType = response.getHeader('content-type'); ``` @@ -692,6 +703,7 @@ Removes a header that's queued for implicit sending. Example: ```js +/* eslint no-undef:0 */ response.removeHeader('Content-Encoding'); ``` @@ -712,12 +724,14 @@ here if you need to send multiple headers with the same name. Example: ```js +/* eslint no-undef:0 */ response.setHeader('Content-Type', 'text/html'); ``` or ```js +/* eslint no-undef:0 */ response.setHeader('Set-Cookie', ['type=ninja', 'language=javascript']); ``` @@ -729,8 +743,11 @@ any headers passed to [`response.writeHead()`][], with the headers passed to [`response.writeHead()`][] given precedence. ```js +const http = require('http'); + // returns content-type = text/plain -const server = http.createServer((req,res) => { +/* eslint no-unused-vars:0 */ +const server = http.createServer((req, res) => { res.setHeader('Content-Type', 'text/html'); res.setHeader('X-Foo', 'bar'); res.writeHead(200, {'Content-Type': 'text/plain'}); @@ -764,6 +781,7 @@ the headers get flushed. Example: ```js +/* eslint no-undef:0 */ response.statusCode = 404; ``` @@ -780,6 +798,7 @@ code will be used. Example: ```js +/* eslint no-undef:0 */ response.statusMessage = 'Not found'; ``` @@ -828,6 +847,7 @@ Example: ```js var body = 'hello world'; +/* eslint no-undef:0 */ response.writeHead(200, { 'Content-Length': body.length, 'Content-Type': 'text/plain' }); @@ -844,8 +864,11 @@ any headers passed to [`response.writeHead()`][], with the headers passed to [`response.writeHead()`][] given precedence. ```js +const http = require('http'); + // returns content-type = text/plain -const server = http.createServer((req,res) => { +/* eslint no-unused-vars:0 */ +const server = http.createServer((req, res) => { res.setHeader('Content-Type', 'text/html'); res.setHeader('X-Foo', 'bar'); res.writeHead(200, {'Content-Type': 'text/plain'}); @@ -893,6 +916,7 @@ Example: // { 'user-agent': 'curl/7.22.0', // host: '127.0.0.1:8000', // accept: '*/*' } +/* eslint no-undef:0 */ console.log(request.headers); ``` @@ -943,6 +967,7 @@ Header names are not lowercased, and duplicates are not merged. // '127.0.0.1:8000', // 'ACCEPT', // '*/*' ] +/* eslint no-undef:0 */ console.log(request.rawHeaders); ``` @@ -1068,6 +1093,8 @@ is that it sets the method to GET and calls `req.end()` automatically. Example: ```js +const http = require('http'); + http.get('http://www.google.com/index.html', (res) => { console.log(`Got response: ${res.statusCode}`); // consume response body @@ -1128,6 +1155,9 @@ upload a file with a POST request, then write to the `ClientRequest` object. Example: ```js +const querystring = require('querystring'); +const http = require('http'); + var postData = querystring.stringify({ 'msg' : 'Hello World!' }); @@ -1151,8 +1181,8 @@ var req = http.request(options, (res) => { console.log(`BODY: ${chunk}`); }); res.on('end', () => { - console.log('No more data in response.') - }) + console.log('No more data in response.'); + }); }); req.on('error', (e) => { diff --git a/doc/api/https.markdown b/doc/api/https.markdown index 69b5f418466859..c468580b5af906 100644 --- a/doc/api/https.markdown +++ b/doc/api/https.markdown @@ -192,6 +192,9 @@ In order to specify these options, use a custom [`Agent`][]. Example: ```js +const fs = require('fs'); +const https = require('https'); + var options = { hostname: 'encrypted.google.com', port: 443, @@ -202,9 +205,10 @@ var options = { }; options.agent = new https.Agent(options); +/* eslint no-unused-vars:0 */ var req = https.request(options, (res) => { - ... -} + /* ... */ +}); ``` Alternatively, opt out of connection pooling by not using an `Agent`. @@ -212,6 +216,9 @@ Alternatively, opt out of connection pooling by not using an `Agent`. Example: ```js +const fs = require('fs'); +const https = require('https'); + var options = { hostname: 'encrypted.google.com', port: 443, @@ -222,9 +229,10 @@ var options = { agent: false }; +/* eslint no-unused-vars:0 */ var req = https.request(options, (res) => { - ... -} + /* ... */ +}); ``` [`Agent`]: #https_class_https_agent diff --git a/doc/api/modules.markdown b/doc/api/modules.markdown index bd715f9fecaefc..a4088fe00b6322 100644 --- a/doc/api/modules.markdown +++ b/doc/api/modules.markdown @@ -12,7 +12,7 @@ The contents of `foo.js`: ```js const circle = require('./circle.js'); -console.log( `The area of a circle of radius 4 is ${circle.area(4)}`); +console.log(`The area of a circle of radius 4 is ${circle.area(4)}`); ``` The contents of `circle.js`: @@ -54,7 +54,7 @@ module.exports = (width) => { return { area: () => width * width }; -} +}; ``` The module system is implemented in the `require("module")` module. @@ -68,7 +68,7 @@ When a file is run directly from Node.js, `require.main` is set to its directly by testing ```js -require.main === module +require.main === module; ``` For a file `foo.js`, this will be `true` if run via `node foo.js`, but @@ -491,10 +491,12 @@ To illustrate the behavior, imagine this hypothetical implementation of `require()`: ```js -function require(...) { +/* eslint no-unused-vars:0 */ +function require(/* ... */) { // ... ((module, exports) => { // Your module code here + /* eslint no-undef:0 */ exports = some_func; // re-assigns exports, exports is no longer // a shortcut, and nothing is exported. module.exports = some_func; // makes your module export 0 diff --git a/doc/api/net.markdown b/doc/api/net.markdown index 2f41a0dfabcca9..f9c3db9f6916d5 100644 --- a/doc/api/net.markdown +++ b/doc/api/net.markdown @@ -46,6 +46,8 @@ Returns an object with three properties, e.g. Example: ```js +const net = require('net'); + var server = net.createServer((socket) => { socket.end('goodbye\n'); }); @@ -53,7 +55,7 @@ var server = net.createServer((socket) => { // grab a random port. server.listen((err) => { if (err) throw err; - address = server.address(); + const address = server.address(); console.log('opened server on %j', address); }); ``` @@ -131,6 +133,11 @@ results in an error. An example which listens on an exclusive port is shown below. ```js +const net = require('net'); + +var server = net.createServer((socket) => { + // New Connection +}); server.listen({ host: 'localhost', port: 80, @@ -190,6 +197,10 @@ another server is already running on the requested port. One way of handling thi would be to wait a second and then try again. This can be done with ```js +const PORT = 8000; +const HOST = 'localhost'; + +/* eslint no-undef:0 */ server.on('error', (e) => { if (e.code == 'EADDRINUSE') { console.log('Address in use, retrying...'); @@ -245,7 +256,7 @@ Construct a new socket object. `options` is an object with the following defaults: -```js +``` { fd: null, allowHalfOpen: false, @@ -547,6 +558,8 @@ To connect on the socket `/tmp/echo.sock` the second line would just be changed to ```js +const net = require('net'); +/* eslint no-unused-vars:0 */ const client = net.connect({path: '/tmp/echo.sock'}); ``` @@ -601,6 +614,8 @@ To connect on the socket `/tmp/echo.sock` the second line would just be changed to ```js +const net = require('net'); +/* eslint no-unused-vars:0 */ const client = net.connect({path: '/tmp/echo.sock'}); ``` @@ -629,7 +644,7 @@ automatically set as a listener for the [`'connection'`][] event. `options` is an object with the following defaults: -```js +``` { allowHalfOpen: false, pauseOnConnect: false @@ -677,6 +692,7 @@ To listen on the socket `/tmp/echo.sock` the third line from the last would just be changed to ```js +/* eslint no-undef:0 */ server.listen('/tmp/echo.sock', (err) => { // 'listening' listener if (err) throw err; @@ -685,7 +701,7 @@ server.listen('/tmp/echo.sock', (err) => { Use `nc` to connect to a UNIX domain socket server: -```js +``` nc -U /tmp/echo.sock ``` diff --git a/doc/api/os.markdown b/doc/api/os.markdown index ea4f40ba79e958..c18041164a3622 100644 --- a/doc/api/os.markdown +++ b/doc/api/os.markdown @@ -24,7 +24,7 @@ milliseconds the CPU/core spent in: user, nice, sys, idle, and irq). Example inspection of os.cpus: -```js +``` [ { model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz', speed: 2926, times: @@ -127,7 +127,7 @@ Windows. Get a list of network interfaces: -```js +``` { lo: [ { address: '127.0.0.1', netmask: '255.0.0.0', diff --git a/doc/api/path.markdown b/doc/api/path.markdown index d7a9e681187653..a352f3da963bcb 100644 --- a/doc/api/path.markdown +++ b/doc/api/path.markdown @@ -15,13 +15,15 @@ Return the last portion of a path. Similar to the Unix `basename` command. Example: ```js -path.basename('/foo/bar/baz/asdf/quux.html') +const path = require('path'); + +path.basename('/foo/bar/baz/asdf/quux.html'); // returns -'quux.html' +// 'quux.html' -path.basename('/foo/bar/baz/asdf/quux.html', '.html') +path.basename('/foo/bar/baz/asdf/quux.html', '.html'); // returns -'quux' +// 'quux' ``` ## path.delimiter @@ -31,23 +33,27 @@ The platform-specific path delimiter, `;` or `':'`. An example on \*nix: ```js -console.log(process.env.PATH) +const path = require('path'); + +console.log(process.env.PATH); // '/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin' -process.env.PATH.split(path.delimiter) +process.env.PATH.split(path.delimiter); // returns -['/usr/bin', '/bin', '/usr/sbin', '/sbin', '/usr/local/bin'] +// ['/usr/bin', '/bin', '/usr/sbin', '/sbin', '/usr/local/bin'] ``` An example on Windows: ```js -console.log(process.env.PATH) +const path = require('path'); + +console.log(process.env.PATH); // 'C:\Windows\system32;C:\Windows;C:\Program Files\node\' -process.env.PATH.split(path.delimiter) +process.env.PATH.split(path.delimiter); // returns -['C:\\Windows\\system32', 'C:\\Windows', 'C:\\Program Files\\node\\'] +// ['C:\\Windows\\system32', 'C:\\Windows', 'C:\\Program Files\\node\\'] ``` ## path.dirname(p) @@ -57,9 +63,11 @@ Return the directory name of a path. Similar to the Unix `dirname` command. Example: ```js -path.dirname('/foo/bar/baz/asdf/quux') +const path = require('path'); + +path.dirname('/foo/bar/baz/asdf/quux'); // returns -'/foo/bar/baz/asdf' +// '/foo/bar/baz/asdf' ``` ## path.extname(p) @@ -70,25 +78,27 @@ of the path or the first character of it is '.', then it returns an empty string. Examples: ```js -path.extname('index.html') +const path = require('path'); + +path.extname('index.html'); // returns -'.html' +// '.html' -path.extname('index.coffee.md') +path.extname('index.coffee.md'); // returns -'.md' +// '.md' -path.extname('index.') +path.extname('index.'); // returns -'.' +// '.' -path.extname('index') +path.extname('index'); // returns -'' +// '' -path.extname('.index') +path.extname('.index'); // returns -'' +// '' ``` ## path.format(pathObject) @@ -96,25 +106,27 @@ path.extname('.index') Returns a path string from an object, the opposite of [`path.parse`][]. ```js +const path = require('path'); + path.format({ - root : "/", - dir : "/home/user/dir", - base : "file.txt", - ext : ".txt", - name : "file" -}) + root : '/', + dir : '/home/user/dir', + base : 'file.txt', + ext : '.txt', + name : 'file' +}); // returns -'/home/user/dir/file.txt' +// '/home/user/dir/file.txt' // `root` will be used if `dir` is not specified and `name` + `ext` will be used // if `base` is not specified path.format({ - root : "/", - ext : ".txt", - name : "file" -}) + root : '/', + ext : '.txt', + name : 'file' +}); // returns -'/file.txt' +// '/file.txt' ``` ## path.isAbsolute(path) @@ -125,19 +137,23 @@ resolve to the same location, regardless of the working directory. Posix examples: ```js -path.isAbsolute('/foo/bar') // true -path.isAbsolute('/baz/..') // true -path.isAbsolute('qux/') // false -path.isAbsolute('.') // false +const path = require('path'); + +path.isAbsolute('/foo/bar'); // true +path.isAbsolute('/baz/..'); // true +path.isAbsolute('qux/'); // false +path.isAbsolute('.'); // false ``` Windows examples: ```js -path.isAbsolute('//server') // true -path.isAbsolute('C:/foo/..') // true -path.isAbsolute('bar\\baz') // false -path.isAbsolute('.') // false +const path = require('path'); + +path.isAbsolute('//server'); // true +path.isAbsolute('C:/foo/..'); // true +path.isAbsolute('bar\\baz'); // false +path.isAbsolute('.'); // false ``` *Note:* If the path string passed as parameter is a zero-length string, unlike @@ -154,13 +170,15 @@ silently ignored. In v0.10 and up, an exception is thrown. Example: ```js -path.join('/foo', 'bar', 'baz/asdf', 'quux', '..') +const path = require('path'); + +path.join('/foo', 'bar', 'baz/asdf', 'quux', '..'); // returns -'/foo/bar/baz/asdf' +// '/foo/bar/baz/asdf' -path.join('foo', {}, 'bar') +path.join('foo', {}, 'bar'); // throws exception -TypeError: Arguments to path.join must be strings +// TypeError: Arguments to path.join must be strings ``` *Note:* If the arguments to `join` have zero-length strings, unlike other path @@ -179,9 +197,11 @@ On Windows backslashes are used. Example: ```js -path.normalize('/foo/bar//baz/asdf/quux/..') +const path = require('path'); + +path.normalize('/foo/bar//baz/asdf/quux/..'); // returns -'/foo/bar/baz/asdf' +// '/foo/bar/baz/asdf' ``` *Note:* If the path string passed as argument is a zero-length string then `'.'` @@ -194,29 +214,33 @@ Returns an object from a path string. An example on \*nix: ```js -path.parse('/home/user/dir/file.txt') +const path = require('path'); + +path.parse('/home/user/dir/file.txt'); // returns -{ - root : "/", - dir : "/home/user/dir", - base : "file.txt", - ext : ".txt", - name : "file" -} +// { +// root : "/", +// dir : "/home/user/dir", +// base : "file.txt", +// ext : ".txt", +// name : "file" +// } ``` An example on Windows: ```js -path.parse('C:\\path\\dir\\index.html') +const path = require('path'); + +path.parse('C:\\path\\dir\\index.html'); // returns -{ - root : "C:\\", - dir : "C:\\path\\dir", - base : "index.html", - ext : ".html", - name : "index" -} +// { +// root : "C:\\", +// dir : "C:\\path\\dir", +// base : "index.html", +// ext : ".html", +// name : "index" +// } ``` ## path.posix @@ -233,19 +257,26 @@ path from one to the other. This is actually the reverse transform of `path.resolve`, which means we see that: ```js -path.resolve(from, path.relative(from, to)) == path.resolve(to) +const path = require('path'); + +const from = '/some/path/'; +const to = '/another/different/path/'; + +path.resolve(from, path.relative(from, to)) == path.resolve(to); ``` Examples: ```js -path.relative('C:\\orandea\\test\\aaa', 'C:\\orandea\\impl\\bbb') +const path = require('path'); + +path.relative('C:\\orandea\\test\\aaa', 'C:\\orandea\\impl\\bbb'); // returns -'..\\..\\impl\\bbb' +// '..\\..\\impl\\bbb' -path.relative('/data/orandea/test/aaa', '/data/orandea/impl/bbb') +path.relative('/data/orandea/test/aaa', '/data/orandea/impl/bbb'); // returns -'../../impl/bbb' +// '../../impl/bbb' ``` *Note:* If the arguments to `relative` have zero-length strings then the current @@ -265,7 +296,9 @@ gets resolved to the root directory. Non-string `from` arguments are ignored. Another way to think of it is as a sequence of `cd` commands in a shell. ```js -path.resolve('foo/bar', '/tmp/file/', '..', 'a/../subfile') +const path = require('path'); + +path.resolve('foo/bar', '/tmp/file/', '..', 'a/../subfile'); ``` Is similar to: @@ -284,17 +317,19 @@ files. Examples: ```js -path.resolve('/foo/bar', './baz') +const path = require('path'); + +path.resolve('/foo/bar', './baz'); // returns -'/foo/bar/baz' +// '/foo/bar/baz' -path.resolve('/foo/bar', '/tmp/file/') +path.resolve('/foo/bar', '/tmp/file/'); // returns -'/tmp/file' +// '/tmp/file' -path.resolve('wwwroot', 'static_files/png/', '../gif/image.gif') +path.resolve('wwwroot', 'static_files/png/', '../gif/image.gif'); // if currently in /home/myself/node, it returns -'/home/myself/node/wwwroot/static_files/gif/image.gif' +// '/home/myself/node/wwwroot/static_files/gif/image.gif' ``` *Note:* If the arguments to `resolve` have zero-length strings then the current @@ -307,17 +342,21 @@ The platform-specific file separator. `'\\'` or `'/'`. An example on \*nix: ```js -'foo/bar/baz'.split(path.sep) +const path = require('path'); + +'foo/bar/baz'.split(path.sep); // returns -['foo', 'bar', 'baz'] +// ['foo', 'bar', 'baz'] ``` An example on Windows: ```js -'foo\\bar\\baz'.split(path.sep) +const path = require('path'); + +'foo\\bar\\baz'.split(path.sep); // returns -['foo', 'bar', 'baz'] +// ['foo', 'bar', 'baz'] ``` ## path.win32 diff --git a/doc/api/process.markdown b/doc/api/process.markdown index c2a07f45a9ed1e..5edd0253855890 100644 --- a/doc/api/process.markdown +++ b/doc/api/process.markdown @@ -107,6 +107,7 @@ setTimeout(() => { }, 500); // Intentionally cause an exception, but don't catch it. +/* eslint no-undef:0 */ nonexistentFunc(); console.log('This will not run.'); ``` @@ -146,8 +147,8 @@ Here is an example that logs every unhandled rejection to the console ```js process.on('unhandledRejection', (reason, p) => { - console.log("Unhandled Rejection at: Promise ", p, " reason: ", reason); - // application specific logging, throwing an error, or other logic here + console.log('Unhandled Rejection at: Promise ', p, ' reason: ', reason); + // application specific logging, throwing an error, or other logic here }); ``` @@ -155,6 +156,7 @@ For example, here is a rejection that will trigger the `'unhandledRejection'` event: ```js +/* eslint no-undef:0 */ somePromise.then((res) => { return reportToUser(JSON.parse(res)); // note the typo }); // no `.catch` or `.then` @@ -169,6 +171,7 @@ function SomeResource() { this.loaded = Promise.reject(new Error('Resource not yet loaded!')); } +/* eslint no-unused-vars:0 */ var resource = new SomeResource(); // no .catch or .then on resource.loaded for at least a turn ``` @@ -397,7 +400,7 @@ An object containing the user environment. See environ(7). An example of this object looks like: -```js +``` { TERM: 'xterm-256color', SHELL: '/usr/local/bin/bash', USER: 'maciej', @@ -466,13 +469,13 @@ $ node --harmony script.js --version results in process.execArgv: -```js +``` ['--harmony'] ``` and process.argv: -```js +``` ['/usr/local/bin/node', 'script.js', '--version'] ``` @@ -676,7 +679,7 @@ console.log(util.inspect(process.memoryUsage())); This will generate: -```js +``` { rss: 4935680, heapTotal: 1826816, heapUsed: 650472 } @@ -731,6 +734,9 @@ It is very important for APIs to be either 100% synchronous or 100% asynchronous. Consider this example: ```js +/* eslint no-unused-vars:0 */ +const fs = require('fs'); + // WARNING! DO NOT USE! BAD UNSAFE HAZARD! function maybeSync(arg, cb) { if (arg) { @@ -745,6 +751,7 @@ function maybeSync(arg, cb) { This API is hazardous. If you do this: ```js +/* eslint no-undef:0 */ maybeSync(true, () => { foo(); }); @@ -756,6 +763,9 @@ then it's not clear whether `foo()` or `bar()` will be called first. This approach is much better: ```js +const fs = require('fs'); + +/* eslint no-unused-vars:0 */ function definitelyAsync(arg, cb) { if (arg) { process.nextTick(cb); @@ -810,7 +820,7 @@ for the source tarball and headers-only tarball. e.g. -```js +``` { name: 'node', sourceUrl: 'https://nodejs.org/download/release/v4.0.0/node-v4.0.0.tar.gz', headersUrl: 'https://nodejs.org/download/release/v4.0.0/node-v4.0.0-headers.tar.gz', @@ -1058,7 +1068,7 @@ console.log(process.versions); Will print something like: -```js +``` { http_parser: '2.3.0', node: '1.1.1', v8: '4.1.0.14', diff --git a/doc/api/punycode.markdown b/doc/api/punycode.markdown index 7f3617c12d8efd..30b7e225ef4334 100644 --- a/doc/api/punycode.markdown +++ b/doc/api/punycode.markdown @@ -11,6 +11,8 @@ access it. (To use it with other Node.js versions, use npm to install the Converts a Punycode string of ASCII-only symbols to a string of Unicode symbols. ```js +const punycode = require('punycode'); + // decode domain name parts punycode.decode('maana-pta'); // 'mañana' punycode.decode('--dqo34k'); // '☃-⌘' @@ -21,6 +23,8 @@ punycode.decode('--dqo34k'); // '☃-⌘' Converts a string of Unicode symbols to a Punycode string of ASCII-only symbols. ```js +const punycode = require('punycode'); + // encode domain name parts punycode.encode('mañana'); // 'maana-pta' punycode.encode('☃-⌘'); // '--dqo34k' @@ -33,6 +37,8 @@ non-ASCII parts of the domain name will be converted, i.e. it doesn't matter if you call it with a domain that's already in ASCII. ```js +const punycode = require('punycode'); + // encode domain names punycode.toASCII('mañana.com'); // 'xn--maana-pta.com' punycode.toASCII('☃-⌘.com'); // 'xn----dqo34k.com' @@ -45,6 +51,8 @@ Punycoded parts of the domain name will be converted, i.e. it doesn't matter if you call it on a string that has already been converted to Unicode. ```js +const punycode = require('punycode'); + // decode domain names punycode.toUnicode('xn--maana-pta.com'); // 'mañana.com' punycode.toUnicode('xn----dqo34k.com'); // '☃-⌘.com' @@ -60,6 +68,8 @@ will convert a pair of surrogate halves (each of which UCS-2 exposes as separate characters) into a single code point, matching UTF-16. ```js +const punycode = require('punycode'); + punycode.ucs2.decode('abc'); // [0x61, 0x62, 0x63] // surrogate pair for U+1D306 tetragram for centre: punycode.ucs2.decode('\uD834\uDF06'); // [0x1D306] @@ -70,6 +80,8 @@ punycode.ucs2.decode('\uD834\uDF06'); // [0x1D306] Creates a string based on an array of numeric code point values. ```js +const punycode = require('punycode'); + punycode.ucs2.encode([0x61, 0x62, 0x63]); // 'abc' punycode.ucs2.encode([0x1D306]); // '\uD834\uDF06' ``` diff --git a/doc/api/querystring.markdown b/doc/api/querystring.markdown index 052bd0ea411e91..309c45547b20b4 100644 --- a/doc/api/querystring.markdown +++ b/doc/api/querystring.markdown @@ -27,16 +27,19 @@ it can be used to decode a `non-utf8` encoding string if necessary. Example: ```js -querystring.parse('foo=bar&baz=qux&baz=quux&corge') +const querystring = require('querystring'); + +querystring.parse('foo=bar&baz=qux&baz=quux&corge'); // returns -{ foo: 'bar', baz: ['qux', 'quux'], corge: '' } +// { foo: 'bar', baz: ['qux', 'quux'], corge: '' } // Suppose gbkDecodeURIComponent function already exists, // it can decode `gbk` encoding string +/* eslint no-undef: 0 */ querystring.parse('w=%D6%D0%CE%C4&foo=bar', null, null, - { decodeURIComponent: gbkDecodeURIComponent }) + { decodeURIComponent: gbkDecodeURIComponent }); // returns -{ w: '中文', foo: 'bar' } +// { w: '中文', foo: 'bar' } ``` ## querystring.stringify(obj[, sep][, eq][, options]) @@ -51,20 +54,23 @@ it can be used to encode string with `non-utf8` encoding if necessary. Example: ```js -querystring.stringify({ foo: 'bar', baz: ['qux', 'quux'], corge: '' }) +const querystring = require('querystring'); + +querystring.stringify({ foo: 'bar', baz: ['qux', 'quux'], corge: '' }); // returns -'foo=bar&baz=qux&baz=quux&corge=' +// 'foo=bar&baz=qux&baz=quux&corge=' -querystring.stringify({foo: 'bar', baz: 'qux'}, ';', ':') +querystring.stringify({foo: 'bar', baz: 'qux'}, ';', ':'); // returns -'foo:bar;baz:qux' +// 'foo:bar;baz:qux' // Suppose gbkEncodeURIComponent function already exists, // it can encode string with `gbk` encoding +/* eslint no-undef: 0 */ querystring.stringify({ w: '中文', foo: 'bar' }, null, null, - { encodeURIComponent: gbkEncodeURIComponent }) + { encodeURIComponent: gbkEncodeURIComponent }); // returns -'w=%D6%D0%CE%C4&foo=bar' +// 'w=%D6%D0%CE%C4&foo=bar' ``` ## querystring.unescape diff --git a/doc/api/readline.markdown b/doc/api/readline.markdown index c2b77c524533bf..41091cae1fc44e 100644 --- a/doc/api/readline.markdown +++ b/doc/api/readline.markdown @@ -69,6 +69,9 @@ nothing is displayed. Example usage: ```js +const readline = require('readline'); +const rl = readline.createInterface(process.stdin, process.stdout); + rl.question('What is your favorite food?', (answer) => { console.log(`Oh, so your favorite food is ${answer}`); }); @@ -94,6 +97,9 @@ This will also resume the `input` stream if it has been paused. Example: ```js +const readline = require('readline'); +const rl = readline.createInterface(process.stdin, process.stdout); + rl.write('Delete me!'); // Simulate ctrl+u to delete the line written previously rl.write(null, {ctrl: true, name: 'u'}); @@ -125,6 +131,9 @@ hook to listen for user input. Example of listening for `'line'`: ```js +const readline = require('readline'); +const rl = readline.createInterface(process.stdin, process.stdout); + rl.on('line', (cmd) => { console.log(`You just typed: ${cmd}`); }); @@ -142,6 +151,9 @@ Also emitted whenever the `input` stream is not paused and receives the Example of listening for `'pause'`: ```js +const readline = require('readline'); +const rl = readline.createInterface(process.stdin, process.stdout); + rl.on('pause', () => { console.log('Readline paused.'); }); @@ -156,6 +168,9 @@ Emitted whenever the `input` stream is resumed. Example of listening for `'resume'`: ```js +const readline = require('readline'); +const rl = readline.createInterface(process.stdin, process.stdout); + rl.on('resume', () => { console.log('Readline resumed.'); }); @@ -175,6 +190,9 @@ background. Example of listening for `SIGCONT`: ```js +const readline = require('readline'); +const rl = readline.createInterface(process.stdin, process.stdout); + rl.on('SIGCONT', () => { // `prompt` will automatically resume the stream rl.prompt(); @@ -192,6 +210,9 @@ stream receives a `SIGINT`, `pause` will be triggered. Example of listening for `SIGINT`: ```js +const readline = require('readline'); +const rl = readline.createInterface(process.stdin, process.stdout); + rl.on('SIGINT', () => { rl.question('Are you sure you want to exit?', (answer) => { if (answer.match(/^y(es)?$/i)) rl.pause(); @@ -218,6 +239,9 @@ before the program was sent to the background. Example of listening for `SIGTSTP`: ```js +const readline = require('readline'); +const rl = readline.createInterface(process.stdin, process.stdout); + rl.on('SIGTSTP', () => { // This will override SIGTSTP and prevent the program from going to the // background. @@ -238,7 +262,7 @@ rl.setPrompt('OHAI> '); rl.prompt(); rl.on('line', (line) => { - switch(line.trim()) { + switch (line.trim()) { case 'hello': console.log('world!'); break; @@ -315,17 +339,19 @@ Which ends up looking something like: Example: ```js +/* eslint no-unused-vars:0 */ function completer(line) { - var completions = '.help .error .exit .quit .q'.split(' ') - var hits = completions.filter((c) => { return c.indexOf(line) == 0 }) + var completions = '.help .error .exit .quit .q'.split(' '); + var hits = completions.filter((c) => { return c.indexOf(line) == 0; }); // show all completions if none found - return [hits.length ? hits : completions, line] + return [hits.length ? hits : completions, line]; } ``` Also `completer` can be run in async mode if it accepts two arguments: ```js +/* eslint no-unused-vars:0 */ function completer(linePartial, callback) { callback(null, [['123'], linePartial]); } @@ -336,6 +362,7 @@ function completer(linePartial, callback) { ```js const readline = require('readline'); +/* eslint no-unused-vars:0 */ const rl = readline.createInterface({ input: process.stdin, output: process.stdout diff --git a/doc/api/repl.markdown b/doc/api/repl.markdown index 86ece2c27ee0af..9099c670b335ea 100644 --- a/doc/api/repl.markdown +++ b/doc/api/repl.markdown @@ -167,6 +167,9 @@ to signal `'end'` on the `input` stream. Example of listening for `exit`: ```js +const repl = require('repl'); + +var replServer = repl.start(); replServer.on('exit', () => { console.log('Got "exit" event from repl!'); process.exit(); @@ -185,8 +188,11 @@ be emitted. Example of listening for `reset`: ```js +const repl = require('repl'); + // Extend the initial repl context. -var replServer = repl.start({ options ... }); +var replServer = repl.start({ /* options ... */ }); +/* eslint no-undef:0 */ someExtension.extend(r.context); // When a new context is created extend it as well. @@ -318,7 +324,7 @@ net.createServer((socket) => { output: socket }).on('exit', () => { socket.end(); - }) + }); }).listen('/tmp/node-repl-sock'); net.createServer((socket) => { diff --git a/doc/api/stream.markdown b/doc/api/stream.markdown index 4f8be5025cf4b1..2c0482be112ee4 100644 --- a/doc/api/stream.markdown +++ b/doc/api/stream.markdown @@ -50,7 +50,7 @@ way. Here is an example of using Streams in an Node.js program: ```js const http = require('http'); -var server = http.createServer( (req, res) => { +var server = http.createServer((req, res) => { // req is an http.IncomingMessage, which is a Readable Stream // res is an http.ServerResponse, which is a Writable Stream @@ -174,6 +174,7 @@ If you just want to get all the data out of the stream as fast as possible, this is the best way to do so. ```js +/* eslint no-undef:0 */ var readable = getReadableStreamSomehow(); readable.on('data', (chunk) => { console.log('got %d bytes of data', chunk.length); @@ -190,6 +191,7 @@ or by calling [`stream.read()`][stream-read] repeatedly until you get to the end. ```js +/* eslint no-undef:0 */ var readable = getReadableStreamSomehow(); readable.on('data', (chunk) => { console.log('got %d bytes of data', chunk.length); @@ -215,6 +217,7 @@ to be read into the internal buffer from the underlying system, if it hadn't already. ```javascript +/* eslint no-undef:0 */ var readable = getReadableStreamSomehow(); readable.on('readable', () => { // there is some data to read now @@ -261,13 +264,14 @@ paused by client code (using [`stream.pause()`][stream-pause] without a corresponding [`stream.resume()`][stream-resume]). ```js -var readable = new stream.Readable +const stream = require('stream'); +var readable = new stream.Readable(); -readable.isPaused() // === false -readable.pause() -readable.isPaused() // === true -readable.resume() -readable.isPaused() // === false +readable.isPaused(); // === false +readable.pause(); +readable.isPaused(); // === true +readable.resume(); +readable.isPaused(); // === false ``` #### readable.pause() @@ -279,6 +283,7 @@ This method will cause a stream in flowing mode to stop emitting available will remain in the internal buffer. ```js +/* eslint no-undef:0 */ var readable = getReadableStreamSomehow(); readable.on('data', (chunk) => { console.log('got %d bytes of data', chunk.length); @@ -304,6 +309,7 @@ the destination is not overwhelmed by a fast readable stream. Multiple destinations can be piped to safely. ```js +/* eslint no-undef:0 */ var readable = getReadableStreamSomehow(); var writable = fs.createWriteStream('file.txt'); // All the data from readable goes into 'file.txt' @@ -314,6 +320,9 @@ This function returns the destination stream, so you can set up pipe chains like so: ```js +const fs = require('fs'); +const zlib = require('zlib'); + var r = fs.createReadStream('file.txt'); var z = zlib.createGzip(); var w = fs.createWriteStream('file.txt.gz'); @@ -334,6 +343,7 @@ This keeps `writer` open so that "Goodbye" can be written at the end. ```js +/* eslint no-undef:0 */ reader.pipe(writer, { end: false }); reader.on('end', () => { writer.end('Goodbye\n'); @@ -365,6 +375,7 @@ this method is called automatically until the internal buffer is drained. ```js +/* eslint no-undef:0 */ var readable = getReadableStreamSomehow(); readable.on('readable', () => { var chunk; @@ -393,6 +404,7 @@ its [`'end'`][] event, you can call [`stream.resume()`][stream-resume] to open the flow of data. ```js +/* eslint no-undef:0 */ var readable = getReadableStreamSomehow(); readable.resume(); readable.on('end', () => { @@ -417,6 +429,7 @@ called [`buf.toString(encoding)`][] on them. If you want to read the data as strings, always use this method. ```js +/* eslint no-undef:0 */ var readable = getReadableStreamSomehow(); readable.setEncoding('utf8'); readable.on('data', (chunk) => { @@ -438,6 +451,7 @@ If the destination is specified, but no pipe is set up for it, then this is a no-op. ```js +/* eslint no-undef:0 */ var readable = getReadableStreamSomehow(); var writable = fs.createWriteStream('file.txt'); // All the data from readable goes into 'file.txt', @@ -471,7 +485,9 @@ for Stream Implementors][].) // Pull off a header delimited by \n\n // use unshift() if we get too much // Call the callback with (error, header, stream) +const Buffer = require('buffer').Buffer; const StringDecoder = require('string_decoder').StringDecoder; +/* eslint no-unused-vars:0 */ function parseHeader(stream, callback) { stream.on('error', callback); stream.on('readable', onReadable); @@ -531,6 +547,7 @@ For example: ```js const OldReader = require('./old-api-module.js').OldReader; +/* eslint new-parens:0 */ const Readable = require('stream').Readable; const oreader = new OldReader; const myReader = new Readable().wrap(oreader); @@ -578,6 +595,7 @@ to the stream. ```js // Write the data to the supplied writable stream one million times. // Be attentive to back-pressure. +/* eslint no-unused-vars:0 */ function writeOneMillionTimes(writer, data, encoding, callback) { var i = 1000000; write(); @@ -615,8 +633,9 @@ When the [`stream.end()`][stream-end] method has been called, and all data has been flushed to the underlying system, this event is emitted. ```javascript +/* eslint no-undef:0 */ var writer = getWritableStreamSomehow(); -for (var i = 0; i < 100; i ++) { +for (var i = 0; i < 100; i++) { writer.write('hello, #${i}!\n'); } writer.end('this is the end\n'); @@ -633,6 +652,7 @@ This is emitted whenever the [`stream.pipe()`][] method is called on a readable stream, adding this writable to its set of destinations. ```js +/* eslint no-undef:0 */ var writer = getWritableStreamSomehow(); var reader = getReadableStreamSomehow(); writer.on('pipe', (src) => { @@ -651,6 +671,7 @@ This is emitted whenever the [`stream.unpipe()`][] method is called on a readable stream, removing this writable from its set of destinations. ```js +/* eslint no-undef:0 */ var writer = getWritableStreamSomehow(); var reader = getReadableStreamSomehow(); writer.on('unpipe', (src) => { @@ -682,6 +703,7 @@ Calling [`stream.write()`][stream-write] after calling ```js // write 'hello, ' and then end with 'world!' +const fs = require('fs'); var file = fs.createWriteStream('example.txt'); file.write('hello, '); file.end('world!'); @@ -927,12 +949,15 @@ could wrap the low-level source object by doing something like this: // source is an object with readStop() and readStart() methods, // and an `ondata` member that gets called when it has data, and // an `onend` member that gets called when the data is over. +const util = require('util'); +const Readable = require('stream').Readable; util.inherits(SourceWrapper, Readable); function SourceWrapper(options) { Readable.call(this, options); +/* eslint no-undef:0 */ this._source = getLowlevelSourceObject(); // Every time there's data, we push it into the internal buffer. @@ -963,6 +988,7 @@ This is a basic example of a Readable stream. It emits the numerals from 1 to 1,000,000 in ascending order, and then ends. ```js +const Buffer = require('buffer').Buffer; const Readable = require('stream').Readable; const util = require('util'); util.inherits(Counter, Readable); @@ -1004,6 +1030,7 @@ However, this would be better implemented as a [Transform][] stream. See // Using Readable directly for this is sub-optimal. See the // alternative example below under the Transform section. +const Buffer = require('buffer').Buffer; const Readable = require('stream').Readable; const util = require('util'); @@ -1036,8 +1063,10 @@ function SimpleProtocol(source, options) { } SimpleProtocol.prototype._read = function(n) { + var chunk; + if (!this._inBody) { - var chunk = this._source.read(); + chunk = this._source.read(); // if the source doesn't have data, we don't have data yet. if (chunk === null) @@ -1089,7 +1118,7 @@ SimpleProtocol.prototype._read = function(n) { } else { // from there on, just provide the data to our consumer. // careful not to push(null), since that would indicate EOF. - var chunk = this._source.read(); + chunk = this._source.read(); if (chunk) this.push(chunk); } }; @@ -1199,12 +1228,13 @@ it will be passed to the push method. In other words the following are equivalent: ```js -transform.prototype._transform = function (data, encoding, callback) { +/* eslint no-undef:0 */ +transform.prototype._transform = function(data, encoding, callback) { this.push(data); callback(); }; -transform.prototype._transform = function (data, encoding, callback) { +transform.prototype._transform = function(data, encoding, callback) { callback(null, data); }; ``` @@ -1226,6 +1256,7 @@ would be piped into the parser, which is a more idiomatic Node.js stream approach. ```javascript +const Buffer = require('buffer').Buffer; const util = require('util'); const Transform = require('stream').Transform; util.inherits(SimpleProtocol, Transform); @@ -1391,24 +1422,29 @@ Examples: ### Duplex ```js +const stream = require('stream'); + +/* eslint no-unused-vars:0 */ var duplex = new stream.Duplex({ read: function(n) { // sets this._read under the hood // push data onto the read queue, passing null // will signal the end of the stream (EOF) +/* eslint no-undef:0 */ this.push(chunk); }, write: function(chunk, encoding, next) { // sets this._write under the hood // An optional error can be passed as the first argument - next() + next(); } }); // or +/* eslint no-redeclare:0 */ var duplex = new stream.Duplex({ read: function(n) { // sets this._read under the hood @@ -1421,7 +1457,7 @@ var duplex = new stream.Duplex({ // sets this._writev under the hood // An optional error can be passed as the first argument - next() + next(); } }); ``` @@ -1429,12 +1465,16 @@ var duplex = new stream.Duplex({ ### Readable ```js +const stream = require('stream'); + +/* eslint no-unused-vars:0 */ var readable = new stream.Readable({ read: function(n) { // sets this._read under the hood // push data onto the read queue, passing null // will signal the end of the stream (EOF) +/* eslint no-undef:0 */ this.push(chunk); } }); @@ -1443,6 +1483,9 @@ var readable = new stream.Readable({ ### Transform ```js +const stream = require('stream'); + +/* eslint no-unused-vars:0 */ var transform = new stream.Transform({ transform: function(chunk, encoding, next) { // sets this._transform under the hood @@ -1467,23 +1510,27 @@ var transform = new stream.Transform({ ### Writable ```js +const stream = require('stream'); + +/* eslint no-unused-vars:0 */ var writable = new stream.Writable({ write: function(chunk, encoding, next) { // sets this._write under the hood // An optional error can be passed as the first argument - next() + next(); } }); // or +/* eslint no-redeclare:0 */ var writable = new stream.Writable({ writev: function(chunks, next) { // sets this._writev under the hood // An optional error can be passed as the first argument - next() + next(); } }); ``` @@ -1548,6 +1595,8 @@ introduces an edge case in the following conditions: For example, consider the following code: ```js +const net = require('net'); + // WARNING! BROKEN! net.createServer((socket) => { @@ -1568,6 +1617,8 @@ The workaround in this situation is to call the [`stream.resume()`][stream-resume] method to start the flow of data: ```js +const net = require('net'); + // Workaround net.createServer((socket) => { diff --git a/doc/api/string_decoder.markdown b/doc/api/string_decoder.markdown index d1de27dc4a395a..3fbe0fb8bbe79b 100644 --- a/doc/api/string_decoder.markdown +++ b/doc/api/string_decoder.markdown @@ -7,6 +7,7 @@ buffer to a string. It is a simple interface to `buffer.toString()` but provides additional support for utf8. ```js +const Buffer = require('buffer').Buffer; const StringDecoder = require('string_decoder').StringDecoder; const decoder = new StringDecoder('utf8'); diff --git a/doc/api/synopsis.markdown b/doc/api/synopsis.markdown index 7dd3b8fe99d7fd..e0ed5fd28d4c3a 100644 --- a/doc/api/synopsis.markdown +++ b/doc/api/synopsis.markdown @@ -8,7 +8,7 @@ An example of a [web server][] written with Node.js which responds with ```js const http = require('http'); -http.createServer( (request, response) => { +http.createServer((request, response) => { response.writeHead(200, {'Content-Type': 'text/plain'}); response.end('Hello World\n'); }).listen(8124); diff --git a/doc/api/tls.markdown b/doc/api/tls.markdown index 968eecabf32f83..c5e91b347821d5 100644 --- a/doc/api/tls.markdown +++ b/doc/api/tls.markdown @@ -257,7 +257,32 @@ established after addition of event listener. Here's an example for using TLS session resumption: ```js -var tlsSessionStore = {}; +const tls = require('tls'); +const fs = require('fs'); + +const options = { + key: fs.readFileSync('server-key.pem'), + cert: fs.readFileSync('server-cert.pem'), + + // This is necessary only if using the client certificate authentication. + requestCert: true, + + // This is necessary only if the client uses the self-signed certificate. + ca: [ fs.readFileSync('client-cert.pem') ] +}; + +var server = tls.createServer(options, (socket) => { + console.log('server connected', + socket.authorized ? 'authorized' : 'unauthorized'); + socket.write('welcome!\n'); + socket.setEncoding('utf8'); + socket.pipe(socket); +}); +server.listen(8000, () => { + console.log('server bound'); +}); + +const tlsSessionStore = {}; server.on('newSession', (id, data, cb) => { tlsSessionStore[id.toString('hex')] = data; cb(); @@ -677,6 +702,7 @@ socket.on('data', (data) => { console.log(data); }); socket.on('end', () => { +/* eslint no-undef:0 */ server.close(); }); ``` @@ -702,6 +728,7 @@ socket.on('data', (data) => { console.log(data); }); socket.on('end', () => { +/* eslint no-undef:0 */ server.close(); }); ``` @@ -793,7 +820,7 @@ automatically set as a listener for the [`'secureConnection'`][] event. The - `ciphers`: A string describing the ciphers to use or exclude, separated by `:`. The default cipher suite is: - ```js + ``` ECDHE-RSA-AES128-GCM-SHA256: ECDHE-ECDSA-AES128-GCM-SHA256: ECDHE-RSA-AES256-GCM-SHA384: @@ -966,7 +993,8 @@ Returns an array with the names of the supported SSL ciphers. Example: ```js -var ciphers = tls.getCiphers(); +const tls = require('tls'); +const ciphers = tls.getCiphers(); console.log(ciphers); // ['AES128-SHA', 'AES256-SHA', ...] ``` diff --git a/doc/api/url.markdown b/doc/api/url.markdown index ab29c500d80335..d15a40d370124d 100644 --- a/doc/api/url.markdown +++ b/doc/api/url.markdown @@ -125,7 +125,9 @@ Take a base URL, and a href URL, and resolve them as a browser would for an anchor tag. Examples: ```js -url.resolve('/one/two/three', 'four') // '/one/two/four' -url.resolve('http://example.com/', '/one') // 'http://example.com/one' -url.resolve('http://example.com/one', '/two') // 'http://example.com/two' +const url = require('url'); + +url.resolve('/one/two/three', 'four'); // '/one/two/four' +url.resolve('http://example.com/', '/one'); // 'http://example.com/one' +url.resolve('http://example.com/one', '/two'); // 'http://example.com/two' ``` diff --git a/doc/api/util.markdown b/doc/api/util.markdown index c5c14a7c116c01..a805013c059e89 100644 --- a/doc/api/util.markdown +++ b/doc/api/util.markdown @@ -32,6 +32,7 @@ returned function is a no-op. For example: ```js +const util = require('util'); var debuglog = util.debuglog('foo'); var bar = 123; @@ -105,6 +106,7 @@ If the placeholder does not have a corresponding argument, the placeholder is not replaced. ```js +/* eslint no-undef:0 */ util.format('%s:%s', 'foo'); // 'foo:%s' ``` @@ -113,6 +115,7 @@ coerced to strings (for objects and symbols, `util.inspect()` is used) and then concatenated, delimited by a space. ```js +/* eslint no-undef:0 */ util.format('%s:%s', 'foo', 'bar', 'baz'); // 'foo:bar baz' ``` @@ -121,6 +124,7 @@ a string that is the concatenation of all its arguments separated by spaces. Each argument is converted to a string with `util.inspect()`. ```js +/* eslint no-undef:0 */ util.format(1, 2, 3); // '1 2 3' ``` @@ -138,14 +142,14 @@ const util = require('util'); const EventEmitter = require('events'); function MyStream() { - EventEmitter.call(this); + EventEmitter.call(this); } util.inherits(MyStream, EventEmitter); MyStream.prototype.write = function(data) { - this.emit('data', data); -} + this.emit('data', data); +}; var stream = new MyStream(); @@ -154,7 +158,7 @@ console.log(MyStream.super_ === EventEmitter); // true stream.on('data', (data) => { console.log(`Received data: "${data}"`); -}) +}); stream.write('It works!'); // Received data: "It works!" ``` @@ -239,6 +243,8 @@ formatted according to the returned Object. This is similar to how `JSON.stringify()` works: ```js +const util = require('util'); + var obj = { foo: 'this will not show up in the inspect() output' }; obj.inspect = function(depth) { return { bar: 'baz' }; @@ -259,11 +265,11 @@ Returns `true` if the given "object" is an `Array`. `false` otherwise. ```js const util = require('util'); -util.isArray([]) +util.isArray([]); // true -util.isArray(new Array) +util.isArray(new Array()); // true -util.isArray({}) +util.isArray({}); // false ``` @@ -276,11 +282,11 @@ Returns `true` if the given "object" is a `Boolean`. `false` otherwise. ```js const util = require('util'); -util.isBoolean(1) +util.isBoolean(1); // false -util.isBoolean(0) +util.isBoolean(0); // false -util.isBoolean(false) +util.isBoolean(false); // true ``` @@ -292,12 +298,13 @@ Returns `true` if the given "object" is a `Buffer`. `false` otherwise. ```js const util = require('util'); +const Buffer = require('buffer').Buffer; -util.isBuffer({ length: 0 }) +util.isBuffer({ length: 0 }); // false -util.isBuffer([]) +util.isBuffer([]); // false -util.isBuffer(new Buffer('hello world')) +util.isBuffer(new Buffer('hello world')); // true ``` @@ -310,11 +317,11 @@ Returns `true` if the given "object" is a `Date`. `false` otherwise. ```js const util = require('util'); -util.isDate(new Date()) +util.isDate(new Date()); // true -util.isDate(Date()) +util.isDate(Date()); // false (without 'new' returns a String) -util.isDate({}) +util.isDate({}); // false ``` @@ -327,11 +334,11 @@ Returns `true` if the given "object" is an [`Error`][]. `false` otherwise. ```js const util = require('util'); -util.isError(new Error()) +util.isError(new Error()); // true -util.isError(new TypeError()) +util.isError(new TypeError()); // true -util.isError({ name: 'Error', message: 'an error occurred' }) +util.isError({ name: 'Error', message: 'an error occurred' }); // false ``` @@ -347,11 +354,11 @@ const util = require('util'); function Foo() {} var Bar = function() {}; -util.isFunction({}) +util.isFunction({}); // false -util.isFunction(Foo) +util.isFunction(Foo); // true -util.isFunction(Bar) +util.isFunction(Bar); // true ``` @@ -364,11 +371,11 @@ Returns `true` if the given "object" is strictly `null`. `false` otherwise. ```js const util = require('util'); -util.isNull(0) +util.isNull(0); // false -util.isNull(undefined) +util.isNull(undefined); // false -util.isNull(null) +util.isNull(null); // true ``` @@ -381,11 +388,11 @@ Returns `true` if the given "object" is `null` or `undefined`. `false` otherwise ```js const util = require('util'); -util.isNullOrUndefined(0) +util.isNullOrUndefined(0); // false -util.isNullOrUndefined(undefined) +util.isNullOrUndefined(undefined); // true -util.isNullOrUndefined(null) +util.isNullOrUndefined(null); // true ``` @@ -398,13 +405,13 @@ Returns `true` if the given "object" is a `Number`. `false` otherwise. ```js const util = require('util'); -util.isNumber(false) +util.isNumber(false); // false -util.isNumber(Infinity) +util.isNumber(Infinity); // true -util.isNumber(0) +util.isNumber(0); // true -util.isNumber(NaN) +util.isNumber(NaN); // true ``` @@ -418,13 +425,13 @@ Returns `true` if the given "object" is strictly an `Object` __and__ not a ```js const util = require('util'); -util.isObject(5) +util.isObject(5); // false -util.isObject(null) +util.isObject(null); // false -util.isObject({}) +util.isObject({}); // true -util.isObject(function(){}) +util.isObject(function() {}); // false ``` @@ -437,23 +444,23 @@ Returns `true` if the given "object" is a primitive type. `false` otherwise. ```js const util = require('util'); -util.isPrimitive(5) +util.isPrimitive(5); // true -util.isPrimitive('foo') +util.isPrimitive('foo'); // true -util.isPrimitive(false) +util.isPrimitive(false); // true -util.isPrimitive(null) +util.isPrimitive(null); // true -util.isPrimitive(undefined) +util.isPrimitive(undefined); // true -util.isPrimitive({}) +util.isPrimitive({}); // false -util.isPrimitive(function() {}) +util.isPrimitive(function() {}); // false -util.isPrimitive(/^$/) +util.isPrimitive(/^$/); // false -util.isPrimitive(new Date()) +util.isPrimitive(new Date()); // false ``` @@ -466,11 +473,11 @@ Returns `true` if the given "object" is a `RegExp`. `false` otherwise. ```js const util = require('util'); -util.isRegExp(/some regexp/) +util.isRegExp(/some regexp/); // true -util.isRegExp(new RegExp('another regexp')) +util.isRegExp(new RegExp('another regexp')); // true -util.isRegExp({}) +util.isRegExp({}); // false ``` @@ -483,13 +490,13 @@ Returns `true` if the given "object" is a `String`. `false` otherwise. ```js const util = require('util'); -util.isString('') +util.isString(''); // true -util.isString('foo') +util.isString('foo'); // true -util.isString(String('foo')) +util.isString(String('foo')); // true -util.isString(5) +util.isString(5); // false ``` @@ -502,11 +509,11 @@ Returns `true` if the given "object" is a `Symbol`. `false` otherwise. ```js const util = require('util'); -util.isSymbol(5) +util.isSymbol(5); // false -util.isSymbol('foo') +util.isSymbol('foo'); // false -util.isSymbol(Symbol('foo')) +util.isSymbol(Symbol('foo')); // true ``` @@ -520,11 +527,11 @@ Returns `true` if the given "object" is `undefined`. `false` otherwise. const util = require('util'); var foo; -util.isUndefined(5) +util.isUndefined(5); // false -util.isUndefined(foo) +util.isUndefined(foo); // true -util.isUndefined(null) +util.isUndefined(null); // false ``` diff --git a/doc/api/v8.markdown b/doc/api/v8.markdown index 6aa763add19dd1..53e50c7ab42e56 100644 --- a/doc/api/v8.markdown +++ b/doc/api/v8.markdown @@ -10,14 +10,14 @@ therefore not covered under the stability index. Returns an object with the following properties -```js +```json { - total_heap_size: 7326976, - total_heap_size_executable: 4194304, - total_physical_size: 7326976, - total_available_size: 1152656, - used_heap_size: 3476208, - heap_size_limit: 1535115264 + "total_heap_size": 7326976, + "total_heap_size_executable": 4194304, + "total_physical_size": 7326976, + "total_available_size": 1152656, + "used_heap_size": 3476208, + "heap_size_limit": 1535115264 } ``` @@ -30,7 +30,7 @@ function. Example result: -``` +```json [ { "space_name": "new_space", diff --git a/doc/api/vm.markdown b/doc/api/vm.markdown index a6d86ef349f97d..5bdce581d558ba 100644 --- a/doc/api/vm.markdown +++ b/doc/api/vm.markdown @@ -7,6 +7,7 @@ You can access this module with: ```js +/* eslint no-unused-vars:0 */ const vm = require('vm'); ``` @@ -139,7 +140,7 @@ const script = new vm.Script('globalVar += 1', { filename: 'myfile.vm' }); for (var i = 0; i < 1000; ++i) { script.runInThisContext(); } - +/* eslint no-undef:0 */ console.log(globalVar); // 1000 @@ -201,7 +202,7 @@ const sandbox = { globalVar: 1 }; vm.createContext(sandbox); for (var i = 0; i < 10; ++i) { - vm.runInContext('globalVar *= 2;', sandbox); + vm.runInContext('globalVar *= 2;', sandbox); } console.log(util.inspect(sandbox)); @@ -218,6 +219,7 @@ a separate process. context. The primary use case is to get access to the V8 debug object: ```js +const vm = require('vm'); const Debug = vm.runInDebugContext('Debug'); Debug.scripts().forEach(function(script) { console.log(script.name); }); ``` diff --git a/doc/api/zlib.markdown b/doc/api/zlib.markdown index 60cd7145abbbfb..e68284595db64b 100644 --- a/doc/api/zlib.markdown +++ b/doc/api/zlib.markdown @@ -16,6 +16,9 @@ Compressing or decompressing a file can be done by piping an fs.ReadStream into a zlib stream, then into an fs.WriteStream. ```js +'use strict'; + +const zlib = require('zlib'); const gzip = zlib.createGzip(); const fs = require('fs'); const inp = fs.createReadStream('input.txt'); @@ -28,6 +31,10 @@ Compressing or decompressing data in one step can be done by using the convenience methods. ```js +'use strict'; + +const zlib = require('zlib'); +const Buffer = require('buffer').Buffer; const input = '.................................'; zlib.deflate(input, (err, buffer) => { if (!err) { @@ -56,6 +63,8 @@ ought to be cached. See [Memory Usage Tuning][] for more information on the speed/memory/compression tradeoffs involved in zlib usage. ```js +'use strict'; + // client request example const zlib = require('zlib'); const http = require('http'); @@ -84,9 +93,6 @@ request.on('response', (response) => { // server example // Running a gzip operation on every request is quite expensive. // It would be much more efficient to cache the compressed buffer. -const zlib = require('zlib'); -const http = require('http'); -const fs = require('fs'); http.createServer((request, response) => { var raw = fs.createReadStream('index.html'); var acceptEncoding = request.headers['accept-encoding']; diff --git a/tools/doc/html.js b/tools/doc/html.js index 4eb81f775f0a95..16d5268bb7f178 100644 --- a/tools/doc/html.js +++ b/tools/doc/html.js @@ -42,6 +42,7 @@ function toHTML(input, filename, template, cb) { function onGtocLoaded() { var lexed = marked.lexer(input); + fs.readFile(template, 'utf8', function(er, template) { if (er) return cb(er); render(lexed, filename, template, cb); @@ -119,6 +120,9 @@ function parseLists(input) { output.push({ type: 'html', text: tok.text }); return; } + if (tok.type === 'code') { + tok.text = tok.text.replace(/\/\*\s*eslint.*\*\/\n/, ''); + } if (state === null || (state === 'AFTERHEADING' && tok.type === 'heading')) { if (tok.type === 'heading') { diff --git a/tools/node_modules/.bin/he b/tools/node_modules/.bin/he new file mode 100644 index 00000000000000..ffec3fe6c552d3 --- /dev/null +++ b/tools/node_modules/.bin/he @@ -0,0 +1,15 @@ +#!/bin/sh +basedir=`dirname "$0"` + +case `uname` in + *CYGWIN*) basedir=`cygpath -w "$basedir"`;; +esac + +if [ -x "$basedir/node" ]; then + "$basedir/node" "$basedir/../he/bin/he" "$@" + ret=$? +else + node "$basedir/../he/bin/he" "$@" + ret=$? +fi +exit $ret diff --git a/tools/node_modules/.bin/he.cmd b/tools/node_modules/.bin/he.cmd new file mode 100644 index 00000000000000..1630c8ee980cc2 --- /dev/null +++ b/tools/node_modules/.bin/he.cmd @@ -0,0 +1,7 @@ +@IF EXIST "%~dp0\node.exe" ( + "%~dp0\node.exe" "%~dp0\..\he\bin\he" %* +) ELSE ( + @SETLOCAL + @SET PATHEXT=%PATHEXT:;.JS;=;% + node "%~dp0\..\he\bin\he" %* +) \ No newline at end of file diff --git a/tools/node_modules/.bin/rc b/tools/node_modules/.bin/rc new file mode 100644 index 00000000000000..4dff20bd504dea --- /dev/null +++ b/tools/node_modules/.bin/rc @@ -0,0 +1,15 @@ +#!/bin/sh +basedir=`dirname "$0"` + +case `uname` in + *CYGWIN*) basedir=`cygpath -w "$basedir"`;; +esac + +if [ -x "$basedir/node" ]; then + "$basedir/node" "$basedir/../rc/index.js" "$@" + ret=$? +else + node "$basedir/../rc/index.js" "$@" + ret=$? +fi +exit $ret diff --git a/tools/node_modules/.bin/rc.cmd b/tools/node_modules/.bin/rc.cmd new file mode 100644 index 00000000000000..8f7475e252a889 --- /dev/null +++ b/tools/node_modules/.bin/rc.cmd @@ -0,0 +1,7 @@ +@IF EXIST "%~dp0\node.exe" ( + "%~dp0\node.exe" "%~dp0\..\rc\index.js" %* +) ELSE ( + @SETLOCAL + @SET PATHEXT=%PATHEXT:;.JS;=;% + node "%~dp0\..\rc\index.js" %* +) \ No newline at end of file diff --git a/tools/node_modules/.bin/remark b/tools/node_modules/.bin/remark new file mode 100644 index 00000000000000..8f98290a50573c --- /dev/null +++ b/tools/node_modules/.bin/remark @@ -0,0 +1,15 @@ +#!/bin/sh +basedir=`dirname "$0"` + +case `uname` in + *CYGWIN*) basedir=`cygpath -w "$basedir"`;; +esac + +if [ -x "$basedir/node" ]; then + "$basedir/node" "$basedir/../remark/bin/remark" "$@" + ret=$? +else + node "$basedir/../remark/bin/remark" "$@" + ret=$? +fi +exit $ret diff --git a/tools/node_modules/.bin/remark.cmd b/tools/node_modules/.bin/remark.cmd new file mode 100644 index 00000000000000..67956a6d901908 --- /dev/null +++ b/tools/node_modules/.bin/remark.cmd @@ -0,0 +1,7 @@ +@IF EXIST "%~dp0\node.exe" ( + "%~dp0\node.exe" "%~dp0\..\remark\bin\remark" %* +) ELSE ( + @SETLOCAL + @SET PATHEXT=%PATHEXT:;.JS;=;% + node "%~dp0\..\remark\bin\remark" %* +) \ No newline at end of file diff --git a/tools/node_modules/.bin/strip-json-comments b/tools/node_modules/.bin/strip-json-comments new file mode 100644 index 00000000000000..a17c29e0daf511 --- /dev/null +++ b/tools/node_modules/.bin/strip-json-comments @@ -0,0 +1,15 @@ +#!/bin/sh +basedir=`dirname "$0"` + +case `uname` in + *CYGWIN*) basedir=`cygpath -w "$basedir"`;; +esac + +if [ -x "$basedir/node" ]; then + "$basedir/node" "$basedir/../strip-json-comments/cli.js" "$@" + ret=$? +else + node "$basedir/../strip-json-comments/cli.js" "$@" + ret=$? +fi +exit $ret diff --git a/tools/node_modules/.bin/strip-json-comments.cmd b/tools/node_modules/.bin/strip-json-comments.cmd new file mode 100644 index 00000000000000..16825d10df9933 --- /dev/null +++ b/tools/node_modules/.bin/strip-json-comments.cmd @@ -0,0 +1,7 @@ +@IF EXIST "%~dp0\node.exe" ( + "%~dp0\node.exe" "%~dp0\..\strip-json-comments\cli.js" %* +) ELSE ( + @SETLOCAL + @SET PATHEXT=%PATHEXT:;.JS;=;% + node "%~dp0\..\strip-json-comments\cli.js" %* +) \ No newline at end of file diff --git a/tools/node_modules/ansi-escapes/index.js b/tools/node_modules/ansi-escapes/index.js new file mode 100644 index 00000000000000..6bc26c82a2812f --- /dev/null +++ b/tools/node_modules/ansi-escapes/index.js @@ -0,0 +1,79 @@ +'use strict'; +var ESC = '\u001b['; +var x = module.exports; + +x.cursorTo = function (x, y) { + if (arguments.length === 0) { + return ESC + 'H'; + } + + if (arguments.length === 1) { + return ESC + (x + 1) + 'G'; + } + + return ESC + (y + 1) + ';' + (x + 1) + 'H'; +}; + +x.cursorMove = function (x, y) { + var ret = ''; + + if (x < 0) { + ret += ESC + (-x) + 'D'; + } else if (x > 0) { + ret += ESC + x + 'C'; + } + + if (y < 0) { + ret += ESC + (-y) + 'A'; + } else if (y > 0) { + ret += ESC + y + 'B'; + } + + return ret; +}; + +x.cursorUp = function (count) { + return ESC + (typeof count === 'number' ? count : 1) + 'A'; +}; + +x.cursorDown = function (count) { + return ESC + (typeof count === 'number' ? count : 1) + 'B'; +}; + +x.cursorForward = function (count) { + return ESC + (typeof count === 'number' ? count : 1) + 'C'; +}; + +x.cursorBackward = function (count) { + return ESC + (typeof count === 'number' ? count : 1) + 'D'; +}; + +x.cursorLeft = ESC + '1000D'; +x.cursorSavePosition = ESC + 's'; +x.cursorRestorePosition = ESC + 'u'; +x.cursorGetPosition = ESC + '6n'; +x.cursorNextLine = ESC + 'E'; +x.cursorPrevLine = ESC + 'F'; +x.cursorHide = ESC + '?25l'; +x.cursorShow = ESC + '?25h'; + +x.eraseLines = function (count) { + var clear = ''; + + for (var i = 0; i < count; i++) { + clear += x.cursorLeft + x.eraseEndLine + (i < count - 1 ? x.cursorUp() : ''); + } + + return clear; +}; + +x.eraseEndLine = ESC + 'K'; +x.eraseStartLine = ESC + '1K'; +x.eraseLine = ESC + '2K'; +x.eraseDown = ESC + 'J'; +x.eraseUp = ESC + '1J'; +x.eraseScreen = ESC + '2J'; +x.scrollUp = ESC + 'S'; +x.scrollDown = ESC + 'T'; + +x.beep = '\u0007'; diff --git a/tools/node_modules/ansi-escapes/license b/tools/node_modules/ansi-escapes/license new file mode 100644 index 00000000000000..654d0bfe943437 --- /dev/null +++ b/tools/node_modules/ansi-escapes/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tools/node_modules/ansi-escapes/package.json b/tools/node_modules/ansi-escapes/package.json new file mode 100644 index 00000000000000..5f1628ad2be544 --- /dev/null +++ b/tools/node_modules/ansi-escapes/package.json @@ -0,0 +1,103 @@ +{ + "_args": [ + [ + "ansi-escapes@^1.0.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\log-update" + ] + ], + "_from": "ansi-escapes@>=1.0.0 <2.0.0", + "_id": "ansi-escapes@1.1.1", + "_inCache": true, + "_location": "/ansi-escapes", + "_nodeVersion": "4.2.4", + "_npmUser": { + "email": "sindresorhus@gmail.com", + "name": "sindresorhus" + }, + "_npmVersion": "2.14.12", + "_phantomChildren": {}, + "_requested": { + "name": "ansi-escapes", + "raw": "ansi-escapes@^1.0.0", + "rawSpec": "^1.0.0", + "scope": null, + "spec": ">=1.0.0 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/log-update" + ], + "_resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-1.1.1.tgz", + "_shasum": "cc9c0b193ac4c2b99a19f9b9fbc18ff5edd1d0a8", + "_shrinkwrap": null, + "_spec": "ansi-escapes@^1.0.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\log-update", + "author": { + "email": "sindresorhus@gmail.com", + "name": "Sindre Sorhus", + "url": "sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/sindresorhus/ansi-escapes/issues" + }, + "dependencies": {}, + "description": "ANSI escape codes for manipulating the terminal", + "devDependencies": { + "ava": "*", + "xo": "*" + }, + "directories": {}, + "dist": { + "shasum": "cc9c0b193ac4c2b99a19f9b9fbc18ff5edd1d0a8", + "tarball": "http://registry.npmjs.org/ansi-escapes/-/ansi-escapes-1.1.1.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "3dff027c48a59a377ed44b6d942b1b4f007c326f", + "homepage": "https://github.com/sindresorhus/ansi-escapes", + "installable": true, + "keywords": [ + "ansi", + "cli", + "code", + "codes", + "command-line", + "console", + "control", + "cursor", + "escape", + "escapes", + "formatting", + "log", + "logging", + "sequence", + "shell", + "string", + "terminal", + "text", + "tty", + "vt100", + "xterm" + ], + "license": "MIT", + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + } + ], + "name": "ansi-escapes", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "https://github.com/sindresorhus/ansi-escapes" + }, + "scripts": { + "test": "xo && ava" + }, + "version": "1.1.1" +} diff --git a/tools/node_modules/ansi-escapes/readme.md b/tools/node_modules/ansi-escapes/readme.md new file mode 100644 index 00000000000000..54762b7f240f8f --- /dev/null +++ b/tools/node_modules/ansi-escapes/readme.md @@ -0,0 +1,132 @@ +# ansi-escapes [![Build Status](https://travis-ci.org/sindresorhus/ansi-escapes.svg?branch=master)](https://travis-ci.org/sindresorhus/ansi-escapes) + +> [ANSI escape codes](http://www.termsys.demon.co.uk/vtansi.htm) for manipulating the terminal + + +## Install + +``` +$ npm install --save ansi-escapes +``` + + +## Usage + +```js +var ansiEscapes = require('ansi-escapes'); + +// moves the cursor two rows up and to the left +process.stdout.write(ansiEscapes.cursorUp(2) + ansiEscapes.cursorLeft); +//=> '\u001b[2A\u001b[1000D' +``` + + +## API + +### cursorTo([x, [y]]) + +Set the absolute position of the cursor. `x0` `y0` is the top left of the screen. + +Specify either both `x` & `y`, only `x`, or nothing. + +### cursorMove(x, [y]) + +Set the position of the cursor relative to its current position. + +### cursorUp(count) + +Move cursor up a specific amount of rows. Default is `1`. + +### cursorDown(count) + +Move cursor down a specific amount of rows. Default is `1`. + +### cursorForward(count) + +Move cursor forward a specific amount of rows. Default is `1`. + +### cursorBackward(count) + +Move cursor backward a specific amount of rows. Default is `1`. + +### cursorLeft + +Move cursor to the left side. + +### cursorSavePosition + +Save cursor position. + +### cursorRestorePosition + +Restore saved cursor position. + +### cursorGetPosition + +Get cursor position. + +### cursorNextLine + +Move cursor to the next line. + +### cursorPrevLine + +Move cursor to the previous line. + +### cursorHide + +Hide cursor. + +### cursorShow + +Show cursor. + +### eraseLines(count) + +Erase from the current cursor position up the specified amount of rows. + +### eraseEndLine + +Erase from the current cursor position to the end of the current line. + +### eraseStartLine + +Erase from the current cursor position to the start of the current line. + +### eraseLine + +Erase the entire current line. + +### eraseDown + +Erase the screen from the current line down to the bottom of the screen. + +### eraseUp + +Erase the screen from the current line up to the top of the screen. + +### eraseScreen + +Erase the screen and move the cursor the top left position. + +### scrollUp + +Scroll display up one line. + +### scrollDown + +Scroll display down one line. + +### beep + +Output a beeping sound. + + +## Related + +- [ansi-styles](https://github.com/chalk/ansi-styles) - ANSI escape codes for styling strings in the terminal + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/tools/node_modules/ansi-regex/index.js b/tools/node_modules/ansi-regex/index.js new file mode 100644 index 00000000000000..4906755bc93573 --- /dev/null +++ b/tools/node_modules/ansi-regex/index.js @@ -0,0 +1,4 @@ +'use strict'; +module.exports = function () { + return /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g; +}; diff --git a/tools/node_modules/ansi-regex/license b/tools/node_modules/ansi-regex/license new file mode 100644 index 00000000000000..654d0bfe943437 --- /dev/null +++ b/tools/node_modules/ansi-regex/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tools/node_modules/ansi-regex/package.json b/tools/node_modules/ansi-regex/package.json new file mode 100644 index 00000000000000..f04b8464ac7434 --- /dev/null +++ b/tools/node_modules/ansi-regex/package.json @@ -0,0 +1,112 @@ +{ + "_args": [ + [ + "ansi-regex@^2.0.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\has-ansi" + ] + ], + "_from": "ansi-regex@>=2.0.0 <3.0.0", + "_id": "ansi-regex@2.0.0", + "_inCache": true, + "_location": "/ansi-regex", + "_nodeVersion": "0.12.5", + "_npmUser": { + "email": "sindresorhus@gmail.com", + "name": "sindresorhus" + }, + "_npmVersion": "2.11.2", + "_phantomChildren": {}, + "_requested": { + "name": "ansi-regex", + "raw": "ansi-regex@^2.0.0", + "rawSpec": "^2.0.0", + "scope": null, + "spec": ">=2.0.0 <3.0.0", + "type": "range" + }, + "_requiredBy": [ + "/has-ansi", + "/strip-ansi" + ], + "_resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.0.0.tgz", + "_shasum": "c5061b6e0ef8a81775e50f5d66151bf6bf371107", + "_shrinkwrap": null, + "_spec": "ansi-regex@^2.0.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\has-ansi", + "author": { + "email": "sindresorhus@gmail.com", + "name": "Sindre Sorhus", + "url": "sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/sindresorhus/ansi-regex/issues" + }, + "dependencies": {}, + "description": "Regular expression for matching ANSI escape codes", + "devDependencies": { + "mocha": "*" + }, + "directories": {}, + "dist": { + "shasum": "c5061b6e0ef8a81775e50f5d66151bf6bf371107", + "tarball": "http://registry.npmjs.org/ansi-regex/-/ansi-regex-2.0.0.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "57c3f2941a73079fa8b081e02a522e3d29913e2f", + "homepage": "https://github.com/sindresorhus/ansi-regex", + "installable": true, + "keywords": [ + "256", + "ansi", + "cli", + "color", + "colors", + "colour", + "command-line", + "console", + "escape", + "find", + "formatting", + "match", + "pattern", + "re", + "regex", + "regexp", + "rgb", + "shell", + "string", + "styles", + "terminal", + "test", + "text", + "tty", + "xterm" + ], + "license": "MIT", + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + }, + { + "name": "jbnicolai", + "email": "jappelman@xebia.com" + } + ], + "name": "ansi-regex", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "https://github.com/sindresorhus/ansi-regex" + }, + "scripts": { + "test": "mocha test/test.js", + "view-supported": "node test/viewCodes.js" + }, + "version": "2.0.0" +} diff --git a/tools/node_modules/ansi-regex/readme.md b/tools/node_modules/ansi-regex/readme.md new file mode 100644 index 00000000000000..1a4894ec1110e3 --- /dev/null +++ b/tools/node_modules/ansi-regex/readme.md @@ -0,0 +1,31 @@ +# ansi-regex [![Build Status](https://travis-ci.org/sindresorhus/ansi-regex.svg?branch=master)](https://travis-ci.org/sindresorhus/ansi-regex) + +> Regular expression for matching [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code) + + +## Install + +``` +$ npm install --save ansi-regex +``` + + +## Usage + +```js +var ansiRegex = require('ansi-regex'); + +ansiRegex().test('\u001b[4mcake\u001b[0m'); +//=> true + +ansiRegex().test('cake'); +//=> false + +'\u001b[4mcake\u001b[0m'.match(ansiRegex()); +//=> ['\u001b[4m', '\u001b[0m'] +``` + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/tools/node_modules/ansi-styles/index.js b/tools/node_modules/ansi-styles/index.js new file mode 100644 index 00000000000000..78945278f78a72 --- /dev/null +++ b/tools/node_modules/ansi-styles/index.js @@ -0,0 +1,65 @@ +'use strict'; + +function assembleStyles () { + var styles = { + modifiers: { + reset: [0, 0], + bold: [1, 22], // 21 isn't widely supported and 22 does the same thing + dim: [2, 22], + italic: [3, 23], + underline: [4, 24], + inverse: [7, 27], + hidden: [8, 28], + strikethrough: [9, 29] + }, + colors: { + black: [30, 39], + red: [31, 39], + green: [32, 39], + yellow: [33, 39], + blue: [34, 39], + magenta: [35, 39], + cyan: [36, 39], + white: [37, 39], + gray: [90, 39] + }, + bgColors: { + bgBlack: [40, 49], + bgRed: [41, 49], + bgGreen: [42, 49], + bgYellow: [43, 49], + bgBlue: [44, 49], + bgMagenta: [45, 49], + bgCyan: [46, 49], + bgWhite: [47, 49] + } + }; + + // fix humans + styles.colors.grey = styles.colors.gray; + + Object.keys(styles).forEach(function (groupName) { + var group = styles[groupName]; + + Object.keys(group).forEach(function (styleName) { + var style = group[styleName]; + + styles[styleName] = group[styleName] = { + open: '\u001b[' + style[0] + 'm', + close: '\u001b[' + style[1] + 'm' + }; + }); + + Object.defineProperty(styles, groupName, { + value: group, + enumerable: false + }); + }); + + return styles; +} + +Object.defineProperty(module, 'exports', { + enumerable: true, + get: assembleStyles +}); diff --git a/tools/node_modules/ansi-styles/license b/tools/node_modules/ansi-styles/license new file mode 100644 index 00000000000000..654d0bfe943437 --- /dev/null +++ b/tools/node_modules/ansi-styles/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tools/node_modules/ansi-styles/package.json b/tools/node_modules/ansi-styles/package.json new file mode 100644 index 00000000000000..d4c71cda43908a --- /dev/null +++ b/tools/node_modules/ansi-styles/package.json @@ -0,0 +1,105 @@ +{ + "_args": [ + [ + "ansi-styles@^2.1.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\chalk" + ] + ], + "_from": "ansi-styles@>=2.1.0 <3.0.0", + "_id": "ansi-styles@2.1.0", + "_inCache": true, + "_location": "/ansi-styles", + "_nodeVersion": "0.12.4", + "_npmUser": { + "email": "jappelman@xebia.com", + "name": "jbnicolai" + }, + "_npmVersion": "2.10.1", + "_phantomChildren": {}, + "_requested": { + "name": "ansi-styles", + "raw": "ansi-styles@^2.1.0", + "rawSpec": "^2.1.0", + "scope": null, + "spec": ">=2.1.0 <3.0.0", + "type": "range" + }, + "_requiredBy": [ + "/chalk" + ], + "_resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.1.0.tgz", + "_shasum": "990f747146927b559a932bf92959163d60c0d0e2", + "_shrinkwrap": null, + "_spec": "ansi-styles@^2.1.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\chalk", + "author": { + "email": "sindresorhus@gmail.com", + "name": "Sindre Sorhus", + "url": "sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/chalk/ansi-styles/issues" + }, + "dependencies": {}, + "description": "ANSI escape codes for styling strings in the terminal", + "devDependencies": { + "mocha": "*" + }, + "directories": {}, + "dist": { + "shasum": "990f747146927b559a932bf92959163d60c0d0e2", + "tarball": "http://registry.npmjs.org/ansi-styles/-/ansi-styles-2.1.0.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "18421cbe4a2d93359ec2599a894f704be126d066", + "homepage": "https://github.com/chalk/ansi-styles", + "installable": true, + "keywords": [ + "256", + "ansi", + "cli", + "color", + "colors", + "colour", + "command-line", + "console", + "escape", + "formatting", + "log", + "logging", + "rgb", + "shell", + "string", + "styles", + "terminal", + "text", + "tty", + "xterm" + ], + "license": "MIT", + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + }, + { + "name": "jbnicolai", + "email": "jappelman@xebia.com" + } + ], + "name": "ansi-styles", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "https://github.com/chalk/ansi-styles" + }, + "scripts": { + "test": "mocha" + }, + "version": "2.1.0" +} diff --git a/tools/node_modules/ansi-styles/readme.md b/tools/node_modules/ansi-styles/readme.md new file mode 100644 index 00000000000000..3f933f6162e58e --- /dev/null +++ b/tools/node_modules/ansi-styles/readme.md @@ -0,0 +1,86 @@ +# ansi-styles [![Build Status](https://travis-ci.org/chalk/ansi-styles.svg?branch=master)](https://travis-ci.org/chalk/ansi-styles) + +> [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles) for styling strings in the terminal + +You probably want the higher-level [chalk](https://github.com/chalk/chalk) module for styling your strings. + +![](screenshot.png) + + +## Install + +``` +$ npm install --save ansi-styles +``` + + +## Usage + +```js +var ansi = require('ansi-styles'); + +console.log(ansi.green.open + 'Hello world!' + ansi.green.close); +``` + + +## API + +Each style has an `open` and `close` property. + + +## Styles + +### Modifiers + +- `reset` +- `bold` +- `dim` +- `italic` *(not widely supported)* +- `underline` +- `inverse` +- `hidden` +- `strikethrough` *(not widely supported)* + +### Colors + +- `black` +- `red` +- `green` +- `yellow` +- `blue` +- `magenta` +- `cyan` +- `white` +- `gray` + +### Background colors + +- `bgBlack` +- `bgRed` +- `bgGreen` +- `bgYellow` +- `bgBlue` +- `bgMagenta` +- `bgCyan` +- `bgWhite` + + +## Advanced usage + +By default you get a map of styles, but the styles are also available as groups. They are non-enumerable so they don't show up unless you access them explicitly. This makes it easier to expose only a subset in a higher-level module. + +- `ansi.modifiers` +- `ansi.colors` +- `ansi.bgColors` + + +###### Example + +```js +console.log(ansi.colors.green.open); +``` + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/tools/node_modules/anymatch/LICENSE b/tools/node_modules/anymatch/LICENSE new file mode 100644 index 00000000000000..bc424705fb9c7f --- /dev/null +++ b/tools/node_modules/anymatch/LICENSE @@ -0,0 +1,15 @@ +The ISC License + +Copyright (c) 2014 Elan Shanker + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR +IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/tools/node_modules/anymatch/README.md b/tools/node_modules/anymatch/README.md new file mode 100644 index 00000000000000..0a632921348fa7 --- /dev/null +++ b/tools/node_modules/anymatch/README.md @@ -0,0 +1,91 @@ +anymatch [![Build Status](https://travis-ci.org/es128/anymatch.svg?branch=master)](https://travis-ci.org/es128/anymatch) [![Coverage Status](https://img.shields.io/coveralls/es128/anymatch.svg?branch=master)](https://coveralls.io/r/es128/anymatch?branch=master) +====== +Javascript module to match a string against a regular expression, glob, string, +or function that takes the string as an argument and returns a truthy or falsy +value. The matcher can also be an array of any or all of these. Useful for +allowing a very flexible user-defined config to define things like file paths. + +[![NPM](https://nodei.co/npm/anymatch.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/anymatch/) +[![NPM](https://nodei.co/npm-dl/anymatch.png?height=3&months=9)](https://nodei.co/npm-dl/anymatch/) + +Usage +----- +```sh +npm install anymatch --save +``` + +#### anymatch (matchers, testString, [returnIndex], [startIndex], [endIndex]) +* __matchers__: (_Array|String|RegExp|Function_) +String to be directly matched, string with glob patterns, regular expression +test, function that takes the testString as an argument and returns a truthy +value if it should be matched, or an array of any number and mix of these types. +* __testString__: (_String|Array_) The string to test against the matchers. If +passed as an array, the first element of the array will be used as the +`testString` for non-function matchers, while the entire array will be applied +as the arguments for function matchers. +* __returnIndex__: (_Boolean [optional]_) If true, return the array index of +the first matcher that that testString matched, or -1 if no match, instead of a +boolean result. +* __startIndex, endIndex__: (_Integer [optional]_) Can be used to define a +subset out of the array of provided matchers to test against. Can be useful +with bound matcher functions (see below). When used with `returnIndex = true` +preserves original indexing. Behaves the same as `Array.prototype.slice` (i.e. +includes array members up to, but not including endIndex). + +```js +var anymatch = require('anymatch'); + +var matchers = [ + 'path/to/file.js', + 'path/anyjs/**/*.js', + /foo.js$/, + function (string) { + return string.indexOf('bar') !== -1 && string.length > 10 + } +]; + +anymatch(matchers, 'path/to/file.js'); // true +anymatch(matchers, 'path/anyjs/baz.js'); // true +anymatch(matchers, 'path/to/foo.js'); // true +anymatch(matchers, 'path/to/bar.js'); // true +anymatch(matchers, 'bar.js'); // false + +// returnIndex = true +anymatch(matchers, 'foo.js', true); // 2 +anymatch(matchers, 'path/anyjs/foo.js', true); // 1 + +// skip matchers +anymatch(matchers, 'path/to/file.js', false, 1); // false +anymatch(matchers, 'path/anyjs/foo.js', true, 2, 3); // 2 +anymatch(matchers, 'path/to/bar.js', true, 0, 3); // -1 +``` + +#### anymatch (matchers) +You can also pass in only your matcher(s) to get a curried function that has +already been bound to the provided matching criteria. This can be used as an +`Array.prototype.filter` callback. + +```js +var matcher = anymatch(matchers); + +matcher('path/to/file.js'); // true +matcher('path/anyjs/baz.js', true); // 1 +matcher('path/anyjs/baz.js', true, 2); // -1 + +['foo.js', 'bar.js'].filter(matcher); // ['foo.js'] +``` + +Change Log +---------- +[See release notes page on GitHub](https://github.com/es128/anymatch/releases) + +NOTE: As of v1.2.0, anymatch uses [micromatch](https://github.com/jonschlinkert/micromatch) +for glob pattern matching. The glob matching behavior should be functionally +equivalent to the commonly used [minimatch](https://github.com/isaacs/minimatch) +library (aside from some fixed bugs and greater performance), so a major +version bump wasn't merited. Issues with glob pattern matching should be +reported directly to the [micromatch issue tracker](https://github.com/jonschlinkert/micromatch/issues). + +License +------- +[ISC](https://raw.github.com/es128/anymatch/master/LICENSE) diff --git a/tools/node_modules/anymatch/index.js b/tools/node_modules/anymatch/index.js new file mode 100644 index 00000000000000..fd70ba07eade6c --- /dev/null +++ b/tools/node_modules/anymatch/index.js @@ -0,0 +1,64 @@ +'use strict'; + +var arrify = require('arrify'); +var micromatch = require('micromatch'); +var path = require('path'); + +var anymatch = function(criteria, value, returnIndex, startIndex, endIndex) { + criteria = arrify(criteria); + value = arrify(value); + if (arguments.length === 1) { + return anymatch.bind(null, criteria.map(function(criterion) { + return typeof criterion === 'string' && criterion[0] !== '!' ? + micromatch.matcher(criterion) : criterion; + })); + } + startIndex = startIndex || 0; + var string = value[0]; + var altString; + var matched = false; + var matchIndex = -1; + function testCriteria (criterion, index) { + var result; + switch (toString.call(criterion)) { + case '[object String]': + result = string === criterion || altString && altString === criterion; + result = result || micromatch.isMatch(string, criterion); + break; + case '[object RegExp]': + result = criterion.test(string) || altString && criterion.test(altString); + break; + case '[object Function]': + result = criterion.apply(null, value); + break; + default: + result = false; + } + if (result) { + matchIndex = index + startIndex; + } + return result; + } + var crit = criteria; + var negGlobs = crit.reduce(function(arr, criterion, index) { + if (typeof criterion === 'string' && criterion[0] === '!') { + if (crit === criteria) { + // make a copy before modifying + crit = crit.slice(); + } + crit[index] = null; + arr.push(criterion.substr(1)); + } + return arr; + }, []); + if (!negGlobs.length || !micromatch.any(string, negGlobs)) { + if (path.sep === '\\' && typeof string === 'string') { + altString = string.split('\\').join('/'); + altString = altString === string ? null : altString; + } + matched = crit.slice(startIndex, endIndex).some(testCriteria); + } + return returnIndex === true ? matchIndex : matched; +}; + +module.exports = anymatch; diff --git a/tools/node_modules/anymatch/package.json b/tools/node_modules/anymatch/package.json new file mode 100644 index 00000000000000..ebea2eb4993076 --- /dev/null +++ b/tools/node_modules/anymatch/package.json @@ -0,0 +1,94 @@ +{ + "_args": [ + [ + "anymatch@^1.3.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\chokidar" + ] + ], + "_from": "anymatch@>=1.3.0 <2.0.0", + "_id": "anymatch@1.3.0", + "_inCache": true, + "_location": "/anymatch", + "_nodeVersion": "1.6.2", + "_npmUser": { + "email": "elan.shanker+npm@gmail.com", + "name": "es128" + }, + "_npmVersion": "2.7.3", + "_phantomChildren": {}, + "_requested": { + "name": "anymatch", + "raw": "anymatch@^1.3.0", + "rawSpec": "^1.3.0", + "scope": null, + "spec": ">=1.3.0 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/chokidar" + ], + "_resolved": "https://registry.npmjs.org/anymatch/-/anymatch-1.3.0.tgz", + "_shasum": "a3e52fa39168c825ff57b0248126ce5a8ff95507", + "_shrinkwrap": null, + "_spec": "anymatch@^1.3.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\chokidar", + "author": { + "name": "Elan Shanker", + "url": "http://github.com/es128" + }, + "bugs": { + "url": "https://github.com/es128/anymatch/issues" + }, + "dependencies": { + "arrify": "^1.0.0", + "micromatch": "^2.1.5" + }, + "description": "Matches strings against configurable strings, globs, regular expressions, and/or functions", + "devDependencies": { + "coveralls": "^2.11.2", + "istanbul": "^0.3.13", + "mocha": "^2.2.4" + }, + "directories": {}, + "dist": { + "shasum": "a3e52fa39168c825ff57b0248126ce5a8ff95507", + "tarball": "http://registry.npmjs.org/anymatch/-/anymatch-1.3.0.tgz" + }, + "files": [ + "index.js" + ], + "gitHead": "253d2ad42f644ed18557f561312a7f8426daca84", + "homepage": "https://github.com/es128/anymatch", + "installable": true, + "keywords": [ + "any", + "expression", + "file", + "fs", + "function", + "glob", + "list", + "match", + "regex", + "regexp", + "regular", + "string" + ], + "license": "ISC", + "maintainers": [ + { + "name": "es128", + "email": "elan.shanker+npm@gmail.com" + } + ], + "name": "anymatch", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "https://github.com/es128/anymatch" + }, + "scripts": { + "test": "istanbul cover _mocha && cat ./coverage/lcov.info | coveralls" + }, + "version": "1.3.0" +} diff --git a/tools/node_modules/arr-diff/LICENSE b/tools/node_modules/arr-diff/LICENSE new file mode 100644 index 00000000000000..fa30c4cb3e4c15 --- /dev/null +++ b/tools/node_modules/arr-diff/LICENSE @@ -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. diff --git a/tools/node_modules/arr-diff/README.md b/tools/node_modules/arr-diff/README.md new file mode 100644 index 00000000000000..7705c6cd52801b --- /dev/null +++ b/tools/node_modules/arr-diff/README.md @@ -0,0 +1,74 @@ +# arr-diff [![NPM version](https://img.shields.io/npm/v/arr-diff.svg)](https://www.npmjs.com/package/arr-diff) [![Build Status](https://img.shields.io/travis/jonschlinkert/base.svg)](https://travis-ci.org/jonschlinkert/base) + +> Returns an array with only the unique values from the first array, by excluding all values from additional arrays using strict equality for comparisons. + +## Install + +Install with [npm](https://www.npmjs.com/) + +```sh +$ npm i arr-diff --save +``` +Install with [bower](http://bower.io/) + +```sh +$ bower install arr-diff --save +``` + +## API + +### [diff](index.js#L33) + +Return the difference between the first array and additional arrays. + +**Params** + +* `a` **{Array}** +* `b` **{Array}** +* `returns` **{Array}** + +**Example** + +```js +var diff = require('arr-diff'); + +var a = ['a', 'b', 'c', 'd']; +var b = ['b', 'c']; + +console.log(diff(a, b)) +//=> ['a', 'd'] +``` + +## Related projects + +* [arr-flatten](https://www.npmjs.com/package/arr-flatten): Recursively flatten an array or arrays. This is the fastest implementation of array flatten. | [homepage](https://github.com/jonschlinkert/arr-flatten) +* [array-filter](https://www.npmjs.com/package/array-filter): Array#filter for older browsers. | [homepage](https://github.com/juliangruber/array-filter) +* [array-intersection](https://www.npmjs.com/package/array-intersection): Return an array with the unique values present in _all_ given arrays using strict equality… [more](https://www.npmjs.com/package/array-intersection) | [homepage](https://github.com/jonschlinkert/array-intersection) + +## 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/arr-diff/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 Sat Dec 05 2015 23:24:53 GMT-0500 (EST)._ diff --git a/tools/node_modules/arr-diff/index.js b/tools/node_modules/arr-diff/index.js new file mode 100644 index 00000000000000..bc7200d8e89491 --- /dev/null +++ b/tools/node_modules/arr-diff/index.js @@ -0,0 +1,58 @@ +/*! + * arr-diff + * + * Copyright (c) 2014 Jon Schlinkert, contributors. + * Licensed under the MIT License + */ + +'use strict'; + +var flatten = require('arr-flatten'); +var slice = [].slice; + +/** + * Return the difference between the first array and + * additional arrays. + * + * ```js + * var diff = require('{%= name %}'); + * + * var a = ['a', 'b', 'c', 'd']; + * var b = ['b', 'c']; + * + * console.log(diff(a, b)) + * //=> ['a', 'd'] + * ``` + * + * @param {Array} `a` + * @param {Array} `b` + * @return {Array} + * @api public + */ + +function diff(arr, arrays) { + var argsLen = arguments.length; + var len = arr.length, i = -1; + var res = [], arrays; + + if (argsLen === 1) { + return arr; + } + + if (argsLen > 2) { + arrays = flatten(slice.call(arguments, 1)); + } + + while (++i < len) { + if (!~arrays.indexOf(arr[i])) { + res.push(arr[i]); + } + } + return res; +} + +/** + * Expose `diff` + */ + +module.exports = diff; diff --git a/tools/node_modules/arr-diff/package.json b/tools/node_modules/arr-diff/package.json new file mode 100644 index 00000000000000..3c46c28aa1ea5b --- /dev/null +++ b/tools/node_modules/arr-diff/package.json @@ -0,0 +1,110 @@ +{ + "_args": [ + [ + "arr-diff@^2.0.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\micromatch" + ] + ], + "_from": "arr-diff@>=2.0.0 <3.0.0", + "_id": "arr-diff@2.0.0", + "_inCache": true, + "_location": "/arr-diff", + "_nodeVersion": "5.0.0", + "_npmUser": { + "email": "github@sellside.com", + "name": "jonschlinkert" + }, + "_npmVersion": "3.3.6", + "_phantomChildren": {}, + "_requested": { + "name": "arr-diff", + "raw": "arr-diff@^2.0.0", + "rawSpec": "^2.0.0", + "scope": null, + "spec": ">=2.0.0 <3.0.0", + "type": "range" + }, + "_requiredBy": [ + "/micromatch" + ], + "_resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-2.0.0.tgz", + "_shasum": "8f3b827f955a8bd669697e4a4256ac3ceae356cf", + "_shrinkwrap": null, + "_spec": "arr-diff@^2.0.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\micromatch", + "author": { + "name": "Jon Schlinkert", + "url": "https://github.com/jonschlinkert" + }, + "bugs": { + "url": "https://github.com/jonschlinkert/arr-diff/issues" + }, + "dependencies": { + "arr-flatten": "^1.0.1" + }, + "description": "Returns an array with only the unique values from the first array, by excluding all values from additional arrays using strict equality for comparisons.", + "devDependencies": { + "array-differ": "^1.0.0", + "array-slice": "^0.2.3", + "benchmarked": "^0.1.4", + "chalk": "^1.1.1", + "mocha": "*", + "should": "*" + }, + "directories": {}, + "dist": { + "shasum": "8f3b827f955a8bd669697e4a4256ac3ceae356cf", + "tarball": "http://registry.npmjs.org/arr-diff/-/arr-diff-2.0.0.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "b89f54eb88ca51afd0e0ea6be9a4a63e5ccecf27", + "homepage": "https://github.com/jonschlinkert/arr-diff", + "installable": true, + "keywords": [ + "arr", + "array", + "diff", + "differ", + "difference" + ], + "license": "MIT", + "main": "index.js", + "maintainers": [ + { + "name": "doowb", + "email": "brian.woodward@gmail.com" + }, + { + "name": "jonschlinkert", + "email": "github@sellside.com" + }, + { + "name": "paulmillr", + "email": "paul@paulmillr.com" + } + ], + "name": "arr-diff", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git+https://github.com/jonschlinkert/arr-diff.git" + }, + "scripts": { + "test": "mocha" + }, + "verb": { + "related": { + "list": [ + "arr-flatten", + "array-filter", + "array-intersection" + ] + } + }, + "version": "2.0.0" +} diff --git a/tools/node_modules/arr-flatten/LICENSE b/tools/node_modules/arr-flatten/LICENSE new file mode 100644 index 00000000000000..fa30c4cb3e4c15 --- /dev/null +++ b/tools/node_modules/arr-flatten/LICENSE @@ -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. diff --git a/tools/node_modules/arr-flatten/README.md b/tools/node_modules/arr-flatten/README.md new file mode 100644 index 00000000000000..bd696e660b5009 --- /dev/null +++ b/tools/node_modules/arr-flatten/README.md @@ -0,0 +1,73 @@ +# arr-flatten [![NPM version](https://badge.fury.io/js/arr-flatten.svg)](http://badge.fury.io/js/arr-flatten) [![Build Status](https://travis-ci.org/jonschlinkert/arr-flatten.svg)](https://travis-ci.org/jonschlinkert/arr-flatten) + +> Recursively flatten an array or arrays. This is the fastest implementation of array flatten. + +Why another flatten utility? I wanted the fastest implementation I could find, with implementation choices that should work for 95% of use cases, but no cruft to cover the other 5%. + +## Run benchmarks + +```bash +npm run benchmarks +``` + +Benchmark results comparing this library to [array-flatten]: + +```bash +#1: large.js + arr-flatten.js x 487,030 ops/sec ±0.67% (92 runs sampled) + array-flatten.js x 347,020 ops/sec ±0.57% (98 runs sampled) + +#2: medium.js + arr-flatten.js x 1,914,516 ops/sec ±0.76% (94 runs sampled) + array-flatten.js x 1,391,661 ops/sec ±0.63% (96 runs sampled) + +#3: small.js + arr-flatten.js x 5,158,980 ops/sec ±0.85% (94 runs sampled) + array-flatten.js x 3,683,173 ops/sec ±0.79% (97 runs sampled) +``` + +## Run tests + +Install dev dependencies: + +```bash +npm i -d && npm test +``` + +## Install with [npm](npmjs.org) + +```bash +npm i arr-flatten --save +``` +### Install with [bower](https://github.com/bower/bower) + +```bash +bower install arr-flatten --save +``` + + +## Usage + +```js +var flatten = require('arr-flatten'); + +flatten(['a', ['b', ['c']], 'd', ['e']]); +//=> ['a', 'b', 'c', 'd', 'e'] +``` + +## Author + +**Jon Schlinkert** + ++ [github/jonschlinkert](https://github.com/jonschlinkert) ++ [twitter/jonschlinkert](http://twitter.com/jonschlinkert) + +## License +Copyright (c) 2014-2015 Jon Schlinkert +Released under the MIT license + +*** + +_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on March 11, 2015._ + +[array-flatten]: https://github.com/blakeembrey/array-flatten \ No newline at end of file diff --git a/tools/node_modules/arr-flatten/index.js b/tools/node_modules/arr-flatten/index.js new file mode 100644 index 00000000000000..f74e48c297863f --- /dev/null +++ b/tools/node_modules/arr-flatten/index.js @@ -0,0 +1,27 @@ +/*! + * arr-flatten + * + * Copyright (c) 2014-2015, Jon Schlinkert. + * Licensed under the MIT License. + */ + +'use strict'; + +module.exports = function flatten(arr) { + return flat(arr, []); +}; + +function flat(arr, res) { + var len = arr.length; + var i = -1; + + while (len--) { + var cur = arr[++i]; + if (Array.isArray(cur)) { + flat(cur, res); + } else { + res.push(cur); + } + } + return res; +} \ No newline at end of file diff --git a/tools/node_modules/arr-flatten/package.json b/tools/node_modules/arr-flatten/package.json new file mode 100644 index 00000000000000..a8299480c2ee15 --- /dev/null +++ b/tools/node_modules/arr-flatten/package.json @@ -0,0 +1,99 @@ +{ + "_args": [ + [ + "arr-flatten@^1.0.1", + "C:\\wamp\\www\\node\\tools\\node_modules\\arr-diff" + ] + ], + "_from": "arr-flatten@>=1.0.1 <2.0.0", + "_id": "arr-flatten@1.0.1", + "_inCache": true, + "_location": "/arr-flatten", + "_nodeVersion": "0.12.0", + "_npmUser": { + "email": "github@sellside.com", + "name": "jonschlinkert" + }, + "_npmVersion": "2.5.1", + "_phantomChildren": {}, + "_requested": { + "name": "arr-flatten", + "raw": "arr-flatten@^1.0.1", + "rawSpec": "^1.0.1", + "scope": null, + "spec": ">=1.0.1 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/arr-diff" + ], + "_resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.0.1.tgz", + "_shasum": "e5ffe54d45e19f32f216e91eb99c8ce892bb604b", + "_shrinkwrap": null, + "_spec": "arr-flatten@^1.0.1", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\arr-diff", + "author": { + "name": "Jon Schlinkert", + "url": "https://github.com/jonschlinkert" + }, + "bugs": { + "url": "https://github.com/jonschlinkert/arr-flatten/issues" + }, + "dependencies": {}, + "description": "Recursively flatten an array or arrays. This is the fastest implementation of array flatten.", + "devDependencies": { + "array-flatten": "^1.0.2", + "array-slice": "^0.2.2", + "benchmarked": "^0.1.3", + "chalk": "^0.5.1", + "glob": "^4.3.5", + "kind-of": "^1.0.0" + }, + "directories": {}, + "dist": { + "shasum": "e5ffe54d45e19f32f216e91eb99c8ce892bb604b", + "tarball": "http://registry.npmjs.org/arr-flatten/-/arr-flatten-1.0.1.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "7b3706eaa0093d8f5ba65af8ed590b6fcb3fe7cf", + "homepage": "https://github.com/jonschlinkert/arr-flatten", + "installable": true, + "keywords": [ + "arr", + "array", + "elements", + "flat", + "flatten", + "nested", + "recurse", + "recursive", + "recursively" + ], + "license": { + "type": "MIT", + "url": "https://github.com/jonschlinkert/arr-flatten/blob/master/LICENSE" + }, + "main": "index.js", + "maintainers": [ + { + "name": "jonschlinkert", + "email": "github@sellside.com" + } + ], + "name": "arr-flatten", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git://github.com/jonschlinkert/arr-flatten.git" + }, + "scripts": { + "benchmarks": "node benchmark", + "test": "mocha" + }, + "version": "1.0.1" +} diff --git a/tools/node_modules/array-union/index.js b/tools/node_modules/array-union/index.js new file mode 100644 index 00000000000000..e33f38a1eb4acd --- /dev/null +++ b/tools/node_modules/array-union/index.js @@ -0,0 +1,6 @@ +'use strict'; +var arrayUniq = require('array-uniq'); + +module.exports = function () { + return arrayUniq([].concat.apply([], arguments)); +}; diff --git a/tools/node_modules/array-union/package.json b/tools/node_modules/array-union/package.json new file mode 100644 index 00000000000000..93a28243fb2da0 --- /dev/null +++ b/tools/node_modules/array-union/package.json @@ -0,0 +1,93 @@ +{ + "_args": [ + [ + "array-union@^1.0.1", + "C:\\wamp\\www\\node\\tools\\node_modules\\globby" + ] + ], + "_from": "array-union@>=1.0.1 <2.0.0", + "_id": "array-union@1.0.1", + "_inCache": true, + "_location": "/array-union", + "_nodeVersion": "0.10.32", + "_npmUser": { + "email": "sindresorhus@gmail.com", + "name": "sindresorhus" + }, + "_npmVersion": "2.1.5", + "_phantomChildren": {}, + "_requested": { + "name": "array-union", + "raw": "array-union@^1.0.1", + "rawSpec": "^1.0.1", + "scope": null, + "spec": ">=1.0.1 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/globby" + ], + "_resolved": "https://registry.npmjs.org/array-union/-/array-union-1.0.1.tgz", + "_shasum": "4d410fc8395cb247637124bade9e3f547d5d55f2", + "_shrinkwrap": null, + "_spec": "array-union@^1.0.1", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\globby", + "author": { + "email": "sindresorhus@gmail.com", + "name": "Sindre Sorhus", + "url": "http://sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/sindresorhus/array-union/issues" + }, + "dependencies": { + "array-uniq": "^1.0.1" + }, + "description": "Create an array of unique values, in order, from the input arrays", + "devDependencies": { + "mocha": "*" + }, + "directories": {}, + "dist": { + "shasum": "4d410fc8395cb247637124bade9e3f547d5d55f2", + "tarball": "http://registry.npmjs.org/array-union/-/array-union-1.0.1.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "d0e72cc6fbff57273032e45050c51ff44c8e137c", + "homepage": "https://github.com/sindresorhus/array-union", + "installable": true, + "keywords": [ + "arr", + "array", + "combine", + "duplicate", + "merge", + "remove", + "set", + "union", + "uniq", + "unique" + ], + "license": "MIT", + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + } + ], + "name": "array-union", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "https://github.com/sindresorhus/array-union" + }, + "scripts": { + "test": "mocha" + }, + "version": "1.0.1" +} diff --git a/tools/node_modules/array-union/readme.md b/tools/node_modules/array-union/readme.md new file mode 100644 index 00000000000000..dbae3615e7e905 --- /dev/null +++ b/tools/node_modules/array-union/readme.md @@ -0,0 +1,28 @@ +# array-union [![Build Status](https://travis-ci.org/sindresorhus/array-union.svg?branch=master)](https://travis-ci.org/sindresorhus/array-union) + +> Create an array of unique values, in order, from the input arrays + + +## Install + +```sh +$ npm install --save array-union +``` + + +## Usage + +```js +var arrayUnion = require('array-union'); + +arrayUnion([1, 1, 2, 3], [2, 3]); +//=> [1, 2, 3] + +arrayUnion(['foo', 'foo', 'bar'], ['foo']); +//=> ['foo', 'bar'] +``` + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/tools/node_modules/array-uniq/index.js b/tools/node_modules/array-uniq/index.js new file mode 100644 index 00000000000000..40f81b8a080d89 --- /dev/null +++ b/tools/node_modules/array-uniq/index.js @@ -0,0 +1,60 @@ +'use strict'; + +// there's 3 implementations written in increasing order of efficiency + +// 1 - no Set type is defined +function uniqNoSet(arr) { + var ret = []; + + for (var i = 0; i < arr.length; i++) { + if (ret.indexOf(arr[i]) === -1) { + ret.push(arr[i]); + } + } + + return ret; +} + +// 2 - a simple Set type is defined +function uniqSet(arr) { + var seen = new Set(); + return arr.filter(function (el) { + if (!seen.has(el)) { + seen.add(el); + return true; + } + }); +} + +// 3 - a standard Set type is defined and it has a forEach method +function uniqSetWithForEach(arr) { + var ret = []; + + (new Set(arr)).forEach(function (el) { + ret.push(el); + }); + + return ret; +} + +// V8 currently has a broken implementation +// https://github.com/joyent/node/issues/8449 +function doesForEachActuallyWork() { + var ret = false; + + (new Set([true])).forEach(function (el) { + ret = el; + }); + + return ret === true; +} + +if ('Set' in global) { + if (typeof Set.prototype.forEach === 'function' && doesForEachActuallyWork()) { + module.exports = uniqSetWithForEach; + } else { + module.exports = uniqSet; + } +} else { + module.exports = uniqNoSet; +} diff --git a/tools/node_modules/array-uniq/package.json b/tools/node_modules/array-uniq/package.json new file mode 100644 index 00000000000000..d548dd2c8ce173 --- /dev/null +++ b/tools/node_modules/array-uniq/package.json @@ -0,0 +1,91 @@ +{ + "_args": [ + [ + "array-uniq@^1.0.1", + "C:\\wamp\\www\\node\\tools\\node_modules\\array-union" + ] + ], + "_from": "array-uniq@>=1.0.1 <2.0.0", + "_id": "array-uniq@1.0.2", + "_inCache": true, + "_location": "/array-uniq", + "_nodeVersion": "0.10.32", + "_npmUser": { + "email": "sindresorhus@gmail.com", + "name": "sindresorhus" + }, + "_npmVersion": "2.1.5", + "_phantomChildren": {}, + "_requested": { + "name": "array-uniq", + "raw": "array-uniq@^1.0.1", + "rawSpec": "^1.0.1", + "scope": null, + "spec": ">=1.0.1 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/array-union" + ], + "_resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.2.tgz", + "_shasum": "5fcc373920775723cfd64d65c64bef53bf9eba6d", + "_shrinkwrap": null, + "_spec": "array-uniq@^1.0.1", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\array-union", + "author": { + "email": "sindresorhus@gmail.com", + "name": "Sindre Sorhus", + "url": "http://sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/sindresorhus/array-uniq/issues" + }, + "dependencies": {}, + "description": "Create an array without duplicates", + "devDependencies": { + "es6-set": "^0.1.0", + "mocha": "*", + "require-uncached": "^1.0.2" + }, + "directories": {}, + "dist": { + "shasum": "5fcc373920775723cfd64d65c64bef53bf9eba6d", + "tarball": "http://registry.npmjs.org/array-uniq/-/array-uniq-1.0.2.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "d5e311f37692dfd25ec216490df10632ce5f69f3", + "homepage": "https://github.com/sindresorhus/array-uniq", + "installable": true, + "keywords": [ + "arr", + "array", + "duplicate", + "es6", + "remove", + "set", + "uniq", + "unique" + ], + "license": "MIT", + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + } + ], + "name": "array-uniq", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "https://github.com/sindresorhus/array-uniq" + }, + "scripts": { + "test": "mocha" + }, + "version": "1.0.2" +} diff --git a/tools/node_modules/array-uniq/readme.md b/tools/node_modules/array-uniq/readme.md new file mode 100644 index 00000000000000..5183d07ec13ff3 --- /dev/null +++ b/tools/node_modules/array-uniq/readme.md @@ -0,0 +1,30 @@ +# array-uniq [![Build Status](https://travis-ci.org/sindresorhus/array-uniq.svg?branch=master)](https://travis-ci.org/sindresorhus/array-uniq) + +> Create an array without duplicates + +It's already pretty fast, but will be much faster when [Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) becomes available in V8 (especially with large arrays). + + +## Install + +```sh +$ npm install --save array-uniq +``` + + +## Usage + +```js +var arrayUniq = require('array-uniq'); + +arrayUniq([1, 1, 2, 3, 3]); +//=> [1, 2, 3] + +arrayUniq(['foo', 'foo', 'bar', 'foo']); +//=> ['foo', 'bar'] +``` + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/tools/node_modules/array-unique/LICENSE b/tools/node_modules/array-unique/LICENSE new file mode 100644 index 00000000000000..fa30c4cb3e4c15 --- /dev/null +++ b/tools/node_modules/array-unique/LICENSE @@ -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. diff --git a/tools/node_modules/array-unique/README.md b/tools/node_modules/array-unique/README.md new file mode 100644 index 00000000000000..2e287743ae96aa --- /dev/null +++ b/tools/node_modules/array-unique/README.md @@ -0,0 +1,51 @@ +# array-unique [![NPM version](https://badge.fury.io/js/array-unique.svg)](http://badge.fury.io/js/array-unique) [![Build Status](https://travis-ci.org/jonschlinkert/array-unique.svg)](https://travis-ci.org/jonschlinkert/array-unique) + +> Return an array free of duplicate values. Fastest ES5 implementation. + +## Install with [npm](npmjs.org) + +```bash +npm i array-unique --save +``` + +## Usage + +```js +var unique = require('array-unique'); + +unique(['a', 'b', 'c', 'c']); +//=> ['a', 'b', 'c'] +``` + +## Related +* [arr-diff](https://github.com/jonschlinkert/arr-diff): Returns an array with only the unique values from the first array, by excluding all values from additional arrays using strict equality for comparisons. +* [arr-union](https://github.com/jonschlinkert/arr-union): Returns an array of unique values using strict equality for comparisons. +* [arr-flatten](https://github.com/jonschlinkert/arr-flatten): Recursively flatten an array or arrays. This is the fastest implementation of array flatten. +* [arr-reduce](https://github.com/jonschlinkert/arr-reduce): Fast array reduce that also loops over sparse elements. +* [arr-map](https://github.com/jonschlinkert/arr-map): Faster, node.js focused alternative to JavaScript's native array map. +* [arr-pluck](https://github.com/jonschlinkert/arr-pluck): Retrieves the value of a specified property from all elements in the collection. + +## Run tests +Install dev dependencies. + +```bash +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/array-unique/issues) + +## Author + +**Jon Schlinkert** + ++ [github/jonschlinkert](https://github.com/jonschlinkert) ++ [twitter/jonschlinkert](http://twitter.com/jonschlinkert) + +## License +Copyright (c) 2015 Jon Schlinkert +Released under the MIT license + +*** + +_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on March 24, 2015._ \ No newline at end of file diff --git a/tools/node_modules/array-unique/index.js b/tools/node_modules/array-unique/index.js new file mode 100644 index 00000000000000..7fa75af90a2639 --- /dev/null +++ b/tools/node_modules/array-unique/index.js @@ -0,0 +1,28 @@ +/*! + * array-unique + * + * Copyright (c) 2014-2015, Jon Schlinkert. + * Licensed under the MIT License. + */ + +'use strict'; + +module.exports = function unique(arr) { + if (!Array.isArray(arr)) { + throw new TypeError('array-unique expects an array.'); + } + + var len = arr.length; + var i = -1; + + while (i++ < len) { + var j = i + 1; + + for (; j < arr.length; ++j) { + if (arr[i] === arr[j]) { + arr.splice(j--, 1); + } + } + } + return arr; +}; diff --git a/tools/node_modules/array-unique/package.json b/tools/node_modules/array-unique/package.json new file mode 100644 index 00000000000000..4bd4b68af13959 --- /dev/null +++ b/tools/node_modules/array-unique/package.json @@ -0,0 +1,85 @@ +{ + "_args": [ + [ + "array-unique@^0.2.1", + "C:\\wamp\\www\\node\\tools\\node_modules\\micromatch" + ] + ], + "_from": "array-unique@>=0.2.1 <0.3.0", + "_id": "array-unique@0.2.1", + "_inCache": true, + "_location": "/array-unique", + "_nodeVersion": "1.6.2", + "_npmUser": { + "email": "github@sellside.com", + "name": "jonschlinkert" + }, + "_npmVersion": "2.7.1", + "_phantomChildren": {}, + "_requested": { + "name": "array-unique", + "raw": "array-unique@^0.2.1", + "rawSpec": "^0.2.1", + "scope": null, + "spec": ">=0.2.1 <0.3.0", + "type": "range" + }, + "_requiredBy": [ + "/micromatch" + ], + "_resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.2.1.tgz", + "_shasum": "a1d97ccafcbc2625cc70fadceb36a50c58b01a53", + "_shrinkwrap": null, + "_spec": "array-unique@^0.2.1", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\micromatch", + "author": { + "name": "Jon Schlinkert", + "url": "https://github.com/jonschlinkert" + }, + "bugs": { + "url": "https://github.com/jonschlinkert/array-unique/issues" + }, + "dependencies": {}, + "description": "Return an array free of duplicate values. Fastest ES5 implementation.", + "devDependencies": { + "array-uniq": "^1.0.2", + "benchmarked": "^0.1.3", + "mocha": "*", + "should": "*" + }, + "directories": {}, + "dist": { + "shasum": "a1d97ccafcbc2625cc70fadceb36a50c58b01a53", + "tarball": "http://registry.npmjs.org/array-unique/-/array-unique-0.2.1.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "36fde8e586fb7cf880b8b3aa6515df889e64ed85", + "homepage": "https://github.com/jonschlinkert/array-unique", + "installable": true, + "license": { + "type": "MIT", + "url": "https://github.com/jonschlinkert/array-unique/blob/master/LICENSE" + }, + "main": "index.js", + "maintainers": [ + { + "name": "jonschlinkert", + "email": "github@sellside.com" + } + ], + "name": "array-unique", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git://github.com/jonschlinkert/array-unique.git" + }, + "scripts": { + "test": "mocha" + }, + "version": "0.2.1" +} diff --git a/tools/node_modules/arrify/index.js b/tools/node_modules/arrify/index.js new file mode 100644 index 00000000000000..2a2fdeeb1dc5a5 --- /dev/null +++ b/tools/node_modules/arrify/index.js @@ -0,0 +1,8 @@ +'use strict'; +module.exports = function (val) { + if (val === null || val === undefined) { + return []; + } + + return Array.isArray(val) ? val : [val]; +}; diff --git a/tools/node_modules/arrify/license b/tools/node_modules/arrify/license new file mode 100644 index 00000000000000..654d0bfe943437 --- /dev/null +++ b/tools/node_modules/arrify/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tools/node_modules/arrify/package.json b/tools/node_modules/arrify/package.json new file mode 100644 index 00000000000000..9a7050b5c00b43 --- /dev/null +++ b/tools/node_modules/arrify/package.json @@ -0,0 +1,89 @@ +{ + "_args": [ + [ + "arrify@^1.0.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\anymatch" + ] + ], + "_from": "arrify@>=1.0.0 <2.0.0", + "_id": "arrify@1.0.1", + "_inCache": true, + "_location": "/arrify", + "_nodeVersion": "4.2.1", + "_npmUser": { + "email": "sindresorhus@gmail.com", + "name": "sindresorhus" + }, + "_npmVersion": "3.5.2", + "_phantomChildren": {}, + "_requested": { + "name": "arrify", + "raw": "arrify@^1.0.0", + "rawSpec": "^1.0.0", + "scope": null, + "spec": ">=1.0.0 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/anymatch", + "/globby" + ], + "_resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", + "_shasum": "898508da2226f380df904728456849c1501a4b0d", + "_shrinkwrap": null, + "_spec": "arrify@^1.0.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\anymatch", + "author": { + "email": "sindresorhus@gmail.com", + "name": "Sindre Sorhus", + "url": "sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/sindresorhus/arrify/issues" + }, + "dependencies": {}, + "description": "Convert a value to an array", + "devDependencies": { + "ava": "*", + "xo": "*" + }, + "directories": {}, + "dist": { + "shasum": "898508da2226f380df904728456849c1501a4b0d", + "tarball": "http://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "087edee1a58d5adaac6cae5a107886121ef43783", + "homepage": "https://github.com/sindresorhus/arrify#readme", + "installable": true, + "keywords": [ + "arr", + "array", + "arrayify", + "arrify", + "convert", + "value" + ], + "license": "MIT", + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + } + ], + "name": "arrify", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git+https://github.com/sindresorhus/arrify.git" + }, + "scripts": { + "test": "xo && ava" + }, + "version": "1.0.1" +} diff --git a/tools/node_modules/arrify/readme.md b/tools/node_modules/arrify/readme.md new file mode 100644 index 00000000000000..183d07576f1aee --- /dev/null +++ b/tools/node_modules/arrify/readme.md @@ -0,0 +1,36 @@ +# arrify [![Build Status](https://travis-ci.org/sindresorhus/arrify.svg?branch=master)](https://travis-ci.org/sindresorhus/arrify) + +> Convert a value to an array + + +## Install + +``` +$ npm install --save arrify +``` + + +## Usage + +```js +const arrify = require('arrify'); + +arrify('unicorn'); +//=> ['unicorn'] + +arrify(['unicorn']); +//=> ['unicorn'] + +arrify(null); +//=> [] + +arrify(undefined); +//=> [] +``` + +*Supplying `null` or `undefined` results in an empty array.* + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/tools/node_modules/async-each/.npmignore b/tools/node_modules/async-each/.npmignore new file mode 100644 index 00000000000000..b2971ef95be90c --- /dev/null +++ b/tools/node_modules/async-each/.npmignore @@ -0,0 +1,25 @@ +# Numerous always-ignore extensions +*.diff +*.err +*.orig +*.log +*~ + +# OS or Editor folders +.DS_Store +.cache +Icon? + +# Folders to ignore +.hg +.svn + +# Node.js package manager +/node_modules +/npm-debug.log + +# Other stuff +*.pyc +/tmp + +# Project stuff diff --git a/tools/node_modules/async-each/CHANGELOG.md b/tools/node_modules/async-each/CHANGELOG.md new file mode 100644 index 00000000000000..949a2cfb4d9187 --- /dev/null +++ b/tools/node_modules/async-each/CHANGELOG.md @@ -0,0 +1,20 @@ +# async-each 0.1.6 (5 November 2014) +* Add license to package.json + +# async-each 0.1.5 (22 October 2014) +* Clean up package.json to fix npm warning about `repo` + +# async-each 0.1.4 (12 November 2013) +* Fixed AMD definition. + +# async-each 0.1.3 (25 July 2013) +* Fixed double wrapping of errors. + +# async-each 0.1.2 (7 July 2013) +* Fixed behaviour on empty arrays. + +# async-each 0.1.1 (14 June 2013) +* Wrapped function in closure, enabled strict mode. + +# async-each 0.1.0 (14 June 2013) +* Initial release. diff --git a/tools/node_modules/async-each/README.md b/tools/node_modules/async-each/README.md new file mode 100644 index 00000000000000..53001862d6c90a --- /dev/null +++ b/tools/node_modules/async-each/README.md @@ -0,0 +1,64 @@ +# async-each + +No-bullshit, ultra-simple, 35-lines-of-code async parallel forEach function for JavaScript. + +We don't need junky 30K async libs. Really. + +For browsers and node.js. + +## Installation +* Just include async-each before your scripts. +* `npm install async-each` if you’re using node.js. +* `component install paulmillr/async-each` if you’re using [component(1)](https://github.com/component/component). +* `bower install async-each` if you’re using [Twitter Bower](http://bower.io). + +## Usage + +* `each(array, iterator, callback);` — `Array`, `Function`, `(optional) Function` +* `iterator(item, next)` receives current item and a callback that will mark the item as done. `next` callback receives optional `error, transformedItem` arguments. +* `callback(error, transformedArray)` optionally receives first error and transformed result `Array`. + +Node.js: + +```javascript +var each = require('async-each'); +each(['a.js', 'b.js', 'c.js'], fs.readFile, function(error, contents) { + if (error) console.error(error); + console.log('Contents for a, b and c:', contents); +}); +``` + +Browser: + +```javascript +// component(1) +var each = require('async-each'); +each(list, fn, callback); + +// Default: +window.asyncEach(list, fn, callback); +``` + +## License + +The MIT License (MIT) + +Copyright (c) 2013 Paul Miller (http://paulmillr.com/) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the “Software”), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tools/node_modules/async-each/bower.json b/tools/node_modules/async-each/bower.json new file mode 100644 index 00000000000000..6510855c8df40e --- /dev/null +++ b/tools/node_modules/async-each/bower.json @@ -0,0 +1,22 @@ +{ + "name": "async-each", + "repo": "paulmillr/async-each", + "description": "No-bullshit, ultra-simple, 35-lines-of-code async parallel forEach / map function for JavaScript.", + "version": "0.1.6", + "keywords": [ + "async", "forEach", "each", "map", + "asynchronous", + "iteration", "iterate", + "loop", "parallel", + "concurrent", "array", + "flow", "control flow" + ], + "main": "index.js", + "dependencies": {}, + "development": {}, + "ignore": [ + "**/.*", + "node_modules", + "bower_components" + ] +} diff --git a/tools/node_modules/async-each/component.json b/tools/node_modules/async-each/component.json new file mode 100644 index 00000000000000..83bc0a57ad37c9 --- /dev/null +++ b/tools/node_modules/async-each/component.json @@ -0,0 +1,18 @@ +{ + "name": "async-each", + "repo": "paulmillr/async-each", + "description": "No-bullshit, ultra-simple, 35-lines-of-code async parallel forEach / map function for JavaScript.", + "version": "0.1.6", + "keywords": [ + "async", "forEach", "each", "map", + "asynchronous", + "iteration", "iterate", + "loop", "parallel", + "concurrent", "array", + "flow", "control flow" + ], + "main": "index.js", + "scripts": ["index.js"], + "dependencies": {}, + "development": {} +} diff --git a/tools/node_modules/async-each/index.js b/tools/node_modules/async-each/index.js new file mode 100644 index 00000000000000..1c51c958884377 --- /dev/null +++ b/tools/node_modules/async-each/index.js @@ -0,0 +1,38 @@ +// async-each MIT license (by Paul Miller from http://paulmillr.com). +(function(globals) { + 'use strict'; + var each = function(items, next, callback) { + if (!Array.isArray(items)) throw new TypeError('each() expects array as first argument'); + if (typeof next !== 'function') throw new TypeError('each() expects function as second argument'); + if (typeof callback !== 'function') callback = Function.prototype; // no-op + + if (items.length === 0) return callback(undefined, items); + + var transformed = new Array(items.length); + var count = 0; + var returned = false; + + items.forEach(function(item, index) { + next(item, function(error, transformedItem) { + if (returned) return; + if (error) { + returned = true; + return callback(error); + } + transformed[index] = transformedItem; + count += 1; + if (count === items.length) return callback(undefined, transformed); + }); + }); + }; + + if (typeof define !== 'undefined' && define.amd) { + define([], function() { + return each; + }); // RequireJS + } else if (typeof module !== 'undefined' && module.exports) { + module.exports = each; // CommonJS + } else { + globals.asyncEach = each; // + + diff --git a/tools/node_modules/clone/test.html b/tools/node_modules/clone/test.html new file mode 100644 index 00000000000000..a955702516dfb3 --- /dev/null +++ b/tools/node_modules/clone/test.html @@ -0,0 +1,148 @@ + + + + + Clone Test-Suite (Browser) + + + + + +

Clone Test-Suite (Browser)

+ Tests started: ; + Tests finished: . +
    + + + diff --git a/tools/node_modules/clone/test.js b/tools/node_modules/clone/test.js new file mode 100644 index 00000000000000..e8b65b3fed93c5 --- /dev/null +++ b/tools/node_modules/clone/test.js @@ -0,0 +1,372 @@ +var clone = require('./'); + +function inspect(obj) { + seen = []; + return JSON.stringify(obj, function (key, val) { + if (val != null && typeof val == "object") { + if (seen.indexOf(val) >= 0) { + return '[cyclic]'; + } + + seen.push(val); + } + + return val; + }); +} + +// Creates a new VM in node, or an iframe in a browser in order to run the +// script +function apartContext(context, script, callback) { + var vm = require('vm'); + + if (vm) { + var ctx = vm.createContext({ ctx: context }); + callback(vm.runInContext(script, ctx)); + } else if (document && document.createElement) { + var iframe = document.createElement('iframe'); + iframe.style.display = 'none'; + document.body.appendChild(iframe); + + var myCtxId = 'tmpCtx' + Math.random(); + + window[myCtxId] = context; + iframe.src = 'test-apart-ctx.html?' + myCtxId + '&' + encodeURIComponent(script); + iframe.onload = function() { + try { + callback(iframe.contentWindow.results); + } catch (e) { + throw e; + } + }; + } else { + console.log('WARNING: cannot create an apart context.'); + } +} + +exports["clone string"] = function (test) { + test.expect(2); // how many tests? + + var a = "foo"; + test.strictEqual(clone(a), a); + a = ""; + test.strictEqual(clone(a), a); + + test.done(); +}; + +exports["clone number"] = function (test) { + test.expect(5); // how many tests? + + var a = 0; + test.strictEqual(clone(a), a); + a = 1; + test.strictEqual(clone(a), a); + a = -1000; + test.strictEqual(clone(a), a); + a = 3.1415927; + test.strictEqual(clone(a), a); + a = -3.1415927; + test.strictEqual(clone(a), a); + + test.done(); +}; + +exports["clone date"] = function (test) { + test.expect(3); // how many tests? + + var a = new Date; + var c = clone(a); + test.ok(!!a.getUTCDate && !!a.toUTCString); + test.ok(!!c.getUTCDate && !!c.toUTCString); + test.equal(a.getTime(), c.getTime()); + + test.done(); +}; + +exports["clone object"] = function (test) { + test.expect(1); // how many tests? + + var a = { foo: { bar: "baz" } }; + var b = clone(a); + + test.deepEqual(b, a); + + test.done(); +}; + +exports["clone array"] = function (test) { + test.expect(2); // how many tests? + + var a = [ + { foo: "bar" }, + "baz" + ]; + var b = clone(a); + + test.ok(b instanceof Array); + test.deepEqual(b, a); + + test.done(); +}; + +exports["clone buffer"] = function (test) { + if (typeof Buffer == 'undefined') { + return test.done(); + } + + test.expect(1); + + var a = new Buffer("this is a test buffer"); + var b = clone(a); + + // no underscore equal since it has no concept of Buffers + test.deepEqual(b, a); + test.done(); +}; + +exports["clone regexp"] = function (test) { + test.expect(5); + + var a = /abc123/gi; + var b = clone(a); + test.deepEqual(b, a); + + var c = /a/g; + test.ok(c.lastIndex === 0); + + c.exec('123a456a'); + test.ok(c.lastIndex === 4); + + var d = clone(c); + test.ok(d.global); + test.ok(d.lastIndex === 4); + + test.done(); +}; + +exports["clone object containing array"] = function (test) { + test.expect(1); // how many tests? + + var a = { + arr1: [ { a: '1234', b: '2345' } ], + arr2: [ { c: '345', d: '456' } ] + }; + + var b = clone(a); + + test.deepEqual(b, a); + + test.done(); +}; + +exports["clone object with circular reference"] = function (test) { + test.expect(8); // how many tests? + + var c = [1, "foo", {'hello': 'bar'}, function () {}, false, [2]]; + var b = [c, 2, 3, 4]; + + var a = {'b': b, 'c': c}; + a.loop = a; + a.loop2 = a; + c.loop = c; + c.aloop = a; + + var aCopy = clone(a); + test.ok(a != aCopy); + test.ok(a.c != aCopy.c); + test.ok(aCopy.c == aCopy.b[0]); + test.ok(aCopy.c.loop.loop.aloop == aCopy); + test.ok(aCopy.c[0] == a.c[0]); + + test.ok(eq(a, aCopy)); + aCopy.c[0] = 2; + test.ok(!eq(a, aCopy)); + aCopy.c = "2"; + test.ok(!eq(a, aCopy)); + + function eq(x, y) { + return inspect(x) === inspect(y); + } + + test.done(); +}; + +exports['clone prototype'] = function (test) { + test.expect(3); // how many tests? + + var a = { + a: "aaa", + x: 123, + y: 45.65 + }; + var b = clone.clonePrototype(a); + + test.strictEqual(b.a, a.a); + test.strictEqual(b.x, a.x); + test.strictEqual(b.y, a.y); + + test.done(); +}; + +exports['clone within an apart context'] = function (test) { + var results = apartContext({ clone: clone }, + "results = ctx.clone({ a: [1, 2, 3], d: new Date(), r: /^foo$/ig })", + function (results) { + test.ok(results.a.constructor.toString() === Array.toString()); + test.ok(results.d.constructor.toString() === Date.toString()); + test.ok(results.r.constructor.toString() === RegExp.toString()); + test.done(); + }); +}; + +exports['clone object with no constructor'] = function (test) { + test.expect(3); + + var n = null; + + var a = { foo: 'bar' }; + a.__proto__ = n; + test.ok(typeof a === 'object'); + test.ok(typeof a !== null); + + var b = clone(a); + test.ok(a.foo, b.foo); + + test.done(); +}; + +exports['clone object with depth argument'] = function (test) { + test.expect(6); + + var a = { + foo: { + bar : { + baz : 'qux' + } + } + }; + + var b = clone(a, false, 1); + test.deepEqual(b, a); + test.notEqual(b, a); + test.strictEqual(b.foo, a.foo); + + b = clone(a, true, 2); + test.deepEqual(b, a); + test.notEqual(b.foo, a.foo); + test.strictEqual(b.foo.bar, a.foo.bar); + + test.done(); +}; + +exports['maintain prototype chain in clones'] = function (test) { + test.expect(1); + + function T() {} + + var a = new T(); + var b = clone(a); + test.strictEqual(Object.getPrototypeOf(a), Object.getPrototypeOf(b)); + + test.done(); +}; + +exports['parent prototype is overriden with prototype provided'] = function (test) { + test.expect(1); + + function T() {} + + var a = new T(); + var b = clone(a, true, Infinity, null); + test.strictEqual(b.__defineSetter__, undefined); + + test.done(); +}; + +exports['clone object with null children'] = function (test) { + test.expect(1); + var a = { + foo: { + bar: null, + baz: { + qux: false + } + } + }; + + var b = clone(a); + + test.deepEqual(b, a); + test.done(); +}; + +exports['clone instance with getter'] = function (test) { + test.expect(1); + function Ctor() {}; + Object.defineProperty(Ctor.prototype, 'prop', { + configurable: true, + enumerable: true, + get: function() { + return 'value'; + } + }); + + var a = new Ctor(); + var b = clone(a); + + test.strictEqual(b.prop, 'value'); + test.done(); +}; + +exports['get RegExp flags'] = function (test) { + test.strictEqual(clone.__getRegExpFlags(/a/), '' ); + test.strictEqual(clone.__getRegExpFlags(/a/i), 'i' ); + test.strictEqual(clone.__getRegExpFlags(/a/g), 'g' ); + test.strictEqual(clone.__getRegExpFlags(/a/gi), 'gi'); + test.strictEqual(clone.__getRegExpFlags(/a/m), 'm' ); + + test.done(); +}; + +exports["recognize Array object"] = function (test) { + var results = apartContext(null, "results = [1, 2, 3]", function(alien) { + var local = [4, 5, 6]; + test.ok(clone.__isArray(alien)); // recognize in other context. + test.ok(clone.__isArray(local)); // recognize in local context. + test.ok(!clone.__isDate(alien)); + test.ok(!clone.__isDate(local)); + test.ok(!clone.__isRegExp(alien)); + test.ok(!clone.__isRegExp(local)); + test.done(); + }); +}; + +exports["recognize Date object"] = function (test) { + var results = apartContext(null, "results = new Date()", function(alien) { + var local = new Date(); + + test.ok(clone.__isDate(alien)); // recognize in other context. + test.ok(clone.__isDate(local)); // recognize in local context. + test.ok(!clone.__isArray(alien)); + test.ok(!clone.__isArray(local)); + test.ok(!clone.__isRegExp(alien)); + test.ok(!clone.__isRegExp(local)); + + test.done(); + }); +}; + +exports["recognize RegExp object"] = function (test) { + var results = apartContext(null, "results = /foo/", function(alien) { + var local = /bar/; + + test.ok(clone.__isRegExp(alien)); // recognize in other context. + test.ok(clone.__isRegExp(local)); // recognize in local context. + test.ok(!clone.__isArray(alien)); + test.ok(!clone.__isArray(local)); + test.ok(!clone.__isDate(alien)); + test.ok(!clone.__isDate(local)); + test.done(); + }); +}; diff --git a/tools/node_modules/co/Readme.md b/tools/node_modules/co/Readme.md new file mode 100644 index 00000000000000..62ed1ccf8d46eb --- /dev/null +++ b/tools/node_modules/co/Readme.md @@ -0,0 +1,371 @@ +# Co + + [![Build Status](https://travis-ci.org/visionmedia/co.svg?branch=master)](https://travis-ci.org/visionmedia/co) + + Generator based flow-control goodness for nodejs and the browser, using + thunks _or_ promises, letting you write non-blocking code in a nice-ish + way. + + Co is careful to relay any errors that occur back to the generator, including those + within the thunk, or from the thunk's callback. "Uncaught" exceptions in the generator + are passed to `co()`'s thunk. + + Make sure to view the [examples](https://github.com/visionmedia/co/tree/master/examples). + +## Platform Compatibility + + When using node 0.11.x or greater, you must use the `--harmony-generators` + flag or just `--harmony` to get access to generators. + + When using node 0.10.x and lower or browsers without generator support, + you must use [gnode](https://github.com/TooTallNate/gnode) and/or [regenerator](http://facebook.github.io/regenerator/). + + When using node 0.8.x and lower or browsers without `setImmediate`, + you must include a `setImmediate` polyfill. + For a really simple polyfill, you may use [component/setimmediate.js](https://github.com/component/setimmediate.js). + For a more robust polyfill, you may use [YuzuJS/setImmediate](https://github.com/YuzuJS/setImmediate). + +## Installation + +``` +$ npm install co +``` + +## Associated libraries + + View the [wiki](https://github.com/visionmedia/co/wiki) for libraries that + work well with Co. + +## Example + +```js +var co = require('co'); +var thunkify = require('thunkify'); +var request = require('request'); +var get = thunkify(request.get); + +co(function *(){ + var a = yield get('http://google.com'); + var b = yield get('http://yahoo.com'); + var c = yield get('http://cloudup.com'); + console.log(a[0].statusCode); + console.log(b[0].statusCode); + console.log(c[0].statusCode); +})() + +co(function *(){ + var a = get('http://google.com'); + var b = get('http://yahoo.com'); + var c = get('http://cloudup.com'); + var res = yield [a, b, c]; + console.log(res); +})() + +// Error handling + +co(function *(){ + try { + var res = yield get('http://badhost.invalid'); + console.log(res); + } catch(e) { + console.log(e.code) // ENOTFOUND + } +})() +``` + +## Yieldables + + The "yieldable" objects currently supported are: + + - promises + - thunks (functions) + - array (parallel execution) + - objects (parallel execution) + - generators (delegation) + - generator functions (delegation) + +To convert a regular node function that accepts a callback into one which returns a thunk you may want to use [thunkify](https://github.com/visionmedia/node-thunkify) or similar. + +## Thunks vs promises + + While co supports promises, you may return "thunks" from your functions, + which otherwise behaves just like the traditional node-style callback + with a signature of: `(err, result)`. + + + For example take `fs.readFile`, we all know the signature is: + +```js +fs.readFile(path, encoding, function(err, result){ + +}); +``` + + To work with Co we need a function to return another function of + the same signature: + +```js +fs.readFile(path, encoding)(function(err, result){ + +}); +``` + + Which basically looks like this: + +```js +function read(path, encoding) { + return function(cb){ + fs.readFile(path, encoding, cb); + } +} +``` + + or to execute immediately like this (see [`thunkify`](https://github.com/visionmedia/node-thunkify)): + +```js +function read(path, encoding) { + // call fs.readFile immediately, store result later + return function(cb){ + // cb(err, result) or when result ready + } +} +``` + +## Receiver propagation + + When `co` is invoked with a receiver it will propagate to most yieldables, + allowing you to alter `this`. + +```js +var ctx = {}; + +function foo() { + assert(this == ctx); +} + +co(function *(){ + assert(this == ctx); + yield foo; +}).call(ctx) +``` + + You also pass arguments through the generator: + +```js +co(function *(a){ + assert(this == ctx); + assert('yay' == a); + yield foo; +}).call(ctx, 'yay'); +``` + +## API + +### co(fn) + + Pass a generator `fn` and return a thunk. The thunk's signature is + `(err, result)`, where `result` is the value passed to the `return` + statement. + +```js +var co = require('co'); +var fs = require('fs'); + +function read(file) { + return function(fn){ + fs.readFile(file, 'utf8', fn); + } +} + +co(function *(){ + var a = yield read('.gitignore'); + var b = yield read('Makefile'); + var c = yield read('package.json'); + return [a, b, c]; +})() +``` + + You may also yield `Generator` objects to support nesting: + + +```js +var co = require('co'); +var fs = require('fs'); + +function size(file) { + return function(fn){ + fs.stat(file, function(err, stat){ + if (err) return fn(err); + fn(null, stat.size); + }); + } +} + +function *foo(){ + var a = yield size('.gitignore'); + var b = yield size('Makefile'); + var c = yield size('package.json'); + return [a, b, c]; +} + +function *bar(){ + var a = yield size('examples/parallel.js'); + var b = yield size('examples/nested.js'); + var c = yield size('examples/simple.js'); + return [a, b, c]; +} + +co(function *(){ + var results = yield [foo(), bar()]; + console.log(results); +})() +``` + + Or if the generator functions do not require arguments, simply `yield` the function: + +```js +var co = require('co'); +var thunkify = require('thunkify'); +var request = require('request'); + +var get = thunkify(request.get); + +function *results() { + var a = get('http://google.com') + var b = get('http://yahoo.com') + var c = get('http://ign.com') + return yield [a, b, c] +} + +co(function *(){ + // 3 concurrent requests at a time + var a = yield results; + var b = yield results; + console.log(a, b); + + // 6 concurrent requests + console.log(yield [results, results]); +})() +``` + + If a thunk is written to execute immediately you may achieve parallelism + by simply `yield`-ing _after_ the call. The following are equivalent if + each call kicks off execution immediately: + +```js +co(function *(){ + var a = size('package.json'); + var b = size('Readme.md'); + var c = size('Makefile'); + + return [yield a, yield b, yield c]; +})() +``` + + Or: + +```js +co(function *(){ + var a = size('package.json'); + var b = size('Readme.md'); + var c = size('Makefile'); + + return yield [a, b, c]; +})() +``` + + You can also pass arguments into the generator. The last argument, `done`, is + the callback function. Here's an example: + +```js +var exec = require('co-exec'); +co(function *(cmd) { + var res = yield exec(cmd); + return res; +})('pwd', done); +``` + +### yield array + + By yielding an array of thunks you may "join" them all into a single thunk which executes them all concurrently, + instead of in sequence. Note that the resulting array ordering _is_ retained. + +```js + +var co = require('co'); +var fs = require('fs'); + +function size(file) { + return function(fn){ + fs.stat(file, function(err, stat){ + if (err) return fn(err); + fn(null, stat.size); + }); + } +} + +co(function *(){ + var a = size('.gitignore'); + var b = size('index.js'); + var c = size('Makefile'); + var res = yield [a, b, c]; + console.log(res); + // => [ 13, 1687, 129 ] +})() +``` + +Nested arrays may also be expressed as simple nested arrays: + +```js +var a = [ + get('http://google.com'), + get('http://yahoo.com'), + get('http://ign.com') +]; + +var b = [ + get('http://google.com'), + get('http://yahoo.com'), + get('http://ign.com') +]; + +console.log(yield [a, b]); +``` + +### yield object + + Yielding an object behaves much like yielding an array, however recursion is supported: + +```js +co(function *(){ + var user = yield { + name: { + first: get('name.first'), + last: get('name.last') + } + }; +})() +``` + + Here is the sequential equivalent without yielding an object: + +```js +co(function *(){ + var user = { + name: { + first: yield get('name.first'), + last: yield get('name.last') + } + }; +})() +``` + +### Performance + + On my machine 30,000 sequential stat()s takes an avg of 570ms, + while the same number of sequential stat()s with `co()` takes + 610ms, aka the overhead introduced by generators is _extremely_ negligible. + +## License + + MIT diff --git a/tools/node_modules/co/index.js b/tools/node_modules/co/index.js new file mode 100644 index 00000000000000..55e4b8a67f34c5 --- /dev/null +++ b/tools/node_modules/co/index.js @@ -0,0 +1,294 @@ + +/** + * slice() reference. + */ + +var slice = Array.prototype.slice; + +/** + * Expose `co`. + */ + +module.exports = co; + +/** + * Wrap the given generator `fn` and + * return a thunk. + * + * @param {Function} fn + * @return {Function} + * @api public + */ + +function co(fn) { + var isGenFun = isGeneratorFunction(fn); + + return function (done) { + var ctx = this; + + // in toThunk() below we invoke co() + // with a generator, so optimize for + // this case + var gen = fn; + + // we only need to parse the arguments + // if gen is a generator function. + if (isGenFun) { + var args = slice.call(arguments), len = args.length; + var hasCallback = len && 'function' == typeof args[len - 1]; + done = hasCallback ? args.pop() : error; + gen = fn.apply(this, args); + } else { + done = done || error; + } + + next(); + + // #92 + // wrap the callback in a setImmediate + // so that any of its errors aren't caught by `co` + function exit(err, res) { + setImmediate(function(){ + done.call(ctx, err, res); + }); + } + + function next(err, res) { + var ret; + + // multiple args + if (arguments.length > 2) res = slice.call(arguments, 1); + + // error + if (err) { + try { + ret = gen.throw(err); + } catch (e) { + return exit(e); + } + } + + // ok + if (!err) { + try { + ret = gen.next(res); + } catch (e) { + return exit(e); + } + } + + // done + if (ret.done) return exit(null, ret.value); + + // normalize + ret.value = toThunk(ret.value, ctx); + + // run + if ('function' == typeof ret.value) { + var called = false; + try { + ret.value.call(ctx, function(){ + if (called) return; + called = true; + next.apply(ctx, arguments); + }); + } catch (e) { + setImmediate(function(){ + if (called) return; + called = true; + next(e); + }); + } + return; + } + + // invalid + next(new TypeError('You may only yield a function, promise, generator, array, or object, ' + + 'but the following was passed: "' + String(ret.value) + '"')); + } + } +} + +/** + * Convert `obj` into a normalized thunk. + * + * @param {Mixed} obj + * @param {Mixed} ctx + * @return {Function} + * @api private + */ + +function toThunk(obj, ctx) { + + if (isGeneratorFunction(obj)) { + return co(obj.call(ctx)); + } + + if (isGenerator(obj)) { + return co(obj); + } + + if (isPromise(obj)) { + return promiseToThunk(obj); + } + + if ('function' == typeof obj) { + return obj; + } + + if (isObject(obj) || Array.isArray(obj)) { + return objectToThunk.call(ctx, obj); + } + + return obj; +} + +/** + * Convert an object of yieldables to a thunk. + * + * @param {Object} obj + * @return {Function} + * @api private + */ + +function objectToThunk(obj){ + var ctx = this; + var isArray = Array.isArray(obj); + + return function(done){ + var keys = Object.keys(obj); + var pending = keys.length; + var results = isArray + ? new Array(pending) // predefine the array length + : new obj.constructor(); + var finished; + + if (!pending) { + setImmediate(function(){ + done(null, results) + }); + return; + } + + // prepopulate object keys to preserve key ordering + if (!isArray) { + for (var i = 0; i < pending; i++) { + results[keys[i]] = undefined; + } + } + + for (var i = 0; i < keys.length; i++) { + run(obj[keys[i]], keys[i]); + } + + function run(fn, key) { + if (finished) return; + try { + fn = toThunk(fn, ctx); + + if ('function' != typeof fn) { + results[key] = fn; + return --pending || done(null, results); + } + + fn.call(ctx, function(err, res){ + if (finished) return; + + if (err) { + finished = true; + return done(err); + } + + results[key] = res; + --pending || done(null, results); + }); + } catch (err) { + finished = true; + done(err); + } + } + } +} + +/** + * Convert `promise` to a thunk. + * + * @param {Object} promise + * @return {Function} + * @api private + */ + +function promiseToThunk(promise) { + return function(fn){ + promise.then(function(res) { + fn(null, res); + }, fn); + } +} + +/** + * Check if `obj` is a promise. + * + * @param {Object} obj + * @return {Boolean} + * @api private + */ + +function isPromise(obj) { + return obj && 'function' == typeof obj.then; +} + +/** + * Check if `obj` is a generator. + * + * @param {Mixed} obj + * @return {Boolean} + * @api private + */ + +function isGenerator(obj) { + return obj && 'function' == typeof obj.next && 'function' == typeof obj.throw; +} + +/** + * Check if `obj` is a generator function. + * + * @param {Mixed} obj + * @return {Boolean} + * @api private + */ + +function isGeneratorFunction(obj) { + return obj && obj.constructor && 'GeneratorFunction' == obj.constructor.name; +} + +/** + * Check for plain object. + * + * @param {Mixed} val + * @return {Boolean} + * @api private + */ + +function isObject(val) { + return val && Object == val.constructor; +} + +/** + * Throw `err` in a new stack. + * + * This is used when co() is invoked + * without supplying a callback, which + * should only be for demonstrational + * purposes. + * + * @param {Error} err + * @api private + */ + +function error(err) { + if (!err) return; + setImmediate(function(){ + throw err; + }); +} diff --git a/tools/node_modules/co/package.json b/tools/node_modules/co/package.json new file mode 100644 index 00000000000000..2114da8aaf9e42 --- /dev/null +++ b/tools/node_modules/co/package.json @@ -0,0 +1,81 @@ +{ + "_args": [ + [ + "co@3.1.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\wrap-fn" + ] + ], + "_from": "co@3.1.0", + "_id": "co@3.1.0", + "_inCache": true, + "_location": "/co", + "_npmUser": { + "email": "tj@vision-media.ca", + "name": "tjholowaychuk" + }, + "_npmVersion": "1.4.9", + "_phantomChildren": {}, + "_requested": { + "name": "co", + "raw": "co@3.1.0", + "rawSpec": "3.1.0", + "scope": null, + "spec": "3.1.0", + "type": "version" + }, + "_requiredBy": [ + "/wrap-fn" + ], + "_resolved": "https://registry.npmjs.org/co/-/co-3.1.0.tgz", + "_shasum": "4ea54ea5a08938153185e15210c68d9092bc1b78", + "_shrinkwrap": null, + "_spec": "co@3.1.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\wrap-fn", + "bugs": { + "url": "https://github.com/visionmedia/co/issues" + }, + "dependencies": {}, + "description": "generator async flow control goodness", + "devDependencies": { + "bluebird": "^2.0.0", + "matcha": "~0.5.0", + "mocha": "^1.12.0", + "request": "^2.36.0", + "should": "^3.0.0", + "thunkify": "^2.0.0" + }, + "directories": {}, + "dist": { + "shasum": "4ea54ea5a08938153185e15210c68d9092bc1b78", + "tarball": "http://registry.npmjs.org/co/-/co-3.1.0.tgz" + }, + "files": [ + "index.js" + ], + "homepage": "https://github.com/visionmedia/co", + "installable": true, + "keywords": [ + "async", + "coro", + "coroutine", + "flow", + "generator" + ], + "license": "MIT", + "maintainers": [ + { + "name": "tjholowaychuk", + "email": "tj@vision-media.ca" + } + ], + "name": "co", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "https://github.com/visionmedia/co.git" + }, + "scripts": { + "test": "make test" + }, + "version": "3.1.0" +} diff --git a/tools/node_modules/code-point-at/index.js b/tools/node_modules/code-point-at/index.js new file mode 100644 index 00000000000000..0335117977237f --- /dev/null +++ b/tools/node_modules/code-point-at/index.js @@ -0,0 +1,33 @@ +'use strict'; +var numberIsNan = require('number-is-nan'); + +module.exports = function (str, pos) { + if (str === null || str === undefined) { + throw TypeError(); + } + + str = String(str); + + var size = str.length; + var i = pos ? Number(pos) : 0; + + if (numberIsNan(i)) { + i = 0; + } + + if (i < 0 || i >= size) { + return undefined; + } + + var first = str.charCodeAt(i); + + if (first >= 0xD800 && first <= 0xDBFF && size > i + 1) { + var second = str.charCodeAt(i + 1); + + if (second >= 0xDC00 && second <= 0xDFFF) { + return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000; + } + } + + return first; +}; diff --git a/tools/node_modules/code-point-at/license b/tools/node_modules/code-point-at/license new file mode 100644 index 00000000000000..654d0bfe943437 --- /dev/null +++ b/tools/node_modules/code-point-at/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tools/node_modules/code-point-at/package.json b/tools/node_modules/code-point-at/package.json new file mode 100644 index 00000000000000..8cff537bbdc69f --- /dev/null +++ b/tools/node_modules/code-point-at/package.json @@ -0,0 +1,95 @@ +{ + "_args": [ + [ + "code-point-at@^1.0.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\string-width" + ] + ], + "_from": "code-point-at@>=1.0.0 <2.0.0", + "_id": "code-point-at@1.0.0", + "_inCache": true, + "_location": "/code-point-at", + "_nodeVersion": "0.12.5", + "_npmUser": { + "email": "sindresorhus@gmail.com", + "name": "sindresorhus" + }, + "_npmVersion": "2.11.2", + "_phantomChildren": {}, + "_requested": { + "name": "code-point-at", + "raw": "code-point-at@^1.0.0", + "rawSpec": "^1.0.0", + "scope": null, + "spec": ">=1.0.0 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/string-width" + ], + "_resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.0.0.tgz", + "_shasum": "f69b192d3f7d91e382e4b71bddb77878619ab0c6", + "_shrinkwrap": null, + "_spec": "code-point-at@^1.0.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\string-width", + "author": { + "email": "sindresorhus@gmail.com", + "name": "Sindre Sorhus", + "url": "sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/sindresorhus/code-point-at/issues" + }, + "dependencies": { + "number-is-nan": "^1.0.0" + }, + "description": "ES2015 String#codePointAt() ponyfill", + "devDependencies": { + "ava": "0.0.4" + }, + "directories": {}, + "dist": { + "shasum": "f69b192d3f7d91e382e4b71bddb77878619ab0c6", + "tarball": "http://registry.npmjs.org/code-point-at/-/code-point-at-1.0.0.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "c2ffa4064718b37c84c73a633abeeed5b486a469", + "homepage": "https://github.com/sindresorhus/code-point-at", + "installable": true, + "keywords": [ + "at", + "code", + "codepoint", + "es2015", + "es6", + "point", + "polyfill", + "ponyfill", + "shim", + "str", + "string", + "unicode" + ], + "license": "MIT", + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + } + ], + "name": "code-point-at", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "https://github.com/sindresorhus/code-point-at" + }, + "scripts": { + "test": "node test.js" + }, + "version": "1.0.0" +} diff --git a/tools/node_modules/code-point-at/readme.md b/tools/node_modules/code-point-at/readme.md new file mode 100644 index 00000000000000..71e7d0931b8b0c --- /dev/null +++ b/tools/node_modules/code-point-at/readme.md @@ -0,0 +1,34 @@ +# code-point-at [![Build Status](https://travis-ci.org/sindresorhus/code-point-at.svg?branch=master)](https://travis-ci.org/sindresorhus/code-point-at) + +> ES2015 [`String#codePointAt()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt) ponyfill + +> Ponyfill: A polyfill that doesn't overwrite the native method + + +## Install + +``` +$ npm install --save code-point-at +``` + + +## Usage + +```js +var codePointAt = require('code-point-at'); + +codePointAt('🐴'); +//=> 128052 + +codePointAt('abc', 2); +//=> 99 +``` + +## API + +### codePointAt(input, [position]) + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/tools/node_modules/collapse-white-space/LICENSE b/tools/node_modules/collapse-white-space/LICENSE new file mode 100644 index 00000000000000..611b67581bb8e2 --- /dev/null +++ b/tools/node_modules/collapse-white-space/LICENSE @@ -0,0 +1,22 @@ +(The MIT License) + +Copyright (c) 2015 Titus Wormer + +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. diff --git a/tools/node_modules/collapse-white-space/history.md b/tools/node_modules/collapse-white-space/history.md new file mode 100644 index 00000000000000..654a34d89a391f --- /dev/null +++ b/tools/node_modules/collapse-white-space/history.md @@ -0,0 +1,9 @@ +--- +mdast: + setext: true +--- + + + +1.0.0 / 2015-07-12 +================== diff --git a/tools/node_modules/collapse-white-space/index.js b/tools/node_modules/collapse-white-space/index.js new file mode 100644 index 00000000000000..b0a5e17480a7bb --- /dev/null +++ b/tools/node_modules/collapse-white-space/index.js @@ -0,0 +1,28 @@ +'use strict'; + +/* + * Constants. + */ + +var WHITE_SPACE_COLLAPSABLE = /\s+/g; +var SPACE = ' '; + +/** + * Replace multiple white-space characters with a single space. + * + * @example + * collapse(' \t\nbar \nbaz\t'); // ' bar baz ' + * + * @param {string} value - Value with uncollapsed white-space, + * coerced to string. + * @return {string} - Value with collapsed white-space. + */ +function collapse(value) { + return String(value).replace(WHITE_SPACE_COLLAPSABLE, SPACE); +} + +/* + * Expose. + */ + +module.exports = collapse; diff --git a/tools/node_modules/collapse-white-space/package.json b/tools/node_modules/collapse-white-space/package.json new file mode 100644 index 00000000000000..314fa6438c5eeb --- /dev/null +++ b/tools/node_modules/collapse-white-space/package.json @@ -0,0 +1,104 @@ +{ + "_args": [ + [ + "collapse-white-space@^1.0.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\remark" + ] + ], + "_from": "collapse-white-space@>=1.0.0 <2.0.0", + "_id": "collapse-white-space@1.0.0", + "_inCache": true, + "_location": "/collapse-white-space", + "_nodeVersion": "2.3.3", + "_npmUser": { + "email": "tituswormer@gmail.com", + "name": "wooorm" + }, + "_npmVersion": "2.11.3", + "_phantomChildren": {}, + "_requested": { + "name": "collapse-white-space", + "raw": "collapse-white-space@^1.0.0", + "rawSpec": "^1.0.0", + "scope": null, + "spec": ">=1.0.0 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/remark" + ], + "_resolved": "https://registry.npmjs.org/collapse-white-space/-/collapse-white-space-1.0.0.tgz", + "_shasum": "94c809660c5661874fbb52bc74dc3519afca9023", + "_shrinkwrap": null, + "_spec": "collapse-white-space@^1.0.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\remark", + "author": { + "email": "tituswormer@gmail.com", + "name": "Titus Wormer" + }, + "bugs": { + "url": "https://github.com/wooorm/collapse-white-space/issues" + }, + "dependencies": {}, + "description": "Replace multiple white-space characters with a single space", + "devDependencies": { + "browserify": "^10.0.0", + "eslint": "^0.24.0", + "esmangle": "^1.0.0", + "istanbul": "^0.3.0", + "jscs": "^1.0.0", + "jscs-jsdoc": "^1.0.0", + "mdast": "^0.26.0", + "mdast-github": "^0.3.1", + "mdast-lint": "^0.4.1", + "mdast-usage": "^0.3.0", + "mdast-yaml-config": "^0.2.0", + "mocha": "^2.0.0" + }, + "directories": {}, + "dist": { + "shasum": "94c809660c5661874fbb52bc74dc3519afca9023", + "tarball": "http://registry.npmjs.org/collapse-white-space/-/collapse-white-space-1.0.0.tgz" + }, + "files": [ + "LICENSE", + "index.js" + ], + "gitHead": "c24540f3690cf840cc7b3549876851aaace3754d", + "homepage": "https://github.com/wooorm/collapse-white-space#readme", + "installable": true, + "keywords": [ + "collapse", + "space", + "white" + ], + "license": "MIT", + "maintainers": [ + { + "name": "wooorm", + "email": "tituswormer@gmail.com" + } + ], + "name": "collapse-white-space", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git+https://github.com/wooorm/collapse-white-space.git" + }, + "scripts": { + "build": "npm run build-md && npm run build-bundle", + "build-bundle": "browserify index.js --bare -s collapseWhiteSpace > collapse-white-space.js", + "build-md": "mdast . LICENSE --output --quiet", + "lint": "npm run lint-api && npm run lint-style", + "lint-api": "eslint .", + "lint-style": "jscs --reporter inline .", + "make": "npm run lint && npm run test-coverage", + "postbuild-bundle": "esmangle collapse-white-space.js > collapse-white-space.min.js", + "test": "npm run test-api", + "test-api": "mocha --check-leaks test.js", + "test-coverage": "istanbul cover _mocha -- --check-leaks test.js", + "test-coveralls": "istanbul cover _mocha --report lcovonly -- --check-leaks test.js", + "test-travis": "npm run test-coveralls" + }, + "version": "1.0.0" +} diff --git a/tools/node_modules/collapse-white-space/readme.md b/tools/node_modules/collapse-white-space/readme.md new file mode 100644 index 00000000000000..d926c889955112 --- /dev/null +++ b/tools/node_modules/collapse-white-space/readme.md @@ -0,0 +1,52 @@ +# collapse-white-space [![Build Status](https://img.shields.io/travis/wooorm/collapse-white-space.svg?style=flat)](https://travis-ci.org/wooorm/collapse-white-space) [![Coverage Status](https://img.shields.io/coveralls/wooorm/collapse-white-space.svg?style=flat)](https://coveralls.io/r/wooorm/collapse-white-space?branch=master) + +Replace multiple white-space characters with a single space. + +## Installation + +[npm](https://docs.npmjs.com/cli/install): + +```bash +npm install collapse-white-space +``` + +**collapse-white-space** is also available for [bower](http://bower.io/#install-packages), +[component](https://github.com/componentjs/component), [duo](http://duojs.org/#getting-started), +and for AMD, CommonJS, and globals ([uncompressed](collapse-white-space.js) and +[compressed](collapse-white-space.min.js)). + +## Usage + +Dependencies. + +```javascript +var collapse = require('collapse-white-space'); +``` + +Collapse white space: + +```javascript +var result = collapse('\tfoo \n\tbar \t\r\nbaz'); +``` + +Yields: + +```text + foo bar baz +``` + +## API + +### collapse(value) + +Replace multiple white-space characters with a single space. + +Parameters: + +* `value` (`string`) — Value with uncollapsed white-space, coerced to string. + +Returns: `string` — Value with collapsed white-space. + +## License + +[MIT](LICENSE) @ [Titus Wormer](http://wooorm.com) diff --git a/tools/node_modules/commander/History.md b/tools/node_modules/commander/History.md new file mode 100644 index 00000000000000..1b47439cbe54a6 --- /dev/null +++ b/tools/node_modules/commander/History.md @@ -0,0 +1,261 @@ + +2.9.0 / 2015-10-13 +================== + + * Add option `isDefault` to set default subcommand #415 @Qix- + * Add callback to allow filtering or post-processing of help text #434 @djulien + * Fix `undefined` text in help information close #414 #416 @zhiyelee + +2.8.1 / 2015-04-22 +================== + + * Back out `support multiline description` Close #396 #397 + +2.8.0 / 2015-04-07 +================== + + * Add `process.execArg` support, execution args like `--harmony` will be passed to sub-commands #387 @DigitalIO @zhiyelee + * Fix bug in Git-style sub-commands #372 @zhiyelee + * Allow commands to be hidden from help #383 @tonylukasavage + * When git-style sub-commands are in use, yet none are called, display help #382 @claylo + * Add ability to specify arguments syntax for top-level command #258 @rrthomas + * Support multiline descriptions #208 @zxqfox + +2.7.1 / 2015-03-11 +================== + + * Revert #347 (fix collisions when option and first arg have same name) which causes a bug in #367. + +2.7.0 / 2015-03-09 +================== + + * Fix git-style bug when installed globally. Close #335 #349 @zhiyelee + * Fix collisions when option and first arg have same name. Close #346 #347 @tonylukasavage + * Add support for camelCase on `opts()`. Close #353 @nkzawa + * Add node.js 0.12 and io.js to travis.yml + * Allow RegEx options. #337 @palanik + * Fixes exit code when sub-command failing. Close #260 #332 @pirelenito + * git-style `bin` files in $PATH make sense. Close #196 #327 @zhiyelee + +2.6.0 / 2014-12-30 +================== + + * added `Command#allowUnknownOption` method. Close #138 #318 @doozr @zhiyelee + * Add application description to the help msg. Close #112 @dalssoft + +2.5.1 / 2014-12-15 +================== + + * fixed two bugs incurred by variadic arguments. Close #291 @Quentin01 #302 @zhiyelee + +2.5.0 / 2014-10-24 +================== + + * add support for variadic arguments. Closes #277 @whitlockjc + +2.4.0 / 2014-10-17 +================== + + * fixed a bug on executing the coercion function of subcommands option. Closes #270 + * added `Command.prototype.name` to retrieve command name. Closes #264 #266 @tonylukasavage + * added `Command.prototype.opts` to retrieve all the options as a simple object of key-value pairs. Closes #262 @tonylukasavage + * fixed a bug on subcommand name. Closes #248 @jonathandelgado + * fixed function normalize doesn’t honor option terminator. Closes #216 @abbr + +2.3.0 / 2014-07-16 +================== + + * add command alias'. Closes PR #210 + * fix: Typos. Closes #99 + * fix: Unused fs module. Closes #217 + +2.2.0 / 2014-03-29 +================== + + * add passing of previous option value + * fix: support subcommands on windows. Closes #142 + * Now the defaultValue passed as the second argument of the coercion function. + +2.1.0 / 2013-11-21 +================== + + * add: allow cflag style option params, unit test, fixes #174 + +2.0.0 / 2013-07-18 +================== + + * remove input methods (.prompt, .confirm, etc) + +1.3.2 / 2013-07-18 +================== + + * add support for sub-commands to co-exist with the original command + +1.3.1 / 2013-07-18 +================== + + * add quick .runningCommand hack so you can opt-out of other logic when running a sub command + +1.3.0 / 2013-07-09 +================== + + * add EACCES error handling + * fix sub-command --help + +1.2.0 / 2013-06-13 +================== + + * allow "-" hyphen as an option argument + * support for RegExp coercion + +1.1.1 / 2012-11-20 +================== + + * add more sub-command padding + * fix .usage() when args are present. Closes #106 + +1.1.0 / 2012-11-16 +================== + + * add git-style executable subcommand support. Closes #94 + +1.0.5 / 2012-10-09 +================== + + * fix `--name` clobbering. Closes #92 + * fix examples/help. Closes #89 + +1.0.4 / 2012-09-03 +================== + + * add `outputHelp()` method. + +1.0.3 / 2012-08-30 +================== + + * remove invalid .version() defaulting + +1.0.2 / 2012-08-24 +================== + + * add `--foo=bar` support [arv] + * fix password on node 0.8.8. Make backward compatible with 0.6 [focusaurus] + +1.0.1 / 2012-08-03 +================== + + * fix issue #56 + * fix tty.setRawMode(mode) was moved to tty.ReadStream#setRawMode() (i.e. process.stdin.setRawMode()) + +1.0.0 / 2012-07-05 +================== + + * add support for optional option descriptions + * add defaulting of `.version()` to package.json's version + +0.6.1 / 2012-06-01 +================== + + * Added: append (yes or no) on confirmation + * Added: allow node.js v0.7.x + +0.6.0 / 2012-04-10 +================== + + * Added `.prompt(obj, callback)` support. Closes #49 + * Added default support to .choose(). Closes #41 + * Fixed the choice example + +0.5.1 / 2011-12-20 +================== + + * Fixed `password()` for recent nodes. Closes #36 + +0.5.0 / 2011-12-04 +================== + + * Added sub-command option support [itay] + +0.4.3 / 2011-12-04 +================== + + * Fixed custom help ordering. Closes #32 + +0.4.2 / 2011-11-24 +================== + + * Added travis support + * Fixed: line-buffered input automatically trimmed. Closes #31 + +0.4.1 / 2011-11-18 +================== + + * Removed listening for "close" on --help + +0.4.0 / 2011-11-15 +================== + + * Added support for `--`. Closes #24 + +0.3.3 / 2011-11-14 +================== + + * Fixed: wait for close event when writing help info [Jerry Hamlet] + +0.3.2 / 2011-11-01 +================== + + * Fixed long flag definitions with values [felixge] + +0.3.1 / 2011-10-31 +================== + + * Changed `--version` short flag to `-V` from `-v` + * Changed `.version()` so it's configurable [felixge] + +0.3.0 / 2011-10-31 +================== + + * Added support for long flags only. Closes #18 + +0.2.1 / 2011-10-24 +================== + + * "node": ">= 0.4.x < 0.7.0". Closes #20 + +0.2.0 / 2011-09-26 +================== + + * Allow for defaults that are not just boolean. Default peassignment only occurs for --no-*, optional, and required arguments. [Jim Isaacs] + +0.1.0 / 2011-08-24 +================== + + * Added support for custom `--help` output + +0.0.5 / 2011-08-18 +================== + + * Changed: when the user enters nothing prompt for password again + * Fixed issue with passwords beginning with numbers [NuckChorris] + +0.0.4 / 2011-08-15 +================== + + * Fixed `Commander#args` + +0.0.3 / 2011-08-15 +================== + + * Added default option value support + +0.0.2 / 2011-08-15 +================== + + * Added mask support to `Command#password(str[, mask], fn)` + * Added `Command#password(str, fn)` + +0.0.1 / 2010-01-03 +================== + + * Initial release diff --git a/tools/node_modules/commander/LICENSE b/tools/node_modules/commander/LICENSE new file mode 100644 index 00000000000000..10f997ab104594 --- /dev/null +++ b/tools/node_modules/commander/LICENSE @@ -0,0 +1,22 @@ +(The MIT License) + +Copyright (c) 2011 TJ Holowaychuk + +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. diff --git a/tools/node_modules/commander/Readme.md b/tools/node_modules/commander/Readme.md new file mode 100644 index 00000000000000..08b9e4cb94ab58 --- /dev/null +++ b/tools/node_modules/commander/Readme.md @@ -0,0 +1,351 @@ +# Commander.js + + +[![Build Status](https://api.travis-ci.org/tj/commander.js.svg)](http://travis-ci.org/tj/commander.js) +[![NPM Version](http://img.shields.io/npm/v/commander.svg?style=flat)](https://www.npmjs.org/package/commander) +[![NPM Downloads](https://img.shields.io/npm/dm/commander.svg?style=flat)](https://www.npmjs.org/package/commander) +[![Join the chat at https://gitter.im/tj/commander.js](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/tj/commander.js?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) + + The complete solution for [node.js](http://nodejs.org) command-line interfaces, inspired by Ruby's [commander](https://github.com/tj/commander). + [API documentation](http://tj.github.com/commander.js/) + + +## Installation + + $ npm install commander + +## Option parsing + + Options with commander are defined with the `.option()` method, also serving as documentation for the options. The example below parses args and options from `process.argv`, leaving remaining args as the `program.args` array which were not consumed by options. + +```js +#!/usr/bin/env node + +/** + * Module dependencies. + */ + +var program = require('commander'); + +program + .version('0.0.1') + .option('-p, --peppers', 'Add peppers') + .option('-P, --pineapple', 'Add pineapple') + .option('-b, --bbq-sauce', 'Add bbq sauce') + .option('-c, --cheese [type]', 'Add the specified type of cheese [marble]', 'marble') + .parse(process.argv); + +console.log('you ordered a pizza with:'); +if (program.peppers) console.log(' - peppers'); +if (program.pineapple) console.log(' - pineapple'); +if (program.bbqSauce) console.log(' - bbq'); +console.log(' - %s cheese', program.cheese); +``` + + Short flags may be passed as a single arg, for example `-abc` is equivalent to `-a -b -c`. Multi-word options such as "--template-engine" are camel-cased, becoming `program.templateEngine` etc. + + +## Coercion + +```js +function range(val) { + return val.split('..').map(Number); +} + +function list(val) { + return val.split(','); +} + +function collect(val, memo) { + memo.push(val); + return memo; +} + +function increaseVerbosity(v, total) { + return total + 1; +} + +program + .version('0.0.1') + .usage('[options] ') + .option('-i, --integer ', 'An integer argument', parseInt) + .option('-f, --float ', 'A float argument', parseFloat) + .option('-r, --range ..', 'A range', range) + .option('-l, --list ', 'A list', list) + .option('-o, --optional [value]', 'An optional value') + .option('-c, --collect [value]', 'A repeatable value', collect, []) + .option('-v, --verbose', 'A value that can be increased', increaseVerbosity, 0) + .parse(process.argv); + +console.log(' int: %j', program.integer); +console.log(' float: %j', program.float); +console.log(' optional: %j', program.optional); +program.range = program.range || []; +console.log(' range: %j..%j', program.range[0], program.range[1]); +console.log(' list: %j', program.list); +console.log(' collect: %j', program.collect); +console.log(' verbosity: %j', program.verbose); +console.log(' args: %j', program.args); +``` + +## Regular Expression +```js +program + .version('0.0.1') + .option('-s --size ', 'Pizza size', /^(large|medium|small)$/i, 'medium') + .option('-d --drink [drink]', 'Drink', /^(coke|pepsi|izze)$/i) + .parse(process.argv); + +console.log(' size: %j', program.size); +console.log(' drink: %j', program.drink); +``` + +## Variadic arguments + + The last argument of a command can be variadic, and only the last argument. To make an argument variadic you have to + append `...` to the argument name. Here is an example: + +```js +#!/usr/bin/env node + +/** + * Module dependencies. + */ + +var program = require('commander'); + +program + .version('0.0.1') + .command('rmdir [otherDirs...]') + .action(function (dir, otherDirs) { + console.log('rmdir %s', dir); + if (otherDirs) { + otherDirs.forEach(function (oDir) { + console.log('rmdir %s', oDir); + }); + } + }); + +program.parse(process.argv); +``` + + An `Array` is used for the value of a variadic argument. This applies to `program.args` as well as the argument passed + to your action as demonstrated above. + +## Specify the argument syntax + +```js +#!/usr/bin/env node + +var program = require('../'); + +program + .version('0.0.1') + .arguments(' [env]') + .action(function (cmd, env) { + cmdValue = cmd; + envValue = env; + }); + +program.parse(process.argv); + +if (typeof cmdValue === 'undefined') { + console.error('no command given!'); + process.exit(1); +} +console.log('command:', cmdValue); +console.log('environment:', envValue || "no environment given"); +``` + +## Git-style sub-commands + +```js +// file: ./examples/pm +var program = require('..'); + +program + .version('0.0.1') + .command('install [name]', 'install one or more packages') + .command('search [query]', 'search with optional query') + .command('list', 'list packages installed', {isDefault: true}) + .parse(process.argv); +``` + +When `.command()` is invoked with a description argument, no `.action(callback)` should be called to handle sub-commands, otherwise there will be an error. This tells commander that you're going to use separate executables for sub-commands, much like `git(1)` and other popular tools. +The commander will try to search the executables in the directory of the entry script (like `./examples/pm`) with the name `program-command`, like `pm-install`, `pm-search`. + +Options can be passed with the call to `.command()`. Specifying `true` for `opts.noHelp` will remove the option from the generated help output. Specifying `true` for `opts.isDefault` will run the subcommand if no other subcommand is specified. + +If the program is designed to be installed globally, make sure the executables have proper modes, like `755`. + +### `--harmony` + +You can enable `--harmony` option in two ways: +* Use `#! /usr/bin/env node --harmony` in the sub-commands scripts. Note some os version don’t support this pattern. +* Use the `--harmony` option when call the command, like `node --harmony examples/pm publish`. The `--harmony` option will be preserved when spawning sub-command process. + +## Automated --help + + The help information is auto-generated based on the information commander already knows about your program, so the following `--help` info is for free: + +``` + $ ./examples/pizza --help + + Usage: pizza [options] + + An application for pizzas ordering + + Options: + + -h, --help output usage information + -V, --version output the version number + -p, --peppers Add peppers + -P, --pineapple Add pineapple + -b, --bbq Add bbq sauce + -c, --cheese Add the specified type of cheese [marble] + -C, --no-cheese You do not want any cheese + +``` + +## Custom help + + You can display arbitrary `-h, --help` information + by listening for "--help". Commander will automatically + exit once you are done so that the remainder of your program + does not execute causing undesired behaviours, for example + in the following executable "stuff" will not output when + `--help` is used. + +```js +#!/usr/bin/env node + +/** + * Module dependencies. + */ + +var program = require('commander'); + +program + .version('0.0.1') + .option('-f, --foo', 'enable some foo') + .option('-b, --bar', 'enable some bar') + .option('-B, --baz', 'enable some baz'); + +// must be before .parse() since +// node's emit() is immediate + +program.on('--help', function(){ + console.log(' Examples:'); + console.log(''); + console.log(' $ custom-help --help'); + console.log(' $ custom-help -h'); + console.log(''); +}); + +program.parse(process.argv); + +console.log('stuff'); +``` + +Yields the following help output when `node script-name.js -h` or `node script-name.js --help` are run: + +``` + +Usage: custom-help [options] + +Options: + + -h, --help output usage information + -V, --version output the version number + -f, --foo enable some foo + -b, --bar enable some bar + -B, --baz enable some baz + +Examples: + + $ custom-help --help + $ custom-help -h + +``` + +## .outputHelp(cb) + +Output help information without exiting. +Optional callback cb allows post-processing of help text before it is displayed. + +If you want to display help by default (e.g. if no command was provided), you can use something like: + +```js +var program = require('commander'); +var colors = require('colors'); + +program + .version('0.0.1') + .command('getstream [url]', 'get stream URL') + .parse(process.argv); + + if (!process.argv.slice(2).length) { + program.outputHelp(make_red); + } + +function make_red(txt) { + return colors.red(txt); //display the help text in red on the console +} +``` + +## .help(cb) + + Output help information and exit immediately. + Optional callback cb allows post-processing of help text before it is displayed. + +## Examples + +```js +var program = require('commander'); + +program + .version('0.0.1') + .option('-C, --chdir ', 'change the working directory') + .option('-c, --config ', 'set config path. defaults to ./deploy.conf') + .option('-T, --no-tests', 'ignore test hook') + +program + .command('setup [env]') + .description('run setup commands for all envs') + .option("-s, --setup_mode [mode]", "Which setup mode to use") + .action(function(env, options){ + var mode = options.setup_mode || "normal"; + env = env || 'all'; + console.log('setup for %s env(s) with %s mode', env, mode); + }); + +program + .command('exec ') + .alias('ex') + .description('execute the given remote cmd') + .option("-e, --exec_mode ", "Which exec mode to use") + .action(function(cmd, options){ + console.log('exec "%s" using %s mode', cmd, options.exec_mode); + }).on('--help', function() { + console.log(' Examples:'); + console.log(); + console.log(' $ deploy exec sequential'); + console.log(' $ deploy exec async'); + console.log(); + }); + +program + .command('*') + .action(function(env){ + console.log('deploying "%s"', env); + }); + +program.parse(process.argv); +``` + +More Demos can be found in the [examples](https://github.com/tj/commander.js/tree/master/examples) directory. + +## License + +MIT + diff --git a/tools/node_modules/commander/index.js b/tools/node_modules/commander/index.js new file mode 100644 index 00000000000000..a19c05d2e3dd91 --- /dev/null +++ b/tools/node_modules/commander/index.js @@ -0,0 +1,1110 @@ +/** + * Module dependencies. + */ + +var EventEmitter = require('events').EventEmitter; +var spawn = require('child_process').spawn; +var readlink = require('graceful-readlink').readlinkSync; +var path = require('path'); +var dirname = path.dirname; +var basename = path.basename; +var fs = require('fs'); + +/** + * Expose the root command. + */ + +exports = module.exports = new Command(); + +/** + * Expose `Command`. + */ + +exports.Command = Command; + +/** + * Expose `Option`. + */ + +exports.Option = Option; + +/** + * Initialize a new `Option` with the given `flags` and `description`. + * + * @param {String} flags + * @param {String} description + * @api public + */ + +function Option(flags, description) { + this.flags = flags; + this.required = ~flags.indexOf('<'); + this.optional = ~flags.indexOf('['); + this.bool = !~flags.indexOf('-no-'); + flags = flags.split(/[ ,|]+/); + if (flags.length > 1 && !/^[[<]/.test(flags[1])) this.short = flags.shift(); + this.long = flags.shift(); + this.description = description || ''; +} + +/** + * Return option name. + * + * @return {String} + * @api private + */ + +Option.prototype.name = function() { + return this.long + .replace('--', '') + .replace('no-', ''); +}; + +/** + * Check if `arg` matches the short or long flag. + * + * @param {String} arg + * @return {Boolean} + * @api private + */ + +Option.prototype.is = function(arg) { + return arg == this.short || arg == this.long; +}; + +/** + * Initialize a new `Command`. + * + * @param {String} name + * @api public + */ + +function Command(name) { + this.commands = []; + this.options = []; + this._execs = {}; + this._allowUnknownOption = false; + this._args = []; + this._name = name || ''; +} + +/** + * Inherit from `EventEmitter.prototype`. + */ + +Command.prototype.__proto__ = EventEmitter.prototype; + +/** + * Add command `name`. + * + * The `.action()` callback is invoked when the + * command `name` is specified via __ARGV__, + * and the remaining arguments are applied to the + * function for access. + * + * When the `name` is "*" an un-matched command + * will be passed as the first arg, followed by + * the rest of __ARGV__ remaining. + * + * Examples: + * + * program + * .version('0.0.1') + * .option('-C, --chdir ', 'change the working directory') + * .option('-c, --config ', 'set config path. defaults to ./deploy.conf') + * .option('-T, --no-tests', 'ignore test hook') + * + * program + * .command('setup') + * .description('run remote setup commands') + * .action(function() { + * console.log('setup'); + * }); + * + * program + * .command('exec ') + * .description('run the given remote command') + * .action(function(cmd) { + * console.log('exec "%s"', cmd); + * }); + * + * program + * .command('teardown [otherDirs...]') + * .description('run teardown commands') + * .action(function(dir, otherDirs) { + * console.log('dir "%s"', dir); + * if (otherDirs) { + * otherDirs.forEach(function (oDir) { + * console.log('dir "%s"', oDir); + * }); + * } + * }); + * + * program + * .command('*') + * .description('deploy the given env') + * .action(function(env) { + * console.log('deploying "%s"', env); + * }); + * + * program.parse(process.argv); + * + * @param {String} name + * @param {String} [desc] for git-style sub-commands + * @return {Command} the new command + * @api public + */ + +Command.prototype.command = function(name, desc, opts) { + opts = opts || {}; + var args = name.split(/ +/); + var cmd = new Command(args.shift()); + + if (desc) { + cmd.description(desc); + this.executables = true; + this._execs[cmd._name] = true; + if (opts.isDefault) this.defaultExecutable = cmd._name; + } + + cmd._noHelp = !!opts.noHelp; + this.commands.push(cmd); + cmd.parseExpectedArgs(args); + cmd.parent = this; + + if (desc) return this; + return cmd; +}; + +/** + * Define argument syntax for the top-level command. + * + * @api public + */ + +Command.prototype.arguments = function (desc) { + return this.parseExpectedArgs(desc.split(/ +/)); +}; + +/** + * Add an implicit `help [cmd]` subcommand + * which invokes `--help` for the given command. + * + * @api private + */ + +Command.prototype.addImplicitHelpCommand = function() { + this.command('help [cmd]', 'display help for [cmd]'); +}; + +/** + * Parse expected `args`. + * + * For example `["[type]"]` becomes `[{ required: false, name: 'type' }]`. + * + * @param {Array} args + * @return {Command} for chaining + * @api public + */ + +Command.prototype.parseExpectedArgs = function(args) { + if (!args.length) return; + var self = this; + args.forEach(function(arg) { + var argDetails = { + required: false, + name: '', + variadic: false + }; + + switch (arg[0]) { + case '<': + argDetails.required = true; + argDetails.name = arg.slice(1, -1); + break; + case '[': + argDetails.name = arg.slice(1, -1); + break; + } + + if (argDetails.name.length > 3 && argDetails.name.slice(-3) === '...') { + argDetails.variadic = true; + argDetails.name = argDetails.name.slice(0, -3); + } + if (argDetails.name) { + self._args.push(argDetails); + } + }); + return this; +}; + +/** + * Register callback `fn` for the command. + * + * Examples: + * + * program + * .command('help') + * .description('display verbose help') + * .action(function() { + * // output help here + * }); + * + * @param {Function} fn + * @return {Command} for chaining + * @api public + */ + +Command.prototype.action = function(fn) { + var self = this; + var listener = function(args, unknown) { + // Parse any so-far unknown options + args = args || []; + unknown = unknown || []; + + var parsed = self.parseOptions(unknown); + + // Output help if necessary + outputHelpIfNecessary(self, parsed.unknown); + + // If there are still any unknown options, then we simply + // die, unless someone asked for help, in which case we give it + // to them, and then we die. + if (parsed.unknown.length > 0) { + self.unknownOption(parsed.unknown[0]); + } + + // Leftover arguments need to be pushed back. Fixes issue #56 + if (parsed.args.length) args = parsed.args.concat(args); + + self._args.forEach(function(arg, i) { + if (arg.required && null == args[i]) { + self.missingArgument(arg.name); + } else if (arg.variadic) { + if (i !== self._args.length - 1) { + self.variadicArgNotLast(arg.name); + } + + args[i] = args.splice(i); + } + }); + + // Always append ourselves to the end of the arguments, + // to make sure we match the number of arguments the user + // expects + if (self._args.length) { + args[self._args.length] = self; + } else { + args.push(self); + } + + fn.apply(self, args); + }; + var parent = this.parent || this; + var name = parent === this ? '*' : this._name; + parent.on(name, listener); + if (this._alias) parent.on(this._alias, listener); + return this; +}; + +/** + * Define option with `flags`, `description` and optional + * coercion `fn`. + * + * The `flags` string should contain both the short and long flags, + * separated by comma, a pipe or space. The following are all valid + * all will output this way when `--help` is used. + * + * "-p, --pepper" + * "-p|--pepper" + * "-p --pepper" + * + * Examples: + * + * // simple boolean defaulting to false + * program.option('-p, --pepper', 'add pepper'); + * + * --pepper + * program.pepper + * // => Boolean + * + * // simple boolean defaulting to true + * program.option('-C, --no-cheese', 'remove cheese'); + * + * program.cheese + * // => true + * + * --no-cheese + * program.cheese + * // => false + * + * // required argument + * program.option('-C, --chdir ', 'change the working directory'); + * + * --chdir /tmp + * program.chdir + * // => "/tmp" + * + * // optional argument + * program.option('-c, --cheese [type]', 'add cheese [marble]'); + * + * @param {String} flags + * @param {String} description + * @param {Function|Mixed} fn or default + * @param {Mixed} defaultValue + * @return {Command} for chaining + * @api public + */ + +Command.prototype.option = function(flags, description, fn, defaultValue) { + var self = this + , option = new Option(flags, description) + , oname = option.name() + , name = camelcase(oname); + + // default as 3rd arg + if (typeof fn != 'function') { + if (fn instanceof RegExp) { + var regex = fn; + fn = function(val, def) { + var m = regex.exec(val); + return m ? m[0] : def; + } + } + else { + defaultValue = fn; + fn = null; + } + } + + // preassign default value only for --no-*, [optional], or + if (false == option.bool || option.optional || option.required) { + // when --no-* we make sure default is true + if (false == option.bool) defaultValue = true; + // preassign only if we have a default + if (undefined !== defaultValue) self[name] = defaultValue; + } + + // register the option + this.options.push(option); + + // when it's passed assign the value + // and conditionally invoke the callback + this.on(oname, function(val) { + // coercion + if (null !== val && fn) val = fn(val, undefined === self[name] + ? defaultValue + : self[name]); + + // unassigned or bool + if ('boolean' == typeof self[name] || 'undefined' == typeof self[name]) { + // if no value, bool true, and we have a default, then use it! + if (null == val) { + self[name] = option.bool + ? defaultValue || true + : false; + } else { + self[name] = val; + } + } else if (null !== val) { + // reassign + self[name] = val; + } + }); + + return this; +}; + +/** + * Allow unknown options on the command line. + * + * @param {Boolean} arg if `true` or omitted, no error will be thrown + * for unknown options. + * @api public + */ +Command.prototype.allowUnknownOption = function(arg) { + this._allowUnknownOption = arguments.length === 0 || arg; + return this; +}; + +/** + * Parse `argv`, settings options and invoking commands when defined. + * + * @param {Array} argv + * @return {Command} for chaining + * @api public + */ + +Command.prototype.parse = function(argv) { + // implicit help + if (this.executables) this.addImplicitHelpCommand(); + + // store raw args + this.rawArgs = argv; + + // guess name + this._name = this._name || basename(argv[1], '.js'); + + // github-style sub-commands with no sub-command + if (this.executables && argv.length < 3 && !this.defaultExecutable) { + // this user needs help + argv.push('--help'); + } + + // process argv + var parsed = this.parseOptions(this.normalize(argv.slice(2))); + var args = this.args = parsed.args; + + var result = this.parseArgs(this.args, parsed.unknown); + + // executable sub-commands + var name = result.args[0]; + if (this._execs[name] && typeof this._execs[name] != "function") { + return this.executeSubCommand(argv, args, parsed.unknown); + } else if (this.defaultExecutable) { + // use the default subcommand + args.unshift(name = this.defaultExecutable); + return this.executeSubCommand(argv, args, parsed.unknown); + } + + return result; +}; + +/** + * Execute a sub-command executable. + * + * @param {Array} argv + * @param {Array} args + * @param {Array} unknown + * @api private + */ + +Command.prototype.executeSubCommand = function(argv, args, unknown) { + args = args.concat(unknown); + + if (!args.length) this.help(); + if ('help' == args[0] && 1 == args.length) this.help(); + + // --help + if ('help' == args[0]) { + args[0] = args[1]; + args[1] = '--help'; + } + + // executable + var f = argv[1]; + // name of the subcommand, link `pm-install` + var bin = basename(f, '.js') + '-' + args[0]; + + + // In case of globally installed, get the base dir where executable + // subcommand file should be located at + var baseDir + , link = readlink(f); + + // when symbolink is relative path + if (link !== f && link.charAt(0) !== '/') { + link = path.join(dirname(f), link) + } + baseDir = dirname(link); + + // prefer local `./` to bin in the $PATH + var localBin = path.join(baseDir, bin); + + // whether bin file is a js script with explicit `.js` extension + var isExplicitJS = false; + if (exists(localBin + '.js')) { + bin = localBin + '.js'; + isExplicitJS = true; + } else if (exists(localBin)) { + bin = localBin; + } + + args = args.slice(1); + + var proc; + if (process.platform !== 'win32') { + if (isExplicitJS) { + args.unshift(localBin); + // add executable arguments to spawn + args = (process.execArgv || []).concat(args); + + proc = spawn('node', args, { stdio: 'inherit', customFds: [0, 1, 2] }); + } else { + proc = spawn(bin, args, { stdio: 'inherit', customFds: [0, 1, 2] }); + } + } else { + args.unshift(localBin); + proc = spawn(process.execPath, args, { stdio: 'inherit'}); + } + + proc.on('close', process.exit.bind(process)); + proc.on('error', function(err) { + if (err.code == "ENOENT") { + console.error('\n %s(1) does not exist, try --help\n', bin); + } else if (err.code == "EACCES") { + console.error('\n %s(1) not executable. try chmod or run with root\n', bin); + } + process.exit(1); + }); + + // Store the reference to the child process + this.runningCommand = proc; +}; + +/** + * Normalize `args`, splitting joined short flags. For example + * the arg "-abc" is equivalent to "-a -b -c". + * This also normalizes equal sign and splits "--abc=def" into "--abc def". + * + * @param {Array} args + * @return {Array} + * @api private + */ + +Command.prototype.normalize = function(args) { + var ret = [] + , arg + , lastOpt + , index; + + for (var i = 0, len = args.length; i < len; ++i) { + arg = args[i]; + if (i > 0) { + lastOpt = this.optionFor(args[i-1]); + } + + if (arg === '--') { + // Honor option terminator + ret = ret.concat(args.slice(i)); + break; + } else if (lastOpt && lastOpt.required) { + ret.push(arg); + } else if (arg.length > 1 && '-' == arg[0] && '-' != arg[1]) { + arg.slice(1).split('').forEach(function(c) { + ret.push('-' + c); + }); + } else if (/^--/.test(arg) && ~(index = arg.indexOf('='))) { + ret.push(arg.slice(0, index), arg.slice(index + 1)); + } else { + ret.push(arg); + } + } + + return ret; +}; + +/** + * Parse command `args`. + * + * When listener(s) are available those + * callbacks are invoked, otherwise the "*" + * event is emitted and those actions are invoked. + * + * @param {Array} args + * @return {Command} for chaining + * @api private + */ + +Command.prototype.parseArgs = function(args, unknown) { + var name; + + if (args.length) { + name = args[0]; + if (this.listeners(name).length) { + this.emit(args.shift(), args, unknown); + } else { + this.emit('*', args); + } + } else { + outputHelpIfNecessary(this, unknown); + + // If there were no args and we have unknown options, + // then they are extraneous and we need to error. + if (unknown.length > 0) { + this.unknownOption(unknown[0]); + } + } + + return this; +}; + +/** + * Return an option matching `arg` if any. + * + * @param {String} arg + * @return {Option} + * @api private + */ + +Command.prototype.optionFor = function(arg) { + for (var i = 0, len = this.options.length; i < len; ++i) { + if (this.options[i].is(arg)) { + return this.options[i]; + } + } +}; + +/** + * Parse options from `argv` returning `argv` + * void of these options. + * + * @param {Array} argv + * @return {Array} + * @api public + */ + +Command.prototype.parseOptions = function(argv) { + var args = [] + , len = argv.length + , literal + , option + , arg; + + var unknownOptions = []; + + // parse options + for (var i = 0; i < len; ++i) { + arg = argv[i]; + + // literal args after -- + if ('--' == arg) { + literal = true; + continue; + } + + if (literal) { + args.push(arg); + continue; + } + + // find matching Option + option = this.optionFor(arg); + + // option is defined + if (option) { + // requires arg + if (option.required) { + arg = argv[++i]; + if (null == arg) return this.optionMissingArgument(option); + this.emit(option.name(), arg); + // optional arg + } else if (option.optional) { + arg = argv[i+1]; + if (null == arg || ('-' == arg[0] && '-' != arg)) { + arg = null; + } else { + ++i; + } + this.emit(option.name(), arg); + // bool + } else { + this.emit(option.name()); + } + continue; + } + + // looks like an option + if (arg.length > 1 && '-' == arg[0]) { + unknownOptions.push(arg); + + // If the next argument looks like it might be + // an argument for this option, we pass it on. + // If it isn't, then it'll simply be ignored + if (argv[i+1] && '-' != argv[i+1][0]) { + unknownOptions.push(argv[++i]); + } + continue; + } + + // arg + args.push(arg); + } + + return { args: args, unknown: unknownOptions }; +}; + +/** + * Return an object containing options as key-value pairs + * + * @return {Object} + * @api public + */ +Command.prototype.opts = function() { + var result = {} + , len = this.options.length; + + for (var i = 0 ; i < len; i++) { + var key = camelcase(this.options[i].name()); + result[key] = key === 'version' ? this._version : this[key]; + } + return result; +}; + +/** + * Argument `name` is missing. + * + * @param {String} name + * @api private + */ + +Command.prototype.missingArgument = function(name) { + console.error(); + console.error(" error: missing required argument `%s'", name); + console.error(); + process.exit(1); +}; + +/** + * `Option` is missing an argument, but received `flag` or nothing. + * + * @param {String} option + * @param {String} flag + * @api private + */ + +Command.prototype.optionMissingArgument = function(option, flag) { + console.error(); + if (flag) { + console.error(" error: option `%s' argument missing, got `%s'", option.flags, flag); + } else { + console.error(" error: option `%s' argument missing", option.flags); + } + console.error(); + process.exit(1); +}; + +/** + * Unknown option `flag`. + * + * @param {String} flag + * @api private + */ + +Command.prototype.unknownOption = function(flag) { + if (this._allowUnknownOption) return; + console.error(); + console.error(" error: unknown option `%s'", flag); + console.error(); + process.exit(1); +}; + +/** + * Variadic argument with `name` is not the last argument as required. + * + * @param {String} name + * @api private + */ + +Command.prototype.variadicArgNotLast = function(name) { + console.error(); + console.error(" error: variadic arguments must be last `%s'", name); + console.error(); + process.exit(1); +}; + +/** + * Set the program version to `str`. + * + * This method auto-registers the "-V, --version" flag + * which will print the version number when passed. + * + * @param {String} str + * @param {String} flags + * @return {Command} for chaining + * @api public + */ + +Command.prototype.version = function(str, flags) { + if (0 == arguments.length) return this._version; + this._version = str; + flags = flags || '-V, --version'; + this.option(flags, 'output the version number'); + this.on('version', function() { + process.stdout.write(str + '\n'); + process.exit(0); + }); + return this; +}; + +/** + * Set the description to `str`. + * + * @param {String} str + * @return {String|Command} + * @api public + */ + +Command.prototype.description = function(str) { + if (0 === arguments.length) return this._description; + this._description = str; + return this; +}; + +/** + * Set an alias for the command + * + * @param {String} alias + * @return {String|Command} + * @api public + */ + +Command.prototype.alias = function(alias) { + if (0 == arguments.length) return this._alias; + this._alias = alias; + return this; +}; + +/** + * Set / get the command usage `str`. + * + * @param {String} str + * @return {String|Command} + * @api public + */ + +Command.prototype.usage = function(str) { + var args = this._args.map(function(arg) { + return humanReadableArgName(arg); + }); + + var usage = '[options]' + + (this.commands.length ? ' [command]' : '') + + (this._args.length ? ' ' + args.join(' ') : ''); + + if (0 == arguments.length) return this._usage || usage; + this._usage = str; + + return this; +}; + +/** + * Get the name of the command + * + * @param {String} name + * @return {String|Command} + * @api public + */ + +Command.prototype.name = function() { + return this._name; +}; + +/** + * Return the largest option length. + * + * @return {Number} + * @api private + */ + +Command.prototype.largestOptionLength = function() { + return this.options.reduce(function(max, option) { + return Math.max(max, option.flags.length); + }, 0); +}; + +/** + * Return help for options. + * + * @return {String} + * @api private + */ + +Command.prototype.optionHelp = function() { + var width = this.largestOptionLength(); + + // Prepend the help information + return [pad('-h, --help', width) + ' ' + 'output usage information'] + .concat(this.options.map(function(option) { + return pad(option.flags, width) + ' ' + option.description; + })) + .join('\n'); +}; + +/** + * Return command help documentation. + * + * @return {String} + * @api private + */ + +Command.prototype.commandHelp = function() { + if (!this.commands.length) return ''; + + var commands = this.commands.filter(function(cmd) { + return !cmd._noHelp; + }).map(function(cmd) { + var args = cmd._args.map(function(arg) { + return humanReadableArgName(arg); + }).join(' '); + + return [ + cmd._name + + (cmd._alias ? '|' + cmd._alias : '') + + (cmd.options.length ? ' [options]' : '') + + ' ' + args + , cmd.description() + ]; + }); + + var width = commands.reduce(function(max, command) { + return Math.max(max, command[0].length); + }, 0); + + return [ + '' + , ' Commands:' + , '' + , commands.map(function(cmd) { + var desc = cmd[1] ? ' ' + cmd[1] : ''; + return pad(cmd[0], width) + desc; + }).join('\n').replace(/^/gm, ' ') + , '' + ].join('\n'); +}; + +/** + * Return program help documentation. + * + * @return {String} + * @api private + */ + +Command.prototype.helpInformation = function() { + var desc = []; + if (this._description) { + desc = [ + ' ' + this._description + , '' + ]; + } + + var cmdName = this._name; + if (this._alias) { + cmdName = cmdName + '|' + this._alias; + } + var usage = [ + '' + ,' Usage: ' + cmdName + ' ' + this.usage() + , '' + ]; + + var cmds = []; + var commandHelp = this.commandHelp(); + if (commandHelp) cmds = [commandHelp]; + + var options = [ + ' Options:' + , '' + , '' + this.optionHelp().replace(/^/gm, ' ') + , '' + , '' + ]; + + return usage + .concat(cmds) + .concat(desc) + .concat(options) + .join('\n'); +}; + +/** + * Output help information for this command + * + * @api public + */ + +Command.prototype.outputHelp = function(cb) { + if (!cb) { + cb = function(passthru) { + return passthru; + } + } + process.stdout.write(cb(this.helpInformation())); + this.emit('--help'); +}; + +/** + * Output help information and exit. + * + * @api public + */ + +Command.prototype.help = function(cb) { + this.outputHelp(cb); + process.exit(); +}; + +/** + * Camel-case the given `flag` + * + * @param {String} flag + * @return {String} + * @api private + */ + +function camelcase(flag) { + return flag.split('-').reduce(function(str, word) { + return str + word[0].toUpperCase() + word.slice(1); + }); +} + +/** + * Pad `str` to `width`. + * + * @param {String} str + * @param {Number} width + * @return {String} + * @api private + */ + +function pad(str, width) { + var len = Math.max(0, width - str.length); + return str + Array(len + 1).join(' '); +} + +/** + * Output help information if necessary + * + * @param {Command} command to output help for + * @param {Array} array of options to search for -h or --help + * @api private + */ + +function outputHelpIfNecessary(cmd, options) { + options = options || []; + for (var i = 0; i < options.length; i++) { + if (options[i] == '--help' || options[i] == '-h') { + cmd.outputHelp(); + process.exit(0); + } + } +} + +/** + * Takes an argument an returns its human readable equivalent for help usage. + * + * @param {Object} arg + * @return {String} + * @api private + */ + +function humanReadableArgName(arg) { + var nameOutput = arg.name + (arg.variadic === true ? '...' : ''); + + return arg.required + ? '<' + nameOutput + '>' + : '[' + nameOutput + ']' +} + +// for versions before node v0.8 when there weren't `fs.existsSync` +function exists(file) { + try { + if (fs.statSync(file).isFile()) { + return true; + } + } catch (e) { + return false; + } +} + diff --git a/tools/node_modules/commander/package.json b/tools/node_modules/commander/package.json new file mode 100644 index 00000000000000..3476a20c10e22c --- /dev/null +++ b/tools/node_modules/commander/package.json @@ -0,0 +1,95 @@ +{ + "_args": [ + [ + "commander@^2.0.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\remark" + ] + ], + "_from": "commander@>=2.0.0 <3.0.0", + "_id": "commander@2.9.0", + "_inCache": true, + "_location": "/commander", + "_nodeVersion": "0.12.7", + "_npmUser": { + "email": "zhiyelee@gmail.com", + "name": "zhiyelee" + }, + "_npmVersion": "2.11.3", + "_phantomChildren": {}, + "_requested": { + "name": "commander", + "raw": "commander@^2.0.0", + "rawSpec": "^2.0.0", + "scope": null, + "spec": ">=2.0.0 <3.0.0", + "type": "range" + }, + "_requiredBy": [ + "/remark" + ], + "_resolved": "https://registry.npmjs.org/commander/-/commander-2.9.0.tgz", + "_shasum": "9c99094176e12240cb22d6c5146098400fe0f7d4", + "_shrinkwrap": null, + "_spec": "commander@^2.0.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\remark", + "author": { + "email": "tj@vision-media.ca", + "name": "TJ Holowaychuk" + }, + "bugs": { + "url": "https://github.com/tj/commander.js/issues" + }, + "dependencies": { + "graceful-readlink": ">= 1.0.0" + }, + "description": "the complete solution for node.js command-line programs", + "devDependencies": { + "should": ">= 0.0.1", + "sinon": ">=1.17.1" + }, + "directories": {}, + "dist": { + "shasum": "9c99094176e12240cb22d6c5146098400fe0f7d4", + "tarball": "http://registry.npmjs.org/commander/-/commander-2.9.0.tgz" + }, + "engines": { + "node": ">= 0.6.x" + }, + "files": [ + "index.js" + ], + "gitHead": "b2aad7a8471d434593a85306aa73777a526e9f75", + "homepage": "https://github.com/tj/commander.js#readme", + "installable": true, + "keywords": [ + "command", + "option", + "parser" + ], + "license": "MIT", + "main": "index", + "maintainers": [ + { + "name": "tjholowaychuk", + "email": "tj@vision-media.ca" + }, + { + "name": "somekittens", + "email": "rkoutnik@gmail.com" + }, + { + "name": "zhiyelee", + "email": "zhiyelee@gmail.com" + } + ], + "name": "commander", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git+https://github.com/tj/commander.js.git" + }, + "scripts": { + "test": "make test" + }, + "version": "2.9.0" +} diff --git a/tools/node_modules/concat-map/.travis.yml b/tools/node_modules/concat-map/.travis.yml new file mode 100644 index 00000000000000..f1d0f13c8a54d0 --- /dev/null +++ b/tools/node_modules/concat-map/.travis.yml @@ -0,0 +1,4 @@ +language: node_js +node_js: + - 0.4 + - 0.6 diff --git a/tools/node_modules/concat-map/LICENSE b/tools/node_modules/concat-map/LICENSE new file mode 100644 index 00000000000000..ee27ba4b4412b0 --- /dev/null +++ b/tools/node_modules/concat-map/LICENSE @@ -0,0 +1,18 @@ +This software is released under the MIT license: + +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. diff --git a/tools/node_modules/concat-map/README.markdown b/tools/node_modules/concat-map/README.markdown new file mode 100644 index 00000000000000..408f70a1be473c --- /dev/null +++ b/tools/node_modules/concat-map/README.markdown @@ -0,0 +1,62 @@ +concat-map +========== + +Concatenative mapdashery. + +[![browser support](http://ci.testling.com/substack/node-concat-map.png)](http://ci.testling.com/substack/node-concat-map) + +[![build status](https://secure.travis-ci.org/substack/node-concat-map.png)](http://travis-ci.org/substack/node-concat-map) + +example +======= + +``` js +var concatMap = require('concat-map'); +var xs = [ 1, 2, 3, 4, 5, 6 ]; +var ys = concatMap(xs, function (x) { + return x % 2 ? [ x - 0.1, x, x + 0.1 ] : []; +}); +console.dir(ys); +``` + +*** + +``` +[ 0.9, 1, 1.1, 2.9, 3, 3.1, 4.9, 5, 5.1 ] +``` + +methods +======= + +``` js +var concatMap = require('concat-map') +``` + +concatMap(xs, fn) +----------------- + +Return an array of concatenated elements by calling `fn(x, i)` for each element +`x` and each index `i` in the array `xs`. + +When `fn(x, i)` returns an array, its result will be concatenated with the +result array. If `fn(x, i)` returns anything else, that value will be pushed +onto the end of the result array. + +install +======= + +With [npm](http://npmjs.org) do: + +``` +npm install concat-map +``` + +license +======= + +MIT + +notes +===== + +This module was written while sitting high above the ground in a tree. diff --git a/tools/node_modules/concat-map/example/map.js b/tools/node_modules/concat-map/example/map.js new file mode 100644 index 00000000000000..33656217b61d8f --- /dev/null +++ b/tools/node_modules/concat-map/example/map.js @@ -0,0 +1,6 @@ +var concatMap = require('../'); +var xs = [ 1, 2, 3, 4, 5, 6 ]; +var ys = concatMap(xs, function (x) { + return x % 2 ? [ x - 0.1, x, x + 0.1 ] : []; +}); +console.dir(ys); diff --git a/tools/node_modules/concat-map/index.js b/tools/node_modules/concat-map/index.js new file mode 100644 index 00000000000000..b29a7812e5055a --- /dev/null +++ b/tools/node_modules/concat-map/index.js @@ -0,0 +1,13 @@ +module.exports = function (xs, fn) { + var res = []; + for (var i = 0; i < xs.length; i++) { + var x = fn(xs[i], i); + if (isArray(x)) res.push.apply(res, x); + else res.push(x); + } + return res; +}; + +var isArray = Array.isArray || function (xs) { + return Object.prototype.toString.call(xs) === '[object Array]'; +}; diff --git a/tools/node_modules/concat-map/package.json b/tools/node_modules/concat-map/package.json new file mode 100644 index 00000000000000..949eb3aacf5a61 --- /dev/null +++ b/tools/node_modules/concat-map/package.json @@ -0,0 +1,108 @@ +{ + "_args": [ + [ + "concat-map@0.0.1", + "C:\\wamp\\www\\node\\tools\\node_modules\\brace-expansion" + ] + ], + "_from": "concat-map@0.0.1", + "_id": "concat-map@0.0.1", + "_inCache": true, + "_location": "/concat-map", + "_npmUser": { + "email": "mail@substack.net", + "name": "substack" + }, + "_npmVersion": "1.3.21", + "_phantomChildren": {}, + "_requested": { + "name": "concat-map", + "raw": "concat-map@0.0.1", + "rawSpec": "0.0.1", + "scope": null, + "spec": "0.0.1", + "type": "version" + }, + "_requiredBy": [ + "/brace-expansion" + ], + "_resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "_shasum": "d8a96bd77fd68df7793a73036a3ba0d5405d477b", + "_shrinkwrap": null, + "_spec": "concat-map@0.0.1", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\brace-expansion", + "author": { + "email": "mail@substack.net", + "name": "James Halliday", + "url": "http://substack.net" + }, + "bugs": { + "url": "https://github.com/substack/node-concat-map/issues" + }, + "dependencies": {}, + "description": "concatenative mapdashery", + "devDependencies": { + "tape": "~2.4.0" + }, + "directories": { + "example": "example", + "test": "test" + }, + "dist": { + "shasum": "d8a96bd77fd68df7793a73036a3ba0d5405d477b", + "tarball": "http://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz" + }, + "homepage": "https://github.com/substack/node-concat-map", + "installable": true, + "keywords": [ + "concat", + "concatMap", + "functional", + "higher-order", + "map" + ], + "license": "MIT", + "main": "index.js", + "maintainers": [ + { + "name": "substack", + "email": "mail@substack.net" + } + ], + "name": "concat-map", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git://github.com/substack/node-concat-map.git" + }, + "scripts": { + "test": "tape test/*.js" + }, + "testling": { + "browsers": { + "chrome": [ + 10, + 22 + ], + "ff": [ + 10, + 15, + 3.5 + ], + "ie": [ + 6, + 7, + 8, + 9 + ], + "opera": [ + 12 + ], + "safari": [ + 5.1 + ] + }, + "files": "test/*.js" + }, + "version": "0.0.1" +} diff --git a/tools/node_modules/concat-map/test/map.js b/tools/node_modules/concat-map/test/map.js new file mode 100644 index 00000000000000..fdbd7022f6da17 --- /dev/null +++ b/tools/node_modules/concat-map/test/map.js @@ -0,0 +1,39 @@ +var concatMap = require('../'); +var test = require('tape'); + +test('empty or not', function (t) { + var xs = [ 1, 2, 3, 4, 5, 6 ]; + var ixes = []; + var ys = concatMap(xs, function (x, ix) { + ixes.push(ix); + return x % 2 ? [ x - 0.1, x, x + 0.1 ] : []; + }); + t.same(ys, [ 0.9, 1, 1.1, 2.9, 3, 3.1, 4.9, 5, 5.1 ]); + t.same(ixes, [ 0, 1, 2, 3, 4, 5 ]); + t.end(); +}); + +test('always something', function (t) { + var xs = [ 'a', 'b', 'c', 'd' ]; + var ys = concatMap(xs, function (x) { + return x === 'b' ? [ 'B', 'B', 'B' ] : [ x ]; + }); + t.same(ys, [ 'a', 'B', 'B', 'B', 'c', 'd' ]); + t.end(); +}); + +test('scalars', function (t) { + var xs = [ 'a', 'b', 'c', 'd' ]; + var ys = concatMap(xs, function (x) { + return x === 'b' ? [ 'B', 'B', 'B' ] : x; + }); + t.same(ys, [ 'a', 'B', 'B', 'B', 'c', 'd' ]); + t.end(); +}); + +test('undefs', function (t) { + var xs = [ 'a', 'b', 'c', 'd' ]; + var ys = concatMap(xs, function () {}); + t.same(ys, [ undefined, undefined, undefined, undefined ]); + t.end(); +}); diff --git a/tools/node_modules/concat-stream/LICENSE b/tools/node_modules/concat-stream/LICENSE new file mode 100644 index 00000000000000..99c130e1de3427 --- /dev/null +++ b/tools/node_modules/concat-stream/LICENSE @@ -0,0 +1,24 @@ +The MIT License + +Copyright (c) 2013 Max Ogden + +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. \ No newline at end of file diff --git a/tools/node_modules/concat-stream/index.js b/tools/node_modules/concat-stream/index.js new file mode 100644 index 00000000000000..b55ae7e03dbd38 --- /dev/null +++ b/tools/node_modules/concat-stream/index.js @@ -0,0 +1,136 @@ +var Writable = require('readable-stream').Writable +var inherits = require('inherits') + +if (typeof Uint8Array === 'undefined') { + var U8 = require('typedarray').Uint8Array +} else { + var U8 = Uint8Array +} + +function ConcatStream(opts, cb) { + if (!(this instanceof ConcatStream)) return new ConcatStream(opts, cb) + + if (typeof opts === 'function') { + cb = opts + opts = {} + } + if (!opts) opts = {} + + var encoding = opts.encoding + var shouldInferEncoding = false + + if (!encoding) { + shouldInferEncoding = true + } else { + encoding = String(encoding).toLowerCase() + if (encoding === 'u8' || encoding === 'uint8') { + encoding = 'uint8array' + } + } + + Writable.call(this, { objectMode: true }) + + this.encoding = encoding + this.shouldInferEncoding = shouldInferEncoding + + if (cb) this.on('finish', function () { cb(this.getBody()) }) + this.body = [] +} + +module.exports = ConcatStream +inherits(ConcatStream, Writable) + +ConcatStream.prototype._write = function(chunk, enc, next) { + this.body.push(chunk) + next() +} + +ConcatStream.prototype.inferEncoding = function (buff) { + var firstBuffer = buff === undefined ? this.body[0] : buff; + if (Buffer.isBuffer(firstBuffer)) return 'buffer' + if (typeof Uint8Array !== 'undefined' && firstBuffer instanceof Uint8Array) return 'uint8array' + if (Array.isArray(firstBuffer)) return 'array' + if (typeof firstBuffer === 'string') return 'string' + if (Object.prototype.toString.call(firstBuffer) === "[object Object]") return 'object' + return 'buffer' +} + +ConcatStream.prototype.getBody = function () { + if (!this.encoding && this.body.length === 0) return [] + if (this.shouldInferEncoding) this.encoding = this.inferEncoding() + if (this.encoding === 'array') return arrayConcat(this.body) + if (this.encoding === 'string') return stringConcat(this.body) + if (this.encoding === 'buffer') return bufferConcat(this.body) + if (this.encoding === 'uint8array') return u8Concat(this.body) + return this.body +} + +var isArray = Array.isArray || function (arr) { + return Object.prototype.toString.call(arr) == '[object Array]' +} + +function isArrayish (arr) { + return /Array\]$/.test(Object.prototype.toString.call(arr)) +} + +function stringConcat (parts) { + var strings = [] + var needsToString = false + for (var i = 0; i < parts.length; i++) { + var p = parts[i] + if (typeof p === 'string') { + strings.push(p) + } else if (Buffer.isBuffer(p)) { + strings.push(p) + } else { + strings.push(Buffer(p)) + } + } + if (Buffer.isBuffer(parts[0])) { + strings = Buffer.concat(strings) + strings = strings.toString('utf8') + } else { + strings = strings.join('') + } + return strings +} + +function bufferConcat (parts) { + var bufs = [] + for (var i = 0; i < parts.length; i++) { + var p = parts[i] + if (Buffer.isBuffer(p)) { + bufs.push(p) + } else if (typeof p === 'string' || isArrayish(p) + || (p && typeof p.subarray === 'function')) { + bufs.push(Buffer(p)) + } else bufs.push(Buffer(String(p))) + } + return Buffer.concat(bufs) +} + +function arrayConcat (parts) { + var res = [] + for (var i = 0; i < parts.length; i++) { + res.push.apply(res, parts[i]) + } + return res +} + +function u8Concat (parts) { + var len = 0 + for (var i = 0; i < parts.length; i++) { + if (typeof parts[i] === 'string') { + parts[i] = Buffer(parts[i]) + } + len += parts[i].length + } + var u8 = new U8(len) + for (var i = 0, offset = 0; i < parts.length; i++) { + var part = parts[i] + for (var j = 0; j < part.length; j++) { + u8[offset++] = part[j] + } + } + return u8 +} diff --git a/tools/node_modules/concat-stream/package.json b/tools/node_modules/concat-stream/package.json new file mode 100644 index 00000000000000..c12b6a7ced6320 --- /dev/null +++ b/tools/node_modules/concat-stream/package.json @@ -0,0 +1,105 @@ +{ + "_args": [ + [ + "concat-stream@^1.0.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\remark" + ] + ], + "_from": "concat-stream@>=1.0.0 <2.0.0", + "_id": "concat-stream@1.5.1", + "_inCache": true, + "_location": "/concat-stream", + "_nodeVersion": "4.0.0", + "_npmUser": { + "email": "max@maxogden.com", + "name": "maxogden" + }, + "_npmVersion": "2.14.2", + "_phantomChildren": {}, + "_requested": { + "name": "concat-stream", + "raw": "concat-stream@^1.0.0", + "rawSpec": "^1.0.0", + "scope": null, + "spec": ">=1.0.0 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/remark" + ], + "_resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.5.1.tgz", + "_shasum": "f3b80acf9e1f48e3875c0688b41b6c31602eea1c", + "_shrinkwrap": null, + "_spec": "concat-stream@^1.0.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\remark", + "author": { + "email": "max@maxogden.com", + "name": "Max Ogden" + }, + "bugs": { + "url": "http://github.com/maxogden/concat-stream/issues" + }, + "dependencies": { + "inherits": "~2.0.1", + "readable-stream": "~2.0.0", + "typedarray": "~0.0.5" + }, + "description": "writable stream that concatenates strings or binary data and calls a callback with the result", + "devDependencies": { + "tape": "~2.3.2" + }, + "directories": {}, + "dist": { + "shasum": "f3b80acf9e1f48e3875c0688b41b6c31602eea1c", + "tarball": "http://registry.npmjs.org/concat-stream/-/concat-stream-1.5.1.tgz" + }, + "engines": [ + "node >= 0.8" + ], + "files": [ + "index.js" + ], + "gitHead": "522adc12d82f57c691a5f946fbc8ba08718dcdcb", + "homepage": "https://github.com/maxogden/concat-stream#readme", + "installable": true, + "license": "MIT", + "main": "index.js", + "maintainers": [ + { + "name": "maxogden", + "email": "max@maxogden.com" + } + ], + "name": "concat-stream", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git+ssh://git@github.com/maxogden/concat-stream.git" + }, + "scripts": { + "test": "tape test/*.js test/server/*.js" + }, + "tags": [ + "simple", + "stream", + "util", + "utility" + ], + "testling": { + "browsers": [ + "android-browser/4.2..latest", + "chrome/22..latest", + "chrome/canary", + "firefox/17..latest", + "firefox/nightly", + "ie/8..latest", + "ipad/6.0..latest", + "iphone/6.0..latest", + "opera/12..latest", + "opera/next", + "safari/5.1..latest" + ], + "files": "test/*.js" + }, + "version": "1.5.1" +} diff --git a/tools/node_modules/concat-stream/readme.md b/tools/node_modules/concat-stream/readme.md new file mode 100644 index 00000000000000..1a16af94c40736 --- /dev/null +++ b/tools/node_modules/concat-stream/readme.md @@ -0,0 +1,100 @@ +# concat-stream + +Writable stream that concatenates all the data from a stream and calls a callback with the result. Use this when you want to collect all the data from a stream into a single buffer. + +[![Build Status](https://travis-ci.org/maxogden/concat-stream.svg?branch=master)](https://travis-ci.org/maxogden/concat-stream) + +[![NPM](https://nodei.co/npm/concat-stream.png)](https://nodei.co/npm/concat-stream/) + +### description + +Streams emit many buffers. If you want to collect all of the buffers, and when the stream ends concatenate all of the buffers together and receive a single buffer then this is the module for you. + +Only use this if you know you can fit all of the output of your stream into a single Buffer (e.g. in RAM). + +There are also `objectMode` streams that emit things other than Buffers, and you can concatenate these too. See below for details. + +## Related + +`stream-each` is part of the [mississippi stream utility collection](https://github.com/maxogden/mississippi) which includes more useful stream modules similar to this one. + +### examples + +#### Buffers + +```js +var fs = require('fs') +var concat = require('concat-stream') + +var readStream = fs.createReadStream('cat.png') +var concatStream = concat(gotPicture) + +readStream.on('error', handleError) +readStream.pipe(concatStream) + +function gotPicture(imageBuffer) { + // imageBuffer is all of `cat.png` as a node.js Buffer +} + +function handleError(err) { + // handle your error appropriately here, e.g.: + console.error(err) // print the error to STDERR + process.exit(1) // exit program with non-zero exit code +} + +``` + +#### Arrays + +```js +var write = concat(function(data) {}) +write.write([1,2,3]) +write.write([4,5,6]) +write.end() +// data will be [1,2,3,4,5,6] in the above callback +``` + +#### Uint8Arrays + +```js +var write = concat(function(data) {}) +var a = new Uint8Array(3) +a[0] = 97; a[1] = 98; a[2] = 99 +write.write(a) +write.write('!') +write.end(Buffer('!!1')) +``` + +See `test/` for more examples + +# methods + +```js +var concat = require('concat-stream') +``` + +## var writable = concat(opts={}, cb) + +Return a `writable` stream that will fire `cb(data)` with all of the data that +was written to the stream. Data can be written to `writable` as strings, +Buffers, arrays of byte integers, and Uint8Arrays. + +By default `concat-stream` will give you back the same data type as the type of the first buffer written to the stream. Use `opts.encoding` to set what format `data` should be returned as, e.g. if you if you don't want to rely on the built-in type checking or for some other reason. + +* `string` - get a string +* `buffer` - get back a Buffer +* `array` - get an array of byte integers +* `uint8array`, `u8`, `uint8` - get back a Uint8Array +* `object`, get back an array of Objects + +If you don't specify an encoding, and the types can't be inferred (e.g. you write things that aren't in the list above), it will try to convert concat them into a `Buffer`. + +# error handling + +`concat-stream` does not handle errors for you, so you must handle errors on whatever streams you pipe into `concat-stream`. This is a general rule when programming with node.js streams: always handle errors on each and every stream. Since `concat-stream` is not itself a stream it does not emit errors. + +We recommend using [`end-of-stream`](https://npmjs.org/end-of-stream) or [`pump`](https://npmjs.org/pump) for writing error tolerant stream code. + +# license + +MIT LICENSE diff --git a/tools/node_modules/core-util-is/LICENSE b/tools/node_modules/core-util-is/LICENSE new file mode 100644 index 00000000000000..d8d7f9437dbf5a --- /dev/null +++ b/tools/node_modules/core-util-is/LICENSE @@ -0,0 +1,19 @@ +Copyright Node.js contributors. All rights reserved. + +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. diff --git a/tools/node_modules/core-util-is/README.md b/tools/node_modules/core-util-is/README.md new file mode 100644 index 00000000000000..5a76b4149c5eb5 --- /dev/null +++ b/tools/node_modules/core-util-is/README.md @@ -0,0 +1,3 @@ +# core-util-is + +The `util.is*` functions introduced in Node v0.12. diff --git a/tools/node_modules/core-util-is/float.patch b/tools/node_modules/core-util-is/float.patch new file mode 100644 index 00000000000000..a06d5c05f75fd5 --- /dev/null +++ b/tools/node_modules/core-util-is/float.patch @@ -0,0 +1,604 @@ +diff --git a/lib/util.js b/lib/util.js +index a03e874..9074e8e 100644 +--- a/lib/util.js ++++ b/lib/util.js +@@ -19,430 +19,6 @@ + // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + // USE OR OTHER DEALINGS IN THE SOFTWARE. + +-var formatRegExp = /%[sdj%]/g; +-exports.format = function(f) { +- if (!isString(f)) { +- var objects = []; +- for (var i = 0; i < arguments.length; i++) { +- objects.push(inspect(arguments[i])); +- } +- return objects.join(' '); +- } +- +- var i = 1; +- var args = arguments; +- var len = args.length; +- var str = String(f).replace(formatRegExp, function(x) { +- if (x === '%%') return '%'; +- if (i >= len) return x; +- switch (x) { +- case '%s': return String(args[i++]); +- case '%d': return Number(args[i++]); +- case '%j': +- try { +- return JSON.stringify(args[i++]); +- } catch (_) { +- return '[Circular]'; +- } +- default: +- return x; +- } +- }); +- for (var x = args[i]; i < len; x = args[++i]) { +- if (isNull(x) || !isObject(x)) { +- str += ' ' + x; +- } else { +- str += ' ' + inspect(x); +- } +- } +- return str; +-}; +- +- +-// Mark that a method should not be used. +-// Returns a modified function which warns once by default. +-// If --no-deprecation is set, then it is a no-op. +-exports.deprecate = function(fn, msg) { +- // Allow for deprecating things in the process of starting up. +- if (isUndefined(global.process)) { +- return function() { +- return exports.deprecate(fn, msg).apply(this, arguments); +- }; +- } +- +- if (process.noDeprecation === true) { +- return fn; +- } +- +- var warned = false; +- function deprecated() { +- if (!warned) { +- if (process.throwDeprecation) { +- throw new Error(msg); +- } else if (process.traceDeprecation) { +- console.trace(msg); +- } else { +- console.error(msg); +- } +- warned = true; +- } +- return fn.apply(this, arguments); +- } +- +- return deprecated; +-}; +- +- +-var debugs = {}; +-var debugEnviron; +-exports.debuglog = function(set) { +- if (isUndefined(debugEnviron)) +- debugEnviron = process.env.NODE_DEBUG || ''; +- set = set.toUpperCase(); +- if (!debugs[set]) { +- if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) { +- var pid = process.pid; +- debugs[set] = function() { +- var msg = exports.format.apply(exports, arguments); +- console.error('%s %d: %s', set, pid, msg); +- }; +- } else { +- debugs[set] = function() {}; +- } +- } +- return debugs[set]; +-}; +- +- +-/** +- * Echos the value of a value. Trys to print the value out +- * in the best way possible given the different types. +- * +- * @param {Object} obj The object to print out. +- * @param {Object} opts Optional options object that alters the output. +- */ +-/* legacy: obj, showHidden, depth, colors*/ +-function inspect(obj, opts) { +- // default options +- var ctx = { +- seen: [], +- stylize: stylizeNoColor +- }; +- // legacy... +- if (arguments.length >= 3) ctx.depth = arguments[2]; +- if (arguments.length >= 4) ctx.colors = arguments[3]; +- if (isBoolean(opts)) { +- // legacy... +- ctx.showHidden = opts; +- } else if (opts) { +- // got an "options" object +- exports._extend(ctx, opts); +- } +- // set default options +- if (isUndefined(ctx.showHidden)) ctx.showHidden = false; +- if (isUndefined(ctx.depth)) ctx.depth = 2; +- if (isUndefined(ctx.colors)) ctx.colors = false; +- if (isUndefined(ctx.customInspect)) ctx.customInspect = true; +- if (ctx.colors) ctx.stylize = stylizeWithColor; +- return formatValue(ctx, obj, ctx.depth); +-} +-exports.inspect = inspect; +- +- +-// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics +-inspect.colors = { +- 'bold' : [1, 22], +- 'italic' : [3, 23], +- 'underline' : [4, 24], +- 'inverse' : [7, 27], +- 'white' : [37, 39], +- 'grey' : [90, 39], +- 'black' : [30, 39], +- 'blue' : [34, 39], +- 'cyan' : [36, 39], +- 'green' : [32, 39], +- 'magenta' : [35, 39], +- 'red' : [31, 39], +- 'yellow' : [33, 39] +-}; +- +-// Don't use 'blue' not visible on cmd.exe +-inspect.styles = { +- 'special': 'cyan', +- 'number': 'yellow', +- 'boolean': 'yellow', +- 'undefined': 'grey', +- 'null': 'bold', +- 'string': 'green', +- 'date': 'magenta', +- // "name": intentionally not styling +- 'regexp': 'red' +-}; +- +- +-function stylizeWithColor(str, styleType) { +- var style = inspect.styles[styleType]; +- +- if (style) { +- return '\u001b[' + inspect.colors[style][0] + 'm' + str + +- '\u001b[' + inspect.colors[style][1] + 'm'; +- } else { +- return str; +- } +-} +- +- +-function stylizeNoColor(str, styleType) { +- return str; +-} +- +- +-function arrayToHash(array) { +- var hash = {}; +- +- array.forEach(function(val, idx) { +- hash[val] = true; +- }); +- +- return hash; +-} +- +- +-function formatValue(ctx, value, recurseTimes) { +- // Provide a hook for user-specified inspect functions. +- // Check that value is an object with an inspect function on it +- if (ctx.customInspect && +- value && +- isFunction(value.inspect) && +- // Filter out the util module, it's inspect function is special +- value.inspect !== exports.inspect && +- // Also filter out any prototype objects using the circular check. +- !(value.constructor && value.constructor.prototype === value)) { +- var ret = value.inspect(recurseTimes, ctx); +- if (!isString(ret)) { +- ret = formatValue(ctx, ret, recurseTimes); +- } +- return ret; +- } +- +- // Primitive types cannot have properties +- var primitive = formatPrimitive(ctx, value); +- if (primitive) { +- return primitive; +- } +- +- // Look up the keys of the object. +- var keys = Object.keys(value); +- var visibleKeys = arrayToHash(keys); +- +- if (ctx.showHidden) { +- keys = Object.getOwnPropertyNames(value); +- } +- +- // Some type of object without properties can be shortcutted. +- if (keys.length === 0) { +- if (isFunction(value)) { +- var name = value.name ? ': ' + value.name : ''; +- return ctx.stylize('[Function' + name + ']', 'special'); +- } +- if (isRegExp(value)) { +- return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); +- } +- if (isDate(value)) { +- return ctx.stylize(Date.prototype.toString.call(value), 'date'); +- } +- if (isError(value)) { +- return formatError(value); +- } +- } +- +- var base = '', array = false, braces = ['{', '}']; +- +- // Make Array say that they are Array +- if (isArray(value)) { +- array = true; +- braces = ['[', ']']; +- } +- +- // Make functions say that they are functions +- if (isFunction(value)) { +- var n = value.name ? ': ' + value.name : ''; +- base = ' [Function' + n + ']'; +- } +- +- // Make RegExps say that they are RegExps +- if (isRegExp(value)) { +- base = ' ' + RegExp.prototype.toString.call(value); +- } +- +- // Make dates with properties first say the date +- if (isDate(value)) { +- base = ' ' + Date.prototype.toUTCString.call(value); +- } +- +- // Make error with message first say the error +- if (isError(value)) { +- base = ' ' + formatError(value); +- } +- +- if (keys.length === 0 && (!array || value.length == 0)) { +- return braces[0] + base + braces[1]; +- } +- +- if (recurseTimes < 0) { +- if (isRegExp(value)) { +- return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); +- } else { +- return ctx.stylize('[Object]', 'special'); +- } +- } +- +- ctx.seen.push(value); +- +- var output; +- if (array) { +- output = formatArray(ctx, value, recurseTimes, visibleKeys, keys); +- } else { +- output = keys.map(function(key) { +- return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array); +- }); +- } +- +- ctx.seen.pop(); +- +- return reduceToSingleString(output, base, braces); +-} +- +- +-function formatPrimitive(ctx, value) { +- if (isUndefined(value)) +- return ctx.stylize('undefined', 'undefined'); +- if (isString(value)) { +- var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '') +- .replace(/'/g, "\\'") +- .replace(/\\"/g, '"') + '\''; +- return ctx.stylize(simple, 'string'); +- } +- if (isNumber(value)) { +- // Format -0 as '-0'. Strict equality won't distinguish 0 from -0, +- // so instead we use the fact that 1 / -0 < 0 whereas 1 / 0 > 0 . +- if (value === 0 && 1 / value < 0) +- return ctx.stylize('-0', 'number'); +- return ctx.stylize('' + value, 'number'); +- } +- if (isBoolean(value)) +- return ctx.stylize('' + value, 'boolean'); +- // For some reason typeof null is "object", so special case here. +- if (isNull(value)) +- return ctx.stylize('null', 'null'); +-} +- +- +-function formatError(value) { +- return '[' + Error.prototype.toString.call(value) + ']'; +-} +- +- +-function formatArray(ctx, value, recurseTimes, visibleKeys, keys) { +- var output = []; +- for (var i = 0, l = value.length; i < l; ++i) { +- if (hasOwnProperty(value, String(i))) { +- output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, +- String(i), true)); +- } else { +- output.push(''); +- } +- } +- keys.forEach(function(key) { +- if (!key.match(/^\d+$/)) { +- output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, +- key, true)); +- } +- }); +- return output; +-} +- +- +-function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) { +- var name, str, desc; +- desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] }; +- if (desc.get) { +- if (desc.set) { +- str = ctx.stylize('[Getter/Setter]', 'special'); +- } else { +- str = ctx.stylize('[Getter]', 'special'); +- } +- } else { +- if (desc.set) { +- str = ctx.stylize('[Setter]', 'special'); +- } +- } +- if (!hasOwnProperty(visibleKeys, key)) { +- name = '[' + key + ']'; +- } +- if (!str) { +- if (ctx.seen.indexOf(desc.value) < 0) { +- if (isNull(recurseTimes)) { +- str = formatValue(ctx, desc.value, null); +- } else { +- str = formatValue(ctx, desc.value, recurseTimes - 1); +- } +- if (str.indexOf('\n') > -1) { +- if (array) { +- str = str.split('\n').map(function(line) { +- return ' ' + line; +- }).join('\n').substr(2); +- } else { +- str = '\n' + str.split('\n').map(function(line) { +- return ' ' + line; +- }).join('\n'); +- } +- } +- } else { +- str = ctx.stylize('[Circular]', 'special'); +- } +- } +- if (isUndefined(name)) { +- if (array && key.match(/^\d+$/)) { +- return str; +- } +- name = JSON.stringify('' + key); +- if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) { +- name = name.substr(1, name.length - 2); +- name = ctx.stylize(name, 'name'); +- } else { +- name = name.replace(/'/g, "\\'") +- .replace(/\\"/g, '"') +- .replace(/(^"|"$)/g, "'"); +- name = ctx.stylize(name, 'string'); +- } +- } +- +- return name + ': ' + str; +-} +- +- +-function reduceToSingleString(output, base, braces) { +- var numLinesEst = 0; +- var length = output.reduce(function(prev, cur) { +- numLinesEst++; +- if (cur.indexOf('\n') >= 0) numLinesEst++; +- return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1; +- }, 0); +- +- if (length > 60) { +- return braces[0] + +- (base === '' ? '' : base + '\n ') + +- ' ' + +- output.join(',\n ') + +- ' ' + +- braces[1]; +- } +- +- return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1]; +-} +- +- + // NOTE: These type checking functions intentionally don't use `instanceof` + // because it is fragile and can be easily faked with `Object.create()`. + function isArray(ar) { +@@ -522,166 +98,10 @@ function isPrimitive(arg) { + exports.isPrimitive = isPrimitive; + + function isBuffer(arg) { +- return arg instanceof Buffer; ++ return Buffer.isBuffer(arg); + } + exports.isBuffer = isBuffer; + + function objectToString(o) { + return Object.prototype.toString.call(o); +-} +- +- +-function pad(n) { +- return n < 10 ? '0' + n.toString(10) : n.toString(10); +-} +- +- +-var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', +- 'Oct', 'Nov', 'Dec']; +- +-// 26 Feb 16:19:34 +-function timestamp() { +- var d = new Date(); +- var time = [pad(d.getHours()), +- pad(d.getMinutes()), +- pad(d.getSeconds())].join(':'); +- return [d.getDate(), months[d.getMonth()], time].join(' '); +-} +- +- +-// log is just a thin wrapper to console.log that prepends a timestamp +-exports.log = function() { +- console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments)); +-}; +- +- +-/** +- * Inherit the prototype methods from one constructor into another. +- * +- * The Function.prototype.inherits from lang.js rewritten as a standalone +- * function (not on Function.prototype). NOTE: If this file is to be loaded +- * during bootstrapping this function needs to be rewritten using some native +- * functions as prototype setup using normal JavaScript does not work as +- * expected during bootstrapping (see mirror.js in r114903). +- * +- * @param {function} ctor Constructor function which needs to inherit the +- * prototype. +- * @param {function} superCtor Constructor function to inherit prototype from. +- */ +-exports.inherits = function(ctor, superCtor) { +- ctor.super_ = superCtor; +- ctor.prototype = Object.create(superCtor.prototype, { +- constructor: { +- value: ctor, +- enumerable: false, +- writable: true, +- configurable: true +- } +- }); +-}; +- +-exports._extend = function(origin, add) { +- // Don't do anything if add isn't an object +- if (!add || !isObject(add)) return origin; +- +- var keys = Object.keys(add); +- var i = keys.length; +- while (i--) { +- origin[keys[i]] = add[keys[i]]; +- } +- return origin; +-}; +- +-function hasOwnProperty(obj, prop) { +- return Object.prototype.hasOwnProperty.call(obj, prop); +-} +- +- +-// Deprecated old stuff. +- +-exports.p = exports.deprecate(function() { +- for (var i = 0, len = arguments.length; i < len; ++i) { +- console.error(exports.inspect(arguments[i])); +- } +-}, 'util.p: Use console.error() instead'); +- +- +-exports.exec = exports.deprecate(function() { +- return require('child_process').exec.apply(this, arguments); +-}, 'util.exec is now called `child_process.exec`.'); +- +- +-exports.print = exports.deprecate(function() { +- for (var i = 0, len = arguments.length; i < len; ++i) { +- process.stdout.write(String(arguments[i])); +- } +-}, 'util.print: Use console.log instead'); +- +- +-exports.puts = exports.deprecate(function() { +- for (var i = 0, len = arguments.length; i < len; ++i) { +- process.stdout.write(arguments[i] + '\n'); +- } +-}, 'util.puts: Use console.log instead'); +- +- +-exports.debug = exports.deprecate(function(x) { +- process.stderr.write('DEBUG: ' + x + '\n'); +-}, 'util.debug: Use console.error instead'); +- +- +-exports.error = exports.deprecate(function(x) { +- for (var i = 0, len = arguments.length; i < len; ++i) { +- process.stderr.write(arguments[i] + '\n'); +- } +-}, 'util.error: Use console.error instead'); +- +- +-exports.pump = exports.deprecate(function(readStream, writeStream, callback) { +- var callbackCalled = false; +- +- function call(a, b, c) { +- if (callback && !callbackCalled) { +- callback(a, b, c); +- callbackCalled = true; +- } +- } +- +- readStream.addListener('data', function(chunk) { +- if (writeStream.write(chunk) === false) readStream.pause(); +- }); +- +- writeStream.addListener('drain', function() { +- readStream.resume(); +- }); +- +- readStream.addListener('end', function() { +- writeStream.end(); +- }); +- +- readStream.addListener('close', function() { +- call(); +- }); +- +- readStream.addListener('error', function(err) { +- writeStream.end(); +- call(err); +- }); +- +- writeStream.addListener('error', function(err) { +- readStream.destroy(); +- call(err); +- }); +-}, 'util.pump(): Use readableStream.pipe() instead'); +- +- +-var uv; +-exports._errnoException = function(err, syscall) { +- if (isUndefined(uv)) uv = process.binding('uv'); +- var errname = uv.errname(err); +- var e = new Error(syscall + ' ' + errname); +- e.code = errname; +- e.errno = errname; +- e.syscall = syscall; +- return e; +-}; ++} \ No newline at end of file diff --git a/tools/node_modules/core-util-is/lib/util.js b/tools/node_modules/core-util-is/lib/util.js new file mode 100644 index 00000000000000..ff4c851c075a2f --- /dev/null +++ b/tools/node_modules/core-util-is/lib/util.js @@ -0,0 +1,107 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +// NOTE: These type checking functions intentionally don't use `instanceof` +// because it is fragile and can be easily faked with `Object.create()`. + +function isArray(arg) { + if (Array.isArray) { + return Array.isArray(arg); + } + return objectToString(arg) === '[object Array]'; +} +exports.isArray = isArray; + +function isBoolean(arg) { + return typeof arg === 'boolean'; +} +exports.isBoolean = isBoolean; + +function isNull(arg) { + return arg === null; +} +exports.isNull = isNull; + +function isNullOrUndefined(arg) { + return arg == null; +} +exports.isNullOrUndefined = isNullOrUndefined; + +function isNumber(arg) { + return typeof arg === 'number'; +} +exports.isNumber = isNumber; + +function isString(arg) { + return typeof arg === 'string'; +} +exports.isString = isString; + +function isSymbol(arg) { + return typeof arg === 'symbol'; +} +exports.isSymbol = isSymbol; + +function isUndefined(arg) { + return arg === void 0; +} +exports.isUndefined = isUndefined; + +function isRegExp(re) { + return objectToString(re) === '[object RegExp]'; +} +exports.isRegExp = isRegExp; + +function isObject(arg) { + return typeof arg === 'object' && arg !== null; +} +exports.isObject = isObject; + +function isDate(d) { + return objectToString(d) === '[object Date]'; +} +exports.isDate = isDate; + +function isError(e) { + return (objectToString(e) === '[object Error]' || e instanceof Error); +} +exports.isError = isError; + +function isFunction(arg) { + return typeof arg === 'function'; +} +exports.isFunction = isFunction; + +function isPrimitive(arg) { + return arg === null || + typeof arg === 'boolean' || + typeof arg === 'number' || + typeof arg === 'string' || + typeof arg === 'symbol' || // ES6 symbol + typeof arg === 'undefined'; +} +exports.isPrimitive = isPrimitive; + +exports.isBuffer = Buffer.isBuffer; + +function objectToString(o) { + return Object.prototype.toString.call(o); +} diff --git a/tools/node_modules/core-util-is/package.json b/tools/node_modules/core-util-is/package.json new file mode 100644 index 00000000000000..7017cbc8d6603f --- /dev/null +++ b/tools/node_modules/core-util-is/package.json @@ -0,0 +1,85 @@ +{ + "_args": [ + [ + "core-util-is@~1.0.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\readable-stream" + ] + ], + "_from": "core-util-is@>=1.0.0 <1.1.0", + "_id": "core-util-is@1.0.2", + "_inCache": true, + "_location": "/core-util-is", + "_nodeVersion": "4.0.0", + "_npmUser": { + "email": "i@izs.me", + "name": "isaacs" + }, + "_npmVersion": "3.3.2", + "_phantomChildren": {}, + "_requested": { + "name": "core-util-is", + "raw": "core-util-is@~1.0.0", + "rawSpec": "~1.0.0", + "scope": null, + "spec": ">=1.0.0 <1.1.0", + "type": "range" + }, + "_requiredBy": [ + "/readable-stream" + ], + "_resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "_shasum": "b5fd54220aa2bc5ab57aab7140c940754503c1a7", + "_shrinkwrap": null, + "_spec": "core-util-is@~1.0.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\readable-stream", + "author": { + "email": "i@izs.me", + "name": "Isaac Z. Schlueter", + "url": "http://blog.izs.me/" + }, + "bugs": { + "url": "https://github.com/isaacs/core-util-is/issues" + }, + "dependencies": {}, + "description": "The `util.is*` functions introduced in Node v0.12.", + "devDependencies": { + "tap": "^2.3.0" + }, + "directories": {}, + "dist": { + "shasum": "b5fd54220aa2bc5ab57aab7140c940754503c1a7", + "tarball": "http://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz" + }, + "gitHead": "a177da234df5638b363ddc15fa324619a38577c8", + "homepage": "https://github.com/isaacs/core-util-is#readme", + "installable": true, + "keywords": [ + "isArray", + "isBuffer", + "isNumber", + "isRegExp", + "isString", + "isThat", + "isThis", + "polyfill", + "util" + ], + "license": "MIT", + "main": "lib/util.js", + "maintainers": [ + { + "name": "isaacs", + "email": "i@izs.me" + } + ], + "name": "core-util-is", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git://github.com/isaacs/core-util-is.git" + }, + "scripts": { + "test": "tap test.js" + }, + "version": "1.0.2" +} diff --git a/tools/node_modules/core-util-is/test.js b/tools/node_modules/core-util-is/test.js new file mode 100644 index 00000000000000..1a490c65ac8b5d --- /dev/null +++ b/tools/node_modules/core-util-is/test.js @@ -0,0 +1,68 @@ +var assert = require('tap'); + +var t = require('./lib/util'); + +assert.equal(t.isArray([]), true); +assert.equal(t.isArray({}), false); + +assert.equal(t.isBoolean(null), false); +assert.equal(t.isBoolean(true), true); +assert.equal(t.isBoolean(false), true); + +assert.equal(t.isNull(null), true); +assert.equal(t.isNull(undefined), false); +assert.equal(t.isNull(false), false); +assert.equal(t.isNull(), false); + +assert.equal(t.isNullOrUndefined(null), true); +assert.equal(t.isNullOrUndefined(undefined), true); +assert.equal(t.isNullOrUndefined(false), false); +assert.equal(t.isNullOrUndefined(), true); + +assert.equal(t.isNumber(null), false); +assert.equal(t.isNumber('1'), false); +assert.equal(t.isNumber(1), true); + +assert.equal(t.isString(null), false); +assert.equal(t.isString('1'), true); +assert.equal(t.isString(1), false); + +assert.equal(t.isSymbol(null), false); +assert.equal(t.isSymbol('1'), false); +assert.equal(t.isSymbol(1), false); +assert.equal(t.isSymbol(Symbol()), true); + +assert.equal(t.isUndefined(null), false); +assert.equal(t.isUndefined(undefined), true); +assert.equal(t.isUndefined(false), false); +assert.equal(t.isUndefined(), true); + +assert.equal(t.isRegExp(null), false); +assert.equal(t.isRegExp('1'), false); +assert.equal(t.isRegExp(new RegExp()), true); + +assert.equal(t.isObject({}), true); +assert.equal(t.isObject([]), true); +assert.equal(t.isObject(new RegExp()), true); +assert.equal(t.isObject(new Date()), true); + +assert.equal(t.isDate(null), false); +assert.equal(t.isDate('1'), false); +assert.equal(t.isDate(new Date()), true); + +assert.equal(t.isError(null), false); +assert.equal(t.isError({ err: true }), false); +assert.equal(t.isError(new Error()), true); + +assert.equal(t.isFunction(null), false); +assert.equal(t.isFunction({ }), false); +assert.equal(t.isFunction(function() {}), true); + +assert.equal(t.isPrimitive(null), true); +assert.equal(t.isPrimitive(''), true); +assert.equal(t.isPrimitive(0), true); +assert.equal(t.isPrimitive(new Date()), false); + +assert.equal(t.isBuffer(null), false); +assert.equal(t.isBuffer({}), false); +assert.equal(t.isBuffer(new Buffer(0)), true); diff --git a/tools/node_modules/debug/.jshintrc b/tools/node_modules/debug/.jshintrc new file mode 100644 index 00000000000000..299877f26aeb6c --- /dev/null +++ b/tools/node_modules/debug/.jshintrc @@ -0,0 +1,3 @@ +{ + "laxbreak": true +} diff --git a/tools/node_modules/debug/.npmignore b/tools/node_modules/debug/.npmignore new file mode 100644 index 00000000000000..7e6163db02e5e7 --- /dev/null +++ b/tools/node_modules/debug/.npmignore @@ -0,0 +1,6 @@ +support +test +examples +example +*.sock +dist diff --git a/tools/node_modules/debug/History.md b/tools/node_modules/debug/History.md new file mode 100644 index 00000000000000..854c9711c6fd68 --- /dev/null +++ b/tools/node_modules/debug/History.md @@ -0,0 +1,195 @@ + +2.2.0 / 2015-05-09 +================== + + * package: update "ms" to v0.7.1 (#202, @dougwilson) + * README: add logging to file example (#193, @DanielOchoa) + * README: fixed a typo (#191, @amir-s) + * browser: expose `storage` (#190, @stephenmathieson) + * Makefile: add a `distclean` target (#189, @stephenmathieson) + +2.1.3 / 2015-03-13 +================== + + * Updated stdout/stderr example (#186) + * Updated example/stdout.js to match debug current behaviour + * Renamed example/stderr.js to stdout.js + * Update Readme.md (#184) + * replace high intensity foreground color for bold (#182, #183) + +2.1.2 / 2015-03-01 +================== + + * dist: recompile + * update "ms" to v0.7.0 + * package: update "browserify" to v9.0.3 + * component: fix "ms.js" repo location + * changed bower package name + * updated documentation about using debug in a browser + * fix: security error on safari (#167, #168, @yields) + +2.1.1 / 2014-12-29 +================== + + * browser: use `typeof` to check for `console` existence + * browser: check for `console.log` truthiness (fix IE 8/9) + * browser: add support for Chrome apps + * Readme: added Windows usage remarks + * Add `bower.json` to properly support bower install + +2.1.0 / 2014-10-15 +================== + + * node: implement `DEBUG_FD` env variable support + * package: update "browserify" to v6.1.0 + * package: add "license" field to package.json (#135, @panuhorsmalahti) + +2.0.0 / 2014-09-01 +================== + + * package: update "browserify" to v5.11.0 + * node: use stderr rather than stdout for logging (#29, @stephenmathieson) + +1.0.4 / 2014-07-15 +================== + + * dist: recompile + * example: remove `console.info()` log usage + * example: add "Content-Type" UTF-8 header to browser example + * browser: place %c marker after the space character + * browser: reset the "content" color via `color: inherit` + * browser: add colors support for Firefox >= v31 + * debug: prefer an instance `log()` function over the global one (#119) + * Readme: update documentation about styled console logs for FF v31 (#116, @wryk) + +1.0.3 / 2014-07-09 +================== + + * Add support for multiple wildcards in namespaces (#122, @seegno) + * browser: fix lint + +1.0.2 / 2014-06-10 +================== + + * browser: update color palette (#113, @gscottolson) + * common: make console logging function configurable (#108, @timoxley) + * node: fix %o colors on old node <= 0.8.x + * Makefile: find node path using shell/which (#109, @timoxley) + +1.0.1 / 2014-06-06 +================== + + * browser: use `removeItem()` to clear localStorage + * browser, node: don't set DEBUG if namespaces is undefined (#107, @leedm777) + * package: add "contributors" section + * node: fix comment typo + * README: list authors + +1.0.0 / 2014-06-04 +================== + + * make ms diff be global, not be scope + * debug: ignore empty strings in enable() + * node: make DEBUG_COLORS able to disable coloring + * *: export the `colors` array + * npmignore: don't publish the `dist` dir + * Makefile: refactor to use browserify + * package: add "browserify" as a dev dependency + * Readme: add Web Inspector Colors section + * node: reset terminal color for the debug content + * node: map "%o" to `util.inspect()` + * browser: map "%j" to `JSON.stringify()` + * debug: add custom "formatters" + * debug: use "ms" module for humanizing the diff + * Readme: add "bash" syntax highlighting + * browser: add Firebug color support + * browser: add colors for WebKit browsers + * node: apply log to `console` + * rewrite: abstract common logic for Node & browsers + * add .jshintrc file + +0.8.1 / 2014-04-14 +================== + + * package: re-add the "component" section + +0.8.0 / 2014-03-30 +================== + + * add `enable()` method for nodejs. Closes #27 + * change from stderr to stdout + * remove unnecessary index.js file + +0.7.4 / 2013-11-13 +================== + + * remove "browserify" key from package.json (fixes something in browserify) + +0.7.3 / 2013-10-30 +================== + + * fix: catch localStorage security error when cookies are blocked (Chrome) + * add debug(err) support. Closes #46 + * add .browser prop to package.json. Closes #42 + +0.7.2 / 2013-02-06 +================== + + * fix package.json + * fix: Mobile Safari (private mode) is broken with debug + * fix: Use unicode to send escape character to shell instead of octal to work with strict mode javascript + +0.7.1 / 2013-02-05 +================== + + * add repository URL to package.json + * add DEBUG_COLORED to force colored output + * add browserify support + * fix component. Closes #24 + +0.7.0 / 2012-05-04 +================== + + * Added .component to package.json + * Added debug.component.js build + +0.6.0 / 2012-03-16 +================== + + * Added support for "-" prefix in DEBUG [Vinay Pulim] + * Added `.enabled` flag to the node version [TooTallNate] + +0.5.0 / 2012-02-02 +================== + + * Added: humanize diffs. Closes #8 + * Added `debug.disable()` to the CS variant + * Removed padding. Closes #10 + * Fixed: persist client-side variant again. Closes #9 + +0.4.0 / 2012-02-01 +================== + + * Added browser variant support for older browsers [TooTallNate] + * Added `debug.enable('project:*')` to browser variant [TooTallNate] + * Added padding to diff (moved it to the right) + +0.3.0 / 2012-01-26 +================== + + * Added millisecond diff when isatty, otherwise UTC string + +0.2.0 / 2012-01-22 +================== + + * Added wildcard support + +0.1.0 / 2011-12-02 +================== + + * Added: remove colors unless stderr isatty [TooTallNate] + +0.0.1 / 2010-01-03 +================== + + * Initial release diff --git a/tools/node_modules/debug/Makefile b/tools/node_modules/debug/Makefile new file mode 100644 index 00000000000000..5cf4a5962b8ba3 --- /dev/null +++ b/tools/node_modules/debug/Makefile @@ -0,0 +1,36 @@ + +# get Makefile directory name: http://stackoverflow.com/a/5982798/376773 +THIS_MAKEFILE_PATH:=$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) +THIS_DIR:=$(shell cd $(dir $(THIS_MAKEFILE_PATH));pwd) + +# BIN directory +BIN := $(THIS_DIR)/node_modules/.bin + +# applications +NODE ?= $(shell which node) +NPM ?= $(NODE) $(shell which npm) +BROWSERIFY ?= $(NODE) $(BIN)/browserify + +all: dist/debug.js + +install: node_modules + +clean: + @rm -rf dist + +dist: + @mkdir -p $@ + +dist/debug.js: node_modules browser.js debug.js dist + @$(BROWSERIFY) \ + --standalone debug \ + . > $@ + +distclean: clean + @rm -rf node_modules + +node_modules: package.json + @NODE_ENV= $(NPM) install + @touch node_modules + +.PHONY: all install clean distclean diff --git a/tools/node_modules/debug/Readme.md b/tools/node_modules/debug/Readme.md new file mode 100644 index 00000000000000..b4f45e3cc6a33a --- /dev/null +++ b/tools/node_modules/debug/Readme.md @@ -0,0 +1,188 @@ +# debug + + tiny node.js debugging utility modelled after node core's debugging technique. + +## Installation + +```bash +$ npm install debug +``` + +## Usage + + With `debug` you simply invoke the exported function to generate your debug function, passing it a name which will determine if a noop function is returned, or a decorated `console.error`, so all of the `console` format string goodies you're used to work fine. A unique color is selected per-function for visibility. + +Example _app.js_: + +```js +var debug = require('debug')('http') + , http = require('http') + , name = 'My App'; + +// fake app + +debug('booting %s', name); + +http.createServer(function(req, res){ + debug(req.method + ' ' + req.url); + res.end('hello\n'); +}).listen(3000, function(){ + debug('listening'); +}); + +// fake worker of some kind + +require('./worker'); +``` + +Example _worker.js_: + +```js +var debug = require('debug')('worker'); + +setInterval(function(){ + debug('doing some work'); +}, 1000); +``` + + The __DEBUG__ environment variable is then used to enable these based on space or comma-delimited names. Here are some examples: + + ![debug http and worker](http://f.cl.ly/items/18471z1H402O24072r1J/Screenshot.png) + + ![debug worker](http://f.cl.ly/items/1X413v1a3M0d3C2c1E0i/Screenshot.png) + +#### Windows note + + On Windows the environment variable is set using the `set` command. + + ```cmd + set DEBUG=*,-not_this + ``` + +Then, run the program to be debugged as usual. + +## Millisecond diff + + When actively developing an application it can be useful to see when the time spent between one `debug()` call and the next. Suppose for example you invoke `debug()` before requesting a resource, and after as well, the "+NNNms" will show you how much time was spent between calls. + + ![](http://f.cl.ly/items/2i3h1d3t121M2Z1A3Q0N/Screenshot.png) + + When stdout is not a TTY, `Date#toUTCString()` is used, making it more useful for logging the debug information as shown below: + + ![](http://f.cl.ly/items/112H3i0e0o0P0a2Q2r11/Screenshot.png) + +## Conventions + + If you're using this in one or more of your libraries, you _should_ use the name of your library so that developers may toggle debugging as desired without guessing names. If you have more than one debuggers you _should_ prefix them with your library name and use ":" to separate features. For example "bodyParser" from Connect would then be "connect:bodyParser". + +## Wildcards + + The `*` character may be used as a wildcard. Suppose for example your library has debuggers named "connect:bodyParser", "connect:compress", "connect:session", instead of listing all three with `DEBUG=connect:bodyParser,connect:compress,connect:session`, you may simply do `DEBUG=connect:*`, or to run everything using this module simply use `DEBUG=*`. + + You can also exclude specific debuggers by prefixing them with a "-" character. For example, `DEBUG=*,-connect:*` would include all debuggers except those starting with "connect:". + +## Browser support + + Debug works in the browser as well, currently persisted by `localStorage`. Consider the situation shown below where you have `worker:a` and `worker:b`, and wish to debug both. Somewhere in the code on your page, include: + +```js +window.myDebug = require("debug"); +``` + + ("debug" is a global object in the browser so we give this object a different name.) When your page is open in the browser, type the following in the console: + +```js +myDebug.enable("worker:*") +``` + + Refresh the page. Debug output will continue to be sent to the console until it is disabled by typing `myDebug.disable()` in the console. + +```js +a = debug('worker:a'); +b = debug('worker:b'); + +setInterval(function(){ + a('doing some work'); +}, 1000); + +setInterval(function(){ + b('doing some work'); +}, 1200); +``` + +#### Web Inspector Colors + + Colors are also enabled on "Web Inspectors" that understand the `%c` formatting + option. These are WebKit web inspectors, Firefox ([since version + 31](https://hacks.mozilla.org/2014/05/editable-box-model-multiple-selection-sublime-text-keys-much-more-firefox-developer-tools-episode-31/)) + and the Firebug plugin for Firefox (any version). + + Colored output looks something like: + + ![](https://cloud.githubusercontent.com/assets/71256/3139768/b98c5fd8-e8ef-11e3-862a-f7253b6f47c6.png) + +### stderr vs stdout + +You can set an alternative logging method per-namespace by overriding the `log` method on a per-namespace or globally: + +Example _stdout.js_: + +```js +var debug = require('debug'); +var error = debug('app:error'); + +// by default stderr is used +error('goes to stderr!'); + +var log = debug('app:log'); +// set this namespace to log via console.log +log.log = console.log.bind(console); // don't forget to bind to console! +log('goes to stdout'); +error('still goes to stderr!'); + +// set all output to go via console.info +// overrides all per-namespace log settings +debug.log = console.info.bind(console); +error('now goes to stdout via console.info'); +log('still goes to stdout, but via console.info now'); +``` + +### Save debug output to a file + +You can save all debug statements to a file by piping them. + +Example: + +```bash +$ DEBUG_FD=3 node your-app.js 3> whatever.log +``` + +## Authors + + - TJ Holowaychuk + - Nathan Rajlich + +## License + +(The MIT License) + +Copyright (c) 2014 TJ Holowaychuk <tj@vision-media.ca> + +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. diff --git a/tools/node_modules/debug/bower.json b/tools/node_modules/debug/bower.json new file mode 100644 index 00000000000000..6af573ff5c260d --- /dev/null +++ b/tools/node_modules/debug/bower.json @@ -0,0 +1,28 @@ +{ + "name": "visionmedia-debug", + "main": "dist/debug.js", + "version": "2.2.0", + "homepage": "https://github.com/visionmedia/debug", + "authors": [ + "TJ Holowaychuk " + ], + "description": "visionmedia-debug", + "moduleType": [ + "amd", + "es6", + "globals", + "node" + ], + "keywords": [ + "visionmedia", + "debug" + ], + "license": "MIT", + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "test", + "tests" + ] +} diff --git a/tools/node_modules/debug/browser.js b/tools/node_modules/debug/browser.js new file mode 100644 index 00000000000000..7c76452219939f --- /dev/null +++ b/tools/node_modules/debug/browser.js @@ -0,0 +1,168 @@ + +/** + * This is the web browser implementation of `debug()`. + * + * Expose `debug()` as the module. + */ + +exports = module.exports = require('./debug'); +exports.log = log; +exports.formatArgs = formatArgs; +exports.save = save; +exports.load = load; +exports.useColors = useColors; +exports.storage = 'undefined' != typeof chrome + && 'undefined' != typeof chrome.storage + ? chrome.storage.local + : localstorage(); + +/** + * Colors. + */ + +exports.colors = [ + 'lightseagreen', + 'forestgreen', + 'goldenrod', + 'dodgerblue', + 'darkorchid', + 'crimson' +]; + +/** + * Currently only WebKit-based Web Inspectors, Firefox >= v31, + * and the Firebug extension (any Firefox version) are known + * to support "%c" CSS customizations. + * + * TODO: add a `localStorage` variable to explicitly enable/disable colors + */ + +function useColors() { + // is webkit? http://stackoverflow.com/a/16459606/376773 + return ('WebkitAppearance' in document.documentElement.style) || + // is firebug? http://stackoverflow.com/a/398120/376773 + (window.console && (console.firebug || (console.exception && console.table))) || + // is firefox >= v31? + // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages + (navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31); +} + +/** + * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. + */ + +exports.formatters.j = function(v) { + return JSON.stringify(v); +}; + + +/** + * Colorize log arguments if enabled. + * + * @api public + */ + +function formatArgs() { + var args = arguments; + var useColors = this.useColors; + + args[0] = (useColors ? '%c' : '') + + this.namespace + + (useColors ? ' %c' : ' ') + + args[0] + + (useColors ? '%c ' : ' ') + + '+' + exports.humanize(this.diff); + + if (!useColors) return args; + + var c = 'color: ' + this.color; + args = [args[0], c, 'color: inherit'].concat(Array.prototype.slice.call(args, 1)); + + // the final "%c" is somewhat tricky, because there could be other + // arguments passed either before or after the %c, so we need to + // figure out the correct index to insert the CSS into + var index = 0; + var lastC = 0; + args[0].replace(/%[a-z%]/g, function(match) { + if ('%%' === match) return; + index++; + if ('%c' === match) { + // we only are interested in the *last* %c + // (the user may have provided their own) + lastC = index; + } + }); + + args.splice(lastC, 0, c); + return args; +} + +/** + * Invokes `console.log()` when available. + * No-op when `console.log` is not a "function". + * + * @api public + */ + +function log() { + // this hackery is required for IE8/9, where + // the `console.log` function doesn't have 'apply' + return 'object' === typeof console + && console.log + && Function.prototype.apply.call(console.log, console, arguments); +} + +/** + * Save `namespaces`. + * + * @param {String} namespaces + * @api private + */ + +function save(namespaces) { + try { + if (null == namespaces) { + exports.storage.removeItem('debug'); + } else { + exports.storage.debug = namespaces; + } + } catch(e) {} +} + +/** + * Load `namespaces`. + * + * @return {String} returns the previously persisted debug modes + * @api private + */ + +function load() { + var r; + try { + r = exports.storage.debug; + } catch(e) {} + return r; +} + +/** + * Enable namespaces listed in `localStorage.debug` initially. + */ + +exports.enable(load()); + +/** + * Localstorage attempts to return the localstorage. + * + * This is necessary because safari throws + * when a user disables cookies/localstorage + * and you attempt to access it. + * + * @return {LocalStorage} + * @api private + */ + +function localstorage(){ + try { + return window.localStorage; + } catch (e) {} +} diff --git a/tools/node_modules/debug/component.json b/tools/node_modules/debug/component.json new file mode 100644 index 00000000000000..ca1063724a4498 --- /dev/null +++ b/tools/node_modules/debug/component.json @@ -0,0 +1,19 @@ +{ + "name": "debug", + "repo": "visionmedia/debug", + "description": "small debugging utility", + "version": "2.2.0", + "keywords": [ + "debug", + "log", + "debugger" + ], + "main": "browser.js", + "scripts": [ + "browser.js", + "debug.js" + ], + "dependencies": { + "rauchg/ms.js": "0.7.1" + } +} diff --git a/tools/node_modules/debug/debug.js b/tools/node_modules/debug/debug.js new file mode 100644 index 00000000000000..7571a86058aec0 --- /dev/null +++ b/tools/node_modules/debug/debug.js @@ -0,0 +1,197 @@ + +/** + * This is the common logic for both the Node.js and web browser + * implementations of `debug()`. + * + * Expose `debug()` as the module. + */ + +exports = module.exports = debug; +exports.coerce = coerce; +exports.disable = disable; +exports.enable = enable; +exports.enabled = enabled; +exports.humanize = require('ms'); + +/** + * The currently active debug mode names, and names to skip. + */ + +exports.names = []; +exports.skips = []; + +/** + * Map of special "%n" handling functions, for the debug "format" argument. + * + * Valid key names are a single, lowercased letter, i.e. "n". + */ + +exports.formatters = {}; + +/** + * Previously assigned color. + */ + +var prevColor = 0; + +/** + * Previous log timestamp. + */ + +var prevTime; + +/** + * Select a color. + * + * @return {Number} + * @api private + */ + +function selectColor() { + return exports.colors[prevColor++ % exports.colors.length]; +} + +/** + * Create a debugger with the given `namespace`. + * + * @param {String} namespace + * @return {Function} + * @api public + */ + +function debug(namespace) { + + // define the `disabled` version + function disabled() { + } + disabled.enabled = false; + + // define the `enabled` version + function enabled() { + + var self = enabled; + + // set `diff` timestamp + var curr = +new Date(); + var ms = curr - (prevTime || curr); + self.diff = ms; + self.prev = prevTime; + self.curr = curr; + prevTime = curr; + + // add the `color` if not set + if (null == self.useColors) self.useColors = exports.useColors(); + if (null == self.color && self.useColors) self.color = selectColor(); + + var args = Array.prototype.slice.call(arguments); + + args[0] = exports.coerce(args[0]); + + if ('string' !== typeof args[0]) { + // anything else let's inspect with %o + args = ['%o'].concat(args); + } + + // apply any `formatters` transformations + var index = 0; + args[0] = args[0].replace(/%([a-z%])/g, function(match, format) { + // if we encounter an escaped % then don't increase the array index + if (match === '%%') return match; + index++; + var formatter = exports.formatters[format]; + if ('function' === typeof formatter) { + var val = args[index]; + match = formatter.call(self, val); + + // now we need to remove `args[index]` since it's inlined in the `format` + args.splice(index, 1); + index--; + } + return match; + }); + + if ('function' === typeof exports.formatArgs) { + args = exports.formatArgs.apply(self, args); + } + var logFn = enabled.log || exports.log || console.log.bind(console); + logFn.apply(self, args); + } + enabled.enabled = true; + + var fn = exports.enabled(namespace) ? enabled : disabled; + + fn.namespace = namespace; + + return fn; +} + +/** + * Enables a debug mode by namespaces. This can include modes + * separated by a colon and wildcards. + * + * @param {String} namespaces + * @api public + */ + +function enable(namespaces) { + exports.save(namespaces); + + var split = (namespaces || '').split(/[\s,]+/); + var len = split.length; + + for (var i = 0; i < len; i++) { + if (!split[i]) continue; // ignore empty strings + namespaces = split[i].replace(/\*/g, '.*?'); + if (namespaces[0] === '-') { + exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$')); + } else { + exports.names.push(new RegExp('^' + namespaces + '$')); + } + } +} + +/** + * Disable debug output. + * + * @api public + */ + +function disable() { + exports.enable(''); +} + +/** + * Returns true if the given mode name is enabled, false otherwise. + * + * @param {String} name + * @return {Boolean} + * @api public + */ + +function enabled(name) { + var i, len; + for (i = 0, len = exports.skips.length; i < len; i++) { + if (exports.skips[i].test(name)) { + return false; + } + } + for (i = 0, len = exports.names.length; i < len; i++) { + if (exports.names[i].test(name)) { + return true; + } + } + return false; +} + +/** + * Coerce `val`. + * + * @param {Mixed} val + * @return {Mixed} + * @api private + */ + +function coerce(val) { + if (val instanceof Error) return val.stack || val.message; + return val; +} diff --git a/tools/node_modules/debug/node.js b/tools/node_modules/debug/node.js new file mode 100644 index 00000000000000..1d392a81d6c785 --- /dev/null +++ b/tools/node_modules/debug/node.js @@ -0,0 +1,209 @@ + +/** + * Module dependencies. + */ + +var tty = require('tty'); +var util = require('util'); + +/** + * This is the Node.js implementation of `debug()`. + * + * Expose `debug()` as the module. + */ + +exports = module.exports = require('./debug'); +exports.log = log; +exports.formatArgs = formatArgs; +exports.save = save; +exports.load = load; +exports.useColors = useColors; + +/** + * Colors. + */ + +exports.colors = [6, 2, 3, 4, 5, 1]; + +/** + * The file descriptor to write the `debug()` calls to. + * Set the `DEBUG_FD` env variable to override with another value. i.e.: + * + * $ DEBUG_FD=3 node script.js 3>debug.log + */ + +var fd = parseInt(process.env.DEBUG_FD, 10) || 2; +var stream = 1 === fd ? process.stdout : + 2 === fd ? process.stderr : + createWritableStdioStream(fd); + +/** + * Is stdout a TTY? Colored output is enabled when `true`. + */ + +function useColors() { + var debugColors = (process.env.DEBUG_COLORS || '').trim().toLowerCase(); + if (0 === debugColors.length) { + return tty.isatty(fd); + } else { + return '0' !== debugColors + && 'no' !== debugColors + && 'false' !== debugColors + && 'disabled' !== debugColors; + } +} + +/** + * Map %o to `util.inspect()`, since Node doesn't do that out of the box. + */ + +var inspect = (4 === util.inspect.length ? + // node <= 0.8.x + function (v, colors) { + return util.inspect(v, void 0, void 0, colors); + } : + // node > 0.8.x + function (v, colors) { + return util.inspect(v, { colors: colors }); + } +); + +exports.formatters.o = function(v) { + return inspect(v, this.useColors) + .replace(/\s*\n\s*/g, ' '); +}; + +/** + * Adds ANSI color escape codes if enabled. + * + * @api public + */ + +function formatArgs() { + var args = arguments; + var useColors = this.useColors; + var name = this.namespace; + + if (useColors) { + var c = this.color; + + args[0] = ' \u001b[3' + c + ';1m' + name + ' ' + + '\u001b[0m' + + args[0] + '\u001b[3' + c + 'm' + + ' +' + exports.humanize(this.diff) + '\u001b[0m'; + } else { + args[0] = new Date().toUTCString() + + ' ' + name + ' ' + args[0]; + } + return args; +} + +/** + * Invokes `console.error()` with the specified arguments. + */ + +function log() { + return stream.write(util.format.apply(this, arguments) + '\n'); +} + +/** + * Save `namespaces`. + * + * @param {String} namespaces + * @api private + */ + +function save(namespaces) { + if (null == namespaces) { + // If you set a process.env field to null or undefined, it gets cast to the + // string 'null' or 'undefined'. Just delete instead. + delete process.env.DEBUG; + } else { + process.env.DEBUG = namespaces; + } +} + +/** + * Load `namespaces`. + * + * @return {String} returns the previously persisted debug modes + * @api private + */ + +function load() { + return process.env.DEBUG; +} + +/** + * Copied from `node/src/node.js`. + * + * XXX: It's lame that node doesn't expose this API out-of-the-box. It also + * relies on the undocumented `tty_wrap.guessHandleType()` which is also lame. + */ + +function createWritableStdioStream (fd) { + var stream; + var tty_wrap = process.binding('tty_wrap'); + + // Note stream._type is used for test-module-load-list.js + + switch (tty_wrap.guessHandleType(fd)) { + case 'TTY': + stream = new tty.WriteStream(fd); + stream._type = 'tty'; + + // Hack to have stream not keep the event loop alive. + // See https://github.com/joyent/node/issues/1726 + if (stream._handle && stream._handle.unref) { + stream._handle.unref(); + } + break; + + case 'FILE': + var fs = require('fs'); + stream = new fs.SyncWriteStream(fd, { autoClose: false }); + stream._type = 'fs'; + break; + + case 'PIPE': + case 'TCP': + var net = require('net'); + stream = new net.Socket({ + fd: fd, + readable: false, + writable: true + }); + + // FIXME Should probably have an option in net.Socket to create a + // stream from an existing fd which is writable only. But for now + // we'll just add this hack and set the `readable` member to false. + // Test: ./node test/fixtures/echo.js < /etc/passwd + stream.readable = false; + stream.read = null; + stream._type = 'pipe'; + + // FIXME Hack to have stream not keep the event loop alive. + // See https://github.com/joyent/node/issues/1726 + if (stream._handle && stream._handle.unref) { + stream._handle.unref(); + } + break; + + default: + // Probably an error on in uv_guess_handle() + throw new Error('Implement me. Unknown stream file type!'); + } + + // For supporting legacy API we put the FD here. + stream.fd = fd; + + stream._isStdio = true; + + return stream; +} + +/** + * Enable namespaces listed in `process.env.DEBUG` initially. + */ + +exports.enable(load()); diff --git a/tools/node_modules/debug/package.json b/tools/node_modules/debug/package.json new file mode 100644 index 00000000000000..2d304cc484d010 --- /dev/null +++ b/tools/node_modules/debug/package.json @@ -0,0 +1,97 @@ +{ + "_args": [ + [ + "debug@^2.0.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\remark" + ] + ], + "_from": "debug@>=2.0.0 <3.0.0", + "_id": "debug@2.2.0", + "_inCache": true, + "_location": "/debug", + "_nodeVersion": "0.12.2", + "_npmUser": { + "email": "nathan@tootallnate.net", + "name": "tootallnate" + }, + "_npmVersion": "2.7.4", + "_phantomChildren": {}, + "_requested": { + "name": "debug", + "raw": "debug@^2.0.0", + "rawSpec": "^2.0.0", + "scope": null, + "spec": ">=2.0.0 <3.0.0", + "type": "range" + }, + "_requiredBy": [ + "/remark" + ], + "_resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", + "_shasum": "f87057e995b1a1f6ae6a4960664137bc56f039da", + "_shrinkwrap": null, + "_spec": "debug@^2.0.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\remark", + "author": { + "email": "tj@vision-media.ca", + "name": "TJ Holowaychuk" + }, + "browser": "./browser.js", + "bugs": { + "url": "https://github.com/visionmedia/debug/issues" + }, + "component": { + "scripts": { + "debug/debug.js": "debug.js", + "debug/index.js": "browser.js" + } + }, + "contributors": [ + { + "name": "Nathan Rajlich", + "email": "nathan@tootallnate.net", + "url": "http://n8.io" + } + ], + "dependencies": { + "ms": "0.7.1" + }, + "description": "small debugging utility", + "devDependencies": { + "browserify": "9.0.3", + "mocha": "*" + }, + "directories": {}, + "dist": { + "shasum": "f87057e995b1a1f6ae6a4960664137bc56f039da", + "tarball": "http://registry.npmjs.org/debug/-/debug-2.2.0.tgz" + }, + "gitHead": "b38458422b5aa8aa6d286b10dfe427e8a67e2b35", + "homepage": "https://github.com/visionmedia/debug", + "installable": true, + "keywords": [ + "debug", + "debugger", + "log" + ], + "license": "MIT", + "main": "./node.js", + "maintainers": [ + { + "name": "tjholowaychuk", + "email": "tj@vision-media.ca" + }, + { + "name": "tootallnate", + "email": "nathan@tootallnate.net" + } + ], + "name": "debug", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git://github.com/visionmedia/debug.git" + }, + "scripts": {}, + "version": "2.2.0" +} diff --git a/tools/node_modules/deep-extend/CHANGELOG.md b/tools/node_modules/deep-extend/CHANGELOG.md new file mode 100644 index 00000000000000..f3efe0b22202cd --- /dev/null +++ b/tools/node_modules/deep-extend/CHANGELOG.md @@ -0,0 +1,21 @@ +Changelog +========= + +v0.4.1 +------ + +- Removed test code from npm package + ([see pull request #21](https://github.com/unclechu/node-deep-extend/pull/21)); +- Increased minimal version of Node from 0.4.0 to 0.12.0 + (because can't run tests on lesser version anyway). + +v0.4.0 +------ + +Broken backward compatibility with v0.3.x + +- Fixed bug with extending arrays instead of cloning; +- Deep cloning for arrays; +- Check for own property; +- Fixed some documentation issues; +- Strict JS mode. diff --git a/tools/node_modules/deep-extend/LICENSE b/tools/node_modules/deep-extend/LICENSE new file mode 100644 index 00000000000000..acc4662ea40702 --- /dev/null +++ b/tools/node_modules/deep-extend/LICENSE @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright (c) 2013-2015, Viacheslav Lotsmanov + +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. diff --git a/tools/node_modules/deep-extend/README.md b/tools/node_modules/deep-extend/README.md new file mode 100644 index 00000000000000..cc17c9cd04509d --- /dev/null +++ b/tools/node_modules/deep-extend/README.md @@ -0,0 +1,90 @@ +Deep Extend +=========== + +Recursive object extending. + +[![NPM](https://nodei.co/npm/deep-extend.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/deep-extend/) +[![NPM](https://nodei.co/npm-dl/deep-extend.png?height=3)](https://nodei.co/npm/deep-extend/) + +Install +------- + +```bash +$ npm install deep-extend +``` + +Usage +----- + +```javascript +var deepExtend = require('deep-extend'); +var obj1 = { + a: 1, + b: 2, + d: { + a: 1, + b: [], + c: { test1: 123, test2: 321 } + }, + f: 5, + g: 123, + i: 321, + j: [1, 2] +}; +var obj2 = { + b: 3, + c: 5, + d: { + b: { first: 'one', second: 'two' }, + c: { test2: 222 } + }, + e: { one: 1, two: 2 }, + f: [], + g: (void 0), + h: /abc/g, + i: null, + j: [3, 4] +}; + +deepExtend(obj1, obj2); + +console.log(obj1); +/* +{ a: 1, + b: 3, + d: + { a: 1, + b: { first: 'one', second: 'two' }, + c: { test1: 123, test2: 222 } }, + f: null, + g: undefined, + c: 5, + e: { one: 1, two: 2 }, + h: /abc/g, + i: null, + j: [3, 4] } +*/ +``` + +Unit testing +------------ + +```bash +$ npm test +``` + +Changelog +--------- + +[CHANGELOG.md](./CHANGELOG.md) + +Any issues? +----------- + +Please, report about issues +[here](https://github.com/unclechu/node-deep-extend/issues). + +License +------- + +[MIT](./LICENSE) diff --git a/tools/node_modules/deep-extend/index.js b/tools/node_modules/deep-extend/index.js new file mode 100644 index 00000000000000..762d81e954e161 --- /dev/null +++ b/tools/node_modules/deep-extend/index.js @@ -0,0 +1 @@ +module.exports = require('./lib/deep-extend'); diff --git a/tools/node_modules/deep-extend/lib/deep-extend.js b/tools/node_modules/deep-extend/lib/deep-extend.js new file mode 100644 index 00000000000000..522461d4d9180e --- /dev/null +++ b/tools/node_modules/deep-extend/lib/deep-extend.js @@ -0,0 +1,144 @@ +/*! + * @description Recursive object extending + * @author Viacheslav Lotsmanov + * @license MIT + * + * The MIT License (MIT) + * + * Copyright (c) 2013-2015 Viacheslav Lotsmanov + * + * 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. + */ + +'use strict'; + +function isSpecificValue(val) { + return ( + val instanceof Buffer + || val instanceof Date + || val instanceof RegExp + ) ? true : false; +} + +function cloneSpecificValue(val) { + if (val instanceof Buffer) { + var x = new Buffer(val.length); + val.copy(x); + return x; + } else if (val instanceof Date) { + return new Date(val.getTime()); + } else if (val instanceof RegExp) { + return new RegExp(val); + } else { + throw new Error('Unexpected situation'); + } +} + +/** + * Recursive cloning array. + */ +function deepCloneArray(arr) { + var clone = []; + arr.forEach(function (item, index) { + if (typeof item === 'object' && item !== null) { + if (Array.isArray(item)) { + clone[index] = deepCloneArray(item); + } else if (isSpecificValue(item)) { + clone[index] = cloneSpecificValue(item); + } else { + clone[index] = deepExtend({}, item); + } + } else { + clone[index] = item; + } + }); + return clone; +} + +/** + * Extening object that entered in first argument. + * + * Returns extended object or false if have no target object or incorrect type. + * + * If you wish to clone source object (without modify it), just use empty new + * object as first argument, like this: + * deepExtend({}, yourObj_1, [yourObj_N]); + */ +var deepExtend = module.exports = function (/*obj_1, [obj_2], [obj_N]*/) { + if (arguments.length < 1 || typeof arguments[0] !== 'object') { + return false; + } + + if (arguments.length < 2) { + return arguments[0]; + } + + var target = arguments[0]; + + // convert arguments to array and cut off target object + var args = Array.prototype.slice.call(arguments, 1); + + var val, src, clone; + + args.forEach(function (obj) { + // skip argument if it is array or isn't object + if (typeof obj !== 'object' || Array.isArray(obj)) { + return; + } + + Object.keys(obj).forEach(function (key) { + src = target[key]; // source value + val = obj[key]; // new value + + // recursion prevention + if (val === target) { + return; + + /** + * if new value isn't object then just overwrite by new value + * instead of extending. + */ + } else if (typeof val !== 'object' || val === null) { + target[key] = val; + return; + + // just clone arrays (and recursive clone objects inside) + } else if (Array.isArray(val)) { + target[key] = deepCloneArray(val); + return; + + // custom cloning and overwrite for specific objects + } else if (isSpecificValue(val)) { + target[key] = cloneSpecificValue(val); + return; + + // overwrite by new value if source isn't object or array + } else if (typeof src !== 'object' || src === null || Array.isArray(src)) { + target[key] = deepExtend({}, val); + return; + + // source value and new value is objects both, extending... + } else { + target[key] = deepExtend(src, val); + return; + } + }); + }); + + return target; +} diff --git a/tools/node_modules/deep-extend/package.json b/tools/node_modules/deep-extend/package.json new file mode 100644 index 00000000000000..32446011b682d5 --- /dev/null +++ b/tools/node_modules/deep-extend/package.json @@ -0,0 +1,111 @@ +{ + "_args": [ + [ + "deep-extend@~0.4.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\rc" + ] + ], + "_from": "deep-extend@>=0.4.0 <0.5.0", + "_id": "deep-extend@0.4.1", + "_inCache": true, + "_location": "/deep-extend", + "_nodeVersion": "0.12.0", + "_npmUser": { + "email": "lotsmanov89@gmail.com", + "name": "unclechu" + }, + "_npmVersion": "2.5.1", + "_phantomChildren": {}, + "_requested": { + "name": "deep-extend", + "raw": "deep-extend@~0.4.0", + "rawSpec": "~0.4.0", + "scope": null, + "spec": ">=0.4.0 <0.5.0", + "type": "range" + }, + "_requiredBy": [ + "/rc" + ], + "_resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.4.1.tgz", + "_shasum": "efe4113d08085f4e6f9687759810f807469e2253", + "_shrinkwrap": null, + "_spec": "deep-extend@~0.4.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\rc", + "author": { + "email": "lotsmanov89@gmail.com", + "name": "Viacheslav Lotsmanov" + }, + "bugs": { + "url": "https://github.com/unclechu/node-deep-extend/issues" + }, + "contributors": [ + { + "name": "Romain Prieto", + "url": "https://github.com/rprieto" + }, + { + "name": "Max Maximov", + "url": "https://github.com/maxmaximov" + } + ], + "dependencies": {}, + "description": "Recursive object extending", + "devDependencies": { + "mocha": "^2.2.1", + "should": "^5.2.0" + }, + "directories": { + "lib": "./lib/", + "test": "./test/" + }, + "dist": { + "shasum": "efe4113d08085f4e6f9687759810f807469e2253", + "tarball": "http://registry.npmjs.org/deep-extend/-/deep-extend-0.4.1.tgz" + }, + "engines": { + "iojs": ">=1.0.0", + "node": ">=0.12.0" + }, + "files": [ + "index.js", + "lib/deep-extend.js" + ], + "gitHead": "08e39356bba769744c669eb219a31fee07decd19", + "homepage": "https://github.com/unclechu/node-deep-extend", + "installable": true, + "keywords": [ + "clone", + "deep", + "deep-extend", + "extend", + "json", + "merge", + "recursive", + "xtend" + ], + "license": "MIT", + "licenses": [ + { + "type": "MIT", + "url": "https://raw.githubusercontent.com/unclechu/node-deep-extend/master/LICENSE" + } + ], + "main": "lib/deep-extend.js", + "maintainers": [ + { + "name": "unclechu", + "email": "lotsmanov89@gmail.com" + } + ], + "name": "deep-extend", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git://github.com/unclechu/node-deep-extend.git" + }, + "scripts": { + "test": "mocha" + }, + "version": "0.4.1" +} diff --git a/tools/node_modules/elegant-spinner/index.js b/tools/node_modules/elegant-spinner/index.js new file mode 100644 index 00000000000000..d80c83d8f7737b --- /dev/null +++ b/tools/node_modules/elegant-spinner/index.js @@ -0,0 +1,15 @@ +'use strict'; + +var frames = process.platform === 'win32' ? + ['-', '\\', '|', '/'] : + ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏']; + +module.exports = function () { + var i = 0; + + return function () { + return frames[i = ++i % frames.length]; + }; +}; + +module.exports.frames = frames; diff --git a/tools/node_modules/elegant-spinner/license b/tools/node_modules/elegant-spinner/license new file mode 100644 index 00000000000000..654d0bfe943437 --- /dev/null +++ b/tools/node_modules/elegant-spinner/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tools/node_modules/elegant-spinner/package.json b/tools/node_modules/elegant-spinner/package.json new file mode 100644 index 00000000000000..5eb8b8d8c48542 --- /dev/null +++ b/tools/node_modules/elegant-spinner/package.json @@ -0,0 +1,98 @@ +{ + "_args": [ + [ + "elegant-spinner@^1.0.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\remark" + ] + ], + "_from": "elegant-spinner@>=1.0.0 <2.0.0", + "_id": "elegant-spinner@1.0.1", + "_inCache": true, + "_location": "/elegant-spinner", + "_nodeVersion": "4.1.1", + "_npmUser": { + "email": "sindresorhus@gmail.com", + "name": "sindresorhus" + }, + "_npmVersion": "2.14.4", + "_phantomChildren": {}, + "_requested": { + "name": "elegant-spinner", + "raw": "elegant-spinner@^1.0.0", + "rawSpec": "^1.0.0", + "scope": null, + "spec": ">=1.0.0 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/remark" + ], + "_resolved": "https://registry.npmjs.org/elegant-spinner/-/elegant-spinner-1.0.1.tgz", + "_shasum": "db043521c95d7e303fd8f345bedc3349cfb0729e", + "_shrinkwrap": null, + "_spec": "elegant-spinner@^1.0.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\remark", + "author": { + "email": "sindresorhus@gmail.com", + "name": "Sindre Sorhus", + "url": "sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/sindresorhus/elegant-spinner/issues" + }, + "dependencies": {}, + "description": "Elegant spinner for interactive CLI apps", + "devDependencies": { + "ava": "0.0.4", + "xo": "*" + }, + "directories": {}, + "dist": { + "shasum": "db043521c95d7e303fd8f345bedc3349cfb0729e", + "tarball": "http://registry.npmjs.org/elegant-spinner/-/elegant-spinner-1.0.1.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "669a9813b4ee7d459b982dd623e72672d9f4f114", + "homepage": "https://github.com/sindresorhus/elegant-spinner", + "installable": true, + "keywords": [ + "ansi", + "busy", + "cli", + "console", + "elegant", + "indicator", + "interactive", + "loader", + "loading", + "log", + "logging", + "loiter", + "progress", + "spinner", + "string", + "terminal" + ], + "license": "MIT", + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + } + ], + "name": "elegant-spinner", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "https://github.com/sindresorhus/elegant-spinner" + }, + "scripts": { + "test": "xo && node test.js" + }, + "version": "1.0.1" +} diff --git a/tools/node_modules/elegant-spinner/readme.md b/tools/node_modules/elegant-spinner/readme.md new file mode 100644 index 00000000000000..b9ef39002e7869 --- /dev/null +++ b/tools/node_modules/elegant-spinner/readme.md @@ -0,0 +1,35 @@ +# elegant-spinner [![Build Status](https://travis-ci.org/sindresorhus/elegant-spinner.svg?branch=master)](https://travis-ci.org/sindresorhus/elegant-spinner) + +> Elegant spinner for interactive CLI apps + + + + +## Install + +``` +$ npm install --save elegant-spinner +``` + + +## Usage + +```js +var elegantSpinner = require('elegant-spinner'); +var logUpdate = require('log-update'); +var frame = elegantSpinner(); + +setInterval(function () { + logUpdate(frame()); +}, 50); +``` + + +## Relevant + +- [log-update](https://github.com/sindresorhus/log-update) - Log by overwriting the previous output in the terminal. Useful for rendering progress bars, animations, etc. + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/tools/node_modules/escape-string-regexp/index.js b/tools/node_modules/escape-string-regexp/index.js new file mode 100644 index 00000000000000..7834bf9b24c481 --- /dev/null +++ b/tools/node_modules/escape-string-regexp/index.js @@ -0,0 +1,11 @@ +'use strict'; + +var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g; + +module.exports = function (str) { + if (typeof str !== 'string') { + throw new TypeError('Expected a string'); + } + + return str.replace(matchOperatorsRe, '\\$&'); +}; diff --git a/tools/node_modules/escape-string-regexp/license b/tools/node_modules/escape-string-regexp/license new file mode 100644 index 00000000000000..654d0bfe943437 --- /dev/null +++ b/tools/node_modules/escape-string-regexp/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tools/node_modules/escape-string-regexp/package.json b/tools/node_modules/escape-string-regexp/package.json new file mode 100644 index 00000000000000..aa038f2a462179 --- /dev/null +++ b/tools/node_modules/escape-string-regexp/package.json @@ -0,0 +1,96 @@ +{ + "_args": [ + [ + "escape-string-regexp@^1.0.2", + "C:\\wamp\\www\\node\\tools\\node_modules\\chalk" + ] + ], + "_from": "escape-string-regexp@>=1.0.2 <2.0.0", + "_id": "escape-string-regexp@1.0.4", + "_inCache": true, + "_location": "/escape-string-regexp", + "_nodeVersion": "4.2.1", + "_npmUser": { + "email": "sindresorhus@gmail.com", + "name": "sindresorhus" + }, + "_npmVersion": "2.14.7", + "_phantomChildren": {}, + "_requested": { + "name": "escape-string-regexp", + "raw": "escape-string-regexp@^1.0.2", + "rawSpec": "^1.0.2", + "scope": null, + "spec": ">=1.0.2 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/chalk" + ], + "_resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.4.tgz", + "_shasum": "b85e679b46f72d03fbbe8a3bf7259d535c21b62f", + "_shrinkwrap": null, + "_spec": "escape-string-regexp@^1.0.2", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\chalk", + "author": { + "email": "sindresorhus@gmail.com", + "name": "Sindre Sorhus", + "url": "sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/sindresorhus/escape-string-regexp/issues" + }, + "dependencies": {}, + "description": "Escape RegExp special characters", + "devDependencies": { + "ava": "*", + "xo": "*" + }, + "directories": {}, + "dist": { + "shasum": "b85e679b46f72d03fbbe8a3bf7259d535c21b62f", + "tarball": "http://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.4.tgz" + }, + "engines": { + "node": ">=0.8.0" + }, + "files": [ + "index.js" + ], + "gitHead": "e9ca6832a9506ca26402cb0e6dc95efcf35b0b97", + "homepage": "https://github.com/sindresorhus/escape-string-regexp", + "installable": true, + "keywords": [ + "characters", + "escape", + "expression", + "re", + "regex", + "regexp", + "regular", + "special", + "str", + "string" + ], + "license": "MIT", + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + }, + { + "name": "jbnicolai", + "email": "jappelman@xebia.com" + } + ], + "name": "escape-string-regexp", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "https://github.com/sindresorhus/escape-string-regexp" + }, + "scripts": { + "test": "xo && ava" + }, + "version": "1.0.4" +} diff --git a/tools/node_modules/escape-string-regexp/readme.md b/tools/node_modules/escape-string-regexp/readme.md new file mode 100644 index 00000000000000..87ac82d5ef8bc9 --- /dev/null +++ b/tools/node_modules/escape-string-regexp/readme.md @@ -0,0 +1,27 @@ +# escape-string-regexp [![Build Status](https://travis-ci.org/sindresorhus/escape-string-regexp.svg?branch=master)](https://travis-ci.org/sindresorhus/escape-string-regexp) + +> Escape RegExp special characters + + +## Install + +``` +$ npm install --save escape-string-regexp +``` + + +## Usage + +```js +const escapeStringRegexp = require('escape-string-regexp'); + +const escapedString = escapeStringRegexp('how much $ for a unicorn?'); +//=> 'how much \$ for a unicorn\?' + +new RegExp(escapedString); +``` + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/tools/node_modules/eslint-plugin-markdown/LICENSE b/tools/node_modules/eslint-plugin-markdown/LICENSE new file mode 100644 index 00000000000000..21a6ce7ca8480f --- /dev/null +++ b/tools/node_modules/eslint-plugin-markdown/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 Brandon Mills. All rights reserved. + +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. diff --git a/tools/node_modules/eslint-plugin-markdown/README.md b/tools/node_modules/eslint-plugin-markdown/README.md new file mode 100644 index 00000000000000..58f84d3beb19f4 --- /dev/null +++ b/tools/node_modules/eslint-plugin-markdown/README.md @@ -0,0 +1,82 @@ +# eslint-plugin-markdown + +[![Join the chat at https://gitter.im/eslint/eslint-plugin-markdown](https://badges.gitter.im/eslint/eslint-plugin-markdown.svg)](https://gitter.im/eslint/eslint-plugin-markdown?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) + +An [ESLint](http://eslint.org/) plugin to lint JavaScript in Markdown. + +Supported extensions are `.markdown`, `.mdown`, `.mkdn`, and `.md`. + +## Usage + +Install the plugin: + +```sh +npm install --save-dev eslint eslint-plugin-markdown +``` + +Add it to your `.eslintrc`: + +```json +{ + "plugins": [ + "markdown" + ] +} +``` + +Run ESLint on `.md` files: + +```sh +eslint --ext md . +``` + +It will lint `js`, `javascript`, `jsx`, or `node` [fenced code blocks](https://help.github.com/articles/github-flavored-markdown/#fenced-code-blocks) in your Markdown documents: + + ```js + // This gets linted + var answer = 6 * 7; + console.log(answer); + ``` + + ```JavaScript + // This also gets linted + + /* eslint quotes: [2, "double"] */ + + function hello() { + console.log("Hello, world!"); + } + hello(); + ``` + + ```jsx + // This gets linted too + var div =
    ; + ``` + + ```node + // And this + console.log(process.version); + ``` + +Blocks that don't specify either `js`, `javascript`, `jsx`, or `node` syntax are ignored: + + ``` + This is plain text and doesn't get linted. + ``` + + ```python + print("This doesn't get linted either.") + ``` + +## Contributing + +```sh +$ git clone https://github.com/eslint/eslint-plugin-markdown.git +$ cd eslint-plugin-markdown +$ npm link +$ npm link eslint-plugin-markdown +$ npm test +``` + +This project follows the [ESLint contribution guidelines](http://eslint.org/docs/developer-guide/contributing.html). diff --git a/tools/node_modules/eslint-plugin-markdown/index.js b/tools/node_modules/eslint-plugin-markdown/index.js new file mode 100644 index 00000000000000..e2cedf8ee50569 --- /dev/null +++ b/tools/node_modules/eslint-plugin-markdown/index.js @@ -0,0 +1,3 @@ +"use strict"; + +module.exports = require("./lib"); diff --git a/tools/node_modules/eslint-plugin-markdown/lib/index.js b/tools/node_modules/eslint-plugin-markdown/lib/index.js new file mode 100644 index 00000000000000..4cd078d110bcee --- /dev/null +++ b/tools/node_modules/eslint-plugin-markdown/lib/index.js @@ -0,0 +1,12 @@ +"use strict"; + +var processor = require("./processor"); + +module.exports = { + "processors": { + ".markdown": processor, + ".mdown": processor, + ".mkdn": processor, + ".md": processor + } +}; diff --git a/tools/node_modules/eslint-plugin-markdown/lib/processor.js b/tools/node_modules/eslint-plugin-markdown/lib/processor.js new file mode 100644 index 00000000000000..15f9b8e67e1ebe --- /dev/null +++ b/tools/node_modules/eslint-plugin-markdown/lib/processor.js @@ -0,0 +1,80 @@ +/** + * @fileoverview Processes Markdown files for consumption by ESLint. + * @author Brandon Mills + * @copyright 2015 Brandon Mills. All rights reserved. + * @copyright 2015 Ian VanSchooten. All rights reserved. + * See LICENSE in root directory for full license. + */ + +"use strict"; + +var assign = require("object-assign"); +var remark = require("remark"); + +var SUPPORTED_SYNTAXES = ["js", "javascript", "node", "jsx"]; + +var blocks = []; + +/** + * Performs a depth-first traversal of the Markdown AST. + * @param {ASTNode} node A Markdown AST node. + * @param {object} callbacks A map of node types to callbacks. + * @returns {void} + */ +function traverse(node, callbacks) { + var i; + + if (callbacks[node.type]) { + callbacks[node.type](node); + } + + if (typeof node.children !== "undefined") { + for (i = 0; i < node.children.length; i++) { + traverse(node.children[i], callbacks); + } + } +} + +/** + * Extracts lintable JavaScript code blocks from Markdown text. + * @param {string} text The text of the file. + * @returns {[string]} Code blocks to lint. + */ +function preprocess(text) { + var ast = remark.parse(text); + + blocks = []; + traverse(ast, { + "code": function(node) { + if (node.lang && SUPPORTED_SYNTAXES.indexOf(node.lang.toLowerCase()) >= 0) { + blocks.push(node); + } + } + }); + + return blocks.map(function(block) { + return block.value; + }); +} + +/** + * Transforms generated messages for output. + * @param {Array} messages An array containing one array of messages + * for each code block returned from `preprocess`. + * @returns {Message[]} A flattened array of messages with mapped locations. + */ +function postprocess(messages) { + return [].concat.apply([], messages.map(function(group, i) { + return group.map(function(message) { + return assign({}, message, { + line: message.line + blocks[i].position.start.line, + column: message.column + blocks[i].position.indent[message.line - 1] - 1 + }); + }); + })); +} + +module.exports = { + preprocess: preprocess, + postprocess: postprocess +}; diff --git a/tools/node_modules/eslint-plugin-markdown/package.json b/tools/node_modules/eslint-plugin-markdown/package.json new file mode 100644 index 00000000000000..c1c8e02afba817 --- /dev/null +++ b/tools/node_modules/eslint-plugin-markdown/package.json @@ -0,0 +1,92 @@ +{ + "_args": [ + [ + "eslint-plugin-markdown", + "C:\\wamp\\www\\node\\tools" + ] + ], + "_from": "eslint-plugin-markdown@*", + "_id": "eslint-plugin-markdown@1.0.0-beta.1", + "_inCache": true, + "_location": "/eslint-plugin-markdown", + "_nodeVersion": "5.4.1", + "_npmUser": { + "email": "mills.brandont@gmail.com", + "name": "btmills" + }, + "_npmVersion": "3.3.12", + "_phantomChildren": {}, + "_requested": { + "name": "eslint-plugin-markdown", + "raw": "eslint-plugin-markdown", + "rawSpec": "", + "scope": null, + "spec": "*", + "type": "range" + }, + "_requiredBy": [ + "#USER" + ], + "_resolved": "https://registry.npmjs.org/eslint-plugin-markdown/-/eslint-plugin-markdown-1.0.0-beta.1.tgz", + "_shasum": "48b0b35f2df1bafa060b8ecc6dafba8181e35ef9", + "_shrinkwrap": null, + "_spec": "eslint-plugin-markdown", + "_where": "C:\\wamp\\www\\node\\tools", + "author": { + "name": "Brandon Mills", + "url": "https://github.com/btmills" + }, + "bugs": { + "url": "https://github.com/eslint/eslint-plugin-markdown/issues" + }, + "dependencies": { + "object-assign": "^4.0.1", + "remark": "^3.2.0" + }, + "description": "An ESLint plugin to lint JavaScript in Markdown code fences.", + "devDependencies": { + "chai": "^3.0.0", + "eslint": "^2.0.0-beta.1", + "eslint-config-eslint": "^2.0.0", + "mocha": "^2.2.5" + }, + "directories": {}, + "dist": { + "shasum": "48b0b35f2df1bafa060b8ecc6dafba8181e35ef9", + "tarball": "http://registry.npmjs.org/eslint-plugin-markdown/-/eslint-plugin-markdown-1.0.0-beta.1.tgz" + }, + "files": [ + "LICENSE", + "README.md", + "index.js", + "lib/*.js" + ], + "gitHead": "a4d25cd5c1d7ef2ac6c94cd8683140a1a963dbde", + "homepage": "https://github.com/eslint/eslint-plugin-markdown#readme", + "installable": true, + "keywords": [ + "eslint", + "eslintplugin", + "lint", + "linter", + "markdown" + ], + "license": "MIT", + "main": "index.js", + "maintainers": [ + { + "name": "btmills", + "email": "mills.brandont@gmail.com" + } + ], + "name": "eslint-plugin-markdown", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git+https://github.com/eslint/eslint-plugin-markdown.git" + }, + "scripts": { + "test": "eslint --ext .js --ext .md . && mocha tests" + }, + "version": "1.0.0-beta.1" +} diff --git a/tools/node_modules/exit-hook/index.js b/tools/node_modules/exit-hook/index.js new file mode 100644 index 00000000000000..e18013fdb7c87a --- /dev/null +++ b/tools/node_modules/exit-hook/index.js @@ -0,0 +1,30 @@ +'use strict'; + +var cbs = []; +var called = false; + +function exit(exit, signal) { + if (called) { + return; + } + + called = true; + + cbs.forEach(function (el) { + el(); + }); + + if (exit === true) { + process.exit(128 + signal); + } +}; + +module.exports = function (cb) { + cbs.push(cb); + + if (cbs.length === 1) { + process.once('exit', exit); + process.once('SIGINT', exit.bind(null, true, 2)); + process.once('SIGTERM', exit.bind(null, true, 15)); + } +}; diff --git a/tools/node_modules/exit-hook/package.json b/tools/node_modules/exit-hook/package.json new file mode 100644 index 00000000000000..31e6fd8da4eb9f --- /dev/null +++ b/tools/node_modules/exit-hook/package.json @@ -0,0 +1,92 @@ +{ + "_args": [ + [ + "exit-hook@^1.0.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\restore-cursor" + ] + ], + "_from": "exit-hook@>=1.0.0 <2.0.0", + "_id": "exit-hook@1.1.1", + "_inCache": true, + "_location": "/exit-hook", + "_npmUser": { + "email": "sindresorhus@gmail.com", + "name": "sindresorhus" + }, + "_npmVersion": "1.4.9", + "_phantomChildren": {}, + "_requested": { + "name": "exit-hook", + "raw": "exit-hook@^1.0.0", + "rawSpec": "^1.0.0", + "scope": null, + "spec": ">=1.0.0 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/restore-cursor" + ], + "_resolved": "https://registry.npmjs.org/exit-hook/-/exit-hook-1.1.1.tgz", + "_shasum": "f05ca233b48c05d54fff07765df8507e95c02ff8", + "_shrinkwrap": null, + "_spec": "exit-hook@^1.0.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\restore-cursor", + "author": { + "email": "sindresorhus@gmail.com", + "name": "Sindre Sorhus", + "url": "http://sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/sindresorhus/exit-hook/issues" + }, + "dependencies": {}, + "description": "Run some code when the process exits", + "devDependencies": { + "ava": "0.0.4" + }, + "directories": {}, + "dist": { + "shasum": "f05ca233b48c05d54fff07765df8507e95c02ff8", + "tarball": "http://registry.npmjs.org/exit-hook/-/exit-hook-1.1.1.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "homepage": "https://github.com/sindresorhus/exit-hook", + "installable": true, + "keywords": [ + "event", + "exit", + "graceful", + "handler", + "hook", + "kill", + "process", + "quit", + "shutdown", + "sigint", + "sigterm", + "stop", + "terminate" + ], + "license": "MIT", + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + } + ], + "name": "exit-hook", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git://github.com/sindresorhus/exit-hook" + }, + "scripts": { + "test": "node test.js" + }, + "version": "1.1.1" +} diff --git a/tools/node_modules/exit-hook/readme.md b/tools/node_modules/exit-hook/readme.md new file mode 100644 index 00000000000000..4dc64b9c5f42b0 --- /dev/null +++ b/tools/node_modules/exit-hook/readme.md @@ -0,0 +1,40 @@ +# exit-hook [![Build Status](https://travis-ci.org/sindresorhus/exit-hook.svg?branch=master)](https://travis-ci.org/sindresorhus/exit-hook) + +> Run some code when the process exits + +The `process.on('exit')` event doesn't catch all the ways a process can exit. + +Useful for cleaning up. + + +## Install + +```sh +$ npm install --save exit-hook +``` + + +## Usage + +```js +var exitHook = require('exit-hook'); + +exitHook(function () { + console.log('exiting'); +}); + +// you can add multiple hooks, even across files +exitHook(function () { + console.log('exiting 2'); +}); + +throw new Error('unicorns'); + +//=> exiting +//=> exiting 2 +``` + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/tools/node_modules/expand-brackets/LICENSE b/tools/node_modules/expand-brackets/LICENSE new file mode 100644 index 00000000000000..33754daecd9a43 --- /dev/null +++ b/tools/node_modules/expand-brackets/LICENSE @@ -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. diff --git a/tools/node_modules/expand-brackets/README.md b/tools/node_modules/expand-brackets/README.md new file mode 100644 index 00000000000000..7eea4ed1499e25 --- /dev/null +++ b/tools/node_modules/expand-brackets/README.md @@ -0,0 +1,89 @@ +# expand-brackets [![NPM version](https://badge.fury.io/js/expand-brackets.svg)](http://badge.fury.io/js/expand-brackets) + +> Expand POSIX bracket expressions (character classes) in glob patterns. + +Install with [npm](https://www.npmjs.com/) + +```sh +$ npm i expand-brackets --save +``` + +## Usage + +```js +var brackets = require('expand-brackets'); + +brackets('[![:lower:]]'); +//=> '[^a-z]' +``` + +## .isMatch + +Return true if the given string matches the bracket expression: + +```js +brackets.isMatch('A', '[![:lower:]]'); +//=> true + +brackets.isMatch('a', '[![:lower:]]'); +//=> false +``` + +## .makeRe + +Make a regular expression from a bracket expression: + +```js +brackets.makeRe('[![:lower:]]'); +//=> /[^a-z]/ +``` + +The following named POSIX bracket expressions are supported: + +* `[:alnum:]`: Alphanumeric characters (`a-zA-Z0-9]`) +* `[:alpha:]`: Alphabetic characters (`a-zA-Z]`) +* `[:blank:]`: Space and tab (`[ t]`) +* `[:digit:]`: Digits (`[0-9]`) +* `[:lower:]`: Lowercase letters (`[a-z]`) +* `[:punct:]`: Punctuation and symbols. (`[!"#$%&'()*+, -./:;<=>?@ [\]^_``{|}~]`) +* `[:upper:]`: Uppercase letters (`[A-Z]`) +* `[:word:]`: Word characters (letters, numbers and underscores) (`[A-Za-z0-9_]`) +* `[:xdigit:]`: Hexadecimal digits (`[A-Fa-f0-9]`) + +Collating sequences are not supported. + +## Related projects + +* [extglob](https://github.com/jonschlinkert/extglob): Convert extended globs to regex-compatible strings. Add (almost) the expressive power of regular expressions to… [more](https://github.com/jonschlinkert/extglob) +* [is-glob](https://github.com/jonschlinkert/is-glob): Returns `true` if the given string looks like a glob pattern. +* [is-extglob](https://github.com/jonschlinkert/is-extglob): Returns true if a string has an extglob. +* [is-posix-bracket](https://github.com/jonschlinkert/is-posix-bracket): Returns true if the given string is a POSIX bracket expression (POSIX character class). +* [micromatch](https://github.com/jonschlinkert/micromatch): Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch. Just… [more](https://github.com/jonschlinkert/micromatch) + +## 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/expand-brackets/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 01, 2015._ \ No newline at end of file diff --git a/tools/node_modules/expand-brackets/index.js b/tools/node_modules/expand-brackets/index.js new file mode 100644 index 00000000000000..0207042b197ac5 --- /dev/null +++ b/tools/node_modules/expand-brackets/index.js @@ -0,0 +1,157 @@ +/*! + * expand-brackets + * + * Copyright (c) 2015 Jon Schlinkert. + * Licensed under the MIT license. + */ + +'use strict'; + +/** + * POSIX character classes + */ + +var POSIX = { + alnum: 'a-zA-Z0-9', + alpha: 'a-zA-Z', + blank: ' \\t', + cntrl: '\\x00-\\x1F\\x7F', + digit: '0-9', + graph: '\\x21-\\x7E', + lower: 'a-z', + print: '\\x20-\\x7E', + punct: '!"#$%&\'()\\*+,-./:;<=>?@[\\]^_`{|}~', + space: ' \\t\\r\\n\\v\\f', + upper: 'A-Z', + word: 'A-Za-z0-9_', + xdigit: 'A-Fa-f0-9', +}; + +/** + * Expose `brackets` + */ + +module.exports = brackets; + +function brackets(str) { + var negated = false; + if (str.indexOf('[^') !== -1) { + negated = true; + str = str.split('[^').join('['); + } + if (str.indexOf('[!') !== -1) { + negated = true; + str = str.split('[!').join('['); + } + + var a = str.split('['); + var b = str.split(']'); + var imbalanced = a.length !== b.length; + + var parts = str.split(/(?::\]\[:|\[?\[:|:\]\]?)/); + var len = parts.length, i = 0; + var end = '', beg = ''; + var res = []; + + // start at the end (innermost) first + while (len--) { + var inner = parts[i++]; + if (inner === '^[!' || inner === '[!') { + inner = ''; + negated = true; + } + + var prefix = negated ? '^' : ''; + var ch = POSIX[inner]; + + if (ch) { + res.push('[' + prefix + ch + ']'); + } else if (inner) { + if (/^\[?\w-\w\]?$/.test(inner)) { + if (i === parts.length) { + res.push('[' + prefix + inner); + } else if (i === 1) { + res.push(prefix + inner + ']'); + } else { + res.push(prefix + inner); + } + } else { + if (i === 1) { + beg += inner; + } else if (i === parts.length) { + end += inner; + } else { + res.push('[' + prefix + inner + ']'); + } + } + } + } + + var result = res.join('|'); + var rlen = res.length || 1; + if (rlen > 1) { + result = '(?:' + result + ')'; + rlen = 1; + } + if (beg) { + rlen++; + if (beg.charAt(0) === '[') { + if (imbalanced) { + beg = '\\[' + beg.slice(1); + } else { + beg += ']'; + } + } + result = beg + result; + } + if (end) { + rlen++; + if (end.slice(-1) === ']') { + if (imbalanced) { + end = end.slice(0, end.length - 1) + '\\]'; + } else { + end = '[' + end; + } + } + result += end; + } + + if (rlen > 1) { + result = result.split('][').join(']|['); + if (result.indexOf('|') !== -1 && !/\(\?/.test(result)) { + result = '(?:' + result + ')'; + } + } + + result = result.replace(/\[+=|=\]+/g, '\\b'); + return result; +} + +brackets.makeRe = function (pattern) { + try { + return new RegExp(brackets(pattern)); + } catch (err) {} +}; + +brackets.isMatch = function (str, pattern) { + try { + return brackets.makeRe(pattern).test(str); + } catch (err) { + return false; + } +}; + +brackets.match = function (arr, pattern) { + var len = arr.length, i = 0; + var res = arr.slice(); + + var re = brackets.makeRe(pattern); + while (i < len) { + var ele = arr[i++]; + if (!re.test(ele)) { + continue; + } + res.splice(i, 1); + } + return res; +}; diff --git a/tools/node_modules/expand-brackets/package.json b/tools/node_modules/expand-brackets/package.json new file mode 100644 index 00000000000000..7d42759892ec0e --- /dev/null +++ b/tools/node_modules/expand-brackets/package.json @@ -0,0 +1,105 @@ +{ + "_args": [ + [ + "expand-brackets@^0.1.4", + "C:\\wamp\\www\\node\\tools\\node_modules\\micromatch" + ] + ], + "_from": "expand-brackets@>=0.1.4 <0.2.0", + "_id": "expand-brackets@0.1.4", + "_inCache": true, + "_location": "/expand-brackets", + "_nodeVersion": "0.12.4", + "_npmUser": { + "email": "github@sellside.com", + "name": "jonschlinkert" + }, + "_npmVersion": "2.10.1", + "_phantomChildren": {}, + "_requested": { + "name": "expand-brackets", + "raw": "expand-brackets@^0.1.4", + "rawSpec": "^0.1.4", + "scope": null, + "spec": ">=0.1.4 <0.2.0", + "type": "range" + }, + "_requiredBy": [ + "/micromatch" + ], + "_resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-0.1.4.tgz", + "_shasum": "797b9e484101205f418cecaec6312c132f51e2ae", + "_shrinkwrap": null, + "_spec": "expand-brackets@^0.1.4", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\micromatch", + "author": { + "name": "Jon Schlinkert", + "url": "https://github.com/jonschlinkert" + }, + "bugs": { + "url": "https://github.com/jonschlinkert/expand-brackets/issues" + }, + "dependencies": {}, + "description": "Expand POSIX bracket expressions (character classes) in glob patterns.", + "devDependencies": { + "mocha": "^2.2.5", + "should": "^7.0.2" + }, + "directories": {}, + "dist": { + "shasum": "797b9e484101205f418cecaec6312c132f51e2ae", + "tarball": "http://registry.npmjs.org/expand-brackets/-/expand-brackets-0.1.4.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "38475d3e4973b8496812e39983d2945a78d0ade3", + "homepage": "https://github.com/jonschlinkert/expand-brackets", + "installable": true, + "keywords": [ + "bracket", + "character class", + "expression", + "posix" + ], + "license": "MIT", + "main": "index.js", + "maintainers": [ + { + "name": "jonschlinkert", + "email": "github@sellside.com" + }, + { + "name": "es128", + "email": "elan.shanker+npm@gmail.com" + }, + { + "name": "doowb", + "email": "brian.woodward@gmail.com" + } + ], + "name": "expand-brackets", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git+https://github.com/jonschlinkert/expand-brackets.git" + }, + "scripts": { + "test": "mocha" + }, + "verb": { + "related": { + "list": [ + "extglob", + "is-extglob", + "is-glob", + "is-posix-bracket", + "micromatch" + ] + } + }, + "version": "0.1.4" +} diff --git a/tools/node_modules/expand-range/LICENSE b/tools/node_modules/expand-range/LICENSE new file mode 100644 index 00000000000000..5a9956a75dd7f2 --- /dev/null +++ b/tools/node_modules/expand-range/LICENSE @@ -0,0 +1,24 @@ +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. diff --git a/tools/node_modules/expand-range/README.md b/tools/node_modules/expand-range/README.md new file mode 100644 index 00000000000000..b34f0f39346aac --- /dev/null +++ b/tools/node_modules/expand-range/README.md @@ -0,0 +1,107 @@ +# expand-range [![NPM version](https://badge.fury.io/js/expand-range.svg)](http://badge.fury.io/js/expand-range) + +> Fast, bash-like range expansion. Expand a range of numbers or letters, uppercase or lowercase. See the benchmarks. Used by micromatch. + +## Install with [npm](npmjs.org) + +```bash +npm i expand-range --save +``` + +Wraps [fill-range] to do range expansion using `..` separated strings. See [fill-range] for the full list of options and features. + + +## Example usage + +```js +var expand = require('expand-range'); +``` + +**Params** + +```js +expand(start, stop, increment); +``` + + - `start`: the number or letter to start with + - `end`: the number or letter to end with + - `increment`: optionally pass the increment to use. works for letters or numbers + +**Examples** + +```js +expand('a..e') +//=> ['a', 'b', 'c', 'd', 'e'] + +expand('a..e..2') +//=> ['a', 'c', 'e'] + +expand('A..E..2') +//=> ['A', 'C', 'E'] + +expand('1..3') +//=> ['1', '2', '3'] + +expand('0..-5') +//=> [ '0', '-1', '-2', '-3', '-4', '-5' ] + +expand('-9..9..3') +//=> [ '-9', '-6', '-3', '0', '3', '6', '9' ]) + +expand('-1..-10..-2') +//=> [ '-1', '-3', '-5', '-7', '-9' ] + +expand('1..10..2') +//=> [ '1', '3', '5', '7', '9' ] +``` + + +### Custom function + +Optionally pass a custom function as the second argument: + +```js +expand('a..e', function (val, isNumber, pad, i) { + if (!isNumber) { + return String.fromCharCode(val) + i; + } + return val; +}); +//=> ['a0', 'b1', 'c2', 'd3', 'e4'] +``` + +## Related + +- [micromatch]: wildcard/glob matcher for javascript. a faster alternative to minimatch. +- [fill-range]: the library this depends on for core functionality +- [braces]: this library is used in braces, a fast Brash-like brace expansion lib. + +## Run tests + +Install dev dependencies + +```bash +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/expand-range/issues). + +## Author + +**Jon Schlinkert** + ++ [github/jonschlinkert](https://github.com/jonschlinkert) ++ [twitter/jonschlinkert](http://twitter.com/jonschlinkert) + +## License +Copyright (c) 2015 Jon Schlinkert +Released under the MIT license + +*** + +_This file was generated by [verb](https://github.com/assemble/verb) on January 30, 2015._ + +[fill-range]: https://github.com/jonschlinkert/fill-range +[micromatch]: https://github.com/jonschlinkert/micromatch +[braces]: https://github.com/jonschlinkert/braces \ No newline at end of file diff --git a/tools/node_modules/expand-range/index.js b/tools/node_modules/expand-range/index.js new file mode 100644 index 00000000000000..ac1a44e236edfa --- /dev/null +++ b/tools/node_modules/expand-range/index.js @@ -0,0 +1,43 @@ +/*! + * expand-range + * + * Copyright (c) 2014-2015, Jon Schlinkert. + * Licensed under the MIT license. + */ + +'use strict'; + +var fill = require('fill-range'); + +module.exports = function expandRange(str, options, fn) { + if (typeof str !== 'string') { + throw new TypeError('expand-range expects a string.'); + } + + if (typeof options === 'function') { + fn = options; + options = {}; + } + + if (typeof options === 'boolean') { + options = {}; + options.makeRe = true; + } + + // create arguments to pass to fill-range + var opts = options || {}; + var args = str.split('..'); + var len = args.length; + if (len > 3) { return str; } + + // if only one argument, it can't expand so return it + if (len === 1) { return args; } + + // if `true`, tell fill-range to regexify the string + if (typeof fn === 'boolean' && fn === true) { + opts.makeRe = true; + } + + args.push(opts); + return fill.apply(fill, args.concat(fn)); +}; diff --git a/tools/node_modules/expand-range/package.json b/tools/node_modules/expand-range/package.json new file mode 100644 index 00000000000000..12c55b656cd0eb --- /dev/null +++ b/tools/node_modules/expand-range/package.json @@ -0,0 +1,106 @@ +{ + "_args": [ + [ + "expand-range@^1.8.1", + "C:\\wamp\\www\\node\\tools\\node_modules\\braces" + ] + ], + "_from": "expand-range@>=1.8.1 <2.0.0", + "_id": "expand-range@1.8.1", + "_inCache": true, + "_location": "/expand-range", + "_nodeVersion": "0.12.0", + "_npmUser": { + "email": "github@sellside.com", + "name": "jonschlinkert" + }, + "_npmVersion": "2.5.1", + "_phantomChildren": {}, + "_requested": { + "name": "expand-range", + "raw": "expand-range@^1.8.1", + "rawSpec": "^1.8.1", + "scope": null, + "spec": ">=1.8.1 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/braces" + ], + "_resolved": "https://registry.npmjs.org/expand-range/-/expand-range-1.8.1.tgz", + "_shasum": "acbd63e56efd9139722b755f099b9db5ac1f33f6", + "_shrinkwrap": null, + "_spec": "expand-range@^1.8.1", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\braces", + "author": { + "name": "Jon Schlinkert", + "url": "https://github.com/jonschlinkert" + }, + "bugs": { + "url": "https://github.com/jonschlinkert/expand-range/issues" + }, + "dependencies": { + "fill-range": "^2.1.0" + }, + "description": "Fast, bash-like range expansion. Expand a range of numbers or letters, uppercase or lowercase. See the benchmarks. Used by micromatch.", + "devDependencies": { + "benchmarked": "^0.1.1", + "brace-expansion": "^1.1.0", + "glob": "^4.3.2", + "minimatch": "^2.0.1", + "mocha": "*", + "should": "^4.1.0" + }, + "directories": {}, + "dist": { + "shasum": "acbd63e56efd9139722b755f099b9db5ac1f33f6", + "tarball": "http://registry.npmjs.org/expand-range/-/expand-range-1.8.1.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "de01a2ae06e6fe9c69812595c439870cca71839f", + "homepage": "https://github.com/jonschlinkert/expand-range", + "installable": true, + "keywords": [ + "alpha", + "alphabetical", + "bash", + "brace", + "expand", + "expansion", + "glob", + "match", + "matches", + "matching", + "number", + "numerical", + "range", + "ranges", + "sh" + ], + "license": { + "type": "MIT", + "url": "https://github.com/jonschlinkert/expand-range/blob/master/LICENSE-MIT" + }, + "main": "index.js", + "maintainers": [ + { + "name": "jonschlinkert", + "email": "github@sellside.com" + } + ], + "name": "expand-range", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git://github.com/jonschlinkert/expand-range.git" + }, + "scripts": { + "test": "mocha -R spec" + }, + "version": "1.8.1" +} diff --git a/tools/node_modules/extend.js/.npmignore b/tools/node_modules/extend.js/.npmignore new file mode 100644 index 00000000000000..f1250e584c94b8 --- /dev/null +++ b/tools/node_modules/extend.js/.npmignore @@ -0,0 +1,4 @@ +support +test +examples +*.sock diff --git a/tools/node_modules/extend.js/History.md b/tools/node_modules/extend.js/History.md new file mode 100644 index 00000000000000..12f7db0ebaad45 --- /dev/null +++ b/tools/node_modules/extend.js/History.md @@ -0,0 +1,12 @@ + +0.0.2 / 2014-12-04 +================== + + * add the .js + * ocd + * component: Fix repo + +0.0.1 / 2010-01-03 +================== + + * Initial release diff --git a/tools/node_modules/extend.js/Makefile b/tools/node_modules/extend.js/Makefile new file mode 100644 index 00000000000000..4e9c8d36ebcd2f --- /dev/null +++ b/tools/node_modules/extend.js/Makefile @@ -0,0 +1,7 @@ + +test: + @./node_modules/.bin/mocha \ + --require should \ + --reporter spec + +.PHONY: test \ No newline at end of file diff --git a/tools/node_modules/extend.js/Readme.md b/tools/node_modules/extend.js/Readme.md new file mode 100644 index 00000000000000..cfe9d35e185d3f --- /dev/null +++ b/tools/node_modules/extend.js/Readme.md @@ -0,0 +1,57 @@ + +# extend.js + + extend objects. `extend(obj, obj2, ...)` + +## Installation + + npm install extend.js + component install matthewmueller/extend.js + +## Example + +```js +var global = { + name : "matt", + age : 24 +}; + +var local = { + age: 50 +}; + +var obj = extend(global, local, { age: 25 }); +``` +results in: + +```js +{ + name: "matt", + age: 25 +} +``` + +## License + +(The MIT License) + +Copyright (c) 2012 matthew mueller <mattmuelle@mgail.com> + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tools/node_modules/extend.js/component.json b/tools/node_modules/extend.js/component.json new file mode 100644 index 00000000000000..f82ff00f0e5e7a --- /dev/null +++ b/tools/node_modules/extend.js/component.json @@ -0,0 +1,14 @@ +{ + "name": "extend", + "repo": "matthewmueller/extend.js", + "description": "extend(obj, obj2, ...)", + "version": "0.0.2", + "keywords": [], + "dependencies": {}, + "development": {}, + "license": "MIT", + "main": "index.js", + "scripts": [ + "index.js" + ] +} \ No newline at end of file diff --git a/tools/node_modules/extend.js/index.js b/tools/node_modules/extend.js/index.js new file mode 100644 index 00000000000000..b4b4b1f8eb17a7 --- /dev/null +++ b/tools/node_modules/extend.js/index.js @@ -0,0 +1,20 @@ +/** + * Extend an object with another. + * + * @param {Object, ...} src, ... + * @return {Object} merged + * @api private + */ + +module.exports = function(src) { + var objs = [].slice.call(arguments, 1), obj; + + for (var i = 0, len = objs.length; i < len; i++) { + obj = objs[i]; + for (var prop in obj) { + src[prop] = obj[prop]; + } + } + + return src; +} diff --git a/tools/node_modules/extend.js/package.json b/tools/node_modules/extend.js/package.json new file mode 100644 index 00000000000000..73bdc7a640b021 --- /dev/null +++ b/tools/node_modules/extend.js/package.json @@ -0,0 +1,63 @@ +{ + "_args": [ + [ + "extend.js@0.0.2", + "C:\\wamp\\www\\node\\tools\\node_modules\\remark" + ] + ], + "_from": "extend.js@0.0.2", + "_id": "extend.js@0.0.2", + "_inCache": true, + "_location": "/extend.js", + "_npmUser": { + "email": "mattmuelle@gmail.com", + "name": "mattmueller" + }, + "_npmVersion": "2.0.0", + "_phantomChildren": {}, + "_requested": { + "name": "extend.js", + "raw": "extend.js@0.0.2", + "rawSpec": "0.0.2", + "scope": null, + "spec": "0.0.2", + "type": "version" + }, + "_requiredBy": [ + "/remark" + ], + "_resolved": "https://registry.npmjs.org/extend.js/-/extend.js-0.0.2.tgz", + "_shasum": "0f9c7a81a1f208b703eb0c3131fe5716ac6ecd15", + "_shrinkwrap": null, + "_spec": "extend.js@0.0.2", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\remark", + "author": { + "email": "mattmuelle@mgail.com", + "name": "matthew mueller" + }, + "dependencies": {}, + "description": "extend(obj, obj2, ...)", + "devDependencies": { + "mocha": "*", + "should": "*" + }, + "directories": {}, + "dist": { + "shasum": "0f9c7a81a1f208b703eb0c3131fe5716ac6ecd15", + "tarball": "http://registry.npmjs.org/extend.js/-/extend.js-0.0.2.tgz" + }, + "gitHead": "afd508dad9778f31c8d2339b88cdd7de11d90a56", + "installable": true, + "keywords": [], + "main": "index", + "maintainers": [ + { + "name": "mattmueller", + "email": "mattmuelle@gmail.com" + } + ], + "name": "extend.js", + "optionalDependencies": {}, + "scripts": {}, + "version": "0.0.2" +} diff --git a/tools/node_modules/extend/.eslintrc b/tools/node_modules/extend/.eslintrc new file mode 100644 index 00000000000000..d49f17353d70e2 --- /dev/null +++ b/tools/node_modules/extend/.eslintrc @@ -0,0 +1,192 @@ +{ + "env": { + "browser": false, + "node": true, + "amd": false, + "mocha": false, + "jasmine": false + }, + + "rules": { + "accessor-pairs": [2, { getWithoutSet: false, setWithoutGet: true }], + "array-bracket-spacing": [2, "never", { + "singleValue": false, + "objectsInArrays": false, + "arraysInArrays": false + }], + "block-scoped-var": [0], + "brace-style": [2, "1tbs", { "allowSingleLine": true }], + "camelcase": [2], + "comma-dangle": [2, "never"], + "comma-spacing": [2], + "comma-style": [2, "last"], + "complexity": [2, 15], + "computed-property-spacing": [2, "never"], + "consistent-return": [2], + "consistent-this": [0, "that"], + "constructor-super": [2], + "curly": [2, "all"], + "default-case": [2], + "dot-notation": [2, { "allowKeywords": true }], + "eol-last": [2], + "eqeqeq": [2], + "func-names": [0], + "func-style": [2, "expression"], + "generator-star-spacing": [2, { "before": false, "after": true }], + "global-strict": [0, "never"], + "guard-for-in": [0], + "handle-callback-err": [0], + "key-spacing": [2, { "beforeColon": false, "afterColon": true }], + "linebreak-style": [2, "unix"], + "lines-around-comment": [2, { + "beforeBlockComment": false, + "afterBlockComment": false, + "beforeLineComment": false, + "beforeLineComment": false, + "allowBlockStart": true, + "allowBlockEnd": true + }], + "quotes": [2, "single", "avoid-escape"], + "max-depth": [1, 4], + "max-len": [0, 80, 4], + "max-nested-callbacks": [2, 2], + "max-params": [2, 2], + "max-statements": [2, 21], + "new-parens": [2], + "new-cap": [2], + "newline-after-var": [0], + "no-alert": [2], + "no-array-constructor": [2], + "no-bitwise": [0], + "no-caller": [2], + "no-catch-shadow": [2], + "no-cond-assign": [2], + "no-console": [2], + "no-constant-condition": [2], + "no-continue": [2], + "no-control-regex": [2], + "no-debugger": [2], + "no-delete-var": [2], + "no-div-regex": [0], + "no-dupe-args": [2], + "no-dupe-keys": [2], + "no-duplicate-case": [2], + "no-else-return": [0], + "no-empty": [2], + "no-empty-character-class": [2], + "no-empty-label": [2], + "no-eq-null": [0], + "no-eval": [2], + "no-ex-assign": [2], + "no-extend-native": [2], + "no-extra-bind": [2], + "no-extra-boolean-cast": [2], + "no-extra-parens": [0], + "no-extra-semi": [2], + "no-fallthrough": [2], + "no-floating-decimal": [2], + "no-func-assign": [2], + "no-implied-eval": [2], + "no-inline-comments": [0], + "no-inner-declarations": [2, "functions"], + "no-invalid-regexp": [2], + "no-irregular-whitespace": [2], + "no-iterator": [2], + "no-label-var": [2], + "no-labels": [2], + "no-lone-blocks": [2], + "no-lonely-if": [2], + "no-loop-func": [2], + "no-mixed-requires": [0, false], + "no-mixed-spaces-and-tabs": [2, false], + "no-multi-spaces": [2], + "no-multi-str": [2], + "no-multiple-empty-lines": [2, {"max": 1}], + "no-native-reassign": [2], + "no-negated-in-lhs": [2], + "no-nested-ternary": [0], + "no-new": [2], + "no-new-func": [2], + "no-new-object": [2], + "no-new-require": [0], + "no-new-wrappers": [2], + "no-obj-calls": [2], + "no-octal": [2], + "no-octal-escape": [2], + "no-param-reassign": [2], + "no-path-concat": [0], + "no-plusplus": [0], + "no-process-env": [0], + "no-process-exit": [2], + "no-proto": [2], + "no-redeclare": [2], + "no-regex-spaces": [2], + "no-reserved-keys": [2], + "no-restricted-modules": [0], + "no-return-assign": [2, "always"], + "no-script-url": [2], + "no-self-compare": [0], + "no-sequences": [2], + "no-shadow": [2], + "no-shadow-restricted-names": [2], + "no-space-before-semi": [2], + "no-spaced-func": [2], + "no-sparse-arrays": [2], + "no-sync": [0], + "no-ternary": [0], + "no-this-before-super": [2], + "no-throw-literal": [2], + "no-trailing-spaces": [2, { "skipBlankLines": false }], + "no-undef": [2], + "no-undef-init": [2], + "no-undefined": [0], + "no-underscore-dangle": [2], + "no-unexpected-multiline": [2], + "no-unneeded-ternary": [2], + "no-unreachable": [2], + "no-unused-expressions": [2], + "no-unused-vars": [2, { "vars": "all", "args": "after-used" }], + "no-use-before-define": [2], + "no-void": [0], + "no-warning-comments": [0, { "terms": ["todo", "fixme", "xxx"], "location": "start" }], + "no-with": [2], + "no-wrap-func": [2], + "object-curly-spacing": [2, "always"], + "object-shorthand": [2, "never"], + "one-var": [0], + "operator-assignment": [0, "always"], + "operator-linebreak": [2, "none"], + "padded-blocks": [0], + "prefer-const": [0], + "quote-props": [0], + "radix": [0], + "semi": [2], + "semi-spacing": [2, { "before": false, "after": true }], + "sort-vars": [0], + "space-after-keywords": [2, "always"], + "space-before-function-paren": [2, { "anonymous": "always", "named": "never" }], + "space-before-blocks": [0, "always"], + "space-in-brackets": [0, "never", { + "singleValue": true, + "arraysInArrays": false, + "arraysInObjects": false, + "objectsInArrays": true, + "objectsInObjects": true, + "propertyName": false + }], + "space-in-parens": [2, "never"], + "space-infix-ops": [2], + "space-return-throw-case": [2], + "space-unary-ops": [2, { "words": true, "nonwords": false }], + "spaced-comment": [2, "always"], + "spaced-line-comment": [0, "always"], + "strict": [2, "global"], + "use-isnan": [2], + "valid-jsdoc": [0], + "valid-typeof": [2], + "vars-on-top": [0], + "wrap-iife": [2], + "wrap-regex": [2], + "yoda": [2, "never", { "exceptRange": true, "onlyEquality": false }] + } +} diff --git a/tools/node_modules/extend/.jscs.json b/tools/node_modules/extend/.jscs.json new file mode 100644 index 00000000000000..7e84b282bb1763 --- /dev/null +++ b/tools/node_modules/extend/.jscs.json @@ -0,0 +1,104 @@ +{ + "additionalRules": [], + + "requireSemicolons": true, + + "disallowMultipleSpaces": true, + + "disallowIdentifierNames": [], + + "requireCurlyBraces": ["if", "else", "for", "while", "do", "try", "catch"], + + "requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch", "function"], + + "disallowSpaceAfterKeywords": [], + + "requireSpacesInAnonymousFunctionExpression": { "beforeOpeningRoundBrace": true, "beforeOpeningCurlyBrace": true }, + "requireSpacesInNamedFunctionExpression": { "beforeOpeningCurlyBrace": true }, + "disallowSpacesInNamedFunctionExpression": { "beforeOpeningRoundBrace": true }, + "requireSpacesInFunctionDeclaration": { "beforeOpeningCurlyBrace": true }, + "disallowSpacesInFunctionDeclaration": { "beforeOpeningRoundBrace": true }, + + "requireSpaceBetweenArguments": true, + + "disallowSpacesInsideParentheses": true, + + "disallowSpacesInsideArrayBrackets": true, + + "disallowQuotedKeysInObjects": "allButReserved", + + "disallowSpaceAfterObjectKeys": true, + + "requireCommaBeforeLineBreak": true, + + "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"], + "requireSpaceAfterPrefixUnaryOperators": [], + + "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"], + "requireSpaceBeforePostfixUnaryOperators": [], + + "disallowSpaceBeforeBinaryOperators": [], + "requireSpaceBeforeBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="], + + "requireSpaceAfterBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="], + "disallowSpaceAfterBinaryOperators": [], + + "disallowImplicitTypeConversion": ["binary", "string"], + + "disallowKeywords": ["with", "eval"], + + "requireKeywordsOnNewLine": [], + "disallowKeywordsOnNewLine": ["else"], + + "requireLineFeedAtFileEnd": true, + + "disallowTrailingWhitespace": true, + + "disallowTrailingComma": true, + + "excludeFiles": ["node_modules/**", "vendor/**"], + + "disallowMultipleLineStrings": true, + + "requireDotNotation": true, + + "requireParenthesesAroundIIFE": true, + + "validateLineBreaks": "LF", + + "validateQuoteMarks": { + "escape": true, + "mark": "'" + }, + + "disallowOperatorBeforeLineBreak": [], + + "requireSpaceBeforeKeywords": [ + "do", + "for", + "if", + "else", + "switch", + "case", + "try", + "catch", + "finally", + "while", + "with", + "return" + ], + + "validateAlignedFunctionParameters": { + "lineBreakAfterOpeningBraces": true, + "lineBreakBeforeClosingBraces": true + }, + + "requirePaddingNewLinesBeforeExport": true, + + "validateNewlineAfterArrayElements": { + "maximum": 6 + }, + + "requirePaddingNewLinesAfterUseStrict": true +} + diff --git a/tools/node_modules/extend/.npmignore b/tools/node_modules/extend/.npmignore new file mode 100644 index 00000000000000..30d74d258442c7 --- /dev/null +++ b/tools/node_modules/extend/.npmignore @@ -0,0 +1 @@ +test \ No newline at end of file diff --git a/tools/node_modules/extend/.travis.yml b/tools/node_modules/extend/.travis.yml new file mode 100644 index 00000000000000..ebef64499b3553 --- /dev/null +++ b/tools/node_modules/extend/.travis.yml @@ -0,0 +1,44 @@ +language: node_js +node_js: + - "iojs-v2.3" + - "iojs-v2.2" + - "iojs-v2.1" + - "iojs-v2.0" + - "iojs-v1.8" + - "iojs-v1.7" + - "iojs-v1.6" + - "iojs-v1.5" + - "iojs-v1.4" + - "iojs-v1.3" + - "iojs-v1.2" + - "iojs-v1.1" + - "iojs-v1.0" + - "0.12" + - "0.11" + - "0.10" + - "0.9" + - "0.8" + - "0.6" + - "0.4" +before_install: + - '[ "${TRAVIS_NODE_VERSION}" = "0.6" ] || npm install -g npm@1.4.28 && npm install -g npm' +sudo: false +matrix: + fast_finish: true + allow_failures: + - node_js: "iojs-v2.2" + - node_js: "iojs-v2.1" + - node_js: "iojs-v2.0" + - node_js: "iojs-v1.7" + - node_js: "iojs-v1.6" + - node_js: "iojs-v1.5" + - node_js: "iojs-v1.4" + - node_js: "iojs-v1.3" + - node_js: "iojs-v1.2" + - node_js: "iojs-v1.1" + - node_js: "iojs-v1.0" + - node_js: "0.11" + - node_js: "0.9" + - node_js: "0.8" + - node_js: "0.6" + - node_js: "0.4" diff --git a/tools/node_modules/extend/CHANGELOG.md b/tools/node_modules/extend/CHANGELOG.md new file mode 100644 index 00000000000000..ee0cfd6adb5a2e --- /dev/null +++ b/tools/node_modules/extend/CHANGELOG.md @@ -0,0 +1,69 @@ +3.0.0 / 2015-07-01 +================== + * [Possible breaking change] Use global "strict" directive (#32) + * [Tests] `int` is an ES3 reserved word + * [Tests] Test up to `io.js` `v2.3` + * [Tests] Add `npm run eslint` + * [Dev Deps] Update `covert`, `jscs` + +2.0.1 / 2015-04-25 +================== + * Use an inline `isArray` check, for ES3 browsers. (#27) + * Some old browsers fail when an identifier is `toString` + * Test latest `node` and `io.js` versions on `travis-ci`; speed up builds + * Add license info to package.json (#25) + * Update `tape`, `jscs` + * Adding a CHANGELOG + +2.0.0 / 2014-10-01 +================== + * Increase code coverage to 100%; run code coverage as part of tests + * Add `npm run lint`; Run linter as part of tests + * Remove nodeType and setInterval checks in isPlainObject + * Updating `tape`, `jscs`, `covert` + * General style and README cleanup + +1.3.0 / 2014-06-20 +================== + * Add component.json for browser support (#18) + * Use SVG for badges in README (#16) + * Updating `tape`, `covert` + * Updating travis-ci to work with multiple node versions + * Fix `deep === false` bug (returning target as {}) (#14) + * Fixing constructor checks in isPlainObject + * Adding additional test coverage + * Adding `npm run coverage` + * Add LICENSE (#13) + * Adding a warning about `false`, per #11 + * General style and whitespace cleanup + +1.2.1 / 2013-09-14 +================== + * Fixing hasOwnProperty bugs that would only have shown up in specific browsers. Fixes #8 + * Updating `tape` + +1.2.0 / 2013-09-02 +================== + * Updating the README: add badges + * Adding a missing variable reference. + * Using `tape` instead of `buster` for tests; add more tests (#7) + * Adding node 0.10 to Travis CI (#6) + * Enabling "npm test" and cleaning up package.json (#5) + * Add Travis CI. + +1.1.3 / 2012-12-06 +================== + * Added unit tests. + * Ensure extend function is named. (Looks nicer in a stack trace.) + * README cleanup. + +1.1.1 / 2012-11-07 +================== + * README cleanup. + * Added installation instructions. + * Added a missing semicolon + +1.0.0 / 2012-04-08 +================== + * Initial commit + diff --git a/tools/node_modules/extend/LICENSE b/tools/node_modules/extend/LICENSE new file mode 100644 index 00000000000000..e16d6a56ca64e2 --- /dev/null +++ b/tools/node_modules/extend/LICENSE @@ -0,0 +1,23 @@ +The MIT License (MIT) + +Copyright (c) 2014 Stefan Thomas + +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. + diff --git a/tools/node_modules/extend/README.md b/tools/node_modules/extend/README.md new file mode 100644 index 00000000000000..632fb0f96fd347 --- /dev/null +++ b/tools/node_modules/extend/README.md @@ -0,0 +1,62 @@ +[![Build Status][travis-svg]][travis-url] +[![dependency status][deps-svg]][deps-url] +[![dev dependency status][dev-deps-svg]][dev-deps-url] + +# extend() for Node.js [![Version Badge][npm-version-png]][npm-url] + +`node-extend` is a port of the classic extend() method from jQuery. It behaves as you expect. It is simple, tried and true. + +## Installation + +This package is available on [npm][npm-url] as: `extend` + +``` sh +npm install extend +``` + +## Usage + +**Syntax:** extend **(** [`deep`], `target`, `object1`, [`objectN`] **)** + +*Extend one object with one or more others, returning the modified object.* + +Keep in mind that the target object will be modified, and will be returned from extend(). + +If a boolean true is specified as the first argument, extend performs a deep copy, recursively copying any objects it finds. Otherwise, the copy will share structure with the original object(s). +Undefined properties are not copied. However, properties inherited from the object's prototype will be copied over. +Warning: passing `false` as the first argument is not supported. + +### Arguments + +* `deep` *Boolean* (optional) +If set, the merge becomes recursive (i.e. deep copy). +* `target` *Object* +The object to extend. +* `object1` *Object* +The object that will be merged into the first. +* `objectN` *Object* (Optional) +More objects to merge into the first. + +## License + +`node-extend` is licensed under the [MIT License][mit-license-url]. + +## Acknowledgements + +All credit to the jQuery authors for perfecting this amazing utility. + +Ported to Node.js by [Stefan Thomas][github-justmoon] with contributions by [Jonathan Buchanan][github-insin] and [Jordan Harband][github-ljharb]. + +[travis-svg]: https://travis-ci.org/justmoon/node-extend.svg +[travis-url]: https://travis-ci.org/justmoon/node-extend +[npm-url]: https://npmjs.org/package/extend +[mit-license-url]: http://opensource.org/licenses/MIT +[github-justmoon]: https://github.com/justmoon +[github-insin]: https://github.com/insin +[github-ljharb]: https://github.com/ljharb +[npm-version-png]: http://vb.teelaun.ch/justmoon/node-extend.svg +[deps-svg]: https://david-dm.org/justmoon/node-extend.svg +[deps-url]: https://david-dm.org/justmoon/node-extend +[dev-deps-svg]: https://david-dm.org/justmoon/node-extend/dev-status.svg +[dev-deps-url]: https://david-dm.org/justmoon/node-extend#info=devDependencies + diff --git a/tools/node_modules/extend/component.json b/tools/node_modules/extend/component.json new file mode 100644 index 00000000000000..1500a2f3718182 --- /dev/null +++ b/tools/node_modules/extend/component.json @@ -0,0 +1,32 @@ +{ + "name": "extend", + "author": "Stefan Thomas (http://www.justmoon.net)", + "version": "3.0.0", + "description": "Port of jQuery.extend for node.js and the browser.", + "scripts": [ + "index.js" + ], + "contributors": [ + { + "name": "Jordan Harband", + "url": "https://github.com/ljharb" + } + ], + "keywords": [ + "extend", + "clone", + "merge" + ], + "repository" : { + "type": "git", + "url": "https://github.com/justmoon/node-extend.git" + }, + "dependencies": { + }, + "devDependencies": { + "tape" : "~3.0.0", + "covert": "~0.4.0", + "jscs": "~1.6.2" + } +} + diff --git a/tools/node_modules/extend/index.js b/tools/node_modules/extend/index.js new file mode 100644 index 00000000000000..f5ec75d52f5f61 --- /dev/null +++ b/tools/node_modules/extend/index.js @@ -0,0 +1,86 @@ +'use strict'; + +var hasOwn = Object.prototype.hasOwnProperty; +var toStr = Object.prototype.toString; + +var isArray = function isArray(arr) { + if (typeof Array.isArray === 'function') { + return Array.isArray(arr); + } + + return toStr.call(arr) === '[object Array]'; +}; + +var isPlainObject = function isPlainObject(obj) { + if (!obj || toStr.call(obj) !== '[object Object]') { + return false; + } + + var hasOwnConstructor = hasOwn.call(obj, 'constructor'); + var hasIsPrototypeOf = obj.constructor && obj.constructor.prototype && hasOwn.call(obj.constructor.prototype, 'isPrototypeOf'); + // Not own constructor property must be Object + if (obj.constructor && !hasOwnConstructor && !hasIsPrototypeOf) { + return false; + } + + // Own properties are enumerated firstly, so to speed up, + // if last one is own, then all properties are own. + var key; + for (key in obj) {/**/} + + return typeof key === 'undefined' || hasOwn.call(obj, key); +}; + +module.exports = function extend() { + var options, name, src, copy, copyIsArray, clone, + target = arguments[0], + i = 1, + length = arguments.length, + deep = false; + + // Handle a deep copy situation + if (typeof target === 'boolean') { + deep = target; + target = arguments[1] || {}; + // skip the boolean and the target + i = 2; + } else if ((typeof target !== 'object' && typeof target !== 'function') || target == null) { + target = {}; + } + + for (; i < length; ++i) { + options = arguments[i]; + // Only deal with non-null/undefined values + if (options != null) { + // Extend the base object + for (name in options) { + src = target[name]; + copy = options[name]; + + // Prevent never-ending loop + if (target !== copy) { + // Recurse if we're merging plain objects or arrays + if (deep && copy && (isPlainObject(copy) || (copyIsArray = isArray(copy)))) { + if (copyIsArray) { + copyIsArray = false; + clone = src && isArray(src) ? src : []; + } else { + clone = src && isPlainObject(src) ? src : {}; + } + + // Never move original objects, clone them + target[name] = extend(deep, clone, copy); + + // Don't bring in undefined values + } else if (typeof copy !== 'undefined') { + target[name] = copy; + } + } + } + } + } + + // Return the modified object + return target; +}; + diff --git a/tools/node_modules/extend/package.json b/tools/node_modules/extend/package.json new file mode 100644 index 00000000000000..b3e21b2de83d61 --- /dev/null +++ b/tools/node_modules/extend/package.json @@ -0,0 +1,97 @@ +{ + "_args": [ + [ + "extend@^3.0.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\unified" + ] + ], + "_from": "extend@>=3.0.0 <4.0.0", + "_id": "extend@3.0.0", + "_inCache": true, + "_location": "/extend", + "_nodeVersion": "2.3.1", + "_npmUser": { + "email": "ljharb@gmail.com", + "name": "ljharb" + }, + "_npmVersion": "2.11.3", + "_phantomChildren": {}, + "_requested": { + "name": "extend", + "raw": "extend@^3.0.0", + "rawSpec": "^3.0.0", + "scope": null, + "spec": ">=3.0.0 <4.0.0", + "type": "range" + }, + "_requiredBy": [ + "/unified" + ], + "_resolved": "https://registry.npmjs.org/extend/-/extend-3.0.0.tgz", + "_shasum": "5a474353b9f3353ddd8176dfd37b91c83a46f1d4", + "_shrinkwrap": null, + "_spec": "extend@^3.0.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\unified", + "author": { + "email": "justmoon@members.fsf.org", + "name": "Stefan Thomas", + "url": "http://www.justmoon.net" + }, + "bugs": { + "url": "https://github.com/justmoon/node-extend/issues" + }, + "contributors": [ + { + "name": "Jordan Harband", + "url": "https://github.com/ljharb" + } + ], + "dependencies": {}, + "description": "Port of jQuery.extend for node.js and the browser", + "devDependencies": { + "covert": "^1.1.0", + "eslint": "^0.24.0", + "jscs": "^1.13.1", + "tape": "^4.0.0" + }, + "directories": {}, + "dist": { + "shasum": "5a474353b9f3353ddd8176dfd37b91c83a46f1d4", + "tarball": "http://registry.npmjs.org/extend/-/extend-3.0.0.tgz" + }, + "gitHead": "148e7270cab2e9413af2cd0cab147070d755ed6d", + "homepage": "https://github.com/justmoon/node-extend#readme", + "installable": true, + "keywords": [ + "clone", + "extend", + "merge" + ], + "license": "MIT", + "main": "index", + "maintainers": [ + { + "name": "justmoon", + "email": "justmoon@members.fsf.org" + }, + { + "name": "ljharb", + "email": "ljharb@gmail.com" + } + ], + "name": "extend", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git+https://github.com/justmoon/node-extend.git" + }, + "scripts": { + "coverage": "covert test/index.js", + "coverage-quiet": "covert test/index.js --quiet", + "eslint": "eslint *.js */*.js", + "jscs": "jscs *.js */*.js", + "lint": "npm run jscs && npm run eslint", + "test": "npm run lint && node test/index.js && npm run coverage-quiet" + }, + "version": "3.0.0" +} diff --git a/tools/node_modules/extglob/LICENSE b/tools/node_modules/extglob/LICENSE new file mode 100644 index 00000000000000..65f90aca8c2fff --- /dev/null +++ b/tools/node_modules/extglob/LICENSE @@ -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. diff --git a/tools/node_modules/extglob/README.md b/tools/node_modules/extglob/README.md new file mode 100644 index 00000000000000..66644066956255 --- /dev/null +++ b/tools/node_modules/extglob/README.md @@ -0,0 +1,88 @@ +# extglob [![NPM version](https://badge.fury.io/js/extglob.svg)](http://badge.fury.io/js/extglob) [![Build Status](https://travis-ci.org/jonschlinkert/extglob.svg)](https://travis-ci.org/jonschlinkert/extglob) + +> Convert extended globs to regex-compatible strings. Add (almost) the expressive power of regular expressions to glob patterns. + +Install with [npm](https://www.npmjs.com/) + +```sh +$ npm i extglob --save +``` + +Used by [micromatch](https://github.com/jonschlinkert/micromatch). + +**Features** + +* Convert an extglob string to a regex-compatible string. **Only converts extglobs**, to handle full globs use [micromatch](https://github.com/jonschlinkert/micromatch). +* Pass `{regex: true}` to return a regex +* Handles nested patterns +* More complete (and correct) support than [minimatch](https://github.com/isaacs/minimatch) + +## Usage + +```js +var extglob = require('extglob'); + +extglob('?(z)'); +//=> '(?:z)?' +extglob('*(z)'); +//=> '(?:z)*' +extglob('+(z)'); +//=> '(?:z)+' +extglob('@(z)'); +//=> '(?:z)' +extglob('!(z)'); +//=> '(?!^(?:(?!z)[^/]*?)).*$' +``` + +**Optionally return regex** + +```js +extglob('!(z)', {regex: true}); +//=> /(?!^(?:(?!z)[^/]*?)).*$/ +``` + +## Extglob patterns + +To learn more about how extglobs work, see the docs for [Bash pattern matching](https://www.gnu.org/software/bash/manual/html_node/Pattern-Matching.html): + +* `?(pattern)`: Match zero or one occurrence of the given pattern. +* `*(pattern)`: Match zero or more occurrences of the given pattern. +* `+(pattern)`: Match one or more occurrences of the given pattern. +* `@(pattern)`: Match one of the given pattern. +* `!(pattern)`: Match anything except one of the given pattern. + +## Related + +* [braces](https://github.com/jonschlinkert/braces): Fastest brace expansion for node.js, with the most complete support for the Bash 4.3 braces… [more](https://github.com/jonschlinkert/braces) +* [expand-brackets](https://github.com/jonschlinkert/expand-brackets): Expand POSIX bracket expressions (character classes) in glob patterns. +* [expand-range](https://github.com/jonschlinkert/expand-range): Fast, bash-like range expansion. Expand a range of numbers or letters, uppercase or lowercase. See… [more](https://github.com/jonschlinkert/expand-range) +* [fill-range](https://github.com/jonschlinkert/fill-range): Fill in a range of numbers or letters, optionally passing an increment or multiplier to… [more](https://github.com/jonschlinkert/fill-range) +* [micromatch](https://github.com/jonschlinkert/micromatch): Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch. Just… [more](https://github.com/jonschlinkert/micromatch) + +## Run 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/extglob/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 01, 2015._ \ No newline at end of file diff --git a/tools/node_modules/extglob/index.js b/tools/node_modules/extglob/index.js new file mode 100644 index 00000000000000..2e774d4aae562e --- /dev/null +++ b/tools/node_modules/extglob/index.js @@ -0,0 +1,178 @@ +/*! + * extglob + * + * Copyright (c) 2015, Jon Schlinkert. + * Licensed under the MIT License. + */ + +'use strict'; + +/** + * Module dependencies + */ + +var isExtglob = require('is-extglob'); +var re, cache = {}; + +/** + * Expose `extglob` + */ + +module.exports = extglob; + +/** + * Convert the given extglob `string` to a regex-compatible + * string. + * + * ```js + * var extglob = require('extglob'); + * extglob('!(a?(b))'); + * //=> '(?!a(?:b)?)[^/]*?' + * ``` + * + * @param {String} `str` The string to convert. + * @param {Object} `options` + * @option {Boolean} [options] `esc` If `false` special characters will not be escaped. Defaults to `true`. + * @option {Boolean} [options] `regex` If `true` a regular expression is returned instead of a string. + * @return {String} + * @api public + */ + + +function extglob(str, opts) { + opts = opts || {}; + var o = {}, i = 0; + + // fix common character reversals + // '*!(.js)' => '*.!(js)' + str = str.replace(/!\(([^\w*()])/g, '$1!('); + + // support file extension negation + str = str.replace(/([*\/])\.!\([*]\)/g, function (m, ch) { + if (ch === '/') { + return escape('\\/[^.]+'); + } + return escape('[^.]+'); + }); + + // create a unique key for caching by + // combining the string and options + var key = str + + String(!!opts.regex) + + String(!!opts.contains) + + String(!!opts.escape); + + if (cache.hasOwnProperty(key)) { + return cache[key]; + } + + if (!(re instanceof RegExp)) { + re = regex(); + } + + opts.negate = false; + var m; + + while (m = re.exec(str)) { + var prefix = m[1]; + var inner = m[3]; + if (prefix === '!') { + opts.negate = true; + } + + var id = '__EXTGLOB_' + (i++) + '__'; + // use the prefix of the _last_ (outtermost) pattern + o[id] = wrap(inner, prefix, opts.escape); + str = str.split(m[0]).join(id); + } + + var keys = Object.keys(o); + var len = keys.length; + + // we have to loop again to allow us to convert + // patterns in reverse order (starting with the + // innermost/last pattern first) + while (len--) { + var prop = keys[len]; + str = str.split(prop).join(o[prop]); + } + + var result = opts.regex + ? toRegex(str, opts.contains, opts.negate) + : str; + + result = result.split('.').join('\\.'); + + // cache the result and return it + return (cache[key] = result); +} + +/** + * Convert `string` to a regex string. + * + * @param {String} `str` + * @param {String} `prefix` Character that determines how to wrap the string. + * @param {Boolean} `esc` If `false` special characters will not be escaped. Defaults to `true`. + * @return {String} + */ + +function wrap(inner, prefix, esc) { + if (esc) inner = escape(inner); + + switch (prefix) { + case '!': + return '(?!' + inner + ')[^/]' + (esc ? '%%%~' : '*?'); + case '@': + return '(?:' + inner + ')'; + case '+': + return '(?:' + inner + ')+'; + case '*': + return '(?:' + inner + ')' + (esc ? '%%' : '*') + case '?': + return '(?:' + inner + '|)'; + default: + return inner; + } +} + +function escape(str) { + str = str.split('*').join('[^/]%%%~'); + str = str.split('.').join('\\.'); + return str; +} + +/** + * extglob regex. + */ + +function regex() { + return /(\\?[@?!+*$]\\?)(\(([^()]*?)\))/; +} + +/** + * Negation regex + */ + +function negate(str) { + return '(?!^' + str + ').*$'; +} + +/** + * Create the regex to do the matching. If + * the leading character in the `pattern` is `!` + * a negation regex is returned. + * + * @param {String} `pattern` + * @param {Boolean} `contains` Allow loose matching. + * @param {Boolean} `isNegated` True if the pattern is a negation pattern. + */ + +function toRegex(pattern, contains, isNegated) { + var prefix = contains ? '^' : ''; + var after = contains ? '$' : ''; + pattern = ('(?:' + pattern + ')' + after); + if (isNegated) { + pattern = prefix + negate(pattern); + } + return new RegExp(prefix + pattern); +} diff --git a/tools/node_modules/extglob/package.json b/tools/node_modules/extglob/package.json new file mode 100644 index 00000000000000..1f7084b751a71b --- /dev/null +++ b/tools/node_modules/extglob/package.json @@ -0,0 +1,107 @@ +{ + "_args": [ + [ + "extglob@^0.3.1", + "C:\\wamp\\www\\node\\tools\\node_modules\\micromatch" + ] + ], + "_from": "extglob@>=0.3.1 <0.4.0", + "_id": "extglob@0.3.2", + "_inCache": true, + "_location": "/extglob", + "_nodeVersion": "5.3.0", + "_npmUser": { + "email": "github@sellside.com", + "name": "jonschlinkert" + }, + "_npmVersion": "3.3.12", + "_phantomChildren": {}, + "_requested": { + "name": "extglob", + "raw": "extglob@^0.3.1", + "rawSpec": "^0.3.1", + "scope": null, + "spec": ">=0.3.1 <0.4.0", + "type": "range" + }, + "_requiredBy": [ + "/micromatch" + ], + "_resolved": "https://registry.npmjs.org/extglob/-/extglob-0.3.2.tgz", + "_shasum": "2e18ff3d2f49ab2765cec9023f011daa8d8349a1", + "_shrinkwrap": null, + "_spec": "extglob@^0.3.1", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\micromatch", + "author": { + "name": "Jon Schlinkert", + "url": "https://github.com/jonschlinkert" + }, + "bugs": { + "url": "https://github.com/jonschlinkert/extglob/issues" + }, + "dependencies": { + "is-extglob": "^1.0.0" + }, + "description": "Convert extended globs to regex-compatible strings. Add (almost) the expressive power of regular expressions to glob patterns.", + "devDependencies": { + "ansi-green": "^0.1.1", + "micromatch": "^2.1.6", + "minimatch": "^2.0.1", + "minimist": "^1.1.0", + "mocha": "*", + "should": "*", + "success-symbol": "^0.1.0" + }, + "directories": {}, + "dist": { + "shasum": "2e18ff3d2f49ab2765cec9023f011daa8d8349a1", + "tarball": "http://registry.npmjs.org/extglob/-/extglob-0.3.2.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "8c3f38bbd9e0afaf31a87e411c0d15532434ef41", + "homepage": "https://github.com/jonschlinkert/extglob", + "installable": true, + "keywords": [ + "bash", + "extended", + "extglob", + "glob", + "ksh", + "match", + "wildcard" + ], + "license": "MIT", + "main": "index.js", + "maintainers": [ + { + "name": "jonschlinkert", + "email": "github@sellside.com" + } + ], + "name": "extglob", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git://github.com/jonschlinkert/extglob.git" + }, + "scripts": { + "test": "mocha" + }, + "verb": { + "related": { + "list": [ + "braces", + "expand-brackets", + "expand-range", + "fill-range", + "micromatch" + ] + } + }, + "version": "0.3.2" +} diff --git a/tools/node_modules/filename-regex/README.md b/tools/node_modules/filename-regex/README.md new file mode 100644 index 00000000000000..d001e7aaefe576 --- /dev/null +++ b/tools/node_modules/filename-regex/README.md @@ -0,0 +1,51 @@ +# filename-regex [![NPM version](https://badge.fury.io/js/filename-regex.svg)](http://badge.fury.io/js/filename-regex) + +> Regular expression for matching file names, with or without extension. + + +## Install with [npm](npmjs.org) + +```bash +npm i filename-regex --save +``` + +## Usage + +```js +var regex = require('filename-regex'); + +'a/b/c/d.min.js'.match(regex()); +//=> match[0] = 'd.min.js' + +'a/b/c/.dotfile'.match(regex()); +//=> match[0] = '.dotfile' +``` + + +## Run tests + +Install dev dependencies: + +```bash +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/regexps/filename-regex/issues) + + +## Author + +**Jon Schlinkert** + ++ [github/jonschlinkert](https://github.com/jonschlinkert) ++ [twitter/jonschlinkert](http://twitter.com/jonschlinkert) + + +## License +Copyright (c) 2015 Jon Schlinkert +Released under the MIT license + +*** + +_This file was generated by [verb](https://github.com/assemble/verb) on January 24, 2015._ diff --git a/tools/node_modules/filename-regex/index.js b/tools/node_modules/filename-regex/index.js new file mode 100644 index 00000000000000..bb1888b4a37448 --- /dev/null +++ b/tools/node_modules/filename-regex/index.js @@ -0,0 +1,10 @@ +/*! + * filename-regex + * + * Copyright (c) 2014-2015, Jon Schlinkert + * Licensed under the MIT license. + */ + +module.exports = function filenameRegex() { + return /([^\\\/]+)$/; +}; diff --git a/tools/node_modules/filename-regex/package.json b/tools/node_modules/filename-regex/package.json new file mode 100644 index 00000000000000..d4c4bd202a1f54 --- /dev/null +++ b/tools/node_modules/filename-regex/package.json @@ -0,0 +1,91 @@ +{ + "_args": [ + [ + "filename-regex@^2.0.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\micromatch" + ] + ], + "_from": "filename-regex@>=2.0.0 <3.0.0", + "_id": "filename-regex@2.0.0", + "_inCache": true, + "_location": "/filename-regex", + "_npmUser": { + "email": "github@sellside.com", + "name": "jonschlinkert" + }, + "_npmVersion": "1.4.28", + "_phantomChildren": {}, + "_requested": { + "name": "filename-regex", + "raw": "filename-regex@^2.0.0", + "rawSpec": "^2.0.0", + "scope": null, + "spec": ">=2.0.0 <3.0.0", + "type": "range" + }, + "_requiredBy": [ + "/micromatch" + ], + "_resolved": "https://registry.npmjs.org/filename-regex/-/filename-regex-2.0.0.tgz", + "_shasum": "996e3e80479b98b9897f15a8a58b3d084e926775", + "_shrinkwrap": null, + "_spec": "filename-regex@^2.0.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\micromatch", + "author": { + "name": "Jon Schlinkert", + "url": "https://github.com/jonschlinkert" + }, + "bugs": { + "url": "https://github.com/regexps/filename-regex/issues" + }, + "dependencies": {}, + "description": "Regular expression for matching file names, with or without extension.", + "devDependencies": {}, + "directories": {}, + "dist": { + "shasum": "996e3e80479b98b9897f15a8a58b3d084e926775", + "tarball": "http://registry.npmjs.org/filename-regex/-/filename-regex-2.0.0.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "aa0f2933322d38cf547ff4c8ced882fbd8422866", + "homepage": "https://github.com/regexps/filename-regex", + "installable": true, + "keywords": [ + "basename", + "file", + "filename", + "filepath", + "match", + "name", + "path", + "regex", + "regexp", + "regular expression" + ], + "license": { + "type": "MIT", + "url": "https://github.com/regexps/filename-regex/blob/master/LICENSE-MIT" + }, + "main": "index.js", + "maintainers": [ + { + "name": "jonschlinkert", + "email": "github@sellside.com" + } + ], + "name": "filename-regex", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git://github.com/regexps/filename-regex.git" + }, + "scripts": { + "test": "mocha -R spec" + }, + "version": "2.0.0" +} diff --git a/tools/node_modules/fill-range/LICENSE b/tools/node_modules/fill-range/LICENSE new file mode 100644 index 00000000000000..fa30c4cb3e4c15 --- /dev/null +++ b/tools/node_modules/fill-range/LICENSE @@ -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. diff --git a/tools/node_modules/fill-range/README.md b/tools/node_modules/fill-range/README.md new file mode 100644 index 00000000000000..c69694a38b7fc5 --- /dev/null +++ b/tools/node_modules/fill-range/README.md @@ -0,0 +1,290 @@ +# fill-range [![NPM version](https://badge.fury.io/js/fill-range.svg)](http://badge.fury.io/js/fill-range) [![Build Status](https://travis-ci.org/jonschlinkert/fill-range.svg)](https://travis-ci.org/jonschlinkert/fill-range) + +> Fill in a range of numbers or letters, optionally passing an increment or multiplier to use. + +## Install with [npm](npmjs.org) + +```bash +npm i fill-range --save +``` + + + +- [Usage](#usage) + * [Invalid ranges](#invalid-ranges) + * [Custom function](#custom-function) + * [Special characters](#special-characters) + + [plus](#plus) + + [pipe and tilde](#pipe-and-tilde) + + [angle bracket](#angle-bracket) + + [question mark](#question-mark) +- [Other useful libs](#other-useful-libs) +- [Running tests](#running-tests) +- [Contributing](#contributing) +- [Author](#author) +- [License](#license) + +_(Table of contents generated by [verb])_ + + + +## Usage + +```js +var range = require('fill-range'); + +range('a', 'e'); +//=> ['a', 'b', 'c', 'd', 'e'] +``` + +**Params** + +```js +range(start, stop, step, options, fn); +``` + + - `start`: **{String|Number}** the number or letter to start with + - `end`: **{String|Number}** the number or letter to end with + - `step`: **{String|Number}** optionally pass the step to use. works for letters or numbers. + - `options`: **{Object}**: + + `makeRe`: return a regex-compatible string (still returned as an array for consistency) + + `step`: pass the step on the options as an alternative to passing it as an argument + + `silent`: `true` by default, set to false to throw errors for invalid ranges. + - `fn`: **{Function}** optionally [pass a function](#custom-function) to modify each character + + +**Examples** + +```js +range(1, 3) +//=> ['1', '2', '3'] + +range('1', '3') +//=> ['1', '2', '3'] + +range('0', '-5') +//=> [ '0', '-1', '-2', '-3', '-4', '-5' ] + +range(-9, 9, 3) +//=> [ '-9', '-6', '-3', '0', '3', '6', '9' ]) + +range('-1', '-10', '-2') +//=> [ '-1', '-3', '-5', '-7', '-9' ] + +range('1', '10', '2') +//=> [ '1', '3', '5', '7', '9' ] + +range('a', 'e') +//=> ['a', 'b', 'c', 'd', 'e'] + +range('a', 'e', 2) +//=> ['a', 'c', 'e'] + +range('A', 'E', 2) +//=> ['A', 'C', 'E'] +``` + +### Invalid ranges + +When an invalid range is passed, `null` is returned. + +```js +range('1.1', '2'); +//=> null + +range('a', '2'); +//=> null + +range(1, 10, 'foo'); +//=> null +``` + +If you want errors to be throw, pass `silent: false` on the options: + + +### Custom function + +Optionally pass a custom function as the third or fourth argument: + +```js +range('a', 'e', function (val, isNumber, pad, i) { + if (!isNumber) { + return String.fromCharCode(val) + i; + } + return val; +}); +//=> ['a0', 'b1', 'c2', 'd3', 'e4'] +``` + +### Special characters + +A special character may be passed as the third arg instead of a step increment. These characters can be pretty useful for brace expansion, creating file paths, test fixtures and similar use case. + +```js +range('a', 'z', SPECIAL_CHARACTER_HERE); +``` + +**Supported characters** + + - `+`: repeat the given string `n` times + - `|`: create a regex-ready string, instead of an array + - `>`: join values to single array element + - `?`: randomize the given pattern using [randomatic] + +#### plus + +Character: _(`+`)_ + +Repeat the first argument the number of times passed on the second argument. + +**Examples:** + +```js +range('a', 3, '+'); +//=> ['a', 'a', 'a'] + +range('abc', 2, '+'); +//=> ['abc', 'abc'] +``` + +#### pipe and tilde + +Characters: _(`|` and `~`)_ + +Creates a regex-capable string (either a logical `or` or a character class) from the expanded arguments. + +**Examples:** + +```js +range('a', 'c', '|'); +//=> ['(a|b|c)' + +range('a', 'c', '~'); +//=> ['[a-c]' + +range('a', 'z', '|5'); +//=> ['(a|f|k|p|u|z)' +``` + +**Automatic separator correction** + +To avoid this error: + +> `Range out of order in character class` + +Fill-range detects invalid sequences and uses the correct syntax. For example: + +**invalid** (regex) + +If you pass these: + +```js +range('a', 'z', '~5'); +// which would result in this +//=> ['[a-f-k-p-u-z]'] + +range('10', '20', '~'); +// which would result in this +//=> ['[10-20]'] +``` + +**valid** (regex) + +fill-range corrects them to this: + +```js +range('a', 'z', '~5'); +//=> ['(a|f|k|p|u|z)' + +range('10', '20', '~'); +//=> ['(10-20)' +``` + +#### angle bracket + +Character: _(`>`)_ + +Joins all values in the returned array to a single value. + +**Examples:** + +```js +range('a', 'e', '>'); +//=> ['abcde'] + +range('5', '8', '>'); +//=> ['5678'] + +range('2', '20', '2>'); +//=> ['2468101214161820'] +``` + + +#### question mark + +Character: _(`?`)_ + +Uses [randomatic] to generate randomized alpha, numeric, or alpha-numeric patterns based on the provided arguments. + +**Examples:** + +_(actual results would obviously be randomized)_ + +Generate a 5-character, uppercase, alphabetical string: + +```js +range('A', 5, '?'); +//=> ['NSHAK'] +``` + +Generate a 5-digit random number: + +```js +range('0', 5, '?'); +//=> ['36583'] +``` + +Generate a 10-character alpha-numeric string: + +```js +range('A0', 10, '?'); +//=> ['5YJD60VQNN'] +``` + +See the [randomatic] repo for all available options and or to create issues or feature requests related to randomization. + +## Other useful libs + * [micromatch](https://github.com/jonschlinkert/micromatch): Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch. Just use `micromatch.isMatch()` instead of `minimatch()`, or use `micromatch()` instead of `multimatch()`. + * [expand-range](https://github.com/jonschlinkert/expand-range): Fast, bash-like range expansion. Expand a range of numbers or letters, uppercase or lowercase. See the benchmarks. Used by micromatch. + * [braces](https://github.com/jonschlinkert/braces): Fastest brace expansion for node.js, with the most complete support for the Bash 4.3 braces specification. + * [is-glob](https://github.com/jonschlinkert/is-glob): Returns `true` if the given string looks like a glob pattern. + +## Running tests +Install dev dependencies: + +```bash +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/fill-range/issues) + +## Author + +**Jon Schlinkert** + ++ [github/jonschlinkert](https://github.com/jonschlinkert) ++ [twitter/jonschlinkert](http://twitter.com/jonschlinkert) + +## License +Copyright (c) 2014-2015 Jon Schlinkert +Released under the MIT license + +*** + +_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on April 07, 2015._ + +[randomatic]: https://github.com/jonschlinkert/randomatic +[expand-range]: https://github.com/jonschlinkert/expand-range +[micromatch]: https://github.com/jonschlinkert/micromatch +[braces]: https://github.com/jonschlinkert/braces \ No newline at end of file diff --git a/tools/node_modules/fill-range/index.js b/tools/node_modules/fill-range/index.js new file mode 100644 index 00000000000000..5657051beec307 --- /dev/null +++ b/tools/node_modules/fill-range/index.js @@ -0,0 +1,408 @@ +/*! + * fill-range + * + * Copyright (c) 2014-2015, Jon Schlinkert. + * Licensed under the MIT License. + */ + +'use strict'; + +var isObject = require('isobject'); +var isNumber = require('is-number'); +var randomize = require('randomatic'); +var repeatStr = require('repeat-string'); +var repeat = require('repeat-element'); + +/** + * Expose `fillRange` + */ + +module.exports = fillRange; + +/** + * Return a range of numbers or letters. + * + * @param {String} `a` Start of the range + * @param {String} `b` End of the range + * @param {String} `step` Increment or decrement to use. + * @param {Function} `fn` Custom function to modify each element in the range. + * @return {Array} + */ + +function fillRange(a, b, step, options, fn) { + if (a == null || b == null) { + throw new Error('fill-range expects the first and second args to be strings.'); + } + + if (typeof step === 'function') { + fn = step; options = {}; step = null; + } + + if (typeof options === 'function') { + fn = options; options = {}; + } + + if (isObject(step)) { + options = step; step = ''; + } + + var expand, regex = false, sep = ''; + var opts = options || {}; + + if (typeof opts.silent === 'undefined') { + opts.silent = true; + } + + step = step || opts.step; + + // store a ref to unmodified arg + var origA = a, origB = b; + + b = (b.toString() === '-0') ? 0 : b; + + if (opts.optimize || opts.makeRe) { + step = step ? (step += '~') : step; + expand = true; + regex = true; + sep = '~'; + } + + // handle special step characters + if (typeof step === 'string') { + var match = stepRe().exec(step); + + if (match) { + var i = match.index; + var m = match[0]; + + // repeat string + if (m === '+') { + return repeat(a, b); + + // randomize a, `b` times + } else if (m === '?') { + return [randomize(a, b)]; + + // expand right, no regex reduction + } else if (m === '>') { + step = step.substr(0, i) + step.substr(i + 1); + expand = true; + + // expand to an array, or if valid create a reduced + // string for a regex logic `or` + } else if (m === '|') { + step = step.substr(0, i) + step.substr(i + 1); + expand = true; + regex = true; + sep = m; + + // expand to an array, or if valid create a reduced + // string for a regex range + } else if (m === '~') { + step = step.substr(0, i) + step.substr(i + 1); + expand = true; + regex = true; + sep = m; + } + } else if (!isNumber(step)) { + if (!opts.silent) { + throw new TypeError('fill-range: invalid step.'); + } + return null; + } + } + + if (/[.&*()[\]^%$#@!]/.test(a) || /[.&*()[\]^%$#@!]/.test(b)) { + if (!opts.silent) { + throw new RangeError('fill-range: invalid range arguments.'); + } + return null; + } + + // has neither a letter nor number, or has both letters and numbers + // this needs to be after the step logic + if (!noAlphaNum(a) || !noAlphaNum(b) || hasBoth(a) || hasBoth(b)) { + if (!opts.silent) { + throw new RangeError('fill-range: invalid range arguments.'); + } + return null; + } + + // validate arguments + var isNumA = isNumber(zeros(a)); + var isNumB = isNumber(zeros(b)); + + if ((!isNumA && isNumB) || (isNumA && !isNumB)) { + if (!opts.silent) { + throw new TypeError('fill-range: first range argument is incompatible with second.'); + } + return null; + } + + // by this point both are the same, so we + // can use A to check going forward. + var isNum = isNumA; + var num = formatStep(step); + + // is the range alphabetical? or numeric? + if (isNum) { + // if numeric, coerce to an integer + a = +a; b = +b; + } else { + // otherwise, get the charCode to expand alpha ranges + a = a.charCodeAt(0); + b = b.charCodeAt(0); + } + + // is the pattern descending? + var isDescending = a > b; + + // don't create a character class if the args are < 0 + if (a < 0 || b < 0) { + expand = false; + regex = false; + } + + // detect padding + var padding = isPadded(origA, origB); + var res, pad, arr = []; + var ii = 0; + + // character classes, ranges and logical `or` + if (regex) { + if (shouldExpand(a, b, num, isNum, padding, opts)) { + // make sure the correct separator is used + if (sep === '|' || sep === '~') { + sep = detectSeparator(a, b, num, isNum, isDescending); + } + return wrap([origA, origB], sep, opts); + } + } + + while (isDescending ? (a >= b) : (a <= b)) { + if (padding && isNum) { + pad = padding(a); + } + + // custom function + if (typeof fn === 'function') { + res = fn(a, isNum, pad, ii++); + + // letters + } else if (!isNum) { + if (regex && isInvalidChar(a)) { + res = null; + } else { + res = String.fromCharCode(a); + } + + // numbers + } else { + res = formatPadding(a, pad); + } + + // add result to the array, filtering any nulled values + if (res !== null) arr.push(res); + + // increment or decrement + if (isDescending) { + a -= num; + } else { + a += num; + } + } + + // now that the array is expanded, we need to handle regex + // character classes, ranges or logical `or` that wasn't + // already handled before the loop + if ((regex || expand) && !opts.noexpand) { + // make sure the correct separator is used + if (sep === '|' || sep === '~') { + sep = detectSeparator(a, b, num, isNum, isDescending); + } + if (arr.length === 1 || a < 0 || b < 0) { return arr; } + return wrap(arr, sep, opts); + } + + return arr; +} + +/** + * Wrap the string with the correct regex + * syntax. + */ + +function wrap(arr, sep, opts) { + if (sep === '~') { sep = '-'; } + var str = arr.join(sep); + var pre = opts && opts.regexPrefix; + + // regex logical `or` + if (sep === '|') { + str = pre ? pre + str : str; + str = '(' + str + ')'; + } + + // regex character class + if (sep === '-') { + str = (pre && pre === '^') + ? pre + str + : str; + str = '[' + str + ']'; + } + return [str]; +} + +/** + * Check for invalid characters + */ + +function isCharClass(a, b, step, isNum, isDescending) { + if (isDescending) { return false; } + if (isNum) { return a <= 9 && b <= 9; } + if (a < b) { return step === 1; } + return false; +} + +/** + * Detect the correct separator to use + */ + +function shouldExpand(a, b, num, isNum, padding, opts) { + if (isNum && (a > 9 || b > 9)) { return false; } + return !padding && num === 1 && a < b; +} + +/** + * Detect the correct separator to use + */ + +function detectSeparator(a, b, step, isNum, isDescending) { + var isChar = isCharClass(a, b, step, isNum, isDescending); + if (!isChar) { + return '|'; + } + return '~'; +} + +/** + * Correctly format the step based on type + */ + +function formatStep(step) { + return Math.abs(step >> 0) || 1; +} + +/** + * Format padding, taking leading `-` into account + */ + +function formatPadding(ch, pad) { + var res = pad ? pad + ch : ch; + if (pad && ch.toString().charAt(0) === '-') { + res = '-' + pad + ch.toString().substr(1); + } + return res.toString(); +} + +/** + * Check for invalid characters + */ + +function isInvalidChar(str) { + var ch = toStr(str); + return ch === '\\' + || ch === '[' + || ch === ']' + || ch === '^' + || ch === '(' + || ch === ')' + || ch === '`'; +} + +/** + * Convert to a string from a charCode + */ + +function toStr(ch) { + return String.fromCharCode(ch); +} + + +/** + * Step regex + */ + +function stepRe() { + return /\?|>|\||\+|\~/g; +} + +/** + * Return true if `val` has either a letter + * or a number + */ + +function noAlphaNum(val) { + return /[a-z0-9]/i.test(val); +} + +/** + * Return true if `val` has both a letter and + * a number (invalid) + */ + +function hasBoth(val) { + return /[a-z][0-9]|[0-9][a-z]/i.test(val); +} + +/** + * Normalize zeros for checks + */ + +function zeros(val) { + if (/^-*0+$/.test(val.toString())) { + return '0'; + } + return val; +} + +/** + * Return true if `val` has leading zeros, + * or a similar valid pattern. + */ + +function hasZeros(val) { + return /[^.]\.|^-*0+[0-9]/.test(val); +} + +/** + * If the string is padded, returns a curried function with + * the a cached padding string, or `false` if no padding. + * + * @param {*} `origA` String or number. + * @return {String|Boolean} + */ + +function isPadded(origA, origB) { + if (hasZeros(origA) || hasZeros(origB)) { + var alen = length(origA); + var blen = length(origB); + + var len = alen >= blen + ? alen + : blen; + + return function (a) { + return repeatStr('0', len - length(a)); + }; + } + return false; +} + +/** + * Get the string length of `val` + */ + +function length(val) { + return val.toString().length; +} diff --git a/tools/node_modules/fill-range/package.json b/tools/node_modules/fill-range/package.json new file mode 100644 index 00000000000000..bb5078d08e4d04 --- /dev/null +++ b/tools/node_modules/fill-range/package.json @@ -0,0 +1,122 @@ +{ + "_args": [ + [ + "fill-range@^2.1.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\expand-range" + ] + ], + "_from": "fill-range@>=2.1.0 <3.0.0", + "_id": "fill-range@2.2.3", + "_inCache": true, + "_location": "/fill-range", + "_nodeVersion": "5.0.0", + "_npmUser": { + "email": "github@sellside.com", + "name": "jonschlinkert" + }, + "_npmVersion": "3.3.6", + "_phantomChildren": {}, + "_requested": { + "name": "fill-range", + "raw": "fill-range@^2.1.0", + "rawSpec": "^2.1.0", + "scope": null, + "spec": ">=2.1.0 <3.0.0", + "type": "range" + }, + "_requiredBy": [ + "/expand-range" + ], + "_resolved": "https://registry.npmjs.org/fill-range/-/fill-range-2.2.3.tgz", + "_shasum": "50b77dfd7e469bc7492470963699fe7a8485a723", + "_shrinkwrap": null, + "_spec": "fill-range@^2.1.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\expand-range", + "author": { + "name": "Jon Schlinkert", + "url": "https://github.com/jonschlinkert" + }, + "bugs": { + "url": "https://github.com/jonschlinkert/fill-range/issues" + }, + "dependencies": { + "is-number": "^2.1.0", + "isobject": "^2.0.0", + "randomatic": "^1.1.3", + "repeat-element": "^1.1.2", + "repeat-string": "^1.5.2" + }, + "description": "Fill in a range of numbers or letters, optionally passing an increment or multiplier to use.", + "devDependencies": { + "benchmarked": "^0.1.3", + "chalk": "^0.5.1", + "should": "*" + }, + "directories": {}, + "dist": { + "shasum": "50b77dfd7e469bc7492470963699fe7a8485a723", + "tarball": "http://registry.npmjs.org/fill-range/-/fill-range-2.2.3.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "6cb50d5c679d9e6d9e8ad97bb2efd63a8c8da610", + "homepage": "https://github.com/jonschlinkert/fill-range", + "installable": true, + "keywords": [ + "alpha", + "alphabetical", + "bash", + "brace", + "expand", + "expansion", + "glob", + "match", + "matches", + "matching", + "number", + "numerical", + "range", + "ranges", + "sh" + ], + "license": "MIT", + "main": "index.js", + "maintainers": [ + { + "name": "jonschlinkert", + "email": "github@sellside.com" + }, + { + "name": "doowb", + "email": "brian.woodward@gmail.com" + }, + { + "name": "es128", + "email": "elan.shanker+npm@gmail.com" + } + ], + "name": "fill-range", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git+https://github.com/jonschlinkert/fill-range.git" + }, + "scripts": { + "test": "mocha" + }, + "verb": { + "related": { + "list": [ + "braces", + "expand-range", + "is-glob", + "micromatch" + ] + } + }, + "version": "2.2.3" +} diff --git a/tools/node_modules/for-in/LICENSE b/tools/node_modules/for-in/LICENSE new file mode 100644 index 00000000000000..fa30c4cb3e4c15 --- /dev/null +++ b/tools/node_modules/for-in/LICENSE @@ -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. diff --git a/tools/node_modules/for-in/README.md b/tools/node_modules/for-in/README.md new file mode 100644 index 00000000000000..e96af5e801e7d9 --- /dev/null +++ b/tools/node_modules/for-in/README.md @@ -0,0 +1,52 @@ +# for-in [![NPM version](https://badge.fury.io/js/for-in.svg)](http://badge.fury.io/js/for-in) + +> Iterate over the own and inherited enumerable properties of an objecte, and return an object with properties that evaluate to true from the callback. Exit early by returning `false`. JavaScript/Node.js + +## Install +#### Install with [npm](npmjs.org): + +```bash +npm i for-in --save +``` + +## Run tests + +```bash +npm test +``` + +## Usage + +```js +var forIn = require('for-in'); + +var obj = {a: 'foo', b: 'bar', c: 'baz'}; +var values = []; +var keys = []; + +forIn(obj, function (value, key, o) { + keys.push(key); + values.push(value); +}); + +console.log(keys); +//=> ['a', 'b', 'c']; + +console.log(values); +//=> ['foo', 'bar', 'baz']; +``` + +## Author + +**Jon Schlinkert** + ++ [github/jonschlinkert](https://github.com/jonschlinkert) ++ [twitter/jonschlinkert](http://twitter.com/jonschlinkert) + +## License +Copyright (c) 2014 Jon Schlinkert, contributors. +Released under the MIT license + +*** + +_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on September 20, 2014._ \ No newline at end of file diff --git a/tools/node_modules/for-in/index.js b/tools/node_modules/for-in/index.js new file mode 100644 index 00000000000000..bc7e45265b31b4 --- /dev/null +++ b/tools/node_modules/for-in/index.js @@ -0,0 +1,16 @@ +/*! + * for-in + * + * Copyright (c) 2014-2015, Jon Schlinkert. + * Licensed under the MIT License. + */ + +'use strict'; + +module.exports = function forIn(o, fn, thisArg) { + for (var key in o) { + if (fn.call(thisArg, o[key], key, o) === false) { + break; + } + } +}; \ No newline at end of file diff --git a/tools/node_modules/for-in/package.json b/tools/node_modules/for-in/package.json new file mode 100644 index 00000000000000..2db1fd9b7a40b8 --- /dev/null +++ b/tools/node_modules/for-in/package.json @@ -0,0 +1,95 @@ +{ + "_args": [ + [ + "for-in@^0.1.4", + "C:\\wamp\\www\\node\\tools\\node_modules\\for-own" + ] + ], + "_from": "for-in@>=0.1.4 <0.2.0", + "_id": "for-in@0.1.4", + "_inCache": true, + "_location": "/for-in", + "_nodeVersion": "1.6.2", + "_npmUser": { + "email": "github@sellside.com", + "name": "jonschlinkert" + }, + "_npmVersion": "2.7.1", + "_phantomChildren": {}, + "_requested": { + "name": "for-in", + "raw": "for-in@^0.1.4", + "rawSpec": "^0.1.4", + "scope": null, + "spec": ">=0.1.4 <0.2.0", + "type": "range" + }, + "_requiredBy": [ + "/for-own" + ], + "_resolved": "https://registry.npmjs.org/for-in/-/for-in-0.1.4.tgz", + "_shasum": "9f5cf7b4ffc7e1ae6591a4e97b177aa59d70fb2e", + "_shrinkwrap": null, + "_spec": "for-in@^0.1.4", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\for-own", + "author": { + "name": "Jon Schlinkert", + "url": "https://github.com/jonschlinkert" + }, + "bugs": { + "url": "https://github.com/jonschlinkert/for-in/issues" + }, + "dependencies": {}, + "description": "Iterate over the own and inherited enumerable properties of an objecte, and return an object with properties that evaluate to true from the callback. Exit early by returning `false`. JavaScript/Node.js", + "devDependencies": { + "mocha": "*", + "should": "^4.0.4" + }, + "directories": {}, + "dist": { + "shasum": "9f5cf7b4ffc7e1ae6591a4e97b177aa59d70fb2e", + "tarball": "http://registry.npmjs.org/for-in/-/for-in-0.1.4.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "fb09612d3e4137486c652a328888872eba5c1548", + "homepage": "https://github.com/jonschlinkert/for-in", + "installable": true, + "keywords": [ + "for-in", + "for-own", + "has", + "has-own", + "hasOwn", + "key", + "keys", + "object", + "own", + "value" + ], + "license": { + "type": "MIT", + "url": "https://github.com/jonschlinkert/for-in/blob/master/LICENSE" + }, + "main": "index.js", + "maintainers": [ + { + "name": "jonschlinkert", + "email": "github@sellside.com" + } + ], + "name": "for-in", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git://github.com/jonschlinkert/for-in.git" + }, + "scripts": { + "test": "mocha" + }, + "version": "0.1.4" +} diff --git a/tools/node_modules/for-own/LICENSE b/tools/node_modules/for-own/LICENSE new file mode 100644 index 00000000000000..fa30c4cb3e4c15 --- /dev/null +++ b/tools/node_modules/for-own/LICENSE @@ -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. diff --git a/tools/node_modules/for-own/README.md b/tools/node_modules/for-own/README.md new file mode 100644 index 00000000000000..c9cf429b529a0f --- /dev/null +++ b/tools/node_modules/for-own/README.md @@ -0,0 +1,52 @@ +# for-own [![NPM version](https://badge.fury.io/js/for-own.svg)](http://badge.fury.io/js/for-own) + +> Iterate over the own and inherited enumerable properties of an object, and return an object with properties that evaluate to true from the callback. Exit early by returning `false`. + +## Install +#### Install with [npm](npmjs.org): + +```bash +npm i for-own --save +``` + +## Run tests + +```bash +npm test +``` + +## Usage + +```js +var forOwn = require('for-own'); + +var obj = {a: 'foo', b: 'bar', c: 'baz'}; +var values = []; +var keys = []; + +forOwn(obj, function (value, key, o) { + keys.push(key); + values.push(value); +}); + +console.log(keys); +//=> ['a', 'b', 'c']; + +console.log(values); +//=> ['foo', 'bar', 'baz']; +``` + +## Author + +**Jon Schlinkert** + ++ [github/jonschlinkert](https://github.com/jonschlinkert) ++ [twitter/jonschlinkert](http://twitter.com/jonschlinkert) + +## License +Copyright (c) 2014 Jon Schlinkert, contributors. +Released under the MIT license + +*** + +_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on September 20, 2014._ \ No newline at end of file diff --git a/tools/node_modules/for-own/index.js b/tools/node_modules/for-own/index.js new file mode 100644 index 00000000000000..966294b306f37a --- /dev/null +++ b/tools/node_modules/for-own/index.js @@ -0,0 +1,19 @@ +/*! + * for-own + * + * Copyright (c) 2014-2015, Jon Schlinkert. + * Licensed under the MIT License. + */ + +'use strict'; + +var forIn = require('for-in'); +var hasOwn = Object.prototype.hasOwnProperty; + +module.exports = function forOwn(o, fn, thisArg) { + forIn(o, function (val, key) { + if (hasOwn.call(o, key)) { + return fn.call(thisArg, o[key], key, o); + } + }); +}; diff --git a/tools/node_modules/for-own/package.json b/tools/node_modules/for-own/package.json new file mode 100644 index 00000000000000..9165b0473edb7a --- /dev/null +++ b/tools/node_modules/for-own/package.json @@ -0,0 +1,97 @@ +{ + "_args": [ + [ + "for-own@^0.1.3", + "C:\\wamp\\www\\node\\tools\\node_modules\\object.omit" + ] + ], + "_from": "for-own@>=0.1.3 <0.2.0", + "_id": "for-own@0.1.3", + "_inCache": true, + "_location": "/for-own", + "_nodeVersion": "1.6.2", + "_npmUser": { + "email": "github@sellside.com", + "name": "jonschlinkert" + }, + "_npmVersion": "2.7.1", + "_phantomChildren": {}, + "_requested": { + "name": "for-own", + "raw": "for-own@^0.1.3", + "rawSpec": "^0.1.3", + "scope": null, + "spec": ">=0.1.3 <0.2.0", + "type": "range" + }, + "_requiredBy": [ + "/object.omit" + ], + "_resolved": "https://registry.npmjs.org/for-own/-/for-own-0.1.3.tgz", + "_shasum": "606444cde77c2f0a11088169e2e354eaf56e74fe", + "_shrinkwrap": null, + "_spec": "for-own@^0.1.3", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\object.omit", + "author": { + "name": "Jon Schlinkert", + "url": "https://github.com/jonschlinkert" + }, + "bugs": { + "url": "https://github.com/jonschlinkert/for-own/issues" + }, + "dependencies": { + "for-in": "^0.1.4" + }, + "description": "Iterate over the own enumerable properties of an object, and return an object with properties that evaluate to true from the callback. Exit early by returning `false`. JavaScript/Node.js.", + "devDependencies": { + "mocha": "*", + "should": "^5.2.0" + }, + "directories": {}, + "dist": { + "shasum": "606444cde77c2f0a11088169e2e354eaf56e74fe", + "tarball": "http://registry.npmjs.org/for-own/-/for-own-0.1.3.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "43c5291f22b71297e1b5855236fcc35ac9ce51e4", + "homepage": "https://github.com/jonschlinkert/for-own", + "installable": true, + "keywords": [ + "for-in", + "for-own", + "has", + "has-own", + "hasOwn", + "key", + "keys", + "object", + "own", + "value" + ], + "license": { + "type": "MIT", + "url": "https://github.com/jonschlinkert/for-own/blob/master/LICENSE" + }, + "main": "index.js", + "maintainers": [ + { + "name": "jonschlinkert", + "email": "github@sellside.com" + } + ], + "name": "for-own", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git://github.com/jonschlinkert/for-own.git" + }, + "scripts": { + "test": "mocha" + }, + "version": "0.1.3" +} diff --git a/tools/node_modules/glob-base/LICENSE b/tools/node_modules/glob-base/LICENSE new file mode 100644 index 00000000000000..65f90aca8c2fff --- /dev/null +++ b/tools/node_modules/glob-base/LICENSE @@ -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. diff --git a/tools/node_modules/glob-base/README.md b/tools/node_modules/glob-base/README.md new file mode 100644 index 00000000000000..1da2e82f15b6cb --- /dev/null +++ b/tools/node_modules/glob-base/README.md @@ -0,0 +1,158 @@ +# glob-base [![NPM version](https://badge.fury.io/js/glob-base.svg)](http://badge.fury.io/js/glob-base) [![Build Status](https://travis-ci.org/jonschlinkert/glob-base.svg)](https://travis-ci.org/jonschlinkert/glob-base) + +> Returns an object with the (non-glob) base path and the actual pattern. + +Use [glob-parent](https://github.com/es128/glob-parent) if you just want the base path. + +## Install with [npm](npmjs.org) + +```bash +npm i glob-base --save +``` + +## Related projects +* [glob-parent](https://github.com/es128/glob-parent): Strips glob magic from a string to provide the parent path +* [micromatch](https://github.com/jonschlinkert/micromatch): Glob matching for javascript/node.js. A faster alternative to minimatch (10-45x faster on avg), with all the features you're used to using in your Grunt and gulp tasks. +* [parse-glob](https://github.com/jonschlinkert/parse-glob): Parse a glob pattern into an object of tokens. +* [is-glob](https://github.com/jonschlinkert/is-glob): Returns `true` if the given string looks like a glob pattern. +* [braces](https://github.com/jonschlinkert/braces): Fastest brace expansion for node.js, with the most complete support for the Bash 4.3 braces specification. +* [fill-range](https://github.com/jonschlinkert/fill-range): Fill in a range of numbers or letters, optionally passing an increment or multiplier to use. +* [expand-range](https://github.com/jonschlinkert/expand-range): Fast, bash-like range expansion. Expand a range of numbers or letters, uppercase or lowercase. See the benchmarks. Used by micromatch. + +## Usage + +```js +var globBase = require('glob-base'); + +globBase('a/b/.git/'); +//=> { base: 'a/b/.git/', isGlob: false, glob: '' }) + +globBase('a/b/**/e'); +//=> { base: 'a/b', isGlob: true, glob: '**/e' } + +globBase('a/b/*.{foo,bar}'); +//=> { base: 'a/b', isGlob: true, glob: '*.{foo,bar}' } + +globBase('a/b/.git/**'); +//=> { base: 'a/b/.git', isGlob: true, glob: '**' } + +globBase('a/b/c/*.md'); +//=> { base: 'a/b/c', isGlob: true, glob: '*.md' } + +globBase('a/b/c/.*.md'); +//=> { base: 'a/b/c', isGlob: true, glob: '.*.md' } + +globBase('a/b/{c,d}'); +//=> { base: 'a/b', isGlob: true, glob: '{c,d}' } + +globBase('!*.min.js'); +//=> { base: '.', isGlob: true, glob: '!*.min.js' } + +globBase('!foo'); +//=> { base: '.', isGlob: true, glob: '!foo' } + +globBase('!foo/(a|b).min.js'); +//=> { base: '.', isGlob: true, glob: '!foo/(a|b).min.js' } + +globBase(''); +//=> { base: '.', isGlob: false, glob: '' } + +globBase('**/*.md'); +//=> { base: '.', isGlob: true, glob: '**/*.md' } + +globBase('**/*.min.js'); +//=> { base: '.', isGlob: true, glob: '**/*.min.js' } + +globBase('**/.*'); +//=> { base: '.', isGlob: true, glob: '**/.*' } + +globBase('**/d'); +//=> { base: '.', isGlob: true, glob: '**/d' } + +globBase('*.*'); +//=> { base: '.', isGlob: true, glob: '*.*' } + +globBase('*.min.js'); +//=> { base: '.', isGlob: true, glob: '*.min.js' } + +globBase('*/*'); +//=> { base: '.', isGlob: true, glob: '*/*' } + +globBase('*b'); +//=> { base: '.', isGlob: true, glob: '*b' } + +globBase('.'); +//=> { base: '.', isGlob: false, glob: '.' } + +globBase('.*'); +//=> { base: '.', isGlob: true, glob: '.*' } + +globBase('./*'); +//=> { base: '.', isGlob: true, glob: '*' } + +globBase('/a'); +//=> { base: '/', isGlob: false, glob: 'a' } + +globBase('@(a|b)/e.f.g/'); +//=> { base: '.', isGlob: true, glob: '@(a|b)/e.f.g/' } + +globBase('[a-c]b*'); +//=> { base: '.', isGlob: true, glob: '[a-c]b*' } + +globBase('a'); +//=> { base: '.', isGlob: false, glob: 'a' } + +globBase('a.min.js'); +//=> { base: '.', isGlob: false, glob: 'a.min.js' } + +globBase('a/'); +//=> { base: 'a/', isGlob: false, glob: '' } + +globBase('a/**/j/**/z/*.md'); +//=> { base: 'a', isGlob: true, glob: '**/j/**/z/*.md' } + +globBase('a/*/c/*.md'); +//=> { base: 'a', isGlob: true, glob: '*/c/*.md' } + +globBase('a/?/c.md'); +//=> { base: 'a', isGlob: true, glob: '?/c.md' } + +globBase('a/??/c.js'); +//=> { base: 'a', isGlob: true, glob: '??/c.js' } + +globBase('a?b'); +//=> { base: '.', isGlob: true, glob: 'a?b' } + +globBase('bb'); +//=> { base: '.', isGlob: false, glob: 'bb' } + +globBase('c.md'); +//=> { base: '.', isGlob: false, glob: 'c.md' } +``` + +## Running tests +Install dev dependencies. + +```bash +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/glob-base/issues) + + +## Author + +**Jon Schlinkert** + ++ [github/jonschlinkert](https://github.com/jonschlinkert) ++ [twitter/jonschlinkert](http://twitter.com/jonschlinkert) + +## License +Copyright (c) 2015 Jon Schlinkert +Released under the MIT license + +*** + +_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on March 08, 2015._ diff --git a/tools/node_modules/glob-base/index.js b/tools/node_modules/glob-base/index.js new file mode 100644 index 00000000000000..564b4a8854f328 --- /dev/null +++ b/tools/node_modules/glob-base/index.js @@ -0,0 +1,51 @@ +/*! + * glob-base + * + * Copyright (c) 2015, Jon Schlinkert. + * Licensed under the MIT License. + */ + +'use strict'; + +var path = require('path'); +var parent = require('glob-parent'); +var isGlob = require('is-glob'); + +module.exports = function globBase(pattern) { + if (typeof pattern !== 'string') { + throw new TypeError('glob-base expects a string.'); + } + + var res = {}; + res.base = parent(pattern); + res.isGlob = isGlob(pattern); + + if (res.base !== '.') { + res.glob = pattern.substr(res.base.length); + if (res.glob.charAt(0) === '/') { + res.glob = res.glob.substr(1); + } + } else { + res.glob = pattern; + } + + if (!res.isGlob) { + res.base = dirname(pattern); + res.glob = res.base !== '.' + ? pattern.substr(res.base.length) + : pattern; + } + + if (res.glob.substr(0, 2) === './') { + res.glob = res.glob.substr(2); + } + if (res.glob.charAt(0) === '/') { + res.glob = res.glob.substr(1); + } + return res; +}; + +function dirname(glob) { + if (glob.slice(-1) === '/') return glob; + return path.dirname(glob); +} diff --git a/tools/node_modules/glob-base/package.json b/tools/node_modules/glob-base/package.json new file mode 100644 index 00000000000000..896981cbd32946 --- /dev/null +++ b/tools/node_modules/glob-base/package.json @@ -0,0 +1,107 @@ +{ + "_args": [ + [ + "glob-base@^0.3.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\parse-glob" + ] + ], + "_from": "glob-base@>=0.3.0 <0.4.0", + "_id": "glob-base@0.3.0", + "_inCache": true, + "_location": "/glob-base", + "_nodeVersion": "0.12.7", + "_npmUser": { + "email": "elan.shanker+npm@gmail.com", + "name": "es128" + }, + "_npmVersion": "2.11.3", + "_phantomChildren": {}, + "_requested": { + "name": "glob-base", + "raw": "glob-base@^0.3.0", + "rawSpec": "^0.3.0", + "scope": null, + "spec": ">=0.3.0 <0.4.0", + "type": "range" + }, + "_requiredBy": [ + "/parse-glob" + ], + "_resolved": "https://registry.npmjs.org/glob-base/-/glob-base-0.3.0.tgz", + "_shasum": "dbb164f6221b1c0b1ccf82aea328b497df0ea3c4", + "_shrinkwrap": null, + "_spec": "glob-base@^0.3.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\parse-glob", + "author": { + "name": "Jon Schlinkert", + "url": "https://github.com/jonschlinkert" + }, + "bugs": { + "url": "https://github.com/jonschlinkert/glob-base/issues" + }, + "dependencies": { + "glob-parent": "^2.0.0", + "is-glob": "^2.0.0" + }, + "description": "Returns an object with the (non-glob) base path and the actual pattern.", + "devDependencies": { + "mocha": "*", + "should": "^5.1.0" + }, + "directories": {}, + "dist": { + "shasum": "dbb164f6221b1c0b1ccf82aea328b497df0ea3c4", + "tarball": "http://registry.npmjs.org/glob-base/-/glob-base-0.3.0.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "adbc0ab07ec8a85f76ffd1b54dd41cdb9d1d0b83", + "homepage": "https://github.com/jonschlinkert/glob-base", + "installable": true, + "keywords": [ + "base", + "directory", + "dirname", + "expression", + "glob", + "parent", + "path", + "pattern", + "regex", + "regular", + "root" + ], + "license": { + "type": "MIT", + "url": "https://github.com/jonschlinkert/glob-base/blob/master/LICENSE" + }, + "main": "index.js", + "maintainers": [ + { + "name": "doowb", + "email": "brian.woodward@gmail.com" + }, + { + "name": "es128", + "email": "elan.shanker+npm@gmail.com" + }, + { + "name": "jonschlinkert", + "email": "github@sellside.com" + } + ], + "name": "glob-base", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git://github.com/jonschlinkert/glob-base.git" + }, + "scripts": { + "test": "mocha" + }, + "version": "0.3.0" +} diff --git a/tools/node_modules/glob-parent/.npmignore b/tools/node_modules/glob-parent/.npmignore new file mode 100644 index 00000000000000..33e391f0e0827e --- /dev/null +++ b/tools/node_modules/glob-parent/.npmignore @@ -0,0 +1,4 @@ +node_modules +.DS_Store +npm-debug.log +coverage diff --git a/tools/node_modules/glob-parent/.travis.yml b/tools/node_modules/glob-parent/.travis.yml new file mode 100644 index 00000000000000..18fc42f69f5b0a --- /dev/null +++ b/tools/node_modules/glob-parent/.travis.yml @@ -0,0 +1,8 @@ +language: node_js +node_js: + - "4" + - "iojs-v3" + - "iojs-v2" + - "iojs-v1" + - "0.12" + - "0.10" diff --git a/tools/node_modules/glob-parent/LICENSE b/tools/node_modules/glob-parent/LICENSE new file mode 100644 index 00000000000000..734076d8affcff --- /dev/null +++ b/tools/node_modules/glob-parent/LICENSE @@ -0,0 +1,15 @@ +The ISC License + +Copyright (c) 2015 Elan Shanker + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR +IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/tools/node_modules/glob-parent/README.md b/tools/node_modules/glob-parent/README.md new file mode 100644 index 00000000000000..ff5310d3b4ce9b --- /dev/null +++ b/tools/node_modules/glob-parent/README.md @@ -0,0 +1,43 @@ +glob-parent [![Build Status](https://travis-ci.org/es128/glob-parent.svg)](https://travis-ci.org/es128/glob-parent) [![Coverage Status](https://img.shields.io/coveralls/es128/glob-parent.svg)](https://coveralls.io/r/es128/glob-parent?branch=master) +====== +Javascript module to extract the non-magic parent path from a glob string. + +[![NPM](https://nodei.co/npm/glob-parent.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/glob-parent/) +[![NPM](https://nodei.co/npm-dl/glob-parent.png?height=3&months=9)](https://nodei.co/npm-dl/glob-parent/) + +Usage +----- +```sh +npm install glob-parent --save +``` + +```js +var globParent = require('glob-parent'); + +globParent('path/to/*.js'); // 'path/to' +globParent('/root/path/to/*.js'); // '/root/path/to' +globParent('/*.js'); // '/' +globParent('*.js'); // '.' +globParent('**/*.js'); // '.' +globParent('path/{to,from}'); // 'path' +globParent('path/!(to|from)'); // 'path' +globParent('path/?(to|from)'); // 'path' +globParent('path/+(to|from)'); // 'path' +globParent('path/*(to|from)'); // 'path' +globParent('path/@(to|from)'); // 'path' +globParent('path/**/*'); // 'path' + +// if provided a non-glob path, returns the nearest dir +globParent('path/foo/bar.js'); // 'path/foo' +globParent('path/foo/'); // 'path/foo' +globParent('path/foo'); // 'path' (see issue #3 for details) + +``` + +Change Log +---------- +[See release notes page on GitHub](https://github.com/es128/glob-parent/releases) + +License +------- +[ISC](https://raw.github.com/es128/glob-parent/master/LICENSE) diff --git a/tools/node_modules/glob-parent/index.js b/tools/node_modules/glob-parent/index.js new file mode 100644 index 00000000000000..61615f1ac06ce9 --- /dev/null +++ b/tools/node_modules/glob-parent/index.js @@ -0,0 +1,10 @@ +'use strict'; + +var path = require('path'); +var isglob = require('is-glob'); + +module.exports = function globParent(str) { + str += 'a'; // preserves full path in case of trailing path separator + do {str = path.dirname(str)} while (isglob(str)); + return str; +}; diff --git a/tools/node_modules/glob-parent/package.json b/tools/node_modules/glob-parent/package.json new file mode 100644 index 00000000000000..d41dd82d057430 --- /dev/null +++ b/tools/node_modules/glob-parent/package.json @@ -0,0 +1,85 @@ +{ + "_args": [ + [ + "glob-parent@^2.0.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\chokidar" + ] + ], + "_from": "glob-parent@>=2.0.0 <3.0.0", + "_id": "glob-parent@2.0.0", + "_inCache": true, + "_location": "/glob-parent", + "_nodeVersion": "3.0.0", + "_npmUser": { + "email": "elan.shanker+npm@gmail.com", + "name": "es128" + }, + "_npmVersion": "2.13.3", + "_phantomChildren": {}, + "_requested": { + "name": "glob-parent", + "raw": "glob-parent@^2.0.0", + "rawSpec": "^2.0.0", + "scope": null, + "spec": ">=2.0.0 <3.0.0", + "type": "range" + }, + "_requiredBy": [ + "/chokidar", + "/glob-base" + ], + "_resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-2.0.0.tgz", + "_shasum": "81383d72db054fcccf5336daa902f182f6edbb28", + "_shrinkwrap": null, + "_spec": "glob-parent@^2.0.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\chokidar", + "author": { + "name": "Elan Shanker" + }, + "bugs": { + "url": "https://github.com/es128/glob-parent/issues" + }, + "dependencies": { + "is-glob": "^2.0.0" + }, + "description": "Strips glob magic from a string to provide the parent path", + "devDependencies": { + "coveralls": "^2.11.2", + "istanbul": "^0.3.5", + "mocha": "^2.1.0" + }, + "directories": {}, + "dist": { + "shasum": "81383d72db054fcccf5336daa902f182f6edbb28", + "tarball": "http://registry.npmjs.org/glob-parent/-/glob-parent-2.0.0.tgz" + }, + "gitHead": "a956910c7ccb5eafd1b3fe900ceb6335cc5b6d3d", + "homepage": "https://github.com/es128/glob-parent", + "installable": true, + "keywords": [ + "base", + "directory", + "glob", + "parent", + "path", + "strip" + ], + "license": "ISC", + "main": "index.js", + "maintainers": [ + { + "name": "es128", + "email": "elan.shanker+npm@gmail.com" + } + ], + "name": "glob-parent", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git+https://github.com/es128/glob-parent.git" + }, + "scripts": { + "test": "istanbul cover _mocha && cat ./coverage/lcov.info | coveralls" + }, + "version": "2.0.0" +} diff --git a/tools/node_modules/glob-parent/test.js b/tools/node_modules/glob-parent/test.js new file mode 100644 index 00000000000000..01156d2ff0d885 --- /dev/null +++ b/tools/node_modules/glob-parent/test.js @@ -0,0 +1,28 @@ +'use strict'; + +var gp = require('./'); +var assert = require('assert'); + +describe('glob-parent', function() { + it('should strip glob magic to return parent path', function() { + assert.equal(gp('path/to/*.js'), 'path/to'); + assert.equal(gp('/root/path/to/*.js'), '/root/path/to'); + assert.equal(gp('/*.js'), '/'); + assert.equal(gp('*.js'), '.'); + assert.equal(gp('**/*.js'), '.'); + assert.equal(gp('path/{to,from}'), 'path'); + assert.equal(gp('path/!(to|from)'), 'path'); + assert.equal(gp('path/?(to|from)'), 'path'); + assert.equal(gp('path/+(to|from)'), 'path'); + assert.equal(gp('path/*(to|from)'), 'path'); + assert.equal(gp('path/@(to|from)'), 'path'); + assert.equal(gp('path/**/*'), 'path'); + assert.equal(gp('path/**/subdir/foo.*'), 'path'); + }); + + it('should return parent dirname from non-glob paths', function() { + assert.equal(gp('path/foo/bar.js'), 'path/foo'); + assert.equal(gp('path/foo/'), 'path/foo'); + assert.equal(gp('path/foo'), 'path'); + }); +}); diff --git a/tools/node_modules/glob/LICENSE b/tools/node_modules/glob/LICENSE new file mode 100644 index 00000000000000..19129e315fe593 --- /dev/null +++ b/tools/node_modules/glob/LICENSE @@ -0,0 +1,15 @@ +The ISC License + +Copyright (c) Isaac Z. Schlueter and Contributors + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR +IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/tools/node_modules/glob/README.md b/tools/node_modules/glob/README.md new file mode 100644 index 00000000000000..6960483bac63c6 --- /dev/null +++ b/tools/node_modules/glob/README.md @@ -0,0 +1,359 @@ +# Glob + +Match files using the patterns the shell uses, like stars and stuff. + +[![Build Status](https://travis-ci.org/isaacs/node-glob.svg?branch=master)](https://travis-ci.org/isaacs/node-glob/) [![Build Status](https://ci.appveyor.com/api/projects/status/kd7f3yftf7unxlsx?svg=true)](https://ci.appveyor.com/project/isaacs/node-glob) [![Coverage Status](https://coveralls.io/repos/isaacs/node-glob/badge.svg?branch=master&service=github)](https://coveralls.io/github/isaacs/node-glob?branch=master) + +This is a glob implementation in JavaScript. It uses the `minimatch` +library to do its matching. + +![](oh-my-glob.gif) + +## Usage + +```javascript +var glob = require("glob") + +// options is optional +glob("**/*.js", options, function (er, files) { + // files is an array of filenames. + // If the `nonull` option is set, and nothing + // was found, then files is ["**/*.js"] + // er is an error object or null. +}) +``` + +## Glob Primer + +"Globs" are the patterns you type when you do stuff like `ls *.js` on +the command line, or put `build/*` in a `.gitignore` file. + +Before parsing the path part patterns, braced sections are expanded +into a set. Braced sections start with `{` and end with `}`, with any +number of comma-delimited sections within. Braced sections may contain +slash characters, so `a{/b/c,bcd}` would expand into `a/b/c` and `abcd`. + +The following characters have special magic meaning when used in a +path portion: + +* `*` Matches 0 or more characters in a single path portion +* `?` Matches 1 character +* `[...]` Matches a range of characters, similar to a RegExp range. + If the first character of the range is `!` or `^` then it matches + any character not in the range. +* `!(pattern|pattern|pattern)` Matches anything that does not match + any of the patterns provided. +* `?(pattern|pattern|pattern)` Matches zero or one occurrence of the + patterns provided. +* `+(pattern|pattern|pattern)` Matches one or more occurrences of the + patterns provided. +* `*(a|b|c)` Matches zero or more occurrences of the patterns provided +* `@(pattern|pat*|pat?erN)` Matches exactly one of the patterns + provided +* `**` If a "globstar" is alone in a path portion, then it matches + zero or more directories and subdirectories searching for matches. + It does not crawl symlinked directories. + +### Dots + +If a file or directory path portion has a `.` as the first character, +then it will not match any glob pattern unless that pattern's +corresponding path part also has a `.` as its first character. + +For example, the pattern `a/.*/c` would match the file at `a/.b/c`. +However the pattern `a/*/c` would not, because `*` does not start with +a dot character. + +You can make glob treat dots as normal characters by setting +`dot:true` in the options. + +### Basename Matching + +If you set `matchBase:true` in the options, and the pattern has no +slashes in it, then it will seek for any file anywhere in the tree +with a matching basename. For example, `*.js` would match +`test/simple/basic.js`. + +### Empty Sets + +If no matching files are found, then an empty array is returned. This +differs from the shell, where the pattern itself is returned. For +example: + + $ echo a*s*d*f + a*s*d*f + +To get the bash-style behavior, set the `nonull:true` in the options. + +### See Also: + +* `man sh` +* `man bash` (Search for "Pattern Matching") +* `man 3 fnmatch` +* `man 5 gitignore` +* [minimatch documentation](https://github.com/isaacs/minimatch) + +## glob.hasMagic(pattern, [options]) + +Returns `true` if there are any special characters in the pattern, and +`false` otherwise. + +Note that the options affect the results. If `noext:true` is set in +the options object, then `+(a|b)` will not be considered a magic +pattern. If the pattern has a brace expansion, like `a/{b/c,x/y}` +then that is considered magical, unless `nobrace:true` is set in the +options. + +## glob(pattern, [options], cb) + +* `pattern` `{String}` Pattern to be matched +* `options` `{Object}` +* `cb` `{Function}` + * `err` `{Error | null}` + * `matches` `{Array}` filenames found matching the pattern + +Perform an asynchronous glob search. + +## glob.sync(pattern, [options]) + +* `pattern` `{String}` Pattern to be matched +* `options` `{Object}` +* return: `{Array}` filenames found matching the pattern + +Perform a synchronous glob search. + +## Class: glob.Glob + +Create a Glob object by instantiating the `glob.Glob` class. + +```javascript +var Glob = require("glob").Glob +var mg = new Glob(pattern, options, cb) +``` + +It's an EventEmitter, and starts walking the filesystem to find matches +immediately. + +### new glob.Glob(pattern, [options], [cb]) + +* `pattern` `{String}` pattern to search for +* `options` `{Object}` +* `cb` `{Function}` Called when an error occurs, or matches are found + * `err` `{Error | null}` + * `matches` `{Array}` filenames found matching the pattern + +Note that if the `sync` flag is set in the options, then matches will +be immediately available on the `g.found` member. + +### Properties + +* `minimatch` The minimatch object that the glob uses. +* `options` The options object passed in. +* `aborted` Boolean which is set to true when calling `abort()`. There + is no way at this time to continue a glob search after aborting, but + you can re-use the statCache to avoid having to duplicate syscalls. +* `cache` Convenience object. Each field has the following possible + values: + * `false` - Path does not exist + * `true` - Path exists + * `'FILE'` - Path exists, and is not a directory + * `'DIR'` - Path exists, and is a directory + * `[file, entries, ...]` - Path exists, is a directory, and the + array value is the results of `fs.readdir` +* `statCache` Cache of `fs.stat` results, to prevent statting the same + path multiple times. +* `symlinks` A record of which paths are symbolic links, which is + relevant in resolving `**` patterns. +* `realpathCache` An optional object which is passed to `fs.realpath` + to minimize unnecessary syscalls. It is stored on the instantiated + Glob object, and may be re-used. + +### Events + +* `end` When the matching is finished, this is emitted with all the + matches found. If the `nonull` option is set, and no match was found, + then the `matches` list contains the original pattern. The matches + are sorted, unless the `nosort` flag is set. +* `match` Every time a match is found, this is emitted with the specific + thing that matched. It is not deduplicated or resolved to a realpath. +* `error` Emitted when an unexpected error is encountered, or whenever + any fs error occurs if `options.strict` is set. +* `abort` When `abort()` is called, this event is raised. + +### Methods + +* `pause` Temporarily stop the search +* `resume` Resume the search +* `abort` Stop the search forever + +### Options + +All the options that can be passed to Minimatch can also be passed to +Glob to change pattern matching behavior. Also, some have been added, +or have glob-specific ramifications. + +All options are false by default, unless otherwise noted. + +All options are added to the Glob object, as well. + +If you are running many `glob` operations, you can pass a Glob object +as the `options` argument to a subsequent operation to shortcut some +`stat` and `readdir` calls. At the very least, you may pass in shared +`symlinks`, `statCache`, `realpathCache`, and `cache` options, so that +parallel glob operations will be sped up by sharing information about +the filesystem. + +* `cwd` The current working directory in which to search. Defaults + to `process.cwd()`. +* `root` The place where patterns starting with `/` will be mounted + onto. Defaults to `path.resolve(options.cwd, "/")` (`/` on Unix + systems, and `C:\` or some such on Windows.) +* `dot` Include `.dot` files in normal matches and `globstar` matches. + Note that an explicit dot in a portion of the pattern will always + match dot files. +* `nomount` By default, a pattern starting with a forward-slash will be + "mounted" onto the root setting, so that a valid filesystem path is + returned. Set this flag to disable that behavior. +* `mark` Add a `/` character to directory matches. Note that this + requires additional stat calls. +* `nosort` Don't sort the results. +* `stat` Set to true to stat *all* results. This reduces performance + somewhat, and is completely unnecessary, unless `readdir` is presumed + to be an untrustworthy indicator of file existence. +* `silent` When an unusual error is encountered when attempting to + read a directory, a warning will be printed to stderr. Set the + `silent` option to true to suppress these warnings. +* `strict` When an unusual error is encountered when attempting to + read a directory, the process will just continue on in search of + other matches. Set the `strict` option to raise an error in these + cases. +* `cache` See `cache` property above. Pass in a previously generated + cache object to save some fs calls. +* `statCache` A cache of results of filesystem information, to prevent + unnecessary stat calls. While it should not normally be necessary + to set this, you may pass the statCache from one glob() call to the + options object of another, if you know that the filesystem will not + change between calls. (See "Race Conditions" below.) +* `symlinks` A cache of known symbolic links. You may pass in a + previously generated `symlinks` object to save `lstat` calls when + resolving `**` matches. +* `sync` DEPRECATED: use `glob.sync(pattern, opts)` instead. +* `nounique` In some cases, brace-expanded patterns can result in the + same file showing up multiple times in the result set. By default, + this implementation prevents duplicates in the result set. Set this + flag to disable that behavior. +* `nonull` Set to never return an empty set, instead returning a set + containing the pattern itself. This is the default in glob(3). +* `debug` Set to enable debug logging in minimatch and glob. +* `nobrace` Do not expand `{a,b}` and `{1..3}` brace sets. +* `noglobstar` Do not match `**` against multiple filenames. (Ie, + treat it as a normal `*` instead.) +* `noext` Do not match `+(a|b)` "extglob" patterns. +* `nocase` Perform a case-insensitive match. Note: on + case-insensitive filesystems, non-magic patterns will match by + default, since `stat` and `readdir` will not raise errors. +* `matchBase` Perform a basename-only match if the pattern does not + contain any slash characters. That is, `*.js` would be treated as + equivalent to `**/*.js`, matching all js files in all directories. +* `nodir` Do not match directories, only files. (Note: to match + *only* directories, simply put a `/` at the end of the pattern.) +* `ignore` Add a pattern or an array of glob patterns to exclude matches. + Note: `ignore` patterns are *always* in `dot:true` mode, regardless + of any other settings. +* `follow` Follow symlinked directories when expanding `**` patterns. + Note that this can result in a lot of duplicate references in the + presence of cyclic links. +* `realpath` Set to true to call `fs.realpath` on all of the results. + In the case of a symlink that cannot be resolved, the full absolute + path to the matched entry is returned (though it will usually be a + broken symlink) + +## Comparisons to other fnmatch/glob implementations + +While strict compliance with the existing standards is a worthwhile +goal, some discrepancies exist between node-glob and other +implementations, and are intentional. + +The double-star character `**` is supported by default, unless the +`noglobstar` flag is set. This is supported in the manner of bsdglob +and bash 4.3, where `**` only has special significance if it is the only +thing in a path part. That is, `a/**/b` will match `a/x/y/b`, but +`a/**b` will not. + +Note that symlinked directories are not crawled as part of a `**`, +though their contents may match against subsequent portions of the +pattern. This prevents infinite loops and duplicates and the like. + +If an escaped pattern has no matches, and the `nonull` flag is set, +then glob returns the pattern as-provided, rather than +interpreting the character escapes. For example, +`glob.match([], "\\*a\\?")` will return `"\\*a\\?"` rather than +`"*a?"`. This is akin to setting the `nullglob` option in bash, except +that it does not resolve escaped pattern characters. + +If brace expansion is not disabled, then it is performed before any +other interpretation of the glob pattern. Thus, a pattern like +`+(a|{b),c)}`, which would not be valid in bash or zsh, is expanded +**first** into the set of `+(a|b)` and `+(a|c)`, and those patterns are +checked for validity. Since those two are valid, matching proceeds. + +### Comments and Negation + +Previously, this module let you mark a pattern as a "comment" if it +started with a `#` character, or a "negated" pattern if it started +with a `!` character. + +These options were deprecated in version 5, and removed in version 6. + +To specify things that should not match, use the `ignore` option. + +## Windows + +**Please only use forward-slashes in glob expressions.** + +Though windows uses either `/` or `\` as its path separator, only `/` +characters are used by this glob implementation. You must use +forward-slashes **only** in glob expressions. Back-slashes will always +be interpreted as escape characters, not path separators. + +Results from absolute patterns such as `/foo/*` are mounted onto the +root setting using `path.join`. On windows, this will by default result +in `/foo/*` matching `C:\foo\bar.txt`. + +## Race Conditions + +Glob searching, by its very nature, is susceptible to race conditions, +since it relies on directory walking and such. + +As a result, it is possible that a file that exists when glob looks for +it may have been deleted or modified by the time it returns the result. + +As part of its internal implementation, this program caches all stat +and readdir calls that it makes, in order to cut down on system +overhead. However, this also makes it even more susceptible to races, +especially if the cache or statCache objects are reused between glob +calls. + +Users are thus advised not to use a glob result as a guarantee of +filesystem state in the face of rapid changes. For the vast majority +of operations, this is never a problem. + +## Contributing + +Any change to behavior (including bugfixes) must come with a test. + +Patches that fail tests or reduce performance will be rejected. + +``` +# to run tests +npm test + +# to re-generate test fixtures +npm run test-regen + +# to benchmark against bash/zsh +npm run bench + +# to profile javascript +npm run prof +``` diff --git a/tools/node_modules/glob/common.js b/tools/node_modules/glob/common.js new file mode 100644 index 00000000000000..c9127eb334f18b --- /dev/null +++ b/tools/node_modules/glob/common.js @@ -0,0 +1,226 @@ +exports.alphasort = alphasort +exports.alphasorti = alphasorti +exports.setopts = setopts +exports.ownProp = ownProp +exports.makeAbs = makeAbs +exports.finish = finish +exports.mark = mark +exports.isIgnored = isIgnored +exports.childrenIgnored = childrenIgnored + +function ownProp (obj, field) { + return Object.prototype.hasOwnProperty.call(obj, field) +} + +var path = require("path") +var minimatch = require("minimatch") +var isAbsolute = require("path-is-absolute") +var Minimatch = minimatch.Minimatch + +function alphasorti (a, b) { + return a.toLowerCase().localeCompare(b.toLowerCase()) +} + +function alphasort (a, b) { + return a.localeCompare(b) +} + +function setupIgnores (self, options) { + self.ignore = options.ignore || [] + + if (!Array.isArray(self.ignore)) + self.ignore = [self.ignore] + + if (self.ignore.length) { + self.ignore = self.ignore.map(ignoreMap) + } +} + +// ignore patterns are always in dot:true mode. +function ignoreMap (pattern) { + var gmatcher = null + if (pattern.slice(-3) === '/**') { + var gpattern = pattern.replace(/(\/\*\*)+$/, '') + gmatcher = new Minimatch(gpattern, { dot: true }) + } + + return { + matcher: new Minimatch(pattern, { dot: true }), + gmatcher: gmatcher + } +} + +function setopts (self, pattern, options) { + if (!options) + options = {} + + // base-matching: just use globstar for that. + if (options.matchBase && -1 === pattern.indexOf("/")) { + if (options.noglobstar) { + throw new Error("base matching requires globstar") + } + pattern = "**/" + pattern + } + + self.silent = !!options.silent + self.pattern = pattern + self.strict = options.strict !== false + self.realpath = !!options.realpath + self.realpathCache = options.realpathCache || Object.create(null) + self.follow = !!options.follow + self.dot = !!options.dot + self.mark = !!options.mark + self.nodir = !!options.nodir + if (self.nodir) + self.mark = true + self.sync = !!options.sync + self.nounique = !!options.nounique + self.nonull = !!options.nonull + self.nosort = !!options.nosort + self.nocase = !!options.nocase + self.stat = !!options.stat + self.noprocess = !!options.noprocess + + self.maxLength = options.maxLength || Infinity + self.cache = options.cache || Object.create(null) + self.statCache = options.statCache || Object.create(null) + self.symlinks = options.symlinks || Object.create(null) + + setupIgnores(self, options) + + self.changedCwd = false + var cwd = process.cwd() + if (!ownProp(options, "cwd")) + self.cwd = cwd + else { + self.cwd = options.cwd + self.changedCwd = path.resolve(options.cwd) !== cwd + } + + self.root = options.root || path.resolve(self.cwd, "/") + self.root = path.resolve(self.root) + if (process.platform === "win32") + self.root = self.root.replace(/\\/g, "/") + + self.nomount = !!options.nomount + + // disable comments and negation in Minimatch. + // Note that they are not supported in Glob itself anyway. + options.nonegate = true + options.nocomment = true + + self.minimatch = new Minimatch(pattern, options) + self.options = self.minimatch.options +} + +function finish (self) { + var nou = self.nounique + var all = nou ? [] : Object.create(null) + + for (var i = 0, l = self.matches.length; i < l; i ++) { + var matches = self.matches[i] + if (!matches || Object.keys(matches).length === 0) { + if (self.nonull) { + // do like the shell, and spit out the literal glob + var literal = self.minimatch.globSet[i] + if (nou) + all.push(literal) + else + all[literal] = true + } + } else { + // had matches + var m = Object.keys(matches) + if (nou) + all.push.apply(all, m) + else + m.forEach(function (m) { + all[m] = true + }) + } + } + + if (!nou) + all = Object.keys(all) + + if (!self.nosort) + all = all.sort(self.nocase ? alphasorti : alphasort) + + // at *some* point we statted all of these + if (self.mark) { + for (var i = 0; i < all.length; i++) { + all[i] = self._mark(all[i]) + } + if (self.nodir) { + all = all.filter(function (e) { + return !(/\/$/.test(e)) + }) + } + } + + if (self.ignore.length) + all = all.filter(function(m) { + return !isIgnored(self, m) + }) + + self.found = all +} + +function mark (self, p) { + var abs = makeAbs(self, p) + var c = self.cache[abs] + var m = p + if (c) { + var isDir = c === 'DIR' || Array.isArray(c) + var slash = p.slice(-1) === '/' + + if (isDir && !slash) + m += '/' + else if (!isDir && slash) + m = m.slice(0, -1) + + if (m !== p) { + var mabs = makeAbs(self, m) + self.statCache[mabs] = self.statCache[abs] + self.cache[mabs] = self.cache[abs] + } + } + + return m +} + +// lotta situps... +function makeAbs (self, f) { + var abs = f + if (f.charAt(0) === '/') { + abs = path.join(self.root, f) + } else if (isAbsolute(f) || f === '') { + abs = f + } else if (self.changedCwd) { + abs = path.resolve(self.cwd, f) + } else { + abs = path.resolve(f) + } + return abs +} + + +// Return true, if pattern ends with globstar '**', for the accompanying parent directory. +// Ex:- If node_modules/** is the pattern, add 'node_modules' to ignore list along with it's contents +function isIgnored (self, path) { + if (!self.ignore.length) + return false + + return self.ignore.some(function(item) { + return item.matcher.match(path) || !!(item.gmatcher && item.gmatcher.match(path)) + }) +} + +function childrenIgnored (self, path) { + if (!self.ignore.length) + return false + + return self.ignore.some(function(item) { + return !!(item.gmatcher && item.gmatcher.match(path)) + }) +} diff --git a/tools/node_modules/glob/glob.js b/tools/node_modules/glob/glob.js new file mode 100644 index 00000000000000..a62da27ebd507a --- /dev/null +++ b/tools/node_modules/glob/glob.js @@ -0,0 +1,765 @@ +// Approach: +// +// 1. Get the minimatch set +// 2. For each pattern in the set, PROCESS(pattern, false) +// 3. Store matches per-set, then uniq them +// +// PROCESS(pattern, inGlobStar) +// Get the first [n] items from pattern that are all strings +// Join these together. This is PREFIX. +// If there is no more remaining, then stat(PREFIX) and +// add to matches if it succeeds. END. +// +// If inGlobStar and PREFIX is symlink and points to dir +// set ENTRIES = [] +// else readdir(PREFIX) as ENTRIES +// If fail, END +// +// with ENTRIES +// If pattern[n] is GLOBSTAR +// // handle the case where the globstar match is empty +// // by pruning it out, and testing the resulting pattern +// PROCESS(pattern[0..n] + pattern[n+1 .. $], false) +// // handle other cases. +// for ENTRY in ENTRIES (not dotfiles) +// // attach globstar + tail onto the entry +// // Mark that this entry is a globstar match +// PROCESS(pattern[0..n] + ENTRY + pattern[n .. $], true) +// +// else // not globstar +// for ENTRY in ENTRIES (not dotfiles, unless pattern[n] is dot) +// Test ENTRY against pattern[n] +// If fails, continue +// If passes, PROCESS(pattern[0..n] + item + pattern[n+1 .. $]) +// +// Caveat: +// Cache all stats and readdirs results to minimize syscall. Since all +// we ever care about is existence and directory-ness, we can just keep +// `true` for files, and [children,...] for directories, or `false` for +// things that don't exist. + +module.exports = glob + +var fs = require('fs') +var minimatch = require('minimatch') +var Minimatch = minimatch.Minimatch +var inherits = require('inherits') +var EE = require('events').EventEmitter +var path = require('path') +var assert = require('assert') +var isAbsolute = require('path-is-absolute') +var globSync = require('./sync.js') +var common = require('./common.js') +var alphasort = common.alphasort +var alphasorti = common.alphasorti +var setopts = common.setopts +var ownProp = common.ownProp +var inflight = require('inflight') +var util = require('util') +var childrenIgnored = common.childrenIgnored +var isIgnored = common.isIgnored + +var once = require('once') + +function glob (pattern, options, cb) { + if (typeof options === 'function') cb = options, options = {} + if (!options) options = {} + + if (options.sync) { + if (cb) + throw new TypeError('callback provided to sync glob') + return globSync(pattern, options) + } + + return new Glob(pattern, options, cb) +} + +glob.sync = globSync +var GlobSync = glob.GlobSync = globSync.GlobSync + +// old api surface +glob.glob = glob + +function extend (origin, add) { + if (add === null || typeof add !== 'object') { + return origin + } + + var keys = Object.keys(add) + var i = keys.length + while (i--) { + origin[keys[i]] = add[keys[i]] + } + return origin +} + +glob.hasMagic = function (pattern, options_) { + var options = extend({}, options_) + options.noprocess = true + + var g = new Glob(pattern, options) + var set = g.minimatch.set + if (set.length > 1) + return true + + for (var j = 0; j < set[0].length; j++) { + if (typeof set[0][j] !== 'string') + return true + } + + return false +} + +glob.Glob = Glob +inherits(Glob, EE) +function Glob (pattern, options, cb) { + if (typeof options === 'function') { + cb = options + options = null + } + + if (options && options.sync) { + if (cb) + throw new TypeError('callback provided to sync glob') + return new GlobSync(pattern, options) + } + + if (!(this instanceof Glob)) + return new Glob(pattern, options, cb) + + setopts(this, pattern, options) + this._didRealPath = false + + // process each pattern in the minimatch set + var n = this.minimatch.set.length + + // The matches are stored as {: true,...} so that + // duplicates are automagically pruned. + // Later, we do an Object.keys() on these. + // Keep them as a list so we can fill in when nonull is set. + this.matches = new Array(n) + + if (typeof cb === 'function') { + cb = once(cb) + this.on('error', cb) + this.on('end', function (matches) { + cb(null, matches) + }) + } + + var self = this + var n = this.minimatch.set.length + this._processing = 0 + this.matches = new Array(n) + + this._emitQueue = [] + this._processQueue = [] + this.paused = false + + if (this.noprocess) + return this + + if (n === 0) + return done() + + for (var i = 0; i < n; i ++) { + this._process(this.minimatch.set[i], i, false, done) + } + + function done () { + --self._processing + if (self._processing <= 0) + self._finish() + } +} + +Glob.prototype._finish = function () { + assert(this instanceof Glob) + if (this.aborted) + return + + if (this.realpath && !this._didRealpath) + return this._realpath() + + common.finish(this) + this.emit('end', this.found) +} + +Glob.prototype._realpath = function () { + if (this._didRealpath) + return + + this._didRealpath = true + + var n = this.matches.length + if (n === 0) + return this._finish() + + var self = this + for (var i = 0; i < this.matches.length; i++) + this._realpathSet(i, next) + + function next () { + if (--n === 0) + self._finish() + } +} + +Glob.prototype._realpathSet = function (index, cb) { + var matchset = this.matches[index] + if (!matchset) + return cb() + + var found = Object.keys(matchset) + var self = this + var n = found.length + + if (n === 0) + return cb() + + var set = this.matches[index] = Object.create(null) + found.forEach(function (p, i) { + // If there's a problem with the stat, then it means that + // one or more of the links in the realpath couldn't be + // resolved. just return the abs value in that case. + p = self._makeAbs(p) + fs.realpath(p, self.realpathCache, function (er, real) { + if (!er) + set[real] = true + else if (er.syscall === 'stat') + set[p] = true + else + self.emit('error', er) // srsly wtf right here + + if (--n === 0) { + self.matches[index] = set + cb() + } + }) + }) +} + +Glob.prototype._mark = function (p) { + return common.mark(this, p) +} + +Glob.prototype._makeAbs = function (f) { + return common.makeAbs(this, f) +} + +Glob.prototype.abort = function () { + this.aborted = true + this.emit('abort') +} + +Glob.prototype.pause = function () { + if (!this.paused) { + this.paused = true + this.emit('pause') + } +} + +Glob.prototype.resume = function () { + if (this.paused) { + this.emit('resume') + this.paused = false + if (this._emitQueue.length) { + var eq = this._emitQueue.slice(0) + this._emitQueue.length = 0 + for (var i = 0; i < eq.length; i ++) { + var e = eq[i] + this._emitMatch(e[0], e[1]) + } + } + if (this._processQueue.length) { + var pq = this._processQueue.slice(0) + this._processQueue.length = 0 + for (var i = 0; i < pq.length; i ++) { + var p = pq[i] + this._processing-- + this._process(p[0], p[1], p[2], p[3]) + } + } + } +} + +Glob.prototype._process = function (pattern, index, inGlobStar, cb) { + assert(this instanceof Glob) + assert(typeof cb === 'function') + + if (this.aborted) + return + + this._processing++ + if (this.paused) { + this._processQueue.push([pattern, index, inGlobStar, cb]) + return + } + + //console.error('PROCESS %d', this._processing, pattern) + + // Get the first [n] parts of pattern that are all strings. + var n = 0 + while (typeof pattern[n] === 'string') { + n ++ + } + // now n is the index of the first one that is *not* a string. + + // see if there's anything else + var prefix + switch (n) { + // if not, then this is rather simple + case pattern.length: + this._processSimple(pattern.join('/'), index, cb) + return + + case 0: + // pattern *starts* with some non-trivial item. + // going to readdir(cwd), but not include the prefix in matches. + prefix = null + break + + default: + // pattern has some string bits in the front. + // whatever it starts with, whether that's 'absolute' like /foo/bar, + // or 'relative' like '../baz' + prefix = pattern.slice(0, n).join('/') + break + } + + var remain = pattern.slice(n) + + // get the list of entries. + var read + if (prefix === null) + read = '.' + else if (isAbsolute(prefix) || isAbsolute(pattern.join('/'))) { + if (!prefix || !isAbsolute(prefix)) + prefix = '/' + prefix + read = prefix + } else + read = prefix + + var abs = this._makeAbs(read) + + //if ignored, skip _processing + if (childrenIgnored(this, read)) + return cb() + + var isGlobStar = remain[0] === minimatch.GLOBSTAR + if (isGlobStar) + this._processGlobStar(prefix, read, abs, remain, index, inGlobStar, cb) + else + this._processReaddir(prefix, read, abs, remain, index, inGlobStar, cb) +} + +Glob.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar, cb) { + var self = this + this._readdir(abs, inGlobStar, function (er, entries) { + return self._processReaddir2(prefix, read, abs, remain, index, inGlobStar, entries, cb) + }) +} + +Glob.prototype._processReaddir2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) { + + // if the abs isn't a dir, then nothing can match! + if (!entries) + return cb() + + // It will only match dot entries if it starts with a dot, or if + // dot is set. Stuff like @(.foo|.bar) isn't allowed. + var pn = remain[0] + var negate = !!this.minimatch.negate + var rawGlob = pn._glob + var dotOk = this.dot || rawGlob.charAt(0) === '.' + + var matchedEntries = [] + for (var i = 0; i < entries.length; i++) { + var e = entries[i] + if (e.charAt(0) !== '.' || dotOk) { + var m + if (negate && !prefix) { + m = !e.match(pn) + } else { + m = e.match(pn) + } + if (m) + matchedEntries.push(e) + } + } + + //console.error('prd2', prefix, entries, remain[0]._glob, matchedEntries) + + var len = matchedEntries.length + // If there are no matched entries, then nothing matches. + if (len === 0) + return cb() + + // if this is the last remaining pattern bit, then no need for + // an additional stat *unless* the user has specified mark or + // stat explicitly. We know they exist, since readdir returned + // them. + + if (remain.length === 1 && !this.mark && !this.stat) { + if (!this.matches[index]) + this.matches[index] = Object.create(null) + + for (var i = 0; i < len; i ++) { + var e = matchedEntries[i] + if (prefix) { + if (prefix !== '/') + e = prefix + '/' + e + else + e = prefix + e + } + + if (e.charAt(0) === '/' && !this.nomount) { + e = path.join(this.root, e) + } + this._emitMatch(index, e) + } + // This was the last one, and no stats were needed + return cb() + } + + // now test all matched entries as stand-ins for that part + // of the pattern. + remain.shift() + for (var i = 0; i < len; i ++) { + var e = matchedEntries[i] + var newPattern + if (prefix) { + if (prefix !== '/') + e = prefix + '/' + e + else + e = prefix + e + } + this._process([e].concat(remain), index, inGlobStar, cb) + } + cb() +} + +Glob.prototype._emitMatch = function (index, e) { + if (this.aborted) + return + + if (this.matches[index][e]) + return + + if (isIgnored(this, e)) + return + + if (this.paused) { + this._emitQueue.push([index, e]) + return + } + + var abs = this._makeAbs(e) + + if (this.nodir) { + var c = this.cache[abs] + if (c === 'DIR' || Array.isArray(c)) + return + } + + if (this.mark) + e = this._mark(e) + + this.matches[index][e] = true + + var st = this.statCache[abs] + if (st) + this.emit('stat', e, st) + + this.emit('match', e) +} + +Glob.prototype._readdirInGlobStar = function (abs, cb) { + if (this.aborted) + return + + // follow all symlinked directories forever + // just proceed as if this is a non-globstar situation + if (this.follow) + return this._readdir(abs, false, cb) + + var lstatkey = 'lstat\0' + abs + var self = this + var lstatcb = inflight(lstatkey, lstatcb_) + + if (lstatcb) + fs.lstat(abs, lstatcb) + + function lstatcb_ (er, lstat) { + if (er) + return cb() + + var isSym = lstat.isSymbolicLink() + self.symlinks[abs] = isSym + + // If it's not a symlink or a dir, then it's definitely a regular file. + // don't bother doing a readdir in that case. + if (!isSym && !lstat.isDirectory()) { + self.cache[abs] = 'FILE' + cb() + } else + self._readdir(abs, false, cb) + } +} + +Glob.prototype._readdir = function (abs, inGlobStar, cb) { + if (this.aborted) + return + + cb = inflight('readdir\0'+abs+'\0'+inGlobStar, cb) + if (!cb) + return + + //console.error('RD %j %j', +inGlobStar, abs) + if (inGlobStar && !ownProp(this.symlinks, abs)) + return this._readdirInGlobStar(abs, cb) + + if (ownProp(this.cache, abs)) { + var c = this.cache[abs] + if (!c || c === 'FILE') + return cb() + + if (Array.isArray(c)) + return cb(null, c) + } + + var self = this + fs.readdir(abs, readdirCb(this, abs, cb)) +} + +function readdirCb (self, abs, cb) { + return function (er, entries) { + if (er) + self._readdirError(abs, er, cb) + else + self._readdirEntries(abs, entries, cb) + } +} + +Glob.prototype._readdirEntries = function (abs, entries, cb) { + if (this.aborted) + return + + // if we haven't asked to stat everything, then just + // assume that everything in there exists, so we can avoid + // having to stat it a second time. + if (!this.mark && !this.stat) { + for (var i = 0; i < entries.length; i ++) { + var e = entries[i] + if (abs === '/') + e = abs + e + else + e = abs + '/' + e + this.cache[e] = true + } + } + + this.cache[abs] = entries + return cb(null, entries) +} + +Glob.prototype._readdirError = function (f, er, cb) { + if (this.aborted) + return + + // handle errors, and cache the information + switch (er.code) { + case 'ENOTSUP': // https://github.com/isaacs/node-glob/issues/205 + case 'ENOTDIR': // totally normal. means it *does* exist. + this.cache[this._makeAbs(f)] = 'FILE' + break + + case 'ENOENT': // not terribly unusual + case 'ELOOP': + case 'ENAMETOOLONG': + case 'UNKNOWN': + this.cache[this._makeAbs(f)] = false + break + + default: // some unusual error. Treat as failure. + this.cache[this._makeAbs(f)] = false + if (this.strict) { + this.emit('error', er) + // If the error is handled, then we abort + // if not, we threw out of here + this.abort() + } + if (!this.silent) + console.error('glob error', er) + break + } + + return cb() +} + +Glob.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar, cb) { + var self = this + this._readdir(abs, inGlobStar, function (er, entries) { + self._processGlobStar2(prefix, read, abs, remain, index, inGlobStar, entries, cb) + }) +} + + +Glob.prototype._processGlobStar2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) { + //console.error('pgs2', prefix, remain[0], entries) + + // no entries means not a dir, so it can never have matches + // foo.txt/** doesn't match foo.txt + if (!entries) + return cb() + + // test without the globstar, and with every child both below + // and replacing the globstar. + var remainWithoutGlobStar = remain.slice(1) + var gspref = prefix ? [ prefix ] : [] + var noGlobStar = gspref.concat(remainWithoutGlobStar) + + // the noGlobStar pattern exits the inGlobStar state + this._process(noGlobStar, index, false, cb) + + var isSym = this.symlinks[abs] + var len = entries.length + + // If it's a symlink, and we're in a globstar, then stop + if (isSym && inGlobStar) + return cb() + + for (var i = 0; i < len; i++) { + var e = entries[i] + if (e.charAt(0) === '.' && !this.dot) + continue + + // these two cases enter the inGlobStar state + var instead = gspref.concat(entries[i], remainWithoutGlobStar) + this._process(instead, index, true, cb) + + var below = gspref.concat(entries[i], remain) + this._process(below, index, true, cb) + } + + cb() +} + +Glob.prototype._processSimple = function (prefix, index, cb) { + // XXX review this. Shouldn't it be doing the mounting etc + // before doing stat? kinda weird? + var self = this + this._stat(prefix, function (er, exists) { + self._processSimple2(prefix, index, er, exists, cb) + }) +} +Glob.prototype._processSimple2 = function (prefix, index, er, exists, cb) { + + //console.error('ps2', prefix, exists) + + if (!this.matches[index]) + this.matches[index] = Object.create(null) + + // If it doesn't exist, then just mark the lack of results + if (!exists) + return cb() + + if (prefix && isAbsolute(prefix) && !this.nomount) { + var trail = /[\/\\]$/.test(prefix) + if (prefix.charAt(0) === '/') { + prefix = path.join(this.root, prefix) + } else { + prefix = path.resolve(this.root, prefix) + if (trail) + prefix += '/' + } + } + + if (process.platform === 'win32') + prefix = prefix.replace(/\\/g, '/') + + // Mark this as a match + this._emitMatch(index, prefix) + cb() +} + +// Returns either 'DIR', 'FILE', or false +Glob.prototype._stat = function (f, cb) { + var abs = this._makeAbs(f) + var needDir = f.slice(-1) === '/' + + if (f.length > this.maxLength) + return cb() + + if (!this.stat && ownProp(this.cache, abs)) { + var c = this.cache[abs] + + if (Array.isArray(c)) + c = 'DIR' + + // It exists, but maybe not how we need it + if (!needDir || c === 'DIR') + return cb(null, c) + + if (needDir && c === 'FILE') + return cb() + + // otherwise we have to stat, because maybe c=true + // if we know it exists, but not what it is. + } + + var exists + var stat = this.statCache[abs] + if (stat !== undefined) { + if (stat === false) + return cb(null, stat) + else { + var type = stat.isDirectory() ? 'DIR' : 'FILE' + if (needDir && type === 'FILE') + return cb() + else + return cb(null, type, stat) + } + } + + var self = this + var statcb = inflight('stat\0' + abs, lstatcb_) + if (statcb) + fs.lstat(abs, statcb) + + function lstatcb_ (er, lstat) { + if (lstat && lstat.isSymbolicLink()) { + // If it's a symlink, then treat it as the target, unless + // the target does not exist, then treat it as a file. + return fs.stat(abs, function (er, stat) { + if (er) + self._stat2(f, abs, null, lstat, cb) + else + self._stat2(f, abs, er, stat, cb) + }) + } else { + self._stat2(f, abs, er, lstat, cb) + } + } +} + +Glob.prototype._stat2 = function (f, abs, er, stat, cb) { + if (er) { + this.statCache[abs] = false + return cb() + } + + var needDir = f.slice(-1) === '/' + this.statCache[abs] = stat + + if (abs.slice(-1) === '/' && !stat.isDirectory()) + return cb(null, false, stat) + + var c = stat.isDirectory() ? 'DIR' : 'FILE' + this.cache[abs] = this.cache[abs] || c + + if (needDir && c !== 'DIR') + return cb() + + return cb(null, c, stat) +} diff --git a/tools/node_modules/glob/package.json b/tools/node_modules/glob/package.json new file mode 100644 index 00000000000000..0657c4dfd77f51 --- /dev/null +++ b/tools/node_modules/glob/package.json @@ -0,0 +1,98 @@ +{ + "_args": [ + [ + "glob@^6.0.1", + "C:\\wamp\\www\\node\\tools\\node_modules\\remark" + ] + ], + "_from": "glob@>=6.0.1 <7.0.0", + "_id": "glob@6.0.4", + "_inCache": true, + "_location": "/glob", + "_nodeVersion": "4.0.0", + "_npmUser": { + "email": "i@izs.me", + "name": "isaacs" + }, + "_npmVersion": "2.14.15", + "_phantomChildren": {}, + "_requested": { + "name": "glob", + "raw": "glob@^6.0.1", + "rawSpec": "^6.0.1", + "scope": null, + "spec": ">=6.0.1 <7.0.0", + "type": "range" + }, + "_requiredBy": [ + "/globby", + "/remark" + ], + "_resolved": "https://registry.npmjs.org/glob/-/glob-6.0.4.tgz", + "_shasum": "0f08860f6a155127b2fadd4f9ce24b1aab6e4d22", + "_shrinkwrap": null, + "_spec": "glob@^6.0.1", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\remark", + "author": { + "email": "i@izs.me", + "name": "Isaac Z. Schlueter", + "url": "http://blog.izs.me/" + }, + "bugs": { + "url": "https://github.com/isaacs/node-glob/issues" + }, + "dependencies": { + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "2 || 3", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "description": "a little globber", + "devDependencies": { + "mkdirp": "0", + "rimraf": "^2.2.8", + "tap": "^5.0.0", + "tick": "0.0.6" + }, + "directories": {}, + "dist": { + "shasum": "0f08860f6a155127b2fadd4f9ce24b1aab6e4d22", + "tarball": "http://registry.npmjs.org/glob/-/glob-6.0.4.tgz" + }, + "engines": { + "node": "*" + }, + "files": [ + "common.js", + "glob.js", + "sync.js" + ], + "gitHead": "3bd419c538737e56fda7e21c21ff52ca0c198df6", + "homepage": "https://github.com/isaacs/node-glob#readme", + "installable": true, + "license": "ISC", + "main": "glob.js", + "maintainers": [ + { + "name": "isaacs", + "email": "i@izs.me" + } + ], + "name": "glob", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git://github.com/isaacs/node-glob.git" + }, + "scripts": { + "bench": "bash benchmark.sh", + "benchclean": "node benchclean.js", + "prepublish": "npm run benchclean", + "prof": "bash prof.sh && cat profile.txt", + "profclean": "rm -f v8.log profile.txt", + "test": "tap test/*.js --cov", + "test-regen": "npm run profclean && TEST_REGEN=1 node test/00-setup.js" + }, + "version": "6.0.4" +} diff --git a/tools/node_modules/glob/sync.js b/tools/node_modules/glob/sync.js new file mode 100644 index 00000000000000..09883d2ce0c9de --- /dev/null +++ b/tools/node_modules/glob/sync.js @@ -0,0 +1,460 @@ +module.exports = globSync +globSync.GlobSync = GlobSync + +var fs = require('fs') +var minimatch = require('minimatch') +var Minimatch = minimatch.Minimatch +var Glob = require('./glob.js').Glob +var util = require('util') +var path = require('path') +var assert = require('assert') +var isAbsolute = require('path-is-absolute') +var common = require('./common.js') +var alphasort = common.alphasort +var alphasorti = common.alphasorti +var setopts = common.setopts +var ownProp = common.ownProp +var childrenIgnored = common.childrenIgnored + +function globSync (pattern, options) { + if (typeof options === 'function' || arguments.length === 3) + throw new TypeError('callback provided to sync glob\n'+ + 'See: https://github.com/isaacs/node-glob/issues/167') + + return new GlobSync(pattern, options).found +} + +function GlobSync (pattern, options) { + if (!pattern) + throw new Error('must provide pattern') + + if (typeof options === 'function' || arguments.length === 3) + throw new TypeError('callback provided to sync glob\n'+ + 'See: https://github.com/isaacs/node-glob/issues/167') + + if (!(this instanceof GlobSync)) + return new GlobSync(pattern, options) + + setopts(this, pattern, options) + + if (this.noprocess) + return this + + var n = this.minimatch.set.length + this.matches = new Array(n) + for (var i = 0; i < n; i ++) { + this._process(this.minimatch.set[i], i, false) + } + this._finish() +} + +GlobSync.prototype._finish = function () { + assert(this instanceof GlobSync) + if (this.realpath) { + var self = this + this.matches.forEach(function (matchset, index) { + var set = self.matches[index] = Object.create(null) + for (var p in matchset) { + try { + p = self._makeAbs(p) + var real = fs.realpathSync(p, self.realpathCache) + set[real] = true + } catch (er) { + if (er.syscall === 'stat') + set[self._makeAbs(p)] = true + else + throw er + } + } + }) + } + common.finish(this) +} + + +GlobSync.prototype._process = function (pattern, index, inGlobStar) { + assert(this instanceof GlobSync) + + // Get the first [n] parts of pattern that are all strings. + var n = 0 + while (typeof pattern[n] === 'string') { + n ++ + } + // now n is the index of the first one that is *not* a string. + + // See if there's anything else + var prefix + switch (n) { + // if not, then this is rather simple + case pattern.length: + this._processSimple(pattern.join('/'), index) + return + + case 0: + // pattern *starts* with some non-trivial item. + // going to readdir(cwd), but not include the prefix in matches. + prefix = null + break + + default: + // pattern has some string bits in the front. + // whatever it starts with, whether that's 'absolute' like /foo/bar, + // or 'relative' like '../baz' + prefix = pattern.slice(0, n).join('/') + break + } + + var remain = pattern.slice(n) + + // get the list of entries. + var read + if (prefix === null) + read = '.' + else if (isAbsolute(prefix) || isAbsolute(pattern.join('/'))) { + if (!prefix || !isAbsolute(prefix)) + prefix = '/' + prefix + read = prefix + } else + read = prefix + + var abs = this._makeAbs(read) + + //if ignored, skip processing + if (childrenIgnored(this, read)) + return + + var isGlobStar = remain[0] === minimatch.GLOBSTAR + if (isGlobStar) + this._processGlobStar(prefix, read, abs, remain, index, inGlobStar) + else + this._processReaddir(prefix, read, abs, remain, index, inGlobStar) +} + + +GlobSync.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar) { + var entries = this._readdir(abs, inGlobStar) + + // if the abs isn't a dir, then nothing can match! + if (!entries) + return + + // It will only match dot entries if it starts with a dot, or if + // dot is set. Stuff like @(.foo|.bar) isn't allowed. + var pn = remain[0] + var negate = !!this.minimatch.negate + var rawGlob = pn._glob + var dotOk = this.dot || rawGlob.charAt(0) === '.' + + var matchedEntries = [] + for (var i = 0; i < entries.length; i++) { + var e = entries[i] + if (e.charAt(0) !== '.' || dotOk) { + var m + if (negate && !prefix) { + m = !e.match(pn) + } else { + m = e.match(pn) + } + if (m) + matchedEntries.push(e) + } + } + + var len = matchedEntries.length + // If there are no matched entries, then nothing matches. + if (len === 0) + return + + // if this is the last remaining pattern bit, then no need for + // an additional stat *unless* the user has specified mark or + // stat explicitly. We know they exist, since readdir returned + // them. + + if (remain.length === 1 && !this.mark && !this.stat) { + if (!this.matches[index]) + this.matches[index] = Object.create(null) + + for (var i = 0; i < len; i ++) { + var e = matchedEntries[i] + if (prefix) { + if (prefix.slice(-1) !== '/') + e = prefix + '/' + e + else + e = prefix + e + } + + if (e.charAt(0) === '/' && !this.nomount) { + e = path.join(this.root, e) + } + this.matches[index][e] = true + } + // This was the last one, and no stats were needed + return + } + + // now test all matched entries as stand-ins for that part + // of the pattern. + remain.shift() + for (var i = 0; i < len; i ++) { + var e = matchedEntries[i] + var newPattern + if (prefix) + newPattern = [prefix, e] + else + newPattern = [e] + this._process(newPattern.concat(remain), index, inGlobStar) + } +} + + +GlobSync.prototype._emitMatch = function (index, e) { + var abs = this._makeAbs(e) + if (this.mark) + e = this._mark(e) + + if (this.matches[index][e]) + return + + if (this.nodir) { + var c = this.cache[this._makeAbs(e)] + if (c === 'DIR' || Array.isArray(c)) + return + } + + this.matches[index][e] = true + if (this.stat) + this._stat(e) +} + + +GlobSync.prototype._readdirInGlobStar = function (abs) { + // follow all symlinked directories forever + // just proceed as if this is a non-globstar situation + if (this.follow) + return this._readdir(abs, false) + + var entries + var lstat + var stat + try { + lstat = fs.lstatSync(abs) + } catch (er) { + // lstat failed, doesn't exist + return null + } + + var isSym = lstat.isSymbolicLink() + this.symlinks[abs] = isSym + + // If it's not a symlink or a dir, then it's definitely a regular file. + // don't bother doing a readdir in that case. + if (!isSym && !lstat.isDirectory()) + this.cache[abs] = 'FILE' + else + entries = this._readdir(abs, false) + + return entries +} + +GlobSync.prototype._readdir = function (abs, inGlobStar) { + var entries + + if (inGlobStar && !ownProp(this.symlinks, abs)) + return this._readdirInGlobStar(abs) + + if (ownProp(this.cache, abs)) { + var c = this.cache[abs] + if (!c || c === 'FILE') + return null + + if (Array.isArray(c)) + return c + } + + try { + return this._readdirEntries(abs, fs.readdirSync(abs)) + } catch (er) { + this._readdirError(abs, er) + return null + } +} + +GlobSync.prototype._readdirEntries = function (abs, entries) { + // if we haven't asked to stat everything, then just + // assume that everything in there exists, so we can avoid + // having to stat it a second time. + if (!this.mark && !this.stat) { + for (var i = 0; i < entries.length; i ++) { + var e = entries[i] + if (abs === '/') + e = abs + e + else + e = abs + '/' + e + this.cache[e] = true + } + } + + this.cache[abs] = entries + + // mark and cache dir-ness + return entries +} + +GlobSync.prototype._readdirError = function (f, er) { + // handle errors, and cache the information + switch (er.code) { + case 'ENOTSUP': // https://github.com/isaacs/node-glob/issues/205 + case 'ENOTDIR': // totally normal. means it *does* exist. + this.cache[this._makeAbs(f)] = 'FILE' + break + + case 'ENOENT': // not terribly unusual + case 'ELOOP': + case 'ENAMETOOLONG': + case 'UNKNOWN': + this.cache[this._makeAbs(f)] = false + break + + default: // some unusual error. Treat as failure. + this.cache[this._makeAbs(f)] = false + if (this.strict) + throw er + if (!this.silent) + console.error('glob error', er) + break + } +} + +GlobSync.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar) { + + var entries = this._readdir(abs, inGlobStar) + + // no entries means not a dir, so it can never have matches + // foo.txt/** doesn't match foo.txt + if (!entries) + return + + // test without the globstar, and with every child both below + // and replacing the globstar. + var remainWithoutGlobStar = remain.slice(1) + var gspref = prefix ? [ prefix ] : [] + var noGlobStar = gspref.concat(remainWithoutGlobStar) + + // the noGlobStar pattern exits the inGlobStar state + this._process(noGlobStar, index, false) + + var len = entries.length + var isSym = this.symlinks[abs] + + // If it's a symlink, and we're in a globstar, then stop + if (isSym && inGlobStar) + return + + for (var i = 0; i < len; i++) { + var e = entries[i] + if (e.charAt(0) === '.' && !this.dot) + continue + + // these two cases enter the inGlobStar state + var instead = gspref.concat(entries[i], remainWithoutGlobStar) + this._process(instead, index, true) + + var below = gspref.concat(entries[i], remain) + this._process(below, index, true) + } +} + +GlobSync.prototype._processSimple = function (prefix, index) { + // XXX review this. Shouldn't it be doing the mounting etc + // before doing stat? kinda weird? + var exists = this._stat(prefix) + + if (!this.matches[index]) + this.matches[index] = Object.create(null) + + // If it doesn't exist, then just mark the lack of results + if (!exists) + return + + if (prefix && isAbsolute(prefix) && !this.nomount) { + var trail = /[\/\\]$/.test(prefix) + if (prefix.charAt(0) === '/') { + prefix = path.join(this.root, prefix) + } else { + prefix = path.resolve(this.root, prefix) + if (trail) + prefix += '/' + } + } + + if (process.platform === 'win32') + prefix = prefix.replace(/\\/g, '/') + + // Mark this as a match + this.matches[index][prefix] = true +} + +// Returns either 'DIR', 'FILE', or false +GlobSync.prototype._stat = function (f) { + var abs = this._makeAbs(f) + var needDir = f.slice(-1) === '/' + + if (f.length > this.maxLength) + return false + + if (!this.stat && ownProp(this.cache, abs)) { + var c = this.cache[abs] + + if (Array.isArray(c)) + c = 'DIR' + + // It exists, but maybe not how we need it + if (!needDir || c === 'DIR') + return c + + if (needDir && c === 'FILE') + return false + + // otherwise we have to stat, because maybe c=true + // if we know it exists, but not what it is. + } + + var exists + var stat = this.statCache[abs] + if (!stat) { + var lstat + try { + lstat = fs.lstatSync(abs) + } catch (er) { + return false + } + + if (lstat.isSymbolicLink()) { + try { + stat = fs.statSync(abs) + } catch (er) { + stat = lstat + } + } else { + stat = lstat + } + } + + this.statCache[abs] = stat + + var c = stat.isDirectory() ? 'DIR' : 'FILE' + this.cache[abs] = this.cache[abs] || c + + if (needDir && c !== 'DIR') + return false + + return c +} + +GlobSync.prototype._mark = function (p) { + return common.mark(this, p) +} + +GlobSync.prototype._makeAbs = function (f) { + return common.makeAbs(this, f) +} diff --git a/tools/node_modules/globby/index.js b/tools/node_modules/globby/index.js new file mode 100644 index 00000000000000..8f20018ff44a75 --- /dev/null +++ b/tools/node_modules/globby/index.js @@ -0,0 +1,68 @@ +'use strict'; +var Promise = require('pinkie-promise'); +var arrayUnion = require('array-union'); +var objectAssign = require('object-assign'); +var glob = require('glob'); +var arrify = require('arrify'); +var pify = require('pify'); + +function sortPatterns(patterns) { + patterns = arrify(patterns); + + var positives = []; + var negatives = []; + + patterns.forEach(function (pattern, index) { + var isNegative = pattern[0] === '!'; + (isNegative ? negatives : positives).push({ + index: index, + pattern: isNegative ? pattern.slice(1) : pattern + }); + }); + + return { + positives: positives, + negatives: negatives + }; +} + +function setIgnore(opts, negatives, positiveIndex) { + opts = objectAssign({}, opts); + + var negativePatterns = negatives.filter(function (negative) { + return negative.index > positiveIndex; + }).map(function (negative) { + return negative.pattern; + }); + + opts.ignore = (opts.ignore || []).concat(negativePatterns); + return opts; +} + +module.exports = function (patterns, opts) { + var sortedPatterns = sortPatterns(patterns); + opts = opts || {}; + + if (sortedPatterns.positives.length === 0) { + return Promise.resolve([]); + } + + return Promise.all(sortedPatterns.positives.map(function (positive) { + var globOpts = setIgnore(opts, sortedPatterns.negatives, positive.index); + return pify(glob, Promise)(positive.pattern, globOpts); + })).then(function (paths) { + return arrayUnion.apply(null, paths); + }); +}; + +module.exports.sync = function (patterns, opts) { + var sortedPatterns = sortPatterns(patterns); + + if (sortedPatterns.positives.length === 0) { + return []; + } + + return sortedPatterns.positives.reduce(function (ret, positive) { + return arrayUnion(ret, glob.sync(positive.pattern, setIgnore(opts, sortedPatterns.negatives, positive.index))); + }, []); +}; diff --git a/tools/node_modules/globby/license b/tools/node_modules/globby/license new file mode 100644 index 00000000000000..654d0bfe943437 --- /dev/null +++ b/tools/node_modules/globby/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tools/node_modules/globby/package.json b/tools/node_modules/globby/package.json new file mode 100644 index 00000000000000..2c1ccc7447d6ae --- /dev/null +++ b/tools/node_modules/globby/package.json @@ -0,0 +1,130 @@ +{ + "_args": [ + [ + "globby@^4.0.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\remark" + ] + ], + "_from": "globby@>=4.0.0 <5.0.0", + "_id": "globby@4.0.0", + "_inCache": true, + "_location": "/globby", + "_nodeVersion": "4.2.1", + "_npmUser": { + "email": "sindresorhus@gmail.com", + "name": "sindresorhus" + }, + "_npmVersion": "2.14.7", + "_phantomChildren": {}, + "_requested": { + "name": "globby", + "raw": "globby@^4.0.0", + "rawSpec": "^4.0.0", + "scope": null, + "spec": ">=4.0.0 <5.0.0", + "type": "range" + }, + "_requiredBy": [ + "/remark" + ], + "_resolved": "https://registry.npmjs.org/globby/-/globby-4.0.0.tgz", + "_shasum": "36ff06c5a9dc1dbc201f700074992882857e9817", + "_shrinkwrap": null, + "_spec": "globby@^4.0.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\remark", + "author": { + "email": "sindresorhus@gmail.com", + "name": "Sindre Sorhus", + "url": "sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/sindresorhus/globby/issues" + }, + "dependencies": { + "array-union": "^1.0.1", + "arrify": "^1.0.0", + "glob": "^6.0.1", + "object-assign": "^4.0.1", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0" + }, + "description": "Extends `glob` with support for multiple patterns and exposes a Promise API", + "devDependencies": { + "glob-stream": "git+https://github.com/wearefractal/glob-stream#master", + "globby": "git+https://github.com/sindresorhus/globby#master", + "matcha": "^0.6.0", + "mocha": "*", + "rimraf": "^2.2.8", + "xo": "*" + }, + "directories": {}, + "dist": { + "shasum": "36ff06c5a9dc1dbc201f700074992882857e9817", + "tarball": "http://registry.npmjs.org/globby/-/globby-4.0.0.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "70389b06d4633868ea016ce38956d0a86aa90a23", + "homepage": "https://github.com/sindresorhus/globby", + "installable": true, + "keywords": [ + "all", + "array", + "directories", + "dirs", + "expand", + "files", + "filesystem", + "filter", + "find", + "fnmatch", + "folders", + "fs", + "glob", + "globbing", + "globs", + "gulpfriendly", + "match", + "matcher", + "minimatch", + "multi", + "multiple", + "paths", + "pattern", + "patterns", + "promise", + "traverse", + "util", + "utility", + "wildcard", + "wildcards" + ], + "license": "MIT", + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + } + ], + "name": "globby", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "https://github.com/sindresorhus/globby" + }, + "scripts": { + "bench": "npm update globby glob-stream && matcha bench.js", + "test": "xo && mocha" + }, + "version": "4.0.0", + "xo": { + "envs": [ + "mocha", + "node" + ] + } +} diff --git a/tools/node_modules/globby/readme.md b/tools/node_modules/globby/readme.md new file mode 100644 index 00000000000000..e0881d54febc09 --- /dev/null +++ b/tools/node_modules/globby/readme.md @@ -0,0 +1,75 @@ +# globby [![Build Status](https://travis-ci.org/sindresorhus/globby.svg?branch=master)](https://travis-ci.org/sindresorhus/globby) + +> Extends [glob](https://github.com/isaacs/node-glob) with support for multiple patterns and exposes a Promise API + + +## Install + +``` +$ npm install --save globby +``` + + +## Usage + +``` +├── unicorn +├── cake +└── rainbow +``` + +```js +const globby = require('globby'); + +globby(['*', '!cake']).then(paths => { + console.log(paths); + //=> ['unicorn', 'rainbow'] +}); +``` + + +## API + +### globby(patterns, [options]) + +Returns a promise that resolves to an array of matching paths. + +### globby.sync(patterns, [options]) + +Returns an array of matching paths. + +#### patterns + +Type: `string`, `array` + +See supported `minimatch` [patterns](https://github.com/isaacs/minimatch#usage). + +#### options + +Type: `object` + +See the `node-glob` [options](https://github.com/isaacs/node-glob#options). + + +## Globbing patterns + +Just a quick overview. + +- `*` matches any number of characters, but not `/` +- `?` matches a single character, but not `/` +- `**` matches any number of characters, including `/`, as long as it's the only thing in a path part +- `{}` allows for a comma-separated list of "or" expressions +- `!` at the beginning of a pattern will negate the match + +[Various patterns and expected matches](https://github.com/sindresorhus/multimatch/blob/master/test.js). + + +## Related + +- [multimatch](https://github.com/sindresorhus/multimatch) - Match against a list instead of the filesystem. +- [glob-stream](https://github.com/wearefractal/glob-stream) - Streaming alternative. + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/tools/node_modules/graceful-fs/LICENSE b/tools/node_modules/graceful-fs/LICENSE new file mode 100644 index 00000000000000..9d2c8036969bed --- /dev/null +++ b/tools/node_modules/graceful-fs/LICENSE @@ -0,0 +1,15 @@ +The ISC License + +Copyright (c) Isaac Z. Schlueter, Ben Noordhuis, and Contributors + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR +IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/tools/node_modules/graceful-fs/README.md b/tools/node_modules/graceful-fs/README.md new file mode 100644 index 00000000000000..d920aaac9e17af --- /dev/null +++ b/tools/node_modules/graceful-fs/README.md @@ -0,0 +1,53 @@ +# graceful-fs + +graceful-fs functions as a drop-in replacement for the fs module, +making various improvements. + +The improvements are meant to normalize behavior across different +platforms and environments, and to make filesystem access more +resilient to errors. + +## Improvements over [fs module](http://api.nodejs.org/fs.html) + +graceful-fs: + +* Queues up `open` and `readdir` calls, and retries them once + something closes if there is an EMFILE error from too many file + descriptors. +* fixes `lchmod` for Node versions prior to 0.6.2. +* implements `fs.lutimes` if possible. Otherwise it becomes a noop. +* ignores `EINVAL` and `EPERM` errors in `chown`, `fchown` or + `lchown` if the user isn't root. +* makes `lchmod` and `lchown` become noops, if not available. +* retries reading a file if `read` results in EAGAIN error. + +On Windows, it retries renaming a file for up to one second if `EACCESS` +or `EPERM` error occurs, likely because antivirus software has locked +the directory. + +## USAGE + +```javascript +// use just like fs +var fs = require('graceful-fs') + +// now go and do stuff with it... +fs.readFileSync('some-file-or-whatever') +``` + +## Global Patching + +If you want to patch the global fs module (or any other fs-like +module) you can do this: + +```javascript +// Make sure to read the caveat below. +var realFs = require('fs') +var gracefulFs = require('graceful-fs') +gracefulFs.gracefulify(realFs) +``` + +This should only ever be done at the top-level application layer, in +order to delay on EMFILE errors from any fs-using dependencies. You +should **not** do this in a library, because it can cause unexpected +delays in other parts of the program. diff --git a/tools/node_modules/graceful-fs/fs.js b/tools/node_modules/graceful-fs/fs.js new file mode 100644 index 00000000000000..8ad4a383965b7b --- /dev/null +++ b/tools/node_modules/graceful-fs/fs.js @@ -0,0 +1,21 @@ +'use strict' + +var fs = require('fs') + +module.exports = clone(fs) + +function clone (obj) { + if (obj === null || typeof obj !== 'object') + return obj + + if (obj instanceof Object) + var copy = { __proto__: obj.__proto__ } + else + var copy = Object.create(null) + + Object.getOwnPropertyNames(obj).forEach(function (key) { + Object.defineProperty(copy, key, Object.getOwnPropertyDescriptor(obj, key)) + }) + + return copy +} diff --git a/tools/node_modules/graceful-fs/graceful-fs.js b/tools/node_modules/graceful-fs/graceful-fs.js new file mode 100644 index 00000000000000..9bf803e686c703 --- /dev/null +++ b/tools/node_modules/graceful-fs/graceful-fs.js @@ -0,0 +1,253 @@ +var fs = require('fs') +var polyfills = require('./polyfills.js') +var legacy = require('./legacy-streams.js') +var queue = [] + +var util = require('util') + +function noop () {} + +var debug = noop +if (util.debuglog) + debug = util.debuglog('gfs4') +else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || '')) + debug = function() { + var m = util.format.apply(util, arguments) + m = 'GFS4: ' + m.split(/\n/).join('\nGFS4: ') + console.error(m) + } + +if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || '')) { + process.on('exit', function() { + debug(queue) + require('assert').equal(queue.length, 0) + }) +} + +module.exports = patch(require('./fs.js')) +if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH) { + module.exports = patch(fs) +} + +// Always patch fs.close/closeSync, because we want to +// retry() whenever a close happens *anywhere* in the program. +// This is essential when multiple graceful-fs instances are +// in play at the same time. +module.exports.close = +fs.close = (function (fs$close) { return function (fd, cb) { + return fs$close.call(fs, fd, function (err) { + if (!err) + retry() + + if (typeof cb === 'function') + cb.apply(this, arguments) + }) +}})(fs.close) + +module.exports.closeSync = +fs.closeSync = (function (fs$closeSync) { return function (fd) { + // Note that graceful-fs also retries when fs.closeSync() fails. + // Looks like a bug to me, although it's probably a harmless one. + var rval = fs$closeSync.apply(fs, arguments) + retry() + return rval +}})(fs.closeSync) + +function patch (fs) { + // Everything that references the open() function needs to be in here + polyfills(fs) + fs.gracefulify = patch + fs.FileReadStream = ReadStream; // Legacy name. + fs.FileWriteStream = WriteStream; // Legacy name. + fs.createReadStream = createReadStream + fs.createWriteStream = createWriteStream + var fs$readFile = fs.readFile + fs.readFile = readFile + function readFile (path, options, cb) { + if (typeof options === 'function') + cb = options, options = null + + return go$readFile(path, options, cb) + + function go$readFile (path, options, cb) { + return fs$readFile(path, options, function (err) { + if (err && (err.code === 'EMFILE' || err.code === 'ENFILE')) + enqueue([go$readFile, [path, options, cb]]) + else { + if (typeof cb === 'function') + cb.apply(this, arguments) + retry() + } + }) + } + } + + var fs$writeFile = fs.writeFile + fs.writeFile = writeFile + function writeFile (path, data, options, cb) { + if (typeof options === 'function') + cb = options, options = null + + return go$writeFile(path, data, options, cb) + + function go$writeFile (path, data, options, cb) { + return fs$writeFile(path, data, options, function (err) { + if (err && (err.code === 'EMFILE' || err.code === 'ENFILE')) + enqueue([go$writeFile, [path, data, options, cb]]) + else { + if (typeof cb === 'function') + cb.apply(this, arguments) + retry() + } + }) + } + } + + var fs$appendFile = fs.appendFile + if (fs$appendFile) + fs.appendFile = appendFile + function appendFile (path, data, options, cb) { + if (typeof options === 'function') + cb = options, options = null + + return go$appendFile(path, data, options, cb) + + function go$appendFile (path, data, options, cb) { + return fs$appendFile(path, data, options, function (err) { + if (err && (err.code === 'EMFILE' || err.code === 'ENFILE')) + enqueue([go$appendFile, [path, data, options, cb]]) + else { + if (typeof cb === 'function') + cb.apply(this, arguments) + retry() + } + }) + } + } + + var fs$readdir = fs.readdir + fs.readdir = readdir + function readdir (path, cb) { + return go$readdir(path, cb) + + function go$readdir () { + return fs$readdir(path, function (err, files) { + if (files && files.sort) + files.sort(); // Backwards compatibility with graceful-fs. + + if (err && (err.code === 'EMFILE' || err.code === 'ENFILE')) + enqueue([go$readdir, [path, cb]]) + else { + if (typeof cb === 'function') + cb.apply(this, arguments) + retry() + } + }) + } + } + + + if (process.version.substr(0, 4) === 'v0.8') { + var legStreams = legacy(fs) + ReadStream = legStreams.ReadStream + WriteStream = legStreams.WriteStream + } + + var fs$ReadStream = fs.ReadStream + ReadStream.prototype = Object.create(fs$ReadStream.prototype) + ReadStream.prototype.open = ReadStream$open + + var fs$WriteStream = fs.WriteStream + WriteStream.prototype = Object.create(fs$WriteStream.prototype) + WriteStream.prototype.open = WriteStream$open + + fs.ReadStream = ReadStream + fs.WriteStream = WriteStream + + function ReadStream (path, options) { + if (this instanceof ReadStream) + return fs$ReadStream.apply(this, arguments), this + else + return ReadStream.apply(Object.create(ReadStream.prototype), arguments) + } + + function ReadStream$open () { + var that = this + open(that.path, that.flags, that.mode, function (err, fd) { + if (err) { + if (that.autoClose) + that.destroy() + + that.emit('error', err) + } else { + that.fd = fd + that.emit('open', fd) + that.read() + } + }) + } + + function WriteStream (path, options) { + if (this instanceof WriteStream) + return fs$WriteStream.apply(this, arguments), this + else + return WriteStream.apply(Object.create(WriteStream.prototype), arguments) + } + + function WriteStream$open () { + var that = this + open(that.path, that.flags, that.mode, function (err, fd) { + if (err) { + that.destroy() + that.emit('error', err) + } else { + that.fd = fd + that.emit('open', fd) + } + }) + } + + function createReadStream (path, options) { + return new ReadStream(path, options) + } + + function createWriteStream (path, options) { + return new WriteStream(path, options) + } + + var fs$open = fs.open + fs.open = open + function open (path, flags, mode, cb) { + if (typeof mode === 'function') + cb = mode, mode = null + + return go$open(path, flags, mode, cb) + + function go$open (path, flags, mode, cb) { + return fs$open(path, flags, mode, function (err, fd) { + if (err && (err.code === 'EMFILE' || err.code === 'ENFILE')) + enqueue([go$open, [path, flags, mode, cb]]) + else { + if (typeof cb === 'function') + cb.apply(this, arguments) + retry() + } + }) + } + } + + return fs +} + +function enqueue (elem) { + debug('ENQUEUE', elem[0].name, elem[1]) + queue.push(elem) +} + +function retry () { + var elem = queue.shift() + if (elem) { + debug('RETRY', elem[0].name, elem[1]) + elem[0].apply(null, elem[1]) + } +} diff --git a/tools/node_modules/graceful-fs/legacy-streams.js b/tools/node_modules/graceful-fs/legacy-streams.js new file mode 100644 index 00000000000000..d617b50fc0832d --- /dev/null +++ b/tools/node_modules/graceful-fs/legacy-streams.js @@ -0,0 +1,118 @@ +var Stream = require('stream').Stream + +module.exports = legacy + +function legacy (fs) { + return { + ReadStream: ReadStream, + WriteStream: WriteStream + } + + function ReadStream (path, options) { + if (!(this instanceof ReadStream)) return new ReadStream(path, options); + + Stream.call(this); + + var self = this; + + this.path = path; + this.fd = null; + this.readable = true; + this.paused = false; + + this.flags = 'r'; + this.mode = 438; /*=0666*/ + this.bufferSize = 64 * 1024; + + options = options || {}; + + // Mixin options into this + var keys = Object.keys(options); + for (var index = 0, length = keys.length; index < length; index++) { + var key = keys[index]; + this[key] = options[key]; + } + + if (this.encoding) this.setEncoding(this.encoding); + + if (this.start !== undefined) { + if ('number' !== typeof this.start) { + throw TypeError('start must be a Number'); + } + if (this.end === undefined) { + this.end = Infinity; + } else if ('number' !== typeof this.end) { + throw TypeError('end must be a Number'); + } + + if (this.start > this.end) { + throw new Error('start must be <= end'); + } + + this.pos = this.start; + } + + if (this.fd !== null) { + process.nextTick(function() { + self._read(); + }); + return; + } + + fs.open(this.path, this.flags, this.mode, function (err, fd) { + if (err) { + self.emit('error', err); + self.readable = false; + return; + } + + self.fd = fd; + self.emit('open', fd); + self._read(); + }) + } + + function WriteStream (path, options) { + if (!(this instanceof WriteStream)) return new WriteStream(path, options); + + Stream.call(this); + + this.path = path; + this.fd = null; + this.writable = true; + + this.flags = 'w'; + this.encoding = 'binary'; + this.mode = 438; /*=0666*/ + this.bytesWritten = 0; + + options = options || {}; + + // Mixin options into this + var keys = Object.keys(options); + for (var index = 0, length = keys.length; index < length; index++) { + var key = keys[index]; + this[key] = options[key]; + } + + if (this.start !== undefined) { + if ('number' !== typeof this.start) { + throw TypeError('start must be a Number'); + } + if (this.start < 0) { + throw new Error('start must be >= zero'); + } + + this.pos = this.start; + } + + this.busy = false; + this._queue = []; + + if (this.fd === null) { + this._open = fs.open; + this._queue.push([this._open, this.path, this.flags, this.mode, undefined]); + this.flush(); + } + } +} diff --git a/tools/node_modules/graceful-fs/package.json b/tools/node_modules/graceful-fs/package.json new file mode 100644 index 00000000000000..f24bfba8789a1d --- /dev/null +++ b/tools/node_modules/graceful-fs/package.json @@ -0,0 +1,102 @@ +{ + "_args": [ + [ + "graceful-fs@^4.1.2", + "C:\\wamp\\www\\node\\tools\\node_modules\\readdirp" + ] + ], + "_from": "graceful-fs@>=4.1.2 <5.0.0", + "_id": "graceful-fs@4.1.3", + "_inCache": true, + "_location": "/graceful-fs", + "_nodeVersion": "4.0.0", + "_npmOperationalInternal": { + "host": "packages-6-west.internal.npmjs.com", + "tmp": "tmp/graceful-fs-4.1.3.tgz_1454449326495_0.943017533281818" + }, + "_npmUser": { + "email": "i@izs.me", + "name": "isaacs" + }, + "_npmVersion": "3.7.0", + "_phantomChildren": {}, + "_requested": { + "name": "graceful-fs", + "raw": "graceful-fs@^4.1.2", + "rawSpec": "^4.1.2", + "scope": null, + "spec": ">=4.1.2 <5.0.0", + "type": "range" + }, + "_requiredBy": [ + "/readdirp" + ], + "_resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.3.tgz", + "_shasum": "92033ce11113c41e2628d61fdfa40bc10dc0155c", + "_shrinkwrap": null, + "_spec": "graceful-fs@^4.1.2", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\readdirp", + "bugs": { + "url": "https://github.com/isaacs/node-graceful-fs/issues" + }, + "dependencies": {}, + "description": "A drop-in replacement for fs, making various improvements.", + "devDependencies": { + "mkdirp": "^0.5.0", + "rimraf": "^2.2.8", + "tap": "^5.4.2" + }, + "directories": { + "test": "test" + }, + "dist": { + "shasum": "92033ce11113c41e2628d61fdfa40bc10dc0155c", + "tarball": "http://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.3.tgz" + }, + "engines": { + "node": ">=0.4.0" + }, + "files": [ + "fs.js", + "graceful-fs.js", + "legacy-streams.js", + "polyfills.js" + ], + "gitHead": "694c56f3aed4aee62d6df169be123d3984f61b85", + "homepage": "https://github.com/isaacs/node-graceful-fs#readme", + "installable": true, + "keywords": [ + "EACCESS", + "EAGAIN", + "EINVAL", + "EMFILE", + "EPERM", + "error", + "errors", + "fs", + "handling", + "module", + "queue", + "reading", + "retries", + "retry" + ], + "license": "ISC", + "main": "graceful-fs.js", + "maintainers": [ + { + "name": "isaacs", + "email": "i@izs.me" + } + ], + "name": "graceful-fs", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git+https://github.com/isaacs/node-graceful-fs.git" + }, + "scripts": { + "test": "node test.js | tap -" + }, + "version": "4.1.3" +} diff --git a/tools/node_modules/graceful-fs/polyfills.js b/tools/node_modules/graceful-fs/polyfills.js new file mode 100644 index 00000000000000..5e4f4804618d17 --- /dev/null +++ b/tools/node_modules/graceful-fs/polyfills.js @@ -0,0 +1,252 @@ +var fs = require('./fs.js') +var constants = require('constants') + +var origCwd = process.cwd +var cwd = null +process.cwd = function() { + if (!cwd) + cwd = origCwd.call(process) + return cwd +} +try { + process.cwd() +} catch (er) {} + +var chdir = process.chdir +process.chdir = function(d) { + cwd = null + chdir.call(process, d) +} + +module.exports = patch + +function patch (fs) { + // (re-)implement some things that are known busted or missing. + + // lchmod, broken prior to 0.6.2 + // back-port the fix here. + if (constants.hasOwnProperty('O_SYMLINK') && + process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) { + patchLchmod(fs) + } + + // lutimes implementation, or no-op + if (!fs.lutimes) { + patchLutimes(fs) + } + + // https://github.com/isaacs/node-graceful-fs/issues/4 + // Chown should not fail on einval or eperm if non-root. + // It should not fail on enosys ever, as this just indicates + // that a fs doesn't support the intended operation. + + fs.chown = chownFix(fs.chown) + fs.fchown = chownFix(fs.fchown) + fs.lchown = chownFix(fs.lchown) + + fs.chmod = chownFix(fs.chmod) + fs.fchmod = chownFix(fs.fchmod) + fs.lchmod = chownFix(fs.lchmod) + + fs.chownSync = chownFixSync(fs.chownSync) + fs.fchownSync = chownFixSync(fs.fchownSync) + fs.lchownSync = chownFixSync(fs.lchownSync) + + fs.chmodSync = chownFix(fs.chmodSync) + fs.fchmodSync = chownFix(fs.fchmodSync) + fs.lchmodSync = chownFix(fs.lchmodSync) + + // if lchmod/lchown do not exist, then make them no-ops + if (!fs.lchmod) { + fs.lchmod = function (path, mode, cb) { + process.nextTick(cb) + } + fs.lchmodSync = function () {} + } + if (!fs.lchown) { + fs.lchown = function (path, uid, gid, cb) { + process.nextTick(cb) + } + fs.lchownSync = function () {} + } + + // on Windows, A/V software can lock the directory, causing this + // to fail with an EACCES or EPERM if the directory contains newly + // created files. Try again on failure, for up to 1 second. + if (process.platform === "win32") { + fs.rename = (function (fs$rename) { return function (from, to, cb) { + var start = Date.now() + fs$rename(from, to, function CB (er) { + if (er + && (er.code === "EACCES" || er.code === "EPERM") + && Date.now() - start < 1000) { + return fs$rename(from, to, CB) + } + if (cb) cb(er) + }) + }})(fs.rename) + } + + // if read() returns EAGAIN, then just try it again. + fs.read = (function (fs$read) { return function (fd, buffer, offset, length, position, callback_) { + var callback + if (callback_ && typeof callback_ === 'function') { + var eagCounter = 0 + callback = function (er, _, __) { + if (er && er.code === 'EAGAIN' && eagCounter < 10) { + eagCounter ++ + return fs$read.call(fs, fd, buffer, offset, length, position, callback) + } + callback_.apply(this, arguments) + } + } + return fs$read.call(fs, fd, buffer, offset, length, position, callback) + }})(fs.read) + + fs.readSync = (function (fs$readSync) { return function (fd, buffer, offset, length, position) { + var eagCounter = 0 + while (true) { + try { + return fs$readSync.call(fs, fd, buffer, offset, length, position) + } catch (er) { + if (er.code === 'EAGAIN' && eagCounter < 10) { + eagCounter ++ + continue + } + throw er + } + } + }})(fs.readSync) +} + +function patchLchmod (fs) { + fs.lchmod = function (path, mode, callback) { + callback = callback || noop + fs.open( path + , constants.O_WRONLY | constants.O_SYMLINK + , mode + , function (err, fd) { + if (err) { + callback(err) + return + } + // prefer to return the chmod error, if one occurs, + // but still try to close, and report closing errors if they occur. + fs.fchmod(fd, mode, function (err) { + fs.close(fd, function(err2) { + callback(err || err2) + }) + }) + }) + } + + fs.lchmodSync = function (path, mode) { + var fd = fs.openSync(path, constants.O_WRONLY | constants.O_SYMLINK, mode) + + // prefer to return the chmod error, if one occurs, + // but still try to close, and report closing errors if they occur. + var threw = true + var ret + try { + ret = fs.fchmodSync(fd, mode) + threw = false + } finally { + if (threw) { + try { + fs.closeSync(fd) + } catch (er) {} + } else { + fs.closeSync(fd) + } + } + return ret + } +} + +function patchLutimes (fs) { + if (constants.hasOwnProperty("O_SYMLINK")) { + fs.lutimes = function (path, at, mt, cb) { + fs.open(path, constants.O_SYMLINK, function (er, fd) { + cb = cb || noop + if (er) return cb(er) + fs.futimes(fd, at, mt, function (er) { + fs.close(fd, function (er2) { + return cb(er || er2) + }) + }) + }) + } + + fs.lutimesSync = function (path, at, mt) { + var fd = fs.openSync(path, constants.O_SYMLINK) + var ret + var threw = true + try { + ret = fs.futimesSync(fd, at, mt) + threw = false + } finally { + if (threw) { + try { + fs.closeSync(fd) + } catch (er) {} + } else { + fs.closeSync(fd) + } + } + return ret + } + + } else { + fs.lutimes = function (_a, _b, _c, cb) { process.nextTick(cb) } + fs.lutimesSync = function () {} + } +} + +function chownFix (orig) { + if (!orig) return orig + return function (target, uid, gid, cb) { + return orig.call(fs, target, uid, gid, function (er, res) { + if (chownErOk(er)) er = null + cb(er, res) + }) + } +} + +function chownFixSync (orig) { + if (!orig) return orig + return function (target, uid, gid) { + try { + return orig.call(fs, target, uid, gid) + } catch (er) { + if (!chownErOk(er)) throw er + } + } +} + +// ENOSYS means that the fs doesn't support the op. Just ignore +// that, because it doesn't matter. +// +// if there's no getuid, or if getuid() is something other +// than 0, and the error is EINVAL or EPERM, then just ignore +// it. +// +// This specific case is a silent failure in cp, install, tar, +// and most other unix tools that manage permissions. +// +// When running as root, or if other types of errors are +// encountered, then it's strict. +function chownErOk (er) { + if (!er) + return true + + if (er.code === "ENOSYS") + return true + + var nonroot = !process.getuid || process.getuid() !== 0 + if (nonroot) { + if (er.code === "EINVAL" || er.code === "EPERM") + return true + } + + return false +} diff --git a/tools/node_modules/graceful-readlink/.npmignore b/tools/node_modules/graceful-readlink/.npmignore new file mode 100644 index 00000000000000..3ac7d16c6d6525 --- /dev/null +++ b/tools/node_modules/graceful-readlink/.npmignore @@ -0,0 +1,3 @@ +.idea/ +.DS_Store +node_modules/ diff --git a/tools/node_modules/graceful-readlink/.travis.yml b/tools/node_modules/graceful-readlink/.travis.yml new file mode 100644 index 00000000000000..baf9be7f6c8c0a --- /dev/null +++ b/tools/node_modules/graceful-readlink/.travis.yml @@ -0,0 +1,5 @@ +language: node_js +node_js: + - "0.10" + - "0.12" + - "io.js" diff --git a/tools/node_modules/graceful-readlink/LICENSE b/tools/node_modules/graceful-readlink/LICENSE new file mode 100644 index 00000000000000..d1f842f0bb2722 --- /dev/null +++ b/tools/node_modules/graceful-readlink/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2015 Zhiye Li + +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. + diff --git a/tools/node_modules/graceful-readlink/README.md b/tools/node_modules/graceful-readlink/README.md new file mode 100644 index 00000000000000..fc63b505a516b2 --- /dev/null +++ b/tools/node_modules/graceful-readlink/README.md @@ -0,0 +1,17 @@ +# graceful-readlink +[![NPM Version](http://img.shields.io/npm/v/graceful-readlink.svg?style=flat)](https://www.npmjs.org/package/graceful-readlink) +[![NPM Downloads](https://img.shields.io/npm/dm/graceful-readlink.svg?style=flat)](https://www.npmjs.org/package/graceful-readlink) + + +## Usage + +```js +var readlinkSync = require('graceful-readlink').readlinkSync; +console.log(readlinkSync(f)); +// output +// the file pointed to when `f` is a symbolic link +// the `f` itself when `f` is not a symbolic link +``` +## Licence + +MIT License diff --git a/tools/node_modules/graceful-readlink/index.js b/tools/node_modules/graceful-readlink/index.js new file mode 100644 index 00000000000000..7e9fc70f0ac251 --- /dev/null +++ b/tools/node_modules/graceful-readlink/index.js @@ -0,0 +1,12 @@ +var fs = require('fs') + , lstat = fs.lstatSync; + +exports.readlinkSync = function (p) { + if (lstat(p).isSymbolicLink()) { + return fs.readlinkSync(p); + } else { + return p; + } +}; + + diff --git a/tools/node_modules/graceful-readlink/package.json b/tools/node_modules/graceful-readlink/package.json new file mode 100644 index 00000000000000..8b0268af55f7df --- /dev/null +++ b/tools/node_modules/graceful-readlink/package.json @@ -0,0 +1,74 @@ +{ + "_args": [ + [ + "graceful-readlink@>= 1.0.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\commander" + ] + ], + "_from": "graceful-readlink@>=1.0.0", + "_id": "graceful-readlink@1.0.1", + "_inCache": true, + "_location": "/graceful-readlink", + "_nodeVersion": "0.11.14", + "_npmUser": { + "email": "zhiyelee@gmail.com", + "name": "zhiyelee" + }, + "_npmVersion": "2.1.17", + "_phantomChildren": {}, + "_requested": { + "name": "graceful-readlink", + "raw": "graceful-readlink@>= 1.0.0", + "rawSpec": ">= 1.0.0", + "scope": null, + "spec": ">=1.0.0", + "type": "range" + }, + "_requiredBy": [ + "/commander" + ], + "_resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz", + "_shasum": "4cafad76bc62f02fa039b2f94e9a3dd3a391a725", + "_shrinkwrap": null, + "_spec": "graceful-readlink@>= 1.0.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\commander", + "author": { + "name": "zhiyelee" + }, + "bugs": { + "url": "https://github.com/zhiyelee/graceful-readlink/issues" + }, + "dependencies": {}, + "description": "graceful fs.readlink", + "devDependencies": {}, + "directories": {}, + "dist": { + "shasum": "4cafad76bc62f02fa039b2f94e9a3dd3a391a725", + "tarball": "http://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz" + }, + "gitHead": "f6655275bebef706fb63fd01b5f062a7052419a5", + "homepage": "https://github.com/zhiyelee/graceful-readlink", + "installable": true, + "keywords": [ + "fs.readlink", + "readlink" + ], + "license": "MIT", + "main": "index.js", + "maintainers": [ + { + "name": "zhiyelee", + "email": "zhiyelee@gmail.com" + } + ], + "name": "graceful-readlink", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git://github.com/zhiyelee/graceful-readlink.git" + }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "version": "1.0.1" +} diff --git a/tools/node_modules/has-ansi/index.js b/tools/node_modules/has-ansi/index.js new file mode 100644 index 00000000000000..98fae067673731 --- /dev/null +++ b/tools/node_modules/has-ansi/index.js @@ -0,0 +1,4 @@ +'use strict'; +var ansiRegex = require('ansi-regex'); +var re = new RegExp(ansiRegex().source); // remove the `g` flag +module.exports = re.test.bind(re); diff --git a/tools/node_modules/has-ansi/license b/tools/node_modules/has-ansi/license new file mode 100644 index 00000000000000..654d0bfe943437 --- /dev/null +++ b/tools/node_modules/has-ansi/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tools/node_modules/has-ansi/package.json b/tools/node_modules/has-ansi/package.json new file mode 100644 index 00000000000000..5038f5996fa15d --- /dev/null +++ b/tools/node_modules/has-ansi/package.json @@ -0,0 +1,109 @@ +{ + "_args": [ + [ + "has-ansi@^2.0.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\chalk" + ] + ], + "_from": "has-ansi@>=2.0.0 <3.0.0", + "_id": "has-ansi@2.0.0", + "_inCache": true, + "_location": "/has-ansi", + "_nodeVersion": "0.12.5", + "_npmUser": { + "email": "sindresorhus@gmail.com", + "name": "sindresorhus" + }, + "_npmVersion": "2.11.2", + "_phantomChildren": {}, + "_requested": { + "name": "has-ansi", + "raw": "has-ansi@^2.0.0", + "rawSpec": "^2.0.0", + "scope": null, + "spec": ">=2.0.0 <3.0.0", + "type": "range" + }, + "_requiredBy": [ + "/chalk" + ], + "_resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "_shasum": "34f5049ce1ecdf2b0649af3ef24e45ed35416d91", + "_shrinkwrap": null, + "_spec": "has-ansi@^2.0.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\chalk", + "author": { + "email": "sindresorhus@gmail.com", + "name": "Sindre Sorhus", + "url": "sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/sindresorhus/has-ansi/issues" + }, + "dependencies": { + "ansi-regex": "^2.0.0" + }, + "description": "Check if a string has ANSI escape codes", + "devDependencies": { + "ava": "0.0.4" + }, + "directories": {}, + "dist": { + "shasum": "34f5049ce1ecdf2b0649af3ef24e45ed35416d91", + "tarball": "http://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "0722275e1bef139fcd09137da6e5550c3cd368b9", + "homepage": "https://github.com/sindresorhus/has-ansi", + "installable": true, + "keywords": [ + "ansi", + "color", + "colors", + "colour", + "command-line", + "console", + "escape", + "find", + "has", + "match", + "pattern", + "re", + "regex", + "regexp", + "shell", + "string", + "styles", + "terminal", + "test", + "text", + "tty", + "xterm" + ], + "license": "MIT", + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + }, + { + "name": "jbnicolai", + "email": "jappelman@xebia.com" + } + ], + "name": "has-ansi", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "https://github.com/sindresorhus/has-ansi" + }, + "scripts": { + "test": "node test.js" + }, + "version": "2.0.0" +} diff --git a/tools/node_modules/has-ansi/readme.md b/tools/node_modules/has-ansi/readme.md new file mode 100644 index 00000000000000..02bc7c2300a679 --- /dev/null +++ b/tools/node_modules/has-ansi/readme.md @@ -0,0 +1,36 @@ +# has-ansi [![Build Status](https://travis-ci.org/sindresorhus/has-ansi.svg?branch=master)](https://travis-ci.org/sindresorhus/has-ansi) + +> Check if a string has [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code) + + +## Install + +``` +$ npm install --save has-ansi +``` + + +## Usage + +```js +var hasAnsi = require('has-ansi'); + +hasAnsi('\u001b[4mcake\u001b[0m'); +//=> true + +hasAnsi('cake'); +//=> false +``` + + +## Related + +- [has-ansi-cli](https://github.com/sindresorhus/has-ansi-cli) - CLI for this module +- [strip-ansi](https://github.com/sindresorhus/strip-ansi) - Strip ANSI escape codes +- [ansi-regex](https://github.com/sindresorhus/ansi-regex) - Regular expression for matching ANSI escape codes +- [chalk](https://github.com/sindresorhus/chalk) - Terminal string styling done right + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/tools/node_modules/he/LICENSE-MIT.txt b/tools/node_modules/he/LICENSE-MIT.txt new file mode 100644 index 00000000000000..a41e0a7ef970ec --- /dev/null +++ b/tools/node_modules/he/LICENSE-MIT.txt @@ -0,0 +1,20 @@ +Copyright Mathias Bynens + +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. diff --git a/tools/node_modules/he/README.md b/tools/node_modules/he/README.md new file mode 100644 index 00000000000000..61765d13a70eb7 --- /dev/null +++ b/tools/node_modules/he/README.md @@ -0,0 +1,336 @@ +# he [![Build status](https://travis-ci.org/mathiasbynens/he.svg?branch=master)](https://travis-ci.org/mathiasbynens/he) [![Code coverage status](http://img.shields.io/coveralls/mathiasbynens/he/master.svg)](https://coveralls.io/r/mathiasbynens/he) [![Dependency status](https://gemnasium.com/mathiasbynens/he.svg)](https://gemnasium.com/mathiasbynens/he) + +_he_ (for “HTML entities”) is a robust HTML entity encoder/decoder written in JavaScript. It supports [all standardized named character references as per HTML](http://www.whatwg.org/specs/web-apps/current-work/multipage/named-character-references.html), handles [ambiguous ampersands](https://mathiasbynens.be/notes/ambiguous-ampersands) and other edge cases [just like a browser would](http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html#tokenizing-character-references), has an extensive test suite, and — contrary to many other JavaScript solutions — _he_ handles astral Unicode symbols just fine. [An online demo is available.](http://mothereff.in/html-entities) + +## Installation + +Via [npm](http://npmjs.org/): + +```bash +npm install he +``` + +Via [Bower](http://bower.io/): + +```bash +bower install he +``` + +Via [Component](https://github.com/component/component): + +```bash +component install mathiasbynens/he +``` + +In a browser: + +```html + +``` + +In [Narwhal](http://narwhaljs.org/), [Node.js](http://nodejs.org/), and [RingoJS](http://ringojs.org/): + +```js +var he = require('he'); +``` + +In [Rhino](http://www.mozilla.org/rhino/): + +```js +load('he.js'); +``` + +Using an AMD loader like [RequireJS](http://requirejs.org/): + +```js +require( + { + 'paths': { + 'he': 'path/to/he' + } + }, + ['he'], + function(he) { + console.log(he); + } +); +``` + +## API + +### `he.version` + +A string representing the semantic version number. + +### `he.encode(text, options)` + +This function takes a string of text and encodes (by default) any symbols that aren’t printable ASCII symbols and `&`, `<`, `>`, `"`, `'`, and `` ` ``, replacing them with character references. + +```js +he.encode('foo © bar ≠ baz 𝌆 qux'); +// → 'foo © bar ≠ baz 𝌆 qux' +``` + +As long as the input string contains [allowed code points](http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html#preprocessing-the-input-stream) only, the return value of this function is always valid HTML. Any [(invalid) code points that cannot be represented using a character reference](http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html#table-charref-overrides) in the input are not encoded. + +```js +he.encode('foo \0 bar'); +// → 'foo \0 bar' +``` + +The `options` object is optional. It recognizes the following properties: + +#### `useNamedReferences` + +The default value for the `useNamedReferences` option is `false`. This means that `encode()` will not use any named character references (e.g. `©`) in the output — hexadecimal escapes (e.g. `©`) will be used instead. Set it to `true` to enable the use of named references. + +**Note that if compatibility with older browsers is a concern, this option should remain disabled.** + +```js +// Using the global default setting (defaults to `false`): +he.encode('foo © bar ≠ baz 𝌆 qux'); +// → 'foo © bar ≠ baz 𝌆 qux' + +// Passing an `options` object to `encode`, to explicitly disallow named references: +he.encode('foo © bar ≠ baz 𝌆 qux', { + 'useNamedReferences': false +}); +// → 'foo © bar ≠ baz 𝌆 qux' + +// Passing an `options` object to `encode`, to explicitly allow named references: +he.encode('foo © bar ≠ baz 𝌆 qux', { + 'useNamedReferences': true +}); +// → 'foo © bar ≠ baz 𝌆 qux' +``` + +#### `encodeEverything` + +The default value for the `encodeEverything` option is `false`. This means that `encode()` will not use any character references for printable ASCII symbols that don’t need escaping. Set it to `true` to encode every symbol in the input string. When set to `true`, this option takes precedence over `allowUnsafeSymbols` (i.e. setting the latter to `true` in such a case has no effect). + +```js +// Using the global default setting (defaults to `false`): +he.encode('foo © bar ≠ baz 𝌆 qux'); +// → 'foo © bar ≠ baz 𝌆 qux' + +// Passing an `options` object to `encode`, to explicitly encode all symbols: +he.encode('foo © bar ≠ baz 𝌆 qux', { + 'encodeEverything': true +}); +// → 'foo © bar ≠ baz 𝌆 qux' + +// This setting can be combined with the `useNamedReferences` option: +he.encode('foo © bar ≠ baz 𝌆 qux', { + 'encodeEverything': true, + 'useNamedReferences': true +}); +// → 'foo © bar ≠ baz 𝌆 qux' +``` + +#### `strict` + +The default value for the `strict` option is `false`. This means that `encode()` will encode any HTML text content you feed it, even if it contains any symbols that cause [parse errors](http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html#preprocessing-the-input-stream). To throw an error when such invalid HTML is encountered, set the `strict` option to `true`. This option makes it possible to use _he_ as part of HTML parsers and HTML validators. + +```js +// Using the global default setting (defaults to `false`, i.e. error-tolerant mode): +he.encode('\x01'); +// → '' + +// Passing an `options` object to `encode`, to explicitly enable error-tolerant mode: +he.encode('\x01', { + 'strict': false +}); +// → '' + +// Passing an `options` object to `encode`, to explicitly enable strict mode: +he.encode('\x01', { + 'strict': true +}); +// → Parse error +``` + +#### `allowUnsafeSymbols` + +The default value for the `allowUnsafeSymbols` option is `false`. This means that characters that are unsafe for use in HTML content (`&`, `<`, `>`, `"`, `'`, and `` ` ``) will be encoded. When set to `true`, only non-ASCII characters will be encoded. If the `encodeEverything` option is set to `true`, this option will be ignored. + +```js +he.encode('foo © and & ampersand', { + 'allowUnsafeSymbols': true +}); +// → 'foo © and & ampersand' +``` + +#### Overriding default `encode` options globally + +The global default setting can be overridden by modifying the `he.encode.options` object. This saves you from passing in an `options` object for every call to `encode` if you want to use the non-default setting. + +```js +// Read the global default setting: +he.encode.options.useNamedReferences; +// → `false` by default + +// Override the global default setting: +he.encode.options.useNamedReferences = true; + +// Using the global default setting, which is now `true`: +he.encode('foo © bar ≠ baz 𝌆 qux'); +// → 'foo © bar ≠ baz 𝌆 qux' +``` + +### `he.decode(html, options)` + +This function takes a string of HTML and decodes any named and numerical character references in it using [the algorithm described in section 12.2.4.69 of the HTML spec](http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html#tokenizing-character-references). + +```js +he.decode('foo © bar ≠ baz 𝌆 qux'); +// → 'foo © bar ≠ baz 𝌆 qux' +``` + +The `options` object is optional. It recognizes the following properties: + +#### `isAttributeValue` + +The default value for the `isAttributeValue` option is `false`. This means that `decode()` will decode the string as if it were used in [a text context in an HTML document](http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html#data-state). HTML has different rules for [parsing character references in attribute values](http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html#character-reference-in-attribute-value-state) — set this option to `true` to treat the input string as if it were used as an attribute value. + +```js +// Using the global default setting (defaults to `false`, i.e. HTML text context): +he.decode('foo&bar'); +// → 'foo&bar' + +// Passing an `options` object to `decode`, to explicitly assume an HTML text context: +he.decode('foo&bar', { + 'isAttributeValue': false +}); +// → 'foo&bar' + +// Passing an `options` object to `decode`, to explicitly assume an HTML attribute value context: +he.decode('foo&bar', { + 'isAttributeValue': true +}); +// → 'foo&bar' +``` + +#### `strict` + +The default value for the `strict` option is `false`. This means that `decode()` will decode any HTML text content you feed it, even if it contains any entities that cause [parse errors](http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html#tokenizing-character-references). To throw an error when such invalid HTML is encountered, set the `strict` option to `true`. This option makes it possible to use _he_ as part of HTML parsers and HTML validators. + +```js +// Using the global default setting (defaults to `false`, i.e. error-tolerant mode): +he.decode('foo&bar'); +// → 'foo&bar' + +// Passing an `options` object to `decode`, to explicitly enable error-tolerant mode: +he.decode('foo&bar', { + 'strict': false +}); +// → 'foo&bar' + +// Passing an `options` object to `decode`, to explicitly enable strict mode: +he.decode('foo&bar', { + 'strict': true +}); +// → Parse error +``` + +#### Overriding default `decode` options globally + +The global default settings for the `decode` function can be overridden by modifying the `he.decode.options` object. This saves you from passing in an `options` object for every call to `decode` if you want to use a non-default setting. + +```js +// Read the global default setting: +he.decode.options.isAttributeValue; +// → `false` by default + +// Override the global default setting: +he.decode.options.isAttributeValue = true; + +// Using the global default setting, which is now `true`: +he.decode('foo&bar'); +// → 'foo&bar' +``` + +### `he.escape(text)` + +This function takes a string of text and escapes it for use in text contexts in XML or HTML documents. Only the following characters are escaped: `&`, `<`, `>`, `"`, `'`, and `` ` ``. + +```js +he.escape(''); +// → '<img src='x' onerror="prompt(1)">' +``` + +### `he.unescape(html, options)` + +`he.unescape` is an alias for `he.decode`. It takes a string of HTML and decodes any named and numerical character references in it. + +### Using the `he` binary + +To use the `he` binary in your shell, simply install _he_ globally using npm: + +```bash +npm install -g he +``` + +After that you will be able to encode/decode HTML entities from the command line: + +```bash +$ he --encode 'föo ♥ bår 𝌆 baz' +föo ♥ bår 𝌆 baz + +$ he --encode --use-named-refs 'föo ♥ bår 𝌆 baz' +föo ♥ bår 𝌆 baz + +$ he --decode 'föo ♥ bår 𝌆 baz' +föo ♥ bår 𝌆 baz +``` + +Read a local text file, encode it for use in an HTML text context, and save the result to a new file: + +```bash +$ he --encode < foo.txt > foo-escaped.html +``` + +Or do the same with an online text file: + +```bash +$ curl -sL "http://git.io/HnfEaw" | he --encode > escaped.html +``` + +Or, the opposite — read a local file containing a snippet of HTML in a text context, decode it back to plain text, and save the result to a new file: + +```bash +$ he --decode < foo-escaped.html > foo.txt +``` + +Or do the same with an online HTML snippet: + +```bash +$ curl -sL "http://git.io/HnfEaw" | he --decode > decoded.txt +``` + +See `he --help` for the full list of options. + +## Support + +he has been tested in at least Chrome 27-29, Firefox 3-22, Safari 4-6, Opera 10-12, IE 6-10, Node.js v0.10.0, Narwhal 0.3.2, RingoJS 0.8-0.9, PhantomJS 1.9.0, and Rhino 1.7RC4. + +## Unit tests & code coverage + +After cloning this repository, run `npm install` to install the dependencies needed for he development and testing. You may want to install Istanbul _globally_ using `npm install istanbul -g`. + +Once that’s done, you can run the unit tests in Node using `npm test` or `node tests/tests.js`. To run the tests in Rhino, Ringo, Narwhal, and web browsers as well, use `grunt test`. + +To generate the code coverage report, use `grunt cover`. + +## Acknowledgements + +Thanks to [Simon Pieters](http://simon.html5.org/) ([@zcorpan](https://twitter.com/zcorpan)) for the many suggestions. + +## Author + +| [![twitter/mathias](https://gravatar.com/avatar/24e08a9ea84deb17ae121074d0f17125?s=70)](https://twitter.com/mathias "Follow @mathias on Twitter") | +|---| +| [Mathias Bynens](https://mathiasbynens.be/) | + +## License + +_he_ is available under the [MIT](http://mths.be/mit) license. diff --git a/tools/node_modules/he/bin/he b/tools/node_modules/he/bin/he new file mode 100644 index 00000000000000..234710cf791efd --- /dev/null +++ b/tools/node_modules/he/bin/he @@ -0,0 +1,143 @@ +#!/usr/bin/env node +(function() { + + var fs = require('fs'); + var he = require('../he.js'); + var strings = process.argv.splice(2); + var stdin = process.stdin; + var data; + var timeout; + var action; + var options = {}; + var log = console.log; + + var main = function() { + var option = strings[0]; + var count = 0; + + if (/^(?:-h|--help|undefined)$/.test(option)) { + log( + 'he v%s - http://mths.be/he', + he.version + ); + log([ + '\nUsage:\n', + '\the [--escape] string', + '\the [--encode] [--use-named-refs] [--everything] [--allow-unsafe] string', + '\the [--decode] [--attribute] [--strict] string', + '\the [-v | --version]', + '\the [-h | --help]', + '\nExamples:\n', + '\the --escape \\', + '\techo \'© 𝌆\' | he --decode' + ].join('\n')); + return process.exit(1); + } + + if (/^(?:-v|--version)$/.test(option)) { + log('v%s', he.version); + return process.exit(1); + } + + strings.forEach(function(string) { + // Process options + if (string == '--escape') { + action = 'escape'; + return; + } + if (string == '--encode') { + action = 'encode'; + return; + } + if (string == '--use-named-refs') { + action = 'encode'; + options.useNamedReferences = true; + return; + } + if (string == '--everything') { + action = 'encode'; + options.encodeEverything = true; + return; + } + if (string == '--allow-unsafe') { + action = 'encode'; + options.allowUnsafeSymbols = true; + return; + } + if (string == '--decode') { + action = 'decode'; + return; + } + if (string == '--attribute') { + action = 'decode'; + options.isAttributeValue = true; + return; + } + if (string == '--strict') { + action = 'decode'; + options.strict = true; + return; + } + // Process string(s) + var result; + if (!action) { + log('Error: he requires at least one option and a string argument.'); + log('Try `he --help` for more information.'); + return process.exit(1); + } + try { + result = he[action](string, options); + log(result); + count++; + } catch(error) { + log(error.message + '\n'); + log('Error: failed to %s.', action); + log('If you think this is a bug in he, please report it:'); + log('https://github.com/mathiasbynens/he/issues/new'); + log( + '\nStack trace using he@%s:\n', + he.version + ); + log(error.stack); + return process.exit(1); + } + }); + if (!count) { + log('Error: he requires a string argument.'); + log('Try `he --help` for more information.'); + return process.exit(1); + } + // Return with exit status 0 outside of the `forEach` loop, in case + // multiple strings were passed in. + return process.exit(0); + }; + + if (stdin.isTTY) { + // handle shell arguments + main(); + } else { + // Either the script is called from within a non-TTY context, or `stdin` + // content is being piped in. + if (!process.stdout.isTTY) { + // The script was called from a non-TTY context. This is a rather uncommon + // use case we don’t actively support. However, we don’t want the script + // to wait forever in such cases, so… + timeout = setTimeout(function() { + // …if no piped data arrived after a whole minute, handle shell + // arguments instead. + main(); + }, 60000); + } + data = ''; + stdin.on('data', function(chunk) { + clearTimeout(timeout); + data += chunk; + }); + stdin.on('end', function() { + strings.push(data.trim()); + main(); + }); + stdin.resume(); + } + +}()); diff --git a/tools/node_modules/he/he.js b/tools/node_modules/he/he.js new file mode 100644 index 00000000000000..74b9fe1870f490 --- /dev/null +++ b/tools/node_modules/he/he.js @@ -0,0 +1,329 @@ +/*! http://mths.be/he v0.5.0 by @mathias | MIT license */ +;(function(root) { + + // Detect free variables `exports`. + var freeExports = typeof exports == 'object' && exports; + + // Detect free variable `module`. + var freeModule = typeof module == 'object' && module && + module.exports == freeExports && module; + + // Detect free variable `global`, from Node.js or Browserified code, + // and use it as `root`. + var freeGlobal = typeof global == 'object' && global; + if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) { + root = freeGlobal; + } + + /*--------------------------------------------------------------------------*/ + + // All astral symbols. + var regexAstralSymbols = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g; + // All ASCII symbols (not just printable ASCII) except those listed in the + // first column of the overrides table. + // http://whatwg.org/html/tokenization.html#table-charref-overrides + var regexAsciiWhitelist = /[\x01-\x7F]/g; + // All BMP symbols that are not ASCII newlines, printable ASCII symbols, or + // code points listed in the first column of the overrides table on + // http://whatwg.org/html/tokenization.html#table-charref-overrides. + var regexBmpWhitelist = /[\x01-\t\x0B\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g; + + var regexEncodeNonAscii = /<\u20D2|=\u20E5|>\u20D2|\u205F\u200A|\u219D\u0338|\u2202\u0338|\u2220\u20D2|\u2229\uFE00|\u222A\uFE00|\u223C\u20D2|\u223D\u0331|\u223E\u0333|\u2242\u0338|\u224B\u0338|\u224D\u20D2|\u224E\u0338|\u224F\u0338|\u2250\u0338|\u2261\u20E5|\u2264\u20D2|\u2265\u20D2|\u2266\u0338|\u2267\u0338|\u2268\uFE00|\u2269\uFE00|\u226A\u0338|\u226A\u20D2|\u226B\u0338|\u226B\u20D2|\u227F\u0338|\u2282\u20D2|\u2283\u20D2|\u228A\uFE00|\u228B\uFE00|\u228F\u0338|\u2290\u0338|\u2293\uFE00|\u2294\uFE00|\u22B4\u20D2|\u22B5\u20D2|\u22D8\u0338|\u22D9\u0338|\u22DA\uFE00|\u22DB\uFE00|\u22F5\u0338|\u22F9\u0338|\u2933\u0338|\u29CF\u0338|\u29D0\u0338|\u2A6D\u0338|\u2A70\u0338|\u2A7D\u0338|\u2A7E\u0338|\u2AA1\u0338|\u2AA2\u0338|\u2AAC\uFE00|\u2AAD\uFE00|\u2AAF\u0338|\u2AB0\u0338|\u2AC5\u0338|\u2AC6\u0338|\u2ACB\uFE00|\u2ACC\uFE00|\u2AFD\u20E5|[\xA0-\u0113\u0116-\u0122\u0124-\u012B\u012E-\u014D\u0150-\u017E\u0192\u01B5\u01F5\u0237\u02C6\u02C7\u02D8-\u02DD\u0311\u0391-\u03A1\u03A3-\u03A9\u03B1-\u03C9\u03D1\u03D2\u03D5\u03D6\u03DC\u03DD\u03F0\u03F1\u03F5\u03F6\u0401-\u040C\u040E-\u044F\u0451-\u045C\u045E\u045F\u2002-\u2005\u2007-\u2010\u2013-\u2016\u2018-\u201A\u201C-\u201E\u2020-\u2022\u2025\u2026\u2030-\u2035\u2039\u203A\u203E\u2041\u2043\u2044\u204F\u2057\u205F-\u2063\u20AC\u20DB\u20DC\u2102\u2105\u210A-\u2113\u2115-\u211E\u2122\u2124\u2127-\u2129\u212C\u212D\u212F-\u2131\u2133-\u2138\u2145-\u2148\u2153-\u215E\u2190-\u219B\u219D-\u21A7\u21A9-\u21AE\u21B0-\u21B3\u21B5-\u21B7\u21BA-\u21DB\u21DD\u21E4\u21E5\u21F5\u21FD-\u2205\u2207-\u2209\u220B\u220C\u220F-\u2214\u2216-\u2218\u221A\u221D-\u2238\u223A-\u2257\u2259\u225A\u225C\u225F-\u2262\u2264-\u228B\u228D-\u229B\u229D-\u22A5\u22A7-\u22B0\u22B2-\u22BB\u22BD-\u22DB\u22DE-\u22E3\u22E6-\u22F7\u22F9-\u22FE\u2305\u2306\u2308-\u2310\u2312\u2313\u2315\u2316\u231C-\u231F\u2322\u2323\u232D\u232E\u2336\u233D\u233F\u237C\u23B0\u23B1\u23B4-\u23B6\u23DC-\u23DF\u23E2\u23E7\u2423\u24C8\u2500\u2502\u250C\u2510\u2514\u2518\u251C\u2524\u252C\u2534\u253C\u2550-\u256C\u2580\u2584\u2588\u2591-\u2593\u25A1\u25AA\u25AB\u25AD\u25AE\u25B1\u25B3-\u25B5\u25B8\u25B9\u25BD-\u25BF\u25C2\u25C3\u25CA\u25CB\u25EC\u25EF\u25F8-\u25FC\u2605\u2606\u260E\u2640\u2642\u2660\u2663\u2665\u2666\u266A\u266D-\u266F\u2713\u2717\u2720\u2736\u2758\u2772\u2773\u27C8\u27C9\u27E6-\u27ED\u27F5-\u27FA\u27FC\u27FF\u2902-\u2905\u290C-\u2913\u2916\u2919-\u2920\u2923-\u292A\u2933\u2935-\u2939\u293C\u293D\u2945\u2948-\u294B\u294E-\u2976\u2978\u2979\u297B-\u297F\u2985\u2986\u298B-\u2996\u299A\u299C\u299D\u29A4-\u29B7\u29B9\u29BB\u29BC\u29BE-\u29C5\u29C9\u29CD-\u29D0\u29DC-\u29DE\u29E3-\u29E5\u29EB\u29F4\u29F6\u2A00-\u2A02\u2A04\u2A06\u2A0C\u2A0D\u2A10-\u2A17\u2A22-\u2A27\u2A29\u2A2A\u2A2D-\u2A31\u2A33-\u2A3C\u2A3F\u2A40\u2A42-\u2A4D\u2A50\u2A53-\u2A58\u2A5A-\u2A5D\u2A5F\u2A66\u2A6A\u2A6D-\u2A75\u2A77-\u2A9A\u2A9D-\u2AA2\u2AA4-\u2AB0\u2AB3-\u2AC8\u2ACB\u2ACC\u2ACF-\u2ADB\u2AE4\u2AE6-\u2AE9\u2AEB-\u2AF3\u2AFD\uFB00-\uFB04]|\uD835[\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDCCF\uDD04\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDD6B]/g; + var encodeMap = {'\xC1':'Aacute','\xE1':'aacute','\u0102':'Abreve','\u0103':'abreve','\u223E':'ac','\u223F':'acd','\u223E\u0333':'acE','\xC2':'Acirc','\xE2':'acirc','\xB4':'acute','\u0410':'Acy','\u0430':'acy','\xC6':'AElig','\xE6':'aelig','\u2061':'af','\uD835\uDD04':'Afr','\uD835\uDD1E':'afr','\xC0':'Agrave','\xE0':'agrave','\u2135':'aleph','\u0391':'Alpha','\u03B1':'alpha','\u0100':'Amacr','\u0101':'amacr','\u2A3F':'amalg','&':'amp','\u2A55':'andand','\u2A53':'And','\u2227':'and','\u2A5C':'andd','\u2A58':'andslope','\u2A5A':'andv','\u2220':'ang','\u29A4':'ange','\u29A8':'angmsdaa','\u29A9':'angmsdab','\u29AA':'angmsdac','\u29AB':'angmsdad','\u29AC':'angmsdae','\u29AD':'angmsdaf','\u29AE':'angmsdag','\u29AF':'angmsdah','\u2221':'angmsd','\u221F':'angrt','\u22BE':'angrtvb','\u299D':'angrtvbd','\u2222':'angsph','\xC5':'angst','\u237C':'angzarr','\u0104':'Aogon','\u0105':'aogon','\uD835\uDD38':'Aopf','\uD835\uDD52':'aopf','\u2A6F':'apacir','\u2248':'ap','\u2A70':'apE','\u224A':'ape','\u224B':'apid','\'':'apos','\xE5':'aring','\uD835\uDC9C':'Ascr','\uD835\uDCB6':'ascr','\u2254':'colone','*':'ast','\u224D':'CupCap','\xC3':'Atilde','\xE3':'atilde','\xC4':'Auml','\xE4':'auml','\u2233':'awconint','\u2A11':'awint','\u224C':'bcong','\u03F6':'bepsi','\u2035':'bprime','\u223D':'bsim','\u22CD':'bsime','\u2216':'setmn','\u2AE7':'Barv','\u22BD':'barvee','\u2305':'barwed','\u2306':'Barwed','\u23B5':'bbrk','\u23B6':'bbrktbrk','\u0411':'Bcy','\u0431':'bcy','\u201E':'bdquo','\u2235':'becaus','\u29B0':'bemptyv','\u212C':'Bscr','\u0392':'Beta','\u03B2':'beta','\u2136':'beth','\u226C':'twixt','\uD835\uDD05':'Bfr','\uD835\uDD1F':'bfr','\u22C2':'xcap','\u25EF':'xcirc','\u22C3':'xcup','\u2A00':'xodot','\u2A01':'xoplus','\u2A02':'xotime','\u2A06':'xsqcup','\u2605':'starf','\u25BD':'xdtri','\u25B3':'xutri','\u2A04':'xuplus','\u22C1':'Vee','\u22C0':'Wedge','\u290D':'rbarr','\u29EB':'lozf','\u25AA':'squf','\u25B4':'utrif','\u25BE':'dtrif','\u25C2':'ltrif','\u25B8':'rtrif','\u2423':'blank','\u2592':'blk12','\u2591':'blk14','\u2593':'blk34','\u2588':'block','=\u20E5':'bne','\u2261\u20E5':'bnequiv','\u2AED':'bNot','\u2310':'bnot','\uD835\uDD39':'Bopf','\uD835\uDD53':'bopf','\u22A5':'bot','\u22C8':'bowtie','\u29C9':'boxbox','\u2510':'boxdl','\u2555':'boxdL','\u2556':'boxDl','\u2557':'boxDL','\u250C':'boxdr','\u2552':'boxdR','\u2553':'boxDr','\u2554':'boxDR','\u2500':'boxh','\u2550':'boxH','\u252C':'boxhd','\u2564':'boxHd','\u2565':'boxhD','\u2566':'boxHD','\u2534':'boxhu','\u2567':'boxHu','\u2568':'boxhU','\u2569':'boxHU','\u229F':'minusb','\u229E':'plusb','\u22A0':'timesb','\u2518':'boxul','\u255B':'boxuL','\u255C':'boxUl','\u255D':'boxUL','\u2514':'boxur','\u2558':'boxuR','\u2559':'boxUr','\u255A':'boxUR','\u2502':'boxv','\u2551':'boxV','\u253C':'boxvh','\u256A':'boxvH','\u256B':'boxVh','\u256C':'boxVH','\u2524':'boxvl','\u2561':'boxvL','\u2562':'boxVl','\u2563':'boxVL','\u251C':'boxvr','\u255E':'boxvR','\u255F':'boxVr','\u2560':'boxVR','\u02D8':'breve','\xA6':'brvbar','\uD835\uDCB7':'bscr','\u204F':'bsemi','\u29C5':'bsolb','\\':'bsol','\u27C8':'bsolhsub','\u2022':'bull','\u224E':'bump','\u2AAE':'bumpE','\u224F':'bumpe','\u0106':'Cacute','\u0107':'cacute','\u2A44':'capand','\u2A49':'capbrcup','\u2A4B':'capcap','\u2229':'cap','\u22D2':'Cap','\u2A47':'capcup','\u2A40':'capdot','\u2145':'DD','\u2229\uFE00':'caps','\u2041':'caret','\u02C7':'caron','\u212D':'Cfr','\u2A4D':'ccaps','\u010C':'Ccaron','\u010D':'ccaron','\xC7':'Ccedil','\xE7':'ccedil','\u0108':'Ccirc','\u0109':'ccirc','\u2230':'Cconint','\u2A4C':'ccups','\u2A50':'ccupssm','\u010A':'Cdot','\u010B':'cdot','\xB8':'cedil','\u29B2':'cemptyv','\xA2':'cent','\xB7':'middot','\uD835\uDD20':'cfr','\u0427':'CHcy','\u0447':'chcy','\u2713':'check','\u03A7':'Chi','\u03C7':'chi','\u02C6':'circ','\u2257':'cire','\u21BA':'olarr','\u21BB':'orarr','\u229B':'oast','\u229A':'ocir','\u229D':'odash','\u2299':'odot','\xAE':'reg','\u24C8':'oS','\u2296':'ominus','\u2295':'oplus','\u2297':'otimes','\u25CB':'cir','\u29C3':'cirE','\u2A10':'cirfnint','\u2AEF':'cirmid','\u29C2':'cirscir','\u2232':'cwconint','\u201D':'rdquo','\u2019':'rsquo','\u2663':'clubs',':':'colon','\u2237':'Colon','\u2A74':'Colone',',':'comma','@':'commat','\u2201':'comp','\u2218':'compfn','\u2102':'Copf','\u2245':'cong','\u2A6D':'congdot','\u2261':'equiv','\u222E':'oint','\u222F':'Conint','\uD835\uDD54':'copf','\u2210':'coprod','\xA9':'copy','\u2117':'copysr','\u21B5':'crarr','\u2717':'cross','\u2A2F':'Cross','\uD835\uDC9E':'Cscr','\uD835\uDCB8':'cscr','\u2ACF':'csub','\u2AD1':'csube','\u2AD0':'csup','\u2AD2':'csupe','\u22EF':'ctdot','\u2938':'cudarrl','\u2935':'cudarrr','\u22DE':'cuepr','\u22DF':'cuesc','\u21B6':'cularr','\u293D':'cularrp','\u2A48':'cupbrcap','\u2A46':'cupcap','\u222A':'cup','\u22D3':'Cup','\u2A4A':'cupcup','\u228D':'cupdot','\u2A45':'cupor','\u222A\uFE00':'cups','\u21B7':'curarr','\u293C':'curarrm','\u22CE':'cuvee','\u22CF':'cuwed','\xA4':'curren','\u2231':'cwint','\u232D':'cylcty','\u2020':'dagger','\u2021':'Dagger','\u2138':'daleth','\u2193':'darr','\u21A1':'Darr','\u21D3':'dArr','\u2010':'dash','\u2AE4':'Dashv','\u22A3':'dashv','\u290F':'rBarr','\u02DD':'dblac','\u010E':'Dcaron','\u010F':'dcaron','\u0414':'Dcy','\u0434':'dcy','\u21CA':'ddarr','\u2146':'dd','\u2911':'DDotrahd','\u2A77':'eDDot','\xB0':'deg','\u2207':'Del','\u0394':'Delta','\u03B4':'delta','\u29B1':'demptyv','\u297F':'dfisht','\uD835\uDD07':'Dfr','\uD835\uDD21':'dfr','\u2965':'dHar','\u21C3':'dharl','\u21C2':'dharr','\u02D9':'dot','`':'grave','\u02DC':'tilde','\u22C4':'diam','\u2666':'diams','\xA8':'die','\u03DD':'gammad','\u22F2':'disin','\xF7':'div','\u22C7':'divonx','\u0402':'DJcy','\u0452':'djcy','\u231E':'dlcorn','\u230D':'dlcrop','$':'dollar','\uD835\uDD3B':'Dopf','\uD835\uDD55':'dopf','\u20DC':'DotDot','\u2250':'doteq','\u2251':'eDot','\u2238':'minusd','\u2214':'plusdo','\u22A1':'sdotb','\u21D0':'lArr','\u21D4':'iff','\u27F8':'xlArr','\u27FA':'xhArr','\u27F9':'xrArr','\u21D2':'rArr','\u22A8':'vDash','\u21D1':'uArr','\u21D5':'vArr','\u2225':'par','\u2913':'DownArrowBar','\u21F5':'duarr','\u0311':'DownBreve','\u2950':'DownLeftRightVector','\u295E':'DownLeftTeeVector','\u2956':'DownLeftVectorBar','\u21BD':'lhard','\u295F':'DownRightTeeVector','\u2957':'DownRightVectorBar','\u21C1':'rhard','\u21A7':'mapstodown','\u22A4':'top','\u2910':'RBarr','\u231F':'drcorn','\u230C':'drcrop','\uD835\uDC9F':'Dscr','\uD835\uDCB9':'dscr','\u0405':'DScy','\u0455':'dscy','\u29F6':'dsol','\u0110':'Dstrok','\u0111':'dstrok','\u22F1':'dtdot','\u25BF':'dtri','\u296F':'duhar','\u29A6':'dwangle','\u040F':'DZcy','\u045F':'dzcy','\u27FF':'dzigrarr','\xC9':'Eacute','\xE9':'eacute','\u2A6E':'easter','\u011A':'Ecaron','\u011B':'ecaron','\xCA':'Ecirc','\xEA':'ecirc','\u2256':'ecir','\u2255':'ecolon','\u042D':'Ecy','\u044D':'ecy','\u0116':'Edot','\u0117':'edot','\u2147':'ee','\u2252':'efDot','\uD835\uDD08':'Efr','\uD835\uDD22':'efr','\u2A9A':'eg','\xC8':'Egrave','\xE8':'egrave','\u2A96':'egs','\u2A98':'egsdot','\u2A99':'el','\u2208':'in','\u23E7':'elinters','\u2113':'ell','\u2A95':'els','\u2A97':'elsdot','\u0112':'Emacr','\u0113':'emacr','\u2205':'empty','\u25FB':'EmptySmallSquare','\u25AB':'EmptyVerySmallSquare','\u2004':'emsp13','\u2005':'emsp14','\u2003':'emsp','\u014A':'ENG','\u014B':'eng','\u2002':'ensp','\u0118':'Eogon','\u0119':'eogon','\uD835\uDD3C':'Eopf','\uD835\uDD56':'eopf','\u22D5':'epar','\u29E3':'eparsl','\u2A71':'eplus','\u03B5':'epsi','\u0395':'Epsilon','\u03F5':'epsiv','\u2242':'esim','\u2A75':'Equal','=':'equals','\u225F':'equest','\u21CC':'rlhar','\u2A78':'equivDD','\u29E5':'eqvparsl','\u2971':'erarr','\u2253':'erDot','\u212F':'escr','\u2130':'Escr','\u2A73':'Esim','\u0397':'Eta','\u03B7':'eta','\xD0':'ETH','\xF0':'eth','\xCB':'Euml','\xEB':'euml','\u20AC':'euro','!':'excl','\u2203':'exist','\u0424':'Fcy','\u0444':'fcy','\u2640':'female','\uFB03':'ffilig','\uFB00':'fflig','\uFB04':'ffllig','\uD835\uDD09':'Ffr','\uD835\uDD23':'ffr','\uFB01':'filig','\u25FC':'FilledSmallSquare','fj':'fjlig','\u266D':'flat','\uFB02':'fllig','\u25B1':'fltns','\u0192':'fnof','\uD835\uDD3D':'Fopf','\uD835\uDD57':'fopf','\u2200':'forall','\u22D4':'fork','\u2AD9':'forkv','\u2131':'Fscr','\u2A0D':'fpartint','\xBD':'half','\u2153':'frac13','\xBC':'frac14','\u2155':'frac15','\u2159':'frac16','\u215B':'frac18','\u2154':'frac23','\u2156':'frac25','\xBE':'frac34','\u2157':'frac35','\u215C':'frac38','\u2158':'frac45','\u215A':'frac56','\u215D':'frac58','\u215E':'frac78','\u2044':'frasl','\u2322':'frown','\uD835\uDCBB':'fscr','\u01F5':'gacute','\u0393':'Gamma','\u03B3':'gamma','\u03DC':'Gammad','\u2A86':'gap','\u011E':'Gbreve','\u011F':'gbreve','\u0122':'Gcedil','\u011C':'Gcirc','\u011D':'gcirc','\u0413':'Gcy','\u0433':'gcy','\u0120':'Gdot','\u0121':'gdot','\u2265':'ge','\u2267':'gE','\u2A8C':'gEl','\u22DB':'gel','\u2A7E':'ges','\u2AA9':'gescc','\u2A80':'gesdot','\u2A82':'gesdoto','\u2A84':'gesdotol','\u22DB\uFE00':'gesl','\u2A94':'gesles','\uD835\uDD0A':'Gfr','\uD835\uDD24':'gfr','\u226B':'gg','\u22D9':'Gg','\u2137':'gimel','\u0403':'GJcy','\u0453':'gjcy','\u2AA5':'gla','\u2277':'gl','\u2A92':'glE','\u2AA4':'glj','\u2A8A':'gnap','\u2A88':'gne','\u2269':'gnE','\u22E7':'gnsim','\uD835\uDD3E':'Gopf','\uD835\uDD58':'gopf','\u2AA2':'GreaterGreater','\u2273':'gsim','\uD835\uDCA2':'Gscr','\u210A':'gscr','\u2A8E':'gsime','\u2A90':'gsiml','\u2AA7':'gtcc','\u2A7A':'gtcir','>':'gt','\u22D7':'gtdot','\u2995':'gtlPar','\u2A7C':'gtquest','\u2978':'gtrarr','\u2269\uFE00':'gvnE','\u200A':'hairsp','\u210B':'Hscr','\u042A':'HARDcy','\u044A':'hardcy','\u2948':'harrcir','\u2194':'harr','\u21AD':'harrw','^':'Hat','\u210F':'hbar','\u0124':'Hcirc','\u0125':'hcirc','\u2665':'hearts','\u2026':'mldr','\u22B9':'hercon','\uD835\uDD25':'hfr','\u210C':'Hfr','\u2925':'searhk','\u2926':'swarhk','\u21FF':'hoarr','\u223B':'homtht','\u21A9':'larrhk','\u21AA':'rarrhk','\uD835\uDD59':'hopf','\u210D':'Hopf','\u2015':'horbar','\uD835\uDCBD':'hscr','\u0126':'Hstrok','\u0127':'hstrok','\u2043':'hybull','\xCD':'Iacute','\xED':'iacute','\u2063':'ic','\xCE':'Icirc','\xEE':'icirc','\u0418':'Icy','\u0438':'icy','\u0130':'Idot','\u0415':'IEcy','\u0435':'iecy','\xA1':'iexcl','\uD835\uDD26':'ifr','\u2111':'Im','\xCC':'Igrave','\xEC':'igrave','\u2148':'ii','\u2A0C':'qint','\u222D':'tint','\u29DC':'iinfin','\u2129':'iiota','\u0132':'IJlig','\u0133':'ijlig','\u012A':'Imacr','\u012B':'imacr','\u2110':'Iscr','\u0131':'imath','\u22B7':'imof','\u01B5':'imped','\u2105':'incare','\u221E':'infin','\u29DD':'infintie','\u22BA':'intcal','\u222B':'int','\u222C':'Int','\u2124':'Zopf','\u2A17':'intlarhk','\u2A3C':'iprod','\u2062':'it','\u0401':'IOcy','\u0451':'iocy','\u012E':'Iogon','\u012F':'iogon','\uD835\uDD40':'Iopf','\uD835\uDD5A':'iopf','\u0399':'Iota','\u03B9':'iota','\xBF':'iquest','\uD835\uDCBE':'iscr','\u22F5':'isindot','\u22F9':'isinE','\u22F4':'isins','\u22F3':'isinsv','\u0128':'Itilde','\u0129':'itilde','\u0406':'Iukcy','\u0456':'iukcy','\xCF':'Iuml','\xEF':'iuml','\u0134':'Jcirc','\u0135':'jcirc','\u0419':'Jcy','\u0439':'jcy','\uD835\uDD0D':'Jfr','\uD835\uDD27':'jfr','\u0237':'jmath','\uD835\uDD41':'Jopf','\uD835\uDD5B':'jopf','\uD835\uDCA5':'Jscr','\uD835\uDCBF':'jscr','\u0408':'Jsercy','\u0458':'jsercy','\u0404':'Jukcy','\u0454':'jukcy','\u039A':'Kappa','\u03BA':'kappa','\u03F0':'kappav','\u0136':'Kcedil','\u0137':'kcedil','\u041A':'Kcy','\u043A':'kcy','\uD835\uDD0E':'Kfr','\uD835\uDD28':'kfr','\u0138':'kgreen','\u0425':'KHcy','\u0445':'khcy','\u040C':'KJcy','\u045C':'kjcy','\uD835\uDD42':'Kopf','\uD835\uDD5C':'kopf','\uD835\uDCA6':'Kscr','\uD835\uDCC0':'kscr','\u21DA':'lAarr','\u0139':'Lacute','\u013A':'lacute','\u29B4':'laemptyv','\u2112':'Lscr','\u039B':'Lambda','\u03BB':'lambda','\u27E8':'lang','\u27EA':'Lang','\u2991':'langd','\u2A85':'lap','\xAB':'laquo','\u21E4':'larrb','\u291F':'larrbfs','\u2190':'larr','\u219E':'Larr','\u291D':'larrfs','\u21AB':'larrlp','\u2939':'larrpl','\u2973':'larrsim','\u21A2':'larrtl','\u2919':'latail','\u291B':'lAtail','\u2AAB':'lat','\u2AAD':'late','\u2AAD\uFE00':'lates','\u290C':'lbarr','\u290E':'lBarr','\u2772':'lbbrk','{':'lcub','[':'lsqb','\u298B':'lbrke','\u298F':'lbrksld','\u298D':'lbrkslu','\u013D':'Lcaron','\u013E':'lcaron','\u013B':'Lcedil','\u013C':'lcedil','\u2308':'lceil','\u041B':'Lcy','\u043B':'lcy','\u2936':'ldca','\u201C':'ldquo','\u2967':'ldrdhar','\u294B':'ldrushar','\u21B2':'ldsh','\u2264':'le','\u2266':'lE','\u21C6':'lrarr','\u27E6':'lobrk','\u2961':'LeftDownTeeVector','\u2959':'LeftDownVectorBar','\u230A':'lfloor','\u21BC':'lharu','\u21C7':'llarr','\u21CB':'lrhar','\u294E':'LeftRightVector','\u21A4':'mapstoleft','\u295A':'LeftTeeVector','\u22CB':'lthree','\u29CF':'LeftTriangleBar','\u22B2':'vltri','\u22B4':'ltrie','\u2951':'LeftUpDownVector','\u2960':'LeftUpTeeVector','\u2958':'LeftUpVectorBar','\u21BF':'uharl','\u2952':'LeftVectorBar','\u2A8B':'lEg','\u22DA':'leg','\u2A7D':'les','\u2AA8':'lescc','\u2A7F':'lesdot','\u2A81':'lesdoto','\u2A83':'lesdotor','\u22DA\uFE00':'lesg','\u2A93':'lesges','\u22D6':'ltdot','\u2276':'lg','\u2AA1':'LessLess','\u2272':'lsim','\u297C':'lfisht','\uD835\uDD0F':'Lfr','\uD835\uDD29':'lfr','\u2A91':'lgE','\u2962':'lHar','\u296A':'lharul','\u2584':'lhblk','\u0409':'LJcy','\u0459':'ljcy','\u226A':'ll','\u22D8':'Ll','\u296B':'llhard','\u25FA':'lltri','\u013F':'Lmidot','\u0140':'lmidot','\u23B0':'lmoust','\u2A89':'lnap','\u2A87':'lne','\u2268':'lnE','\u22E6':'lnsim','\u27EC':'loang','\u21FD':'loarr','\u27F5':'xlarr','\u27F7':'xharr','\u27FC':'xmap','\u27F6':'xrarr','\u21AC':'rarrlp','\u2985':'lopar','\uD835\uDD43':'Lopf','\uD835\uDD5D':'lopf','\u2A2D':'loplus','\u2A34':'lotimes','\u2217':'lowast','_':'lowbar','\u2199':'swarr','\u2198':'searr','\u25CA':'loz','(':'lpar','\u2993':'lparlt','\u296D':'lrhard','\u200E':'lrm','\u22BF':'lrtri','\u2039':'lsaquo','\uD835\uDCC1':'lscr','\u21B0':'lsh','\u2A8D':'lsime','\u2A8F':'lsimg','\u2018':'lsquo','\u201A':'sbquo','\u0141':'Lstrok','\u0142':'lstrok','\u2AA6':'ltcc','\u2A79':'ltcir','<':'lt','\u22C9':'ltimes','\u2976':'ltlarr','\u2A7B':'ltquest','\u25C3':'ltri','\u2996':'ltrPar','\u294A':'lurdshar','\u2966':'luruhar','\u2268\uFE00':'lvnE','\xAF':'macr','\u2642':'male','\u2720':'malt','\u2905':'Map','\u21A6':'map','\u21A5':'mapstoup','\u25AE':'marker','\u2A29':'mcomma','\u041C':'Mcy','\u043C':'mcy','\u2014':'mdash','\u223A':'mDDot','\u205F':'MediumSpace','\u2133':'Mscr','\uD835\uDD10':'Mfr','\uD835\uDD2A':'mfr','\u2127':'mho','\xB5':'micro','\u2AF0':'midcir','\u2223':'mid','\u2212':'minus','\u2A2A':'minusdu','\u2213':'mp','\u2ADB':'mlcp','\u22A7':'models','\uD835\uDD44':'Mopf','\uD835\uDD5E':'mopf','\uD835\uDCC2':'mscr','\u039C':'Mu','\u03BC':'mu','\u22B8':'mumap','\u0143':'Nacute','\u0144':'nacute','\u2220\u20D2':'nang','\u2249':'nap','\u2A70\u0338':'napE','\u224B\u0338':'napid','\u0149':'napos','\u266E':'natur','\u2115':'Nopf','\xA0':'nbsp','\u224E\u0338':'nbump','\u224F\u0338':'nbumpe','\u2A43':'ncap','\u0147':'Ncaron','\u0148':'ncaron','\u0145':'Ncedil','\u0146':'ncedil','\u2247':'ncong','\u2A6D\u0338':'ncongdot','\u2A42':'ncup','\u041D':'Ncy','\u043D':'ncy','\u2013':'ndash','\u2924':'nearhk','\u2197':'nearr','\u21D7':'neArr','\u2260':'ne','\u2250\u0338':'nedot','\u200B':'ZeroWidthSpace','\u2262':'nequiv','\u2928':'toea','\u2242\u0338':'nesim','\n':'NewLine','\u2204':'nexist','\uD835\uDD11':'Nfr','\uD835\uDD2B':'nfr','\u2267\u0338':'ngE','\u2271':'nge','\u2A7E\u0338':'nges','\u22D9\u0338':'nGg','\u2275':'ngsim','\u226B\u20D2':'nGt','\u226F':'ngt','\u226B\u0338':'nGtv','\u21AE':'nharr','\u21CE':'nhArr','\u2AF2':'nhpar','\u220B':'ni','\u22FC':'nis','\u22FA':'nisd','\u040A':'NJcy','\u045A':'njcy','\u219A':'nlarr','\u21CD':'nlArr','\u2025':'nldr','\u2266\u0338':'nlE','\u2270':'nle','\u2A7D\u0338':'nles','\u226E':'nlt','\u22D8\u0338':'nLl','\u2274':'nlsim','\u226A\u20D2':'nLt','\u22EA':'nltri','\u22EC':'nltrie','\u226A\u0338':'nLtv','\u2224':'nmid','\u2060':'NoBreak','\uD835\uDD5F':'nopf','\u2AEC':'Not','\xAC':'not','\u226D':'NotCupCap','\u2226':'npar','\u2209':'notin','\u2279':'ntgl','\u22F5\u0338':'notindot','\u22F9\u0338':'notinE','\u22F7':'notinvb','\u22F6':'notinvc','\u29CF\u0338':'NotLeftTriangleBar','\u2278':'ntlg','\u2AA2\u0338':'NotNestedGreaterGreater','\u2AA1\u0338':'NotNestedLessLess','\u220C':'notni','\u22FE':'notnivb','\u22FD':'notnivc','\u2280':'npr','\u2AAF\u0338':'npre','\u22E0':'nprcue','\u29D0\u0338':'NotRightTriangleBar','\u22EB':'nrtri','\u22ED':'nrtrie','\u228F\u0338':'NotSquareSubset','\u22E2':'nsqsube','\u2290\u0338':'NotSquareSuperset','\u22E3':'nsqsupe','\u2282\u20D2':'vnsub','\u2288':'nsube','\u2281':'nsc','\u2AB0\u0338':'nsce','\u22E1':'nsccue','\u227F\u0338':'NotSucceedsTilde','\u2283\u20D2':'vnsup','\u2289':'nsupe','\u2241':'nsim','\u2244':'nsime','\u2AFD\u20E5':'nparsl','\u2202\u0338':'npart','\u2A14':'npolint','\u2933\u0338':'nrarrc','\u219B':'nrarr','\u21CF':'nrArr','\u219D\u0338':'nrarrw','\uD835\uDCA9':'Nscr','\uD835\uDCC3':'nscr','\u2284':'nsub','\u2AC5\u0338':'nsubE','\u2285':'nsup','\u2AC6\u0338':'nsupE','\xD1':'Ntilde','\xF1':'ntilde','\u039D':'Nu','\u03BD':'nu','#':'num','\u2116':'numero','\u2007':'numsp','\u224D\u20D2':'nvap','\u22AC':'nvdash','\u22AD':'nvDash','\u22AE':'nVdash','\u22AF':'nVDash','\u2265\u20D2':'nvge','>\u20D2':'nvgt','\u2904':'nvHarr','\u29DE':'nvinfin','\u2902':'nvlArr','\u2264\u20D2':'nvle','<\u20D2':'nvlt','\u22B4\u20D2':'nvltrie','\u2903':'nvrArr','\u22B5\u20D2':'nvrtrie','\u223C\u20D2':'nvsim','\u2923':'nwarhk','\u2196':'nwarr','\u21D6':'nwArr','\u2927':'nwnear','\xD3':'Oacute','\xF3':'oacute','\xD4':'Ocirc','\xF4':'ocirc','\u041E':'Ocy','\u043E':'ocy','\u0150':'Odblac','\u0151':'odblac','\u2A38':'odiv','\u29BC':'odsold','\u0152':'OElig','\u0153':'oelig','\u29BF':'ofcir','\uD835\uDD12':'Ofr','\uD835\uDD2C':'ofr','\u02DB':'ogon','\xD2':'Ograve','\xF2':'ograve','\u29C1':'ogt','\u29B5':'ohbar','\u03A9':'ohm','\u29BE':'olcir','\u29BB':'olcross','\u203E':'oline','\u29C0':'olt','\u014C':'Omacr','\u014D':'omacr','\u03C9':'omega','\u039F':'Omicron','\u03BF':'omicron','\u29B6':'omid','\uD835\uDD46':'Oopf','\uD835\uDD60':'oopf','\u29B7':'opar','\u29B9':'operp','\u2A54':'Or','\u2228':'or','\u2A5D':'ord','\u2134':'oscr','\xAA':'ordf','\xBA':'ordm','\u22B6':'origof','\u2A56':'oror','\u2A57':'orslope','\u2A5B':'orv','\uD835\uDCAA':'Oscr','\xD8':'Oslash','\xF8':'oslash','\u2298':'osol','\xD5':'Otilde','\xF5':'otilde','\u2A36':'otimesas','\u2A37':'Otimes','\xD6':'Ouml','\xF6':'ouml','\u233D':'ovbar','\u23DE':'OverBrace','\u23B4':'tbrk','\u23DC':'OverParenthesis','\xB6':'para','\u2AF3':'parsim','\u2AFD':'parsl','\u2202':'part','\u041F':'Pcy','\u043F':'pcy','%':'percnt','.':'period','\u2030':'permil','\u2031':'pertenk','\uD835\uDD13':'Pfr','\uD835\uDD2D':'pfr','\u03A6':'Phi','\u03C6':'phi','\u03D5':'phiv','\u260E':'phone','\u03A0':'Pi','\u03C0':'pi','\u03D6':'piv','\u210E':'planckh','\u2A23':'plusacir','\u2A22':'pluscir','+':'plus','\u2A25':'plusdu','\u2A72':'pluse','\xB1':'pm','\u2A26':'plussim','\u2A27':'plustwo','\u2A15':'pointint','\uD835\uDD61':'popf','\u2119':'Popf','\xA3':'pound','\u2AB7':'prap','\u2ABB':'Pr','\u227A':'pr','\u227C':'prcue','\u2AAF':'pre','\u227E':'prsim','\u2AB9':'prnap','\u2AB5':'prnE','\u22E8':'prnsim','\u2AB3':'prE','\u2032':'prime','\u2033':'Prime','\u220F':'prod','\u232E':'profalar','\u2312':'profline','\u2313':'profsurf','\u221D':'prop','\u22B0':'prurel','\uD835\uDCAB':'Pscr','\uD835\uDCC5':'pscr','\u03A8':'Psi','\u03C8':'psi','\u2008':'puncsp','\uD835\uDD14':'Qfr','\uD835\uDD2E':'qfr','\uD835\uDD62':'qopf','\u211A':'Qopf','\u2057':'qprime','\uD835\uDCAC':'Qscr','\uD835\uDCC6':'qscr','\u2A16':'quatint','?':'quest','"':'quot','\u21DB':'rAarr','\u223D\u0331':'race','\u0154':'Racute','\u0155':'racute','\u221A':'Sqrt','\u29B3':'raemptyv','\u27E9':'rang','\u27EB':'Rang','\u2992':'rangd','\u29A5':'range','\xBB':'raquo','\u2975':'rarrap','\u21E5':'rarrb','\u2920':'rarrbfs','\u2933':'rarrc','\u2192':'rarr','\u21A0':'Rarr','\u291E':'rarrfs','\u2945':'rarrpl','\u2974':'rarrsim','\u2916':'Rarrtl','\u21A3':'rarrtl','\u219D':'rarrw','\u291A':'ratail','\u291C':'rAtail','\u2236':'ratio','\u2773':'rbbrk','}':'rcub',']':'rsqb','\u298C':'rbrke','\u298E':'rbrksld','\u2990':'rbrkslu','\u0158':'Rcaron','\u0159':'rcaron','\u0156':'Rcedil','\u0157':'rcedil','\u2309':'rceil','\u0420':'Rcy','\u0440':'rcy','\u2937':'rdca','\u2969':'rdldhar','\u21B3':'rdsh','\u211C':'Re','\u211B':'Rscr','\u211D':'Ropf','\u25AD':'rect','\u297D':'rfisht','\u230B':'rfloor','\uD835\uDD2F':'rfr','\u2964':'rHar','\u21C0':'rharu','\u296C':'rharul','\u03A1':'Rho','\u03C1':'rho','\u03F1':'rhov','\u21C4':'rlarr','\u27E7':'robrk','\u295D':'RightDownTeeVector','\u2955':'RightDownVectorBar','\u21C9':'rrarr','\u22A2':'vdash','\u295B':'RightTeeVector','\u22CC':'rthree','\u29D0':'RightTriangleBar','\u22B3':'vrtri','\u22B5':'rtrie','\u294F':'RightUpDownVector','\u295C':'RightUpTeeVector','\u2954':'RightUpVectorBar','\u21BE':'uharr','\u2953':'RightVectorBar','\u02DA':'ring','\u200F':'rlm','\u23B1':'rmoust','\u2AEE':'rnmid','\u27ED':'roang','\u21FE':'roarr','\u2986':'ropar','\uD835\uDD63':'ropf','\u2A2E':'roplus','\u2A35':'rotimes','\u2970':'RoundImplies',')':'rpar','\u2994':'rpargt','\u2A12':'rppolint','\u203A':'rsaquo','\uD835\uDCC7':'rscr','\u21B1':'rsh','\u22CA':'rtimes','\u25B9':'rtri','\u29CE':'rtriltri','\u29F4':'RuleDelayed','\u2968':'ruluhar','\u211E':'rx','\u015A':'Sacute','\u015B':'sacute','\u2AB8':'scap','\u0160':'Scaron','\u0161':'scaron','\u2ABC':'Sc','\u227B':'sc','\u227D':'sccue','\u2AB0':'sce','\u2AB4':'scE','\u015E':'Scedil','\u015F':'scedil','\u015C':'Scirc','\u015D':'scirc','\u2ABA':'scnap','\u2AB6':'scnE','\u22E9':'scnsim','\u2A13':'scpolint','\u227F':'scsim','\u0421':'Scy','\u0441':'scy','\u22C5':'sdot','\u2A66':'sdote','\u21D8':'seArr','\xA7':'sect',';':'semi','\u2929':'tosa','\u2736':'sext','\uD835\uDD16':'Sfr','\uD835\uDD30':'sfr','\u266F':'sharp','\u0429':'SHCHcy','\u0449':'shchcy','\u0428':'SHcy','\u0448':'shcy','\u2191':'uarr','\xAD':'shy','\u03A3':'Sigma','\u03C3':'sigma','\u03C2':'sigmaf','\u223C':'sim','\u2A6A':'simdot','\u2243':'sime','\u2A9E':'simg','\u2AA0':'simgE','\u2A9D':'siml','\u2A9F':'simlE','\u2246':'simne','\u2A24':'simplus','\u2972':'simrarr','\u2A33':'smashp','\u29E4':'smeparsl','\u2323':'smile','\u2AAA':'smt','\u2AAC':'smte','\u2AAC\uFE00':'smtes','\u042C':'SOFTcy','\u044C':'softcy','\u233F':'solbar','\u29C4':'solb','/':'sol','\uD835\uDD4A':'Sopf','\uD835\uDD64':'sopf','\u2660':'spades','\u2293':'sqcap','\u2293\uFE00':'sqcaps','\u2294':'sqcup','\u2294\uFE00':'sqcups','\u228F':'sqsub','\u2291':'sqsube','\u2290':'sqsup','\u2292':'sqsupe','\u25A1':'squ','\uD835\uDCAE':'Sscr','\uD835\uDCC8':'sscr','\u22C6':'Star','\u2606':'star','\u2282':'sub','\u22D0':'Sub','\u2ABD':'subdot','\u2AC5':'subE','\u2286':'sube','\u2AC3':'subedot','\u2AC1':'submult','\u2ACB':'subnE','\u228A':'subne','\u2ABF':'subplus','\u2979':'subrarr','\u2AC7':'subsim','\u2AD5':'subsub','\u2AD3':'subsup','\u2211':'sum','\u266A':'sung','\xB9':'sup1','\xB2':'sup2','\xB3':'sup3','\u2283':'sup','\u22D1':'Sup','\u2ABE':'supdot','\u2AD8':'supdsub','\u2AC6':'supE','\u2287':'supe','\u2AC4':'supedot','\u27C9':'suphsol','\u2AD7':'suphsub','\u297B':'suplarr','\u2AC2':'supmult','\u2ACC':'supnE','\u228B':'supne','\u2AC0':'supplus','\u2AC8':'supsim','\u2AD4':'supsub','\u2AD6':'supsup','\u21D9':'swArr','\u292A':'swnwar','\xDF':'szlig','\t':'Tab','\u2316':'target','\u03A4':'Tau','\u03C4':'tau','\u0164':'Tcaron','\u0165':'tcaron','\u0162':'Tcedil','\u0163':'tcedil','\u0422':'Tcy','\u0442':'tcy','\u20DB':'tdot','\u2315':'telrec','\uD835\uDD17':'Tfr','\uD835\uDD31':'tfr','\u2234':'there4','\u0398':'Theta','\u03B8':'theta','\u03D1':'thetav','\u205F\u200A':'ThickSpace','\u2009':'thinsp','\xDE':'THORN','\xFE':'thorn','\u2A31':'timesbar','\xD7':'times','\u2A30':'timesd','\u2336':'topbot','\u2AF1':'topcir','\uD835\uDD4B':'Topf','\uD835\uDD65':'topf','\u2ADA':'topfork','\u2034':'tprime','\u2122':'trade','\u25B5':'utri','\u225C':'trie','\u25EC':'tridot','\u2A3A':'triminus','\u2A39':'triplus','\u29CD':'trisb','\u2A3B':'tritime','\u23E2':'trpezium','\uD835\uDCAF':'Tscr','\uD835\uDCC9':'tscr','\u0426':'TScy','\u0446':'tscy','\u040B':'TSHcy','\u045B':'tshcy','\u0166':'Tstrok','\u0167':'tstrok','\xDA':'Uacute','\xFA':'uacute','\u219F':'Uarr','\u2949':'Uarrocir','\u040E':'Ubrcy','\u045E':'ubrcy','\u016C':'Ubreve','\u016D':'ubreve','\xDB':'Ucirc','\xFB':'ucirc','\u0423':'Ucy','\u0443':'ucy','\u21C5':'udarr','\u0170':'Udblac','\u0171':'udblac','\u296E':'udhar','\u297E':'ufisht','\uD835\uDD18':'Ufr','\uD835\uDD32':'ufr','\xD9':'Ugrave','\xF9':'ugrave','\u2963':'uHar','\u2580':'uhblk','\u231C':'ulcorn','\u230F':'ulcrop','\u25F8':'ultri','\u016A':'Umacr','\u016B':'umacr','\u23DF':'UnderBrace','\u23DD':'UnderParenthesis','\u228E':'uplus','\u0172':'Uogon','\u0173':'uogon','\uD835\uDD4C':'Uopf','\uD835\uDD66':'uopf','\u2912':'UpArrowBar','\u2195':'varr','\u03C5':'upsi','\u03D2':'Upsi','\u03A5':'Upsilon','\u21C8':'uuarr','\u231D':'urcorn','\u230E':'urcrop','\u016E':'Uring','\u016F':'uring','\u25F9':'urtri','\uD835\uDCB0':'Uscr','\uD835\uDCCA':'uscr','\u22F0':'utdot','\u0168':'Utilde','\u0169':'utilde','\xDC':'Uuml','\xFC':'uuml','\u29A7':'uwangle','\u299C':'vangrt','\u228A\uFE00':'vsubne','\u2ACB\uFE00':'vsubnE','\u228B\uFE00':'vsupne','\u2ACC\uFE00':'vsupnE','\u2AE8':'vBar','\u2AEB':'Vbar','\u2AE9':'vBarv','\u0412':'Vcy','\u0432':'vcy','\u22A9':'Vdash','\u22AB':'VDash','\u2AE6':'Vdashl','\u22BB':'veebar','\u225A':'veeeq','\u22EE':'vellip','|':'vert','\u2016':'Vert','\u2758':'VerticalSeparator','\u2240':'wr','\uD835\uDD19':'Vfr','\uD835\uDD33':'vfr','\uD835\uDD4D':'Vopf','\uD835\uDD67':'vopf','\uD835\uDCB1':'Vscr','\uD835\uDCCB':'vscr','\u22AA':'Vvdash','\u299A':'vzigzag','\u0174':'Wcirc','\u0175':'wcirc','\u2A5F':'wedbar','\u2259':'wedgeq','\u2118':'wp','\uD835\uDD1A':'Wfr','\uD835\uDD34':'wfr','\uD835\uDD4E':'Wopf','\uD835\uDD68':'wopf','\uD835\uDCB2':'Wscr','\uD835\uDCCC':'wscr','\uD835\uDD1B':'Xfr','\uD835\uDD35':'xfr','\u039E':'Xi','\u03BE':'xi','\u22FB':'xnis','\uD835\uDD4F':'Xopf','\uD835\uDD69':'xopf','\uD835\uDCB3':'Xscr','\uD835\uDCCD':'xscr','\xDD':'Yacute','\xFD':'yacute','\u042F':'YAcy','\u044F':'yacy','\u0176':'Ycirc','\u0177':'ycirc','\u042B':'Ycy','\u044B':'ycy','\xA5':'yen','\uD835\uDD1C':'Yfr','\uD835\uDD36':'yfr','\u0407':'YIcy','\u0457':'yicy','\uD835\uDD50':'Yopf','\uD835\uDD6A':'yopf','\uD835\uDCB4':'Yscr','\uD835\uDCCE':'yscr','\u042E':'YUcy','\u044E':'yucy','\xFF':'yuml','\u0178':'Yuml','\u0179':'Zacute','\u017A':'zacute','\u017D':'Zcaron','\u017E':'zcaron','\u0417':'Zcy','\u0437':'zcy','\u017B':'Zdot','\u017C':'zdot','\u2128':'Zfr','\u0396':'Zeta','\u03B6':'zeta','\uD835\uDD37':'zfr','\u0416':'ZHcy','\u0436':'zhcy','\u21DD':'zigrarr','\uD835\uDD6B':'zopf','\uD835\uDCB5':'Zscr','\uD835\uDCCF':'zscr','\u200D':'zwj','\u200C':'zwnj'}; + + var regexEscape = /["&'<>`]/g; + var escapeMap = { + '"': '"', + '&': '&', + '\'': ''', + '<': '<', + // See https://mathiasbynens.be/notes/ambiguous-ampersands: in HTML, the + // following is not strictly necessary unless it’s part of a tag or an + // unquoted attribute value. We’re only escaping it to support those + // situations, and for XML support. + '>': '>', + // In Internet Explorer ≤ 8, the backtick character can be used + // to break out of (un)quoted attribute values or HTML comments. + // See http://html5sec.org/#102, http://html5sec.org/#108, and + // http://html5sec.org/#133. + '`': '`' + }; + + var regexInvalidEntity = /&#(?:[xX][^a-fA-F0-9]|[^0-9xX])/; + var regexInvalidRawCodePoint = /[\0-\x08\x0B\x0E-\x1F\x7F-\x9F\uFDD0-\uFDEF\uFFFE\uFFFF]|[\uD83F\uD87F\uD8BF\uD8FF\uD93F\uD97F\uD9BF\uD9FF\uDA3F\uDA7F\uDABF\uDAFF\uDB3F\uDB7F\uDBBF\uDBFF][\uDFFE\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/; + var regexDecode = /&#([0-9]+)(;?)|&#[xX]([a-fA-F0-9]+)(;?)|&([0-9a-zA-Z]+);|&(Aacute|iacute|Uacute|plusmn|otilde|Otilde|Agrave|agrave|yacute|Yacute|oslash|Oslash|Atilde|atilde|brvbar|Ccedil|ccedil|ograve|curren|divide|Eacute|eacute|Ograve|oacute|Egrave|egrave|ugrave|frac12|frac14|frac34|Ugrave|Oacute|Iacute|ntilde|Ntilde|uacute|middot|Igrave|igrave|iquest|aacute|laquo|THORN|micro|iexcl|icirc|Icirc|Acirc|ucirc|ecirc|Ocirc|ocirc|Ecirc|Ucirc|aring|Aring|aelig|AElig|acute|pound|raquo|acirc|times|thorn|szlig|cedil|COPY|Auml|ordf|ordm|uuml|macr|Uuml|auml|Ouml|ouml|para|nbsp|Euml|quot|QUOT|euml|yuml|cent|sect|copy|sup1|sup2|sup3|Iuml|iuml|shy|eth|reg|not|yen|amp|AMP|REG|uml|ETH|deg|gt|GT|LT|lt)([=a-zA-Z0-9])?/g; + var decodeMap = {'Aacute':'\xC1','aacute':'\xE1','Abreve':'\u0102','abreve':'\u0103','ac':'\u223E','acd':'\u223F','acE':'\u223E\u0333','Acirc':'\xC2','acirc':'\xE2','acute':'\xB4','Acy':'\u0410','acy':'\u0430','AElig':'\xC6','aelig':'\xE6','af':'\u2061','Afr':'\uD835\uDD04','afr':'\uD835\uDD1E','Agrave':'\xC0','agrave':'\xE0','alefsym':'\u2135','aleph':'\u2135','Alpha':'\u0391','alpha':'\u03B1','Amacr':'\u0100','amacr':'\u0101','amalg':'\u2A3F','amp':'&','AMP':'&','andand':'\u2A55','And':'\u2A53','and':'\u2227','andd':'\u2A5C','andslope':'\u2A58','andv':'\u2A5A','ang':'\u2220','ange':'\u29A4','angle':'\u2220','angmsdaa':'\u29A8','angmsdab':'\u29A9','angmsdac':'\u29AA','angmsdad':'\u29AB','angmsdae':'\u29AC','angmsdaf':'\u29AD','angmsdag':'\u29AE','angmsdah':'\u29AF','angmsd':'\u2221','angrt':'\u221F','angrtvb':'\u22BE','angrtvbd':'\u299D','angsph':'\u2222','angst':'\xC5','angzarr':'\u237C','Aogon':'\u0104','aogon':'\u0105','Aopf':'\uD835\uDD38','aopf':'\uD835\uDD52','apacir':'\u2A6F','ap':'\u2248','apE':'\u2A70','ape':'\u224A','apid':'\u224B','apos':'\'','ApplyFunction':'\u2061','approx':'\u2248','approxeq':'\u224A','Aring':'\xC5','aring':'\xE5','Ascr':'\uD835\uDC9C','ascr':'\uD835\uDCB6','Assign':'\u2254','ast':'*','asymp':'\u2248','asympeq':'\u224D','Atilde':'\xC3','atilde':'\xE3','Auml':'\xC4','auml':'\xE4','awconint':'\u2233','awint':'\u2A11','backcong':'\u224C','backepsilon':'\u03F6','backprime':'\u2035','backsim':'\u223D','backsimeq':'\u22CD','Backslash':'\u2216','Barv':'\u2AE7','barvee':'\u22BD','barwed':'\u2305','Barwed':'\u2306','barwedge':'\u2305','bbrk':'\u23B5','bbrktbrk':'\u23B6','bcong':'\u224C','Bcy':'\u0411','bcy':'\u0431','bdquo':'\u201E','becaus':'\u2235','because':'\u2235','Because':'\u2235','bemptyv':'\u29B0','bepsi':'\u03F6','bernou':'\u212C','Bernoullis':'\u212C','Beta':'\u0392','beta':'\u03B2','beth':'\u2136','between':'\u226C','Bfr':'\uD835\uDD05','bfr':'\uD835\uDD1F','bigcap':'\u22C2','bigcirc':'\u25EF','bigcup':'\u22C3','bigodot':'\u2A00','bigoplus':'\u2A01','bigotimes':'\u2A02','bigsqcup':'\u2A06','bigstar':'\u2605','bigtriangledown':'\u25BD','bigtriangleup':'\u25B3','biguplus':'\u2A04','bigvee':'\u22C1','bigwedge':'\u22C0','bkarow':'\u290D','blacklozenge':'\u29EB','blacksquare':'\u25AA','blacktriangle':'\u25B4','blacktriangledown':'\u25BE','blacktriangleleft':'\u25C2','blacktriangleright':'\u25B8','blank':'\u2423','blk12':'\u2592','blk14':'\u2591','blk34':'\u2593','block':'\u2588','bne':'=\u20E5','bnequiv':'\u2261\u20E5','bNot':'\u2AED','bnot':'\u2310','Bopf':'\uD835\uDD39','bopf':'\uD835\uDD53','bot':'\u22A5','bottom':'\u22A5','bowtie':'\u22C8','boxbox':'\u29C9','boxdl':'\u2510','boxdL':'\u2555','boxDl':'\u2556','boxDL':'\u2557','boxdr':'\u250C','boxdR':'\u2552','boxDr':'\u2553','boxDR':'\u2554','boxh':'\u2500','boxH':'\u2550','boxhd':'\u252C','boxHd':'\u2564','boxhD':'\u2565','boxHD':'\u2566','boxhu':'\u2534','boxHu':'\u2567','boxhU':'\u2568','boxHU':'\u2569','boxminus':'\u229F','boxplus':'\u229E','boxtimes':'\u22A0','boxul':'\u2518','boxuL':'\u255B','boxUl':'\u255C','boxUL':'\u255D','boxur':'\u2514','boxuR':'\u2558','boxUr':'\u2559','boxUR':'\u255A','boxv':'\u2502','boxV':'\u2551','boxvh':'\u253C','boxvH':'\u256A','boxVh':'\u256B','boxVH':'\u256C','boxvl':'\u2524','boxvL':'\u2561','boxVl':'\u2562','boxVL':'\u2563','boxvr':'\u251C','boxvR':'\u255E','boxVr':'\u255F','boxVR':'\u2560','bprime':'\u2035','breve':'\u02D8','Breve':'\u02D8','brvbar':'\xA6','bscr':'\uD835\uDCB7','Bscr':'\u212C','bsemi':'\u204F','bsim':'\u223D','bsime':'\u22CD','bsolb':'\u29C5','bsol':'\\','bsolhsub':'\u27C8','bull':'\u2022','bullet':'\u2022','bump':'\u224E','bumpE':'\u2AAE','bumpe':'\u224F','Bumpeq':'\u224E','bumpeq':'\u224F','Cacute':'\u0106','cacute':'\u0107','capand':'\u2A44','capbrcup':'\u2A49','capcap':'\u2A4B','cap':'\u2229','Cap':'\u22D2','capcup':'\u2A47','capdot':'\u2A40','CapitalDifferentialD':'\u2145','caps':'\u2229\uFE00','caret':'\u2041','caron':'\u02C7','Cayleys':'\u212D','ccaps':'\u2A4D','Ccaron':'\u010C','ccaron':'\u010D','Ccedil':'\xC7','ccedil':'\xE7','Ccirc':'\u0108','ccirc':'\u0109','Cconint':'\u2230','ccups':'\u2A4C','ccupssm':'\u2A50','Cdot':'\u010A','cdot':'\u010B','cedil':'\xB8','Cedilla':'\xB8','cemptyv':'\u29B2','cent':'\xA2','centerdot':'\xB7','CenterDot':'\xB7','cfr':'\uD835\uDD20','Cfr':'\u212D','CHcy':'\u0427','chcy':'\u0447','check':'\u2713','checkmark':'\u2713','Chi':'\u03A7','chi':'\u03C7','circ':'\u02C6','circeq':'\u2257','circlearrowleft':'\u21BA','circlearrowright':'\u21BB','circledast':'\u229B','circledcirc':'\u229A','circleddash':'\u229D','CircleDot':'\u2299','circledR':'\xAE','circledS':'\u24C8','CircleMinus':'\u2296','CirclePlus':'\u2295','CircleTimes':'\u2297','cir':'\u25CB','cirE':'\u29C3','cire':'\u2257','cirfnint':'\u2A10','cirmid':'\u2AEF','cirscir':'\u29C2','ClockwiseContourIntegral':'\u2232','CloseCurlyDoubleQuote':'\u201D','CloseCurlyQuote':'\u2019','clubs':'\u2663','clubsuit':'\u2663','colon':':','Colon':'\u2237','Colone':'\u2A74','colone':'\u2254','coloneq':'\u2254','comma':',','commat':'@','comp':'\u2201','compfn':'\u2218','complement':'\u2201','complexes':'\u2102','cong':'\u2245','congdot':'\u2A6D','Congruent':'\u2261','conint':'\u222E','Conint':'\u222F','ContourIntegral':'\u222E','copf':'\uD835\uDD54','Copf':'\u2102','coprod':'\u2210','Coproduct':'\u2210','copy':'\xA9','COPY':'\xA9','copysr':'\u2117','CounterClockwiseContourIntegral':'\u2233','crarr':'\u21B5','cross':'\u2717','Cross':'\u2A2F','Cscr':'\uD835\uDC9E','cscr':'\uD835\uDCB8','csub':'\u2ACF','csube':'\u2AD1','csup':'\u2AD0','csupe':'\u2AD2','ctdot':'\u22EF','cudarrl':'\u2938','cudarrr':'\u2935','cuepr':'\u22DE','cuesc':'\u22DF','cularr':'\u21B6','cularrp':'\u293D','cupbrcap':'\u2A48','cupcap':'\u2A46','CupCap':'\u224D','cup':'\u222A','Cup':'\u22D3','cupcup':'\u2A4A','cupdot':'\u228D','cupor':'\u2A45','cups':'\u222A\uFE00','curarr':'\u21B7','curarrm':'\u293C','curlyeqprec':'\u22DE','curlyeqsucc':'\u22DF','curlyvee':'\u22CE','curlywedge':'\u22CF','curren':'\xA4','curvearrowleft':'\u21B6','curvearrowright':'\u21B7','cuvee':'\u22CE','cuwed':'\u22CF','cwconint':'\u2232','cwint':'\u2231','cylcty':'\u232D','dagger':'\u2020','Dagger':'\u2021','daleth':'\u2138','darr':'\u2193','Darr':'\u21A1','dArr':'\u21D3','dash':'\u2010','Dashv':'\u2AE4','dashv':'\u22A3','dbkarow':'\u290F','dblac':'\u02DD','Dcaron':'\u010E','dcaron':'\u010F','Dcy':'\u0414','dcy':'\u0434','ddagger':'\u2021','ddarr':'\u21CA','DD':'\u2145','dd':'\u2146','DDotrahd':'\u2911','ddotseq':'\u2A77','deg':'\xB0','Del':'\u2207','Delta':'\u0394','delta':'\u03B4','demptyv':'\u29B1','dfisht':'\u297F','Dfr':'\uD835\uDD07','dfr':'\uD835\uDD21','dHar':'\u2965','dharl':'\u21C3','dharr':'\u21C2','DiacriticalAcute':'\xB4','DiacriticalDot':'\u02D9','DiacriticalDoubleAcute':'\u02DD','DiacriticalGrave':'`','DiacriticalTilde':'\u02DC','diam':'\u22C4','diamond':'\u22C4','Diamond':'\u22C4','diamondsuit':'\u2666','diams':'\u2666','die':'\xA8','DifferentialD':'\u2146','digamma':'\u03DD','disin':'\u22F2','div':'\xF7','divide':'\xF7','divideontimes':'\u22C7','divonx':'\u22C7','DJcy':'\u0402','djcy':'\u0452','dlcorn':'\u231E','dlcrop':'\u230D','dollar':'$','Dopf':'\uD835\uDD3B','dopf':'\uD835\uDD55','Dot':'\xA8','dot':'\u02D9','DotDot':'\u20DC','doteq':'\u2250','doteqdot':'\u2251','DotEqual':'\u2250','dotminus':'\u2238','dotplus':'\u2214','dotsquare':'\u22A1','doublebarwedge':'\u2306','DoubleContourIntegral':'\u222F','DoubleDot':'\xA8','DoubleDownArrow':'\u21D3','DoubleLeftArrow':'\u21D0','DoubleLeftRightArrow':'\u21D4','DoubleLeftTee':'\u2AE4','DoubleLongLeftArrow':'\u27F8','DoubleLongLeftRightArrow':'\u27FA','DoubleLongRightArrow':'\u27F9','DoubleRightArrow':'\u21D2','DoubleRightTee':'\u22A8','DoubleUpArrow':'\u21D1','DoubleUpDownArrow':'\u21D5','DoubleVerticalBar':'\u2225','DownArrowBar':'\u2913','downarrow':'\u2193','DownArrow':'\u2193','Downarrow':'\u21D3','DownArrowUpArrow':'\u21F5','DownBreve':'\u0311','downdownarrows':'\u21CA','downharpoonleft':'\u21C3','downharpoonright':'\u21C2','DownLeftRightVector':'\u2950','DownLeftTeeVector':'\u295E','DownLeftVectorBar':'\u2956','DownLeftVector':'\u21BD','DownRightTeeVector':'\u295F','DownRightVectorBar':'\u2957','DownRightVector':'\u21C1','DownTeeArrow':'\u21A7','DownTee':'\u22A4','drbkarow':'\u2910','drcorn':'\u231F','drcrop':'\u230C','Dscr':'\uD835\uDC9F','dscr':'\uD835\uDCB9','DScy':'\u0405','dscy':'\u0455','dsol':'\u29F6','Dstrok':'\u0110','dstrok':'\u0111','dtdot':'\u22F1','dtri':'\u25BF','dtrif':'\u25BE','duarr':'\u21F5','duhar':'\u296F','dwangle':'\u29A6','DZcy':'\u040F','dzcy':'\u045F','dzigrarr':'\u27FF','Eacute':'\xC9','eacute':'\xE9','easter':'\u2A6E','Ecaron':'\u011A','ecaron':'\u011B','Ecirc':'\xCA','ecirc':'\xEA','ecir':'\u2256','ecolon':'\u2255','Ecy':'\u042D','ecy':'\u044D','eDDot':'\u2A77','Edot':'\u0116','edot':'\u0117','eDot':'\u2251','ee':'\u2147','efDot':'\u2252','Efr':'\uD835\uDD08','efr':'\uD835\uDD22','eg':'\u2A9A','Egrave':'\xC8','egrave':'\xE8','egs':'\u2A96','egsdot':'\u2A98','el':'\u2A99','Element':'\u2208','elinters':'\u23E7','ell':'\u2113','els':'\u2A95','elsdot':'\u2A97','Emacr':'\u0112','emacr':'\u0113','empty':'\u2205','emptyset':'\u2205','EmptySmallSquare':'\u25FB','emptyv':'\u2205','EmptyVerySmallSquare':'\u25AB','emsp13':'\u2004','emsp14':'\u2005','emsp':'\u2003','ENG':'\u014A','eng':'\u014B','ensp':'\u2002','Eogon':'\u0118','eogon':'\u0119','Eopf':'\uD835\uDD3C','eopf':'\uD835\uDD56','epar':'\u22D5','eparsl':'\u29E3','eplus':'\u2A71','epsi':'\u03B5','Epsilon':'\u0395','epsilon':'\u03B5','epsiv':'\u03F5','eqcirc':'\u2256','eqcolon':'\u2255','eqsim':'\u2242','eqslantgtr':'\u2A96','eqslantless':'\u2A95','Equal':'\u2A75','equals':'=','EqualTilde':'\u2242','equest':'\u225F','Equilibrium':'\u21CC','equiv':'\u2261','equivDD':'\u2A78','eqvparsl':'\u29E5','erarr':'\u2971','erDot':'\u2253','escr':'\u212F','Escr':'\u2130','esdot':'\u2250','Esim':'\u2A73','esim':'\u2242','Eta':'\u0397','eta':'\u03B7','ETH':'\xD0','eth':'\xF0','Euml':'\xCB','euml':'\xEB','euro':'\u20AC','excl':'!','exist':'\u2203','Exists':'\u2203','expectation':'\u2130','exponentiale':'\u2147','ExponentialE':'\u2147','fallingdotseq':'\u2252','Fcy':'\u0424','fcy':'\u0444','female':'\u2640','ffilig':'\uFB03','fflig':'\uFB00','ffllig':'\uFB04','Ffr':'\uD835\uDD09','ffr':'\uD835\uDD23','filig':'\uFB01','FilledSmallSquare':'\u25FC','FilledVerySmallSquare':'\u25AA','fjlig':'fj','flat':'\u266D','fllig':'\uFB02','fltns':'\u25B1','fnof':'\u0192','Fopf':'\uD835\uDD3D','fopf':'\uD835\uDD57','forall':'\u2200','ForAll':'\u2200','fork':'\u22D4','forkv':'\u2AD9','Fouriertrf':'\u2131','fpartint':'\u2A0D','frac12':'\xBD','frac13':'\u2153','frac14':'\xBC','frac15':'\u2155','frac16':'\u2159','frac18':'\u215B','frac23':'\u2154','frac25':'\u2156','frac34':'\xBE','frac35':'\u2157','frac38':'\u215C','frac45':'\u2158','frac56':'\u215A','frac58':'\u215D','frac78':'\u215E','frasl':'\u2044','frown':'\u2322','fscr':'\uD835\uDCBB','Fscr':'\u2131','gacute':'\u01F5','Gamma':'\u0393','gamma':'\u03B3','Gammad':'\u03DC','gammad':'\u03DD','gap':'\u2A86','Gbreve':'\u011E','gbreve':'\u011F','Gcedil':'\u0122','Gcirc':'\u011C','gcirc':'\u011D','Gcy':'\u0413','gcy':'\u0433','Gdot':'\u0120','gdot':'\u0121','ge':'\u2265','gE':'\u2267','gEl':'\u2A8C','gel':'\u22DB','geq':'\u2265','geqq':'\u2267','geqslant':'\u2A7E','gescc':'\u2AA9','ges':'\u2A7E','gesdot':'\u2A80','gesdoto':'\u2A82','gesdotol':'\u2A84','gesl':'\u22DB\uFE00','gesles':'\u2A94','Gfr':'\uD835\uDD0A','gfr':'\uD835\uDD24','gg':'\u226B','Gg':'\u22D9','ggg':'\u22D9','gimel':'\u2137','GJcy':'\u0403','gjcy':'\u0453','gla':'\u2AA5','gl':'\u2277','glE':'\u2A92','glj':'\u2AA4','gnap':'\u2A8A','gnapprox':'\u2A8A','gne':'\u2A88','gnE':'\u2269','gneq':'\u2A88','gneqq':'\u2269','gnsim':'\u22E7','Gopf':'\uD835\uDD3E','gopf':'\uD835\uDD58','grave':'`','GreaterEqual':'\u2265','GreaterEqualLess':'\u22DB','GreaterFullEqual':'\u2267','GreaterGreater':'\u2AA2','GreaterLess':'\u2277','GreaterSlantEqual':'\u2A7E','GreaterTilde':'\u2273','Gscr':'\uD835\uDCA2','gscr':'\u210A','gsim':'\u2273','gsime':'\u2A8E','gsiml':'\u2A90','gtcc':'\u2AA7','gtcir':'\u2A7A','gt':'>','GT':'>','Gt':'\u226B','gtdot':'\u22D7','gtlPar':'\u2995','gtquest':'\u2A7C','gtrapprox':'\u2A86','gtrarr':'\u2978','gtrdot':'\u22D7','gtreqless':'\u22DB','gtreqqless':'\u2A8C','gtrless':'\u2277','gtrsim':'\u2273','gvertneqq':'\u2269\uFE00','gvnE':'\u2269\uFE00','Hacek':'\u02C7','hairsp':'\u200A','half':'\xBD','hamilt':'\u210B','HARDcy':'\u042A','hardcy':'\u044A','harrcir':'\u2948','harr':'\u2194','hArr':'\u21D4','harrw':'\u21AD','Hat':'^','hbar':'\u210F','Hcirc':'\u0124','hcirc':'\u0125','hearts':'\u2665','heartsuit':'\u2665','hellip':'\u2026','hercon':'\u22B9','hfr':'\uD835\uDD25','Hfr':'\u210C','HilbertSpace':'\u210B','hksearow':'\u2925','hkswarow':'\u2926','hoarr':'\u21FF','homtht':'\u223B','hookleftarrow':'\u21A9','hookrightarrow':'\u21AA','hopf':'\uD835\uDD59','Hopf':'\u210D','horbar':'\u2015','HorizontalLine':'\u2500','hscr':'\uD835\uDCBD','Hscr':'\u210B','hslash':'\u210F','Hstrok':'\u0126','hstrok':'\u0127','HumpDownHump':'\u224E','HumpEqual':'\u224F','hybull':'\u2043','hyphen':'\u2010','Iacute':'\xCD','iacute':'\xED','ic':'\u2063','Icirc':'\xCE','icirc':'\xEE','Icy':'\u0418','icy':'\u0438','Idot':'\u0130','IEcy':'\u0415','iecy':'\u0435','iexcl':'\xA1','iff':'\u21D4','ifr':'\uD835\uDD26','Ifr':'\u2111','Igrave':'\xCC','igrave':'\xEC','ii':'\u2148','iiiint':'\u2A0C','iiint':'\u222D','iinfin':'\u29DC','iiota':'\u2129','IJlig':'\u0132','ijlig':'\u0133','Imacr':'\u012A','imacr':'\u012B','image':'\u2111','ImaginaryI':'\u2148','imagline':'\u2110','imagpart':'\u2111','imath':'\u0131','Im':'\u2111','imof':'\u22B7','imped':'\u01B5','Implies':'\u21D2','incare':'\u2105','in':'\u2208','infin':'\u221E','infintie':'\u29DD','inodot':'\u0131','intcal':'\u22BA','int':'\u222B','Int':'\u222C','integers':'\u2124','Integral':'\u222B','intercal':'\u22BA','Intersection':'\u22C2','intlarhk':'\u2A17','intprod':'\u2A3C','InvisibleComma':'\u2063','InvisibleTimes':'\u2062','IOcy':'\u0401','iocy':'\u0451','Iogon':'\u012E','iogon':'\u012F','Iopf':'\uD835\uDD40','iopf':'\uD835\uDD5A','Iota':'\u0399','iota':'\u03B9','iprod':'\u2A3C','iquest':'\xBF','iscr':'\uD835\uDCBE','Iscr':'\u2110','isin':'\u2208','isindot':'\u22F5','isinE':'\u22F9','isins':'\u22F4','isinsv':'\u22F3','isinv':'\u2208','it':'\u2062','Itilde':'\u0128','itilde':'\u0129','Iukcy':'\u0406','iukcy':'\u0456','Iuml':'\xCF','iuml':'\xEF','Jcirc':'\u0134','jcirc':'\u0135','Jcy':'\u0419','jcy':'\u0439','Jfr':'\uD835\uDD0D','jfr':'\uD835\uDD27','jmath':'\u0237','Jopf':'\uD835\uDD41','jopf':'\uD835\uDD5B','Jscr':'\uD835\uDCA5','jscr':'\uD835\uDCBF','Jsercy':'\u0408','jsercy':'\u0458','Jukcy':'\u0404','jukcy':'\u0454','Kappa':'\u039A','kappa':'\u03BA','kappav':'\u03F0','Kcedil':'\u0136','kcedil':'\u0137','Kcy':'\u041A','kcy':'\u043A','Kfr':'\uD835\uDD0E','kfr':'\uD835\uDD28','kgreen':'\u0138','KHcy':'\u0425','khcy':'\u0445','KJcy':'\u040C','kjcy':'\u045C','Kopf':'\uD835\uDD42','kopf':'\uD835\uDD5C','Kscr':'\uD835\uDCA6','kscr':'\uD835\uDCC0','lAarr':'\u21DA','Lacute':'\u0139','lacute':'\u013A','laemptyv':'\u29B4','lagran':'\u2112','Lambda':'\u039B','lambda':'\u03BB','lang':'\u27E8','Lang':'\u27EA','langd':'\u2991','langle':'\u27E8','lap':'\u2A85','Laplacetrf':'\u2112','laquo':'\xAB','larrb':'\u21E4','larrbfs':'\u291F','larr':'\u2190','Larr':'\u219E','lArr':'\u21D0','larrfs':'\u291D','larrhk':'\u21A9','larrlp':'\u21AB','larrpl':'\u2939','larrsim':'\u2973','larrtl':'\u21A2','latail':'\u2919','lAtail':'\u291B','lat':'\u2AAB','late':'\u2AAD','lates':'\u2AAD\uFE00','lbarr':'\u290C','lBarr':'\u290E','lbbrk':'\u2772','lbrace':'{','lbrack':'[','lbrke':'\u298B','lbrksld':'\u298F','lbrkslu':'\u298D','Lcaron':'\u013D','lcaron':'\u013E','Lcedil':'\u013B','lcedil':'\u013C','lceil':'\u2308','lcub':'{','Lcy':'\u041B','lcy':'\u043B','ldca':'\u2936','ldquo':'\u201C','ldquor':'\u201E','ldrdhar':'\u2967','ldrushar':'\u294B','ldsh':'\u21B2','le':'\u2264','lE':'\u2266','LeftAngleBracket':'\u27E8','LeftArrowBar':'\u21E4','leftarrow':'\u2190','LeftArrow':'\u2190','Leftarrow':'\u21D0','LeftArrowRightArrow':'\u21C6','leftarrowtail':'\u21A2','LeftCeiling':'\u2308','LeftDoubleBracket':'\u27E6','LeftDownTeeVector':'\u2961','LeftDownVectorBar':'\u2959','LeftDownVector':'\u21C3','LeftFloor':'\u230A','leftharpoondown':'\u21BD','leftharpoonup':'\u21BC','leftleftarrows':'\u21C7','leftrightarrow':'\u2194','LeftRightArrow':'\u2194','Leftrightarrow':'\u21D4','leftrightarrows':'\u21C6','leftrightharpoons':'\u21CB','leftrightsquigarrow':'\u21AD','LeftRightVector':'\u294E','LeftTeeArrow':'\u21A4','LeftTee':'\u22A3','LeftTeeVector':'\u295A','leftthreetimes':'\u22CB','LeftTriangleBar':'\u29CF','LeftTriangle':'\u22B2','LeftTriangleEqual':'\u22B4','LeftUpDownVector':'\u2951','LeftUpTeeVector':'\u2960','LeftUpVectorBar':'\u2958','LeftUpVector':'\u21BF','LeftVectorBar':'\u2952','LeftVector':'\u21BC','lEg':'\u2A8B','leg':'\u22DA','leq':'\u2264','leqq':'\u2266','leqslant':'\u2A7D','lescc':'\u2AA8','les':'\u2A7D','lesdot':'\u2A7F','lesdoto':'\u2A81','lesdotor':'\u2A83','lesg':'\u22DA\uFE00','lesges':'\u2A93','lessapprox':'\u2A85','lessdot':'\u22D6','lesseqgtr':'\u22DA','lesseqqgtr':'\u2A8B','LessEqualGreater':'\u22DA','LessFullEqual':'\u2266','LessGreater':'\u2276','lessgtr':'\u2276','LessLess':'\u2AA1','lesssim':'\u2272','LessSlantEqual':'\u2A7D','LessTilde':'\u2272','lfisht':'\u297C','lfloor':'\u230A','Lfr':'\uD835\uDD0F','lfr':'\uD835\uDD29','lg':'\u2276','lgE':'\u2A91','lHar':'\u2962','lhard':'\u21BD','lharu':'\u21BC','lharul':'\u296A','lhblk':'\u2584','LJcy':'\u0409','ljcy':'\u0459','llarr':'\u21C7','ll':'\u226A','Ll':'\u22D8','llcorner':'\u231E','Lleftarrow':'\u21DA','llhard':'\u296B','lltri':'\u25FA','Lmidot':'\u013F','lmidot':'\u0140','lmoustache':'\u23B0','lmoust':'\u23B0','lnap':'\u2A89','lnapprox':'\u2A89','lne':'\u2A87','lnE':'\u2268','lneq':'\u2A87','lneqq':'\u2268','lnsim':'\u22E6','loang':'\u27EC','loarr':'\u21FD','lobrk':'\u27E6','longleftarrow':'\u27F5','LongLeftArrow':'\u27F5','Longleftarrow':'\u27F8','longleftrightarrow':'\u27F7','LongLeftRightArrow':'\u27F7','Longleftrightarrow':'\u27FA','longmapsto':'\u27FC','longrightarrow':'\u27F6','LongRightArrow':'\u27F6','Longrightarrow':'\u27F9','looparrowleft':'\u21AB','looparrowright':'\u21AC','lopar':'\u2985','Lopf':'\uD835\uDD43','lopf':'\uD835\uDD5D','loplus':'\u2A2D','lotimes':'\u2A34','lowast':'\u2217','lowbar':'_','LowerLeftArrow':'\u2199','LowerRightArrow':'\u2198','loz':'\u25CA','lozenge':'\u25CA','lozf':'\u29EB','lpar':'(','lparlt':'\u2993','lrarr':'\u21C6','lrcorner':'\u231F','lrhar':'\u21CB','lrhard':'\u296D','lrm':'\u200E','lrtri':'\u22BF','lsaquo':'\u2039','lscr':'\uD835\uDCC1','Lscr':'\u2112','lsh':'\u21B0','Lsh':'\u21B0','lsim':'\u2272','lsime':'\u2A8D','lsimg':'\u2A8F','lsqb':'[','lsquo':'\u2018','lsquor':'\u201A','Lstrok':'\u0141','lstrok':'\u0142','ltcc':'\u2AA6','ltcir':'\u2A79','lt':'<','LT':'<','Lt':'\u226A','ltdot':'\u22D6','lthree':'\u22CB','ltimes':'\u22C9','ltlarr':'\u2976','ltquest':'\u2A7B','ltri':'\u25C3','ltrie':'\u22B4','ltrif':'\u25C2','ltrPar':'\u2996','lurdshar':'\u294A','luruhar':'\u2966','lvertneqq':'\u2268\uFE00','lvnE':'\u2268\uFE00','macr':'\xAF','male':'\u2642','malt':'\u2720','maltese':'\u2720','Map':'\u2905','map':'\u21A6','mapsto':'\u21A6','mapstodown':'\u21A7','mapstoleft':'\u21A4','mapstoup':'\u21A5','marker':'\u25AE','mcomma':'\u2A29','Mcy':'\u041C','mcy':'\u043C','mdash':'\u2014','mDDot':'\u223A','measuredangle':'\u2221','MediumSpace':'\u205F','Mellintrf':'\u2133','Mfr':'\uD835\uDD10','mfr':'\uD835\uDD2A','mho':'\u2127','micro':'\xB5','midast':'*','midcir':'\u2AF0','mid':'\u2223','middot':'\xB7','minusb':'\u229F','minus':'\u2212','minusd':'\u2238','minusdu':'\u2A2A','MinusPlus':'\u2213','mlcp':'\u2ADB','mldr':'\u2026','mnplus':'\u2213','models':'\u22A7','Mopf':'\uD835\uDD44','mopf':'\uD835\uDD5E','mp':'\u2213','mscr':'\uD835\uDCC2','Mscr':'\u2133','mstpos':'\u223E','Mu':'\u039C','mu':'\u03BC','multimap':'\u22B8','mumap':'\u22B8','nabla':'\u2207','Nacute':'\u0143','nacute':'\u0144','nang':'\u2220\u20D2','nap':'\u2249','napE':'\u2A70\u0338','napid':'\u224B\u0338','napos':'\u0149','napprox':'\u2249','natural':'\u266E','naturals':'\u2115','natur':'\u266E','nbsp':'\xA0','nbump':'\u224E\u0338','nbumpe':'\u224F\u0338','ncap':'\u2A43','Ncaron':'\u0147','ncaron':'\u0148','Ncedil':'\u0145','ncedil':'\u0146','ncong':'\u2247','ncongdot':'\u2A6D\u0338','ncup':'\u2A42','Ncy':'\u041D','ncy':'\u043D','ndash':'\u2013','nearhk':'\u2924','nearr':'\u2197','neArr':'\u21D7','nearrow':'\u2197','ne':'\u2260','nedot':'\u2250\u0338','NegativeMediumSpace':'\u200B','NegativeThickSpace':'\u200B','NegativeThinSpace':'\u200B','NegativeVeryThinSpace':'\u200B','nequiv':'\u2262','nesear':'\u2928','nesim':'\u2242\u0338','NestedGreaterGreater':'\u226B','NestedLessLess':'\u226A','NewLine':'\n','nexist':'\u2204','nexists':'\u2204','Nfr':'\uD835\uDD11','nfr':'\uD835\uDD2B','ngE':'\u2267\u0338','nge':'\u2271','ngeq':'\u2271','ngeqq':'\u2267\u0338','ngeqslant':'\u2A7E\u0338','nges':'\u2A7E\u0338','nGg':'\u22D9\u0338','ngsim':'\u2275','nGt':'\u226B\u20D2','ngt':'\u226F','ngtr':'\u226F','nGtv':'\u226B\u0338','nharr':'\u21AE','nhArr':'\u21CE','nhpar':'\u2AF2','ni':'\u220B','nis':'\u22FC','nisd':'\u22FA','niv':'\u220B','NJcy':'\u040A','njcy':'\u045A','nlarr':'\u219A','nlArr':'\u21CD','nldr':'\u2025','nlE':'\u2266\u0338','nle':'\u2270','nleftarrow':'\u219A','nLeftarrow':'\u21CD','nleftrightarrow':'\u21AE','nLeftrightarrow':'\u21CE','nleq':'\u2270','nleqq':'\u2266\u0338','nleqslant':'\u2A7D\u0338','nles':'\u2A7D\u0338','nless':'\u226E','nLl':'\u22D8\u0338','nlsim':'\u2274','nLt':'\u226A\u20D2','nlt':'\u226E','nltri':'\u22EA','nltrie':'\u22EC','nLtv':'\u226A\u0338','nmid':'\u2224','NoBreak':'\u2060','NonBreakingSpace':'\xA0','nopf':'\uD835\uDD5F','Nopf':'\u2115','Not':'\u2AEC','not':'\xAC','NotCongruent':'\u2262','NotCupCap':'\u226D','NotDoubleVerticalBar':'\u2226','NotElement':'\u2209','NotEqual':'\u2260','NotEqualTilde':'\u2242\u0338','NotExists':'\u2204','NotGreater':'\u226F','NotGreaterEqual':'\u2271','NotGreaterFullEqual':'\u2267\u0338','NotGreaterGreater':'\u226B\u0338','NotGreaterLess':'\u2279','NotGreaterSlantEqual':'\u2A7E\u0338','NotGreaterTilde':'\u2275','NotHumpDownHump':'\u224E\u0338','NotHumpEqual':'\u224F\u0338','notin':'\u2209','notindot':'\u22F5\u0338','notinE':'\u22F9\u0338','notinva':'\u2209','notinvb':'\u22F7','notinvc':'\u22F6','NotLeftTriangleBar':'\u29CF\u0338','NotLeftTriangle':'\u22EA','NotLeftTriangleEqual':'\u22EC','NotLess':'\u226E','NotLessEqual':'\u2270','NotLessGreater':'\u2278','NotLessLess':'\u226A\u0338','NotLessSlantEqual':'\u2A7D\u0338','NotLessTilde':'\u2274','NotNestedGreaterGreater':'\u2AA2\u0338','NotNestedLessLess':'\u2AA1\u0338','notni':'\u220C','notniva':'\u220C','notnivb':'\u22FE','notnivc':'\u22FD','NotPrecedes':'\u2280','NotPrecedesEqual':'\u2AAF\u0338','NotPrecedesSlantEqual':'\u22E0','NotReverseElement':'\u220C','NotRightTriangleBar':'\u29D0\u0338','NotRightTriangle':'\u22EB','NotRightTriangleEqual':'\u22ED','NotSquareSubset':'\u228F\u0338','NotSquareSubsetEqual':'\u22E2','NotSquareSuperset':'\u2290\u0338','NotSquareSupersetEqual':'\u22E3','NotSubset':'\u2282\u20D2','NotSubsetEqual':'\u2288','NotSucceeds':'\u2281','NotSucceedsEqual':'\u2AB0\u0338','NotSucceedsSlantEqual':'\u22E1','NotSucceedsTilde':'\u227F\u0338','NotSuperset':'\u2283\u20D2','NotSupersetEqual':'\u2289','NotTilde':'\u2241','NotTildeEqual':'\u2244','NotTildeFullEqual':'\u2247','NotTildeTilde':'\u2249','NotVerticalBar':'\u2224','nparallel':'\u2226','npar':'\u2226','nparsl':'\u2AFD\u20E5','npart':'\u2202\u0338','npolint':'\u2A14','npr':'\u2280','nprcue':'\u22E0','nprec':'\u2280','npreceq':'\u2AAF\u0338','npre':'\u2AAF\u0338','nrarrc':'\u2933\u0338','nrarr':'\u219B','nrArr':'\u21CF','nrarrw':'\u219D\u0338','nrightarrow':'\u219B','nRightarrow':'\u21CF','nrtri':'\u22EB','nrtrie':'\u22ED','nsc':'\u2281','nsccue':'\u22E1','nsce':'\u2AB0\u0338','Nscr':'\uD835\uDCA9','nscr':'\uD835\uDCC3','nshortmid':'\u2224','nshortparallel':'\u2226','nsim':'\u2241','nsime':'\u2244','nsimeq':'\u2244','nsmid':'\u2224','nspar':'\u2226','nsqsube':'\u22E2','nsqsupe':'\u22E3','nsub':'\u2284','nsubE':'\u2AC5\u0338','nsube':'\u2288','nsubset':'\u2282\u20D2','nsubseteq':'\u2288','nsubseteqq':'\u2AC5\u0338','nsucc':'\u2281','nsucceq':'\u2AB0\u0338','nsup':'\u2285','nsupE':'\u2AC6\u0338','nsupe':'\u2289','nsupset':'\u2283\u20D2','nsupseteq':'\u2289','nsupseteqq':'\u2AC6\u0338','ntgl':'\u2279','Ntilde':'\xD1','ntilde':'\xF1','ntlg':'\u2278','ntriangleleft':'\u22EA','ntrianglelefteq':'\u22EC','ntriangleright':'\u22EB','ntrianglerighteq':'\u22ED','Nu':'\u039D','nu':'\u03BD','num':'#','numero':'\u2116','numsp':'\u2007','nvap':'\u224D\u20D2','nvdash':'\u22AC','nvDash':'\u22AD','nVdash':'\u22AE','nVDash':'\u22AF','nvge':'\u2265\u20D2','nvgt':'>\u20D2','nvHarr':'\u2904','nvinfin':'\u29DE','nvlArr':'\u2902','nvle':'\u2264\u20D2','nvlt':'<\u20D2','nvltrie':'\u22B4\u20D2','nvrArr':'\u2903','nvrtrie':'\u22B5\u20D2','nvsim':'\u223C\u20D2','nwarhk':'\u2923','nwarr':'\u2196','nwArr':'\u21D6','nwarrow':'\u2196','nwnear':'\u2927','Oacute':'\xD3','oacute':'\xF3','oast':'\u229B','Ocirc':'\xD4','ocirc':'\xF4','ocir':'\u229A','Ocy':'\u041E','ocy':'\u043E','odash':'\u229D','Odblac':'\u0150','odblac':'\u0151','odiv':'\u2A38','odot':'\u2299','odsold':'\u29BC','OElig':'\u0152','oelig':'\u0153','ofcir':'\u29BF','Ofr':'\uD835\uDD12','ofr':'\uD835\uDD2C','ogon':'\u02DB','Ograve':'\xD2','ograve':'\xF2','ogt':'\u29C1','ohbar':'\u29B5','ohm':'\u03A9','oint':'\u222E','olarr':'\u21BA','olcir':'\u29BE','olcross':'\u29BB','oline':'\u203E','olt':'\u29C0','Omacr':'\u014C','omacr':'\u014D','Omega':'\u03A9','omega':'\u03C9','Omicron':'\u039F','omicron':'\u03BF','omid':'\u29B6','ominus':'\u2296','Oopf':'\uD835\uDD46','oopf':'\uD835\uDD60','opar':'\u29B7','OpenCurlyDoubleQuote':'\u201C','OpenCurlyQuote':'\u2018','operp':'\u29B9','oplus':'\u2295','orarr':'\u21BB','Or':'\u2A54','or':'\u2228','ord':'\u2A5D','order':'\u2134','orderof':'\u2134','ordf':'\xAA','ordm':'\xBA','origof':'\u22B6','oror':'\u2A56','orslope':'\u2A57','orv':'\u2A5B','oS':'\u24C8','Oscr':'\uD835\uDCAA','oscr':'\u2134','Oslash':'\xD8','oslash':'\xF8','osol':'\u2298','Otilde':'\xD5','otilde':'\xF5','otimesas':'\u2A36','Otimes':'\u2A37','otimes':'\u2297','Ouml':'\xD6','ouml':'\xF6','ovbar':'\u233D','OverBar':'\u203E','OverBrace':'\u23DE','OverBracket':'\u23B4','OverParenthesis':'\u23DC','para':'\xB6','parallel':'\u2225','par':'\u2225','parsim':'\u2AF3','parsl':'\u2AFD','part':'\u2202','PartialD':'\u2202','Pcy':'\u041F','pcy':'\u043F','percnt':'%','period':'.','permil':'\u2030','perp':'\u22A5','pertenk':'\u2031','Pfr':'\uD835\uDD13','pfr':'\uD835\uDD2D','Phi':'\u03A6','phi':'\u03C6','phiv':'\u03D5','phmmat':'\u2133','phone':'\u260E','Pi':'\u03A0','pi':'\u03C0','pitchfork':'\u22D4','piv':'\u03D6','planck':'\u210F','planckh':'\u210E','plankv':'\u210F','plusacir':'\u2A23','plusb':'\u229E','pluscir':'\u2A22','plus':'+','plusdo':'\u2214','plusdu':'\u2A25','pluse':'\u2A72','PlusMinus':'\xB1','plusmn':'\xB1','plussim':'\u2A26','plustwo':'\u2A27','pm':'\xB1','Poincareplane':'\u210C','pointint':'\u2A15','popf':'\uD835\uDD61','Popf':'\u2119','pound':'\xA3','prap':'\u2AB7','Pr':'\u2ABB','pr':'\u227A','prcue':'\u227C','precapprox':'\u2AB7','prec':'\u227A','preccurlyeq':'\u227C','Precedes':'\u227A','PrecedesEqual':'\u2AAF','PrecedesSlantEqual':'\u227C','PrecedesTilde':'\u227E','preceq':'\u2AAF','precnapprox':'\u2AB9','precneqq':'\u2AB5','precnsim':'\u22E8','pre':'\u2AAF','prE':'\u2AB3','precsim':'\u227E','prime':'\u2032','Prime':'\u2033','primes':'\u2119','prnap':'\u2AB9','prnE':'\u2AB5','prnsim':'\u22E8','prod':'\u220F','Product':'\u220F','profalar':'\u232E','profline':'\u2312','profsurf':'\u2313','prop':'\u221D','Proportional':'\u221D','Proportion':'\u2237','propto':'\u221D','prsim':'\u227E','prurel':'\u22B0','Pscr':'\uD835\uDCAB','pscr':'\uD835\uDCC5','Psi':'\u03A8','psi':'\u03C8','puncsp':'\u2008','Qfr':'\uD835\uDD14','qfr':'\uD835\uDD2E','qint':'\u2A0C','qopf':'\uD835\uDD62','Qopf':'\u211A','qprime':'\u2057','Qscr':'\uD835\uDCAC','qscr':'\uD835\uDCC6','quaternions':'\u210D','quatint':'\u2A16','quest':'?','questeq':'\u225F','quot':'"','QUOT':'"','rAarr':'\u21DB','race':'\u223D\u0331','Racute':'\u0154','racute':'\u0155','radic':'\u221A','raemptyv':'\u29B3','rang':'\u27E9','Rang':'\u27EB','rangd':'\u2992','range':'\u29A5','rangle':'\u27E9','raquo':'\xBB','rarrap':'\u2975','rarrb':'\u21E5','rarrbfs':'\u2920','rarrc':'\u2933','rarr':'\u2192','Rarr':'\u21A0','rArr':'\u21D2','rarrfs':'\u291E','rarrhk':'\u21AA','rarrlp':'\u21AC','rarrpl':'\u2945','rarrsim':'\u2974','Rarrtl':'\u2916','rarrtl':'\u21A3','rarrw':'\u219D','ratail':'\u291A','rAtail':'\u291C','ratio':'\u2236','rationals':'\u211A','rbarr':'\u290D','rBarr':'\u290F','RBarr':'\u2910','rbbrk':'\u2773','rbrace':'}','rbrack':']','rbrke':'\u298C','rbrksld':'\u298E','rbrkslu':'\u2990','Rcaron':'\u0158','rcaron':'\u0159','Rcedil':'\u0156','rcedil':'\u0157','rceil':'\u2309','rcub':'}','Rcy':'\u0420','rcy':'\u0440','rdca':'\u2937','rdldhar':'\u2969','rdquo':'\u201D','rdquor':'\u201D','rdsh':'\u21B3','real':'\u211C','realine':'\u211B','realpart':'\u211C','reals':'\u211D','Re':'\u211C','rect':'\u25AD','reg':'\xAE','REG':'\xAE','ReverseElement':'\u220B','ReverseEquilibrium':'\u21CB','ReverseUpEquilibrium':'\u296F','rfisht':'\u297D','rfloor':'\u230B','rfr':'\uD835\uDD2F','Rfr':'\u211C','rHar':'\u2964','rhard':'\u21C1','rharu':'\u21C0','rharul':'\u296C','Rho':'\u03A1','rho':'\u03C1','rhov':'\u03F1','RightAngleBracket':'\u27E9','RightArrowBar':'\u21E5','rightarrow':'\u2192','RightArrow':'\u2192','Rightarrow':'\u21D2','RightArrowLeftArrow':'\u21C4','rightarrowtail':'\u21A3','RightCeiling':'\u2309','RightDoubleBracket':'\u27E7','RightDownTeeVector':'\u295D','RightDownVectorBar':'\u2955','RightDownVector':'\u21C2','RightFloor':'\u230B','rightharpoondown':'\u21C1','rightharpoonup':'\u21C0','rightleftarrows':'\u21C4','rightleftharpoons':'\u21CC','rightrightarrows':'\u21C9','rightsquigarrow':'\u219D','RightTeeArrow':'\u21A6','RightTee':'\u22A2','RightTeeVector':'\u295B','rightthreetimes':'\u22CC','RightTriangleBar':'\u29D0','RightTriangle':'\u22B3','RightTriangleEqual':'\u22B5','RightUpDownVector':'\u294F','RightUpTeeVector':'\u295C','RightUpVectorBar':'\u2954','RightUpVector':'\u21BE','RightVectorBar':'\u2953','RightVector':'\u21C0','ring':'\u02DA','risingdotseq':'\u2253','rlarr':'\u21C4','rlhar':'\u21CC','rlm':'\u200F','rmoustache':'\u23B1','rmoust':'\u23B1','rnmid':'\u2AEE','roang':'\u27ED','roarr':'\u21FE','robrk':'\u27E7','ropar':'\u2986','ropf':'\uD835\uDD63','Ropf':'\u211D','roplus':'\u2A2E','rotimes':'\u2A35','RoundImplies':'\u2970','rpar':')','rpargt':'\u2994','rppolint':'\u2A12','rrarr':'\u21C9','Rrightarrow':'\u21DB','rsaquo':'\u203A','rscr':'\uD835\uDCC7','Rscr':'\u211B','rsh':'\u21B1','Rsh':'\u21B1','rsqb':']','rsquo':'\u2019','rsquor':'\u2019','rthree':'\u22CC','rtimes':'\u22CA','rtri':'\u25B9','rtrie':'\u22B5','rtrif':'\u25B8','rtriltri':'\u29CE','RuleDelayed':'\u29F4','ruluhar':'\u2968','rx':'\u211E','Sacute':'\u015A','sacute':'\u015B','sbquo':'\u201A','scap':'\u2AB8','Scaron':'\u0160','scaron':'\u0161','Sc':'\u2ABC','sc':'\u227B','sccue':'\u227D','sce':'\u2AB0','scE':'\u2AB4','Scedil':'\u015E','scedil':'\u015F','Scirc':'\u015C','scirc':'\u015D','scnap':'\u2ABA','scnE':'\u2AB6','scnsim':'\u22E9','scpolint':'\u2A13','scsim':'\u227F','Scy':'\u0421','scy':'\u0441','sdotb':'\u22A1','sdot':'\u22C5','sdote':'\u2A66','searhk':'\u2925','searr':'\u2198','seArr':'\u21D8','searrow':'\u2198','sect':'\xA7','semi':';','seswar':'\u2929','setminus':'\u2216','setmn':'\u2216','sext':'\u2736','Sfr':'\uD835\uDD16','sfr':'\uD835\uDD30','sfrown':'\u2322','sharp':'\u266F','SHCHcy':'\u0429','shchcy':'\u0449','SHcy':'\u0428','shcy':'\u0448','ShortDownArrow':'\u2193','ShortLeftArrow':'\u2190','shortmid':'\u2223','shortparallel':'\u2225','ShortRightArrow':'\u2192','ShortUpArrow':'\u2191','shy':'\xAD','Sigma':'\u03A3','sigma':'\u03C3','sigmaf':'\u03C2','sigmav':'\u03C2','sim':'\u223C','simdot':'\u2A6A','sime':'\u2243','simeq':'\u2243','simg':'\u2A9E','simgE':'\u2AA0','siml':'\u2A9D','simlE':'\u2A9F','simne':'\u2246','simplus':'\u2A24','simrarr':'\u2972','slarr':'\u2190','SmallCircle':'\u2218','smallsetminus':'\u2216','smashp':'\u2A33','smeparsl':'\u29E4','smid':'\u2223','smile':'\u2323','smt':'\u2AAA','smte':'\u2AAC','smtes':'\u2AAC\uFE00','SOFTcy':'\u042C','softcy':'\u044C','solbar':'\u233F','solb':'\u29C4','sol':'/','Sopf':'\uD835\uDD4A','sopf':'\uD835\uDD64','spades':'\u2660','spadesuit':'\u2660','spar':'\u2225','sqcap':'\u2293','sqcaps':'\u2293\uFE00','sqcup':'\u2294','sqcups':'\u2294\uFE00','Sqrt':'\u221A','sqsub':'\u228F','sqsube':'\u2291','sqsubset':'\u228F','sqsubseteq':'\u2291','sqsup':'\u2290','sqsupe':'\u2292','sqsupset':'\u2290','sqsupseteq':'\u2292','square':'\u25A1','Square':'\u25A1','SquareIntersection':'\u2293','SquareSubset':'\u228F','SquareSubsetEqual':'\u2291','SquareSuperset':'\u2290','SquareSupersetEqual':'\u2292','SquareUnion':'\u2294','squarf':'\u25AA','squ':'\u25A1','squf':'\u25AA','srarr':'\u2192','Sscr':'\uD835\uDCAE','sscr':'\uD835\uDCC8','ssetmn':'\u2216','ssmile':'\u2323','sstarf':'\u22C6','Star':'\u22C6','star':'\u2606','starf':'\u2605','straightepsilon':'\u03F5','straightphi':'\u03D5','strns':'\xAF','sub':'\u2282','Sub':'\u22D0','subdot':'\u2ABD','subE':'\u2AC5','sube':'\u2286','subedot':'\u2AC3','submult':'\u2AC1','subnE':'\u2ACB','subne':'\u228A','subplus':'\u2ABF','subrarr':'\u2979','subset':'\u2282','Subset':'\u22D0','subseteq':'\u2286','subseteqq':'\u2AC5','SubsetEqual':'\u2286','subsetneq':'\u228A','subsetneqq':'\u2ACB','subsim':'\u2AC7','subsub':'\u2AD5','subsup':'\u2AD3','succapprox':'\u2AB8','succ':'\u227B','succcurlyeq':'\u227D','Succeeds':'\u227B','SucceedsEqual':'\u2AB0','SucceedsSlantEqual':'\u227D','SucceedsTilde':'\u227F','succeq':'\u2AB0','succnapprox':'\u2ABA','succneqq':'\u2AB6','succnsim':'\u22E9','succsim':'\u227F','SuchThat':'\u220B','sum':'\u2211','Sum':'\u2211','sung':'\u266A','sup1':'\xB9','sup2':'\xB2','sup3':'\xB3','sup':'\u2283','Sup':'\u22D1','supdot':'\u2ABE','supdsub':'\u2AD8','supE':'\u2AC6','supe':'\u2287','supedot':'\u2AC4','Superset':'\u2283','SupersetEqual':'\u2287','suphsol':'\u27C9','suphsub':'\u2AD7','suplarr':'\u297B','supmult':'\u2AC2','supnE':'\u2ACC','supne':'\u228B','supplus':'\u2AC0','supset':'\u2283','Supset':'\u22D1','supseteq':'\u2287','supseteqq':'\u2AC6','supsetneq':'\u228B','supsetneqq':'\u2ACC','supsim':'\u2AC8','supsub':'\u2AD4','supsup':'\u2AD6','swarhk':'\u2926','swarr':'\u2199','swArr':'\u21D9','swarrow':'\u2199','swnwar':'\u292A','szlig':'\xDF','Tab':'\t','target':'\u2316','Tau':'\u03A4','tau':'\u03C4','tbrk':'\u23B4','Tcaron':'\u0164','tcaron':'\u0165','Tcedil':'\u0162','tcedil':'\u0163','Tcy':'\u0422','tcy':'\u0442','tdot':'\u20DB','telrec':'\u2315','Tfr':'\uD835\uDD17','tfr':'\uD835\uDD31','there4':'\u2234','therefore':'\u2234','Therefore':'\u2234','Theta':'\u0398','theta':'\u03B8','thetasym':'\u03D1','thetav':'\u03D1','thickapprox':'\u2248','thicksim':'\u223C','ThickSpace':'\u205F\u200A','ThinSpace':'\u2009','thinsp':'\u2009','thkap':'\u2248','thksim':'\u223C','THORN':'\xDE','thorn':'\xFE','tilde':'\u02DC','Tilde':'\u223C','TildeEqual':'\u2243','TildeFullEqual':'\u2245','TildeTilde':'\u2248','timesbar':'\u2A31','timesb':'\u22A0','times':'\xD7','timesd':'\u2A30','tint':'\u222D','toea':'\u2928','topbot':'\u2336','topcir':'\u2AF1','top':'\u22A4','Topf':'\uD835\uDD4B','topf':'\uD835\uDD65','topfork':'\u2ADA','tosa':'\u2929','tprime':'\u2034','trade':'\u2122','TRADE':'\u2122','triangle':'\u25B5','triangledown':'\u25BF','triangleleft':'\u25C3','trianglelefteq':'\u22B4','triangleq':'\u225C','triangleright':'\u25B9','trianglerighteq':'\u22B5','tridot':'\u25EC','trie':'\u225C','triminus':'\u2A3A','TripleDot':'\u20DB','triplus':'\u2A39','trisb':'\u29CD','tritime':'\u2A3B','trpezium':'\u23E2','Tscr':'\uD835\uDCAF','tscr':'\uD835\uDCC9','TScy':'\u0426','tscy':'\u0446','TSHcy':'\u040B','tshcy':'\u045B','Tstrok':'\u0166','tstrok':'\u0167','twixt':'\u226C','twoheadleftarrow':'\u219E','twoheadrightarrow':'\u21A0','Uacute':'\xDA','uacute':'\xFA','uarr':'\u2191','Uarr':'\u219F','uArr':'\u21D1','Uarrocir':'\u2949','Ubrcy':'\u040E','ubrcy':'\u045E','Ubreve':'\u016C','ubreve':'\u016D','Ucirc':'\xDB','ucirc':'\xFB','Ucy':'\u0423','ucy':'\u0443','udarr':'\u21C5','Udblac':'\u0170','udblac':'\u0171','udhar':'\u296E','ufisht':'\u297E','Ufr':'\uD835\uDD18','ufr':'\uD835\uDD32','Ugrave':'\xD9','ugrave':'\xF9','uHar':'\u2963','uharl':'\u21BF','uharr':'\u21BE','uhblk':'\u2580','ulcorn':'\u231C','ulcorner':'\u231C','ulcrop':'\u230F','ultri':'\u25F8','Umacr':'\u016A','umacr':'\u016B','uml':'\xA8','UnderBar':'_','UnderBrace':'\u23DF','UnderBracket':'\u23B5','UnderParenthesis':'\u23DD','Union':'\u22C3','UnionPlus':'\u228E','Uogon':'\u0172','uogon':'\u0173','Uopf':'\uD835\uDD4C','uopf':'\uD835\uDD66','UpArrowBar':'\u2912','uparrow':'\u2191','UpArrow':'\u2191','Uparrow':'\u21D1','UpArrowDownArrow':'\u21C5','updownarrow':'\u2195','UpDownArrow':'\u2195','Updownarrow':'\u21D5','UpEquilibrium':'\u296E','upharpoonleft':'\u21BF','upharpoonright':'\u21BE','uplus':'\u228E','UpperLeftArrow':'\u2196','UpperRightArrow':'\u2197','upsi':'\u03C5','Upsi':'\u03D2','upsih':'\u03D2','Upsilon':'\u03A5','upsilon':'\u03C5','UpTeeArrow':'\u21A5','UpTee':'\u22A5','upuparrows':'\u21C8','urcorn':'\u231D','urcorner':'\u231D','urcrop':'\u230E','Uring':'\u016E','uring':'\u016F','urtri':'\u25F9','Uscr':'\uD835\uDCB0','uscr':'\uD835\uDCCA','utdot':'\u22F0','Utilde':'\u0168','utilde':'\u0169','utri':'\u25B5','utrif':'\u25B4','uuarr':'\u21C8','Uuml':'\xDC','uuml':'\xFC','uwangle':'\u29A7','vangrt':'\u299C','varepsilon':'\u03F5','varkappa':'\u03F0','varnothing':'\u2205','varphi':'\u03D5','varpi':'\u03D6','varpropto':'\u221D','varr':'\u2195','vArr':'\u21D5','varrho':'\u03F1','varsigma':'\u03C2','varsubsetneq':'\u228A\uFE00','varsubsetneqq':'\u2ACB\uFE00','varsupsetneq':'\u228B\uFE00','varsupsetneqq':'\u2ACC\uFE00','vartheta':'\u03D1','vartriangleleft':'\u22B2','vartriangleright':'\u22B3','vBar':'\u2AE8','Vbar':'\u2AEB','vBarv':'\u2AE9','Vcy':'\u0412','vcy':'\u0432','vdash':'\u22A2','vDash':'\u22A8','Vdash':'\u22A9','VDash':'\u22AB','Vdashl':'\u2AE6','veebar':'\u22BB','vee':'\u2228','Vee':'\u22C1','veeeq':'\u225A','vellip':'\u22EE','verbar':'|','Verbar':'\u2016','vert':'|','Vert':'\u2016','VerticalBar':'\u2223','VerticalLine':'|','VerticalSeparator':'\u2758','VerticalTilde':'\u2240','VeryThinSpace':'\u200A','Vfr':'\uD835\uDD19','vfr':'\uD835\uDD33','vltri':'\u22B2','vnsub':'\u2282\u20D2','vnsup':'\u2283\u20D2','Vopf':'\uD835\uDD4D','vopf':'\uD835\uDD67','vprop':'\u221D','vrtri':'\u22B3','Vscr':'\uD835\uDCB1','vscr':'\uD835\uDCCB','vsubnE':'\u2ACB\uFE00','vsubne':'\u228A\uFE00','vsupnE':'\u2ACC\uFE00','vsupne':'\u228B\uFE00','Vvdash':'\u22AA','vzigzag':'\u299A','Wcirc':'\u0174','wcirc':'\u0175','wedbar':'\u2A5F','wedge':'\u2227','Wedge':'\u22C0','wedgeq':'\u2259','weierp':'\u2118','Wfr':'\uD835\uDD1A','wfr':'\uD835\uDD34','Wopf':'\uD835\uDD4E','wopf':'\uD835\uDD68','wp':'\u2118','wr':'\u2240','wreath':'\u2240','Wscr':'\uD835\uDCB2','wscr':'\uD835\uDCCC','xcap':'\u22C2','xcirc':'\u25EF','xcup':'\u22C3','xdtri':'\u25BD','Xfr':'\uD835\uDD1B','xfr':'\uD835\uDD35','xharr':'\u27F7','xhArr':'\u27FA','Xi':'\u039E','xi':'\u03BE','xlarr':'\u27F5','xlArr':'\u27F8','xmap':'\u27FC','xnis':'\u22FB','xodot':'\u2A00','Xopf':'\uD835\uDD4F','xopf':'\uD835\uDD69','xoplus':'\u2A01','xotime':'\u2A02','xrarr':'\u27F6','xrArr':'\u27F9','Xscr':'\uD835\uDCB3','xscr':'\uD835\uDCCD','xsqcup':'\u2A06','xuplus':'\u2A04','xutri':'\u25B3','xvee':'\u22C1','xwedge':'\u22C0','Yacute':'\xDD','yacute':'\xFD','YAcy':'\u042F','yacy':'\u044F','Ycirc':'\u0176','ycirc':'\u0177','Ycy':'\u042B','ycy':'\u044B','yen':'\xA5','Yfr':'\uD835\uDD1C','yfr':'\uD835\uDD36','YIcy':'\u0407','yicy':'\u0457','Yopf':'\uD835\uDD50','yopf':'\uD835\uDD6A','Yscr':'\uD835\uDCB4','yscr':'\uD835\uDCCE','YUcy':'\u042E','yucy':'\u044E','yuml':'\xFF','Yuml':'\u0178','Zacute':'\u0179','zacute':'\u017A','Zcaron':'\u017D','zcaron':'\u017E','Zcy':'\u0417','zcy':'\u0437','Zdot':'\u017B','zdot':'\u017C','zeetrf':'\u2128','ZeroWidthSpace':'\u200B','Zeta':'\u0396','zeta':'\u03B6','zfr':'\uD835\uDD37','Zfr':'\u2128','ZHcy':'\u0416','zhcy':'\u0436','zigrarr':'\u21DD','zopf':'\uD835\uDD6B','Zopf':'\u2124','Zscr':'\uD835\uDCB5','zscr':'\uD835\uDCCF','zwj':'\u200D','zwnj':'\u200C'}; + var decodeMapLegacy = {'Aacute':'\xC1','aacute':'\xE1','Acirc':'\xC2','acirc':'\xE2','acute':'\xB4','AElig':'\xC6','aelig':'\xE6','Agrave':'\xC0','agrave':'\xE0','amp':'&','AMP':'&','Aring':'\xC5','aring':'\xE5','Atilde':'\xC3','atilde':'\xE3','Auml':'\xC4','auml':'\xE4','brvbar':'\xA6','Ccedil':'\xC7','ccedil':'\xE7','cedil':'\xB8','cent':'\xA2','copy':'\xA9','COPY':'\xA9','curren':'\xA4','deg':'\xB0','divide':'\xF7','Eacute':'\xC9','eacute':'\xE9','Ecirc':'\xCA','ecirc':'\xEA','Egrave':'\xC8','egrave':'\xE8','ETH':'\xD0','eth':'\xF0','Euml':'\xCB','euml':'\xEB','frac12':'\xBD','frac14':'\xBC','frac34':'\xBE','gt':'>','GT':'>','Iacute':'\xCD','iacute':'\xED','Icirc':'\xCE','icirc':'\xEE','iexcl':'\xA1','Igrave':'\xCC','igrave':'\xEC','iquest':'\xBF','Iuml':'\xCF','iuml':'\xEF','laquo':'\xAB','lt':'<','LT':'<','macr':'\xAF','micro':'\xB5','middot':'\xB7','nbsp':'\xA0','not':'\xAC','Ntilde':'\xD1','ntilde':'\xF1','Oacute':'\xD3','oacute':'\xF3','Ocirc':'\xD4','ocirc':'\xF4','Ograve':'\xD2','ograve':'\xF2','ordf':'\xAA','ordm':'\xBA','Oslash':'\xD8','oslash':'\xF8','Otilde':'\xD5','otilde':'\xF5','Ouml':'\xD6','ouml':'\xF6','para':'\xB6','plusmn':'\xB1','pound':'\xA3','quot':'"','QUOT':'"','raquo':'\xBB','reg':'\xAE','REG':'\xAE','sect':'\xA7','shy':'\xAD','sup1':'\xB9','sup2':'\xB2','sup3':'\xB3','szlig':'\xDF','THORN':'\xDE','thorn':'\xFE','times':'\xD7','Uacute':'\xDA','uacute':'\xFA','Ucirc':'\xDB','ucirc':'\xFB','Ugrave':'\xD9','ugrave':'\xF9','uml':'\xA8','Uuml':'\xDC','uuml':'\xFC','Yacute':'\xDD','yacute':'\xFD','yen':'\xA5','yuml':'\xFF'}; + var decodeMapNumeric = {'0':'\uFFFD','128':'\u20AC','130':'\u201A','131':'\u0192','132':'\u201E','133':'\u2026','134':'\u2020','135':'\u2021','136':'\u02C6','137':'\u2030','138':'\u0160','139':'\u2039','140':'\u0152','142':'\u017D','145':'\u2018','146':'\u2019','147':'\u201C','148':'\u201D','149':'\u2022','150':'\u2013','151':'\u2014','152':'\u02DC','153':'\u2122','154':'\u0161','155':'\u203A','156':'\u0153','158':'\u017E','159':'\u0178'}; + var invalidReferenceCodePoints = [1,2,3,4,5,6,7,8,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,64976,64977,64978,64979,64980,64981,64982,64983,64984,64985,64986,64987,64988,64989,64990,64991,64992,64993,64994,64995,64996,64997,64998,64999,65000,65001,65002,65003,65004,65005,65006,65007,65534,65535,131070,131071,196606,196607,262142,262143,327678,327679,393214,393215,458750,458751,524286,524287,589822,589823,655358,655359,720894,720895,786430,786431,851966,851967,917502,917503,983038,983039,1048574,1048575,1114110,1114111]; + + /*--------------------------------------------------------------------------*/ + + var stringFromCharCode = String.fromCharCode; + + var object = {}; + var hasOwnProperty = object.hasOwnProperty; + var has = function(object, propertyName) { + return hasOwnProperty.call(object, propertyName); + }; + + var contains = function(array, value) { + var index = -1; + var length = array.length; + while (++index < length) { + if (array[index] == value) { + return true; + } + } + return false; + }; + + var merge = function(options, defaults) { + if (!options) { + return defaults; + } + var result = {}; + var key; + for (key in defaults) { + // A `hasOwnProperty` check is not needed here, since only recognized + // option names are used anyway. Any others are ignored. + result[key] = has(options, key) ? options[key] : defaults[key]; + } + return result; + }; + + // Modified version of `ucs2encode`; see http://mths.be/punycode. + var codePointToSymbol = function(codePoint, strict) { + var output = ''; + if ((codePoint >= 0xD800 && codePoint <= 0xDFFF) || codePoint > 0x10FFFF) { + // See issue #4: + // “Otherwise, if the number is in the range 0xD800 to 0xDFFF or is + // greater than 0x10FFFF, then this is a parse error. Return a U+FFFD + // REPLACEMENT CHARACTER.” + if (strict) { + parseError('character reference outside the permissible Unicode range'); + } + return '\uFFFD'; + } + if (has(decodeMapNumeric, codePoint)) { + if (strict) { + parseError('disallowed character reference'); + } + return decodeMapNumeric[codePoint]; + } + if (strict && contains(invalidReferenceCodePoints, codePoint)) { + parseError('disallowed character reference'); + } + if (codePoint > 0xFFFF) { + codePoint -= 0x10000; + output += stringFromCharCode(codePoint >>> 10 & 0x3FF | 0xD800); + codePoint = 0xDC00 | codePoint & 0x3FF; + } + output += stringFromCharCode(codePoint); + return output; + }; + + var hexEscape = function(symbol) { + return '&#x' + symbol.charCodeAt(0).toString(16).toUpperCase() + ';'; + }; + + var parseError = function(message) { + throw Error('Parse error: ' + message); + }; + + /*--------------------------------------------------------------------------*/ + + var encode = function(string, options) { + options = merge(options, encode.options); + var strict = options.strict; + if (strict && regexInvalidRawCodePoint.test(string)) { + parseError('forbidden code point'); + } + var encodeEverything = options.encodeEverything; + var useNamedReferences = options.useNamedReferences; + var allowUnsafeSymbols = options.allowUnsafeSymbols; + if (encodeEverything) { + // Encode ASCII symbols. + string = string.replace(regexAsciiWhitelist, function(symbol) { + // Use named references if requested & possible. + if (useNamedReferences && has(encodeMap, symbol)) { + return '&' + encodeMap[symbol] + ';'; + } + return hexEscape(symbol); + }); + // Shorten a few escapes that represent two symbols, of which at least one + // is within the ASCII range. + if (useNamedReferences) { + string = string + .replace(/>\u20D2/g, '>⃒') + .replace(/<\u20D2/g, '<⃒') + .replace(/fj/g, 'fj'); + } + // Encode non-ASCII symbols. + if (useNamedReferences) { + // Encode non-ASCII symbols that can be replaced with a named reference. + string = string.replace(regexEncodeNonAscii, function(string) { + // Note: there is no need to check `has(encodeMap, string)` here. + return '&' + encodeMap[string] + ';'; + }); + } + // Note: any remaining non-ASCII symbols are handled outside of the `if`. + } else if (useNamedReferences) { + // Apply named character references. + // Encode `<>"'&` using named character references. + if (!allowUnsafeSymbols) { + string = string.replace(regexEscape, function(string) { + return '&' + encodeMap[string] + ';'; // no need to check `has()` here + }); + } + // Shorten escapes that represent two symbols, of which at least one is + // `<>"'&`. + string = string + .replace(/>\u20D2/g, '>⃒') + .replace(/<\u20D2/g, '<⃒'); + // Encode non-ASCII symbols that can be replaced with a named reference. + string = string.replace(regexEncodeNonAscii, function(string) { + // Note: there is no need to check `has(encodeMap, string)` here. + return '&' + encodeMap[string] + ';'; + }); + } else if (!allowUnsafeSymbols) { + // Encode `<>"'&` using hexadecimal escapes, now that they’re not handled + // using named character references. + string = string.replace(regexEscape, hexEscape); + } + return string + // Encode astral symbols. + .replace(regexAstralSymbols, function($0) { + // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae + var high = $0.charCodeAt(0); + var low = $0.charCodeAt(1); + var codePoint = (high - 0xD800) * 0x400 + low - 0xDC00 + 0x10000; + return '&#x' + codePoint.toString(16).toUpperCase() + ';'; + }) + // Encode any remaining BMP symbols that are not printable ASCII symbols + // using a hexadecimal escape. + .replace(regexBmpWhitelist, hexEscape); + }; + // Expose default options (so they can be overridden globally). + encode.options = { + 'allowUnsafeSymbols': false, + 'encodeEverything': false, + 'strict': false, + 'useNamedReferences': false + }; + + var decode = function(html, options) { + options = merge(options, decode.options); + var strict = options.strict; + if (strict && regexInvalidEntity.test(html)) { + parseError('malformed character reference'); + } + return html.replace(regexDecode, function($0, $1, $2, $3, $4, $5, $6, $7) { + var codePoint; + var semicolon; + var hexDigits; + var reference; + var next; + if ($1) { + // Decode decimal escapes, e.g. `𝌆`. + codePoint = $1; + semicolon = $2; + if (strict && !semicolon) { + parseError('character reference was not terminated by a semicolon'); + } + return codePointToSymbol(codePoint, strict); + } + if ($3) { + // Decode hexadecimal escapes, e.g. `𝌆`. + hexDigits = $3; + semicolon = $4; + if (strict && !semicolon) { + parseError('character reference was not terminated by a semicolon'); + } + codePoint = parseInt(hexDigits, 16); + return codePointToSymbol(codePoint, strict); + } + if ($5) { + // Decode named character references with trailing `;`, e.g. `©`. + reference = $5; + if (has(decodeMap, reference)) { + return decodeMap[reference]; + } else { + // Ambiguous ampersand; see http://mths.be/notes/ambiguous-ampersands. + if (strict) { + parseError( + 'named character reference was not terminated by a semicolon' + ); + } + return $0; + } + } + // If we’re still here, it’s a legacy reference for sure. No need for an + // extra `if` check. + // Decode named character references without trailing `;`, e.g. `&` + // This is only a parse error if it gets converted to `&`, or if it is + // followed by `=` in an attribute context. + reference = $6; + next = $7; + if (next && options.isAttributeValue) { + if (strict && next == '=') { + parseError('`&` did not start a character reference'); + } + return $0; + } else { + if (strict) { + parseError( + 'named character reference was not terminated by a semicolon' + ); + } + // Note: there is no need to check `has(decodeMapLegacy, reference)`. + return decodeMapLegacy[reference] + (next || ''); + } + }); + }; + // Expose default options (so they can be overridden globally). + decode.options = { + 'isAttributeValue': false, + 'strict': false + }; + + var escape = function(string) { + return string.replace(regexEscape, function($0) { + // Note: there is no need to check `has(escapeMap, $0)` here. + return escapeMap[$0]; + }); + }; + + /*--------------------------------------------------------------------------*/ + + var he = { + 'version': '0.5.0', + 'encode': encode, + 'decode': decode, + 'escape': escape, + 'unescape': decode + }; + + // Some AMD build optimizers, like r.js, check for specific condition patterns + // like the following: + if ( + typeof define == 'function' && + typeof define.amd == 'object' && + define.amd + ) { + define(function() { + return he; + }); + } else if (freeExports && !freeExports.nodeType) { + if (freeModule) { // in Node.js or RingoJS v0.8.0+ + freeModule.exports = he; + } else { // in Narwhal or RingoJS v0.7.0- + for (var key in he) { + has(he, key) && (freeExports[key] = he[key]); + } + } + } else { // in Rhino or a web browser + root.he = he; + } + +}(this)); diff --git a/tools/node_modules/he/man/he.1 b/tools/node_modules/he/man/he.1 new file mode 100644 index 00000000000000..3a7e50414e5133 --- /dev/null +++ b/tools/node_modules/he/man/he.1 @@ -0,0 +1,78 @@ +.Dd July 27, 2013 +.Dt he 1 +.Sh NAME +.Nm he +.Nd encode/decode HTML entities just like a browser would +.Sh SYNOPSIS +.Nm +.Op Fl -escape Ar string +.br +.Op Fl -encode Ar string +.br +.Op Fl -encode Fl -use-named-refs Fl -everything Fl -allow-unsafe Ar string +.br +.Op Fl -decode Ar string +.br +.Op Fl -decode Fl -attribute Ar string +.br +.Op Fl -decode Fl -strict Ar string +.br +.Op Fl v | -version +.br +.Op Fl h | -help +.Sh DESCRIPTION +.Nm +encodes/decodes HTML entities in strings just like a browser would. +.Sh OPTIONS +.Bl -ohang -offset +.It Sy "--escape" +Take a string of text and escape it for use in text contexts in XML or HTML documents. Only the following characters are escaped: `&`, `<`, `>`, `"`, and `'`. +.It Sy "--encode" +Take a string of text and encode any symbols that aren't printable ASCII symbols and that can be replaced with character references. For example, it would turn `©` into `©`, but it wouldn't turn `+` into `+` since there is no point in doing so. Additionally, it replaces any remaining non-ASCII symbols with a hexadecimal escape sequence (e.g. `𝌆`). The return value of this function is always valid HTML. +.It Sy "--encode --use-named-refs" +Enable the use of named character references (like `©`) in the output. If compatibility with older browsers is a concern, don't use this option. +.It Sy "--encode --everything" +Encode every symbol in the input string, even safe printable ASCII symbols. +.It Sy "--encode --allow-unsafe" +Encode non-ASCII characters only. This leaves unsafe HTML/XML symbols like `&`, `<`, `>`, `"`, and `'` intact. +.It Sy "--decode" +Takes a string of HTML and decode any named and numerical character references in it using the algorithm described in the HTML spec. +.It Sy "--decode --attribute" +Parse the input as if it was an HTML attribute value rather than a string in an HTML text content. +.It Sy "--decode --strict" +Throw an error if an invalid character reference is encountered. +.It Sy "-v, --version" +Print he's version. +.It Sy "-h, --help" +Show the help screen. +.El +.Sh EXIT STATUS +The +.Nm he +utility exits with one of the following values: +.Pp +.Bl -tag -width flag -compact +.It Li 0 +.Nm +successfully encoded/decoded the input and printed the result. +.It Li 1 +.Nm +wasn't instructed to encode/decode anything (for example, the +.Ar --help +flag was set); or, an error occurred. +.El +.Sh EXAMPLES +.Bl -ohang -offset +.It Sy "he --escape ''" +Print an escaped version of the given string that is safe for use in HTML text contexts, escaping only `&`, `<`, `>`, `"`, and `'`. +.It Sy "he --decode '©𝌆'" +Print the decoded version of the given HTML string. +.It Sy "echo\ '©𝌆'\ |\ he --decode" +Print the decoded version of the HTML string that gets piped in. +.El +.Sh BUGS +he's bug tracker is located at . +.Sh AUTHOR +Mathias Bynens +.Sh WWW + diff --git a/tools/node_modules/he/package.json b/tools/node_modules/he/package.json new file mode 100644 index 00000000000000..58e6c2f802d5e5 --- /dev/null +++ b/tools/node_modules/he/package.json @@ -0,0 +1,107 @@ +{ + "_args": [ + [ + "he@^0.5.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\remark" + ] + ], + "_from": "he@>=0.5.0 <0.6.0", + "_id": "he@0.5.0", + "_inCache": true, + "_location": "/he", + "_npmUser": { + "email": "mathias@qiwi.be", + "name": "mathias" + }, + "_npmVersion": "1.4.9", + "_phantomChildren": {}, + "_requested": { + "name": "he", + "raw": "he@^0.5.0", + "rawSpec": "^0.5.0", + "scope": null, + "spec": ">=0.5.0 <0.6.0", + "type": "range" + }, + "_requiredBy": [ + "/remark" + ], + "_resolved": "https://registry.npmjs.org/he/-/he-0.5.0.tgz", + "_shasum": "2c05ffaef90b68e860f3fd2b54ef580989277ee2", + "_shrinkwrap": null, + "_spec": "he@^0.5.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\remark", + "author": { + "name": "Mathias Bynens", + "url": "https://mathiasbynens.be/" + }, + "bin": { + "he": "bin/he" + }, + "bugs": { + "url": "https://github.com/mathiasbynens/he/issues" + }, + "dependencies": {}, + "description": "A robust HTML entities encoder/decoder with full Unicode support.", + "devDependencies": { + "coveralls": "^2.11.1", + "grunt": "^0.4.5", + "grunt-shell": "^1.0.1", + "grunt-template": "^0.2.3", + "istanbul": "^0.3.0", + "jsesc": "^0.5.0", + "lodash": "^2.4.1", + "qunit-extras": "^1.1.0", + "qunitjs": "~1.11.0", + "regenerate": "^0.6.2", + "requirejs": "^2.1.14", + "string.fromcodepoint": "^0.2.1" + }, + "directories": { + "bin": "bin", + "man": "man", + "test": "tests" + }, + "dist": { + "shasum": "2c05ffaef90b68e860f3fd2b54ef580989277ee2", + "tarball": "http://registry.npmjs.org/he/-/he-0.5.0.tgz" + }, + "files": [ + "LICENSE-MIT.txt", + "bin/", + "he.js", + "man/" + ], + "homepage": "http://mths.be/he", + "installable": true, + "keywords": [ + "decode", + "encode", + "entities", + "entity", + "html", + "string", + "unicode" + ], + "license": "MIT", + "main": "he.js", + "maintainers": [ + { + "name": "mathias", + "email": "mathias@qiwi.be" + } + ], + "man": [ + "/Users/mathias/.npm/he/0.5.0/package/man/he.1" + ], + "name": "he", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "https://github.com/mathiasbynens/he.git" + }, + "scripts": { + "test": "node tests/tests.js" + }, + "version": "0.5.0" +} diff --git a/tools/node_modules/inflight/.eslintrc b/tools/node_modules/inflight/.eslintrc new file mode 100644 index 00000000000000..b7a1550efc2b2c --- /dev/null +++ b/tools/node_modules/inflight/.eslintrc @@ -0,0 +1,17 @@ +{ + "env" : { + "node" : true + }, + "rules" : { + "semi": [2, "never"], + "strict": 0, + "quotes": [1, "single", "avoid-escape"], + "no-use-before-define": 0, + "curly": 0, + "no-underscore-dangle": 0, + "no-lonely-if": 1, + "no-unused-vars": [2, {"vars" : "all", "args" : "after-used"}], + "no-mixed-requires": 0, + "space-infix-ops": 0 + } +} diff --git a/tools/node_modules/inflight/LICENSE b/tools/node_modules/inflight/LICENSE new file mode 100644 index 00000000000000..05eeeb88c2ef4c --- /dev/null +++ b/tools/node_modules/inflight/LICENSE @@ -0,0 +1,15 @@ +The ISC License + +Copyright (c) Isaac Z. Schlueter + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR +IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/tools/node_modules/inflight/README.md b/tools/node_modules/inflight/README.md new file mode 100644 index 00000000000000..6dc8929171a8c5 --- /dev/null +++ b/tools/node_modules/inflight/README.md @@ -0,0 +1,37 @@ +# inflight + +Add callbacks to requests in flight to avoid async duplication + +## USAGE + +```javascript +var inflight = require('inflight') + +// some request that does some stuff +function req(key, callback) { + // key is any random string. like a url or filename or whatever. + // + // will return either a falsey value, indicating that the + // request for this key is already in flight, or a new callback + // which when called will call all callbacks passed to inflightk + // with the same key + callback = inflight(key, callback) + + // If we got a falsey value back, then there's already a req going + if (!callback) return + + // this is where you'd fetch the url or whatever + // callback is also once()-ified, so it can safely be assigned + // to multiple events etc. First call wins. + setTimeout(function() { + callback(null, key) + }, 100) +} + +// only assigns a single setTimeout +// when it dings, all cbs get called +req('foo', cb1) +req('foo', cb2) +req('foo', cb3) +req('foo', cb4) +``` diff --git a/tools/node_modules/inflight/inflight.js b/tools/node_modules/inflight/inflight.js new file mode 100644 index 00000000000000..8bc96cbd3730b5 --- /dev/null +++ b/tools/node_modules/inflight/inflight.js @@ -0,0 +1,44 @@ +var wrappy = require('wrappy') +var reqs = Object.create(null) +var once = require('once') + +module.exports = wrappy(inflight) + +function inflight (key, cb) { + if (reqs[key]) { + reqs[key].push(cb) + return null + } else { + reqs[key] = [cb] + return makeres(key) + } +} + +function makeres (key) { + return once(function RES () { + var cbs = reqs[key] + var len = cbs.length + var args = slice(arguments) + for (var i = 0; i < len; i++) { + cbs[i].apply(null, args) + } + if (cbs.length > len) { + // added more in the interim. + // de-zalgo, just in case, but don't call again. + cbs.splice(0, len) + process.nextTick(function () { + RES.apply(null, args) + }) + } else { + delete reqs[key] + } + }) +} + +function slice (args) { + var length = args.length + var array = [] + + for (var i = 0; i < length; i++) array[i] = args[i] + return array +} diff --git a/tools/node_modules/inflight/package.json b/tools/node_modules/inflight/package.json new file mode 100644 index 00000000000000..25a6e0b506f1cc --- /dev/null +++ b/tools/node_modules/inflight/package.json @@ -0,0 +1,85 @@ +{ + "_args": [ + [ + "inflight@^1.0.4", + "C:\\wamp\\www\\node\\tools\\node_modules\\glob" + ] + ], + "_from": "inflight@>=1.0.4 <2.0.0", + "_id": "inflight@1.0.4", + "_inCache": true, + "_location": "/inflight", + "_nodeVersion": "0.10.32", + "_npmUser": { + "email": "ogd@aoaioxxysz.net", + "name": "othiym23" + }, + "_npmVersion": "2.1.3", + "_phantomChildren": {}, + "_requested": { + "name": "inflight", + "raw": "inflight@^1.0.4", + "rawSpec": "^1.0.4", + "scope": null, + "spec": ">=1.0.4 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/glob" + ], + "_resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.4.tgz", + "_shasum": "6cbb4521ebd51ce0ec0a936bfd7657ef7e9b172a", + "_shrinkwrap": null, + "_spec": "inflight@^1.0.4", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\glob", + "author": { + "email": "i@izs.me", + "name": "Isaac Z. Schlueter", + "url": "http://blog.izs.me/" + }, + "bugs": { + "url": "https://github.com/isaacs/inflight/issues" + }, + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + }, + "description": "Add callbacks to requests in flight to avoid async duplication", + "devDependencies": { + "tap": "^0.4.10" + }, + "directories": {}, + "dist": { + "shasum": "6cbb4521ebd51ce0ec0a936bfd7657ef7e9b172a", + "tarball": "http://registry.npmjs.org/inflight/-/inflight-1.0.4.tgz" + }, + "gitHead": "c7b5531d572a867064d4a1da9e013e8910b7d1ba", + "homepage": "https://github.com/isaacs/inflight", + "installable": true, + "license": "ISC", + "main": "inflight.js", + "maintainers": [ + { + "name": "isaacs", + "email": "i@izs.me" + }, + { + "name": "othiym23", + "email": "ogd@aoaioxxysz.net" + }, + { + "name": "iarna", + "email": "me@re-becca.org" + } + ], + "name": "inflight", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git://github.com/isaacs/inflight" + }, + "scripts": { + "test": "tap test.js" + }, + "version": "1.0.4" +} diff --git a/tools/node_modules/inflight/test.js b/tools/node_modules/inflight/test.js new file mode 100644 index 00000000000000..2bb75b38814a60 --- /dev/null +++ b/tools/node_modules/inflight/test.js @@ -0,0 +1,97 @@ +var test = require('tap').test +var inf = require('./inflight.js') + + +function req (key, cb) { + cb = inf(key, cb) + if (cb) setTimeout(function () { + cb(key) + cb(key) + }) + return cb +} + +test('basic', function (t) { + var calleda = false + var a = req('key', function (k) { + t.notOk(calleda) + calleda = true + t.equal(k, 'key') + if (calledb) t.end() + }) + t.ok(a, 'first returned cb function') + + var calledb = false + var b = req('key', function (k) { + t.notOk(calledb) + calledb = true + t.equal(k, 'key') + if (calleda) t.end() + }) + + t.notOk(b, 'second should get falsey inflight response') +}) + +test('timing', function (t) { + var expect = [ + 'method one', + 'start one', + 'end one', + 'two', + 'tick', + 'three' + ] + var i = 0 + + function log (m) { + t.equal(m, expect[i], m + ' === ' + expect[i]) + ++i + if (i === expect.length) + t.end() + } + + function method (name, cb) { + log('method ' + name) + process.nextTick(cb) + } + + var one = inf('foo', function () { + log('start one') + var three = inf('foo', function () { + log('three') + }) + if (three) method('three', three) + log('end one') + }) + + method('one', one) + + var two = inf('foo', function () { + log('two') + }) + if (two) method('one', two) + + process.nextTick(log.bind(null, 'tick')) +}) + +test('parameters', function (t) { + t.plan(8) + + var a = inf('key', function (first, second, third) { + t.equal(first, 1) + t.equal(second, 2) + t.equal(third, 3) + }) + t.ok(a, 'first returned cb function') + + var b = inf('key', function (first, second, third) { + t.equal(first, 1) + t.equal(second, 2) + t.equal(third, 3) + }) + t.notOk(b, 'second should get falsey inflight response') + + setTimeout(function () { + a(1, 2, 3) + }) +}) diff --git a/tools/node_modules/inherits/LICENSE b/tools/node_modules/inherits/LICENSE new file mode 100644 index 00000000000000..dea3013d6710ee --- /dev/null +++ b/tools/node_modules/inherits/LICENSE @@ -0,0 +1,16 @@ +The ISC License + +Copyright (c) Isaac Z. Schlueter + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. + diff --git a/tools/node_modules/inherits/README.md b/tools/node_modules/inherits/README.md new file mode 100644 index 00000000000000..b1c56658557b81 --- /dev/null +++ b/tools/node_modules/inherits/README.md @@ -0,0 +1,42 @@ +Browser-friendly inheritance fully compatible with standard node.js +[inherits](http://nodejs.org/api/util.html#util_util_inherits_constructor_superconstructor). + +This package exports standard `inherits` from node.js `util` module in +node environment, but also provides alternative browser-friendly +implementation through [browser +field](https://gist.github.com/shtylman/4339901). Alternative +implementation is a literal copy of standard one located in standalone +module to avoid requiring of `util`. It also has a shim for old +browsers with no `Object.create` support. + +While keeping you sure you are using standard `inherits` +implementation in node.js environment, it allows bundlers such as +[browserify](https://github.com/substack/node-browserify) to not +include full `util` package to your client code if all you need is +just `inherits` function. It worth, because browser shim for `util` +package is large and `inherits` is often the single function you need +from it. + +It's recommended to use this package instead of +`require('util').inherits` for any code that has chances to be used +not only in node.js but in browser too. + +## usage + +```js +var inherits = require('inherits'); +// then use exactly as the standard one +``` + +## note on version ~1.0 + +Version ~1.0 had completely different motivation and is not compatible +neither with 2.0 nor with standard node.js `inherits`. + +If you are using version ~1.0 and planning to switch to ~2.0, be +careful: + +* new version uses `super_` instead of `super` for referencing + superclass +* new version overwrites current prototype while old one preserves any + existing fields on it diff --git a/tools/node_modules/inherits/inherits.js b/tools/node_modules/inherits/inherits.js new file mode 100644 index 00000000000000..29f5e24f57b5aa --- /dev/null +++ b/tools/node_modules/inherits/inherits.js @@ -0,0 +1 @@ +module.exports = require('util').inherits diff --git a/tools/node_modules/inherits/inherits_browser.js b/tools/node_modules/inherits/inherits_browser.js new file mode 100644 index 00000000000000..c1e78a75e6b52b --- /dev/null +++ b/tools/node_modules/inherits/inherits_browser.js @@ -0,0 +1,23 @@ +if (typeof Object.create === 'function') { + // implementation from standard node.js 'util' module + module.exports = function inherits(ctor, superCtor) { + ctor.super_ = superCtor + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }); + }; +} else { + // old school shim for old browsers + module.exports = function inherits(ctor, superCtor) { + ctor.super_ = superCtor + var TempCtor = function () {} + TempCtor.prototype = superCtor.prototype + ctor.prototype = new TempCtor() + ctor.prototype.constructor = ctor + } +} diff --git a/tools/node_modules/inherits/package.json b/tools/node_modules/inherits/package.json new file mode 100644 index 00000000000000..8937b3fe3d556e --- /dev/null +++ b/tools/node_modules/inherits/package.json @@ -0,0 +1,79 @@ +{ + "_args": [ + [ + "inherits@^2.0.1", + "C:\\wamp\\www\\node\\tools\\node_modules\\chokidar" + ] + ], + "_from": "inherits@>=2.0.1 <3.0.0", + "_id": "inherits@2.0.1", + "_inCache": true, + "_location": "/inherits", + "_npmUser": { + "email": "i@izs.me", + "name": "isaacs" + }, + "_npmVersion": "1.3.8", + "_phantomChildren": {}, + "_requested": { + "name": "inherits", + "raw": "inherits@^2.0.1", + "rawSpec": "^2.0.1", + "scope": null, + "spec": ">=2.0.1 <3.0.0", + "type": "range" + }, + "_requiredBy": [ + "/chokidar", + "/concat-stream", + "/glob", + "/readable-stream", + "/unherit" + ], + "_resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", + "_shasum": "b17d08d326b4423e568eff719f91b0b1cbdf69f1", + "_shrinkwrap": null, + "_spec": "inherits@^2.0.1", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\chokidar", + "browser": "./inherits_browser.js", + "bugs": { + "url": "https://github.com/isaacs/inherits/issues" + }, + "dependencies": {}, + "description": "Browser-friendly inheritance fully compatible with standard node.js inherits()", + "devDependencies": {}, + "directories": {}, + "dist": { + "shasum": "b17d08d326b4423e568eff719f91b0b1cbdf69f1", + "tarball": "http://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz" + }, + "installable": true, + "keywords": [ + "browser", + "browserify", + "class", + "inheritance", + "inherits", + "klass", + "object-oriented", + "oop" + ], + "license": "ISC", + "main": "./inherits.js", + "maintainers": [ + { + "name": "isaacs", + "email": "i@izs.me" + } + ], + "name": "inherits", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git://github.com/isaacs/inherits" + }, + "scripts": { + "test": "node test" + }, + "version": "2.0.1" +} diff --git a/tools/node_modules/inherits/test.js b/tools/node_modules/inherits/test.js new file mode 100644 index 00000000000000..fc53012d31c0cd --- /dev/null +++ b/tools/node_modules/inherits/test.js @@ -0,0 +1,25 @@ +var inherits = require('./inherits.js') +var assert = require('assert') + +function test(c) { + assert(c.constructor === Child) + assert(c.constructor.super_ === Parent) + assert(Object.getPrototypeOf(c) === Child.prototype) + assert(Object.getPrototypeOf(Object.getPrototypeOf(c)) === Parent.prototype) + assert(c instanceof Child) + assert(c instanceof Parent) +} + +function Child() { + Parent.call(this) + test(this) +} + +function Parent() {} + +inherits(Child, Parent) + +var c = new Child +test(c) + +console.log('ok') diff --git a/tools/node_modules/ini/LICENSE b/tools/node_modules/ini/LICENSE new file mode 100644 index 00000000000000..19129e315fe593 --- /dev/null +++ b/tools/node_modules/ini/LICENSE @@ -0,0 +1,15 @@ +The ISC License + +Copyright (c) Isaac Z. Schlueter and Contributors + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR +IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/tools/node_modules/ini/README.md b/tools/node_modules/ini/README.md new file mode 100644 index 00000000000000..33df258297db7f --- /dev/null +++ b/tools/node_modules/ini/README.md @@ -0,0 +1,102 @@ +An ini format parser and serializer for node. + +Sections are treated as nested objects. Items before the first +heading are saved on the object directly. + +## Usage + +Consider an ini-file `config.ini` that looks like this: + + ; this comment is being ignored + scope = global + + [database] + user = dbuser + password = dbpassword + database = use_this_database + + [paths.default] + datadir = /var/lib/data + array[] = first value + array[] = second value + array[] = third value + +You can read, manipulate and write the ini-file like so: + + var fs = require('fs') + , ini = require('ini') + + var config = ini.parse(fs.readFileSync('./config.ini', 'utf-8')) + + config.scope = 'local' + config.database.database = 'use_another_database' + config.paths.default.tmpdir = '/tmp' + delete config.paths.default.datadir + config.paths.default.array.push('fourth value') + + fs.writeFileSync('./config_modified.ini', ini.stringify(config, { section: 'section' })) + +This will result in a file called `config_modified.ini` being written +to the filesystem with the following content: + + [section] + scope=local + [section.database] + user=dbuser + password=dbpassword + database=use_another_database + [section.paths.default] + tmpdir=/tmp + array[]=first value + array[]=second value + array[]=third value + array[]=fourth value + + +## API + +### decode(inistring) + +Decode the ini-style formatted `inistring` into a nested object. + +### parse(inistring) + +Alias for `decode(inistring)` + +### encode(object, [options]) + +Encode the object `object` into an ini-style formatted string. If the +optional parameter `section` is given, then all top-level properties +of the object are put into this section and the `section`-string is +prepended to all sub-sections, see the usage example above. + +The `options` object may contain the following: + +* `section` A string which will be the first `section` in the encoded + ini data. Defaults to none. +* `whitespace` Boolean to specify whether to put whitespace around the + `=` character. By default, whitespace is omitted, to be friendly to + some persnickety old parsers that don't tolerate it well. But some + find that it's more human-readable and pretty with the whitespace. + +For backwards compatibility reasons, if a `string` options is passed +in, then it is assumed to be the `section` value. + +### stringify(object, [options]) + +Alias for `encode(object, [options])` + +### safe(val) + +Escapes the string `val` such that it is safe to be used as a key or +value in an ini-file. Basically escapes quotes. For example + + ini.safe('"unsafe string"') + +would result in + + "\"unsafe string\"" + +### unsafe(val) + +Unescapes the string `val` diff --git a/tools/node_modules/ini/ini.js b/tools/node_modules/ini/ini.js new file mode 100644 index 00000000000000..ddf5bd9cc6baed --- /dev/null +++ b/tools/node_modules/ini/ini.js @@ -0,0 +1,190 @@ + +exports.parse = exports.decode = decode +exports.stringify = exports.encode = encode + +exports.safe = safe +exports.unsafe = unsafe + +var eol = process.platform === "win32" ? "\r\n" : "\n" + +function encode (obj, opt) { + var children = [] + , out = "" + + if (typeof opt === "string") { + opt = { + section: opt, + whitespace: false + } + } else { + opt = opt || {} + opt.whitespace = opt.whitespace === true + } + + var separator = opt.whitespace ? " = " : "=" + + Object.keys(obj).forEach(function (k, _, __) { + var val = obj[k] + if (val && Array.isArray(val)) { + val.forEach(function(item) { + out += safe(k + "[]") + separator + safe(item) + "\n" + }) + } + else if (val && typeof val === "object") { + children.push(k) + } else { + out += safe(k) + separator + safe(val) + eol + } + }) + + if (opt.section && out.length) { + out = "[" + safe(opt.section) + "]" + eol + out + } + + children.forEach(function (k, _, __) { + var nk = dotSplit(k).join('\\.') + var section = (opt.section ? opt.section + "." : "") + nk + var child = encode(obj[k], { + section: section, + whitespace: opt.whitespace + }) + if (out.length && child.length) { + out += eol + } + out += child + }) + + return out +} + +function dotSplit (str) { + return str.replace(/\1/g, '\u0002LITERAL\\1LITERAL\u0002') + .replace(/\\\./g, '\u0001') + .split(/\./).map(function (part) { + return part.replace(/\1/g, '\\.') + .replace(/\2LITERAL\\1LITERAL\2/g, '\u0001') + }) +} + +function decode (str) { + var out = {} + , p = out + , section = null + , state = "START" + // section |key = value + , re = /^\[([^\]]*)\]$|^([^=]+)(=(.*))?$/i + , lines = str.split(/[\r\n]+/g) + , section = null + + lines.forEach(function (line, _, __) { + if (!line || line.match(/^\s*[;#]/)) return + var match = line.match(re) + if (!match) return + if (match[1] !== undefined) { + section = unsafe(match[1]) + p = out[section] = out[section] || {} + return + } + var key = unsafe(match[2]) + , value = match[3] ? unsafe((match[4] || "")) : true + switch (value) { + case 'true': + case 'false': + case 'null': value = JSON.parse(value) + } + + // Convert keys with '[]' suffix to an array + if (key.length > 2 && key.slice(-2) === "[]") { + key = key.substring(0, key.length - 2) + if (!p[key]) { + p[key] = [] + } + else if (!Array.isArray(p[key])) { + p[key] = [p[key]] + } + } + + // safeguard against resetting a previously defined + // array by accidentally forgetting the brackets + if (Array.isArray(p[key])) { + p[key].push(value) + } + else { + p[key] = value + } + }) + + // {a:{y:1},"a.b":{x:2}} --> {a:{y:1,b:{x:2}}} + // use a filter to return the keys that have to be deleted. + Object.keys(out).filter(function (k, _, __) { + if (!out[k] || typeof out[k] !== "object" || Array.isArray(out[k])) return false + // see if the parent section is also an object. + // if so, add it to that, and mark this one for deletion + var parts = dotSplit(k) + , p = out + , l = parts.pop() + , nl = l.replace(/\\\./g, '.') + parts.forEach(function (part, _, __) { + if (!p[part] || typeof p[part] !== "object") p[part] = {} + p = p[part] + }) + if (p === out && nl === l) return false + p[nl] = out[k] + return true + }).forEach(function (del, _, __) { + delete out[del] + }) + + return out +} + +function isQuoted (val) { + return (val.charAt(0) === "\"" && val.slice(-1) === "\"") + || (val.charAt(0) === "'" && val.slice(-1) === "'") +} + +function safe (val) { + return ( typeof val !== "string" + || val.match(/[=\r\n]/) + || val.match(/^\[/) + || (val.length > 1 + && isQuoted(val)) + || val !== val.trim() ) + ? JSON.stringify(val) + : val.replace(/;/g, '\\;').replace(/#/g, "\\#") +} + +function unsafe (val, doUnesc) { + val = (val || "").trim() + if (isQuoted(val)) { + // remove the single quotes before calling JSON.parse + if (val.charAt(0) === "'") { + val = val.substr(1, val.length - 2); + } + try { val = JSON.parse(val) } catch (_) {} + } else { + // walk the val to find the first not-escaped ; character + var esc = false + var unesc = ""; + for (var i = 0, l = val.length; i < l; i++) { + var c = val.charAt(i) + if (esc) { + if ("\\;#".indexOf(c) !== -1) + unesc += c + else + unesc += "\\" + c + esc = false + } else if (";#".indexOf(c) !== -1) { + break + } else if (c === "\\") { + esc = true + } else { + unesc += c + } + } + if (esc) + unesc += "\\" + return unesc + } + return val +} diff --git a/tools/node_modules/ini/package.json b/tools/node_modules/ini/package.json new file mode 100644 index 00000000000000..f0c92a6c2499db --- /dev/null +++ b/tools/node_modules/ini/package.json @@ -0,0 +1,80 @@ +{ + "_args": [ + [ + "ini@~1.3.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\rc" + ] + ], + "_from": "ini@>=1.3.0 <1.4.0", + "_id": "ini@1.3.4", + "_inCache": true, + "_location": "/ini", + "_nodeVersion": "2.0.1", + "_npmUser": { + "email": "isaacs@npmjs.com", + "name": "isaacs" + }, + "_npmVersion": "2.10.1", + "_phantomChildren": {}, + "_requested": { + "name": "ini", + "raw": "ini@~1.3.0", + "rawSpec": "~1.3.0", + "scope": null, + "spec": ">=1.3.0 <1.4.0", + "type": "range" + }, + "_requiredBy": [ + "/rc" + ], + "_resolved": "https://registry.npmjs.org/ini/-/ini-1.3.4.tgz", + "_shasum": "0537cb79daf59b59a1a517dff706c86ec039162e", + "_shrinkwrap": null, + "_spec": "ini@~1.3.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\rc", + "author": { + "email": "i@izs.me", + "name": "Isaac Z. Schlueter", + "url": "http://blog.izs.me/" + }, + "bugs": { + "url": "https://github.com/isaacs/ini/issues" + }, + "dependencies": {}, + "description": "An ini encoder/decoder for node", + "devDependencies": { + "tap": "^1.2.0" + }, + "directories": {}, + "dist": { + "shasum": "0537cb79daf59b59a1a517dff706c86ec039162e", + "tarball": "http://registry.npmjs.org/ini/-/ini-1.3.4.tgz" + }, + "engines": { + "node": "*" + }, + "files": [ + "ini.js" + ], + "gitHead": "4a3001abc4c608e51add9f1d2b2cadf02b8e6dea", + "homepage": "https://github.com/isaacs/ini#readme", + "installable": true, + "license": "ISC", + "main": "ini.js", + "maintainers": [ + { + "name": "isaacs", + "email": "i@izs.me" + } + ], + "name": "ini", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git://github.com/isaacs/ini.git" + }, + "scripts": { + "test": "tap test/*.js" + }, + "version": "1.3.4" +} diff --git a/tools/node_modules/irregular-plurals/irregular-plurals.json b/tools/node_modules/irregular-plurals/irregular-plurals.json new file mode 100644 index 00000000000000..10dc22d9bcf413 --- /dev/null +++ b/tools/node_modules/irregular-plurals/irregular-plurals.json @@ -0,0 +1,124 @@ +{ + "addendum": "addenda", + "aircraft": "aircraft", + "alga": "algae", + "alumna": "alumnae", + "alumnus": "alumni", + "amoeba": "amoebae", + "analysis": "analyses", + "antenna": "antennae", + "antithesis": "antitheses", + "apex": "apices", + "appendix": "appendices", + "axis": "axes", + "bacillus": "bacilli", + "bacterium": "bacteria", + "barracks": "barracks", + "basis": "bases", + "beau": "beaux", + "bison": "bison", + "bureau": "bureaus", + "cactus": "cacti", + "calf": "calves", + "child": "children", + "château": "châteaus", + "codex": "codices", + "concerto": "concerti", + "corpus": "corpora", + "crisis": "crises", + "criterion": "criteria", + "curriculum": "curricula", + "datum": "data", + "deer": "deer", + "diagnosis": "diagnoses", + "die": "dice", + "dwarf": "dwarfs", + "echo": "echoes", + "elf": "elves", + "ellipsis": "ellipses", + "embargo": "embargoes", + "emphasis": "emphases", + "erratum": "errata", + "faux pas": "faux pas", + "fez": "fezes", + "fish": "fish", + "focus": "foci", + "foot": "feet", + "formula": "formulae", + "fungus": "fungi", + "gallows": "gallows", + "genus": "genera", + "goose": "geese", + "graffito": "graffiti", + "grouse": "grouse", + "half": "halves", + "hero": "heroes", + "hoof": "hooves", + "hypothesis": "hypotheses", + "index": "indices", + "knife": "knives", + "larva": "larvae", + "leaf": "leaves", + "libretto": "libretti", + "life": "lives", + "loaf": "loaves", + "locus": "loci", + "louse": "lice", + "man": "men", + "matrix": "matrices", + "means": "means", + "medium": "media", + "memorandum": "memoranda", + "minutia": "minutiae", + "mouse": "mice", + "nebula": "nebulae", + "neurosis": "neuroses", + "news": "news", + "nucleus": "nuclei", + "oasis": "oases", + "offspring": "offspring", + "opus": "opera", + "ovum": "ova", + "ox": "oxen", + "paralysis": "paralyses", + "parenthesis": "parentheses", + "phenomenon": "phenomena", + "phylum": "phyla", + "potato": "potatoes", + "prognosis": "prognoses", + "quiz": "quizzes", + "radius": "radii", + "referendum": "referenda", + "salmon": "salmon", + "scarf": "scarves", + "self": "selves", + "series": "series", + "sheep": "sheep", + "shelf": "shelves", + "shrimp": "shrimp", + "species": "species", + "stimulus": "stimuli", + "stratum": "strata", + "swine": "swine", + "syllabus": "syllabi", + "symposium": "symposia", + "synopsis": "synopses", + "synthesis": "syntheses", + "tableau": "tableaus", + "thesis": "theses", + "thief": "thieves", + "tomato": "tomatoes", + "tooth": "teeth", + "torpedo": "torpedoes", + "trout": "trout", + "tuna": "tuna", + "vertebra": "vertebrae", + "vertex": "vertices", + "veto": "vetoes", + "vita": "vitae", + "vortex": "vortices", + "wharf": "wharves", + "wife": "wives", + "wolf": "wolves", + "woman": "women" +} diff --git a/tools/node_modules/irregular-plurals/license b/tools/node_modules/irregular-plurals/license new file mode 100644 index 00000000000000..654d0bfe943437 --- /dev/null +++ b/tools/node_modules/irregular-plurals/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tools/node_modules/irregular-plurals/package.json b/tools/node_modules/irregular-plurals/package.json new file mode 100644 index 00000000000000..42bed34eebb5b5 --- /dev/null +++ b/tools/node_modules/irregular-plurals/package.json @@ -0,0 +1,94 @@ +{ + "_args": [ + [ + "irregular-plurals@^1.0.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\plur" + ] + ], + "_from": "irregular-plurals@>=1.0.0 <2.0.0", + "_id": "irregular-plurals@1.1.0", + "_inCache": true, + "_location": "/irregular-plurals", + "_nodeVersion": "4.2.1", + "_npmUser": { + "email": "sindresorhus@gmail.com", + "name": "sindresorhus" + }, + "_npmVersion": "2.14.7", + "_phantomChildren": {}, + "_requested": { + "name": "irregular-plurals", + "raw": "irregular-plurals@^1.0.0", + "rawSpec": "^1.0.0", + "scope": null, + "spec": ">=1.0.0 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/plur" + ], + "_resolved": "https://registry.npmjs.org/irregular-plurals/-/irregular-plurals-1.1.0.tgz", + "_shasum": "35f288bebd598e0eca9e7e24fc71f43bf9b9538e", + "_shrinkwrap": null, + "_spec": "irregular-plurals@^1.0.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\plur", + "author": { + "email": "sindresorhus@gmail.com", + "name": "Sindre Sorhus", + "url": "sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/sindresorhus/irregular-plurals/issues" + }, + "dependencies": {}, + "description": "Map of nouns to their irregular plural form", + "devDependencies": { + "ava": "*", + "xo": "*" + }, + "directories": {}, + "dist": { + "shasum": "35f288bebd598e0eca9e7e24fc71f43bf9b9538e", + "tarball": "http://registry.npmjs.org/irregular-plurals/-/irregular-plurals-1.1.0.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "irregular-plurals.json" + ], + "gitHead": "ecf2d6a7906e0ed817ca0476f3900f095351396c", + "homepage": "https://github.com/sindresorhus/irregular-plurals", + "installable": true, + "keywords": [ + "hash", + "irregular", + "json", + "list", + "map", + "noun", + "nouns", + "plural", + "plurals", + "word", + "words" + ], + "license": "MIT", + "main": "irregular-plurals.json", + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + } + ], + "name": "irregular-plurals", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "https://github.com/sindresorhus/irregular-plurals" + }, + "scripts": { + "test": "xo && ava" + }, + "version": "1.1.0" +} diff --git a/tools/node_modules/irregular-plurals/readme.md b/tools/node_modules/irregular-plurals/readme.md new file mode 100644 index 00000000000000..4bb657287d8b42 --- /dev/null +++ b/tools/node_modules/irregular-plurals/readme.md @@ -0,0 +1,42 @@ +# irregular-plurals [![Build Status](https://travis-ci.org/sindresorhus/irregular-plurals.svg?branch=master)](https://travis-ci.org/sindresorhus/irregular-plurals) + +> Map of nouns to their irregular plural form +> Irregular plurals are nouns that cannot be made plural by adding an "s" or "es" to the end + +*The list is just a [JSON file](irregular-plurals.json) and can be used wherever.* + + +## Install + +``` +$ npm install --save irregular-plurals +``` + + +## Usage + +```js +const irregularPlurals = require('irregular-plurals'); + +console.log(irregularPlurals['cactus']); +//=> 'cacti' + +console.log(irregularPlurals); +/* + { + addendum: 'addenda', + alga: 'algae', + ... + } +*/ +``` + + +## Related + +- [plur](https://github.com/sindresorhus/plur) - Pluralize a word + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/tools/node_modules/is-binary-path/index.js b/tools/node_modules/is-binary-path/index.js new file mode 100644 index 00000000000000..6c8c7e72841930 --- /dev/null +++ b/tools/node_modules/is-binary-path/index.js @@ -0,0 +1,12 @@ +'use strict'; +var path = require('path'); +var binaryExtensions = require('binary-extensions'); +var exts = Object.create(null); + +binaryExtensions.forEach(function (el) { + exts[el] = true; +}); + +module.exports = function (filepath) { + return path.extname(filepath).slice(1).toLowerCase() in exts; +}; diff --git a/tools/node_modules/is-binary-path/license b/tools/node_modules/is-binary-path/license new file mode 100644 index 00000000000000..654d0bfe943437 --- /dev/null +++ b/tools/node_modules/is-binary-path/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tools/node_modules/is-binary-path/package.json b/tools/node_modules/is-binary-path/package.json new file mode 100644 index 00000000000000..55d57fccc8c245 --- /dev/null +++ b/tools/node_modules/is-binary-path/package.json @@ -0,0 +1,101 @@ +{ + "_args": [ + [ + "is-binary-path@^1.0.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\chokidar" + ] + ], + "_from": "is-binary-path@>=1.0.0 <2.0.0", + "_id": "is-binary-path@1.0.1", + "_inCache": true, + "_location": "/is-binary-path", + "_nodeVersion": "0.12.4", + "_npmUser": { + "email": "sindresorhus@gmail.com", + "name": "sindresorhus" + }, + "_npmVersion": "2.10.1", + "_phantomChildren": {}, + "_requested": { + "name": "is-binary-path", + "raw": "is-binary-path@^1.0.0", + "rawSpec": "^1.0.0", + "scope": null, + "spec": ">=1.0.0 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/chokidar" + ], + "_resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz", + "_shasum": "75f16642b480f187a711c814161fd3a4a7655898", + "_shrinkwrap": null, + "_spec": "is-binary-path@^1.0.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\chokidar", + "author": { + "email": "sindresorhus@gmail.com", + "name": "Sindre Sorhus", + "url": "sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/sindresorhus/is-binary-path/issues" + }, + "dependencies": { + "binary-extensions": "^1.0.0" + }, + "description": "Check if a filepath is a binary file", + "devDependencies": { + "ava": "0.0.4" + }, + "directories": {}, + "dist": { + "shasum": "75f16642b480f187a711c814161fd3a4a7655898", + "tarball": "http://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "ed26bd7be5e29dad159c2771cb99dd48913f9de0", + "homepage": "https://github.com/sindresorhus/is-binary-path", + "installable": true, + "keywords": [ + "bin", + "binary", + "check", + "detect", + "ext", + "extension", + "extensions", + "file", + "is", + "path" + ], + "license": "MIT", + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + }, + { + "name": "paulmillr", + "email": "paul@paulmillr.com" + }, + { + "name": "es128", + "email": "elan.shanker+npm@gmail.com" + } + ], + "name": "is-binary-path", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "https://github.com/sindresorhus/is-binary-path" + }, + "scripts": { + "test": "node test.js" + }, + "version": "1.0.1" +} diff --git a/tools/node_modules/is-binary-path/readme.md b/tools/node_modules/is-binary-path/readme.md new file mode 100644 index 00000000000000..a17d6a245d1842 --- /dev/null +++ b/tools/node_modules/is-binary-path/readme.md @@ -0,0 +1,34 @@ +# is-binary-path [![Build Status](https://travis-ci.org/sindresorhus/is-binary-path.svg?branch=master)](https://travis-ci.org/sindresorhus/is-binary-path) + +> Check if a filepath is a binary file + + +## Install + +``` +$ npm install --save is-binary-path +``` + + +## Usage + +```js +var isBinaryPath = require('is-binary-path'); + +isBinaryPath('src/unicorn.png'); +//=> true + +isBinaryPath('src/unicorn.txt'); +//=> false +``` + + +## Related + +- [`binary-extensions`](https://github.com/sindresorhus/binary-extensions) - List of binary file extensions +- [`is-text-path`](https://github.com/sindresorhus/is-text-path) - Check if a filepath is a text file + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/tools/node_modules/is-buffer/.travis.yml b/tools/node_modules/is-buffer/.travis.yml new file mode 100644 index 00000000000000..8803fc1945bf9a --- /dev/null +++ b/tools/node_modules/is-buffer/.travis.yml @@ -0,0 +1,7 @@ +language: node_js +node_js: +- 'iojs' +env: + global: + - secure: du27W3wTgZ3G183axW7w0I01lOIurx8kilMH9p45VMfNXCu8lo6FLtLIQZxJ1FYMoJLQ1yfJTu2G0rq39SotDfJumsk6tF7BjTY/HKCocZaHqCMgw0W2bcylb5kMAdLhBNPlzejpPoWa1x1axbAHNFOLQNVosG/Bavu3/kuIIps= + - secure: Ax/5aekM40o67NuTkvQqx1DhfP86ZlHTtKbv5yI+WFmbjD3FQM8b8G1J/o7doaBDev7Mp+1zDJOK2pFGtt+JGRl0lM2JUmLh6yh/b28obXyei5iuUkqzKJLfKZHMbY5QW/1i4DUM+zSXe6Kava0qnqYg5wBBnrF6gLdsVsCGNQk= diff --git a/tools/node_modules/is-buffer/.zuul.yml b/tools/node_modules/is-buffer/.zuul.yml new file mode 100644 index 00000000000000..7b84b05ede12f7 --- /dev/null +++ b/tools/node_modules/is-buffer/.zuul.yml @@ -0,0 +1,18 @@ +ui: tape +browsers: + - name: chrome + version: 39..latest + - name: firefox + version: 34..latest + - name: safari + version: 5..latest + - name: ie + version: 8..latest + - name: opera + version: 11..latest + - name: iphone + version: 5.1..latest + - name: ipad + version: 5.1..latest + - name: android + version: 5.0..latest diff --git a/tools/node_modules/is-buffer/LICENSE b/tools/node_modules/is-buffer/LICENSE new file mode 100644 index 00000000000000..0c068ceecbd48f --- /dev/null +++ b/tools/node_modules/is-buffer/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Feross Aboukhadijeh + +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. diff --git a/tools/node_modules/is-buffer/README.md b/tools/node_modules/is-buffer/README.md new file mode 100644 index 00000000000000..e6eb61adb59dc5 --- /dev/null +++ b/tools/node_modules/is-buffer/README.md @@ -0,0 +1,49 @@ +# is-buffer [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][npm-url] + +#### Determine if an object is a [`Buffer`](http://nodejs.org/api/buffer.html) (incl. [browser Buffers](https://github.com/feross/buffer)) + +[![saucelabs][saucelabs-image]][saucelabs-url] + +[travis-image]: https://img.shields.io/travis/feross/is-buffer/master.svg +[travis-url]: https://travis-ci.org/feross/is-buffer +[npm-image]: https://img.shields.io/npm/v/is-buffer.svg +[npm-url]: https://npmjs.org/package/is-buffer +[downloads-image]: https://img.shields.io/npm/dm/is-buffer.svg +[saucelabs-image]: https://saucelabs.com/browser-matrix/is-buffer.svg +[saucelabs-url]: https://saucelabs.com/u/is-buffer + +## Why not use `Buffer.isBuffer`? + +This module lets you check if an object is a `Buffer` without using `Buffer.isBuffer` (which includes the whole [buffer](https://github.com/feross/buffer) module in [browserify](http://browserify.org/)). + +It's future-proof and works in node too! + +## install + +```bash +npm install is-buffer +``` + +## usage + +```js +var isBuffer = require('is-buffer') + +isBuffer(new Buffer(4)) // true + +isBuffer(undefined) // false +isBuffer(null) // false +isBuffer('') // false +isBuffer(true) // false +isBuffer(false) // false +isBuffer(0) // false +isBuffer(1) // false +isBuffer(1.0) // false +isBuffer('string') // false +isBuffer({}) // false +isBuffer(function foo () {}) // false +``` + +## license + +MIT. Copyright (C) [Feross Aboukhadijeh](http://feross.org). diff --git a/tools/node_modules/is-buffer/index.js b/tools/node_modules/is-buffer/index.js new file mode 100644 index 00000000000000..ef028240a80ec8 --- /dev/null +++ b/tools/node_modules/is-buffer/index.js @@ -0,0 +1,17 @@ +/** + * Determine if an object is Buffer + * + * Author: Feross Aboukhadijeh + * License: MIT + * + * `npm install is-buffer` + */ + +module.exports = function (obj) { + return !!(obj != null && + (obj._isBuffer || // For Safari 5-7 (missing Object.prototype.constructor) + (obj.constructor && + typeof obj.constructor.isBuffer === 'function' && + obj.constructor.isBuffer(obj)) + )) +} diff --git a/tools/node_modules/is-buffer/package.json b/tools/node_modules/is-buffer/package.json new file mode 100644 index 00000000000000..056f9414f1d686 --- /dev/null +++ b/tools/node_modules/is-buffer/package.json @@ -0,0 +1,99 @@ +{ + "_args": [ + [ + "is-buffer@^1.0.2", + "C:\\wamp\\www\\node\\tools\\node_modules\\kind-of" + ] + ], + "_from": "is-buffer@>=1.0.2 <2.0.0", + "_id": "is-buffer@1.1.2", + "_inCache": true, + "_location": "/is-buffer", + "_nodeVersion": "4.2.6", + "_npmUser": { + "email": "feross@feross.org", + "name": "feross" + }, + "_npmVersion": "2.14.12", + "_phantomChildren": {}, + "_requested": { + "name": "is-buffer", + "raw": "is-buffer@^1.0.2", + "rawSpec": "^1.0.2", + "scope": null, + "spec": ">=1.0.2 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/kind-of" + ], + "_resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.2.tgz", + "_shasum": "fa1226588fa0048b005c47e4fb1bb1555d5edeaa", + "_shrinkwrap": null, + "_spec": "is-buffer@^1.0.2", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\kind-of", + "author": { + "email": "feross@feross.org", + "name": "Feross Aboukhadijeh", + "url": "http://feross.org/" + }, + "bugs": { + "url": "https://github.com/feross/is-buffer/issues" + }, + "dependencies": {}, + "description": "Determine if an object is Buffer", + "devDependencies": { + "standard": "^5.4.1", + "tape": "^4.0.0", + "zuul": "^3.0.0" + }, + "directories": {}, + "dist": { + "shasum": "fa1226588fa0048b005c47e4fb1bb1555d5edeaa", + "tarball": "http://registry.npmjs.org/is-buffer/-/is-buffer-1.1.2.tgz" + }, + "gitHead": "ba9a9f359e4412c90c583e14492072c9f4f2d45c", + "homepage": "http://feross.org", + "installable": true, + "keywords": [ + "arraybuffer", + "browser", + "browser buffer", + "browserify", + "buffer", + "buffers", + "core buffer", + "dataview", + "float32array", + "float64array", + "int16array", + "int32array", + "type", + "typed array", + "uint32array" + ], + "license": "MIT", + "main": "index.js", + "maintainers": [ + { + "name": "feross", + "email": "feross@feross.org" + } + ], + "name": "is-buffer", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git://github.com/feross/is-buffer.git" + }, + "scripts": { + "test": "standard && npm run test-node && npm run test-browser", + "test-browser": "zuul -- test/*.js", + "test-browser-local": "zuul --local -- test/*.js", + "test-node": "tape test/*.js" + }, + "testling": { + "files": "test/*.js" + }, + "version": "1.1.2" +} diff --git a/tools/node_modules/is-buffer/test/basic.js b/tools/node_modules/is-buffer/test/basic.js new file mode 100644 index 00000000000000..38d883b074513c --- /dev/null +++ b/tools/node_modules/is-buffer/test/basic.js @@ -0,0 +1,20 @@ +var isBuffer = require('../') +var test = require('tape') + +test('is-buffer', function (t) { + t.ok(isBuffer(new Buffer(4)), 'new Buffer(4)') + + t.notOk(isBuffer(undefined), 'undefined') + t.notOk(isBuffer(null), 'null') + t.notOk(isBuffer(''), 'empty string') + t.notOk(isBuffer(true), 'true') + t.notOk(isBuffer(false), 'false') + t.notOk(isBuffer(0), '0') + t.notOk(isBuffer(1), '1') + t.notOk(isBuffer(1.0), '1.0') + t.notOk(isBuffer('string'), 'string') + t.notOk(isBuffer({}), '{}') + t.notOk(isBuffer(function foo () {}), 'function foo () {}') + + t.end() +}) diff --git a/tools/node_modules/is-dotfile/LICENSE b/tools/node_modules/is-dotfile/LICENSE new file mode 100644 index 00000000000000..33754daecd9a43 --- /dev/null +++ b/tools/node_modules/is-dotfile/LICENSE @@ -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. diff --git a/tools/node_modules/is-dotfile/README.md b/tools/node_modules/is-dotfile/README.md new file mode 100644 index 00000000000000..d17b55ccb71865 --- /dev/null +++ b/tools/node_modules/is-dotfile/README.md @@ -0,0 +1,74 @@ +# is-dotfile [![NPM version](https://badge.fury.io/js/is-dotfile.svg)](http://badge.fury.io/js/is-dotfile) + +> Return true if a file path is (or has) a dotfile. Returns false if the path is a dot directory. + +## Install + +Install with [npm](https://www.npmjs.com/) + +```sh +$ npm i is-dotfile --save +``` + +## Usage + +```js +var isDotfile = require('is-dotfile'); +``` + +**false** + +All of the following return `false`: + +```js +isDotfile('a/b/c.js'); +isDotfile('/.git/foo'); +isDotfile('a/b/c/.git/foo'); +//=> false +``` + +**true** + +All of the following return `true`: + +```js +isDotfile('a/b/.gitignore'); +isDotfile('.gitignore'); +isDotfile('/.gitignore'); +//=> true +``` + +## Related projects + +* [dotfile-regex](https://www.npmjs.com/package/dotfile-regex): Regular expresson for matching dotfiles. | [homepage](https://github.com/regexps/dotfile-regex) +* [has-glob](https://www.npmjs.com/package/has-glob): Returns `true` if an array has a glob pattern. | [homepage](https://github.com/jonschlinkert/has-glob) +* [is-dotdir](https://www.npmjs.com/package/is-dotdir): Returns true if a path is a dot-directory. | [homepage](https://github.com/jonschlinkert/is-dotdir) +* [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://www.npmjs.com/package/is-glob) | [homepage](https://github.com/jonschlinkert/is-glob) + +## 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-dotfile/issues/new). + +## Authors + +**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 October 20, 2015._ \ No newline at end of file diff --git a/tools/node_modules/is-dotfile/index.js b/tools/node_modules/is-dotfile/index.js new file mode 100644 index 00000000000000..5a0a0caa8d1ffa --- /dev/null +++ b/tools/node_modules/is-dotfile/index.js @@ -0,0 +1,15 @@ +/*! + * is-dotfile + * + * Copyright (c) 2015 Jon Schlinkert, contributors. + * Licensed under the MIT license. + */ + +module.exports = function(str) { + if (str.charCodeAt(0) === 46 /* . */ && str.indexOf('/', 1) === -1) { + return true; + } + + var last = str.lastIndexOf('/'); + return last !== -1 ? str.charCodeAt(last + 1) === 46 /* . */ : false; +}; diff --git a/tools/node_modules/is-dotfile/package.json b/tools/node_modules/is-dotfile/package.json new file mode 100644 index 00000000000000..9285719a301392 --- /dev/null +++ b/tools/node_modules/is-dotfile/package.json @@ -0,0 +1,107 @@ +{ + "_args": [ + [ + "is-dotfile@^1.0.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\parse-glob" + ] + ], + "_from": "is-dotfile@>=1.0.0 <2.0.0", + "_id": "is-dotfile@1.0.2", + "_inCache": true, + "_location": "/is-dotfile", + "_nodeVersion": "4.2.1", + "_npmUser": { + "email": "github@sellside.com", + "name": "jonschlinkert" + }, + "_npmVersion": "2.14.7", + "_phantomChildren": {}, + "_requested": { + "name": "is-dotfile", + "raw": "is-dotfile@^1.0.0", + "rawSpec": "^1.0.0", + "scope": null, + "spec": ">=1.0.0 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/parse-glob" + ], + "_resolved": "https://registry.npmjs.org/is-dotfile/-/is-dotfile-1.0.2.tgz", + "_shasum": "2c132383f39199f8edc268ca01b9b007d205cc4d", + "_shrinkwrap": null, + "_spec": "is-dotfile@^1.0.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\parse-glob", + "author": { + "name": "Jon Schlinkert", + "url": "https://github.com/jonschlinkert" + }, + "bugs": { + "url": "https://github.com/jonschlinkert/is-dotfile/issues" + }, + "dependencies": {}, + "description": "Return true if a file path is (or has) a dotfile. Returns false if the path is a dot directory.", + "devDependencies": { + "benchmarked": "^0.1.3", + "dotfile-regex": "^0.1.2", + "mocha": "*" + }, + "directories": {}, + "dist": { + "shasum": "2c132383f39199f8edc268ca01b9b007d205cc4d", + "tarball": "http://registry.npmjs.org/is-dotfile/-/is-dotfile-1.0.2.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "df258600b0afa6403a2a840f2ec486c9d350492f", + "homepage": "https://github.com/jonschlinkert/is-dotfile", + "installable": true, + "keywords": [ + "detect", + "dot", + "dotfile", + "expression", + "file", + "filepath", + "find", + "fs", + "is", + "match", + "path", + "regex", + "regexp", + "regular" + ], + "license": "MIT", + "main": "index.js", + "maintainers": [ + { + "name": "jonschlinkert", + "email": "github@sellside.com" + } + ], + "name": "is-dotfile", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git+https://github.com/jonschlinkert/is-dotfile.git" + }, + "scripts": { + "test": "mocha" + }, + "verb": { + "related": { + "list": [ + "dotfile-regex", + "has-glob", + "is-dotdir", + "is-glob" + ] + } + }, + "version": "1.0.2" +} diff --git a/tools/node_modules/is-equal-shallow/LICENSE b/tools/node_modules/is-equal-shallow/LICENSE new file mode 100644 index 00000000000000..65f90aca8c2fff --- /dev/null +++ b/tools/node_modules/is-equal-shallow/LICENSE @@ -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. diff --git a/tools/node_modules/is-equal-shallow/README.md b/tools/node_modules/is-equal-shallow/README.md new file mode 100644 index 00000000000000..11422761f1cfc8 --- /dev/null +++ b/tools/node_modules/is-equal-shallow/README.md @@ -0,0 +1,90 @@ +# is-equal-shallow [![NPM version](https://badge.fury.io/js/is-equal-shallow.svg)](http://badge.fury.io/js/is-equal-shallow) [![Build Status](https://travis-ci.org/jonschlinkert/is-equal-shallow.svg)](https://travis-ci.org/jonschlinkert/is-equal-shallow) + +> Does a shallow comparison of two objects, returning false if the keys or values differ. + +The purpose of this lib is to do the fastest comparison possible of two objects when the values will predictably be primitives. + +* only compares objects. +* only compares the first level of each object +* values must be primitives. If a value is not a primitive, even if the values are the same, `false` is returned. + +Install with [npm](https://www.npmjs.com/) + +```sh +$ npm i is-equal-shallow --save +``` + +## Usage + +```js +var equals = require('is-equal-shallow'); +equals(object_a, object_b); +``` + +**Examples** + +```js +equals({a: true, b: true}, {a: true, b: true}); +//=> 'true' + +equals({a: true, b: false}, {c: false, b: false}); +//=> 'false' + +equals({a: true, b: false}, {a: false, b: false}); +//=> 'false' +``` + +Strict comparison for equality: + +```js +equals({a: true, b: true}, {a: true, b: 'true'}); +//=> 'false' +``` + +When values are not primitives, `false` is always returned: + +```js +equals({ b: {}}, { b: {}}); +//=> 'false' + +equals({ b: []}, { b: []}); +//=> 'false' +``` + +## Related projects + +Other object utils: + +* [clone-deep](https://github.com/jonschlinkert/clone-deep): Recursively (deep) clone JavaScript native types, like Object, Array, RegExp, Date as well as primitives. +* [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) +* [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) +* [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. + +## 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-equal-shallow/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 June 22, 2015._ \ No newline at end of file diff --git a/tools/node_modules/is-equal-shallow/index.js b/tools/node_modules/is-equal-shallow/index.js new file mode 100644 index 00000000000000..1006eef10f4801 --- /dev/null +++ b/tools/node_modules/is-equal-shallow/index.js @@ -0,0 +1,27 @@ +/*! + * is-equal-shallow + * + * Copyright (c) 2015, Jon Schlinkert. + * Licensed under the MIT License. + */ + +'use strict'; + +var isPrimitive = require('is-primitive'); + +module.exports = function isEqual(a, b) { + if (!a && !b) { return true; } + if (!a && b || a && !b) { return false; } + + var numKeysA = 0, numKeysB = 0, key; + for (key in b) { + numKeysB++; + if (!isPrimitive(b[key]) || !a.hasOwnProperty(key) || (a[key] !== b[key])) { + return false; + } + } + for (key in a) { + numKeysA++; + } + return numKeysA === numKeysB; +}; diff --git a/tools/node_modules/is-equal-shallow/package.json b/tools/node_modules/is-equal-shallow/package.json new file mode 100644 index 00000000000000..663ea907095199 --- /dev/null +++ b/tools/node_modules/is-equal-shallow/package.json @@ -0,0 +1,111 @@ +{ + "_args": [ + [ + "is-equal-shallow@^0.1.1", + "C:\\wamp\\www\\node\\tools\\node_modules\\regex-cache" + ] + ], + "_from": "is-equal-shallow@>=0.1.1 <0.2.0", + "_id": "is-equal-shallow@0.1.3", + "_inCache": true, + "_location": "/is-equal-shallow", + "_nodeVersion": "0.12.4", + "_npmUser": { + "email": "github@sellside.com", + "name": "jonschlinkert" + }, + "_npmVersion": "2.10.1", + "_phantomChildren": {}, + "_requested": { + "name": "is-equal-shallow", + "raw": "is-equal-shallow@^0.1.1", + "rawSpec": "^0.1.1", + "scope": null, + "spec": ">=0.1.1 <0.2.0", + "type": "range" + }, + "_requiredBy": [ + "/regex-cache" + ], + "_resolved": "https://registry.npmjs.org/is-equal-shallow/-/is-equal-shallow-0.1.3.tgz", + "_shasum": "2238098fc221de0bcfa5d9eac4c45d638aa1c534", + "_shrinkwrap": null, + "_spec": "is-equal-shallow@^0.1.1", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\regex-cache", + "author": { + "name": "Jon Schlinkert", + "url": "https://github.com/jonschlinkert" + }, + "bugs": { + "url": "https://github.com/jonschlinkert/is-equal-shallow/issues" + }, + "dependencies": { + "is-primitive": "^2.0.0" + }, + "description": "Does a shallow comparison of two objects, returning false if the keys or values differ.", + "devDependencies": { + "mocha": "*", + "should": "*" + }, + "directories": {}, + "dist": { + "shasum": "2238098fc221de0bcfa5d9eac4c45d638aa1c534", + "tarball": "http://registry.npmjs.org/is-equal-shallow/-/is-equal-shallow-0.1.3.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "dceb47dd9c9c21066958116e3b54b3c8c251ee4a", + "homepage": "https://github.com/jonschlinkert/is-equal-shallow", + "installable": true, + "keywords": [ + "compare", + "comparison", + "equal", + "equals", + "is", + "is-equal", + "key", + "object", + "same", + "shallow", + "value" + ], + "license": "MIT", + "main": "index.js", + "maintainers": [ + { + "name": "jonschlinkert", + "email": "github@sellside.com" + }, + { + "name": "doowb", + "email": "brian.woodward@gmail.com" + } + ], + "name": "is-equal-shallow", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git://github.com/jonschlinkert/is-equal-shallow.git" + }, + "scripts": { + "test": "mocha" + }, + "verbiage": { + "related": { + "description": "Other object utils:", + "list": [ + "clone-deep", + "for-in", + "for-own", + "is-plain-object", + "isobject" + ] + } + }, + "version": "0.1.3" +} diff --git a/tools/node_modules/is-extendable/LICENSE b/tools/node_modules/is-extendable/LICENSE new file mode 100644 index 00000000000000..65f90aca8c2fff --- /dev/null +++ b/tools/node_modules/is-extendable/LICENSE @@ -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. diff --git a/tools/node_modules/is-extendable/README.md b/tools/node_modules/is-extendable/README.md new file mode 100644 index 00000000000000..e4cfaebcb7997c --- /dev/null +++ b/tools/node_modules/is-extendable/README.md @@ -0,0 +1,72 @@ +# is-extendable [![NPM version](https://badge.fury.io/js/is-extendable.svg)](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._ \ No newline at end of file diff --git a/tools/node_modules/is-extendable/index.js b/tools/node_modules/is-extendable/index.js new file mode 100644 index 00000000000000..4ee71a44a3a678 --- /dev/null +++ b/tools/node_modules/is-extendable/index.js @@ -0,0 +1,13 @@ +/*! + * 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'); +}; diff --git a/tools/node_modules/is-extendable/package.json b/tools/node_modules/is-extendable/package.json new file mode 100644 index 00000000000000..ad5081694e4c38 --- /dev/null +++ b/tools/node_modules/is-extendable/package.json @@ -0,0 +1,105 @@ +{ + "_args": [ + [ + "is-extendable@^0.1.1", + "C:\\wamp\\www\\node\\tools\\node_modules\\object.omit" + ] + ], + "_from": "is-extendable@>=0.1.1 <0.2.0", + "_id": "is-extendable@0.1.1", + "_inCache": true, + "_location": "/is-extendable", + "_nodeVersion": "0.12.4", + "_npmUser": { + "email": "github@sellside.com", + "name": "jonschlinkert" + }, + "_npmVersion": "2.10.1", + "_phantomChildren": {}, + "_requested": { + "name": "is-extendable", + "raw": "is-extendable@^0.1.1", + "rawSpec": "^0.1.1", + "scope": null, + "spec": ">=0.1.1 <0.2.0", + "type": "range" + }, + "_requiredBy": [ + "/object.omit" + ], + "_resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", + "_shasum": "62b110e289a471418e3ec36a617d472e301dfc89", + "_shrinkwrap": null, + "_spec": "is-extendable@^0.1.1", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\object.omit", + "author": { + "name": "Jon Schlinkert", + "url": "https://github.com/jonschlinkert" + }, + "bugs": { + "url": "https://github.com/jonschlinkert/is-extendable/issues" + }, + "dependencies": {}, + "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?\"", + "devDependencies": { + "mocha": "*" + }, + "directories": {}, + "dist": { + "shasum": "62b110e289a471418e3ec36a617d472e301dfc89", + "tarball": "http://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "c36a0732e6a76931c6f66c5931d1f3e54fa44380", + "homepage": "https://github.com/jonschlinkert/is-extendable", + "installable": true, + "keywords": [ + "array", + "assign", + "check", + "date", + "extend", + "extensible", + "function", + "is", + "object", + "regex", + "test" + ], + "license": "MIT", + "main": "index.js", + "maintainers": [ + { + "name": "jonschlinkert", + "email": "github@sellside.com" + } + ], + "name": "is-extendable", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git+https://github.com/jonschlinkert/is-extendable.git" + }, + "scripts": { + "test": "mocha" + }, + "verbiage": { + "related": { + "list": [ + "assign-deep", + "extend-shallow", + "is-equal-shallow", + "is-extendable", + "is-plain-object", + "isobject", + "kind-of" + ] + } + }, + "version": "0.1.1" +} diff --git a/tools/node_modules/is-extglob/LICENSE b/tools/node_modules/is-extglob/LICENSE new file mode 100644 index 00000000000000..fa30c4cb3e4c15 --- /dev/null +++ b/tools/node_modules/is-extglob/LICENSE @@ -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. diff --git a/tools/node_modules/is-extglob/README.md b/tools/node_modules/is-extglob/README.md new file mode 100644 index 00000000000000..80e7128d64dc8e --- /dev/null +++ b/tools/node_modules/is-extglob/README.md @@ -0,0 +1,75 @@ +# is-extglob [![NPM version](https://badge.fury.io/js/is-extglob.svg)](http://badge.fury.io/js/is-extglob) [![Build Status](https://travis-ci.org/jonschlinkert/is-extglob.svg)](https://travis-ci.org/jonschlinkert/is-extglob) + +> Returns true if a string has an extglob. + +## Install with [npm](npmjs.org) + +```bash +npm i is-extglob --save +``` + +## Usage + +```js +var isExtglob = require('is-extglob'); +``` + +**True** + +```js +isExtglob('?(abc)'); +isExtglob('@(abc)'); +isExtglob('!(abc)'); +isExtglob('*(abc)'); +isExtglob('+(abc)'); +``` + +**False** + +Everything else... + +```js +isExtglob('foo.js'); +isExtglob('!foo.js'); +isExtglob('*.js'); +isExtglob('**/abc.js'); +isExtglob('abc/*.js'); +isExtglob('abc/(aaa|bbb).js'); +isExtglob('abc/[a-z].js'); +isExtglob('abc/{a,b}.js'); +isExtglob('abc/?.js'); +isExtglob('abc.js'); +isExtglob('abc/def/ghi.js'); +``` + +## Related +* [extglob](https://github.com/jonschlinkert/extglob): Extended globs. extglobs add the expressive power of regular expressions to glob patterns. +* [micromatch](https://github.com/jonschlinkert/micromatch): Glob matching for javascript/node.js. A faster alternative to minimatch (10-45x faster on avg), with all the features you're used to using in your Grunt and gulp tasks. +* [parse-glob](https://github.com/jonschlinkert/parse-glob): Parse a glob pattern into an object of tokens. + +## Run tests +Install dev dependencies. + +```bash +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-extglob/issues) + + +## Author + +**Jon Schlinkert** + ++ [github/jonschlinkert](https://github.com/jonschlinkert) ++ [twitter/jonschlinkert](http://twitter.com/jonschlinkert) + +## License +Copyright (c) 2015 Jon Schlinkert +Released under the MIT license + +*** + +_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on March 06, 2015._ \ No newline at end of file diff --git a/tools/node_modules/is-extglob/index.js b/tools/node_modules/is-extglob/index.js new file mode 100644 index 00000000000000..803047f7485ecd --- /dev/null +++ b/tools/node_modules/is-extglob/index.js @@ -0,0 +1,11 @@ +/*! + * is-extglob + * + * Copyright (c) 2014-2015, Jon Schlinkert. + * Licensed under the MIT License. + */ + +module.exports = function isExtglob(str) { + return typeof str === 'string' + && /[@?!+*]\(/.test(str); +}; diff --git a/tools/node_modules/is-extglob/package.json b/tools/node_modules/is-extglob/package.json new file mode 100644 index 00000000000000..01d2f9ea524db7 --- /dev/null +++ b/tools/node_modules/is-extglob/package.json @@ -0,0 +1,101 @@ +{ + "_args": [ + [ + "is-extglob@^1.0.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\micromatch" + ] + ], + "_from": "is-extglob@>=1.0.0 <2.0.0", + "_id": "is-extglob@1.0.0", + "_inCache": true, + "_location": "/is-extglob", + "_nodeVersion": "0.12.0", + "_npmUser": { + "email": "github@sellside.com", + "name": "jonschlinkert" + }, + "_npmVersion": "2.5.1", + "_phantomChildren": {}, + "_requested": { + "name": "is-extglob", + "raw": "is-extglob@^1.0.0", + "rawSpec": "^1.0.0", + "scope": null, + "spec": ">=1.0.0 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/extglob", + "/is-glob", + "/micromatch", + "/parse-glob" + ], + "_resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz", + "_shasum": "ac468177c4943405a092fc8f29760c6ffc6206c0", + "_shrinkwrap": null, + "_spec": "is-extglob@^1.0.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\micromatch", + "author": { + "name": "Jon Schlinkert", + "url": "https://github.com/jonschlinkert" + }, + "bugs": { + "url": "https://github.com/jonschlinkert/is-extglob/issues" + }, + "dependencies": {}, + "description": "Returns true if a string has an extglob.", + "devDependencies": { + "mocha": "*", + "should": "*" + }, + "directories": {}, + "dist": { + "shasum": "ac468177c4943405a092fc8f29760c6ffc6206c0", + "tarball": "http://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "homepage": "https://github.com/jonschlinkert/is-extglob", + "installable": true, + "keywords": [ + "bash", + "braces", + "check", + "exec", + "expression", + "extglob", + "glob", + "globbing", + "globstar", + "match", + "matches", + "pattern", + "regex", + "regular", + "string", + "test" + ], + "license": "MIT", + "main": "index.js", + "maintainers": [ + { + "name": "jonschlinkert", + "email": "github@sellside.com" + } + ], + "name": "is-extglob", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "https://github.com/jonschlinkert/is-extglob" + }, + "scripts": { + "prepublish": "browserify -o browser.js -e index.js", + "test": "mocha" + }, + "version": "1.0.0" +} diff --git a/tools/node_modules/is-fullwidth-code-point/index.js b/tools/node_modules/is-fullwidth-code-point/index.js new file mode 100644 index 00000000000000..a7d3e3855f1c24 --- /dev/null +++ b/tools/node_modules/is-fullwidth-code-point/index.js @@ -0,0 +1,46 @@ +'use strict'; +var numberIsNan = require('number-is-nan'); + +module.exports = function (x) { + if (numberIsNan(x)) { + return false; + } + + // https://github.com/nodejs/io.js/blob/cff7300a578be1b10001f2d967aaedc88aee6402/lib/readline.js#L1369 + + // code points are derived from: + // http://www.unix.org/Public/UNIDATA/EastAsianWidth.txt + if (x >= 0x1100 && ( + x <= 0x115f || // Hangul Jamo + 0x2329 === x || // LEFT-POINTING ANGLE BRACKET + 0x232a === x || // RIGHT-POINTING ANGLE BRACKET + // CJK Radicals Supplement .. Enclosed CJK Letters and Months + (0x2e80 <= x && x <= 0x3247 && x !== 0x303f) || + // Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A + 0x3250 <= x && x <= 0x4dbf || + // CJK Unified Ideographs .. Yi Radicals + 0x4e00 <= x && x <= 0xa4c6 || + // Hangul Jamo Extended-A + 0xa960 <= x && x <= 0xa97c || + // Hangul Syllables + 0xac00 <= x && x <= 0xd7a3 || + // CJK Compatibility Ideographs + 0xf900 <= x && x <= 0xfaff || + // Vertical Forms + 0xfe10 <= x && x <= 0xfe19 || + // CJK Compatibility Forms .. Small Form Variants + 0xfe30 <= x && x <= 0xfe6b || + // Halfwidth and Fullwidth Forms + 0xff01 <= x && x <= 0xff60 || + 0xffe0 <= x && x <= 0xffe6 || + // Kana Supplement + 0x1b000 <= x && x <= 0x1b001 || + // Enclosed Ideographic Supplement + 0x1f200 <= x && x <= 0x1f251 || + // CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane + 0x20000 <= x && x <= 0x3fffd)) { + return true; + } + + return false; +} diff --git a/tools/node_modules/is-fullwidth-code-point/license b/tools/node_modules/is-fullwidth-code-point/license new file mode 100644 index 00000000000000..654d0bfe943437 --- /dev/null +++ b/tools/node_modules/is-fullwidth-code-point/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tools/node_modules/is-fullwidth-code-point/package.json b/tools/node_modules/is-fullwidth-code-point/package.json new file mode 100644 index 00000000000000..837eee08148ae1 --- /dev/null +++ b/tools/node_modules/is-fullwidth-code-point/package.json @@ -0,0 +1,99 @@ +{ + "_args": [ + [ + "is-fullwidth-code-point@^1.0.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\string-width" + ] + ], + "_from": "is-fullwidth-code-point@>=1.0.0 <2.0.0", + "_id": "is-fullwidth-code-point@1.0.0", + "_inCache": true, + "_location": "/is-fullwidth-code-point", + "_nodeVersion": "0.12.5", + "_npmUser": { + "email": "sindresorhus@gmail.com", + "name": "sindresorhus" + }, + "_npmVersion": "2.11.2", + "_phantomChildren": {}, + "_requested": { + "name": "is-fullwidth-code-point", + "raw": "is-fullwidth-code-point@^1.0.0", + "rawSpec": "^1.0.0", + "scope": null, + "spec": ">=1.0.0 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/string-width" + ], + "_resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "_shasum": "ef9e31386f031a7f0d643af82fde50c457ef00cb", + "_shrinkwrap": null, + "_spec": "is-fullwidth-code-point@^1.0.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\string-width", + "author": { + "email": "sindresorhus@gmail.com", + "name": "Sindre Sorhus", + "url": "sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/sindresorhus/is-fullwidth-code-point/issues" + }, + "dependencies": { + "number-is-nan": "^1.0.0" + }, + "description": "Check if the character represented by a given Unicode code point is fullwidth", + "devDependencies": { + "ava": "0.0.4", + "code-point-at": "^1.0.0" + }, + "directories": {}, + "dist": { + "shasum": "ef9e31386f031a7f0d643af82fde50c457ef00cb", + "tarball": "http://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "f2152d357f41f82785436d428e4f8ede143b7548", + "homepage": "https://github.com/sindresorhus/is-fullwidth-code-point", + "installable": true, + "keywords": [ + "char", + "character", + "check", + "code", + "codepoint", + "detect", + "full", + "full-width", + "fullwidth", + "is", + "point", + "str", + "string", + "unicode", + "width" + ], + "license": "MIT", + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + } + ], + "name": "is-fullwidth-code-point", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "https://github.com/sindresorhus/is-fullwidth-code-point" + }, + "scripts": { + "test": "node test.js" + }, + "version": "1.0.0" +} diff --git a/tools/node_modules/is-fullwidth-code-point/readme.md b/tools/node_modules/is-fullwidth-code-point/readme.md new file mode 100644 index 00000000000000..4936464b1b4155 --- /dev/null +++ b/tools/node_modules/is-fullwidth-code-point/readme.md @@ -0,0 +1,39 @@ +# is-fullwidth-code-point [![Build Status](https://travis-ci.org/sindresorhus/is-fullwidth-code-point.svg?branch=master)](https://travis-ci.org/sindresorhus/is-fullwidth-code-point) + +> Check if the character represented by a given [Unicode code point](https://en.wikipedia.org/wiki/Code_point) is [fullwidth](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms) + + +## Install + +``` +$ npm install --save is-fullwidth-code-point +``` + + +## Usage + +```js +var isFullwidthCodePoint = require('is-fullwidth-code-point'); + +isFullwidthCodePoint('谢'.codePointAt()); +//=> true + +isFullwidthCodePoint('a'.codePointAt()); +//=> false +``` + + +## API + +### isFullwidthCodePoint(input) + +#### input + +Type: `number` + +[Code point](https://en.wikipedia.org/wiki/Code_point) of a character. + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/tools/node_modules/is-glob/LICENSE b/tools/node_modules/is-glob/LICENSE new file mode 100644 index 00000000000000..fa30c4cb3e4c15 --- /dev/null +++ b/tools/node_modules/is-glob/LICENSE @@ -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. diff --git a/tools/node_modules/is-glob/README.md b/tools/node_modules/is-glob/README.md new file mode 100644 index 00000000000000..b162542931404b --- /dev/null +++ b/tools/node_modules/is-glob/README.md @@ -0,0 +1,105 @@ +# is-glob [![NPM version](https://badge.fury.io/js/is-glob.svg)](http://badge.fury.io/js/is-glob) [![Build Status](https://travis-ci.org/jonschlinkert/is-glob.svg)](https://travis-ci.org/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 better user experience. + +Also take a look at [is-valid-glob](https://github.com/jonschlinkert/is-valid-glob) and [has-glob](https://github.com/jonschlinkert/has-glob). + +## Install + +Install with [npm](https://www.npmjs.com/) + +```sh +$ npm i is-glob --save +``` + +## Usage + +```js +var isGlob = require('is-glob'); +``` + +**True** + +Patterns that have glob characters or regex patterns will return `true`: + +```js +isGlob('!foo.js'); +isGlob('*.js'); +isGlob('**/abc.js'); +isGlob('abc/*.js'); +isGlob('abc/(aaa|bbb).js'); +isGlob('abc/[a-z].js'); +isGlob('abc/{a,b}.js'); +isGlob('abc/?.js'); +//=> true +``` + +Extglobs + +```js +isGlob('abc/@(a).js'); +isGlob('abc/!(a).js'); +isGlob('abc/+(a).js'); +isGlob('abc/*(a).js'); +isGlob('abc/?(a).js'); +//=> true +``` + +**False** + +Patterns that do not have glob patterns return `false`: + +```js +isGlob('abc.js'); +isGlob('abc/def/ghi.js'); +isGlob('foo.js'); +isGlob('abc/@.js'); +isGlob('abc/+.js'); +isGlob(); +isGlob(null); +//=> false +``` + +Arrays are also `false` (If you want to check if an array has a glob pattern, use [has-glob](https://github.com/jonschlinkert/has-glob)): + +```js +isGlob(['**/*.js']); +isGlob(['foo.js']); +//=> false +``` + +## Related + +* [has-glob](https://www.npmjs.com/package/has-glob): Returns `true` if an array has a glob pattern. | [homepage](https://github.com/jonschlinkert/has-glob) +* [is-extglob](https://www.npmjs.com/package/is-extglob): Returns true if a string has an extglob. | [homepage](https://github.com/jonschlinkert/is-extglob) +* [is-posix-bracket](https://www.npmjs.com/package/is-posix-bracket): Returns true if the given string is a POSIX bracket expression (POSIX character class). | [homepage](https://github.com/jonschlinkert/is-posix-bracket) +* [is-valid-glob](https://www.npmjs.com/package/is-valid-glob): Return true if a value is a valid glob pattern or patterns. | [homepage](https://github.com/jonschlinkert/is-valid-glob) +* [micromatch](https://www.npmjs.com/package/micromatch): Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch. Just… [more](https://www.npmjs.com/package/micromatch) | [homepage](https://github.com/jonschlinkert/micromatch) + +## Run 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-glob/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 October 02, 2015._ \ No newline at end of file diff --git a/tools/node_modules/is-glob/index.js b/tools/node_modules/is-glob/index.js new file mode 100644 index 00000000000000..ef27bba4fd75a9 --- /dev/null +++ b/tools/node_modules/is-glob/index.js @@ -0,0 +1,14 @@ +/*! + * is-glob + * + * Copyright (c) 2014-2015, Jon Schlinkert. + * Licensed under the MIT License. + */ + +var isExtglob = require('is-extglob'); + +module.exports = function isGlob(str) { + return typeof str === 'string' + && (/[*!?{}(|)[\]]/.test(str) + || isExtglob(str)); +}; \ No newline at end of file diff --git a/tools/node_modules/is-glob/package.json b/tools/node_modules/is-glob/package.json new file mode 100644 index 00000000000000..0791368cda97c4 --- /dev/null +++ b/tools/node_modules/is-glob/package.json @@ -0,0 +1,118 @@ +{ + "_args": [ + [ + "is-glob@^2.0.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\chokidar" + ] + ], + "_from": "is-glob@>=2.0.0 <3.0.0", + "_id": "is-glob@2.0.1", + "_inCache": true, + "_location": "/is-glob", + "_nodeVersion": "0.12.4", + "_npmUser": { + "email": "github@sellside.com", + "name": "jonschlinkert" + }, + "_npmVersion": "2.10.1", + "_phantomChildren": {}, + "_requested": { + "name": "is-glob", + "raw": "is-glob@^2.0.0", + "rawSpec": "^2.0.0", + "scope": null, + "spec": ">=2.0.0 <3.0.0", + "type": "range" + }, + "_requiredBy": [ + "/chokidar", + "/glob-base", + "/glob-parent", + "/micromatch", + "/parse-glob" + ], + "_resolved": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz", + "_shasum": "d096f926a3ded5600f3fdfd91198cb0888c2d863", + "_shrinkwrap": null, + "_spec": "is-glob@^2.0.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\chokidar", + "author": { + "name": "Jon Schlinkert", + "url": "https://github.com/jonschlinkert" + }, + "bugs": { + "url": "https://github.com/jonschlinkert/is-glob/issues" + }, + "dependencies": { + "is-extglob": "^1.0.0" + }, + "description": "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", + "devDependencies": { + "mocha": "*" + }, + "directories": {}, + "dist": { + "shasum": "d096f926a3ded5600f3fdfd91198cb0888c2d863", + "tarball": "http://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "d7db1b2dd559b3d5a73f89dbe72d9e9f4d6587d7", + "homepage": "https://github.com/jonschlinkert/is-glob", + "installable": true, + "keywords": [ + "bash", + "braces", + "check", + "exec", + "expression", + "extglob", + "glob", + "globbing", + "globstar", + "match", + "matches", + "pattern", + "regex", + "regular", + "string", + "test" + ], + "license": "MIT", + "main": "index.js", + "maintainers": [ + { + "name": "jonschlinkert", + "email": "github@sellside.com" + }, + { + "name": "doowb", + "email": "brian.woodward@gmail.com" + } + ], + "name": "is-glob", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git+https://github.com/jonschlinkert/is-glob.git" + }, + "scripts": { + "test": "mocha" + }, + "verb": { + "related": { + "list": [ + "has-glob", + "is-extglob", + "is-posix-bracket", + "is-valid-glob", + "micromatch" + ] + } + }, + "version": "2.0.1" +} diff --git a/tools/node_modules/is-number/LICENSE b/tools/node_modules/is-number/LICENSE new file mode 100644 index 00000000000000..fa30c4cb3e4c15 --- /dev/null +++ b/tools/node_modules/is-number/LICENSE @@ -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. diff --git a/tools/node_modules/is-number/README.md b/tools/node_modules/is-number/README.md new file mode 100644 index 00000000000000..8395f913179a7f --- /dev/null +++ b/tools/node_modules/is-number/README.md @@ -0,0 +1,103 @@ +# is-number [![NPM version](https://badge.fury.io/js/is-number.svg)](http://badge.fury.io/js/is-number) [![Build Status](https://travis-ci.org/jonschlinkert/is-number.svg)](https://travis-ci.org/jonschlinkert/is-number) + +> Returns true if the value is a number. comprehensive tests. + +To understand some of the rationale behind the decisions made in this library (and to learn about some oddities of number evaluation in JavaScript), [see this gist](https://gist.github.com/jonschlinkert/e30c70c713da325d0e81). + +## Install + +Install with [npm](https://www.npmjs.com/) + +```sh +$ npm i is-number --save +``` + +## Usage + +```js +var isNumber = require('is-number'); +``` + +### true + +See the [tests](./test.js) for more examples. + +```js +isNumber(5e3) //=> 'true' +isNumber(0xff) //=> 'true' +isNumber(-1.1) //=> 'true' +isNumber(0) //=> 'true' +isNumber(1) //=> 'true' +isNumber(1.1) //=> 'true' +isNumber(10) //=> 'true' +isNumber(10.10) //=> 'true' +isNumber(100) //=> 'true' +isNumber('-1.1') //=> 'true' +isNumber('0') //=> 'true' +isNumber('012') //=> 'true' +isNumber('0xff') //=> 'true' +isNumber('1') //=> 'true' +isNumber('1.1') //=> 'true' +isNumber('10') //=> 'true' +isNumber('10.10') //=> 'true' +isNumber('100') //=> 'true' +isNumber('5e3') //=> 'true' +isNumber(parseInt('012')) //=> 'true' +isNumber(parseFloat('012')) //=> 'true' +``` + +### False + +See the [tests](./test.js) for more examples. + +```js +isNumber('foo') //=> 'false' +isNumber([1]) //=> 'false' +isNumber([]) //=> 'false' +isNumber(function () {}) //=> 'false' +isNumber(Infinity) //=> 'false' +isNumber(NaN) //=> 'false' +isNumber(new Array('abc')) //=> 'false' +isNumber(new Array(2)) //=> 'false' +isNumber(new Buffer('abc')) //=> 'false' +isNumber(null) //=> 'false' +isNumber(undefined) //=> 'false' +isNumber({abc: 'abc'}) //=> 'false' +``` + +## Other projects + +* [even](https://www.npmjs.com/package/even): Get the even numbered items from an array. | [homepage](https://github.com/jonschlinkert/even) +* [is-even](https://www.npmjs.com/package/is-even): Return true if the given number is even. | [homepage](https://github.com/jonschlinkert/is-even) +* [is-odd](https://www.npmjs.com/package/is-odd): Returns true if the given number is odd. | [homepage](https://github.com/jonschlinkert/is-odd) +* [is-primitive](https://www.npmjs.com/package/is-primitive): Returns `true` if the value is a primitive. | [homepage](https://github.com/jonschlinkert/is-primitive) +* [kind-of](https://www.npmjs.com/package/kind-of): Get the native type of a value. | [homepage](https://github.com/jonschlinkert/kind-of) +* [odd](https://www.npmjs.com/package/odd): Get the odd numbered items from an array. | [homepage](https://github.com/jonschlinkert/odd) + +## Contributing + +Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/is-number/issues/new). + +## Run 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 November 22, 2015._ \ No newline at end of file diff --git a/tools/node_modules/is-number/index.js b/tools/node_modules/is-number/index.js new file mode 100644 index 00000000000000..96ec66d5e2fc1f --- /dev/null +++ b/tools/node_modules/is-number/index.js @@ -0,0 +1,19 @@ +/*! + * is-number + * + * Copyright (c) 2014-2015, Jon Schlinkert. + * Licensed under the MIT License. + */ + +'use strict'; + +var typeOf = require('kind-of'); + +module.exports = function isNumber(num) { + var type = typeOf(num); + if (type !== 'number' && type !== 'string') { + return false; + } + var n = +num; + return (n - n + 1) >= 0 && num !== ''; +}; diff --git a/tools/node_modules/is-number/package.json b/tools/node_modules/is-number/package.json new file mode 100644 index 00000000000000..d0deb1d07aea07 --- /dev/null +++ b/tools/node_modules/is-number/package.json @@ -0,0 +1,117 @@ +{ + "_args": [ + [ + "is-number@^2.1.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\fill-range" + ] + ], + "_from": "is-number@>=2.1.0 <3.0.0", + "_id": "is-number@2.1.0", + "_inCache": true, + "_location": "/is-number", + "_nodeVersion": "5.0.0", + "_npmUser": { + "email": "github@sellside.com", + "name": "jonschlinkert" + }, + "_npmVersion": "3.3.6", + "_phantomChildren": {}, + "_requested": { + "name": "is-number", + "raw": "is-number@^2.1.0", + "rawSpec": "^2.1.0", + "scope": null, + "spec": ">=2.1.0 <3.0.0", + "type": "range" + }, + "_requiredBy": [ + "/fill-range", + "/randomatic" + ], + "_resolved": "https://registry.npmjs.org/is-number/-/is-number-2.1.0.tgz", + "_shasum": "01fcbbb393463a548f2f466cce16dece49db908f", + "_shrinkwrap": null, + "_spec": "is-number@^2.1.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\fill-range", + "author": { + "name": "Jon Schlinkert", + "url": "https://github.com/jonschlinkert" + }, + "bugs": { + "url": "https://github.com/jonschlinkert/is-number/issues" + }, + "dependencies": { + "kind-of": "^3.0.2" + }, + "description": "Returns true if the value is a number. comprehensive tests.", + "devDependencies": { + "benchmarked": "^0.1.3", + "chalk": "^0.5.1", + "mocha": "*" + }, + "directories": {}, + "dist": { + "shasum": "01fcbbb393463a548f2f466cce16dece49db908f", + "tarball": "http://registry.npmjs.org/is-number/-/is-number-2.1.0.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "d06c6e2cc048d3cad016cb8dfb055bb14d86fffa", + "homepage": "https://github.com/jonschlinkert/is-number", + "installable": true, + "keywords": [ + "check", + "coerce", + "coercion", + "integer", + "is", + "is number", + "is-number", + "istype", + "kind of", + "math", + "number", + "test", + "type", + "typeof", + "value" + ], + "license": "MIT", + "main": "index.js", + "maintainers": [ + { + "name": "jonschlinkert", + "email": "github@sellside.com" + }, + { + "name": "doowb", + "email": "brian.woodward@gmail.com" + } + ], + "name": "is-number", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git+https://github.com/jonschlinkert/is-number.git" + }, + "scripts": { + "test": "mocha" + }, + "verb": { + "related": { + "list": [ + "even", + "is-even", + "is-odd", + "is-primitive", + "kind-of", + "odd" + ] + } + }, + "version": "2.1.0" +} diff --git a/tools/node_modules/is-primitive/LICENSE b/tools/node_modules/is-primitive/LICENSE new file mode 100644 index 00000000000000..fa30c4cb3e4c15 --- /dev/null +++ b/tools/node_modules/is-primitive/LICENSE @@ -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. diff --git a/tools/node_modules/is-primitive/README.md b/tools/node_modules/is-primitive/README.md new file mode 100644 index 00000000000000..e1c306428fda30 --- /dev/null +++ b/tools/node_modules/is-primitive/README.md @@ -0,0 +1,57 @@ +# is-primitive [![NPM version](https://badge.fury.io/js/is-primitive.svg)](http://badge.fury.io/js/is-primitive) [![Build Status](https://travis-ci.org/jonschlinkert/is-primitive.svg)](https://travis-ci.org/jonschlinkert/is-primitive) + +> Returns `true` if the value is a primitive. + +## Install with [npm](npmjs.org) + +```bash +npm i is-primitive --save +``` + +## Running tests +Install dev dependencies. + +```bash +npm i -d && npm test +``` + +## Usage + +```js +var isPrimitive = require('is-primitive'); +isPrimitive('abc'); +//=> true + +isPrimitive(42); +//=> true + +isPrimitive(false); +//=> true + +isPrimitive(true); +//=> true + +isPrimitive({}); +//=> false + +isPrimitive([]); +//=> false + +isPrimitive(function(){}); +//=> false +``` + +## Author + +**Jon Schlinkert** + ++ [github/jonschlinkert](https://github.com/jonschlinkert) ++ [twitter/jonschlinkert](http://twitter.com/jonschlinkert) + +## License +Copyright (c) 2014-2015 Jon Schlinkert +Released under the MIT license + +*** + +_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on March 16, 2015._ \ No newline at end of file diff --git a/tools/node_modules/is-primitive/index.js b/tools/node_modules/is-primitive/index.js new file mode 100644 index 00000000000000..55f11cf05b4269 --- /dev/null +++ b/tools/node_modules/is-primitive/index.js @@ -0,0 +1,13 @@ +/*! + * is-primitive + * + * Copyright (c) 2014-2015, Jon Schlinkert. + * Licensed under the MIT License. + */ + +'use strict'; + +// see http://jsperf.com/testing-value-is-primitive/7 +module.exports = function isPrimitive(value) { + return value == null || (typeof value !== 'function' && typeof value !== 'object'); +}; diff --git a/tools/node_modules/is-primitive/package.json b/tools/node_modules/is-primitive/package.json new file mode 100644 index 00000000000000..c66f3ebbdc6234 --- /dev/null +++ b/tools/node_modules/is-primitive/package.json @@ -0,0 +1,95 @@ +{ + "_args": [ + [ + "is-primitive@^2.0.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\regex-cache" + ] + ], + "_from": "is-primitive@>=2.0.0 <3.0.0", + "_id": "is-primitive@2.0.0", + "_inCache": true, + "_location": "/is-primitive", + "_nodeVersion": "0.12.0", + "_npmUser": { + "email": "github@sellside.com", + "name": "jonschlinkert" + }, + "_npmVersion": "2.5.1", + "_phantomChildren": {}, + "_requested": { + "name": "is-primitive", + "raw": "is-primitive@^2.0.0", + "rawSpec": "^2.0.0", + "scope": null, + "spec": ">=2.0.0 <3.0.0", + "type": "range" + }, + "_requiredBy": [ + "/is-equal-shallow", + "/regex-cache" + ], + "_resolved": "https://registry.npmjs.org/is-primitive/-/is-primitive-2.0.0.tgz", + "_shasum": "207bab91638499c07b2adf240a41a87210034575", + "_shrinkwrap": null, + "_spec": "is-primitive@^2.0.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\regex-cache", + "author": { + "name": "Jon Schlinkert", + "url": "https://github.com/jonschlinkert" + }, + "bugs": { + "url": "https://github.com/jonschlinkert/is-primitive/issues" + }, + "dependencies": {}, + "description": "Returns `true` if the value is a primitive. ", + "devDependencies": { + "mocha": "*", + "should": "^4.0.4" + }, + "directories": {}, + "dist": { + "shasum": "207bab91638499c07b2adf240a41a87210034575", + "tarball": "http://registry.npmjs.org/is-primitive/-/is-primitive-2.0.0.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "c512b7c95fb049aa9b1f039ddc0670611b66cce2", + "homepage": "https://github.com/jonschlinkert/is-primitive", + "installable": true, + "keywords": [ + "boolean", + "check", + "number", + "primitive", + "string", + "symbol", + "type", + "typeof", + "util" + ], + "license": { + "type": "MIT", + "url": "https://github.com/jonschlinkert/is-primitive/blob/master/LICENSE" + }, + "main": "index.js", + "maintainers": [ + { + "name": "jonschlinkert", + "email": "github@sellside.com" + } + ], + "name": "is-primitive", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git://github.com/jonschlinkert/is-primitive.git" + }, + "scripts": { + "test": "mocha" + }, + "version": "2.0.0" +} diff --git a/tools/node_modules/isarray/README.md b/tools/node_modules/isarray/README.md new file mode 100644 index 00000000000000..052a62b8d7b7ae --- /dev/null +++ b/tools/node_modules/isarray/README.md @@ -0,0 +1,54 @@ + +# isarray + +`Array#isArray` for older browsers. + +## Usage + +```js +var isArray = require('isarray'); + +console.log(isArray([])); // => true +console.log(isArray({})); // => false +``` + +## Installation + +With [npm](http://npmjs.org) do + +```bash +$ npm install isarray +``` + +Then bundle for the browser with +[browserify](https://github.com/substack/browserify). + +With [component](http://component.io) do + +```bash +$ component install juliangruber/isarray +``` + +## License + +(MIT) + +Copyright (c) 2013 Julian Gruber <julian@juliangruber.com> + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/tools/node_modules/isarray/build/build.js b/tools/node_modules/isarray/build/build.js new file mode 100644 index 00000000000000..ec58596aeebe4e --- /dev/null +++ b/tools/node_modules/isarray/build/build.js @@ -0,0 +1,209 @@ + +/** + * Require the given path. + * + * @param {String} path + * @return {Object} exports + * @api public + */ + +function require(path, parent, orig) { + var resolved = require.resolve(path); + + // lookup failed + if (null == resolved) { + orig = orig || path; + parent = parent || 'root'; + var err = new Error('Failed to require "' + orig + '" from "' + parent + '"'); + err.path = orig; + err.parent = parent; + err.require = true; + throw err; + } + + var module = require.modules[resolved]; + + // perform real require() + // by invoking the module's + // registered function + if (!module.exports) { + module.exports = {}; + module.client = module.component = true; + module.call(this, module.exports, require.relative(resolved), module); + } + + return module.exports; +} + +/** + * Registered modules. + */ + +require.modules = {}; + +/** + * Registered aliases. + */ + +require.aliases = {}; + +/** + * Resolve `path`. + * + * Lookup: + * + * - PATH/index.js + * - PATH.js + * - PATH + * + * @param {String} path + * @return {String} path or null + * @api private + */ + +require.resolve = function(path) { + if (path.charAt(0) === '/') path = path.slice(1); + var index = path + '/index.js'; + + var paths = [ + path, + path + '.js', + path + '.json', + path + '/index.js', + path + '/index.json' + ]; + + for (var i = 0; i < paths.length; i++) { + var path = paths[i]; + if (require.modules.hasOwnProperty(path)) return path; + } + + if (require.aliases.hasOwnProperty(index)) { + return require.aliases[index]; + } +}; + +/** + * Normalize `path` relative to the current path. + * + * @param {String} curr + * @param {String} path + * @return {String} + * @api private + */ + +require.normalize = function(curr, path) { + var segs = []; + + if ('.' != path.charAt(0)) return path; + + curr = curr.split('/'); + path = path.split('/'); + + for (var i = 0; i < path.length; ++i) { + if ('..' == path[i]) { + curr.pop(); + } else if ('.' != path[i] && '' != path[i]) { + segs.push(path[i]); + } + } + + return curr.concat(segs).join('/'); +}; + +/** + * Register module at `path` with callback `definition`. + * + * @param {String} path + * @param {Function} definition + * @api private + */ + +require.register = function(path, definition) { + require.modules[path] = definition; +}; + +/** + * Alias a module definition. + * + * @param {String} from + * @param {String} to + * @api private + */ + +require.alias = function(from, to) { + if (!require.modules.hasOwnProperty(from)) { + throw new Error('Failed to alias "' + from + '", it does not exist'); + } + require.aliases[to] = from; +}; + +/** + * Return a require function relative to the `parent` path. + * + * @param {String} parent + * @return {Function} + * @api private + */ + +require.relative = function(parent) { + var p = require.normalize(parent, '..'); + + /** + * lastIndexOf helper. + */ + + function lastIndexOf(arr, obj) { + var i = arr.length; + while (i--) { + if (arr[i] === obj) return i; + } + return -1; + } + + /** + * The relative require() itself. + */ + + function localRequire(path) { + var resolved = localRequire.resolve(path); + return require(resolved, parent, path); + } + + /** + * Resolve relative to the parent. + */ + + localRequire.resolve = function(path) { + var c = path.charAt(0); + if ('/' == c) return path.slice(1); + if ('.' == c) return require.normalize(p, path); + + // resolve deps by returning + // the dep in the nearest "deps" + // directory + var segs = parent.split('/'); + var i = lastIndexOf(segs, 'deps') + 1; + if (!i) i = 0; + path = segs.slice(0, i + 1).join('/') + '/deps/' + path; + return path; + }; + + /** + * Check if module is defined at `path`. + */ + + localRequire.exists = function(path) { + return require.modules.hasOwnProperty(localRequire.resolve(path)); + }; + + return localRequire; +}; +require.register("isarray/index.js", function(exports, require, module){ +module.exports = Array.isArray || function (arr) { + return Object.prototype.toString.call(arr) == '[object Array]'; +}; + +}); +require.alias("isarray/index.js", "isarray/index.js"); + diff --git a/tools/node_modules/isarray/component.json b/tools/node_modules/isarray/component.json new file mode 100644 index 00000000000000..9e31b683889015 --- /dev/null +++ b/tools/node_modules/isarray/component.json @@ -0,0 +1,19 @@ +{ + "name" : "isarray", + "description" : "Array#isArray for older browsers", + "version" : "0.0.1", + "repository" : "juliangruber/isarray", + "homepage": "https://github.com/juliangruber/isarray", + "main" : "index.js", + "scripts" : [ + "index.js" + ], + "dependencies" : {}, + "keywords": ["browser","isarray","array"], + "author": { + "name": "Julian Gruber", + "email": "mail@juliangruber.com", + "url": "http://juliangruber.com" + }, + "license": "MIT" +} diff --git a/tools/node_modules/isarray/index.js b/tools/node_modules/isarray/index.js new file mode 100644 index 00000000000000..5f5ad45d46dda9 --- /dev/null +++ b/tools/node_modules/isarray/index.js @@ -0,0 +1,3 @@ +module.exports = Array.isArray || function (arr) { + return Object.prototype.toString.call(arr) == '[object Array]'; +}; diff --git a/tools/node_modules/isarray/package.json b/tools/node_modules/isarray/package.json new file mode 100644 index 00000000000000..6e82ee5a2a164c --- /dev/null +++ b/tools/node_modules/isarray/package.json @@ -0,0 +1,75 @@ +{ + "_args": [ + [ + "isarray@0.0.1", + "C:\\wamp\\www\\node\\tools\\node_modules\\isobject" + ] + ], + "_from": "isarray@0.0.1", + "_id": "isarray@0.0.1", + "_inCache": true, + "_location": "/isarray", + "_npmUser": { + "email": "julian@juliangruber.com", + "name": "juliangruber" + }, + "_npmVersion": "1.2.18", + "_phantomChildren": {}, + "_requested": { + "name": "isarray", + "raw": "isarray@0.0.1", + "rawSpec": "0.0.1", + "scope": null, + "spec": "0.0.1", + "type": "version" + }, + "_requiredBy": [ + "/isobject", + "/readable-stream" + ], + "_resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "_shasum": "8a18acfca9a8f4177e09abfc6038939b05d1eedf", + "_shrinkwrap": null, + "_spec": "isarray@0.0.1", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\isobject", + "author": { + "email": "mail@juliangruber.com", + "name": "Julian Gruber", + "url": "http://juliangruber.com" + }, + "dependencies": {}, + "description": "Array#isArray for older browsers", + "devDependencies": { + "tap": "*" + }, + "directories": {}, + "dist": { + "shasum": "8a18acfca9a8f4177e09abfc6038939b05d1eedf", + "tarball": "http://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz" + }, + "homepage": "https://github.com/juliangruber/isarray", + "installable": true, + "keywords": [ + "array", + "browser", + "isarray" + ], + "license": "MIT", + "main": "index.js", + "maintainers": [ + { + "name": "juliangruber", + "email": "julian@juliangruber.com" + } + ], + "name": "isarray", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git://github.com/juliangruber/isarray.git" + }, + "scripts": { + "test": "tap test/*.js" + }, + "version": "0.0.1" +} diff --git a/tools/node_modules/isobject/LICENSE b/tools/node_modules/isobject/LICENSE new file mode 100644 index 00000000000000..fa30c4cb3e4c15 --- /dev/null +++ b/tools/node_modules/isobject/LICENSE @@ -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. diff --git a/tools/node_modules/isobject/README.md b/tools/node_modules/isobject/README.md new file mode 100644 index 00000000000000..29eec83281c1b3 --- /dev/null +++ b/tools/node_modules/isobject/README.md @@ -0,0 +1,81 @@ +# isobject [![NPM version](https://badge.fury.io/js/isobject.svg)](http://badge.fury.io/js/isobject) [![Build Status](https://travis-ci.org/jonschlinkert/isobject.svg)](https://travis-ci.org/jonschlinkert/isobject) + +> Returns true if the value is an object and not an array or null. + +Use [is-plain-object](https://github.com/jonschlinkert/is-plain-object) if you want only objects that are created by the `Object` constructor. + +## Install + +Install with [npm](https://www.npmjs.com/) + +```sh +$ npm i isobject --save +``` + +Install with [bower](http://bower.io/) + +```sh +$ bower install isobject --save +``` + +## Usage + +```js +var isObject = require('isobject'); +``` + +**True** + +All of the following return `true`: + +```js +isObject({}); +isObject(Object.create({})); +isObject(Object.create(Object.prototype)); +isObject(Object.create(null)); +isObject({}); +isObject(new Foo); +isObject(/foo/); +``` + +**False** + +All of the following return `false`: + +```js +isObject(); +isObject(function () {}); +isObject(1); +isObject([]); +isObject(undefined); +isObject(null); +``` + +## 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. +* [is-plain-object](https://github.com/jonschlinkert/is-plain-object): Returns true if an object was created by the `Object` constructor. +* [is-extendable](https://github.com/jonschlinkert/is-extendable): Returns true if a value is any of the object types: array, regexp, plain object,… [more](https://github.com/jonschlinkert/is-extendable) +* [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. + +## Contributing + +Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/isobject/issues/new) + +## Author + +**Jon Schlinkert** + ++ [github/jonschlinkert](https://github.com/jonschlinkert) ++ [twitter/jonschlinkert](http://twitter.com/jonschlinkert) + +## License + +Copyright © 2014-2015 [Jon Schlinkert](https://github.com/jonschlinkert) +Released under the MIT license. + +*** + +_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on July 20, 2015._ \ No newline at end of file diff --git a/tools/node_modules/isobject/index.js b/tools/node_modules/isobject/index.js new file mode 100644 index 00000000000000..66159fa933a85e --- /dev/null +++ b/tools/node_modules/isobject/index.js @@ -0,0 +1,14 @@ +/*! + * isobject + * + * Copyright (c) 2014-2015, Jon Schlinkert. + * Licensed under the MIT License. + */ + +'use strict'; + +var isArray = require('isarray'); + +module.exports = function isObject(o) { + return o != null && typeof o === 'object' && !isArray(o); +}; diff --git a/tools/node_modules/isobject/package.json b/tools/node_modules/isobject/package.json new file mode 100644 index 00000000000000..f0c0903d710e66 --- /dev/null +++ b/tools/node_modules/isobject/package.json @@ -0,0 +1,107 @@ +{ + "_args": [ + [ + "isobject@^2.0.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\fill-range" + ] + ], + "_from": "isobject@>=2.0.0 <3.0.0", + "_id": "isobject@2.0.0", + "_inCache": true, + "_location": "/isobject", + "_nodeVersion": "0.12.4", + "_npmUser": { + "email": "github@sellside.com", + "name": "jonschlinkert" + }, + "_npmVersion": "2.10.1", + "_phantomChildren": {}, + "_requested": { + "name": "isobject", + "raw": "isobject@^2.0.0", + "rawSpec": "^2.0.0", + "scope": null, + "spec": ">=2.0.0 <3.0.0", + "type": "range" + }, + "_requiredBy": [ + "/fill-range" + ], + "_resolved": "https://registry.npmjs.org/isobject/-/isobject-2.0.0.tgz", + "_shasum": "208de872bd7378c2a92af9428a3f56eb91a122c4", + "_shrinkwrap": null, + "_spec": "isobject@^2.0.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\fill-range", + "author": { + "name": "Jon Schlinkert", + "url": "https://github.com/jonschlinkert" + }, + "bugs": { + "url": "https://github.com/jonschlinkert/isobject/issues" + }, + "dependencies": { + "isarray": "0.0.1" + }, + "description": "Returns true if the value is an object and not an array or null.", + "devDependencies": { + "mocha": "*" + }, + "directories": {}, + "dist": { + "shasum": "208de872bd7378c2a92af9428a3f56eb91a122c4", + "tarball": "http://registry.npmjs.org/isobject/-/isobject-2.0.0.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "563423a8cd174564f2cf758358c690b0d3a5e5c2", + "homepage": "https://github.com/jonschlinkert/isobject", + "installable": true, + "keywords": [ + "check", + "is", + "is-object", + "isobject", + "kind", + "kind-of", + "kindof", + "native", + "object", + "type", + "typeof", + "value" + ], + "license": "MIT", + "main": "index.js", + "maintainers": [ + { + "name": "jonschlinkert", + "email": "github@sellside.com" + } + ], + "name": "isobject", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git+https://github.com/jonschlinkert/isobject.git" + }, + "scripts": { + "test": "mocha" + }, + "verb": { + "related": { + "list": [ + "assign-deep", + "extend-shallow", + "is-equal-shallow", + "is-extendable", + "is-plain-object", + "kind-of" + ] + } + }, + "version": "2.0.0" +} diff --git a/tools/node_modules/kind-of/LICENSE b/tools/node_modules/kind-of/LICENSE new file mode 100644 index 00000000000000..fa30c4cb3e4c15 --- /dev/null +++ b/tools/node_modules/kind-of/LICENSE @@ -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. diff --git a/tools/node_modules/kind-of/README.md b/tools/node_modules/kind-of/README.md new file mode 100644 index 00000000000000..bfc8e20f23c8c5 --- /dev/null +++ b/tools/node_modules/kind-of/README.md @@ -0,0 +1,237 @@ +# kind-of [![NPM version](https://badge.fury.io/js/kind-of.svg)](http://badge.fury.io/js/kind-of) [![Build Status](https://travis-ci.org/jonschlinkert/kind-of.svg)](https://travis-ci.org/jonschlinkert/kind-of) + +> Get the native type of a value. + +[](#optimizations)**What makes this so fast?** + +## Install + +Install with [npm](https://www.npmjs.com/) + +```sh +$ npm i kind-of --save +``` + +Install with [bower](http://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(/[\s\S]+/); +//=> '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' +``` + +## 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://www.npmjs.com/package/is-glob) | [homepage](https://github.com/jonschlinkert/is-glob) +* [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) +* [is-primitive](https://www.npmjs.com/package/is-primitive): Returns `true` if the value is a primitive. | [homepage](https://github.com/jonschlinkert/is-primitive) + +## 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'` + +## 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/kind-of/issues/new). + +## Author + +**Jon Schlinkert** + ++ [github/jonschlinkert](https://github.com/jonschlinkert) ++ [twitter/jonschlinkert](http://twitter.com/jonschlinkert) + +## License + +Copyright © 2014-2015 [Jon Schlinkert](https://github.com/jonschlinkert) +Released under the MIT license. + +*** + +_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on November 17, 2015._ \ No newline at end of file diff --git a/tools/node_modules/kind-of/index.js b/tools/node_modules/kind-of/index.js new file mode 100644 index 00000000000000..87938c9a2ba002 --- /dev/null +++ b/tools/node_modules/kind-of/index.js @@ -0,0 +1,113 @@ +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'; + } + + // buffer + if (typeof Buffer !== 'undefined' && 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'; +}; diff --git a/tools/node_modules/kind-of/package.json b/tools/node_modules/kind-of/package.json new file mode 100644 index 00000000000000..f72e1f02669394 --- /dev/null +++ b/tools/node_modules/kind-of/package.json @@ -0,0 +1,126 @@ +{ + "_args": [ + [ + "kind-of@^3.0.2", + "C:\\wamp\\www\\node\\tools\\node_modules\\micromatch" + ] + ], + "_from": "kind-of@>=3.0.2 <4.0.0", + "_id": "kind-of@3.0.2", + "_inCache": true, + "_location": "/kind-of", + "_nodeVersion": "5.0.0", + "_npmUser": { + "email": "github@sellside.com", + "name": "jonschlinkert" + }, + "_npmVersion": "3.3.6", + "_phantomChildren": {}, + "_requested": { + "name": "kind-of", + "raw": "kind-of@^3.0.2", + "rawSpec": "^3.0.2", + "scope": null, + "spec": ">=3.0.2 <4.0.0", + "type": "range" + }, + "_requiredBy": [ + "/is-number", + "/micromatch", + "/randomatic" + ], + "_resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.0.2.tgz", + "_shasum": "187db427046e7e90945692e6768668bd6900dea0", + "_shrinkwrap": null, + "_spec": "kind-of@^3.0.2", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\micromatch", + "author": { + "name": "Jon Schlinkert", + "url": "https://github.com/jonschlinkert" + }, + "bugs": { + "url": "https://github.com/jonschlinkert/kind-of/issues" + }, + "dependencies": { + "is-buffer": "^1.0.2" + }, + "description": "Get the native type of a value.", + "devDependencies": { + "ansi-bold": "^0.1.1", + "benchmarked": "^0.1.3", + "browserify": "^11.0.1", + "glob": "^4.3.5", + "mocha": "*", + "should": "*", + "type-of": "^2.0.1", + "typeof": "^1.0.0" + }, + "directories": {}, + "dist": { + "shasum": "187db427046e7e90945692e6768668bd6900dea0", + "tarball": "http://registry.npmjs.org/kind-of/-/kind-of-3.0.2.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "917a9701737a64abe0f77441c9ef21afca5ab397", + "homepage": "https://github.com/jonschlinkert/kind-of", + "installable": true, + "keywords": [ + "arguments", + "array", + "boolean", + "check", + "date", + "function", + "is", + "is-type", + "is-type-of", + "kind", + "kind-of", + "number", + "object", + "regexp", + "string", + "test", + "type", + "type-of", + "typeof", + "types" + ], + "license": "MIT", + "main": "index.js", + "maintainers": [ + { + "name": "jonschlinkert", + "email": "github@sellside.com" + }, + { + "name": "doowb", + "email": "brian.woodward@gmail.com" + } + ], + "name": "kind-of", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git+https://github.com/jonschlinkert/kind-of.git" + }, + "scripts": { + "prepublish": "browserify -o browser.js -e index.js -s index --bare", + "test": "mocha" + }, + "verb": { + "related": { + "list": [ + "is-glob", + "is-number", + "is-primitive" + ] + } + }, + "version": "3.0.2" +} diff --git a/tools/node_modules/log-symbols/index.js b/tools/node_modules/log-symbols/index.js new file mode 100644 index 00000000000000..4dd29fad1c370d --- /dev/null +++ b/tools/node_modules/log-symbols/index.js @@ -0,0 +1,18 @@ +'use strict'; +var chalk = require('chalk'); + +var main = { + info: chalk.blue('ℹ'), + success: chalk.green('✔'), + warning: chalk.yellow('⚠'), + error: chalk.red('✖') +}; + +var win = { + info: chalk.blue('i'), + success: chalk.green('√'), + warning: chalk.yellow('‼'), + error: chalk.red('×') +}; + +module.exports = process.platform === 'win32' ? win : main; diff --git a/tools/node_modules/log-symbols/license b/tools/node_modules/log-symbols/license new file mode 100644 index 00000000000000..654d0bfe943437 --- /dev/null +++ b/tools/node_modules/log-symbols/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tools/node_modules/log-symbols/package.json b/tools/node_modules/log-symbols/package.json new file mode 100644 index 00000000000000..d45b5747d8df36 --- /dev/null +++ b/tools/node_modules/log-symbols/package.json @@ -0,0 +1,100 @@ +{ + "_args": [ + [ + "log-symbols@^1.0.2", + "C:\\wamp\\www\\node\\tools\\node_modules\\vfile-reporter" + ] + ], + "_from": "log-symbols@>=1.0.2 <2.0.0", + "_id": "log-symbols@1.0.2", + "_inCache": true, + "_location": "/log-symbols", + "_nodeVersion": "0.12.0", + "_npmUser": { + "email": "sindresorhus@gmail.com", + "name": "sindresorhus" + }, + "_npmVersion": "2.5.1", + "_phantomChildren": {}, + "_requested": { + "name": "log-symbols", + "raw": "log-symbols@^1.0.2", + "rawSpec": "^1.0.2", + "scope": null, + "spec": ">=1.0.2 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/vfile-reporter" + ], + "_resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-1.0.2.tgz", + "_shasum": "376ff7b58ea3086a0f09facc74617eca501e1a18", + "_shrinkwrap": null, + "_spec": "log-symbols@^1.0.2", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\vfile-reporter", + "author": { + "email": "sindresorhus@gmail.com", + "name": "Sindre Sorhus", + "url": "http://sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/sindresorhus/log-symbols/issues" + }, + "dependencies": { + "chalk": "^1.0.0" + }, + "description": "Colored symbols for various log levels. Example: ✔︎ success", + "devDependencies": { + "ava": "0.0.4" + }, + "directories": {}, + "dist": { + "shasum": "376ff7b58ea3086a0f09facc74617eca501e1a18", + "tarball": "http://registry.npmjs.org/log-symbols/-/log-symbols-1.0.2.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "ffcc995a1d4efc91ceed3e536fecccc8dc517c76", + "homepage": "https://github.com/sindresorhus/log-symbols", + "installable": true, + "keywords": [ + "char", + "characters", + "cli", + "cmd", + "command-line", + "fallback", + "figure", + "figures", + "log", + "logging", + "stdout", + "symbol", + "symbols", + "terminal", + "unicode", + "win", + "windows" + ], + "license": "MIT", + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + } + ], + "name": "log-symbols", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "https://github.com/sindresorhus/log-symbols" + }, + "scripts": { + "test": "node test.js" + }, + "version": "1.0.2" +} diff --git a/tools/node_modules/log-symbols/readme.md b/tools/node_modules/log-symbols/readme.md new file mode 100644 index 00000000000000..cc7a52b498dc66 --- /dev/null +++ b/tools/node_modules/log-symbols/readme.md @@ -0,0 +1,39 @@ +# log-symbols [![Build Status](https://travis-ci.org/sindresorhus/log-symbols.svg?branch=master)](https://travis-ci.org/sindresorhus/log-symbols) + +> Colored symbols for various log levels + +Includes fallbacks for Windows CMD which only supports a [limited character set](http://en.wikipedia.org/wiki/Code_page_437). + +![](screenshot.png) + + +## Install + +```sh +$ npm install --save log-symbols +``` + + +## Usage + +```js +var logSymbols = require('log-symbols'); + +console.log(logSymbols.success, 'finished successfully!'); +// On real OSes: ✔ finished successfully! +// On Windows: √ finished successfully! +``` + +## API + +### logSymbols + +#### info +#### success +#### warning +#### error + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/tools/node_modules/log-update/index.js b/tools/node_modules/log-update/index.js new file mode 100644 index 00000000000000..09bcd87ac56c16 --- /dev/null +++ b/tools/node_modules/log-update/index.js @@ -0,0 +1,30 @@ +'use strict'; +var ansiEscapes = require('ansi-escapes'); +var cliCursor = require('cli-cursor'); + +function main(stream) { + var prevLineCount = 0; + + var render = function () { + cliCursor.hide(); + var out = [].join.call(arguments, ' ') + '\n'; + stream.write(ansiEscapes.eraseLines(prevLineCount) + out); + prevLineCount = out.split('\n').length; + }; + + render.clear = function () { + stream.write(ansiEscapes.eraseLines(prevLineCount)); + prevLineCount = 0; + }; + + render.done = function () { + prevLineCount = 0; + cliCursor.show(); + }; + + return render; +} + +module.exports = main(process.stdout); +module.exports.stderr = main(process.stderr); +module.exports.create = main; diff --git a/tools/node_modules/log-update/license b/tools/node_modules/log-update/license new file mode 100644 index 00000000000000..654d0bfe943437 --- /dev/null +++ b/tools/node_modules/log-update/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tools/node_modules/log-update/package.json b/tools/node_modules/log-update/package.json new file mode 100644 index 00000000000000..4b457fd4c5c1aa --- /dev/null +++ b/tools/node_modules/log-update/package.json @@ -0,0 +1,101 @@ +{ + "_args": [ + [ + "log-update@^1.0.1", + "C:\\wamp\\www\\node\\tools\\node_modules\\remark" + ] + ], + "_from": "log-update@>=1.0.1 <2.0.0", + "_id": "log-update@1.0.2", + "_inCache": true, + "_location": "/log-update", + "_nodeVersion": "4.1.1", + "_npmUser": { + "email": "sindresorhus@gmail.com", + "name": "sindresorhus" + }, + "_npmVersion": "2.14.4", + "_phantomChildren": {}, + "_requested": { + "name": "log-update", + "raw": "log-update@^1.0.1", + "rawSpec": "^1.0.1", + "scope": null, + "spec": ">=1.0.1 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/remark" + ], + "_resolved": "https://registry.npmjs.org/log-update/-/log-update-1.0.2.tgz", + "_shasum": "19929f64c4093d2d2e7075a1dad8af59c296b8d1", + "_shrinkwrap": null, + "_spec": "log-update@^1.0.1", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\remark", + "author": { + "email": "sindresorhus@gmail.com", + "name": "Sindre Sorhus", + "url": "sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/sindresorhus/log-update/issues" + }, + "dependencies": { + "ansi-escapes": "^1.0.0", + "cli-cursor": "^1.0.2" + }, + "description": "Log by overwriting the previous output in the terminal. Useful for rendering progress bars, animations, etc.", + "devDependencies": { + "ava": "*", + "xo": "*" + }, + "directories": {}, + "dist": { + "shasum": "19929f64c4093d2d2e7075a1dad8af59c296b8d1", + "tarball": "http://registry.npmjs.org/log-update/-/log-update-1.0.2.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "678eddf319511f1bc61060fb40d37c0bc6c9efb3", + "homepage": "https://github.com/sindresorhus/log-update", + "installable": true, + "keywords": [ + "animation", + "bar", + "cli", + "console", + "log", + "logger", + "logging", + "output", + "overwrite", + "progress", + "refresh", + "shell", + "stdout", + "term", + "terminal", + "update" + ], + "license": "MIT", + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + } + ], + "name": "log-update", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "https://github.com/sindresorhus/log-update" + }, + "scripts": { + "test": "xo && ava" + }, + "version": "1.0.2" +} diff --git a/tools/node_modules/log-update/readme.md b/tools/node_modules/log-update/readme.md new file mode 100644 index 00000000000000..331c9002330a5c --- /dev/null +++ b/tools/node_modules/log-update/readme.md @@ -0,0 +1,65 @@ +# log-update [![Build Status](https://travis-ci.org/sindresorhus/log-update.svg?branch=master)](https://travis-ci.org/sindresorhus/log-update) + +> Log by overwriting the previous output in the terminal. +> Useful for rendering progress bars, animations, etc. + +![](screenshot.gif) + + +## Install + +``` +$ npm install --save log-update +``` + + +## Usage + +```js +var logUpdate = require('log-update'); + +var i = 0; +var frames = ['-', '\\', '|', '/']; + +setInterval(function () { + var frame = frames[i++ % frames.length]; + logUpdate('\n' + ' ♥♥\n ' + frame + ' unicorns ' + frame + '\n ♥♥'); +}, 100); +``` + + +## API + +### logUpdate(text, ...) + +Log to stdout. + +### logUpdate.clear() + +Clear the logged output. + +### logUpdate.done() + +Persist the logged output. +Useful if you want to start a new log session below the current one. + +### logUpdate.stderr(text, ...) + +Log to stderr. + +### logUpdate.stderr.clear() +### logUpdate.stderr.done() + +### logUpdate.create(stream) + +Get a `logUpdate` method that logs to the specified stream. + + +## Examples + +- [speed-test](https://github.com/sindresorhus/speed-test) - Uses this module to render a spinner + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/tools/node_modules/longest-streak/LICENSE b/tools/node_modules/longest-streak/LICENSE new file mode 100644 index 00000000000000..611b67581bb8e2 --- /dev/null +++ b/tools/node_modules/longest-streak/LICENSE @@ -0,0 +1,22 @@ +(The MIT License) + +Copyright (c) 2015 Titus Wormer + +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. diff --git a/tools/node_modules/longest-streak/history.md b/tools/node_modules/longest-streak/history.md new file mode 100644 index 00000000000000..654a34d89a391f --- /dev/null +++ b/tools/node_modules/longest-streak/history.md @@ -0,0 +1,9 @@ +--- +mdast: + setext: true +--- + + + +1.0.0 / 2015-07-12 +================== diff --git a/tools/node_modules/longest-streak/index.js b/tools/node_modules/longest-streak/index.js new file mode 100644 index 00000000000000..719d5168603e4f --- /dev/null +++ b/tools/node_modules/longest-streak/index.js @@ -0,0 +1,51 @@ +'use strict'; + +/** + * Get the count of the longest repeating streak of + * `character` in `value`. + * + * @example + * longestStreak('` foo `` bar `', '`') // 2 + * + * @param {string} value - Content, coerced to string. + * @param {string} character - Single character to look + * for. + * @return {number} - Number of characters at the place + * where `character` occurs in its longest streak in + * `value`. + * @throws {Error} - when `character` is not a single + * character. + */ +function longestStreak(value, character) { + var count = 0; + var maximum = 0; + var index = -1; + var length; + + value = String(value); + length = value.length; + + if (typeof character !== 'string' || character.length !== 1) { + throw new Error('Expected character'); + } + + while (++index < length) { + if (value.charAt(index) === character) { + count++; + + if (count > maximum) { + maximum = count; + } + } else { + count = 0; + } + } + + return maximum; +} + +/* + * Expose. + */ + +module.exports = longestStreak; diff --git a/tools/node_modules/longest-streak/package.json b/tools/node_modules/longest-streak/package.json new file mode 100644 index 00000000000000..39696e63b16422 --- /dev/null +++ b/tools/node_modules/longest-streak/package.json @@ -0,0 +1,106 @@ +{ + "_args": [ + [ + "longest-streak@^1.0.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\remark" + ] + ], + "_from": "longest-streak@>=1.0.0 <2.0.0", + "_id": "longest-streak@1.0.0", + "_inCache": true, + "_location": "/longest-streak", + "_nodeVersion": "2.3.3", + "_npmUser": { + "email": "tituswormer@gmail.com", + "name": "wooorm" + }, + "_npmVersion": "2.11.3", + "_phantomChildren": {}, + "_requested": { + "name": "longest-streak", + "raw": "longest-streak@^1.0.0", + "rawSpec": "^1.0.0", + "scope": null, + "spec": ">=1.0.0 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/remark" + ], + "_resolved": "https://registry.npmjs.org/longest-streak/-/longest-streak-1.0.0.tgz", + "_shasum": "d06597c4d4c31b52ccb1f5d8f8fe7148eafd6965", + "_shrinkwrap": null, + "_spec": "longest-streak@^1.0.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\remark", + "author": { + "email": "tituswormer@gmail.com", + "name": "Titus Wormer" + }, + "bugs": { + "url": "https://github.com/wooorm/longest-streak/issues" + }, + "dependencies": {}, + "description": "Count the longest repeating streak of a character", + "devDependencies": { + "browserify": "^10.0.0", + "eslint": "^0.24.0", + "esmangle": "^1.0.0", + "istanbul": "^0.3.0", + "jscs": "^1.0.0", + "jscs-jsdoc": "^1.0.0", + "mdast": "^0.26.0", + "mdast-github": "^0.3.1", + "mdast-lint": "^0.4.1", + "mdast-yaml-config": "^0.2.0", + "mocha": "^2.0.0" + }, + "directories": {}, + "dist": { + "shasum": "d06597c4d4c31b52ccb1f5d8f8fe7148eafd6965", + "tarball": "http://registry.npmjs.org/longest-streak/-/longest-streak-1.0.0.tgz" + }, + "files": [ + "LICENSE", + "index.js" + ], + "gitHead": "77606ef995c1825d353f1a12ef7ded403df67c52", + "homepage": "https://github.com/wooorm/longest-streak#readme", + "installable": true, + "keywords": [ + "character", + "count", + "length", + "longest", + "repeating", + "streak" + ], + "license": "MIT", + "maintainers": [ + { + "name": "wooorm", + "email": "tituswormer@gmail.com" + } + ], + "name": "longest-streak", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git+https://github.com/wooorm/longest-streak.git" + }, + "scripts": { + "build": "npm run build-md && npm run build-bundle", + "build-bundle": "browserify index.js --bare -s longestStreak > longest-streak.js", + "build-md": "mdast . LICENSE --output --quiet", + "lint": "npm run lint-api && npm run lint-style", + "lint-api": "eslint .", + "lint-style": "jscs --reporter inline .", + "make": "npm run lint && npm run test-coverage", + "postbuild-bundle": "esmangle longest-streak.js > longest-streak.min.js", + "test": "npm run test-api", + "test-api": "mocha --check-leaks test.js", + "test-coverage": "istanbul cover _mocha -- --check-leaks test.js", + "test-coveralls": "istanbul cover _mocha --report lcovonly -- --check-leaks test.js", + "test-travis": "npm run test-coveralls" + }, + "version": "1.0.0" +} diff --git a/tools/node_modules/longest-streak/readme.md b/tools/node_modules/longest-streak/readme.md new file mode 100644 index 00000000000000..780c53cf7b1eda --- /dev/null +++ b/tools/node_modules/longest-streak/readme.md @@ -0,0 +1,52 @@ +# longest-streak [![Build Status](https://img.shields.io/travis/wooorm/longest-streak.svg?style=flat)](https://travis-ci.org/wooorm/longest-streak) [![Coverage Status](https://img.shields.io/coveralls/wooorm/longest-streak.svg?style=flat)](https://coveralls.io/r/wooorm/longest-streak?branch=master) + +Count the longest repeating streak of a character. + +## Installation + +[npm](https://docs.npmjs.com/cli/install): + +```bash +npm install longest-streak +``` + +**longest-streak** is also available for [bower](http://bower.io/#install-packages), +[component](https://github.com/componentjs/component), [duo](http://duojs.org/#getting-started), +and for AMD, CommonJS, and globals ([uncompressed](longest-streak.js) and +[compressed](longest-streak.min.js)). + +## Usage + +Dependencies. + +```javascript +var longestStreak = require('longest-streak'); +``` + +Process: + +```javascript +longestStreak('` foo `` bar `', '`') // 2 +``` + +## API + +### longestStreak(value, character) + +Get the count of the longest repeating streak of `character` in `value`. + +Parameters: + +* `value` (`string`) — Content, coerced to string. +* `character` (`string`) — Single character to look for. + +Returns: `number` — Number of characters at the place where `character` +occurs in its longest streak in `value`. + +Throws: + +* `Error` — when `character` is not a single character string. + +## License + +[MIT](LICENSE) @ [Titus Wormer](http://wooorm.com) diff --git a/tools/node_modules/markdown-table/History.md b/tools/node_modules/markdown-table/History.md new file mode 100644 index 00000000000000..31f82cf920115a --- /dev/null +++ b/tools/node_modules/markdown-table/History.md @@ -0,0 +1,63 @@ + +0.4.0 / 2015-04-08 +================== + +* Refactor to simplify branch ([23f8bea](https://github.com/wooorm/markdown-table/commit/23f8bea)) +* Update `.travis.yml` ([e68017e](https://github.com/wooorm/markdown-table/commit/e68017e)) +* Refactor style ([d6d7f37](https://github.com/wooorm/markdown-table/commit/d6d7f37)) +* Remove left-alignment colon for neutral columns ([6061c21](https://github.com/wooorm/markdown-table/commit/6061c21)) +* Refactor style ([7022ed1](https://github.com/wooorm/markdown-table/commit/7022ed1)) +* Update chalk ([7beb551](https://github.com/wooorm/markdown-table/commit/7beb551)) +* Update eslint ([14d61ab](https://github.com/wooorm/markdown-table/commit/14d61ab)) + +0.3.2 / 2015-01-22 +================== + + * Update test reference to include line numbers in `Readme.md` + * Update copyright notice in `LICENSE` to include 2015 + * Add link to whole license in `Readme.md` + * Add Duo as an instalation method in `Readme.md` + * Add links to installation methods in `Readme.md` + * Refactor fences code blocks in `Readme.md` + * Update usage example in `Readme.md` for changes + * Update npm script targets + * Update jscs-jsdoc + * Update eslint + +0.3.1 / 2014-12-26 +================== + + * Merge branch 'bug/dont-modify-align' + * Fix mutating `options.align` + +0.3.0 / 2014-12-19 +================== + + * Add support for multi-character values in alignment + * Remove alignment when left-aligning + * Refactor to adhere to strict jsdoc style + * Add jscs-jsdoc configuration to `.jscs.json` + * Add jscs-jsdoc as a dev-dependency + * Refactor npm scripts for changes in npm + +0.2.0 / 2014-11-29 +================== + + * Add option to specify a single alignment + * Refactor npm script targets in `package.json` + * Add link to personal website in `Readme.md` + * Add shorter description to `Readme.md`, `package.json`, `component.json`, `bower.json` + * Fix incorrect executive rights on `test.js` + * Update eslint + * Fix link to test in `Readme.md` + +0.1.0 / 2014-10-30 +================== + + * Add flat badges to `Readme.md` + * Add `.eslintrc` + * Refactor to disallow space after object keys + * Move `spec/markdown-table.spec.js` to `test.js` + * Update `.gitignore`, `.npmignore`, bower ignore + * Remove incorrect data reference in `component.json` + * Update eslint, mocha diff --git a/tools/node_modules/markdown-table/LICENSE b/tools/node_modules/markdown-table/LICENSE new file mode 100644 index 00000000000000..ce731a9cb02e09 --- /dev/null +++ b/tools/node_modules/markdown-table/LICENSE @@ -0,0 +1,22 @@ +(The MIT License) + +Copyright (c) 2014-2015 Titus Wormer + +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. diff --git a/tools/node_modules/markdown-table/Readme.md b/tools/node_modules/markdown-table/Readme.md new file mode 100644 index 00000000000000..9931cc11d2fa4b --- /dev/null +++ b/tools/node_modules/markdown-table/Readme.md @@ -0,0 +1,132 @@ +# markdown-table [![Build Status](https://img.shields.io/travis/wooorm/markdown-table.svg?style=flat)](https://travis-ci.org/wooorm/markdown-table) [![Coverage Status](https://img.shields.io/coveralls/wooorm/markdown-table.svg?style=flat)](https://coveralls.io/r/wooorm/markdown-table?branch=master) + +Generate fancy [Markdown](https://help.github.com/articles/github-flavored-markdown/#tables)/ASCII tables. + +## Installation + +[npm](https://docs.npmjs.com/cli/install): + +```bash +$ npm install markdown-table +``` + +[Component.js](https://github.com/componentjs/component): + +```bash +$ component install wooorm/markdown-table +``` + +[Bower](http://bower.io/#install-packages): + +```bash +$ bower install markdown-table +``` + +[Duo](http://duojs.org/#getting-started): + +```javascript +var table = require('wooorm/markdown-table'); +``` + +## Usage + +```javascript +var table = require('markdown-table'); + +/** + * Normal usage (defaults to left-alignment): + */ + +table([ + ['Branch', 'Commit'], + ['master', '0123456789abcdef'], + ['staging', 'fedcba9876543210'] +]); +/* + * | Branch | Commit | + * | ------- | ---------------- | + * | master | 0123456789abcdef | + * | staging | fedcba9876543210 | + */ + +/** + * With alignment: + */ + +table([ + ['Beep', 'No.', 'Boop'], + ['beep', '1024', 'xyz'], + ['boop', '3388450', 'tuv'], + ['foo', '10106', 'qrstuv'], + ['bar', '45', 'lmno'] +], { + 'align': ['l', 'c', 'r'] +}); +/* + * | Beep | No. | Boop | + * | :--- | :-----: | -----: | + * | beep | 1024 | xyz | + * | boop | 3388450 | tuv | + * | foo | 10106 | qrstuv | + * | bar | 45 | lmno | + */ + +/** + * Alignment on dots: + */ + +table([ + ['No.'], + ['0.1.2'], + ['11.22.33'], + ['5.6.'], + ['1.22222'], +], { + 'align': '.' +}); +/* + * | No. | + * | :---------: | + * | 0.1.2 | + * | 11.22.33 | + * | 5.6. | + * | 1.22222 | + */ +``` + +## API + +### markdownTable(table, options?) + +Turns a given matrix of strings (an array of arrays of strings) into a table. + +The following options are available: + +- `options.align` — String or array of strings, the strings being either `"l"` (left), `"r"` (right), `c` (center), or `.` (dot). Other values are treated as `""`, which doesn’t place the colon but does left align. _Only the lowercased first character is used, so `Right` is fine_; +- `options.delimiter` — Value to insert between cells. Carefull, non-pipe values will break GitHub Flavored Markdown; +- `options.start` — Value to insert at the beginning of every row. +- `options.end` — Value to insert at the end of every row. +- `options.rule` — Whether to display a rule between the header and the body of the table. Carefull, will break GitHub Flavored Markdown when `false`; +- `options.stringLength` — The method to detect the length of a cell (see below). + +### options.stringLength(cell) + +ANSI-sequences mess up tables on terminals. To fix this, you have to pass in a `stringLength` option to detect the “visible” length of a cell. + +```javascript +var chalk = require('chalk'); + +function stringLength(cell) { + return chalk.stripColor(cell).length; +} +``` + +See the [tests for an example](test.js#L368-L375). + +## Inspiration + +The original idea and basic implementation was inspired by James Halliday's [text-table](https://github.com/substack/text-table) library. + +## License + +[MIT](LICENSE) © [Titus Wormer](http://wooorm.com) diff --git a/tools/node_modules/markdown-table/index.js b/tools/node_modules/markdown-table/index.js new file mode 100644 index 00000000000000..8b64246a2d4cce --- /dev/null +++ b/tools/node_modules/markdown-table/index.js @@ -0,0 +1,284 @@ +'use strict'; + +/* + * Useful expressions. + */ + +var EXPRESSION_DOT = /\./; +var EXPRESSION_LAST_DOT = /\.[^.]*$/; + +/* + * Allowed alignment values. + */ + +var LEFT = 'l'; +var RIGHT = 'r'; +var CENTER = 'c'; +var DOT = '.'; +var NULL = ''; + +var ALLIGNMENT = [LEFT, RIGHT, CENTER, DOT, NULL]; + +/* + * Characters. + */ + +var COLON = ':'; +var DASH = '-'; +var PIPE = '|'; +var SPACE = ' '; +var NEW_LINE = '\n'; + +/** + * Get the length of `value`. + * + * @param {string} value + * @return {number} + */ +function lengthNoop(value) { + return String(value).length; +} + +/** + * Get a string consisting of `length` `character`s. + * + * @param {number} length + * @param {string} [character=' '] + * @return {string} + */ +function pad(length, character) { + return Array(length + 1).join(character || SPACE); +} + +/** + * Get the position of the last dot in `value`. + * + * @param {string} value + * @return {number} + */ +function dotindex(value) { + var match = EXPRESSION_LAST_DOT.exec(value); + + return match ? match.index + 1 : value.length; +} + +/** + * Create a table from a matrix of strings. + * + * @param {Array.>} table + * @param {Object?} options + * @param {boolean?} [options.rule=true] + * @param {string?} [options.delimiter=" | "] + * @param {string?} [options.start="| "] + * @param {string?} [options.end=" |"] + * @param {Array.?} options.align + * @param {function(string)?} options.stringLength + * @return {string} Pretty table + */ +function markdownTable(table, options) { + var settings = options || {}; + var delimiter = settings.delimiter; + var start = settings.start; + var end = settings.end; + var alignment = settings.align; + var calculateStringLength = settings.stringLength || lengthNoop; + var cellCount = 0; + var rowIndex = -1; + var rowLength = table.length; + var sizes = []; + var align; + var rule; + var rows; + var row; + var cells; + var index; + var position; + var size; + var value; + var spacing; + var before; + var after; + + alignment = alignment ? alignment.concat() : []; + + if (delimiter === null || delimiter === undefined) { + delimiter = SPACE + PIPE + SPACE; + } + + if (start === null || start === undefined) { + start = PIPE + SPACE; + } + + if (end === null || end === undefined) { + end = SPACE + PIPE; + } + + while (++rowIndex < rowLength) { + row = table[rowIndex]; + + index = -1; + + if (row.length > cellCount) { + cellCount = row.length; + } + + while (++index < cellCount) { + position = row[index] ? dotindex(row[index]) : null; + + if (!sizes[index]) { + sizes[index] = 3; + } + + if (position > sizes[index]) { + sizes[index] = position; + } + } + } + + if (typeof alignment === 'string') { + alignment = pad(cellCount, alignment).split(''); + } + + /* + * Make sure only valid alignments are used. + */ + + index = -1; + + while (++index < cellCount) { + align = alignment[index]; + + if (typeof align === 'string') { + align = align.charAt(0).toLowerCase(); + } + + if (ALLIGNMENT.indexOf(align) === -1) { + align = NULL; + } + + alignment[index] = align; + } + + rowIndex = -1; + rows = []; + + while (++rowIndex < rowLength) { + row = table[rowIndex]; + + index = -1; + cells = []; + + while (++index < cellCount) { + value = row[index]; + + if (value === null || value === undefined) { + value = ''; + } else { + value = String(value); + } + + if (alignment[index] !== DOT) { + cells[index] = value; + } else { + position = dotindex(value); + + size = sizes[index] + + (EXPRESSION_DOT.test(value) ? 0 : 1) - + (calculateStringLength(value) - position); + + cells[index] = value + pad(size - 1); + } + } + + rows[rowIndex] = cells; + } + + sizes = []; + rowIndex = -1; + + while (++rowIndex < rowLength) { + cells = rows[rowIndex]; + + index = -1; + + while (++index < cellCount) { + value = cells[index]; + + if (!sizes[index]) { + sizes[index] = 3; + } + + size = calculateStringLength(value); + + if (size > sizes[index]) { + sizes[index] = size; + } + } + } + + rowIndex = -1; + + while (++rowIndex < rowLength) { + cells = rows[rowIndex]; + + index = -1; + + while (++index < cellCount) { + value = cells[index]; + + position = sizes[index] - (calculateStringLength(value) || 0); + spacing = pad(position); + + if (alignment[index] === RIGHT || alignment[index] === DOT) { + value = spacing + value; + } else if (alignment[index] !== CENTER) { + value = value + spacing; + } else { + position = position / 2; + + if (position % 1 === 0) { + before = position; + after = position; + } else { + before = position + 0.5; + after = position - 0.5; + } + + value = pad(before) + value + pad(after); + } + + cells[index] = value; + } + + rows[rowIndex] = cells.join(delimiter); + } + + if (settings.rule !== false) { + index = -1; + rule = []; + + while (++index < cellCount) { + align = alignment[index]; + + /* + * When `align` is left, don't add colons. + */ + + value = align === RIGHT || align === NULL ? DASH : COLON; + value += pad(sizes[index] - 2, DASH); + value += align !== LEFT && align !== NULL ? COLON : DASH; + + rule[index] = value; + } + + rows.splice(1, 0, rule.join(delimiter)); + } + + return start + rows.join(end + NEW_LINE + start) + end; +} + +/* + * Expose `markdownTable`. + */ + +module.exports = markdownTable; diff --git a/tools/node_modules/markdown-table/package.json b/tools/node_modules/markdown-table/package.json new file mode 100644 index 00000000000000..e90f1a3e5c18bd --- /dev/null +++ b/tools/node_modules/markdown-table/package.json @@ -0,0 +1,95 @@ +{ + "_args": [ + [ + "markdown-table@^0.4.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\remark" + ] + ], + "_from": "markdown-table@>=0.4.0 <0.5.0", + "_id": "markdown-table@0.4.0", + "_inCache": true, + "_location": "/markdown-table", + "_nodeVersion": "1.6.3", + "_npmUser": { + "email": "tituswormer@gmail.com", + "name": "wooorm" + }, + "_npmVersion": "2.7.4", + "_phantomChildren": {}, + "_requested": { + "name": "markdown-table", + "raw": "markdown-table@^0.4.0", + "rawSpec": "^0.4.0", + "scope": null, + "spec": ">=0.4.0 <0.5.0", + "type": "range" + }, + "_requiredBy": [ + "/remark" + ], + "_resolved": "https://registry.npmjs.org/markdown-table/-/markdown-table-0.4.0.tgz", + "_shasum": "890c2c1b3bfe83fb00e4129b8e4cfe645270f9d1", + "_shrinkwrap": null, + "_spec": "markdown-table@^0.4.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\remark", + "author": { + "email": "tituswormer@gmail.com", + "name": "Titus Wormer" + }, + "bugs": { + "url": "https://github.com/wooorm/markdown-table/issues" + }, + "dependencies": {}, + "description": "Markdown/ASCII tables", + "devDependencies": { + "chalk": "^1.0.0", + "eslint": "^0.18.0", + "istanbul": "^0.3.0", + "jscs": "^1.0.0", + "jscs-jsdoc": "^0.4.0", + "mocha": "^2.0.0" + }, + "directories": {}, + "dist": { + "shasum": "890c2c1b3bfe83fb00e4129b8e4cfe645270f9d1", + "tarball": "http://registry.npmjs.org/markdown-table/-/markdown-table-0.4.0.tgz" + }, + "gitHead": "500964b100c0261c8f731bbb9c3617a624b5b255", + "homepage": "https://github.com/wooorm/markdown-table", + "installable": true, + "keywords": [ + "align", + "ascii", + "markdown", + "rows", + "table", + "tabular", + "text" + ], + "license": "MIT", + "maintainers": [ + { + "name": "wooorm", + "email": "tituswormer@gmail.com" + } + ], + "name": "markdown-table", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "https://github.com/wooorm/markdown-table.git" + }, + "scripts": { + "lint": "npm run lint-api && npm run lint-test && npm run lint-style", + "lint-api": "eslint index.js", + "lint-style": "jscs --reporter inline index.js test.js", + "lint-test": "eslint --env mocha test.js", + "make": "npm run lint && npm run test-coverage", + "test": "npm run test-api", + "test-api": "_mocha --check-leaks test.js", + "test-coverage": "istanbul cover _mocha -- -- test.js", + "test-coveralls": "istanbul cover _mocha --report lcovonly -- --check-leaks test.js", + "test-travis": "npm run test-coveralls" + }, + "version": "0.4.0" +} diff --git a/tools/node_modules/micromatch/LICENSE b/tools/node_modules/micromatch/LICENSE new file mode 100644 index 00000000000000..fa30c4cb3e4c15 --- /dev/null +++ b/tools/node_modules/micromatch/LICENSE @@ -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. diff --git a/tools/node_modules/micromatch/README.md b/tools/node_modules/micromatch/README.md new file mode 100644 index 00000000000000..0c8cedeb52fddd --- /dev/null +++ b/tools/node_modules/micromatch/README.md @@ -0,0 +1,616 @@ +# micromatch [![NPM version](https://badge.fury.io/js/micromatch.svg)](http://badge.fury.io/js/micromatch) [![Build Status](https://travis-ci.org/jonschlinkert/micromatch.svg)](https://travis-ci.org/jonschlinkert/micromatch) + +> Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch. Just use `micromatch.isMatch()` instead of `minimatch()`, or use `micromatch()` instead of `multimatch()`. + +## Install + +Install with [npm](https://www.npmjs.com/) + +```sh +$ npm i micromatch --save +``` + +## Table of contents + + + +* [Features](#features) +* [Usage](#usage) +* [Switch from minimatch](#switch-from-minimatch) +* [Methods](#methods) + - [.isMatch](#ismatch) + - [.contains](#contains) + - [.matcher](#matcher) + - [.filter](#filter) + - [.any](#any) + - [.expand](#expand) + - [.makeRe](#makere) +* [Options](#options) + - [options.unixify](#optionsunixify) + - [options.dot](#optionsdot) + - [options.unescape](#optionsunescape) + - [options.nodupes](#optionsnodupes) + - [options.matchBase](#optionsmatchbase) + - [options.nobraces](#optionsnobraces) + - [options.nobrackets](#optionsnobrackets) + - [options.noextglob](#optionsnoextglob) + - [options.nocase](#optionsnocase) + - [options.nonull](#optionsnonull) + - [options.cache](#optionscache) +* [Other features](#other-features) + - [Extended globbing](#extended-globbing) + + [extglobs](#extglobs) + + [brace expansion](#brace-expansion) + + [regex character classes](#regex-character-classes) + + [regex groups](#regex-groups) + + [POSIX bracket expressions](#posix-bracket-expressions) +* [Notes](#notes) +* [Benchmarks](#benchmarks) +* [Run tests](#run-tests) +* [Contributing](#contributing) +* [Related](#related) +* [Author](#author) +* [License](#license) + +_(Table of contents generated by [verb](https://github.com/verbose/verb))_ + + + +## Features + +Micromatch is [10-55x faster](#benchmarks) than [minimatch](https://github.com/isaacs/minimatch), resulting from a combination of caching, tokenization, parsing, runtime compilation and regex optimization strategies. + +* [Drop-in replacement](#switch-from-minimatch) for [minimatch](https://github.com/isaacs/minimatch) and [multimatch](https://github.com/sindresorhus/multimatch) +* Built-in support for multiple glob patterns, like `['foo/*.js', '!bar.js']` +* Better support for the Bash 4.3 specification, and less buggy +* Extensive [unit tests](./test) (approx. 1,300 tests). Minimatch fails many of the tests. + +**Mainstream glob features:** + +* [Brace Expansion](https://github.com/jonschlinkert/braces) (`foo/bar-{1..5}.md`, `one/{two,three}/four.md`) +* Typical glob patterns, like `**/*`, `a/b/*.js`, or `['foo/*.js', '!bar.js']` + +**Extended globbing features:** + +* Logical `OR` (`foo/bar/(abc|xyz).js`) +* Regex character classes (`foo/bar/baz-[1-5].js`) +* POSIX [bracket expressions](https://github.com/jonschlinkert/expand-brackets) (`**/[[:alpha:][:digit:]]/`) +* [extglobs](https://github.com/jonschlinkert/extglob) (`**/+(x|y)`, `!(a|b)`, etc) + +You can combine these to create whatever matching patterns you need. + +## Usage + +```js +var mm = require('micromatch'); +mm(array, patterns); +``` + +**Examples** + +```js +mm(['a.js', 'b.md', 'c.txt'], '*.{js,txt}'); +//=> ['a.js', 'c.txt'] +``` + +**Multiple patterns** + +Multiple patterns can also be passed: + +```js +mm(['a.md', 'b.js', 'c.txt', 'd.json'], ['*.md', '*.txt']); +//=> ['a.md', 'c.txt'] +``` + +**Negation patterns:** + +Behavior; + +* when the pattern is a string, [minimatch](https://github.com/isaacs/minimatch) behavior is used, so patterns are **inclusive by default**. +* when an array of patterns is passed, [multimatch](https://github.com/sindresorhus/multimatch) behavior is used, so patterns are **exclusive by default** + +```js +mm(['a.js', 'b.md', 'c.txt'], '!*.{js,txt}'); +//=> ['b.md'] + +mm(['a.md', 'b.js', 'c.txt', 'd.json'], ['*.*', '!*.{js,txt}']); +//=> ['a.md', 'd.json'] +``` + +## Switch from minimatch + +> Use `micromatch.isMatch()` instead of `minimatch()` + +**Minimatch** + +The main `minimatch()` function returns true/false for a single file path and pattern: + +```js +var minimatch = require('minimatch'); +minimatch('foo.js', '*.js'); +//=> 'true' +``` + +**Micromatch** + +With micromatch, `.isMatch()` to get the same result: + +```js +var mm = require('micromatch'); +mm.isMatch('foo.js', '*.js'); +//=> 'true' +``` + +This implementation difference is necessary since the main `micromatch()` method supports matching on multiple globs, with behavior similar to [multimatch](https://github.com/sindresorhus/multimatch). + +## Methods + +```js +var mm = require('micromatch'); +``` + +### .isMatch + +```js +mm.isMatch(filepath, globPattern); +``` + +Returns true if a file path matches the given glob pattern. + +**Example** + +```js +mm.isMatch('.verb.md', '*.md'); +//=> false + +mm.isMatch('.verb.md', '*.md', {dot: true}); +//=> true +``` + +### .contains + +Returns true if any part of a file path matches the given glob pattern. Think of this is "has path" versus "is path". + +**Example** + +`.isMatch()` would return false for both of the following: + +```js +mm.contains('a/b/c', 'a/b'); +//=> true + +mm.contains('a/b/c', 'a/*'); +//=> true +``` + +### .matcher + +Returns a function for matching using the supplied pattern. e.g. create your own "matcher". The advantage of this method is that the pattern can be compiled outside of a loop. + +**Pattern** + +Can be any of the following: + +* `glob/string` +* `regex` +* `function` + +**Example** + +```js +var isMatch = mm.matcher('*.md'); +var files = []; + +['a.md', 'b.txt', 'c.md'].forEach(function(fp) { + if (isMatch(fp)) { + files.push(fp); + } +}); +``` + +### .filter + +Returns a function that can be passed to `Array#filter()`. + +**Params** + +* `patterns` **{String|Array}**: + +**Examples** + +Single glob: + +```js +var fn = mm.filter('*.md'); +['a.js', 'b.txt', 'c.md'].filter(fn); +//=> ['c.md'] + +var fn = mm.filter('[a-c]'); +['a', 'b', 'c', 'd', 'e'].filter(fn); +//=> ['a', 'b', 'c'] +``` + +Array of glob patterns: + +```js +var arr = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]; + +var fn = mm.filter(['{1..10}', '![7-9]', '!{3..4}']); +arr.filter(fn); +//=> [1, 2, 5, 6, 10] +``` + +_(Internally this function generates the matching function by using the [matcher](#matcher) method. You can use the [matcher](#matcher) method directly to create your own filter function)_ + +### .any + +Returns true if a file path matches any of the given patterns. + +```js +mm.any(filepath, patterns, options); +``` + +**Params** + +* filepath `{String}`: The file path to test. +* patterns `{String|Array}`: One or more glob patterns +* options: `{Object}`: options to pass to the `.matcher()` method. + +**Example** + +```js +mm.any('abc', ['!*z']); +//=> true +mm.any('abc', ['a*', 'z*']); +//=> true +mm.any('abc', 'a*'); +//=> true +mm.any('abc', ['z*']); +//=> false +``` + +### .expand + +Returns an object with a regex-compatible string and tokens. + +```js +mm.expand('*.js'); + +// when `track` is enabled (for debugging), the `history` array is used +// to record each mutation to the glob pattern as it's converted to regex +{ options: { track: false, dot: undefined, makeRe: true, negated: false }, + pattern: '(.*\\/|^)bar\\/(?:(?!(?:^|\\/)\\.).)*?', + history: [], + tokens: + { path: + { whole: '**/bar/**', + dirname: '**/bar/', + filename: '**', + basename: '**', + extname: '', + ext: '' }, + is: + { glob: true, + negated: false, + globstar: true, + dotfile: false, + dotdir: false }, + match: {}, + original: '**/bar/**', + pattern: '**/bar/**', + base: '' } } +``` + +### .makeRe + +Create a regular expression for matching file paths based on the given pattern: + +```js +mm.makeRe('*.js'); +//=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/ +``` + +## Options + +### options.unixify + +Normalize slashes in file paths and glob patterns to forward slashes. + +Type: `{Boolean}` + +Default: `undefined` on non-windows, `true` on windows. + +### options.dot + +Match dotfiles. Same behavior as [minimatch](https://github.com/isaacs/minimatch). + +Type: `{Boolean}` + +Default: `false` + +### options.unescape + +Unescape slashes in glob patterns. Use cautiously, especially on windows. + +Type: `{Boolean}` + +Default: `undefined` + +**Example** + +```js +mm.isMatch('abc', '\\a\\b\\c', {unescape: true}); +//=> true +``` + +### options.nodupes + +Remove duplicate elements from the result array. + +Type: `{Boolean}` + +Default: `undefined` + +**Example** + +Example of using the `unescape` and `nodupes` options together: + +```js +mm.match(['abc', '\\a\\b\\c'], '\\a\\b\\c', {unescape: true}); +//=> ['abc', 'abc'] + +mm.match(['abc', '\\a\\b\\c'], '\\a\\b\\c', {unescape: true, nodupes: true}); +//=> ['abc'] +``` + +### options.matchBase + +Allow glob patterns without slashes to match a file path based on its basename. . Same behavior as [minimatch](https://github.com/isaacs/minimatch). + +Type: `{Boolean}` + +Default: `false` + +**Example** + +```js +mm(['a/b.js', 'a/c.md'], '*.js'); +//=> [] + +mm(['a/b.js', 'a/c.md'], '*.js', {matchBase: true}); +//=> ['a/b.js'] +``` + +### options.nobraces + +Don't expand braces in glob patterns. Same behavior as [minimatch](https://github.com/isaacs/minimatch) `nobrace`. + +Type: `{Boolean}` + +Default: `undefined` + +See [braces](https://github.com/jonschlinkert/braces) for more information about extended brace expansion. + +### options.nobrackets + +Don't expand POSIX bracket expressions. + +Type: `{Boolean}` + +Default: `undefined` + +See [expand-brackets](https://github.com/jonschlinkert/expand-brackets) for more information about extended bracket expressions. + +### options.noextglob + +Don't expand extended globs. + +Type: `{Boolean}` + +Default: `undefined` + +See [extglob](https://github.com/jonschlinkert/extglob) for more information about extended globs. + +### options.nocase + +Use a case-insensitive regex for matching files. Same behavior as [minimatch](https://github.com/isaacs/minimatch). + +Type: `{Boolean}` + +Default: `false` + +### options.nonull + +If `true`, when no matches are found the actual (array-ified) glob pattern is returned instead of an empty array. Same behavior as [minimatch](https://github.com/isaacs/minimatch). + +Type: `{Boolean}` + +Default: `false` + +### options.cache + +Cache the platform (e.g. `win32`) to prevent this from being looked up for every filepath. + +Type: `{Boolean}` + +Default: `true` + +## Other features + +Micromatch also supports the following. + +### Extended globbing + +#### extglobs + +Extended globbing, as described by the bash man page: + +| **pattern** | **regex equivalent** | **description** | +| --- | --- | --- | +| `?(pattern-list)` | `(...|...)?` | Matches zero or one occurrence of the given patterns | +| `*(pattern-list)` | `(...|...)*` | Matches zero or more occurrences of the given patterns | +| `+(pattern-list)` | `(...|...)+` | Matches one or more occurrences of the given patterns | +| `@(pattern-list)` | `(...|...)` * | Matches one of the given patterns | +| `!(pattern-list)` | N/A | Matches anything except one of the given patterns | + +* `@` isn't a RegEx character. + +Powered by [extglob](https://github.com/jonschlinkert/extglob). Visit that library for the full range of options or to report extglob related issues. + +See [extglob](https://github.com/jonschlinkert/extglob) for more information about extended globs. + +#### brace expansion + +In simple cases, brace expansion appears to work the same way as the logical `OR` operator. For example, `(a|b)` will achieve the same result as `{a,b}`. + +Here are some powerful features unique to brace expansion (versus character classes): + +* range expansion: `a{1..3}b/*.js` expands to: `['a1b/*.js', 'a2b/*.js', 'a3b/*.js']` +* nesting: `a{c,{d,e}}b/*.js` expands to: `['acb/*.js', 'adb/*.js', 'aeb/*.js']` + +Visit [braces](https://github.com/jonschlinkert/braces) to ask questions and create an issue related to brace-expansion, or to see the full range of features and options related to brace expansion. + +#### regex character classes + +With the exception of brace expansion (`{a,b}`, `{1..5}`, etc), most of the special characters convert directly to regex, so you can expect them to follow the same rules and produce the same results as regex. + +For example, given the list: `['a.js', 'b.js', 'c.js', 'd.js', 'E.js']`: + +* `[ac].js`: matches both `a` and `c`, returning `['a.js', 'c.js']` +* `[b-d].js`: matches from `b` to `d`, returning `['b.js', 'c.js', 'd.js']` +* `[b-d].js`: matches from `b` to `d`, returning `['b.js', 'c.js', 'd.js']` +* `a/[A-Z].js`: matches and uppercase letter, returning `['a/E.md']` + +Learn about [regex character classes](http://www.regular-expressions.info/charclass.html). + +#### regex groups + +Given `['a.js', 'b.js', 'c.js', 'd.js', 'E.js']`: + +* `(a|c).js`: would match either `a` or `c`, returning `['a.js', 'c.js']` +* `(b|d).js`: would match either `b` or `d`, returning `['b.js', 'd.js']` +* `(b|[A-Z]).js`: would match either `b` or an uppercase letter, returning `['b.js', 'E.js']` + +As with regex, parenthese can be nested, so patterns like `((a|b)|c)/b` will work. But it might be easier to achieve your goal using brace expansion. + +#### POSIX bracket expressions + +**Example** + +```js +mm.isMatch('a1', '[[:alpha:][:digit:]]'); +//=> true +``` + +See [expand-brackets](https://github.com/jonschlinkert/expand-brackets) for more information about extended bracket expressions. + +## Notes + +Whenever possible parsing behavior for patterns is based on globbing specifications in Bash 4.3. Patterns that aren't described by Bash follow wildmatch spec (used by git). + +## Benchmarks + +Run the [benchmarks](./benchmark): + +```bash +node benchmark +``` + +As of October 03, 2015: + +```bash +#1: basename-braces + micromatch x 26,420 ops/sec ±0.89% (91 runs sampled) + minimatch x 3,507 ops/sec ±0.64% (97 runs sampled) + +#2: basename + micromatch x 25,315 ops/sec ±0.82% (93 runs sampled) + minimatch x 4,398 ops/sec ±0.86% (94 runs sampled) + +#3: braces-no-glob + micromatch x 341,254 ops/sec ±0.78% (93 runs sampled) + minimatch x 30,197 ops/sec ±1.12% (91 runs sampled) + +#4: braces + micromatch x 54,649 ops/sec ±0.74% (94 runs sampled) + minimatch x 3,095 ops/sec ±0.82% (95 runs sampled) + +#5: immediate + micromatch x 16,719 ops/sec ±0.79% (95 runs sampled) + minimatch x 4,348 ops/sec ±0.86% (96 runs sampled) + +#6: large + micromatch x 721 ops/sec ±0.77% (94 runs sampled) + minimatch x 17.73 ops/sec ±1.08% (50 runs sampled) + +#7: long + micromatch x 5,051 ops/sec ±0.87% (97 runs sampled) + minimatch x 628 ops/sec ±0.83% (94 runs sampled) + +#8: mid + micromatch x 51,280 ops/sec ±0.80% (95 runs sampled) + minimatch x 1,923 ops/sec ±0.84% (95 runs sampled) + +#9: multi-patterns + micromatch x 22,440 ops/sec ±0.97% (94 runs sampled) + minimatch x 2,481 ops/sec ±1.10% (94 runs sampled) + +#10: no-glob + micromatch x 722,823 ops/sec ±1.30% (87 runs sampled) + minimatch x 52,967 ops/sec ±1.09% (94 runs sampled) + +#11: range + micromatch x 243,471 ops/sec ±0.79% (94 runs sampled) + minimatch x 11,736 ops/sec ±0.82% (96 runs sampled) + +#12: shallow + micromatch x 190,874 ops/sec ±0.98% (95 runs sampled) + minimatch x 21,699 ops/sec ±0.81% (97 runs sampled) + +#13: short + micromatch x 496,393 ops/sec ±3.86% (90 runs sampled) + minimatch x 53,765 ops/sec ±0.75% (95 runs sampled) +``` + +## Run 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/micromatch/issues/new). + +Please be sure to run the benchmarks before/after any code changes to judge the impact before you do a PR. thanks! + +## Related + +* [braces](https://www.npmjs.com/package/braces): Fastest brace expansion for node.js, with the most complete… [more](https://www.npmjs.com/package/braces) | [homepage](https://github.com/jonschlinkert/braces) +* [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-range](https://www.npmjs.com/package/expand-range): Fast, bash-like range expansion. Expand a range of numbers… [more](https://www.npmjs.com/package/expand-range) | [homepage](https://github.com/jonschlinkert/expand-range) +* [extglob](https://www.npmjs.com/package/extglob): Convert extended globs to regex-compatible strings. Add (almost) the… [more](https://www.npmjs.com/package/extglob) | [homepage](https://github.com/jonschlinkert/extglob) +* [fill-range](https://www.npmjs.com/package/fill-range): Fill in a range of numbers or letters, optionally… [more](https://www.npmjs.com/package/fill-range) | [homepage](https://github.com/jonschlinkert/fill-range) +* [gulp-micromatch](https://www.npmjs.com/package/gulp-micromatch): Filter vinyl files with glob patterns, string, regexp, array,… [more](https://www.npmjs.com/package/gulp-micromatch) | [homepage](https://github.com/tunnckocore/gulp-micromatch) +* [is-glob](https://www.npmjs.com/package/is-glob): Returns `true` if the given string looks like a… [more](https://www.npmjs.com/package/is-glob) | [homepage](https://github.com/jonschlinkert/is-glob) +* [parse-glob](https://www.npmjs.com/package/parse-glob): Parse a glob pattern into an object of tokens. | [homepage](https://github.com/jonschlinkert/parse-glob) + +## Author + +**Jon Schlinkert** + ++ [github/jonschlinkert](https://github.com/jonschlinkert) ++ [twitter/jonschlinkert](http://twitter.com/jonschlinkert) + +## License + +Copyright © 2014-2015 [Jon Schlinkert](https://github.com/jonschlinkert) +Released under the MIT license. + +*** + +_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on October 03, 2015._ + + \ No newline at end of file diff --git a/tools/node_modules/micromatch/index.js b/tools/node_modules/micromatch/index.js new file mode 100644 index 00000000000000..cbafd67c02f245 --- /dev/null +++ b/tools/node_modules/micromatch/index.js @@ -0,0 +1,428 @@ +/*! + * micromatch + * + * Copyright (c) 2014-2015, Jon Schlinkert. + * Licensed under the MIT License. + */ + +'use strict'; + +var expand = require('./lib/expand'); +var utils = require('./lib/utils'); + +/** + * The main function. Pass an array of filepaths, + * and a string or array of glob patterns + * + * @param {Array|String} `files` + * @param {Array|String} `patterns` + * @param {Object} `opts` + * @return {Array} Array of matches + */ + +function micromatch(files, patterns, opts) { + if (!files || !patterns) return []; + opts = opts || {}; + + if (typeof opts.cache === 'undefined') { + opts.cache = true; + } + + if (!Array.isArray(patterns)) { + return match(files, patterns, opts); + } + + var len = patterns.length, i = 0; + var omit = [], keep = []; + + while (len--) { + var glob = patterns[i++]; + if (typeof glob === 'string' && glob.charCodeAt(0) === 33 /* ! */) { + omit.push.apply(omit, match(files, glob.slice(1), opts)); + } else { + keep.push.apply(keep, match(files, glob, opts)); + } + } + return utils.diff(keep, omit); +} + +/** + * Pass an array of files and a glob pattern as a string. + * + * This function is called by the main `micromatch` function + * If you only need to pass a single pattern you might get + * very minor speed improvements using this function. + * + * @param {Array} `files` + * @param {Array} `pattern` + * @param {Object} `options` + * @return {Array} + */ + +function match(files, pattern, opts) { + if (utils.typeOf(files) !== 'string' && !Array.isArray(files)) { + throw new Error(msg('match', 'files', 'a string or array')); + } + + files = utils.arrayify(files); + opts = opts || {}; + + var negate = opts.negate || false; + var orig = pattern; + + if (typeof pattern === 'string') { + negate = pattern.charAt(0) === '!'; + if (negate) { + pattern = pattern.slice(1); + } + + // we need to remove the character regardless, + // so the above logic is still needed + if (opts.nonegate === true) { + negate = false; + } + } + + var _isMatch = matcher(pattern, opts); + var len = files.length, i = 0; + var res = []; + + while (i < len) { + var file = files[i++]; + var fp = utils.unixify(file, opts); + + if (!_isMatch(fp)) { continue; } + res.push(fp); + } + + if (res.length === 0) { + if (opts.failglob === true) { + throw new Error('micromatch.match() found no matches for: "' + orig + '".'); + } + + if (opts.nonull || opts.nullglob) { + res.push(utils.unescapeGlob(orig)); + } + } + + // if `negate` was defined, diff negated files + if (negate) { res = utils.diff(files, res); } + + // if `ignore` was defined, diff ignored filed + if (opts.ignore && opts.ignore.length) { + pattern = opts.ignore; + opts = utils.omit(opts, ['ignore']); + res = utils.diff(res, micromatch(res, pattern, opts)); + } + + if (opts.nodupes) { + return utils.unique(res); + } + return res; +} + +/** + * Returns a function that takes a glob pattern or array of glob patterns + * to be used with `Array#filter()`. (Internally this function generates + * the matching function using the [matcher] method). + * + * ```js + * var fn = mm.filter('[a-c]'); + * ['a', 'b', 'c', 'd', 'e'].filter(fn); + * //=> ['a', 'b', 'c'] + * ``` + * + * @param {String|Array} `patterns` Can be a glob or array of globs. + * @param {Options} `opts` Options to pass to the [matcher] method. + * @return {Function} Filter function to be passed to `Array#filter()`. + */ + +function filter(patterns, opts) { + if (!Array.isArray(patterns) && typeof patterns !== 'string') { + throw new TypeError(msg('filter', 'patterns', 'a string or array')); + } + + patterns = utils.arrayify(patterns); + var len = patterns.length, i = 0; + var patternMatchers = Array(len); + while (i < len) { + patternMatchers[i] = matcher(patterns[i++], opts); + } + + return function(fp) { + if (fp == null) return []; + var len = patternMatchers.length, i = 0; + var res = true; + + fp = utils.unixify(fp, opts); + while (i < len) { + var fn = patternMatchers[i++]; + if (!fn(fp)) { + res = false; + break; + } + } + return res; + }; +} + +/** + * Returns true if the filepath contains the given + * pattern. Can also return a function for matching. + * + * ```js + * isMatch('foo.md', '*.md', {}); + * //=> true + * + * isMatch('*.md', {})('foo.md') + * //=> true + * ``` + * + * @param {String} `fp` + * @param {String} `pattern` + * @param {Object} `opts` + * @return {Boolean} + */ + +function isMatch(fp, pattern, opts) { + if (typeof fp !== 'string') { + throw new TypeError(msg('isMatch', 'filepath', 'a string')); + } + + fp = utils.unixify(fp, opts); + if (utils.typeOf(pattern) === 'object') { + return matcher(fp, pattern); + } + return matcher(pattern, opts)(fp); +} + +/** + * Returns true if the filepath matches the + * given pattern. + */ + +function contains(fp, pattern, opts) { + if (typeof fp !== 'string') { + throw new TypeError(msg('contains', 'pattern', 'a string')); + } + + opts = opts || {}; + opts.contains = (pattern !== ''); + fp = utils.unixify(fp, opts); + + if (opts.contains && !utils.isGlob(pattern)) { + return fp.indexOf(pattern) !== -1; + } + return matcher(pattern, opts)(fp); +} + +/** + * Returns true if a file path matches any of the + * given patterns. + * + * @param {String} `fp` The filepath to test. + * @param {String|Array} `patterns` Glob patterns to use. + * @param {Object} `opts` Options to pass to the `matcher()` function. + * @return {String} + */ + +function any(fp, patterns, opts) { + if (!Array.isArray(patterns) && typeof patterns !== 'string') { + throw new TypeError(msg('any', 'patterns', 'a string or array')); + } + + patterns = utils.arrayify(patterns); + var len = patterns.length; + + fp = utils.unixify(fp, opts); + while (len--) { + var isMatch = matcher(patterns[len], opts); + if (isMatch(fp)) { + return true; + } + } + return false; +} + +/** + * Filter the keys of an object with the given `glob` pattern + * and `options` + * + * @param {Object} `object` + * @param {Pattern} `object` + * @return {Array} + */ + +function matchKeys(obj, glob, options) { + if (utils.typeOf(obj) !== 'object') { + throw new TypeError(msg('matchKeys', 'first argument', 'an object')); + } + + var fn = matcher(glob, options); + var res = {}; + + for (var key in obj) { + if (obj.hasOwnProperty(key) && fn(key)) { + res[key] = obj[key]; + } + } + return res; +} + +/** + * Return a function for matching based on the + * given `pattern` and `options`. + * + * @param {String} `pattern` + * @param {Object} `options` + * @return {Function} + */ + +function matcher(pattern, opts) { + // pattern is a function + if (typeof pattern === 'function') { + return pattern; + } + // pattern is a regex + if (pattern instanceof RegExp) { + return function(fp) { + return pattern.test(fp); + }; + } + + if (typeof pattern !== 'string') { + throw new TypeError(msg('matcher', 'pattern', 'a string, regex, or function')); + } + + // strings, all the way down... + pattern = utils.unixify(pattern, opts); + + // pattern is a non-glob string + if (!utils.isGlob(pattern)) { + return utils.matchPath(pattern, opts); + } + // pattern is a glob string + var re = makeRe(pattern, opts); + + // `matchBase` is defined + if (opts && opts.matchBase) { + return utils.hasFilename(re, opts); + } + // `matchBase` is not defined + return function(fp) { + fp = utils.unixify(fp, opts); + return re.test(fp); + }; +} + +/** + * Create and cache a regular expression for matching + * file paths. + * + * If the leading character in the `glob` is `!`, a negation + * regex is returned. + * + * @param {String} `glob` + * @param {Object} `options` + * @return {RegExp} + */ + +function toRegex(glob, options) { + // clone options to prevent mutating the original object + var opts = Object.create(options || {}); + var flags = opts.flags || ''; + if (opts.nocase && flags.indexOf('i') === -1) { + flags += 'i'; + } + + var parsed = expand(glob, opts); + + // pass in tokens to avoid parsing more than once + opts.negated = opts.negated || parsed.negated; + opts.negate = opts.negated; + glob = wrapGlob(parsed.pattern, opts); + var re; + + try { + re = new RegExp(glob, flags); + return re; + } catch (err) { + err.reason = 'micromatch invalid regex: (' + re + ')'; + if (opts.strict) throw new SyntaxError(err); + } + + // we're only here if a bad pattern was used and the user + // passed `options.silent`, so match nothing + return /$^/; +} + +/** + * Create the regex to do the matching. If the leading + * character in the `glob` is `!` a negation regex is returned. + * + * @param {String} `glob` + * @param {Boolean} `negate` + */ + +function wrapGlob(glob, opts) { + var prefix = (opts && !opts.contains) ? '^' : ''; + var after = (opts && !opts.contains) ? '$' : ''; + glob = ('(?:' + glob + ')' + after); + if (opts && opts.negate) { + return prefix + ('(?!^' + glob + ').*$'); + } + return prefix + glob; +} + +/** + * Wrap `toRegex` to memoize the generated regex when + * the string and options don't change + */ + +function makeRe(glob, opts) { + if (utils.typeOf(glob) !== 'string') { + throw new Error(msg('makeRe', 'glob', 'a string')); + } + return utils.cache(toRegex, glob, opts); +} + +/** + * Make error messages consistent. Follows this format: + * + * ```js + * msg(methodName, argNumber, nativeType); + * // example: + * msg('matchKeys', 'first', 'an object'); + * ``` + * + * @param {String} `method` + * @param {String} `num` + * @param {String} `type` + * @return {String} + */ + +function msg(method, what, type) { + return 'micromatch.' + method + '(): ' + what + ' should be ' + type + '.'; +} + +/** + * Public methods + */ + +/* eslint no-multi-spaces: 0 */ +micromatch.any = any; +micromatch.braces = micromatch.braceExpand = utils.braces; +micromatch.contains = contains; +micromatch.expand = expand; +micromatch.filter = filter; +micromatch.isMatch = isMatch; +micromatch.makeRe = makeRe; +micromatch.match = match; +micromatch.matcher = matcher; +micromatch.matchKeys = matchKeys; + +/** + * Expose `micromatch` + */ + +module.exports = micromatch; diff --git a/tools/node_modules/micromatch/lib/chars.js b/tools/node_modules/micromatch/lib/chars.js new file mode 100644 index 00000000000000..a1ffe371418aba --- /dev/null +++ b/tools/node_modules/micromatch/lib/chars.js @@ -0,0 +1,67 @@ +'use strict'; + +var chars = {}, unesc, temp; + +function reverse(object, prepender) { + return Object.keys(object).reduce(function(reversed, key) { + var newKey = prepender ? prepender + key : key; // Optionally prepend a string to key. + reversed[object[key]] = newKey; // Swap key and value. + return reversed; // Return the result. + }, {}); +} + +/** + * Regex for common characters + */ + +chars.escapeRegex = { + '?': /\?/g, + '@': /\@/g, + '!': /\!/g, + '+': /\+/g, + '*': /\*/g, + '(': /\(/g, + ')': /\)/g, + '[': /\[/g, + ']': /\]/g +}; + +/** + * Escape characters + */ + +chars.ESC = { + '?': '__UNESC_QMRK__', + '@': '__UNESC_AMPE__', + '!': '__UNESC_EXCL__', + '+': '__UNESC_PLUS__', + '*': '__UNESC_STAR__', + ',': '__UNESC_COMMA__', + '(': '__UNESC_LTPAREN__', + ')': '__UNESC_RTPAREN__', + '[': '__UNESC_LTBRACK__', + ']': '__UNESC_RTBRACK__' +}; + +/** + * Unescape characters + */ + +chars.UNESC = unesc || (unesc = reverse(chars.ESC, '\\')); + +chars.ESC_TEMP = { + '?': '__TEMP_QMRK__', + '@': '__TEMP_AMPE__', + '!': '__TEMP_EXCL__', + '*': '__TEMP_STAR__', + '+': '__TEMP_PLUS__', + ',': '__TEMP_COMMA__', + '(': '__TEMP_LTPAREN__', + ')': '__TEMP_RTPAREN__', + '[': '__TEMP_LTBRACK__', + ']': '__TEMP_RTBRACK__' +}; + +chars.TEMP = temp || (temp = reverse(chars.ESC_TEMP)); + +module.exports = chars; diff --git a/tools/node_modules/micromatch/lib/expand.js b/tools/node_modules/micromatch/lib/expand.js new file mode 100644 index 00000000000000..a8c95ae0cfd01d --- /dev/null +++ b/tools/node_modules/micromatch/lib/expand.js @@ -0,0 +1,311 @@ +/*! + * micromatch + * + * Copyright (c) 2014-2015, Jon Schlinkert. + * Licensed under the MIT License. + */ + +'use strict'; + +var utils = require('./utils'); +var Glob = require('./glob'); + +/** + * Expose `expand` + */ + +module.exports = expand; + +/** + * Expand a glob pattern to resolve braces and + * similar patterns before converting to regex. + * + * @param {String|Array} `pattern` + * @param {Array} `files` + * @param {Options} `opts` + * @return {Array} + */ + +function expand(pattern, options) { + if (typeof pattern !== 'string') { + throw new TypeError('micromatch.expand(): argument should be a string.'); + } + + var glob = new Glob(pattern, options || {}); + var opts = glob.options; + + if (!utils.isGlob(pattern)) { + glob.pattern = glob.pattern.replace(/([\/.])/g, '\\$1'); + return glob; + } + + glob.pattern = glob.pattern.replace(/(\+)(?!\()/g, '\\$1'); + glob.pattern = glob.pattern.split('$').join('\\$'); + + if (typeof opts.braces !== 'boolean' && typeof opts.nobraces !== 'boolean') { + opts.braces = true; + } + + if (glob.pattern === '.*') { + return { + pattern: '\\.' + star, + tokens: tok, + options: opts + }; + } + + if (glob.pattern === '*') { + return { + pattern: oneStar(opts.dot), + tokens: tok, + options: opts + }; + } + + // parse the glob pattern into tokens + glob.parse(); + var tok = glob.tokens; + tok.is.negated = opts.negated; + + // dotfile handling + if ((opts.dotfiles === true || tok.is.dotfile) && opts.dot !== false) { + opts.dotfiles = true; + opts.dot = true; + } + + if ((opts.dotdirs === true || tok.is.dotdir) && opts.dot !== false) { + opts.dotdirs = true; + opts.dot = true; + } + + // check for braces with a dotfile pattern + if (/[{,]\./.test(glob.pattern)) { + opts.makeRe = false; + opts.dot = true; + } + + if (opts.nonegate !== true) { + opts.negated = glob.negated; + } + + // if the leading character is a dot or a slash, escape it + if (glob.pattern.charAt(0) === '.' && glob.pattern.charAt(1) !== '/') { + glob.pattern = '\\' + glob.pattern; + } + + /** + * Extended globs + */ + + // expand braces, e.g `{1..5}` + glob.track('before braces'); + if (tok.is.braces) { + glob.braces(); + } + glob.track('after braces'); + + // expand extglobs, e.g `foo/!(a|b)` + glob.track('before extglob'); + if (tok.is.extglob) { + glob.extglob(); + } + glob.track('after extglob'); + + // expand brackets, e.g `[[:alpha:]]` + glob.track('before brackets'); + if (tok.is.brackets) { + glob.brackets(); + } + glob.track('after brackets'); + + // special patterns + glob._replace('[!', '[^'); + glob._replace('(?', '(%~'); + glob._replace(/\[\]/, '\\[\\]'); + glob._replace('/[', '/' + (opts.dot ? dotfiles : nodot) + '[', true); + glob._replace('/?', '/' + (opts.dot ? dotfiles : nodot) + '[^/]', true); + glob._replace('/.', '/(?=.)\\.', true); + + // windows drives + glob._replace(/^(\w):([\\\/]+?)/gi, '(?=.)$1:$2', true); + + // negate slashes in exclusion ranges + if (glob.pattern.indexOf('[^') !== -1) { + glob.pattern = negateSlash(glob.pattern); + } + + if (opts.globstar !== false && glob.pattern === '**') { + glob.pattern = globstar(opts.dot); + + } else { + // '/*/*/*' => '(?:/*){3}' + glob._replace(/(\/\*)+/g, function(match) { + var len = match.length / 2; + if (len === 1) { return match; } + return '(?:\\/*){' + len + '}'; + }); + + glob.pattern = balance(glob.pattern, '[', ']'); + glob.escape(glob.pattern); + + // if the pattern has `**` + if (tok.is.globstar) { + glob.pattern = collapse(glob.pattern, '/**'); + glob.pattern = collapse(glob.pattern, '**/'); + glob._replace('/**/', '(?:/' + globstar(opts.dot) + '/|/)', true); + glob._replace(/\*{2,}/g, '**'); + + // 'foo/*' + glob._replace(/(\w+)\*(?!\/)/g, '$1[^/]*?', true); + glob._replace(/\*\*\/\*(\w)/g, globstar(opts.dot) + '\\/' + (opts.dot ? dotfiles : nodot) + '[^/]*?$1', true); + + if (opts.dot !== true) { + glob._replace(/\*\*\/(.)/g, '(?:**\\/|)$1'); + } + + // 'foo/**' or '{**,*}', but not 'foo**' + if (tok.path.dirname !== '' || /,\*\*|\*\*,/.test(glob.orig)) { + glob._replace('**', globstar(opts.dot), true); + } + } + + // ends with /* + glob._replace(/\/\*$/, '\\/' + oneStar(opts.dot), true); + // ends with *, no slashes + glob._replace(/(?!\/)\*$/, star, true); + // has 'n*.' (partial wildcard w/ file extension) + glob._replace(/([^\/]+)\*/, '$1' + oneStar(true), true); + // has '*' + glob._replace('*', oneStar(opts.dot), true); + glob._replace('?.', '?\\.', true); + glob._replace('?:', '?:', true); + + glob._replace(/\?+/g, function(match) { + var len = match.length; + if (len === 1) { + return qmark; + } + return qmark + '{' + len + '}'; + }); + + // escape '.abc' => '\\.abc' + glob._replace(/\.([*\w]+)/g, '\\.$1'); + // fix '[^\\\\/]' + glob._replace(/\[\^[\\\/]+\]/g, qmark); + // '///' => '\/' + glob._replace(/\/+/g, '\\/'); + // '\\\\\\' => '\\' + glob._replace(/\\{2,}/g, '\\'); + } + + // unescape previously escaped patterns + glob.unescape(glob.pattern); + glob._replace('__UNESC_STAR__', '*'); + + // escape dots that follow qmarks + glob._replace('?.', '?\\.'); + + // remove unnecessary slashes in character classes + glob._replace('[^\\/]', qmark); + + if (glob.pattern.length > 1) { + if (/^[\[?*]/.test(glob.pattern)) { + // only prepend the string if we don't want to match dotfiles + glob.pattern = (opts.dot ? dotfiles : nodot) + glob.pattern; + } + } + + return glob; +} + +/** + * Collapse repeated character sequences. + * + * ```js + * collapse('a/../../../b', '../'); + * //=> 'a/../b' + * ``` + * + * @param {String} `str` + * @param {String} `ch` Character sequence to collapse + * @return {String} + */ + +function collapse(str, ch) { + var res = str.split(ch); + var isFirst = res[0] === ''; + var isLast = res[res.length - 1] === ''; + res = res.filter(Boolean); + if (isFirst) res.unshift(''); + if (isLast) res.push(''); + return res.join(ch); +} + +/** + * Negate slashes in exclusion ranges, per glob spec: + * + * ```js + * negateSlash('[^foo]'); + * //=> '[^\\/foo]' + * ``` + * + * @param {String} `str` glob pattern + * @return {String} + */ + +function negateSlash(str) { + return str.replace(/\[\^([^\]]*?)\]/g, function(match, inner) { + if (inner.indexOf('/') === -1) { + inner = '\\/' + inner; + } + return '[^' + inner + ']'; + }); +} + +/** + * Escape imbalanced braces/bracket. This is a very + * basic, naive implementation that only does enough + * to serve the purpose. + */ + +function balance(str, a, b) { + var aarr = str.split(a); + var alen = aarr.join('').length; + var blen = str.split(b).join('').length; + + if (alen !== blen) { + str = aarr.join('\\' + a); + return str.split(b).join('\\' + b); + } + return str; +} + +/** + * Special patterns to be converted to regex. + * Heuristics are used to simplify patterns + * and speed up processing. + */ + +/* eslint no-multi-spaces: 0 */ +var qmark = '[^/]'; +var star = qmark + '*?'; +var nodot = '(?!\\.)(?=.)'; +var dotfileGlob = '(?:\\/|^)\\.{1,2}($|\\/)'; +var dotfiles = '(?!' + dotfileGlob + ')(?=.)'; +var twoStarDot = '(?:(?!' + dotfileGlob + ').)*?'; + +/** + * Create a regex for `*`. + * + * If `dot` is true, or the pattern does not begin with + * a leading star, then return the simpler regex. + */ + +function oneStar(dotfile) { + return dotfile ? '(?!' + dotfileGlob + ')(?=.)' + star : (nodot + star); +} + +function globstar(dotfile) { + if (dotfile) { return twoStarDot; } + return '(?:(?!(?:\\/|^)\\.).)*?'; +} diff --git a/tools/node_modules/micromatch/lib/glob.js b/tools/node_modules/micromatch/lib/glob.js new file mode 100644 index 00000000000000..c613326736c1d2 --- /dev/null +++ b/tools/node_modules/micromatch/lib/glob.js @@ -0,0 +1,193 @@ +'use strict'; + +var chars = require('./chars'); +var utils = require('./utils'); + +/** + * Expose `Glob` + */ + +var Glob = module.exports = function Glob(pattern, options) { + if (!(this instanceof Glob)) { + return new Glob(pattern, options); + } + this.options = options || {}; + this.pattern = pattern; + this.history = []; + this.tokens = {}; + this.init(pattern); +}; + +/** + * Initialize defaults + */ + +Glob.prototype.init = function(pattern) { + this.orig = pattern; + this.negated = this.isNegated(); + this.options.track = this.options.track || false; + this.options.makeRe = true; +}; + +/** + * Push a change into `glob.history`. Useful + * for debugging. + */ + +Glob.prototype.track = function(msg) { + if (this.options.track) { + this.history.push({msg: msg, pattern: this.pattern}); + } +}; + +/** + * Return true if `glob.pattern` was negated + * with `!`, also remove the `!` from the pattern. + * + * @return {Boolean} + */ + +Glob.prototype.isNegated = function() { + if (this.pattern.charCodeAt(0) === 33 /* '!' */) { + this.pattern = this.pattern.slice(1); + return true; + } + return false; +}; + +/** + * Expand braces in the given glob pattern. + * + * We only need to use the [braces] lib when + * patterns are nested. + */ + +Glob.prototype.braces = function() { + if (this.options.nobraces !== true && this.options.nobrace !== true) { + // naive/fast check for imbalanced characters + var a = this.pattern.match(/[\{\(\[]/g); + var b = this.pattern.match(/[\}\)\]]/g); + + // if imbalanced, don't optimize the pattern + if (a && b && (a.length !== b.length)) { + this.options.makeRe = false; + } + + // expand brace patterns and join the resulting array + var expanded = utils.braces(this.pattern, this.options); + this.pattern = expanded.join('|'); + } +}; + +/** + * Expand bracket expressions in `glob.pattern` + */ + +Glob.prototype.brackets = function() { + if (this.options.nobrackets !== true) { + this.pattern = utils.brackets(this.pattern); + } +}; + +/** + * Expand bracket expressions in `glob.pattern` + */ + +Glob.prototype.extglob = function() { + if (this.options.noextglob === true) return; + + if (utils.isExtglob(this.pattern)) { + this.pattern = utils.extglob(this.pattern, {escape: true}); + } +}; + +/** + * Parse the given pattern + */ + +Glob.prototype.parse = function(pattern) { + this.tokens = utils.parseGlob(pattern || this.pattern, true); + return this.tokens; +}; + +/** + * Replace `a` with `b`. Also tracks the change before and + * after each replacement. This is disabled by default, but + * can be enabled by setting `options.track` to true. + * + * Also, when the pattern is a string, `.split()` is used, + * because it's much faster than replace. + * + * @param {RegExp|String} `a` + * @param {String} `b` + * @param {Boolean} `escape` When `true`, escapes `*` and `?` in the replacement. + * @return {String} + */ + +Glob.prototype._replace = function(a, b, escape) { + this.track('before (find): "' + a + '" (replace with): "' + b + '"'); + if (escape) b = esc(b); + if (a && b && typeof a === 'string') { + this.pattern = this.pattern.split(a).join(b); + } else { + this.pattern = this.pattern.replace(a, b); + } + this.track('after'); +}; + +/** + * Escape special characters in the given string. + * + * @param {String} `str` Glob pattern + * @return {String} + */ + +Glob.prototype.escape = function(str) { + this.track('before escape: '); + var re = /["\\](['"]?[^"'\\]['"]?)/g; + + this.pattern = str.replace(re, function($0, $1) { + var o = chars.ESC; + var ch = o && o[$1]; + if (ch) { + return ch; + } + if (/[a-z]/i.test($0)) { + return $0.split('\\').join(''); + } + return $0; + }); + + this.track('after escape: '); +}; + +/** + * Unescape special characters in the given string. + * + * @param {String} `str` + * @return {String} + */ + +Glob.prototype.unescape = function(str) { + var re = /__([A-Z]+)_([A-Z]+)__/g; + this.pattern = str.replace(re, function($0, $1) { + return chars[$1][$0]; + }); + this.pattern = unesc(this.pattern); +}; + +/** + * Escape/unescape utils + */ + +function esc(str) { + str = str.split('?').join('%~'); + str = str.split('*').join('%%'); + return str; +} + +function unesc(str) { + str = str.split('%~').join('?'); + str = str.split('%%').join('*'); + return str; +} diff --git a/tools/node_modules/micromatch/lib/utils.js b/tools/node_modules/micromatch/lib/utils.js new file mode 100644 index 00000000000000..30f3c2ac62907b --- /dev/null +++ b/tools/node_modules/micromatch/lib/utils.js @@ -0,0 +1,144 @@ +'use strict'; + +var win32 = process && process.platform === 'win32'; +var path = require('path'); +var fileRe = require('filename-regex'); +var utils = module.exports; + +/** + * Module dependencies + */ + +utils.diff = require('arr-diff'); +utils.unique = require('array-unique'); +utils.braces = require('braces'); +utils.brackets = require('expand-brackets'); +utils.extglob = require('extglob'); +utils.isExtglob = require('is-extglob'); +utils.isGlob = require('is-glob'); +utils.typeOf = require('kind-of'); +utils.normalize = require('normalize-path'); +utils.omit = require('object.omit'); +utils.parseGlob = require('parse-glob'); +utils.cache = require('regex-cache'); + +/** + * Get the filename of a filepath + * + * @param {String} `string` + * @return {String} + */ + +utils.filename = function filename(fp) { + var seg = fp.match(fileRe()); + return seg && seg[0]; +}; + +/** + * Returns a function that returns true if the given + * pattern is the same as a given `filepath` + * + * @param {String} `pattern` + * @return {Function} + */ + +utils.isPath = function isPath(pattern, opts) { + return function(fp) { + return pattern === utils.unixify(fp, opts); + }; +}; + +/** + * Returns a function that returns true if the given + * pattern contains a `filepath` + * + * @param {String} `pattern` + * @return {Function} + */ + +utils.hasPath = function hasPath(pattern, opts) { + return function(fp) { + return utils.unixify(pattern, opts).indexOf(fp) !== -1; + }; +}; + +/** + * Returns a function that returns true if the given + * pattern matches or contains a `filepath` + * + * @param {String} `pattern` + * @return {Function} + */ + +utils.matchPath = function matchPath(pattern, opts) { + var fn = (opts && opts.contains) + ? utils.hasPath(pattern, opts) + : utils.isPath(pattern, opts); + return fn; +}; + +/** + * Returns a function that returns true if the given + * regex matches the `filename` of a file path. + * + * @param {RegExp} `re` + * @return {Boolean} + */ + +utils.hasFilename = function hasFilename(re) { + return function(fp) { + var name = utils.filename(fp); + return name && re.test(name); + }; +}; + +/** + * Coerce `val` to an array + * + * @param {*} val + * @return {Array} + */ + +utils.arrayify = function arrayify(val) { + return !Array.isArray(val) + ? [val] + : val; +}; + +/** + * Normalize all slashes in a file path or glob pattern to + * forward slashes. + */ + +utils.unixify = function unixify(fp, opts) { + if (opts && opts.unixify === false) return fp; + if (opts && opts.unixify === true || win32 || path.sep === '\\') { + return utils.normalize(fp, false); + } + if (opts && opts.unescape === true) { + return fp ? fp.toString().replace(/\\(\w)/g, '$1') : ''; + } + return fp; +}; + +/** + * Escape/unescape utils + */ + +utils.escapePath = function escapePath(fp) { + return fp.replace(/[\\.]/g, '\\$&'); +}; + +utils.unescapeGlob = function unescapeGlob(fp) { + return fp.replace(/[\\"']/g, ''); +}; + +utils.escapeRe = function escapeRe(str) { + return str.replace(/[-[\\$*+?.#^\s{}(|)\]]/g, '\\$&'); +}; + +/** + * Expose `utils` + */ + +module.exports = utils; diff --git a/tools/node_modules/micromatch/package.json b/tools/node_modules/micromatch/package.json new file mode 100644 index 00000000000000..ab6f01fdcb3763 --- /dev/null +++ b/tools/node_modules/micromatch/package.json @@ -0,0 +1,163 @@ +{ + "_args": [ + [ + "micromatch@^2.1.5", + "C:\\wamp\\www\\node\\tools\\node_modules\\anymatch" + ] + ], + "_from": "micromatch@>=2.1.5 <3.0.0", + "_id": "micromatch@2.3.7", + "_inCache": true, + "_location": "/micromatch", + "_nodeVersion": "5.0.0", + "_npmUser": { + "email": "github@sellside.com", + "name": "jonschlinkert" + }, + "_npmVersion": "3.3.6", + "_phantomChildren": {}, + "_requested": { + "name": "micromatch", + "raw": "micromatch@^2.1.5", + "rawSpec": "^2.1.5", + "scope": null, + "spec": ">=2.1.5 <3.0.0", + "type": "range" + }, + "_requiredBy": [ + "/anymatch" + ], + "_resolved": "https://registry.npmjs.org/micromatch/-/micromatch-2.3.7.tgz", + "_shasum": "2f2e85ef46140dbea6cb55e739b6b11b30eaa509", + "_shrinkwrap": null, + "_spec": "micromatch@^2.1.5", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\anymatch", + "author": { + "name": "Jon Schlinkert", + "url": "https://github.com/jonschlinkert" + }, + "bugs": { + "url": "https://github.com/jonschlinkert/micromatch/issues" + }, + "dependencies": { + "arr-diff": "^2.0.0", + "array-unique": "^0.2.1", + "braces": "^1.8.2", + "expand-brackets": "^0.1.4", + "extglob": "^0.3.1", + "filename-regex": "^2.0.0", + "is-extglob": "^1.0.0", + "is-glob": "^2.0.1", + "kind-of": "^3.0.2", + "normalize-path": "^2.0.1", + "object.omit": "^2.0.0", + "parse-glob": "^3.0.4", + "regex-cache": "^0.4.2" + }, + "description": "Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch. Just use `micromatch.isMatch()` instead of `minimatch()`, or use `micromatch()` instead of `multimatch()`.", + "devDependencies": { + "benchmarked": "^0.1.4", + "chalk": "^1.1.1", + "gulp": "^3.9.0", + "gulp-eslint": "^1.1.1", + "gulp-istanbul": "^0.10.1", + "gulp-mocha": "^2.1.3", + "minimatch": "^3.0.0", + "minimist": "^1.2.0", + "mocha": "*", + "multimatch": "^2.0.0", + "should": "*", + "write": "^0.2.1" + }, + "directories": {}, + "dist": { + "shasum": "2f2e85ef46140dbea6cb55e739b6b11b30eaa509", + "tarball": "http://registry.npmjs.org/micromatch/-/micromatch-2.3.7.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js", + "lib/" + ], + "gitHead": "cf7209ba3a3c962613509d5ec61a890aaf2a42a0", + "homepage": "https://github.com/jonschlinkert/micromatch", + "installable": true, + "keywords": [ + "bash", + "expand", + "expansion", + "expression", + "file", + "files", + "filter", + "find", + "glob", + "globbing", + "globs", + "globstar", + "match", + "matcher", + "matches", + "matching", + "minimatch", + "multimatch", + "path", + "pattern", + "patterns", + "regex", + "regexp", + "regular", + "shell", + "wildcard" + ], + "license": "MIT", + "main": "index.js", + "maintainers": [ + { + "name": "jonschlinkert", + "email": "github@sellside.com" + }, + { + "name": "doowb", + "email": "brian.woodward@gmail.com" + }, + { + "name": "es128", + "email": "elan.shanker+npm@gmail.com" + } + ], + "name": "micromatch", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git+https://github.com/jonschlinkert/micromatch.git" + }, + "scripts": { + "test": "mocha" + }, + "verb": { + "reflinks": [ + "braces", + "expand-brackets", + "extglob", + "minimatch", + "multimatch", + "verb" + ], + "related": { + "list": [ + "braces", + "expand-brackets", + "expand-range", + "extglob", + "fill-range", + "gulp-micromatch", + "is-glob", + "parse-glob" + ] + } + }, + "version": "2.3.7" +} diff --git a/tools/node_modules/minimatch/LICENSE b/tools/node_modules/minimatch/LICENSE new file mode 100644 index 00000000000000..19129e315fe593 --- /dev/null +++ b/tools/node_modules/minimatch/LICENSE @@ -0,0 +1,15 @@ +The ISC License + +Copyright (c) Isaac Z. Schlueter and Contributors + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR +IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/tools/node_modules/minimatch/README.md b/tools/node_modules/minimatch/README.md new file mode 100644 index 00000000000000..d458bc2e0a6b03 --- /dev/null +++ b/tools/node_modules/minimatch/README.md @@ -0,0 +1,216 @@ +# minimatch + +A minimal matching utility. + +[![Build Status](https://secure.travis-ci.org/isaacs/minimatch.png)](http://travis-ci.org/isaacs/minimatch) + + +This is the matching library used internally by npm. + +It works by converting glob expressions into JavaScript `RegExp` +objects. + +## Usage + +```javascript +var minimatch = require("minimatch") + +minimatch("bar.foo", "*.foo") // true! +minimatch("bar.foo", "*.bar") // false! +minimatch("bar.foo", "*.+(bar|foo)", { debug: true }) // true, and noisy! +``` + +## Features + +Supports these glob features: + +* Brace Expansion +* Extended glob matching +* "Globstar" `**` matching + +See: + +* `man sh` +* `man bash` +* `man 3 fnmatch` +* `man 5 gitignore` + +## Minimatch Class + +Create a minimatch object by instanting the `minimatch.Minimatch` class. + +```javascript +var Minimatch = require("minimatch").Minimatch +var mm = new Minimatch(pattern, options) +``` + +### Properties + +* `pattern` The original pattern the minimatch object represents. +* `options` The options supplied to the constructor. +* `set` A 2-dimensional array of regexp or string expressions. + Each row in the + array corresponds to a brace-expanded pattern. Each item in the row + corresponds to a single path-part. For example, the pattern + `{a,b/c}/d` would expand to a set of patterns like: + + [ [ a, d ] + , [ b, c, d ] ] + + If a portion of the pattern doesn't have any "magic" in it + (that is, it's something like `"foo"` rather than `fo*o?`), then it + will be left as a string rather than converted to a regular + expression. + +* `regexp` Created by the `makeRe` method. A single regular expression + expressing the entire pattern. This is useful in cases where you wish + to use the pattern somewhat like `fnmatch(3)` with `FNM_PATH` enabled. +* `negate` True if the pattern is negated. +* `comment` True if the pattern is a comment. +* `empty` True if the pattern is `""`. + +### Methods + +* `makeRe` Generate the `regexp` member if necessary, and return it. + Will return `false` if the pattern is invalid. +* `match(fname)` Return true if the filename matches the pattern, or + false otherwise. +* `matchOne(fileArray, patternArray, partial)` Take a `/`-split + filename, and match it against a single row in the `regExpSet`. This + method is mainly for internal use, but is exposed so that it can be + used by a glob-walker that needs to avoid excessive filesystem calls. + +All other methods are internal, and will be called as necessary. + +## Functions + +The top-level exported function has a `cache` property, which is an LRU +cache set to store 100 items. So, calling these methods repeatedly +with the same pattern and options will use the same Minimatch object, +saving the cost of parsing it multiple times. + +### minimatch(path, pattern, options) + +Main export. Tests a path against the pattern using the options. + +```javascript +var isJS = minimatch(file, "*.js", { matchBase: true }) +``` + +### minimatch.filter(pattern, options) + +Returns a function that tests its +supplied argument, suitable for use with `Array.filter`. Example: + +```javascript +var javascripts = fileList.filter(minimatch.filter("*.js", {matchBase: true})) +``` + +### minimatch.match(list, pattern, options) + +Match against the list of +files, in the style of fnmatch or glob. If nothing is matched, and +options.nonull is set, then return a list containing the pattern itself. + +```javascript +var javascripts = minimatch.match(fileList, "*.js", {matchBase: true})) +``` + +### minimatch.makeRe(pattern, options) + +Make a regular expression object from the pattern. + +## Options + +All options are `false` by default. + +### debug + +Dump a ton of stuff to stderr. + +### nobrace + +Do not expand `{a,b}` and `{1..3}` brace sets. + +### noglobstar + +Disable `**` matching against multiple folder names. + +### dot + +Allow patterns to match filenames starting with a period, even if +the pattern does not explicitly have a period in that spot. + +Note that by default, `a/**/b` will **not** match `a/.d/b`, unless `dot` +is set. + +### noext + +Disable "extglob" style patterns like `+(a|b)`. + +### nocase + +Perform a case-insensitive match. + +### nonull + +When a match is not found by `minimatch.match`, return a list containing +the pattern itself if this option is set. When not set, an empty list +is returned if there are no matches. + +### matchBase + +If set, then patterns without slashes will be matched +against the basename of the path if it contains slashes. For example, +`a?b` would match the path `/xyz/123/acb`, but not `/xyz/acb/123`. + +### nocomment + +Suppress the behavior of treating `#` at the start of a pattern as a +comment. + +### nonegate + +Suppress the behavior of treating a leading `!` character as negation. + +### flipNegate + +Returns from negate expressions the same as if they were not negated. +(Ie, true on a hit, false on a miss.) + + +## Comparisons to other fnmatch/glob implementations + +While strict compliance with the existing standards is a worthwhile +goal, some discrepancies exist between minimatch and other +implementations, and are intentional. + +If the pattern starts with a `!` character, then it is negated. Set the +`nonegate` flag to suppress this behavior, and treat leading `!` +characters normally. This is perhaps relevant if you wish to start the +pattern with a negative extglob pattern like `!(a|B)`. Multiple `!` +characters at the start of a pattern will negate the pattern multiple +times. + +If a pattern starts with `#`, then it is treated as a comment, and +will not match anything. Use `\#` to match a literal `#` at the +start of a line, or set the `nocomment` flag to suppress this behavior. + +The double-star character `**` is supported by default, unless the +`noglobstar` flag is set. This is supported in the manner of bsdglob +and bash 4.1, where `**` only has special significance if it is the only +thing in a path part. That is, `a/**/b` will match `a/x/y/b`, but +`a/**b` will not. + +If an escaped pattern has no matches, and the `nonull` flag is set, +then minimatch.match returns the pattern as-provided, rather than +interpreting the character escapes. For example, +`minimatch.match([], "\\*a\\?")` will return `"\\*a\\?"` rather than +`"*a?"`. This is akin to setting the `nullglob` option in bash, except +that it does not resolve escaped pattern characters. + +If brace expansion is not disabled, then it is performed before any +other interpretation of the glob pattern. Thus, a pattern like +`+(a|{b),c)}`, which would not be valid in bash or zsh, is expanded +**first** into the set of `+(a|b)` and `+(a|c)`, and those patterns are +checked for validity. Since those two are valid, matching proceeds. diff --git a/tools/node_modules/minimatch/minimatch.js b/tools/node_modules/minimatch/minimatch.js new file mode 100644 index 00000000000000..ec4c05c570c52e --- /dev/null +++ b/tools/node_modules/minimatch/minimatch.js @@ -0,0 +1,912 @@ +module.exports = minimatch +minimatch.Minimatch = Minimatch + +var path = { sep: '/' } +try { + path = require('path') +} catch (er) {} + +var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {} +var expand = require('brace-expansion') + +// any single thing other than / +// don't need to escape / when using new RegExp() +var qmark = '[^/]' + +// * => any number of characters +var star = qmark + '*?' + +// ** when dots are allowed. Anything goes, except .. and . +// not (^ or / followed by one or two dots followed by $ or /), +// followed by anything, any number of times. +var twoStarDot = '(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?' + +// not a ^ or / followed by a dot, +// followed by anything, any number of times. +var twoStarNoDot = '(?:(?!(?:\\\/|^)\\.).)*?' + +// characters that need to be escaped in RegExp. +var reSpecials = charSet('().*{}+?[]^$\\!') + +// "abc" -> { a:true, b:true, c:true } +function charSet (s) { + return s.split('').reduce(function (set, c) { + set[c] = true + return set + }, {}) +} + +// normalizes slashes. +var slashSplit = /\/+/ + +minimatch.filter = filter +function filter (pattern, options) { + options = options || {} + return function (p, i, list) { + return minimatch(p, pattern, options) + } +} + +function ext (a, b) { + a = a || {} + b = b || {} + var t = {} + Object.keys(b).forEach(function (k) { + t[k] = b[k] + }) + Object.keys(a).forEach(function (k) { + t[k] = a[k] + }) + return t +} + +minimatch.defaults = function (def) { + if (!def || !Object.keys(def).length) return minimatch + + var orig = minimatch + + var m = function minimatch (p, pattern, options) { + return orig.minimatch(p, pattern, ext(def, options)) + } + + m.Minimatch = function Minimatch (pattern, options) { + return new orig.Minimatch(pattern, ext(def, options)) + } + + return m +} + +Minimatch.defaults = function (def) { + if (!def || !Object.keys(def).length) return Minimatch + return minimatch.defaults(def).Minimatch +} + +function minimatch (p, pattern, options) { + if (typeof pattern !== 'string') { + throw new TypeError('glob pattern string required') + } + + if (!options) options = {} + + // shortcut: comments match nothing. + if (!options.nocomment && pattern.charAt(0) === '#') { + return false + } + + // "" only matches "" + if (pattern.trim() === '') return p === '' + + return new Minimatch(pattern, options).match(p) +} + +function Minimatch (pattern, options) { + if (!(this instanceof Minimatch)) { + return new Minimatch(pattern, options) + } + + if (typeof pattern !== 'string') { + throw new TypeError('glob pattern string required') + } + + if (!options) options = {} + pattern = pattern.trim() + + // windows support: need to use /, not \ + if (path.sep !== '/') { + pattern = pattern.split(path.sep).join('/') + } + + this.options = options + this.set = [] + this.pattern = pattern + this.regexp = null + this.negate = false + this.comment = false + this.empty = false + + // make the set of regexps etc. + this.make() +} + +Minimatch.prototype.debug = function () {} + +Minimatch.prototype.make = make +function make () { + // don't do it more than once. + if (this._made) return + + var pattern = this.pattern + var options = this.options + + // empty patterns and comments match nothing. + if (!options.nocomment && pattern.charAt(0) === '#') { + this.comment = true + return + } + if (!pattern) { + this.empty = true + return + } + + // step 1: figure out negation, etc. + this.parseNegate() + + // step 2: expand braces + var set = this.globSet = this.braceExpand() + + if (options.debug) this.debug = console.error + + this.debug(this.pattern, set) + + // step 3: now we have a set, so turn each one into a series of path-portion + // matching patterns. + // These will be regexps, except in the case of "**", which is + // set to the GLOBSTAR object for globstar behavior, + // and will not contain any / characters + set = this.globParts = set.map(function (s) { + return s.split(slashSplit) + }) + + this.debug(this.pattern, set) + + // glob --> regexps + set = set.map(function (s, si, set) { + return s.map(this.parse, this) + }, this) + + this.debug(this.pattern, set) + + // filter out everything that didn't compile properly. + set = set.filter(function (s) { + return s.indexOf(false) === -1 + }) + + this.debug(this.pattern, set) + + this.set = set +} + +Minimatch.prototype.parseNegate = parseNegate +function parseNegate () { + var pattern = this.pattern + var negate = false + var options = this.options + var negateOffset = 0 + + if (options.nonegate) return + + for (var i = 0, l = pattern.length + ; i < l && pattern.charAt(i) === '!' + ; i++) { + negate = !negate + negateOffset++ + } + + if (negateOffset) this.pattern = pattern.substr(negateOffset) + this.negate = negate +} + +// Brace expansion: +// a{b,c}d -> abd acd +// a{b,}c -> abc ac +// a{0..3}d -> a0d a1d a2d a3d +// a{b,c{d,e}f}g -> abg acdfg acefg +// a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg +// +// Invalid sets are not expanded. +// a{2..}b -> a{2..}b +// a{b}c -> a{b}c +minimatch.braceExpand = function (pattern, options) { + return braceExpand(pattern, options) +} + +Minimatch.prototype.braceExpand = braceExpand + +function braceExpand (pattern, options) { + if (!options) { + if (this instanceof Minimatch) { + options = this.options + } else { + options = {} + } + } + + pattern = typeof pattern === 'undefined' + ? this.pattern : pattern + + if (typeof pattern === 'undefined') { + throw new Error('undefined pattern') + } + + if (options.nobrace || + !pattern.match(/\{.*\}/)) { + // shortcut. no need to expand. + return [pattern] + } + + return expand(pattern) +} + +// parse a component of the expanded set. +// At this point, no pattern may contain "/" in it +// so we're going to return a 2d array, where each entry is the full +// pattern, split on '/', and then turned into a regular expression. +// A regexp is made at the end which joins each array with an +// escaped /, and another full one which joins each regexp with |. +// +// Following the lead of Bash 4.1, note that "**" only has special meaning +// when it is the *only* thing in a path portion. Otherwise, any series +// of * is equivalent to a single *. Globstar behavior is enabled by +// default, and can be disabled by setting options.noglobstar. +Minimatch.prototype.parse = parse +var SUBPARSE = {} +function parse (pattern, isSub) { + var options = this.options + + // shortcuts + if (!options.noglobstar && pattern === '**') return GLOBSTAR + if (pattern === '') return '' + + var re = '' + var hasMagic = !!options.nocase + var escaping = false + // ? => one single character + var patternListStack = [] + var negativeLists = [] + var plType + var stateChar + var inClass = false + var reClassStart = -1 + var classStart = -1 + // . and .. never match anything that doesn't start with ., + // even when options.dot is set. + var patternStart = pattern.charAt(0) === '.' ? '' // anything + // not (start or / followed by . or .. followed by / or end) + : options.dot ? '(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))' + : '(?!\\.)' + var self = this + + function clearStateChar () { + if (stateChar) { + // we had some state-tracking character + // that wasn't consumed by this pass. + switch (stateChar) { + case '*': + re += star + hasMagic = true + break + case '?': + re += qmark + hasMagic = true + break + default: + re += '\\' + stateChar + break + } + self.debug('clearStateChar %j %j', stateChar, re) + stateChar = false + } + } + + for (var i = 0, len = pattern.length, c + ; (i < len) && (c = pattern.charAt(i)) + ; i++) { + this.debug('%s\t%s %s %j', pattern, i, re, c) + + // skip over any that are escaped. + if (escaping && reSpecials[c]) { + re += '\\' + c + escaping = false + continue + } + + switch (c) { + case '/': + // completely not allowed, even escaped. + // Should already be path-split by now. + return false + + case '\\': + clearStateChar() + escaping = true + continue + + // the various stateChar values + // for the "extglob" stuff. + case '?': + case '*': + case '+': + case '@': + case '!': + this.debug('%s\t%s %s %j <-- stateChar', pattern, i, re, c) + + // all of those are literals inside a class, except that + // the glob [!a] means [^a] in regexp + if (inClass) { + this.debug(' in class') + if (c === '!' && i === classStart + 1) c = '^' + re += c + continue + } + + // if we already have a stateChar, then it means + // that there was something like ** or +? in there. + // Handle the stateChar, then proceed with this one. + self.debug('call clearStateChar %j', stateChar) + clearStateChar() + stateChar = c + // if extglob is disabled, then +(asdf|foo) isn't a thing. + // just clear the statechar *now*, rather than even diving into + // the patternList stuff. + if (options.noext) clearStateChar() + continue + + case '(': + if (inClass) { + re += '(' + continue + } + + if (!stateChar) { + re += '\\(' + continue + } + + plType = stateChar + patternListStack.push({ + type: plType, + start: i - 1, + reStart: re.length + }) + // negation is (?:(?!js)[^/]*) + re += stateChar === '!' ? '(?:(?!(?:' : '(?:' + this.debug('plType %j %j', stateChar, re) + stateChar = false + continue + + case ')': + if (inClass || !patternListStack.length) { + re += '\\)' + continue + } + + clearStateChar() + hasMagic = true + re += ')' + var pl = patternListStack.pop() + plType = pl.type + // negation is (?:(?!js)[^/]*) + // The others are (?:) + switch (plType) { + case '!': + negativeLists.push(pl) + re += ')[^/]*?)' + pl.reEnd = re.length + break + case '?': + case '+': + case '*': + re += plType + break + case '@': break // the default anyway + } + continue + + case '|': + if (inClass || !patternListStack.length || escaping) { + re += '\\|' + escaping = false + continue + } + + clearStateChar() + re += '|' + continue + + // these are mostly the same in regexp and glob + case '[': + // swallow any state-tracking char before the [ + clearStateChar() + + if (inClass) { + re += '\\' + c + continue + } + + inClass = true + classStart = i + reClassStart = re.length + re += c + continue + + case ']': + // a right bracket shall lose its special + // meaning and represent itself in + // a bracket expression if it occurs + // first in the list. -- POSIX.2 2.8.3.2 + if (i === classStart + 1 || !inClass) { + re += '\\' + c + escaping = false + continue + } + + // handle the case where we left a class open. + // "[z-a]" is valid, equivalent to "\[z-a\]" + if (inClass) { + // split where the last [ was, make sure we don't have + // an invalid re. if so, re-walk the contents of the + // would-be class to re-translate any characters that + // were passed through as-is + // TODO: It would probably be faster to determine this + // without a try/catch and a new RegExp, but it's tricky + // to do safely. For now, this is safe and works. + var cs = pattern.substring(classStart + 1, i) + try { + RegExp('[' + cs + ']') + } catch (er) { + // not a valid class! + var sp = this.parse(cs, SUBPARSE) + re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]' + hasMagic = hasMagic || sp[1] + inClass = false + continue + } + } + + // finish up the class. + hasMagic = true + inClass = false + re += c + continue + + default: + // swallow any state char that wasn't consumed + clearStateChar() + + if (escaping) { + // no need + escaping = false + } else if (reSpecials[c] + && !(c === '^' && inClass)) { + re += '\\' + } + + re += c + + } // switch + } // for + + // handle the case where we left a class open. + // "[abc" is valid, equivalent to "\[abc" + if (inClass) { + // split where the last [ was, and escape it + // this is a huge pita. We now have to re-walk + // the contents of the would-be class to re-translate + // any characters that were passed through as-is + cs = pattern.substr(classStart + 1) + sp = this.parse(cs, SUBPARSE) + re = re.substr(0, reClassStart) + '\\[' + sp[0] + hasMagic = hasMagic || sp[1] + } + + // handle the case where we had a +( thing at the *end* + // of the pattern. + // each pattern list stack adds 3 chars, and we need to go through + // and escape any | chars that were passed through as-is for the regexp. + // Go through and escape them, taking care not to double-escape any + // | chars that were already escaped. + for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) { + var tail = re.slice(pl.reStart + 3) + // maybe some even number of \, then maybe 1 \, followed by a | + tail = tail.replace(/((?:\\{2})*)(\\?)\|/g, function (_, $1, $2) { + if (!$2) { + // the | isn't already escaped, so escape it. + $2 = '\\' + } + + // need to escape all those slashes *again*, without escaping the + // one that we need for escaping the | character. As it works out, + // escaping an even number of slashes can be done by simply repeating + // it exactly after itself. That's why this trick works. + // + // I am sorry that you have to see this. + return $1 + $1 + $2 + '|' + }) + + this.debug('tail=%j\n %s', tail, tail) + var t = pl.type === '*' ? star + : pl.type === '?' ? qmark + : '\\' + pl.type + + hasMagic = true + re = re.slice(0, pl.reStart) + t + '\\(' + tail + } + + // handle trailing things that only matter at the very end. + clearStateChar() + if (escaping) { + // trailing \\ + re += '\\\\' + } + + // only need to apply the nodot start if the re starts with + // something that could conceivably capture a dot + var addPatternStart = false + switch (re.charAt(0)) { + case '.': + case '[': + case '(': addPatternStart = true + } + + // Hack to work around lack of negative lookbehind in JS + // A pattern like: *.!(x).!(y|z) needs to ensure that a name + // like 'a.xyz.yz' doesn't match. So, the first negative + // lookahead, has to look ALL the way ahead, to the end of + // the pattern. + for (var n = negativeLists.length - 1; n > -1; n--) { + var nl = negativeLists[n] + + var nlBefore = re.slice(0, nl.reStart) + var nlFirst = re.slice(nl.reStart, nl.reEnd - 8) + var nlLast = re.slice(nl.reEnd - 8, nl.reEnd) + var nlAfter = re.slice(nl.reEnd) + + nlLast += nlAfter + + // Handle nested stuff like *(*.js|!(*.json)), where open parens + // mean that we should *not* include the ) in the bit that is considered + // "after" the negated section. + var openParensBefore = nlBefore.split('(').length - 1 + var cleanAfter = nlAfter + for (i = 0; i < openParensBefore; i++) { + cleanAfter = cleanAfter.replace(/\)[+*?]?/, '') + } + nlAfter = cleanAfter + + var dollar = '' + if (nlAfter === '' && isSub !== SUBPARSE) { + dollar = '$' + } + var newRe = nlBefore + nlFirst + nlAfter + dollar + nlLast + re = newRe + } + + // if the re is not "" at this point, then we need to make sure + // it doesn't match against an empty path part. + // Otherwise a/* will match a/, which it should not. + if (re !== '' && hasMagic) { + re = '(?=.)' + re + } + + if (addPatternStart) { + re = patternStart + re + } + + // parsing just a piece of a larger pattern. + if (isSub === SUBPARSE) { + return [re, hasMagic] + } + + // skip the regexp for non-magical patterns + // unescape anything in it, though, so that it'll be + // an exact match against a file etc. + if (!hasMagic) { + return globUnescape(pattern) + } + + var flags = options.nocase ? 'i' : '' + var regExp = new RegExp('^' + re + '$', flags) + + regExp._glob = pattern + regExp._src = re + + return regExp +} + +minimatch.makeRe = function (pattern, options) { + return new Minimatch(pattern, options || {}).makeRe() +} + +Minimatch.prototype.makeRe = makeRe +function makeRe () { + if (this.regexp || this.regexp === false) return this.regexp + + // at this point, this.set is a 2d array of partial + // pattern strings, or "**". + // + // It's better to use .match(). This function shouldn't + // be used, really, but it's pretty convenient sometimes, + // when you just want to work with a regex. + var set = this.set + + if (!set.length) { + this.regexp = false + return this.regexp + } + var options = this.options + + var twoStar = options.noglobstar ? star + : options.dot ? twoStarDot + : twoStarNoDot + var flags = options.nocase ? 'i' : '' + + var re = set.map(function (pattern) { + return pattern.map(function (p) { + return (p === GLOBSTAR) ? twoStar + : (typeof p === 'string') ? regExpEscape(p) + : p._src + }).join('\\\/') + }).join('|') + + // must match entire pattern + // ending in a * or ** will make it less strict. + re = '^(?:' + re + ')$' + + // can match anything, as long as it's not this. + if (this.negate) re = '^(?!' + re + ').*$' + + try { + this.regexp = new RegExp(re, flags) + } catch (ex) { + this.regexp = false + } + return this.regexp +} + +minimatch.match = function (list, pattern, options) { + options = options || {} + var mm = new Minimatch(pattern, options) + list = list.filter(function (f) { + return mm.match(f) + }) + if (mm.options.nonull && !list.length) { + list.push(pattern) + } + return list +} + +Minimatch.prototype.match = match +function match (f, partial) { + this.debug('match', f, this.pattern) + // short-circuit in the case of busted things. + // comments, etc. + if (this.comment) return false + if (this.empty) return f === '' + + if (f === '/' && partial) return true + + var options = this.options + + // windows: need to use /, not \ + if (path.sep !== '/') { + f = f.split(path.sep).join('/') + } + + // treat the test path as a set of pathparts. + f = f.split(slashSplit) + this.debug(this.pattern, 'split', f) + + // just ONE of the pattern sets in this.set needs to match + // in order for it to be valid. If negating, then just one + // match means that we have failed. + // Either way, return on the first hit. + + var set = this.set + this.debug(this.pattern, 'set', set) + + // Find the basename of the path by looking for the last non-empty segment + var filename + var i + for (i = f.length - 1; i >= 0; i--) { + filename = f[i] + if (filename) break + } + + for (i = 0; i < set.length; i++) { + var pattern = set[i] + var file = f + if (options.matchBase && pattern.length === 1) { + file = [filename] + } + var hit = this.matchOne(file, pattern, partial) + if (hit) { + if (options.flipNegate) return true + return !this.negate + } + } + + // didn't get any hits. this is success if it's a negative + // pattern, failure otherwise. + if (options.flipNegate) return false + return this.negate +} + +// set partial to true to test if, for example, +// "/a/b" matches the start of "/*/b/*/d" +// Partial means, if you run out of file before you run +// out of pattern, then that's fine, as long as all +// the parts match. +Minimatch.prototype.matchOne = function (file, pattern, partial) { + var options = this.options + + this.debug('matchOne', + { 'this': this, file: file, pattern: pattern }) + + this.debug('matchOne', file.length, pattern.length) + + for (var fi = 0, + pi = 0, + fl = file.length, + pl = pattern.length + ; (fi < fl) && (pi < pl) + ; fi++, pi++) { + this.debug('matchOne loop') + var p = pattern[pi] + var f = file[fi] + + this.debug(pattern, p, f) + + // should be impossible. + // some invalid regexp stuff in the set. + if (p === false) return false + + if (p === GLOBSTAR) { + this.debug('GLOBSTAR', [pattern, p, f]) + + // "**" + // a/**/b/**/c would match the following: + // a/b/x/y/z/c + // a/x/y/z/b/c + // a/b/x/b/x/c + // a/b/c + // To do this, take the rest of the pattern after + // the **, and see if it would match the file remainder. + // If so, return success. + // If not, the ** "swallows" a segment, and try again. + // This is recursively awful. + // + // a/**/b/**/c matching a/b/x/y/z/c + // - a matches a + // - doublestar + // - matchOne(b/x/y/z/c, b/**/c) + // - b matches b + // - doublestar + // - matchOne(x/y/z/c, c) -> no + // - matchOne(y/z/c, c) -> no + // - matchOne(z/c, c) -> no + // - matchOne(c, c) yes, hit + var fr = fi + var pr = pi + 1 + if (pr === pl) { + this.debug('** at the end') + // a ** at the end will just swallow the rest. + // We have found a match. + // however, it will not swallow /.x, unless + // options.dot is set. + // . and .. are *never* matched by **, for explosively + // exponential reasons. + for (; fi < fl; fi++) { + if (file[fi] === '.' || file[fi] === '..' || + (!options.dot && file[fi].charAt(0) === '.')) return false + } + return true + } + + // ok, let's see if we can swallow whatever we can. + while (fr < fl) { + var swallowee = file[fr] + + this.debug('\nglobstar while', file, fr, pattern, pr, swallowee) + + // XXX remove this slice. Just pass the start index. + if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) { + this.debug('globstar found match!', fr, fl, swallowee) + // found a match. + return true + } else { + // can't swallow "." or ".." ever. + // can only swallow ".foo" when explicitly asked. + if (swallowee === '.' || swallowee === '..' || + (!options.dot && swallowee.charAt(0) === '.')) { + this.debug('dot detected!', file, fr, pattern, pr) + break + } + + // ** swallows a segment, and continue. + this.debug('globstar swallow a segment, and continue') + fr++ + } + } + + // no match was found. + // However, in partial mode, we can't say this is necessarily over. + // If there's more *pattern* left, then + if (partial) { + // ran out of file + this.debug('\n>>> no match, partial?', file, fr, pattern, pr) + if (fr === fl) return true + } + return false + } + + // something other than ** + // non-magic patterns just have to match exactly + // patterns with magic have been turned into regexps. + var hit + if (typeof p === 'string') { + if (options.nocase) { + hit = f.toLowerCase() === p.toLowerCase() + } else { + hit = f === p + } + this.debug('string match', p, f, hit) + } else { + hit = f.match(p) + this.debug('pattern match', p, f, hit) + } + + if (!hit) return false + } + + // Note: ending in / means that we'll get a final "" + // at the end of the pattern. This can only match a + // corresponding "" at the end of the file. + // If the file ends in /, then it can only match a + // a pattern that ends in /, unless the pattern just + // doesn't have any more for it. But, a/b/ should *not* + // match "a/b/*", even though "" matches against the + // [^/]*? pattern, except in partial mode, where it might + // simply not be reached yet. + // However, a/b/ should still satisfy a/* + + // now either we fell off the end of the pattern, or we're done. + if (fi === fl && pi === pl) { + // ran out of pattern and filename at the same time. + // an exact hit! + return true + } else if (fi === fl) { + // ran out of file, but still had pattern left. + // this is ok if we're doing the match as part of + // a glob fs traversal. + return partial + } else if (pi === pl) { + // ran out of pattern, still have file left. + // this is only acceptable if we're on the very last + // empty segment of a file with a trailing slash. + // a/* should match a/b/ + var emptyFileEnd = (fi === fl - 1) && (file[fi] === '') + return emptyFileEnd + } + + // should be unreachable. + throw new Error('wtf?') +} + +// replace stuff like \* with * +function globUnescape (s) { + return s.replace(/\\(.)/g, '$1') +} + +function regExpEscape (s) { + return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&') +} diff --git a/tools/node_modules/minimatch/package.json b/tools/node_modules/minimatch/package.json new file mode 100644 index 00000000000000..dbaadd1644d6e0 --- /dev/null +++ b/tools/node_modules/minimatch/package.json @@ -0,0 +1,85 @@ +{ + "_args": [ + [ + "minimatch@^3.0.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\remark" + ] + ], + "_from": "minimatch@>=3.0.0 <4.0.0", + "_id": "minimatch@3.0.0", + "_inCache": true, + "_location": "/minimatch", + "_nodeVersion": "4.0.0", + "_npmUser": { + "email": "isaacs@npmjs.com", + "name": "isaacs" + }, + "_npmVersion": "3.3.2", + "_phantomChildren": {}, + "_requested": { + "name": "minimatch", + "raw": "minimatch@^3.0.0", + "rawSpec": "^3.0.0", + "scope": null, + "spec": ">=3.0.0 <4.0.0", + "type": "range" + }, + "_requiredBy": [ + "/glob", + "/remark" + ], + "_resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.0.tgz", + "_shasum": "5236157a51e4f004c177fb3c527ff7dd78f0ef83", + "_shrinkwrap": null, + "_spec": "minimatch@^3.0.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\remark", + "author": { + "email": "i@izs.me", + "name": "Isaac Z. Schlueter", + "url": "http://blog.izs.me" + }, + "bugs": { + "url": "https://github.com/isaacs/minimatch/issues" + }, + "dependencies": { + "brace-expansion": "^1.0.0" + }, + "description": "a glob matcher in javascript", + "devDependencies": { + "standard": "^3.7.2", + "tap": "^1.2.0" + }, + "directories": {}, + "dist": { + "shasum": "5236157a51e4f004c177fb3c527ff7dd78f0ef83", + "tarball": "http://registry.npmjs.org/minimatch/-/minimatch-3.0.0.tgz" + }, + "engines": { + "node": "*" + }, + "files": [ + "minimatch.js" + ], + "gitHead": "270dbea567f0af6918cb18103e98c612aa717a20", + "homepage": "https://github.com/isaacs/minimatch#readme", + "installable": true, + "license": "ISC", + "main": "minimatch.js", + "maintainers": [ + { + "name": "isaacs", + "email": "i@izs.me" + } + ], + "name": "minimatch", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git://github.com/isaacs/minimatch.git" + }, + "scripts": { + "posttest": "standard minimatch.js test/*.js", + "test": "tap test/*.js" + }, + "version": "3.0.0" +} diff --git a/tools/node_modules/minimist/.travis.yml b/tools/node_modules/minimist/.travis.yml new file mode 100644 index 00000000000000..74c57bf15e2391 --- /dev/null +++ b/tools/node_modules/minimist/.travis.yml @@ -0,0 +1,8 @@ +language: node_js +node_js: + - "0.8" + - "0.10" + - "0.12" + - "iojs" +before_install: + - npm install -g npm@~1.4.6 diff --git a/tools/node_modules/minimist/LICENSE b/tools/node_modules/minimist/LICENSE new file mode 100644 index 00000000000000..ee27ba4b4412b0 --- /dev/null +++ b/tools/node_modules/minimist/LICENSE @@ -0,0 +1,18 @@ +This software is released under the MIT license: + +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. diff --git a/tools/node_modules/minimist/example/parse.js b/tools/node_modules/minimist/example/parse.js new file mode 100644 index 00000000000000..abff3e8ee8f5ef --- /dev/null +++ b/tools/node_modules/minimist/example/parse.js @@ -0,0 +1,2 @@ +var argv = require('../')(process.argv.slice(2)); +console.dir(argv); diff --git a/tools/node_modules/minimist/index.js b/tools/node_modules/minimist/index.js new file mode 100644 index 00000000000000..6a0559d58133a8 --- /dev/null +++ b/tools/node_modules/minimist/index.js @@ -0,0 +1,236 @@ +module.exports = function (args, opts) { + if (!opts) opts = {}; + + var flags = { bools : {}, strings : {}, unknownFn: null }; + + if (typeof opts['unknown'] === 'function') { + flags.unknownFn = opts['unknown']; + } + + if (typeof opts['boolean'] === 'boolean' && opts['boolean']) { + flags.allBools = true; + } else { + [].concat(opts['boolean']).filter(Boolean).forEach(function (key) { + flags.bools[key] = true; + }); + } + + var aliases = {}; + Object.keys(opts.alias || {}).forEach(function (key) { + aliases[key] = [].concat(opts.alias[key]); + aliases[key].forEach(function (x) { + aliases[x] = [key].concat(aliases[key].filter(function (y) { + return x !== y; + })); + }); + }); + + [].concat(opts.string).filter(Boolean).forEach(function (key) { + flags.strings[key] = true; + if (aliases[key]) { + flags.strings[aliases[key]] = true; + } + }); + + var defaults = opts['default'] || {}; + + var argv = { _ : [] }; + Object.keys(flags.bools).forEach(function (key) { + setArg(key, defaults[key] === undefined ? false : defaults[key]); + }); + + var notFlags = []; + + if (args.indexOf('--') !== -1) { + notFlags = args.slice(args.indexOf('--')+1); + args = args.slice(0, args.indexOf('--')); + } + + function argDefined(key, arg) { + return (flags.allBools && /^--[^=]+$/.test(arg)) || + flags.strings[key] || flags.bools[key] || aliases[key]; + } + + function setArg (key, val, arg) { + if (arg && flags.unknownFn && !argDefined(key, arg)) { + if (flags.unknownFn(arg) === false) return; + } + + var value = !flags.strings[key] && isNumber(val) + ? Number(val) : val + ; + setKey(argv, key.split('.'), value); + + (aliases[key] || []).forEach(function (x) { + setKey(argv, x.split('.'), value); + }); + } + + function setKey (obj, keys, value) { + var o = obj; + keys.slice(0,-1).forEach(function (key) { + if (o[key] === undefined) o[key] = {}; + o = o[key]; + }); + + var key = keys[keys.length - 1]; + if (o[key] === undefined || flags.bools[key] || typeof o[key] === 'boolean') { + o[key] = value; + } + else if (Array.isArray(o[key])) { + o[key].push(value); + } + else { + o[key] = [ o[key], value ]; + } + } + + function aliasIsBoolean(key) { + return aliases[key].some(function (x) { + return flags.bools[x]; + }); + } + + for (var i = 0; i < args.length; i++) { + var arg = args[i]; + + if (/^--.+=/.test(arg)) { + // Using [\s\S] instead of . because js doesn't support the + // 'dotall' regex modifier. See: + // http://stackoverflow.com/a/1068308/13216 + var m = arg.match(/^--([^=]+)=([\s\S]*)$/); + var key = m[1]; + var value = m[2]; + if (flags.bools[key]) { + value = value !== 'false'; + } + setArg(key, value, arg); + } + else if (/^--no-.+/.test(arg)) { + var key = arg.match(/^--no-(.+)/)[1]; + setArg(key, false, arg); + } + else if (/^--.+/.test(arg)) { + var key = arg.match(/^--(.+)/)[1]; + var next = args[i + 1]; + if (next !== undefined && !/^-/.test(next) + && !flags.bools[key] + && !flags.allBools + && (aliases[key] ? !aliasIsBoolean(key) : true)) { + setArg(key, next, arg); + i++; + } + else if (/^(true|false)$/.test(next)) { + setArg(key, next === 'true', arg); + i++; + } + else { + setArg(key, flags.strings[key] ? '' : true, arg); + } + } + else if (/^-[^-]+/.test(arg)) { + var letters = arg.slice(1,-1).split(''); + + var broken = false; + for (var j = 0; j < letters.length; j++) { + var next = arg.slice(j+2); + + if (next === '-') { + setArg(letters[j], next, arg) + continue; + } + + if (/[A-Za-z]/.test(letters[j]) && /=/.test(next)) { + setArg(letters[j], next.split('=')[1], arg); + broken = true; + break; + } + + if (/[A-Za-z]/.test(letters[j]) + && /-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) { + setArg(letters[j], next, arg); + broken = true; + break; + } + + if (letters[j+1] && letters[j+1].match(/\W/)) { + setArg(letters[j], arg.slice(j+2), arg); + broken = true; + break; + } + else { + setArg(letters[j], flags.strings[letters[j]] ? '' : true, arg); + } + } + + var key = arg.slice(-1)[0]; + if (!broken && key !== '-') { + if (args[i+1] && !/^(-|--)[^-]/.test(args[i+1]) + && !flags.bools[key] + && (aliases[key] ? !aliasIsBoolean(key) : true)) { + setArg(key, args[i+1], arg); + i++; + } + else if (args[i+1] && /true|false/.test(args[i+1])) { + setArg(key, args[i+1] === 'true', arg); + i++; + } + else { + setArg(key, flags.strings[key] ? '' : true, arg); + } + } + } + else { + if (!flags.unknownFn || flags.unknownFn(arg) !== false) { + argv._.push( + flags.strings['_'] || !isNumber(arg) ? arg : Number(arg) + ); + } + if (opts.stopEarly) { + argv._.push.apply(argv._, args.slice(i + 1)); + break; + } + } + } + + Object.keys(defaults).forEach(function (key) { + if (!hasKey(argv, key.split('.'))) { + setKey(argv, key.split('.'), defaults[key]); + + (aliases[key] || []).forEach(function (x) { + setKey(argv, x.split('.'), defaults[key]); + }); + } + }); + + if (opts['--']) { + argv['--'] = new Array(); + notFlags.forEach(function(key) { + argv['--'].push(key); + }); + } + else { + notFlags.forEach(function(key) { + argv._.push(key); + }); + } + + return argv; +}; + +function hasKey (obj, keys) { + var o = obj; + keys.slice(0,-1).forEach(function (key) { + o = (o[key] || {}); + }); + + var key = keys[keys.length - 1]; + return key in o; +} + +function isNumber (x) { + if (typeof x === 'number') return true; + if (/^0x[0-9a-f]+$/i.test(x)) return true; + return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x); +} + diff --git a/tools/node_modules/minimist/package.json b/tools/node_modules/minimist/package.json new file mode 100644 index 00000000000000..f9b4c0b0213b53 --- /dev/null +++ b/tools/node_modules/minimist/package.json @@ -0,0 +1,96 @@ +{ + "_args": [ + [ + "minimist@^1.2.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\rc" + ] + ], + "_from": "minimist@>=1.2.0 <2.0.0", + "_id": "minimist@1.2.0", + "_inCache": true, + "_location": "/minimist", + "_nodeVersion": "2.4.0", + "_npmUser": { + "email": "substack@gmail.com", + "name": "substack" + }, + "_npmVersion": "3.2.2", + "_phantomChildren": {}, + "_requested": { + "name": "minimist", + "raw": "minimist@^1.2.0", + "rawSpec": "^1.2.0", + "scope": null, + "spec": ">=1.2.0 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/rc" + ], + "_resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "_shasum": "a35008b20f41383eec1fb914f4cd5df79a264284", + "_shrinkwrap": null, + "_spec": "minimist@^1.2.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\rc", + "author": { + "email": "mail@substack.net", + "name": "James Halliday", + "url": "http://substack.net" + }, + "bugs": { + "url": "https://github.com/substack/minimist/issues" + }, + "dependencies": {}, + "description": "parse argument options", + "devDependencies": { + "covert": "^1.0.0", + "tap": "~0.4.0", + "tape": "^3.5.0" + }, + "directories": {}, + "dist": { + "shasum": "a35008b20f41383eec1fb914f4cd5df79a264284", + "tarball": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz" + }, + "gitHead": "dc624482fcfec5bc669c68cdb861f00573ed4e64", + "homepage": "https://github.com/substack/minimist", + "installable": true, + "keywords": [ + "argv", + "getopt", + "optimist", + "parser" + ], + "license": "MIT", + "main": "index.js", + "maintainers": [ + { + "name": "substack", + "email": "mail@substack.net" + } + ], + "name": "minimist", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git://github.com/substack/minimist.git" + }, + "scripts": { + "coverage": "covert test/*.js", + "test": "tap test/*.js" + }, + "testling": { + "browsers": [ + "chrome/10", + "chrome/latest", + "ff/5", + "firefox/latest", + "ie/6..latest", + "opera/12", + "safari/5.1", + "safari/latest" + ], + "files": "test/*.js" + }, + "version": "1.2.0" +} diff --git a/tools/node_modules/minimist/readme.markdown b/tools/node_modules/minimist/readme.markdown new file mode 100644 index 00000000000000..30a74cf8c158d7 --- /dev/null +++ b/tools/node_modules/minimist/readme.markdown @@ -0,0 +1,91 @@ +# minimist + +parse argument options + +This module is the guts of optimist's argument parser without all the +fanciful decoration. + +[![browser support](https://ci.testling.com/substack/minimist.png)](http://ci.testling.com/substack/minimist) + +[![build status](https://secure.travis-ci.org/substack/minimist.png)](http://travis-ci.org/substack/minimist) + +# example + +``` js +var argv = require('minimist')(process.argv.slice(2)); +console.dir(argv); +``` + +``` +$ node example/parse.js -a beep -b boop +{ _: [], a: 'beep', b: 'boop' } +``` + +``` +$ node example/parse.js -x 3 -y 4 -n5 -abc --beep=boop foo bar baz +{ _: [ 'foo', 'bar', 'baz' ], + x: 3, + y: 4, + n: 5, + a: true, + b: true, + c: true, + beep: 'boop' } +``` + +# methods + +``` js +var parseArgs = require('minimist') +``` + +## var argv = parseArgs(args, opts={}) + +Return an argument object `argv` populated with the array arguments from `args`. + +`argv._` contains all the arguments that didn't have an option associated with +them. + +Numeric-looking arguments will be returned as numbers unless `opts.string` or +`opts.boolean` is set for that argument name. + +Any arguments after `'--'` will not be parsed and will end up in `argv._`. + +options can be: + +* `opts.string` - a string or array of strings argument names to always treat as +strings +* `opts.boolean` - a boolean, string or array of strings to always treat as +booleans. if `true` will treat all double hyphenated arguments without equal signs +as boolean (e.g. affects `--foo`, not `-f` or `--foo=bar`) +* `opts.alias` - an object mapping string names to strings or arrays of string +argument names to use as aliases +* `opts.default` - an object mapping string argument names to default values +* `opts.stopEarly` - when true, populate `argv._` with everything after the +first non-option +* `opts['--']` - when true, populate `argv._` with everything before the `--` +and `argv['--']` with everything after the `--`. Here's an example: +* `opts.unknown` - a function which is invoked with a command line parameter not +defined in the `opts` configuration object. If the function returns `false`, the +unknown option is not added to `argv`. + +``` +> require('./')('one two three -- four five --six'.split(' '), { '--': true }) +{ _: [ 'one', 'two', 'three' ], + '--': [ 'four', 'five', '--six' ] } +``` + +Note that with `opts['--']` set, parsing for arguments still stops after the +`--`. + +# install + +With [npm](https://npmjs.org) do: + +``` +npm install minimist +``` + +# license + +MIT diff --git a/tools/node_modules/minimist/test/all_bool.js b/tools/node_modules/minimist/test/all_bool.js new file mode 100644 index 00000000000000..ac835483d9a659 --- /dev/null +++ b/tools/node_modules/minimist/test/all_bool.js @@ -0,0 +1,32 @@ +var parse = require('../'); +var test = require('tape'); + +test('flag boolean true (default all --args to boolean)', function (t) { + var argv = parse(['moo', '--honk', 'cow'], { + boolean: true + }); + + t.deepEqual(argv, { + honk: true, + _: ['moo', 'cow'] + }); + + t.deepEqual(typeof argv.honk, 'boolean'); + t.end(); +}); + +test('flag boolean true only affects double hyphen arguments without equals signs', function (t) { + var argv = parse(['moo', '--honk', 'cow', '-p', '55', '--tacos=good'], { + boolean: true + }); + + t.deepEqual(argv, { + honk: true, + tacos: 'good', + p: 55, + _: ['moo', 'cow'] + }); + + t.deepEqual(typeof argv.honk, 'boolean'); + t.end(); +}); diff --git a/tools/node_modules/minimist/test/bool.js b/tools/node_modules/minimist/test/bool.js new file mode 100644 index 00000000000000..14b0717cefd5e9 --- /dev/null +++ b/tools/node_modules/minimist/test/bool.js @@ -0,0 +1,166 @@ +var parse = require('../'); +var test = require('tape'); + +test('flag boolean default false', function (t) { + var argv = parse(['moo'], { + boolean: ['t', 'verbose'], + default: { verbose: false, t: false } + }); + + t.deepEqual(argv, { + verbose: false, + t: false, + _: ['moo'] + }); + + t.deepEqual(typeof argv.verbose, 'boolean'); + t.deepEqual(typeof argv.t, 'boolean'); + t.end(); + +}); + +test('boolean groups', function (t) { + var argv = parse([ '-x', '-z', 'one', 'two', 'three' ], { + boolean: ['x','y','z'] + }); + + t.deepEqual(argv, { + x : true, + y : false, + z : true, + _ : [ 'one', 'two', 'three' ] + }); + + t.deepEqual(typeof argv.x, 'boolean'); + t.deepEqual(typeof argv.y, 'boolean'); + t.deepEqual(typeof argv.z, 'boolean'); + t.end(); +}); +test('boolean and alias with chainable api', function (t) { + var aliased = [ '-h', 'derp' ]; + var regular = [ '--herp', 'derp' ]; + var opts = { + herp: { alias: 'h', boolean: true } + }; + var aliasedArgv = parse(aliased, { + boolean: 'herp', + alias: { h: 'herp' } + }); + var propertyArgv = parse(regular, { + boolean: 'herp', + alias: { h: 'herp' } + }); + var expected = { + herp: true, + h: true, + '_': [ 'derp' ] + }; + + t.same(aliasedArgv, expected); + t.same(propertyArgv, expected); + t.end(); +}); + +test('boolean and alias with options hash', function (t) { + var aliased = [ '-h', 'derp' ]; + var regular = [ '--herp', 'derp' ]; + var opts = { + alias: { 'h': 'herp' }, + boolean: 'herp' + }; + var aliasedArgv = parse(aliased, opts); + var propertyArgv = parse(regular, opts); + var expected = { + herp: true, + h: true, + '_': [ 'derp' ] + }; + t.same(aliasedArgv, expected); + t.same(propertyArgv, expected); + t.end(); +}); + +test('boolean and alias array with options hash', function (t) { + var aliased = [ '-h', 'derp' ]; + var regular = [ '--herp', 'derp' ]; + var alt = [ '--harp', 'derp' ]; + var opts = { + alias: { 'h': ['herp', 'harp'] }, + boolean: 'h' + }; + var aliasedArgv = parse(aliased, opts); + var propertyArgv = parse(regular, opts); + var altPropertyArgv = parse(alt, opts); + var expected = { + harp: true, + herp: true, + h: true, + '_': [ 'derp' ] + }; + t.same(aliasedArgv, expected); + t.same(propertyArgv, expected); + t.same(altPropertyArgv, expected); + t.end(); +}); + +test('boolean and alias using explicit true', function (t) { + var aliased = [ '-h', 'true' ]; + var regular = [ '--herp', 'true' ]; + var opts = { + alias: { h: 'herp' }, + boolean: 'h' + }; + var aliasedArgv = parse(aliased, opts); + var propertyArgv = parse(regular, opts); + var expected = { + herp: true, + h: true, + '_': [ ] + }; + + t.same(aliasedArgv, expected); + t.same(propertyArgv, expected); + t.end(); +}); + +// regression, see https://github.com/substack/node-optimist/issues/71 +test('boolean and --x=true', function(t) { + var parsed = parse(['--boool', '--other=true'], { + boolean: 'boool' + }); + + t.same(parsed.boool, true); + t.same(parsed.other, 'true'); + + parsed = parse(['--boool', '--other=false'], { + boolean: 'boool' + }); + + t.same(parsed.boool, true); + t.same(parsed.other, 'false'); + t.end(); +}); + +test('boolean --boool=true', function (t) { + var parsed = parse(['--boool=true'], { + default: { + boool: false + }, + boolean: ['boool'] + }); + + t.same(parsed.boool, true); + t.end(); +}); + +test('boolean --boool=false', function (t) { + var parsed = parse(['--boool=false'], { + default: { + boool: true + }, + boolean: ['boool'] + }); + + t.same(parsed.boool, false); + t.end(); +}); diff --git a/tools/node_modules/minimist/test/dash.js b/tools/node_modules/minimist/test/dash.js new file mode 100644 index 00000000000000..5a4fa5be418596 --- /dev/null +++ b/tools/node_modules/minimist/test/dash.js @@ -0,0 +1,31 @@ +var parse = require('../'); +var test = require('tape'); + +test('-', function (t) { + t.plan(5); + t.deepEqual(parse([ '-n', '-' ]), { n: '-', _: [] }); + t.deepEqual(parse([ '-' ]), { _: [ '-' ] }); + t.deepEqual(parse([ '-f-' ]), { f: '-', _: [] }); + t.deepEqual( + parse([ '-b', '-' ], { boolean: 'b' }), + { b: true, _: [ '-' ] } + ); + t.deepEqual( + parse([ '-s', '-' ], { string: 's' }), + { s: '-', _: [] } + ); +}); + +test('-a -- b', function (t) { + t.plan(3); + t.deepEqual(parse([ '-a', '--', 'b' ]), { a: true, _: [ 'b' ] }); + t.deepEqual(parse([ '--a', '--', 'b' ]), { a: true, _: [ 'b' ] }); + t.deepEqual(parse([ '--a', '--', 'b' ]), { a: true, _: [ 'b' ] }); +}); + +test('move arguments after the -- into their own `--` array', function(t) { + t.plan(1); + t.deepEqual( + parse([ '--name', 'John', 'before', '--', 'after' ], { '--': true }), + { name: 'John', _: [ 'before' ], '--': [ 'after' ] }); +}); diff --git a/tools/node_modules/minimist/test/default_bool.js b/tools/node_modules/minimist/test/default_bool.js new file mode 100644 index 00000000000000..780a311270fcda --- /dev/null +++ b/tools/node_modules/minimist/test/default_bool.js @@ -0,0 +1,35 @@ +var test = require('tape'); +var parse = require('../'); + +test('boolean default true', function (t) { + var argv = parse([], { + boolean: 'sometrue', + default: { sometrue: true } + }); + t.equal(argv.sometrue, true); + t.end(); +}); + +test('boolean default false', function (t) { + var argv = parse([], { + boolean: 'somefalse', + default: { somefalse: false } + }); + t.equal(argv.somefalse, false); + t.end(); +}); + +test('boolean default to null', function (t) { + var argv = parse([], { + boolean: 'maybe', + default: { maybe: null } + }); + t.equal(argv.maybe, null); + var argv = parse(['--maybe'], { + boolean: 'maybe', + default: { maybe: null } + }); + t.equal(argv.maybe, true); + t.end(); + +}) diff --git a/tools/node_modules/minimist/test/dotted.js b/tools/node_modules/minimist/test/dotted.js new file mode 100644 index 00000000000000..d8b3e856ec795f --- /dev/null +++ b/tools/node_modules/minimist/test/dotted.js @@ -0,0 +1,22 @@ +var parse = require('../'); +var test = require('tape'); + +test('dotted alias', function (t) { + var argv = parse(['--a.b', '22'], {default: {'a.b': 11}, alias: {'a.b': 'aa.bb'}}); + t.equal(argv.a.b, 22); + t.equal(argv.aa.bb, 22); + t.end(); +}); + +test('dotted default', function (t) { + var argv = parse('', {default: {'a.b': 11}, alias: {'a.b': 'aa.bb'}}); + t.equal(argv.a.b, 11); + t.equal(argv.aa.bb, 11); + t.end(); +}); + +test('dotted default with no alias', function (t) { + var argv = parse('', {default: {'a.b': 11}}); + t.equal(argv.a.b, 11); + t.end(); +}); diff --git a/tools/node_modules/minimist/test/kv_short.js b/tools/node_modules/minimist/test/kv_short.js new file mode 100644 index 00000000000000..f813b305057b0a --- /dev/null +++ b/tools/node_modules/minimist/test/kv_short.js @@ -0,0 +1,16 @@ +var parse = require('../'); +var test = require('tape'); + +test('short -k=v' , function (t) { + t.plan(1); + + var argv = parse([ '-b=123' ]); + t.deepEqual(argv, { b: 123, _: [] }); +}); + +test('multi short -k=v' , function (t) { + t.plan(1); + + var argv = parse([ '-a=whatever', '-b=robots' ]); + t.deepEqual(argv, { a: 'whatever', b: 'robots', _: [] }); +}); diff --git a/tools/node_modules/minimist/test/long.js b/tools/node_modules/minimist/test/long.js new file mode 100644 index 00000000000000..5d3a1e09d3b64c --- /dev/null +++ b/tools/node_modules/minimist/test/long.js @@ -0,0 +1,31 @@ +var test = require('tape'); +var parse = require('../'); + +test('long opts', function (t) { + t.deepEqual( + parse([ '--bool' ]), + { bool : true, _ : [] }, + 'long boolean' + ); + t.deepEqual( + parse([ '--pow', 'xixxle' ]), + { pow : 'xixxle', _ : [] }, + 'long capture sp' + ); + t.deepEqual( + parse([ '--pow=xixxle' ]), + { pow : 'xixxle', _ : [] }, + 'long capture eq' + ); + t.deepEqual( + parse([ '--host', 'localhost', '--port', '555' ]), + { host : 'localhost', port : 555, _ : [] }, + 'long captures sp' + ); + t.deepEqual( + parse([ '--host=localhost', '--port=555' ]), + { host : 'localhost', port : 555, _ : [] }, + 'long captures eq' + ); + t.end(); +}); diff --git a/tools/node_modules/minimist/test/num.js b/tools/node_modules/minimist/test/num.js new file mode 100644 index 00000000000000..2cc77f4d62ffb2 --- /dev/null +++ b/tools/node_modules/minimist/test/num.js @@ -0,0 +1,36 @@ +var parse = require('../'); +var test = require('tape'); + +test('nums', function (t) { + var argv = parse([ + '-x', '1234', + '-y', '5.67', + '-z', '1e7', + '-w', '10f', + '--hex', '0xdeadbeef', + '789' + ]); + t.deepEqual(argv, { + x : 1234, + y : 5.67, + z : 1e7, + w : '10f', + hex : 0xdeadbeef, + _ : [ 789 ] + }); + t.deepEqual(typeof argv.x, 'number'); + t.deepEqual(typeof argv.y, 'number'); + t.deepEqual(typeof argv.z, 'number'); + t.deepEqual(typeof argv.w, 'string'); + t.deepEqual(typeof argv.hex, 'number'); + t.deepEqual(typeof argv._[0], 'number'); + t.end(); +}); + +test('already a number', function (t) { + var argv = parse([ '-x', 1234, 789 ]); + t.deepEqual(argv, { x : 1234, _ : [ 789 ] }); + t.deepEqual(typeof argv.x, 'number'); + t.deepEqual(typeof argv._[0], 'number'); + t.end(); +}); diff --git a/tools/node_modules/minimist/test/parse.js b/tools/node_modules/minimist/test/parse.js new file mode 100644 index 00000000000000..7b4a2a17c0dda5 --- /dev/null +++ b/tools/node_modules/minimist/test/parse.js @@ -0,0 +1,197 @@ +var parse = require('../'); +var test = require('tape'); + +test('parse args', function (t) { + t.deepEqual( + parse([ '--no-moo' ]), + { moo : false, _ : [] }, + 'no' + ); + t.deepEqual( + parse([ '-v', 'a', '-v', 'b', '-v', 'c' ]), + { v : ['a','b','c'], _ : [] }, + 'multi' + ); + t.end(); +}); + +test('comprehensive', function (t) { + t.deepEqual( + parse([ + '--name=meowmers', 'bare', '-cats', 'woo', + '-h', 'awesome', '--multi=quux', + '--key', 'value', + '-b', '--bool', '--no-meep', '--multi=baz', + '--', '--not-a-flag', 'eek' + ]), + { + c : true, + a : true, + t : true, + s : 'woo', + h : 'awesome', + b : true, + bool : true, + key : 'value', + multi : [ 'quux', 'baz' ], + meep : false, + name : 'meowmers', + _ : [ 'bare', '--not-a-flag', 'eek' ] + } + ); + t.end(); +}); + +test('flag boolean', function (t) { + var argv = parse([ '-t', 'moo' ], { boolean: 't' }); + t.deepEqual(argv, { t : true, _ : [ 'moo' ] }); + t.deepEqual(typeof argv.t, 'boolean'); + t.end(); +}); + +test('flag boolean value', function (t) { + var argv = parse(['--verbose', 'false', 'moo', '-t', 'true'], { + boolean: [ 't', 'verbose' ], + default: { verbose: true } + }); + + t.deepEqual(argv, { + verbose: false, + t: true, + _: ['moo'] + }); + + t.deepEqual(typeof argv.verbose, 'boolean'); + t.deepEqual(typeof argv.t, 'boolean'); + t.end(); +}); + +test('newlines in params' , function (t) { + var args = parse([ '-s', "X\nX" ]) + t.deepEqual(args, { _ : [], s : "X\nX" }); + + // reproduce in bash: + // VALUE="new + // line" + // node program.js --s="$VALUE" + args = parse([ "--s=X\nX" ]) + t.deepEqual(args, { _ : [], s : "X\nX" }); + t.end(); +}); + +test('strings' , function (t) { + var s = parse([ '-s', '0001234' ], { string: 's' }).s; + t.equal(s, '0001234'); + t.equal(typeof s, 'string'); + + var x = parse([ '-x', '56' ], { string: 'x' }).x; + t.equal(x, '56'); + t.equal(typeof x, 'string'); + t.end(); +}); + +test('stringArgs', function (t) { + var s = parse([ ' ', ' ' ], { string: '_' })._; + t.same(s.length, 2); + t.same(typeof s[0], 'string'); + t.same(s[0], ' '); + t.same(typeof s[1], 'string'); + t.same(s[1], ' '); + t.end(); +}); + +test('empty strings', function(t) { + var s = parse([ '-s' ], { string: 's' }).s; + t.equal(s, ''); + t.equal(typeof s, 'string'); + + var str = parse([ '--str' ], { string: 'str' }).str; + t.equal(str, ''); + t.equal(typeof str, 'string'); + + var letters = parse([ '-art' ], { + string: [ 'a', 't' ] + }); + + t.equal(letters.a, ''); + t.equal(letters.r, true); + t.equal(letters.t, ''); + + t.end(); +}); + + +test('string and alias', function(t) { + var x = parse([ '--str', '000123' ], { + string: 's', + alias: { s: 'str' } + }); + + t.equal(x.str, '000123'); + t.equal(typeof x.str, 'string'); + t.equal(x.s, '000123'); + t.equal(typeof x.s, 'string'); + + var y = parse([ '-s', '000123' ], { + string: 'str', + alias: { str: 's' } + }); + + t.equal(y.str, '000123'); + t.equal(typeof y.str, 'string'); + t.equal(y.s, '000123'); + t.equal(typeof y.s, 'string'); + t.end(); +}); + +test('slashBreak', function (t) { + t.same( + parse([ '-I/foo/bar/baz' ]), + { I : '/foo/bar/baz', _ : [] } + ); + t.same( + parse([ '-xyz/foo/bar/baz' ]), + { x : true, y : true, z : '/foo/bar/baz', _ : [] } + ); + t.end(); +}); + +test('alias', function (t) { + var argv = parse([ '-f', '11', '--zoom', '55' ], { + alias: { z: 'zoom' } + }); + t.equal(argv.zoom, 55); + t.equal(argv.z, argv.zoom); + t.equal(argv.f, 11); + t.end(); +}); + +test('multiAlias', function (t) { + var argv = parse([ '-f', '11', '--zoom', '55' ], { + alias: { z: [ 'zm', 'zoom' ] } + }); + t.equal(argv.zoom, 55); + t.equal(argv.z, argv.zoom); + t.equal(argv.z, argv.zm); + t.equal(argv.f, 11); + t.end(); +}); + +test('nested dotted objects', function (t) { + var argv = parse([ + '--foo.bar', '3', '--foo.baz', '4', + '--foo.quux.quibble', '5', '--foo.quux.o_O', + '--beep.boop' + ]); + + t.same(argv.foo, { + bar : 3, + baz : 4, + quux : { + quibble : 5, + o_O : true + } + }); + t.same(argv.beep, { boop : true }); + t.end(); +}); diff --git a/tools/node_modules/minimist/test/parse_modified.js b/tools/node_modules/minimist/test/parse_modified.js new file mode 100644 index 00000000000000..ab620dc5e4dc39 --- /dev/null +++ b/tools/node_modules/minimist/test/parse_modified.js @@ -0,0 +1,9 @@ +var parse = require('../'); +var test = require('tape'); + +test('parse with modifier functions' , function (t) { + t.plan(1); + + var argv = parse([ '-b', '123' ], { boolean: 'b' }); + t.deepEqual(argv, { b: true, _: [123] }); +}); diff --git a/tools/node_modules/minimist/test/short.js b/tools/node_modules/minimist/test/short.js new file mode 100644 index 00000000000000..d513a1c2529095 --- /dev/null +++ b/tools/node_modules/minimist/test/short.js @@ -0,0 +1,67 @@ +var parse = require('../'); +var test = require('tape'); + +test('numeric short args', function (t) { + t.plan(2); + t.deepEqual(parse([ '-n123' ]), { n: 123, _: [] }); + t.deepEqual( + parse([ '-123', '456' ]), + { 1: true, 2: true, 3: 456, _: [] } + ); +}); + +test('short', function (t) { + t.deepEqual( + parse([ '-b' ]), + { b : true, _ : [] }, + 'short boolean' + ); + t.deepEqual( + parse([ 'foo', 'bar', 'baz' ]), + { _ : [ 'foo', 'bar', 'baz' ] }, + 'bare' + ); + t.deepEqual( + parse([ '-cats' ]), + { c : true, a : true, t : true, s : true, _ : [] }, + 'group' + ); + t.deepEqual( + parse([ '-cats', 'meow' ]), + { c : true, a : true, t : true, s : 'meow', _ : [] }, + 'short group next' + ); + t.deepEqual( + parse([ '-h', 'localhost' ]), + { h : 'localhost', _ : [] }, + 'short capture' + ); + t.deepEqual( + parse([ '-h', 'localhost', '-p', '555' ]), + { h : 'localhost', p : 555, _ : [] }, + 'short captures' + ); + t.end(); +}); + +test('mixed short bool and capture', function (t) { + t.same( + parse([ '-h', 'localhost', '-fp', '555', 'script.js' ]), + { + f : true, p : 555, h : 'localhost', + _ : [ 'script.js' ] + } + ); + t.end(); +}); + +test('short and long', function (t) { + t.deepEqual( + parse([ '-h', 'localhost', '-fp', '555', 'script.js' ]), + { + f : true, p : 555, h : 'localhost', + _ : [ 'script.js' ] + } + ); + t.end(); +}); diff --git a/tools/node_modules/minimist/test/stop_early.js b/tools/node_modules/minimist/test/stop_early.js new file mode 100644 index 00000000000000..bdf9fbcb0b57ab --- /dev/null +++ b/tools/node_modules/minimist/test/stop_early.js @@ -0,0 +1,15 @@ +var parse = require('../'); +var test = require('tape'); + +test('stops parsing on the first non-option when stopEarly is set', function (t) { + var argv = parse(['--aaa', 'bbb', 'ccc', '--ddd'], { + stopEarly: true + }); + + t.deepEqual(argv, { + aaa: 'bbb', + _: ['ccc', '--ddd'] + }); + + t.end(); +}); diff --git a/tools/node_modules/minimist/test/unknown.js b/tools/node_modules/minimist/test/unknown.js new file mode 100644 index 00000000000000..462a36bdd7ec9f --- /dev/null +++ b/tools/node_modules/minimist/test/unknown.js @@ -0,0 +1,102 @@ +var parse = require('../'); +var test = require('tape'); + +test('boolean and alias is not unknown', function (t) { + var unknown = []; + function unknownFn(arg) { + unknown.push(arg); + return false; + } + var aliased = [ '-h', 'true', '--derp', 'true' ]; + var regular = [ '--herp', 'true', '-d', 'true' ]; + var opts = { + alias: { h: 'herp' }, + boolean: 'h', + unknown: unknownFn + }; + var aliasedArgv = parse(aliased, opts); + var propertyArgv = parse(regular, opts); + + t.same(unknown, ['--derp', '-d']); + t.end(); +}); + +test('flag boolean true any double hyphen argument is not unknown', function (t) { + var unknown = []; + function unknownFn(arg) { + unknown.push(arg); + return false; + } + var argv = parse(['--honk', '--tacos=good', 'cow', '-p', '55'], { + boolean: true, + unknown: unknownFn + }); + t.same(unknown, ['--tacos=good', 'cow', '-p']); + t.same(argv, { + honk: true, + _: [] + }); + t.end(); +}); + +test('string and alias is not unknown', function (t) { + var unknown = []; + function unknownFn(arg) { + unknown.push(arg); + return false; + } + var aliased = [ '-h', 'hello', '--derp', 'goodbye' ]; + var regular = [ '--herp', 'hello', '-d', 'moon' ]; + var opts = { + alias: { h: 'herp' }, + string: 'h', + unknown: unknownFn + }; + var aliasedArgv = parse(aliased, opts); + var propertyArgv = parse(regular, opts); + + t.same(unknown, ['--derp', '-d']); + t.end(); +}); + +test('default and alias is not unknown', function (t) { + var unknown = []; + function unknownFn(arg) { + unknown.push(arg); + return false; + } + var aliased = [ '-h', 'hello' ]; + var regular = [ '--herp', 'hello' ]; + var opts = { + default: { 'h': 'bar' }, + alias: { 'h': 'herp' }, + unknown: unknownFn + }; + var aliasedArgv = parse(aliased, opts); + var propertyArgv = parse(regular, opts); + + t.same(unknown, []); + t.end(); + unknownFn(); // exercise fn for 100% coverage +}); + +test('value following -- is not unknown', function (t) { + var unknown = []; + function unknownFn(arg) { + unknown.push(arg); + return false; + } + var aliased = [ '--bad', '--', 'good', 'arg' ]; + var opts = { + '--': true, + unknown: unknownFn + }; + var argv = parse(aliased, opts); + + t.same(unknown, ['--bad']); + t.same(argv, { + '--': ['good', 'arg'], + '_': [] + }) + t.end(); +}); diff --git a/tools/node_modules/minimist/test/whitespace.js b/tools/node_modules/minimist/test/whitespace.js new file mode 100644 index 00000000000000..8a52a58cecfd7a --- /dev/null +++ b/tools/node_modules/minimist/test/whitespace.js @@ -0,0 +1,8 @@ +var parse = require('../'); +var test = require('tape'); + +test('whitespace should be whitespace' , function (t) { + t.plan(1); + var x = parse([ '-x', '\t' ]).x; + t.equal(x, '\t'); +}); diff --git a/tools/node_modules/ms/.npmignore b/tools/node_modules/ms/.npmignore new file mode 100644 index 00000000000000..d1aa0ce42e1360 --- /dev/null +++ b/tools/node_modules/ms/.npmignore @@ -0,0 +1,5 @@ +node_modules +test +History.md +Makefile +component.json diff --git a/tools/node_modules/ms/History.md b/tools/node_modules/ms/History.md new file mode 100644 index 00000000000000..32fdfc17623565 --- /dev/null +++ b/tools/node_modules/ms/History.md @@ -0,0 +1,66 @@ + +0.7.1 / 2015-04-20 +================== + + * prevent extraordinary long inputs (@evilpacket) + * Fixed broken readme link + +0.7.0 / 2014-11-24 +================== + + * add time abbreviations, updated tests and readme for the new units + * fix example in the readme. + * add LICENSE file + +0.6.2 / 2013-12-05 +================== + + * Adding repository section to package.json to suppress warning from NPM. + +0.6.1 / 2013-05-10 +================== + + * fix singularization [visionmedia] + +0.6.0 / 2013-03-15 +================== + + * fix minutes + +0.5.1 / 2013-02-24 +================== + + * add component namespace + +0.5.0 / 2012-11-09 +================== + + * add short formatting as default and .long option + * add .license property to component.json + * add version to component.json + +0.4.0 / 2012-10-22 +================== + + * add rounding to fix crazy decimals + +0.3.0 / 2012-09-07 +================== + + * fix `ms()` [visionmedia] + +0.2.0 / 2012-09-03 +================== + + * add component.json [visionmedia] + * add days support [visionmedia] + * add hours support [visionmedia] + * add minutes support [visionmedia] + * add seconds support [visionmedia] + * add ms string support [visionmedia] + * refactor tests to facilitate ms(number) [visionmedia] + +0.1.0 / 2012-03-07 +================== + + * Initial release diff --git a/tools/node_modules/ms/LICENSE b/tools/node_modules/ms/LICENSE new file mode 100644 index 00000000000000..6c07561b62ddfa --- /dev/null +++ b/tools/node_modules/ms/LICENSE @@ -0,0 +1,20 @@ +(The MIT License) + +Copyright (c) 2014 Guillermo Rauch + +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. diff --git a/tools/node_modules/ms/README.md b/tools/node_modules/ms/README.md new file mode 100644 index 00000000000000..9b4fd03581b18c --- /dev/null +++ b/tools/node_modules/ms/README.md @@ -0,0 +1,35 @@ +# ms.js: miliseconds conversion utility + +```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('100') // 100 +``` + +```js +ms(60000) // "1m" +ms(2 * 60000) // "2m" +ms(ms('10 hours')) // "10h" +``` + +```js +ms(60000, { long: true }) // "1 minute" +ms(2 * 60000, { long: true }) // "2 minutes" +ms(ms('10 hours'), { long: true }) // "10 hours" +``` + +- Node/Browser compatible. Published as [`ms`](https://www.npmjs.org/package/ms) in [NPM](http://nodejs.org/download). +- 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. + +## License + +MIT diff --git a/tools/node_modules/ms/index.js b/tools/node_modules/ms/index.js new file mode 100644 index 00000000000000..4f9277169674b4 --- /dev/null +++ b/tools/node_modules/ms/index.js @@ -0,0 +1,125 @@ +/** + * 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 + * @return {String|Number} + * @api public + */ + +module.exports = function(val, options){ + options = options || {}; + if ('string' == typeof val) return parse(val); + return options.long + ? long(val) + : short(val); +}; + +/** + * Parse the given `str` and return milliseconds. + * + * @param {String} str + * @return {Number} + * @api private + */ + +function parse(str) { + str = '' + str; + if (str.length > 10000) 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; + } +} + +/** + * Short format for `ms`. + * + * @param {Number} ms + * @return {String} + * @api private + */ + +function short(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 long(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'; +} diff --git a/tools/node_modules/ms/package.json b/tools/node_modules/ms/package.json new file mode 100644 index 00000000000000..8b518d2333ac0f --- /dev/null +++ b/tools/node_modules/ms/package.json @@ -0,0 +1,73 @@ +{ + "_args": [ + [ + "ms@0.7.1", + "C:\\wamp\\www\\node\\tools\\node_modules\\debug" + ] + ], + "_from": "ms@0.7.1", + "_id": "ms@0.7.1", + "_inCache": true, + "_location": "/ms", + "_nodeVersion": "0.12.2", + "_npmUser": { + "email": "rauchg@gmail.com", + "name": "rauchg" + }, + "_npmVersion": "2.7.5", + "_phantomChildren": {}, + "_requested": { + "name": "ms", + "raw": "ms@0.7.1", + "rawSpec": "0.7.1", + "scope": null, + "spec": "0.7.1", + "type": "version" + }, + "_requiredBy": [ + "/debug" + ], + "_resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz", + "_shasum": "9cd13c03adbff25b65effde7ce864ee952017098", + "_shrinkwrap": null, + "_spec": "ms@0.7.1", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\debug", + "bugs": { + "url": "https://github.com/guille/ms.js/issues" + }, + "component": { + "scripts": { + "ms/index.js": "index.js" + } + }, + "dependencies": {}, + "description": "Tiny ms conversion utility", + "devDependencies": { + "expect.js": "*", + "mocha": "*", + "serve": "*" + }, + "directories": {}, + "dist": { + "shasum": "9cd13c03adbff25b65effde7ce864ee952017098", + "tarball": "http://registry.npmjs.org/ms/-/ms-0.7.1.tgz" + }, + "gitHead": "713dcf26d9e6fd9dbc95affe7eff9783b7f1b909", + "homepage": "https://github.com/guille/ms.js", + "installable": true, + "main": "./index", + "maintainers": [ + { + "name": "rauchg", + "email": "rauchg@gmail.com" + } + ], + "name": "ms", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git://github.com/guille/ms.js.git" + }, + "scripts": {}, + "version": "0.7.1" +} diff --git a/tools/node_modules/normalize-path/LICENSE b/tools/node_modules/normalize-path/LICENSE new file mode 100644 index 00000000000000..fa30c4cb3e4c15 --- /dev/null +++ b/tools/node_modules/normalize-path/LICENSE @@ -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. diff --git a/tools/node_modules/normalize-path/README.md b/tools/node_modules/normalize-path/README.md new file mode 100644 index 00000000000000..e75d4bd0a68a4a --- /dev/null +++ b/tools/node_modules/normalize-path/README.md @@ -0,0 +1,75 @@ +# normalize-path [![NPM version](https://badge.fury.io/js/normalize-path.svg)](http://badge.fury.io/js/normalize-path) [![Build Status](https://travis-ci.org/jonschlinkert/normalize-path.svg)](https://travis-ci.org/jonschlinkert/normalize-path) + +> Normalize file path slashes to be unix-like forward slashes. Also condenses repeat slashes to a single slash and removes and trailing slashes. + +## Install + +Install with [npm](https://www.npmjs.com/) + +```sh +$ npm i normalize-path --save +``` + +## Usage + +```js +var normalize = require('normalize-path'); + +normalize('\\foo\\bar\\baz\\'); +//=> '/foo/bar/baz' + +normalize('./foo/bar/baz/'); +//=> './foo/bar/baz' +``` + +Pass `false` as the last argument to **not** strip trailing slashes: + +```js +normalize('./foo/bar/baz/', false); +//=> './foo/bar/baz/' + +normalize('foo\\bar\\baz\\', false); +//=> 'foo/bar/baz/' +``` + +## Related + +Other useful libraries for working with paths in node.js: + +* [contains-path](https://www.npmjs.com/package/contains-path): Return true if a file path contains the given path. | [homepage](https://github.com/jonschlinkert/contains-path) +* [ends-with](https://www.npmjs.com/package/ends-with): Returns `true` if the given `string` or `array` ends with `suffix` using strict equality for… [more](https://www.npmjs.com/package/ends-with) | [homepage](https://github.com/jonschlinkert/ends-with) +* [is-absolute](https://www.npmjs.com/package/is-absolute): Returns true if a file path is absolute. | [homepage](https://github.com/jonschlinkert/is-absolute) +* [is-relative](https://www.npmjs.com/package/is-relative): Returns `true` if the path appears to be relative. | [homepage](https://github.com/jonschlinkert/is-relative) +* [parse-filepath](https://www.npmjs.com/package/parse-filepath): Parse a filepath into an object. Falls back on the native node.js `path.parse` method if… [more](https://www.npmjs.com/package/parse-filepath) | [homepage](https://github.com/jonschlinkert/parse-filepath) +* [path-ends-with](https://www.npmjs.com/package/path-ends-with): Return `true` if a file path ends with the given string/suffix. | [homepage](https://github.com/jonschlinkert/path-ends-with) +* [path-segments](https://www.npmjs.com/package/path-segments): Get n specific segments of a file path, e.g. first 2, last 3, etc. | [homepage](https://github.com/jonschlinkert/path-segments) +* [rewrite-ext](https://www.npmjs.com/package/rewrite-ext): Automatically re-write the destination extension of a filepath based on the source extension. e.g … [more](https://www.npmjs.com/package/rewrite-ext) | [homepage](https://github.com/jonschlinkert/rewrite-ext) +* [unixify](https://www.npmjs.com/package/unixify): Convert Windows file paths to unix paths. | [homepage](https://github.com/jonschlinkert/unixify) + +## 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/normalize-path/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 November 17, 2015._ \ No newline at end of file diff --git a/tools/node_modules/normalize-path/index.js b/tools/node_modules/normalize-path/index.js new file mode 100644 index 00000000000000..137f6015b1d376 --- /dev/null +++ b/tools/node_modules/normalize-path/index.js @@ -0,0 +1,17 @@ +/*! + * normalize-path + * + * Copyright (c) 2014-2015, Jon Schlinkert. + * Licensed under the MIT License + */ + +module.exports = function normalizePath(str, stripTrailing) { + if (typeof str !== 'string') { + throw new TypeError('expected a string'); + } + str = str.replace(/[\\\/]+/g, '/'); + if (stripTrailing !== false) { + str = str.replace(/\/$/, ''); + } + return str; +}; diff --git a/tools/node_modules/normalize-path/package.json b/tools/node_modules/normalize-path/package.json new file mode 100644 index 00000000000000..f41efba2a0f6dd --- /dev/null +++ b/tools/node_modules/normalize-path/package.json @@ -0,0 +1,117 @@ +{ + "_args": [ + [ + "normalize-path@^2.0.1", + "C:\\wamp\\www\\node\\tools\\node_modules\\micromatch" + ] + ], + "_from": "normalize-path@>=2.0.1 <3.0.0", + "_id": "normalize-path@2.0.1", + "_inCache": true, + "_location": "/normalize-path", + "_nodeVersion": "5.0.0", + "_npmUser": { + "email": "github@sellside.com", + "name": "jonschlinkert" + }, + "_npmVersion": "3.3.6", + "_phantomChildren": {}, + "_requested": { + "name": "normalize-path", + "raw": "normalize-path@^2.0.1", + "rawSpec": "^2.0.1", + "scope": null, + "spec": ">=2.0.1 <3.0.0", + "type": "range" + }, + "_requiredBy": [ + "/micromatch" + ], + "_resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.0.1.tgz", + "_shasum": "47886ac1662760d4261b7d979d241709d3ce3f7a", + "_shrinkwrap": null, + "_spec": "normalize-path@^2.0.1", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\micromatch", + "author": { + "name": "Jon Schlinkert", + "url": "https://github.com/jonschlinkert" + }, + "bugs": { + "url": "https://github.com/jonschlinkert/normalize-path/issues" + }, + "dependencies": {}, + "description": "Normalize file path slashes to be unix-like forward slashes. Also condenses repeat slashes to a single slash and removes and trailing slashes.", + "devDependencies": { + "benchmarked": "^0.1.1", + "minimist": "^1.2.0", + "mocha": "*" + }, + "directories": {}, + "dist": { + "shasum": "47886ac1662760d4261b7d979d241709d3ce3f7a", + "tarball": "http://registry.npmjs.org/normalize-path/-/normalize-path-2.0.1.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "ca536e0e8755d3ed04f3ba4d21cc9e122e0f749f", + "homepage": "https://github.com/jonschlinkert/normalize-path", + "installable": true, + "keywords": [ + "backslash", + "file", + "filepath", + "fix", + "forward", + "fp", + "fs", + "normalize", + "path", + "slash", + "slashes", + "trailing", + "unix", + "urix" + ], + "license": "MIT", + "main": "index.js", + "maintainers": [ + { + "name": "doowb", + "email": "brian.woodward@gmail.com" + }, + { + "name": "jonschlinkert", + "email": "github@sellside.com" + } + ], + "name": "normalize-path", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git+https://github.com/jonschlinkert/normalize-path.git" + }, + "scripts": { + "test": "mocha" + }, + "verb": { + "related": { + "description": "Other useful libraries for working with paths in node.js:", + "list": [ + "contains-path", + "ends-with", + "is-absolute", + "is-relative", + "parse-filepath", + "path-ends-with", + "path-segments", + "rewrite-ext", + "unixify" + ] + } + }, + "version": "2.0.1" +} diff --git a/tools/node_modules/npm-prefix/LICENSE b/tools/node_modules/npm-prefix/LICENSE new file mode 100644 index 00000000000000..34098240132269 --- /dev/null +++ b/tools/node_modules/npm-prefix/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 Eugene Sharygin + +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. diff --git a/tools/node_modules/npm-prefix/README.md b/tools/node_modules/npm-prefix/README.md new file mode 100644 index 00000000000000..36f5a6ccfdf671 --- /dev/null +++ b/tools/node_modules/npm-prefix/README.md @@ -0,0 +1,37 @@ +[![npm](https://nodei.co/npm/npm-prefix.png)](https://npmjs.com/package/npm-prefix) + +# npm-prefix + +[![Build Status][travis-badge]][travis] [![Dependency Status][david-badge]][david] + +Get global npm prefix. Respects npmrc configs. + +[travis]: https://travis-ci.org/eush77/npm-prefix +[travis-badge]: https://travis-ci.org/eush77/npm-prefix.svg?branch=master +[david]: https://david-dm.org/eush77/npm-prefix +[david-badge]: https://david-dm.org/eush77/npm-prefix.png + +## Example + +```js +var npmPrefix = require('npm-prefix'); + +npmPrefix() +//=> '/usr/local' +``` + +## API + +#### `npmPrefix()` + +Returns the npm prefix. + +## Install + +``` +npm install npm-prefix +``` + +## License + +MIT diff --git a/tools/node_modules/npm-prefix/index.js b/tools/node_modules/npm-prefix/index.js new file mode 100644 index 00000000000000..398bcf4cd209fd --- /dev/null +++ b/tools/node_modules/npm-prefix/index.js @@ -0,0 +1,21 @@ +'use strict'; + +var rc = require('rc'), + untildify = require('untildify'); + +var path = require('path'); + + +module.exports = function () { + var rcPrefix = rc('npm', null, []).prefix; + + if (rcPrefix) { + return untildify(rcPrefix); + } + else if (process.platform == 'win32') { + return path.dirname(process.execPath); + } + else { + return path.resolve(process.execPath, '../..'); + } +}; diff --git a/tools/node_modules/npm-prefix/package.json b/tools/node_modules/npm-prefix/package.json new file mode 100644 index 00000000000000..a8d6c13f9beb0c --- /dev/null +++ b/tools/node_modules/npm-prefix/package.json @@ -0,0 +1,93 @@ +{ + "_args": [ + [ + "npm-prefix@^1.0.1", + "C:\\wamp\\www\\node\\tools\\node_modules\\remark" + ] + ], + "_from": "npm-prefix@>=1.0.1 <2.0.0", + "_id": "npm-prefix@1.1.1", + "_inCache": true, + "_location": "/npm-prefix", + "_nodeVersion": "2.1.0", + "_npmUser": { + "email": "eush77@gmail.com", + "name": "eush77" + }, + "_npmVersion": "3.3.3", + "_phantomChildren": {}, + "_requested": { + "name": "npm-prefix", + "raw": "npm-prefix@^1.0.1", + "rawSpec": "^1.0.1", + "scope": null, + "spec": ">=1.0.1 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/remark" + ], + "_resolved": "https://registry.npmjs.org/npm-prefix/-/npm-prefix-1.1.1.tgz", + "_shasum": "dd9efa2ec617118f24edb310e2f62cb1ee6dcb1c", + "_shrinkwrap": null, + "_spec": "npm-prefix@^1.0.1", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\remark", + "author": { + "email": "eush77@gmail.com", + "name": "Eugene Sharygin" + }, + "bugs": { + "url": "https://github.com/eush77/npm-prefix/issues" + }, + "dependencies": { + "rc": "^1.1.0", + "untildify": "^2.1.0" + }, + "description": "Get global npm prefix. Respects npmrc configs", + "devDependencies": { + "os-homedir": "^1.0.1", + "tape": "^4.2.2" + }, + "directories": {}, + "dist": { + "shasum": "dd9efa2ec617118f24edb310e2f62cb1ee6dcb1c", + "tarball": "http://registry.npmjs.org/npm-prefix/-/npm-prefix-1.1.1.tgz" + }, + "files": [ + "index.js" + ], + "gitHead": "dfe58e72c672e9dafa6a846e7d18b8ab9b1ef31b", + "homepage": "https://github.com/eush77/npm-prefix", + "installable": true, + "keywords": [ + "bin", + "config", + "global", + "lib", + "node_modules", + "npm", + "npmrc", + "path", + "prefix", + "require", + "resolve", + "root" + ], + "license": "MIT", + "maintainers": [ + { + "name": "eush77", + "email": "eush77@gmail.com" + } + ], + "name": "npm-prefix", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git+https://github.com/eush77/npm-prefix.git" + }, + "scripts": { + "test": "tape test/*.js" + }, + "version": "1.1.1" +} diff --git a/tools/node_modules/number-is-nan/index.js b/tools/node_modules/number-is-nan/index.js new file mode 100644 index 00000000000000..79be4b9cb8c3bc --- /dev/null +++ b/tools/node_modules/number-is-nan/index.js @@ -0,0 +1,4 @@ +'use strict'; +module.exports = Number.isNaN || function (x) { + return x !== x; +}; diff --git a/tools/node_modules/number-is-nan/license b/tools/node_modules/number-is-nan/license new file mode 100644 index 00000000000000..654d0bfe943437 --- /dev/null +++ b/tools/node_modules/number-is-nan/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tools/node_modules/number-is-nan/package.json b/tools/node_modules/number-is-nan/package.json new file mode 100644 index 00000000000000..e5cdf9f0b620da --- /dev/null +++ b/tools/node_modules/number-is-nan/package.json @@ -0,0 +1,93 @@ +{ + "_args": [ + [ + "number-is-nan@^1.0.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\code-point-at" + ] + ], + "_from": "number-is-nan@>=1.0.0 <2.0.0", + "_id": "number-is-nan@1.0.0", + "_inCache": true, + "_location": "/number-is-nan", + "_nodeVersion": "0.12.3", + "_npmUser": { + "email": "sindresorhus@gmail.com", + "name": "sindresorhus" + }, + "_npmVersion": "2.10.0", + "_phantomChildren": {}, + "_requested": { + "name": "number-is-nan", + "raw": "number-is-nan@^1.0.0", + "rawSpec": "^1.0.0", + "scope": null, + "spec": ">=1.0.0 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/code-point-at", + "/is-fullwidth-code-point" + ], + "_resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.0.tgz", + "_shasum": "c020f529c5282adfdd233d91d4b181c3d686dc4b", + "_shrinkwrap": null, + "_spec": "number-is-nan@^1.0.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\code-point-at", + "author": { + "email": "sindresorhus@gmail.com", + "name": "Sindre Sorhus", + "url": "sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/sindresorhus/number-is-nan/issues" + }, + "dependencies": {}, + "description": "ES6 Number.isNaN() ponyfill", + "devDependencies": { + "ava": "0.0.4" + }, + "directories": {}, + "dist": { + "shasum": "c020f529c5282adfdd233d91d4b181c3d686dc4b", + "tarball": "http://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.0.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "0f394b1bc33185c40304363b209e3f0588dbeeb3", + "homepage": "https://github.com/sindresorhus/number-is-nan#readme", + "installable": true, + "keywords": [ + "ecmascript", + "es2015", + "es6", + "harmony", + "is", + "nan", + "not", + "number", + "polyfill", + "ponyfill", + "shim" + ], + "license": "MIT", + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + } + ], + "name": "number-is-nan", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git+https://github.com/sindresorhus/number-is-nan.git" + }, + "scripts": { + "test": "node test.js" + }, + "version": "1.0.0" +} diff --git a/tools/node_modules/number-is-nan/readme.md b/tools/node_modules/number-is-nan/readme.md new file mode 100644 index 00000000000000..93d851a14f1ac5 --- /dev/null +++ b/tools/node_modules/number-is-nan/readme.md @@ -0,0 +1,30 @@ +# number-is-nan [![Build Status](https://travis-ci.org/sindresorhus/number-is-nan.svg?branch=master)](https://travis-ci.org/sindresorhus/number-is-nan) + +> ES6 [`Number.isNaN()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN) ponyfill + +> Ponyfill: A polyfill that doesn't overwrite the native method + + +## Install + +``` +$ npm install --save number-is-nan +``` + + +## Usage + +```js +var numberIsNan = require('number-is-nan'); + +numberIsNan(NaN); +//=> true + +numberIsNan('unicorn'); +//=> false +``` + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/tools/node_modules/object-assign/index.js b/tools/node_modules/object-assign/index.js new file mode 100644 index 00000000000000..c097d87580622e --- /dev/null +++ b/tools/node_modules/object-assign/index.js @@ -0,0 +1,39 @@ +/* eslint-disable no-unused-vars */ +'use strict'; +var hasOwnProperty = Object.prototype.hasOwnProperty; +var propIsEnumerable = Object.prototype.propertyIsEnumerable; + +function toObject(val) { + if (val === null || val === undefined) { + throw new TypeError('Object.assign cannot be called with null or undefined'); + } + + return Object(val); +} + +module.exports = Object.assign || function (target, source) { + var from; + var to = toObject(target); + var symbols; + + for (var s = 1; s < arguments.length; s++) { + from = Object(arguments[s]); + + for (var key in from) { + if (hasOwnProperty.call(from, key)) { + to[key] = from[key]; + } + } + + if (Object.getOwnPropertySymbols) { + symbols = Object.getOwnPropertySymbols(from); + for (var i = 0; i < symbols.length; i++) { + if (propIsEnumerable.call(from, symbols[i])) { + to[symbols[i]] = from[symbols[i]]; + } + } + } + } + + return to; +}; diff --git a/tools/node_modules/object-assign/license b/tools/node_modules/object-assign/license new file mode 100644 index 00000000000000..654d0bfe943437 --- /dev/null +++ b/tools/node_modules/object-assign/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tools/node_modules/object-assign/package.json b/tools/node_modules/object-assign/package.json new file mode 100644 index 00000000000000..bb112ce5fd70a5 --- /dev/null +++ b/tools/node_modules/object-assign/package.json @@ -0,0 +1,104 @@ +{ + "_args": [ + [ + "object-assign@^4.0.1", + "C:\\wamp\\www\\node\\tools\\node_modules\\eslint-plugin-markdown" + ] + ], + "_from": "object-assign@>=4.0.1 <5.0.0", + "_id": "object-assign@4.0.1", + "_inCache": true, + "_location": "/object-assign", + "_nodeVersion": "3.0.0", + "_npmUser": { + "email": "sindresorhus@gmail.com", + "name": "sindresorhus" + }, + "_npmVersion": "2.13.3", + "_phantomChildren": {}, + "_requested": { + "name": "object-assign", + "raw": "object-assign@^4.0.1", + "rawSpec": "^4.0.1", + "scope": null, + "spec": ">=4.0.1 <5.0.0", + "type": "range" + }, + "_requiredBy": [ + "/eslint-plugin-markdown", + "/globby" + ], + "_resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.0.1.tgz", + "_shasum": "99504456c3598b5cad4fc59c26e8a9bb107fe0bd", + "_shrinkwrap": null, + "_spec": "object-assign@^4.0.1", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\eslint-plugin-markdown", + "author": { + "email": "sindresorhus@gmail.com", + "name": "Sindre Sorhus", + "url": "http://sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/sindresorhus/object-assign/issues" + }, + "dependencies": {}, + "description": "ES6 Object.assign() ponyfill", + "devDependencies": { + "lodash": "^3.10.1", + "matcha": "^0.6.0", + "mocha": "*", + "xo": "*" + }, + "directories": {}, + "dist": { + "shasum": "99504456c3598b5cad4fc59c26e8a9bb107fe0bd", + "tarball": "http://registry.npmjs.org/object-assign/-/object-assign-4.0.1.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "b0c40d37cbc43e89ad3326a9bad4c6b3133ba6d3", + "homepage": "https://github.com/sindresorhus/object-assign#readme", + "installable": true, + "keywords": [ + "assign", + "browser", + "ecmascript", + "es6", + "extend", + "harmony", + "object", + "polyfill", + "ponyfill", + "prollyfill", + "properties", + "shim" + ], + "license": "MIT", + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + } + ], + "name": "object-assign", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git+https://github.com/sindresorhus/object-assign.git" + }, + "scripts": { + "bench": "matcha bench.js", + "test": "xo && mocha" + }, + "version": "4.0.1", + "xo": { + "envs": [ + "mocha", + "node" + ] + } +} diff --git a/tools/node_modules/object-assign/readme.md b/tools/node_modules/object-assign/readme.md new file mode 100644 index 00000000000000..aee51c12b56589 --- /dev/null +++ b/tools/node_modules/object-assign/readme.md @@ -0,0 +1,51 @@ +# object-assign [![Build Status](https://travis-ci.org/sindresorhus/object-assign.svg?branch=master)](https://travis-ci.org/sindresorhus/object-assign) + +> ES6 [`Object.assign()`](http://www.2ality.com/2014/01/object-assign.html) ponyfill + +> Ponyfill: A polyfill that doesn't overwrite the native method + + +## Install + +```sh +$ npm install --save object-assign +``` + + +## Usage + +```js +var objectAssign = require('object-assign'); + +objectAssign({foo: 0}, {bar: 1}); +//=> {foo: 0, bar: 1} + +// multiple sources +objectAssign({foo: 0}, {bar: 1}, {baz: 2}); +//=> {foo: 0, bar: 1, baz: 2} + +// overwrites equal keys +objectAssign({foo: 0}, {foo: 1}, {foo: 2}); +//=> {foo: 2} + +// ignores null and undefined sources +objectAssign({foo: 0}, null, {bar: 1}, undefined); +//=> {foo: 0, bar: 1} +``` + + +## API + +### objectAssign(target, source, [source, ...]) + +Assigns enumerable own properties of `source` objects to the `target` object and returns the `target` object. Additional `source` objects will overwrite previous ones. + + +## Resources + +- [ES6 spec - Object.assign](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign) + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/tools/node_modules/object.omit/LICENSE b/tools/node_modules/object.omit/LICENSE new file mode 100644 index 00000000000000..fa30c4cb3e4c15 --- /dev/null +++ b/tools/node_modules/object.omit/LICENSE @@ -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. diff --git a/tools/node_modules/object.omit/README.md b/tools/node_modules/object.omit/README.md new file mode 100644 index 00000000000000..39251833961d7a --- /dev/null +++ b/tools/node_modules/object.omit/README.md @@ -0,0 +1,104 @@ +# object.omit [![NPM version](https://badge.fury.io/js/object.omit.svg)](http://badge.fury.io/js/object.omit) + +> Return a copy of an object excluding the given key, or array of keys. Also accepts an optional filter function as the last argument. + +## Install + +```sh +$ npm i object.omit --save-dev +``` + +## Usage + +```js +var omit = require('object.omit'); +``` + +Pass a string `key` to omit: + +```js +omit({a: 'a', b: 'b', c: 'c'}, 'a') +//=> { b: 'b', c: 'c' } +``` + +Pass an array of `keys` to omit: + +```js +omit({a: 'a', b: 'b', c: 'c'}, ['a', 'c']) +//=> { b: 'b' } +``` + +Returns the object if no keys are passed: + +```js +omit({a: 'a', b: 'b', c: 'c'}) +//=> {a: 'a', b: 'b', c: 'c'} +``` + +Returns an empty object if no value is passed. + +```js +omit() +//=> {} +``` + +### Filter function + +An optional filter function may be passed as the last argument, with or without keys passed on the arguments: + +**filter on keys** + +```js +var res = omit({a: 'a', b: 'b', c: 'c'}, function (val, key) { + return key === 'a'; +}); +//=> {a: 'a'} +``` + +**filter on values** + +```js +var fn = function() {}; +var obj = {a: 'a', b: 'b', c: fn}; + +var res = omit(obj, ['a'], function (val, key) { + return typeof val !== 'function'; +}); +//=> {b: 'b'} +``` + +### Other awesome javascript/node.js utils + +* [object.filter](https://github.com/jonschlinkert/object.filter): Create a new object filtered to have only properties for which the callback returns true. +* [object.pick](https://github.com/jonschlinkert/object.pick): Returns a filtered copy of an object with only the specified keys, like `pick` from… [more](https://github.com/jonschlinkert/object.pick) +* [object.pluck](https://github.com/jonschlinkert/object.pluck): Like pluck from underscore / lo-dash, but returns an object composed of specified properties, with… [more](https://github.com/jonschlinkert/object.pluck) +* [object.reduce](https://github.com/jonschlinkert/object.reduce): Reduces an object to a value that is the accumulated result of running each property… [more](https://github.com/jonschlinkert/object.reduce) +* [object.defaults](https://github.com/jonschlinkert/object.defaults): Like `extend` but only copies missing properties/values to the target object. + +## Runing 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/object.omit/issues/new) + +## Author + +**Jon Schlinkert** + ++ [github/jonschlinkert](https://github.com/jonschlinkert) ++ [twitter/jonschlinkert](http://twitter.com/jonschlinkert) + +## License + +Copyright © 2014-2015 Jon Schlinkert +Released under the MIT license. + +*** + +_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on July 22, 2015._ \ No newline at end of file diff --git a/tools/node_modules/object.omit/index.js b/tools/node_modules/object.omit/index.js new file mode 100644 index 00000000000000..576a578f88d29d --- /dev/null +++ b/tools/node_modules/object.omit/index.js @@ -0,0 +1,40 @@ +/*! + * object.omit + * + * Copyright (c) 2014-2015, Jon Schlinkert. + * Licensed under the MIT License. + */ + +'use strict'; + +var isObject = require('is-extendable'); +var forOwn = require('for-own'); + +module.exports = function omit(obj, keys) { + if (!isObject(obj)) return {}; + + var keys = [].concat.apply([], [].slice.call(arguments, 1)); + var last = keys[keys.length - 1]; + var res = {}, fn; + + if (typeof last === 'function') { + fn = keys.pop(); + } + + var isFunction = typeof fn === 'function'; + if (!keys.length && !isFunction) { + return obj; + } + + forOwn(obj, function (value, key) { + if (keys.indexOf(key) === -1) { + + if (!isFunction) { + res[key] = value; + } else if (fn(value, key, obj)) { + res[key] = value; + } + } + }); + return res; +}; diff --git a/tools/node_modules/object.omit/package.json b/tools/node_modules/object.omit/package.json new file mode 100644 index 00000000000000..27e354363b2b98 --- /dev/null +++ b/tools/node_modules/object.omit/package.json @@ -0,0 +1,104 @@ +{ + "_args": [ + [ + "object.omit@^2.0.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\micromatch" + ] + ], + "_from": "object.omit@>=2.0.0 <3.0.0", + "_id": "object.omit@2.0.0", + "_inCache": true, + "_location": "/object.omit", + "_nodeVersion": "0.12.4", + "_npmUser": { + "email": "github@sellside.com", + "name": "jonschlinkert" + }, + "_npmVersion": "2.10.1", + "_phantomChildren": {}, + "_requested": { + "name": "object.omit", + "raw": "object.omit@^2.0.0", + "rawSpec": "^2.0.0", + "scope": null, + "spec": ">=2.0.0 <3.0.0", + "type": "range" + }, + "_requiredBy": [ + "/micromatch" + ], + "_resolved": "https://registry.npmjs.org/object.omit/-/object.omit-2.0.0.tgz", + "_shasum": "868597333d54e60662940bb458605dd6ae12fe94", + "_shrinkwrap": null, + "_spec": "object.omit@^2.0.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\micromatch", + "author": { + "name": "Jon Schlinkert", + "url": "https://github.com/jonschlinkert" + }, + "bugs": { + "url": "https://github.com/jonschlinkert/object.omit/issues" + }, + "dependencies": { + "for-own": "^0.1.3", + "is-extendable": "^0.1.1" + }, + "description": "Return a copy of an object excluding the given key, or array of keys. Also accepts an optional filter function as the last argument.", + "devDependencies": { + "mocha": "*", + "should": "*" + }, + "directories": {}, + "dist": { + "shasum": "868597333d54e60662940bb458605dd6ae12fe94", + "tarball": "http://registry.npmjs.org/object.omit/-/object.omit-2.0.0.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "6e222f2cf39634faa26f642b06af4eb2050b5e75", + "homepage": "https://github.com/jonschlinkert/object.omit", + "installable": true, + "keywords": [ + "clear", + "delete", + "key", + "object", + "omit", + "property", + "remove", + "value" + ], + "license": "MIT", + "main": "index.js", + "maintainers": [ + { + "name": "jonschlinkert", + "email": "github@sellside.com" + } + ], + "name": "object.omit", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git+https://github.com/jonschlinkert/object.omit.git" + }, + "scripts": { + "test": "mocha" + }, + "verb": { + "related": { + "list": [ + "object.defaults", + "object.filter", + "object.pick", + "object.pluck", + "object.reduce" + ] + } + }, + "version": "2.0.0" +} diff --git a/tools/node_modules/once/LICENSE b/tools/node_modules/once/LICENSE new file mode 100644 index 00000000000000..19129e315fe593 --- /dev/null +++ b/tools/node_modules/once/LICENSE @@ -0,0 +1,15 @@ +The ISC License + +Copyright (c) Isaac Z. Schlueter and Contributors + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR +IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/tools/node_modules/once/README.md b/tools/node_modules/once/README.md new file mode 100644 index 00000000000000..a2981ea0705196 --- /dev/null +++ b/tools/node_modules/once/README.md @@ -0,0 +1,51 @@ +# once + +Only call a function once. + +## usage + +```javascript +var once = require('once') + +function load (file, cb) { + cb = once(cb) + loader.load('file') + loader.once('load', cb) + loader.once('error', cb) +} +``` + +Or add to the Function.prototype in a responsible way: + +```javascript +// only has to be done once +require('once').proto() + +function load (file, cb) { + cb = cb.once() + loader.load('file') + loader.once('load', cb) + loader.once('error', cb) +} +``` + +Ironically, the prototype feature makes this module twice as +complicated as necessary. + +To check whether you function has been called, use `fn.called`. Once the +function is called for the first time the return value of the original +function is saved in `fn.value` and subsequent calls will continue to +return this value. + +```javascript +var once = require('once') + +function load (cb) { + cb = once(cb) + var stream = createStream() + stream.once('data', cb) + stream.once('end', function () { + if (!cb.called) cb(new Error('not found')) + }) +} +``` diff --git a/tools/node_modules/once/once.js b/tools/node_modules/once/once.js new file mode 100644 index 00000000000000..2e1e721bfecec3 --- /dev/null +++ b/tools/node_modules/once/once.js @@ -0,0 +1,21 @@ +var wrappy = require('wrappy') +module.exports = wrappy(once) + +once.proto = once(function () { + Object.defineProperty(Function.prototype, 'once', { + value: function () { + return once(this) + }, + configurable: true + }) +}) + +function once (fn) { + var f = function () { + if (f.called) return f.value + f.called = true + return f.value = fn.apply(this, arguments) + } + f.called = false + return f +} diff --git a/tools/node_modules/once/package.json b/tools/node_modules/once/package.json new file mode 100644 index 00000000000000..f2714ec4964a85 --- /dev/null +++ b/tools/node_modules/once/package.json @@ -0,0 +1,88 @@ +{ + "_args": [ + [ + "once@^1.3.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\glob" + ] + ], + "_from": "once@>=1.3.0 <2.0.0", + "_id": "once@1.3.3", + "_inCache": true, + "_location": "/once", + "_nodeVersion": "4.0.0", + "_npmUser": { + "email": "i@izs.me", + "name": "isaacs" + }, + "_npmVersion": "3.3.2", + "_phantomChildren": {}, + "_requested": { + "name": "once", + "raw": "once@^1.3.0", + "rawSpec": "^1.3.0", + "scope": null, + "spec": ">=1.3.0 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/glob", + "/inflight" + ], + "_resolved": "https://registry.npmjs.org/once/-/once-1.3.3.tgz", + "_shasum": "b2e261557ce4c314ec8304f3fa82663e4297ca20", + "_shrinkwrap": null, + "_spec": "once@^1.3.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\glob", + "author": { + "email": "i@izs.me", + "name": "Isaac Z. Schlueter", + "url": "http://blog.izs.me/" + }, + "bugs": { + "url": "https://github.com/isaacs/once/issues" + }, + "dependencies": { + "wrappy": "1" + }, + "description": "Run a function exactly one time", + "devDependencies": { + "tap": "^1.2.0" + }, + "directories": { + "test": "test" + }, + "dist": { + "shasum": "b2e261557ce4c314ec8304f3fa82663e4297ca20", + "tarball": "http://registry.npmjs.org/once/-/once-1.3.3.tgz" + }, + "files": [ + "once.js" + ], + "gitHead": "2ad558657e17fafd24803217ba854762842e4178", + "homepage": "https://github.com/isaacs/once#readme", + "installable": true, + "keywords": [ + "function", + "once", + "one", + "single" + ], + "license": "ISC", + "main": "once.js", + "maintainers": [ + { + "name": "isaacs", + "email": "i@izs.me" + } + ], + "name": "once", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git://github.com/isaacs/once.git" + }, + "scripts": { + "test": "tap test/*.js" + }, + "version": "1.3.3" +} diff --git a/tools/node_modules/onetime/index.js b/tools/node_modules/onetime/index.js new file mode 100644 index 00000000000000..cc3c3ed8dcf4a9 --- /dev/null +++ b/tools/node_modules/onetime/index.js @@ -0,0 +1,31 @@ +'use strict'; +module.exports = function (fn, errMsg) { + if (typeof fn !== 'function') { + throw new TypeError('Expected a function'); + } + + var ret; + var called = false; + var fnName = fn.displayName || fn.name || (/function ([^\(]+)/.exec(fn.toString()) || [])[1]; + + var onetime = function () { + if (called) { + if (errMsg === true) { + fnName = fnName ? fnName + '()' : 'Function'; + throw new Error(fnName + ' can only be called once.'); + } + + return ret; + } + + called = true; + ret = fn.apply(this, arguments); + fn = null; + + return ret; + }; + + onetime.displayName = fnName; + + return onetime; +}; diff --git a/tools/node_modules/onetime/license b/tools/node_modules/onetime/license new file mode 100644 index 00000000000000..654d0bfe943437 --- /dev/null +++ b/tools/node_modules/onetime/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tools/node_modules/onetime/package.json b/tools/node_modules/onetime/package.json new file mode 100644 index 00000000000000..d26b33ce159a06 --- /dev/null +++ b/tools/node_modules/onetime/package.json @@ -0,0 +1,88 @@ +{ + "_args": [ + [ + "onetime@^1.0.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\restore-cursor" + ] + ], + "_from": "onetime@>=1.0.0 <2.0.0", + "_id": "onetime@1.1.0", + "_inCache": true, + "_location": "/onetime", + "_nodeVersion": "4.2.1", + "_npmUser": { + "email": "sindresorhus@gmail.com", + "name": "sindresorhus" + }, + "_npmVersion": "2.14.7", + "_phantomChildren": {}, + "_requested": { + "name": "onetime", + "raw": "onetime@^1.0.0", + "rawSpec": "^1.0.0", + "scope": null, + "spec": ">=1.0.0 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/restore-cursor" + ], + "_resolved": "https://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz", + "_shasum": "a1f7838f8314c516f05ecefcbc4ccfe04b4ed789", + "_shrinkwrap": null, + "_spec": "onetime@^1.0.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\restore-cursor", + "author": { + "email": "sindresorhus@gmail.com", + "name": "Sindre Sorhus", + "url": "sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/sindresorhus/onetime/issues" + }, + "dependencies": {}, + "description": "Only call a function once", + "devDependencies": { + "ava": "*", + "xo": "*" + }, + "directories": {}, + "dist": { + "shasum": "a1f7838f8314c516f05ecefcbc4ccfe04b4ed789", + "tarball": "http://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "6fae2fb77b95b49719d1c270d8ba07d9515bdfe8", + "homepage": "https://github.com/sindresorhus/onetime", + "installable": true, + "keywords": [ + "call", + "function", + "once", + "one", + "prevent", + "single" + ], + "license": "MIT", + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + } + ], + "name": "onetime", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "https://github.com/sindresorhus/onetime" + }, + "scripts": { + "test": "xo && ava" + }, + "version": "1.1.0" +} diff --git a/tools/node_modules/onetime/readme.md b/tools/node_modules/onetime/readme.md new file mode 100644 index 00000000000000..e27d2bcb47ae34 --- /dev/null +++ b/tools/node_modules/onetime/readme.md @@ -0,0 +1,52 @@ +# onetime [![Build Status](https://travis-ci.org/sindresorhus/onetime.svg?branch=master)](https://travis-ci.org/sindresorhus/onetime) + +> Only call a function once + +When called multiple times it will return the return value from the first call. + +*Unlike the module [once](https://github.com/isaacs/once), this one isn't naughty extending `Function.prototype`.* + + +## Install + +``` +$ npm install --save onetime +``` + + +## Usage + +```js +let i = 0; + +const foo = onetime(() => i++); + +foo(); //=> 0 +foo(); //=> 0 +foo(); //=> 0 +``` + + +## API + +### onetime(function, [shouldThrow]) + +#### function + +Type: `function` + +Function that should only be called once. + +#### shouldThrow + +Type: `boolean` +Default: `false` + +![](screenshot-shouldthrow.png) + +Set to `true` if you want it to fail with a nice and descriptive error when called more than once. + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/tools/node_modules/os-homedir/index.js b/tools/node_modules/os-homedir/index.js new file mode 100644 index 00000000000000..33066166fe6692 --- /dev/null +++ b/tools/node_modules/os-homedir/index.js @@ -0,0 +1,24 @@ +'use strict'; +var os = require('os'); + +function homedir() { + var env = process.env; + var home = env.HOME; + var user = env.LOGNAME || env.USER || env.LNAME || env.USERNAME; + + if (process.platform === 'win32') { + return env.USERPROFILE || env.HOMEDRIVE + env.HOMEPATH || home || null; + } + + if (process.platform === 'darwin') { + return home || (user ? '/Users/' + user : null); + } + + if (process.platform === 'linux') { + return home || (process.getuid() === 0 ? '/root' : (user ? '/home/' + user : null)); + } + + return home || null; +} + +module.exports = typeof os.homedir === 'function' ? os.homedir : homedir; diff --git a/tools/node_modules/os-homedir/license b/tools/node_modules/os-homedir/license new file mode 100644 index 00000000000000..654d0bfe943437 --- /dev/null +++ b/tools/node_modules/os-homedir/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tools/node_modules/os-homedir/package.json b/tools/node_modules/os-homedir/package.json new file mode 100644 index 00000000000000..080fc6474ccf1b --- /dev/null +++ b/tools/node_modules/os-homedir/package.json @@ -0,0 +1,96 @@ +{ + "_args": [ + [ + "os-homedir@^1.0.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\untildify" + ] + ], + "_from": "os-homedir@>=1.0.0 <2.0.0", + "_id": "os-homedir@1.0.1", + "_inCache": true, + "_location": "/os-homedir", + "_nodeVersion": "0.12.5", + "_npmUser": { + "email": "sindresorhus@gmail.com", + "name": "sindresorhus" + }, + "_npmVersion": "2.11.2", + "_phantomChildren": {}, + "_requested": { + "name": "os-homedir", + "raw": "os-homedir@^1.0.0", + "rawSpec": "^1.0.0", + "scope": null, + "spec": ">=1.0.0 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/untildify", + "/user-home" + ], + "_resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.1.tgz", + "_shasum": "0d62bdf44b916fd3bbdcf2cab191948fb094f007", + "_shrinkwrap": null, + "_spec": "os-homedir@^1.0.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\untildify", + "author": { + "email": "sindresorhus@gmail.com", + "name": "Sindre Sorhus", + "url": "sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/sindresorhus/os-homedir/issues" + }, + "dependencies": {}, + "description": "io.js 2.3.0 os.homedir() ponyfill", + "devDependencies": { + "ava": "0.0.4", + "path-exists": "^1.0.0" + }, + "directories": {}, + "dist": { + "shasum": "0d62bdf44b916fd3bbdcf2cab191948fb094f007", + "tarball": "http://registry.npmjs.org/os-homedir/-/os-homedir-1.0.1.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "13ff83fbd13ebe286a6092286b2c634ab4534c5f", + "homepage": "https://github.com/sindresorhus/os-homedir", + "installable": true, + "keywords": [ + "built-in", + "core", + "dir", + "directory", + "folder", + "home", + "homedir", + "os", + "path", + "polyfill", + "ponyfill", + "shim", + "user" + ], + "license": "MIT", + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + } + ], + "name": "os-homedir", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "https://github.com/sindresorhus/os-homedir" + }, + "scripts": { + "test": "node test.js" + }, + "version": "1.0.1" +} diff --git a/tools/node_modules/os-homedir/readme.md b/tools/node_modules/os-homedir/readme.md new file mode 100644 index 00000000000000..4851f104ea7134 --- /dev/null +++ b/tools/node_modules/os-homedir/readme.md @@ -0,0 +1,33 @@ +# os-homedir [![Build Status](https://travis-ci.org/sindresorhus/os-homedir.svg?branch=master)](https://travis-ci.org/sindresorhus/os-homedir) + +> io.js 2.3.0 [`os.homedir()`](https://iojs.org/api/os.html#os_os_homedir) ponyfill + +> Ponyfill: A polyfill that doesn't overwrite the native method + + +## Install + +``` +$ npm install --save os-homedir +``` + + +## Usage + +```js +var osHomedir = require('os-homedir'); + +console.log(osHomedir()); +//=> /Users/sindresorhus +``` + + +## Related + +- [user-home](https://github.com/sindresorhus/user-home) - Same as this module but caches the result +- [home-or-tmp](https://github.com/sindresorhus/home-or-tmp) - Get the user home directory with fallback to the system temp directory + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/tools/node_modules/parse-entities/LICENSE b/tools/node_modules/parse-entities/LICENSE new file mode 100644 index 00000000000000..611b67581bb8e2 --- /dev/null +++ b/tools/node_modules/parse-entities/LICENSE @@ -0,0 +1,22 @@ +(The MIT License) + +Copyright (c) 2015 Titus Wormer + +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. diff --git a/tools/node_modules/parse-entities/history.md b/tools/node_modules/parse-entities/history.md new file mode 100644 index 00000000000000..c066e4dad9d775 --- /dev/null +++ b/tools/node_modules/parse-entities/history.md @@ -0,0 +1,18 @@ + + + + +1.0.2 / 2015-12-29 +================== + +* Fix legacy entity support ([7bf652a](https://github.com/wooorm/parse-entities/commit/7bf652a)) + +1.0.1 / 2015-12-27 +================== + +* Update mdast to remark ([8b158ad](https://github.com/wooorm/parse-entities/commit/8b158ad)) +* Fix escaping in `readme.md` ([c743fa2](https://github.com/wooorm/parse-entities/commit/c743fa2)) +* Fix missing dependencies in `component.json` ([cbdd3da](https://github.com/wooorm/parse-entities/commit/cbdd3da)) + +1.0.0 / 2015-12-23 +================== diff --git a/tools/node_modules/parse-entities/index.js b/tools/node_modules/parse-entities/index.js new file mode 100644 index 00000000000000..229d02e0d39594 --- /dev/null +++ b/tools/node_modules/parse-entities/index.js @@ -0,0 +1,704 @@ +/** + * @author Titus Wormer + * @copyright 2015 Titus Wormer + * @license MIT + * @module parse-entities + * @fileoverview Parse HTML character references: fast, spec-compliant, + * positional information. + */ + +'use strict'; + +/* eslint-env commonjs */ + +/* + * Dependencies. + */ + +var characterEntities = require('character-entities'); +var legacy = require('character-entities-legacy'); +var invalid = require('character-reference-invalid'); + +/* + * Methods. + */ + +var fromCharCode = String.fromCharCode; +var has = Object.prototype.hasOwnProperty; +var noop = Function.prototype; + +/* + * Reference types. + */ + +var NAMED = 'named'; +var HEXADECIMAL = 'hexadecimal'; +var DECIMAL = 'decimal'; + +/* + * Map of bases. + */ + +var BASE = {}; + +BASE[HEXADECIMAL] = 16; +BASE[DECIMAL] = 10; + +/* + * Warning messages. + */ + +var NUMERIC_REFERENCE = 'Numeric character references'; +var NAMED_REFERENCE = 'Named character references'; +var TERMINATED = ' must be terminated by a semicolon'; +var VOID = ' cannot be empty'; + +var NAMED_NOT_TERMINATED = 1; +var NUMERIC_NOT_TERMINATED = 2; +var NAMED_EMPTY = 3; +var NUMERIC_EMPTY = 4; +var NAMED_UNKNOWN = 5; +var NUMERIC_DISALLOWED = 6; +var NUMERIC_PROHIBITED = 7; + +var MESSAGES = {}; + +MESSAGES[NAMED_NOT_TERMINATED] = NAMED_REFERENCE + TERMINATED; +MESSAGES[NUMERIC_NOT_TERMINATED] = NUMERIC_REFERENCE + TERMINATED; +MESSAGES[NAMED_EMPTY] = NAMED_REFERENCE + VOID; +MESSAGES[NUMERIC_EMPTY] = NUMERIC_REFERENCE + VOID; +MESSAGES[NAMED_UNKNOWN] = NAMED_REFERENCE + ' must be known'; +MESSAGES[NUMERIC_DISALLOWED] = NUMERIC_REFERENCE + ' cannot be disallowed'; +MESSAGES[NUMERIC_PROHIBITED] = NUMERIC_REFERENCE + ' cannot be outside the ' + + 'permissible Unicode range'; + +/* + * Characters. + */ + +var REPLACEMENT = '\uFFFD'; +var FORM_FEED = '\f'; +var AMPERSAND = '&'; +var OCTOTHORP = '#'; +var SEMICOLON = ';'; +var NEWLINE = '\n'; +var X_LOWER = 'x'; +var X_UPPER = 'X'; +var SPACE = ' '; +var LESS_THAN = '<'; +var EQUAL = '='; +var EMPTY = ''; +var TAB = '\t'; + +/** + * Get the character-code at the first indice in + * `character`. + * + * @param {string} character - Value. + * @return {number} - Character-code at the first indice + * in `character`. + */ +function charCode(character) { + return character.charCodeAt(0); +} + +/** + * Check whether `character` is a decimal. + * + * @param {string} character - Value. + * @return {boolean} - Whether `character` is a decimal. + */ +function isDecimal(character) { + var code = charCode(character); + + return code >= 48 /* 0 */ && code <= 57 /* 9 */; +} + +/** + * Check whether `character` is a hexadecimal. + * + * @param {string} character - Value. + * @return {boolean} - Whether `character` is a + * hexadecimal. + */ +function isHexadecimal(character) { + var code = charCode(character); + + return (code >= 48 /* 0 */ && code <= 57 /* 9 */) || + (code >= 65 /* A */ && code <= 70 /* F */) || + (code >= 97 /* a */ && code <= 102 /* f */); +} + +/** + * Check whether `character` is an alphanumeric. + * + * @param {string} character - Value. + * @return {boolean} - Whether `character` is an + * alphanumeric. + */ +function isAlphanumeric(character) { + var code = charCode(character); + + return (code >= 48 /* 0 */ && code <= 57 /* 9 */) || + (code >= 65 /* A */ && code <= 90 /* Z */) || + (code >= 97 /* a */ && code <= 122 /* z */); +} + +/** + * Check whether `character` is outside the permissible + * unicode range. + * + * @param {number} characterCode - Value. + * @return {boolean} - Whether `character` is an + * outside the permissible unicode range. + */ +function isProhibited(characterCode) { + return (characterCode >= 0xD800 && characterCode <= 0xDFFF) || + (characterCode > 0x10FFFF); +} + +/** + * Check whether `character` is disallowed. + * + * @param {number} characterCode - Value. + * @return {boolean} - Whether `character` is disallowed. + */ +function isWarning(characterCode) { + return (characterCode >= 0x0001 && characterCode <= 0x0008) || + (characterCode >= 0x000D && characterCode <= 0x001F) || + (characterCode >= 0x007F && characterCode <= 0x009F) || + (characterCode >= 0xFDD0 && characterCode <= 0xFDEF) || + characterCode === 0x000B || + characterCode === 0xFFFE || + characterCode === 0xFFFF || + characterCode === 0x1FFFE || + characterCode === 0x1FFFF || + characterCode === 0x2FFFE || + characterCode === 0x2FFFF || + characterCode === 0x3FFFE || + characterCode === 0x3FFFF || + characterCode === 0x4FFFE || + characterCode === 0x4FFFF || + characterCode === 0x5FFFE || + characterCode === 0x5FFFF || + characterCode === 0x6FFFE || + characterCode === 0x6FFFF || + characterCode === 0x7FFFE || + characterCode === 0x7FFFF || + characterCode === 0x8FFFE || + characterCode === 0x8FFFF || + characterCode === 0x9FFFE || + characterCode === 0x9FFFF || + characterCode === 0xAFFFE || + characterCode === 0xAFFFF || + characterCode === 0xBFFFE || + characterCode === 0xBFFFF || + characterCode === 0xCFFFE || + characterCode === 0xCFFFF || + characterCode === 0xDFFFE || + characterCode === 0xDFFFF || + characterCode === 0xEFFFE || + characterCode === 0xEFFFF || + characterCode === 0xFFFFE || + characterCode === 0xFFFFF || + characterCode === 0x10FFFE || + characterCode === 0x10FFFF; +} + +/* + * Map of types to tests. Each type of character reference + * accepts different characters. This test is used to + * detect whether a reference has ended (as the semicolon + * is not strictly needed). + */ + +var TESTS = {}; + +TESTS[NAMED] = isAlphanumeric; +TESTS[DECIMAL] = isDecimal; +TESTS[HEXADECIMAL] = isHexadecimal; + +/** + * Parse entities. + * + * @param {string} value - Value to tokenise. + * @param {Object?} [settings] - Configuration. + */ +function parse(value, settings) { + var additional = settings.additional; + var handleText = settings.text; + var handleReference = settings.reference; + var handleWarning = settings.warning; + var textContext = settings.textContext; + var referenceContext = settings.referenceContext; + var warningContext = settings.warningContext; + var pos = settings.position; + var indent = settings.indent || []; + var length = value.length; + var index = 0; + var lines = -1; + var column = pos.column || 1; + var line = pos.line || 1; + var queue = EMPTY; + var result = []; + var entityCharacters; + var terminated; + var characters; + var character; + var reference; + var following; + var warning; + var reason; + var output; + var entity; + var begin; + var start; + var type; + var test; + var prev; + var next; + var diff; + var end; + + /** + * Get current position. + * + * @return {Object} - Positional information of a + * single point. + */ + function now() { + return { + 'line': line, + 'column': column, + 'offset': index + (pos.offset || 0) + }; + } + + /** + * “Throw” a parse-error: a warning. + * + * @param {number} code - Identifier of reason for + * failing. + * @param {number} offset - Offset in characters from + * the current position point at which the + * parse-error ocurred, cannot point past newlines. + */ + function parseError(code, offset) { + var position = now(); + + position.column += offset; + position.offset += offset; + + handleWarning.call(warningContext, MESSAGES[code], position, code); + } + + /** + * Get character at position. + * + * @param {number} position - Indice of character in `value`. + * @return {string} - Character at `position` in + * `value`. + */ + function at(position) { + return value.charAt(position); + } + + /** + * Flush `queue` (normal text). Macro invoked before + * each entity and at the end of `value`. + * + * Does nothing when `queue` is empty. + */ + function flush() { + if (queue) { + result.push(queue); + + if (handleText) { + handleText.call(textContext, queue, { + 'start': prev, + 'end': now() + }); + } + + queue = EMPTY; + } + } + + /* + * Cache the current point. + */ + + prev = now(); + + /* + * Wrap `handleWarning`. + */ + + warning = handleWarning ? parseError : noop; + + /* + * Ensure the algorithm walks over the first character + * and the end (inclusive). + */ + + index--; + length++; + + while (++index < length) { + /* + * If the previous character was a newline. + */ + + if (character === NEWLINE) { + column = indent[lines] || 1; + } + + character = at(index); + + /* + * Handle anything other than an ampersand, + * including newlines and EOF. + */ + + if (character !== AMPERSAND) { + if (character === NEWLINE) { + line++; + lines++; + column = 0; + } + + if (character) { + queue += character; + column++; + } else { + flush(); + } + } else { + following = at(index + 1); + + /* + * The behaviour depends on the identity of the next character. + */ + + if ( + following === TAB || + following === NEWLINE || + following === FORM_FEED || + following === SPACE || + following === LESS_THAN || + following === AMPERSAND || + following === EMPTY || + (additional && following === additional) + ) { + /* + * Not a character reference. No characters + * are consumed, and nothing is returned. + * This is not an error, either. + */ + + queue += character; + column++; + + continue; + } + + start = begin = end = index + 1; + + /* + * Numerical entity. + */ + + if (following !== OCTOTHORP) { + type = NAMED; + } else { + end = ++begin; + + /* + * The behaviour further depends on the + * character after the U+0023 NUMBER SIGN. + */ + + following = at(end); + + if (following === X_LOWER || following === X_UPPER) { + /* + * ASCII hex digits. + */ + + type = HEXADECIMAL; + end = ++begin; + } else { + /* + * ASCII digits. + */ + + type = DECIMAL; + } + } + + entityCharacters = entity = characters = EMPTY; + test = TESTS[type]; + end--; + + while (++end < length) { + following = at(end); + + if (!test(following)) { + break; + } + + characters += following; + + /* + * Check if we can match a legacy named + * reference. If so, we cache that as the + * last viable named reference. This + * ensures we do not need to walk backwards + * later. + */ + + if ( + type === NAMED && + has.call(legacy, characters) + ) { + entityCharacters = characters; + entity = legacy[characters]; + } + } + + terminated = at(end) === SEMICOLON; + + if (terminated) { + end++; + + if ( + type === NAMED && + has.call(characterEntities, characters) + ) { + entityCharacters = characters; + entity = characterEntities[characters]; + } + } + + diff = 1 + end - start; + + if (!characters) { + /* + * An empty (possible) entity is valid, unless + * its numeric (thus an ampersand followed by + * an octothorp). + */ + + if (type !== NAMED) { + warning(NUMERIC_EMPTY, diff); + } + } else if (type === NAMED) { + /* + * An ampersand followed by anything + * unknown, and not terminated, is invalid. + */ + + if (terminated && !entity) { + warning(NAMED_UNKNOWN, 1); + } else { + /* + * If theres something after an entity + * name which is not known, cap the + * reference. + */ + + if (entityCharacters !== characters) { + end = begin + entityCharacters.length; + diff = 1 + end - begin; + terminated = false; + } + + /* + * If the reference is not terminated, + * warn. + */ + + if (!terminated) { + reason = entityCharacters ? + NAMED_NOT_TERMINATED : + NAMED_EMPTY; + + if (!settings.attribute) { + warning(reason, diff); + } else { + following = at(end); + + if (following === EQUAL) { + warning(reason, diff); + entity = null; + } else if (isAlphanumeric(following)) { + entity = null; + } else { + warning(reason, diff); + } + } + } + } + + reference = entity; + } else { + if (!terminated) { + /* + * All non-terminated numeric entities are + * not rendered, and trigger a warning. + */ + + warning(NUMERIC_NOT_TERMINATED, diff); + } + + /* + * When terminated and number, parse as + * either hexadecimal or decimal. + */ + + reference = parseInt(characters, BASE[type]); + + /* + * Trigger a warning when the parsed number + * is prohibited, and replace with + * replacement character. + */ + + if (isProhibited(reference)) { + warning(NUMERIC_PROHIBITED, diff); + + reference = REPLACEMENT; + } else if (reference in invalid) { + /* + * Trigger a warning when the parsed number + * is disallowed, and replace by an + * alternative. + */ + + warning(NUMERIC_DISALLOWED, diff); + + reference = invalid[reference]; + } else { + /* + * Parse the number. + */ + + output = EMPTY; + + /* + * Trigger a warning when the parsed + * number should not be used. + */ + + if (isWarning(reference)) { + warning(NUMERIC_DISALLOWED, diff); + } + + /* + * Stringify the number. + */ + + if (reference > 0xFFFF) { + reference -= 0x10000; + output += fromCharCode( + reference >>> 10 & 0x3FF | 0xD800 + ); + + reference = 0xDC00 | reference & 0x3FF; + } + + reference = output + fromCharCode(reference); + } + } + + /* + * If we could not find a reference, queue the + * checked characters (as normal characters), + * and move the pointer to their end. This is + * possible because we can be certain neither + * newlines nor ampersands are included. + */ + + if (!reference) { + characters = value.slice(start - 1, end); + queue += characters; + column += characters.length; + index = end - 1; + } else { + /* + * Found it! First eat the queued + * characters as normal text, then eat + * an entity. + */ + + flush(); + + prev = now(); + index = end - 1; + column += end - start + 1; + result.push(reference); + next = now(); + next.offset++; + + if (handleReference) { + handleReference.call(referenceContext, reference, { + 'start': prev, + 'end': next + }, value.slice(start - 1, end)); + } + + prev = next; + } + } + } + + /* + * Return the reduced nodes, and any possible warnings. + */ + + return result.join(EMPTY); +} + +var defaults = { + 'warning': null, + 'reference': null, + 'text': null, + 'warningContext': null, + 'referenceContext': null, + 'textContext': null, + 'position': {}, + 'additional': null, + 'attribute': false +}; + +/** + * Wrap to ensure clean parameters are given to `parse`. + * + * @param {string} value - Value with entities. + * @param {Object?} [options] - Configuration. + */ +function wrapper(value, options) { + var settings = {}; + var key; + + if (!options) { + options = {}; + } + + for (key in defaults) { + settings[key] = options[key] || defaults[key]; + } + + if (settings.position.indent || settings.position.start) { + settings.indent = settings.position.indent || []; + settings.position = settings.position.start; + } + + return parse(value, settings); +} + +/* + * Expose. + */ + +module.exports = wrapper; diff --git a/tools/node_modules/parse-entities/package.json b/tools/node_modules/parse-entities/package.json new file mode 100644 index 00000000000000..427add09a1b7a7 --- /dev/null +++ b/tools/node_modules/parse-entities/package.json @@ -0,0 +1,110 @@ +{ + "_args": [ + [ + "parse-entities@^1.0.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\remark" + ] + ], + "_from": "parse-entities@>=1.0.0 <2.0.0", + "_id": "parse-entities@1.0.2", + "_inCache": true, + "_location": "/parse-entities", + "_nodeVersion": "5.1.0", + "_npmUser": { + "email": "tituswormer@gmail.com", + "name": "wooorm" + }, + "_npmVersion": "3.5.0", + "_phantomChildren": {}, + "_requested": { + "name": "parse-entities", + "raw": "parse-entities@^1.0.0", + "rawSpec": "^1.0.0", + "scope": null, + "spec": ">=1.0.0 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/remark" + ], + "_resolved": "https://registry.npmjs.org/parse-entities/-/parse-entities-1.0.2.tgz", + "_shasum": "6ec4c6014e25a310d3a146661208f0380edfd41a", + "_shrinkwrap": null, + "_spec": "parse-entities@^1.0.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\remark", + "author": { + "email": "tituswormer@gmail.com", + "name": "Titus Wormer" + }, + "bugs": { + "url": "https://github.com/wooorm/parse-entities/issues" + }, + "dependencies": { + "character-entities": "^1.0.0", + "character-entities-legacy": "^1.0.0", + "character-reference-invalid": "^1.0.0" + }, + "description": "Parse HTML character references: fast, spec-compliant, positional information", + "devDependencies": { + "browserify": "^12.0.0", + "eslint": "^1.0.0", + "esmangle": "^1.0.0", + "istanbul": "^0.4.0", + "jscs": "^2.0.0", + "jscs-jsdoc": "^1.0.0", + "remark": "^3.0.0", + "remark-comment-config": "^2.0.0", + "remark-github": "^2.0.0", + "remark-lint": "^2.0.0", + "remark-slug": "^3.0.0", + "remark-validate-links": "^2.0.0", + "remark-yaml-config": "^2.0.0", + "tape": "^4.2.0" + }, + "directories": {}, + "dist": { + "shasum": "6ec4c6014e25a310d3a146661208f0380edfd41a", + "tarball": "http://registry.npmjs.org/parse-entities/-/parse-entities-1.0.2.tgz" + }, + "files": [ + "LICENSE", + "index.js" + ], + "gitHead": "1a5feddc5d9c0029fa802dc1ecb2968190d7361f", + "homepage": "https://github.com/wooorm/parse-entities#readme", + "installable": true, + "keywords": [ + "character", + "entities", + "entity", + "html", + "parse", + "reference" + ], + "license": "MIT", + "maintainers": [ + { + "name": "wooorm", + "email": "tituswormer@gmail.com" + } + ], + "name": "parse-entities", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git+https://github.com/wooorm/parse-entities.git" + }, + "scripts": { + "build": "npm run build-md && npm run build-bundle && npm run build-mangle", + "build-bundle": "browserify index.js --bare -s parseEntities > parse-entities.js", + "build-mangle": "esmangle parse-entities.js > parse-entities.min.js", + "build-md": "remark . --quiet --frail", + "lint": "npm run lint-api && npm run lint-style", + "lint-api": "eslint .", + "lint-style": "jscs --reporter inline .", + "test": "npm run build && npm run lint && npm run test-coverage", + "test-api": "node test.js", + "test-coverage": "istanbul cover test.js" + }, + "version": "1.0.2" +} diff --git a/tools/node_modules/parse-entities/readme.md b/tools/node_modules/parse-entities/readme.md new file mode 100644 index 00000000000000..cfc8d4480e7661 --- /dev/null +++ b/tools/node_modules/parse-entities/readme.md @@ -0,0 +1,141 @@ +# parse-entities [![Build Status](https://img.shields.io/travis/wooorm/parse-entities.svg?style=flat)](https://travis-ci.org/wooorm/parse-entities) [![Coverage Status](https://img.shields.io/codecov/c/github/wooorm/parse-entities.svg)](https://codecov.io/github/wooorm/parse-entities) + +Parse HTML character references: fast, spec-compliant, positional information. + +## Installation + +[npm](https://docs.npmjs.com/cli/install): + +```bash +npm install parse-entities +``` + +**parse-entities** is also available for [duo](http://duojs.org/#getting-started), +and [bundled](https://github.com/wooorm/parse-entities/releases) for AMD, +CommonJS, and globals (uncompressed and compressed). + +## Usage + +```js +var decode = require('parse-entities'); + +decode('alpha & bravo'); +// alpha & bravo + +decode('charlie ©cat; delta'); +// charlie ©cat; delta + +decode('echo © foxtrot ≠ golf 𝌆 hotel'); +// echo © foxtrot ≠ golf 𝌆 hotel +``` + +## API + +## parseEntities(value\[, options]) + +**Parameters** + +* `value` (`string`) + — Value with entities to parse; + +* `options` (`Object`, optional): + + * `additional` (`string`, optional, default: `''`) + — Additional character to accept when following an ampersand (without + error); + + * `attribute` (`boolean`, optional, default: `false`) + — Whether to parse `value` as an attribute value; + + * `position` (`Location` or `Position`, optional) + — Starting `position` of `value`, useful when dealing with values + nested in some sort of syntax tree. The default is: + + ```json + { + "start": { + "line": 1, + "column": 1, + "offset": 0 + }, + "indent": [] + } + ``` + + * `warning` ([`Function`](#function-warningreason-position-code), + optional) — Error handler; + + * `text` ([`Function`](#function-textvalue-location), optional) + — Text handler; + + * `reference` ([`Function`](#function-referencevalue-location-source), + optional) — Reference handler; + + * `warningContext` (`'*'`, optional) + — Context used when invoking `warning`; + + * `textContext` (`'*'`, optional) + — Context used when invoking `text`; + + * `referenceContext` (`'*'`, optional) + — Context used when invoking `reference`. + +**Returns** + +`string` — Decoded `value`. + +### function warning(reason, position, code) + +Error handler. + +**Context**: `this` refers to `warningContext` when given to `parseEntities`. + +**Parameters** + +* `reason` (`string`) + — Reason (human-readable) for triggering a parse error; + +* `position` (`Position`) + — Place at which the parse error occurred; + +* `code` (`number`) + — Identifier of reason for triggering a parse error. + +The following codes are used: + +| Code | Example | Note | +| ---- | ------------------ | ----------------------------------------------------------------------------- | +| `1` | `foo & bar` | Missing semicolon (named) | +| `2` | `foo { bar` | Missing semicolon (numeric) | +| `3` | `Foo &bar baz` | Ampersand did not start a reference | +| `4` | `Foo &#` | Empty reference | +| `5` | `Foo &bar; baz` | Unknown entity | +| `6` | `Foo € baz` | [Disallowed reference](https://github.com/wooorm/character-reference-invalid) | +| `7` | `Foo � baz` | Prohibited: outside permissible unicode range | + +### function text(value, location) + +Text handler. + +**Context**: `this` refers to `textContext` when given to `parseEntities`. + +**Parameters** + +* `value` (`string`) — String of content; +* `location` (`Location`) — Location at which `value` starts and ends. + +### function reference(value, location, source) + +Character reference handler. + +**Context**: `this` refers to `referenceContext` when given to `parseEntities`. + +**Parameters** + +* `value` (`string`) — Encoded character reference; +* `location` (`Location`) — Location at which `value` starts and ends; +* `source` (`Location`) — Source of character reference. + +## License + +[MIT](LICENSE) © [Titus Wormer](http://wooorm.com) diff --git a/tools/node_modules/parse-glob/LICENSE b/tools/node_modules/parse-glob/LICENSE new file mode 100644 index 00000000000000..65f90aca8c2fff --- /dev/null +++ b/tools/node_modules/parse-glob/LICENSE @@ -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. diff --git a/tools/node_modules/parse-glob/README.md b/tools/node_modules/parse-glob/README.md new file mode 100644 index 00000000000000..000ccd99cb4235 --- /dev/null +++ b/tools/node_modules/parse-glob/README.md @@ -0,0 +1,115 @@ +# parse-glob [![NPM version](https://badge.fury.io/js/parse-glob.svg)](http://badge.fury.io/js/parse-glob) [![Build Status](https://travis-ci.org/jonschlinkert/parse-glob.svg)](https://travis-ci.org/jonschlinkert/parse-glob) + +> Parse a glob pattern into an object of tokens. + +**Changes from v1.0.0 to v3.0.4** + +* all path-related properties are now on the `path` object +* all boolean properties are now on the `is` object +* adds `base` property + +See the [properties](#properties) section for details. + +Install with [npm](https://www.npmjs.com/) + +```sh +$ npm i parse-glob --save +``` + +* parses 1,000+ glob patterns in 29ms (2.3 GHz Intel Core i7) +* Extensive [unit tests](./test.js) (more than 1,000 lines), covering wildcards, globstars, character classes, brace patterns, extglobs, dotfiles and other complex patterns. + +See the tests for [hundreds of examples](./test.js). + +## Usage + +```js +var parseGlob = require('parse-glob'); +``` + +**Example** + +```js +parseGlob('a/b/c/**/*.{yml,json}'); +``` + +**Returns:** + +```js +{ orig: 'a/b/c/**/*.{yml,json}', + is: + { glob: true, + negated: false, + extglob: false, + braces: true, + brackets: false, + globstar: true, + dotfile: false, + dotdir: false }, + glob: '**/*.{yml,json}', + base: 'a/b/c', + path: + { dirname: 'a/b/c/**/', + basename: '*.{yml,json}', + filename: '*', + extname: '.{yml,json}', + ext: '{yml,json}' } } +``` + +## Properties + +The object returned by parseGlob has the following properties: + +* `orig`: a copy of the original, unmodified glob pattern +* `is`: an object with boolean information about the glob: + - `glob`: true if the pattern actually a glob pattern + - `negated`: true if it's a negation pattern (`!**/foo.js`) + - `extglob`: true if it has extglobs (`@(foo|bar)`) + - `braces`: true if it has braces (`{1..2}` or `.{txt,md}`) + - `brackets`: true if it has POSIX brackets (`[[:alpha:]]`) + - `globstar`: true if the pattern has a globstar (double star, `**`) + - `dotfile`: true if the pattern should match dotfiles + - `dotdir`: true if the pattern should match dot-directories (like `.git`) +* `glob`: the glob pattern part of the string, if any +* `base`: the non-glob part of the string, if any +* `path`: file path segments + - `dirname`: directory + - `basename`: file name with extension + - `filename`: file name without extension + - `extname`: file extension with dot + - `ext`: file extension without dot + +## Related +* [glob-base](https://www.npmjs.com/package/glob-base): Returns an object with the (non-glob) base path and the actual pattern. | [homepage](https://github.com/jonschlinkert/glob-base) +* [glob-parent](https://www.npmjs.com/package/glob-parent): Strips glob magic from a string to provide the parent path | [homepage](https://github.com/es128/glob-parent) +* [glob-path-regex](https://www.npmjs.com/package/glob-path-regex): Regular expression for matching the parts of glob pattern. | [homepage](https://github.com/regexps/glob-path-regex) +* [is-glob](https://www.npmjs.com/package/is-glob): Returns `true` if the given string looks like a glob pattern. | [homepage](https://github.com/jonschlinkert/is-glob) +* [micromatch](https://www.npmjs.com/package/micromatch): Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch. Just… [more](https://www.npmjs.com/package/micromatch) | [homepage](https://github.com/jonschlinkert/micromatch) + +## Contributing + +Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/parse-glob/issues/new). + +## 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 © 2014-2015 Jon Schlinkert +Released under the MIT license. + +*** + +_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on September 22, 2015._ \ No newline at end of file diff --git a/tools/node_modules/parse-glob/index.js b/tools/node_modules/parse-glob/index.js new file mode 100644 index 00000000000000..4ab691afc7d581 --- /dev/null +++ b/tools/node_modules/parse-glob/index.js @@ -0,0 +1,156 @@ +/*! + * parse-glob + * + * Copyright (c) 2015, Jon Schlinkert. + * Licensed under the MIT License. + */ + +'use strict'; + +var isGlob = require('is-glob'); +var findBase = require('glob-base'); +var extglob = require('is-extglob'); +var dotfile = require('is-dotfile'); + +/** + * Expose `cache` + */ + +var cache = module.exports.cache = {}; + +/** + * Parse a glob pattern into tokens. + * + * When no paths or '**' are in the glob, we use a + * different strategy for parsing the filename, since + * file names can contain braces and other difficult + * patterns. such as: + * + * - `*.{a,b}` + * - `(**|*.js)` + */ + +module.exports = function parseGlob(glob) { + if (cache.hasOwnProperty(glob)) { + return cache[glob]; + } + + var tok = {}; + tok.orig = glob; + tok.is = {}; + + // unescape dots and slashes in braces/brackets + glob = escape(glob); + + var parsed = findBase(glob); + tok.is.glob = parsed.isGlob; + + tok.glob = parsed.glob; + tok.base = parsed.base; + var segs = /([^\/]*)$/.exec(glob); + + tok.path = {}; + tok.path.dirname = ''; + tok.path.basename = segs[1] || ''; + tok.path.dirname = glob.split(tok.path.basename).join('') || ''; + var basename = (tok.path.basename || '').split('.') || ''; + tok.path.filename = basename[0] || ''; + tok.path.extname = basename.slice(1).join('.') || ''; + tok.path.ext = ''; + + if (isGlob(tok.path.dirname) && !tok.path.basename) { + if (!/\/$/.test(tok.glob)) { + tok.path.basename = tok.glob; + } + tok.path.dirname = tok.base; + } + + if (glob.indexOf('/') === -1 && !tok.is.globstar) { + tok.path.dirname = ''; + tok.path.basename = tok.orig; + } + + var dot = tok.path.basename.indexOf('.'); + if (dot !== -1) { + tok.path.filename = tok.path.basename.slice(0, dot); + tok.path.extname = tok.path.basename.slice(dot); + } + + if (tok.path.extname.charAt(0) === '.') { + var exts = tok.path.extname.split('.'); + tok.path.ext = exts[exts.length - 1]; + } + + // unescape dots and slashes in braces/brackets + tok.glob = unescape(tok.glob); + tok.path.dirname = unescape(tok.path.dirname); + tok.path.basename = unescape(tok.path.basename); + tok.path.filename = unescape(tok.path.filename); + tok.path.extname = unescape(tok.path.extname); + + // Booleans + var is = (glob && tok.is.glob); + tok.is.negated = glob && glob.charAt(0) === '!'; + tok.is.extglob = glob && extglob(glob); + tok.is.braces = has(is, glob, '{'); + tok.is.brackets = has(is, glob, '[:'); + tok.is.globstar = has(is, glob, '**'); + tok.is.dotfile = dotfile(tok.path.basename) || dotfile(tok.path.filename); + tok.is.dotdir = dotdir(tok.path.dirname); + return (cache[glob] = tok); +} + +/** + * Returns true if the glob matches dot-directories. + * + * @param {Object} `tok` The tokens object + * @param {Object} `path` The path object + * @return {Object} + */ + +function dotdir(base) { + if (base.indexOf('/.') !== -1) { + return true; + } + if (base.charAt(0) === '.' && base.charAt(1) !== '/') { + return true; + } + return false; +} + +/** + * Returns true if the pattern has the given `ch`aracter(s) + * + * @param {Object} `glob` The glob pattern. + * @param {Object} `ch` The character to test for + * @return {Object} + */ + +function has(is, glob, ch) { + return is && glob.indexOf(ch) !== -1; +} + +/** + * Escape/unescape utils + */ + +function escape(str) { + var re = /\{([^{}]*?)}|\(([^()]*?)\)|\[([^\[\]]*?)\]/g; + return str.replace(re, function (outter, braces, parens, brackets) { + var inner = braces || parens || brackets; + if (!inner) { return outter; } + return outter.split(inner).join(esc(inner)); + }); +} + +function esc(str) { + str = str.split('/').join('__SLASH__'); + str = str.split('.').join('__DOT__'); + return str; +} + +function unescape(str) { + str = str.split('__SLASH__').join('/'); + str = str.split('__DOT__').join('.'); + return str; +} diff --git a/tools/node_modules/parse-glob/package.json b/tools/node_modules/parse-glob/package.json new file mode 100644 index 00000000000000..d5e61f360b4338 --- /dev/null +++ b/tools/node_modules/parse-glob/package.json @@ -0,0 +1,115 @@ +{ + "_args": [ + [ + "parse-glob@^3.0.4", + "C:\\wamp\\www\\node\\tools\\node_modules\\micromatch" + ] + ], + "_from": "parse-glob@>=3.0.4 <4.0.0", + "_id": "parse-glob@3.0.4", + "_inCache": true, + "_location": "/parse-glob", + "_nodeVersion": "0.12.4", + "_npmUser": { + "email": "github@sellside.com", + "name": "jonschlinkert" + }, + "_npmVersion": "2.10.1", + "_phantomChildren": {}, + "_requested": { + "name": "parse-glob", + "raw": "parse-glob@^3.0.4", + "rawSpec": "^3.0.4", + "scope": null, + "spec": ">=3.0.4 <4.0.0", + "type": "range" + }, + "_requiredBy": [ + "/micromatch" + ], + "_resolved": "https://registry.npmjs.org/parse-glob/-/parse-glob-3.0.4.tgz", + "_shasum": "b2c376cfb11f35513badd173ef0bb6e3a388391c", + "_shrinkwrap": null, + "_spec": "parse-glob@^3.0.4", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\micromatch", + "author": { + "name": "Jon Schlinkert", + "url": "https://github.com/jonschlinkert" + }, + "bugs": { + "url": "https://github.com/jonschlinkert/parse-glob/issues" + }, + "dependencies": { + "glob-base": "^0.3.0", + "is-dotfile": "^1.0.0", + "is-extglob": "^1.0.0", + "is-glob": "^2.0.0" + }, + "description": "Parse a glob pattern into an object of tokens.", + "devDependencies": { + "browserify": "^9.0.3", + "lodash": "^3.3.1", + "mocha": "*" + }, + "directories": {}, + "dist": { + "shasum": "b2c376cfb11f35513badd173ef0bb6e3a388391c", + "tarball": "http://registry.npmjs.org/parse-glob/-/parse-glob-3.0.4.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "9bfccb63acdeb3b1ed62035b3adef0e5081d8fc6", + "homepage": "https://github.com/jonschlinkert/parse-glob", + "installable": true, + "keywords": [ + "bash", + "expand", + "expansion", + "expression", + "file", + "files", + "filter", + "find", + "glob", + "glob", + "globbing", + "globs", + "globstar", + "match", + "match", + "matcher", + "matches", + "matching", + "path", + "pattern", + "patterns", + "regex", + "regexp", + "regular", + "shell", + "wildcard" + ], + "license": "MIT", + "main": "index.js", + "maintainers": [ + { + "name": "jonschlinkert", + "email": "github@sellside.com" + } + ], + "name": "parse-glob", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git+https://github.com/jonschlinkert/parse-glob.git" + }, + "scripts": { + "prepublish": "browserify -o browser.js -e index.js", + "test": "mocha" + }, + "version": "3.0.4" +} diff --git a/tools/node_modules/path-is-absolute/index.js b/tools/node_modules/path-is-absolute/index.js new file mode 100644 index 00000000000000..19f103f908ac72 --- /dev/null +++ b/tools/node_modules/path-is-absolute/index.js @@ -0,0 +1,20 @@ +'use strict'; + +function posix(path) { + return path.charAt(0) === '/'; +}; + +function win32(path) { + // https://github.com/joyent/node/blob/b3fcc245fb25539909ef1d5eaa01dbf92e168633/lib/path.js#L56 + var splitDeviceRe = /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/; + var result = splitDeviceRe.exec(path); + var device = result[1] || ''; + var isUnc = !!device && device.charAt(1) !== ':'; + + // UNC paths are always absolute + return !!result[2] || isUnc; +}; + +module.exports = process.platform === 'win32' ? win32 : posix; +module.exports.posix = posix; +module.exports.win32 = win32; diff --git a/tools/node_modules/path-is-absolute/license b/tools/node_modules/path-is-absolute/license new file mode 100644 index 00000000000000..654d0bfe943437 --- /dev/null +++ b/tools/node_modules/path-is-absolute/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tools/node_modules/path-is-absolute/package.json b/tools/node_modules/path-is-absolute/package.json new file mode 100644 index 00000000000000..ff261b9f442223 --- /dev/null +++ b/tools/node_modules/path-is-absolute/package.json @@ -0,0 +1,97 @@ +{ + "_args": [ + [ + "path-is-absolute@^1.0.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\chokidar" + ] + ], + "_from": "path-is-absolute@>=1.0.0 <2.0.0", + "_id": "path-is-absolute@1.0.0", + "_inCache": true, + "_location": "/path-is-absolute", + "_nodeVersion": "0.12.0", + "_npmUser": { + "email": "sindresorhus@gmail.com", + "name": "sindresorhus" + }, + "_npmVersion": "2.5.1", + "_phantomChildren": {}, + "_requested": { + "name": "path-is-absolute", + "raw": "path-is-absolute@^1.0.0", + "rawSpec": "^1.0.0", + "scope": null, + "spec": ">=1.0.0 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/chokidar", + "/glob" + ], + "_resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.0.tgz", + "_shasum": "263dada66ab3f2fb10bf7f9d24dd8f3e570ef912", + "_shrinkwrap": null, + "_spec": "path-is-absolute@^1.0.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\chokidar", + "author": { + "email": "sindresorhus@gmail.com", + "name": "Sindre Sorhus", + "url": "sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/sindresorhus/path-is-absolute/issues" + }, + "dependencies": {}, + "description": "Node.js 0.12 path.isAbsolute() ponyfill", + "devDependencies": {}, + "directories": {}, + "dist": { + "shasum": "263dada66ab3f2fb10bf7f9d24dd8f3e570ef912", + "tarball": "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.0.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "7a76a0c9f2263192beedbe0a820e4d0baee5b7a1", + "homepage": "https://github.com/sindresorhus/path-is-absolute", + "installable": true, + "keywords": [ + "absolute", + "built-in", + "check", + "core", + "detect", + "dir", + "file", + "is", + "is-absolute", + "isabsolute", + "path", + "paths", + "polyfill", + "ponyfill", + "shim", + "util", + "utils" + ], + "license": "MIT", + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + } + ], + "name": "path-is-absolute", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "https://github.com/sindresorhus/path-is-absolute" + }, + "scripts": { + "test": "node test.js" + }, + "version": "1.0.0" +} diff --git a/tools/node_modules/path-is-absolute/readme.md b/tools/node_modules/path-is-absolute/readme.md new file mode 100644 index 00000000000000..cdf94f4309a27e --- /dev/null +++ b/tools/node_modules/path-is-absolute/readme.md @@ -0,0 +1,51 @@ +# path-is-absolute [![Build Status](https://travis-ci.org/sindresorhus/path-is-absolute.svg?branch=master)](https://travis-ci.org/sindresorhus/path-is-absolute) + +> Node.js 0.12 [`path.isAbsolute()`](http://nodejs.org/api/path.html#path_path_isabsolute_path) ponyfill + +> Ponyfill: A polyfill that doesn't overwrite the native method + + +## Install + +``` +$ npm install --save path-is-absolute +``` + + +## Usage + +```js +var pathIsAbsolute = require('path-is-absolute'); + +// Linux +pathIsAbsolute('/home/foo'); +//=> true + +// Windows +pathIsAbsolute('C:/Users/'); +//=> true + +// Any OS +pathIsAbsolute.posix('/home/foo'); +//=> true +``` + + +## API + +See the [`path.isAbsolute()` docs](http://nodejs.org/api/path.html#path_path_isabsolute_path). + +### pathIsAbsolute(path) + +### pathIsAbsolute.posix(path) + +The Posix specific version. + +### pathIsAbsolute.win32(path) + +The Windows specific version. + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/tools/node_modules/pify/index.js b/tools/node_modules/pify/index.js new file mode 100644 index 00000000000000..7c720ebee88727 --- /dev/null +++ b/tools/node_modules/pify/index.js @@ -0,0 +1,68 @@ +'use strict'; + +var processFn = function (fn, P, opts) { + return function () { + var that = this; + var args = new Array(arguments.length); + + for (var i = 0; i < arguments.length; i++) { + args[i] = arguments[i]; + } + + return new P(function (resolve, reject) { + args.push(function (err, result) { + if (err) { + reject(err); + } else if (opts.multiArgs) { + var results = new Array(arguments.length - 1); + + for (var i = 1; i < arguments.length; i++) { + results[i - 1] = arguments[i]; + } + + resolve(results); + } else { + resolve(result); + } + }); + + fn.apply(that, args); + }); + }; +}; + +var pify = module.exports = function (obj, P, opts) { + if (typeof P !== 'function') { + opts = P; + P = Promise; + } + + opts = opts || {}; + opts.exclude = opts.exclude || [/.+Sync$/]; + + var filter = function (key) { + var match = function (pattern) { + return typeof pattern === 'string' ? key === pattern : pattern.test(key); + }; + + return opts.include ? opts.include.some(match) : !opts.exclude.some(match); + }; + + var ret = typeof obj === 'function' ? function () { + if (opts.excludeMain) { + return obj.apply(this, arguments); + } + + return processFn(obj, P, opts).apply(this, arguments); + } : {}; + + return Object.keys(obj).reduce(function (ret, key) { + var x = obj[key]; + + ret[key] = typeof x === 'function' && filter(key) ? processFn(x, P, opts) : x; + + return ret; + }, ret); +}; + +pify.all = pify; diff --git a/tools/node_modules/pify/license b/tools/node_modules/pify/license new file mode 100644 index 00000000000000..654d0bfe943437 --- /dev/null +++ b/tools/node_modules/pify/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tools/node_modules/pify/package.json b/tools/node_modules/pify/package.json new file mode 100644 index 00000000000000..4c2bdecedd26da --- /dev/null +++ b/tools/node_modules/pify/package.json @@ -0,0 +1,103 @@ +{ + "_args": [ + [ + "pify@^2.0.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\globby" + ] + ], + "_from": "pify@>=2.0.0 <3.0.0", + "_id": "pify@2.3.0", + "_inCache": true, + "_location": "/pify", + "_nodeVersion": "4.2.1", + "_npmUser": { + "email": "sindresorhus@gmail.com", + "name": "sindresorhus" + }, + "_npmVersion": "2.14.7", + "_phantomChildren": {}, + "_requested": { + "name": "pify", + "raw": "pify@^2.0.0", + "rawSpec": "^2.0.0", + "scope": null, + "spec": ">=2.0.0 <3.0.0", + "type": "range" + }, + "_requiredBy": [ + "/globby" + ], + "_resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "_shasum": "ed141a6ac043a849ea588498e7dca8b15330e90c", + "_shrinkwrap": null, + "_spec": "pify@^2.0.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\globby", + "author": { + "email": "sindresorhus@gmail.com", + "name": "Sindre Sorhus", + "url": "sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/sindresorhus/pify/issues" + }, + "dependencies": {}, + "description": "Promisify a callback-style function", + "devDependencies": { + "ava": "*", + "pinkie-promise": "^1.0.0", + "v8-natives": "0.0.2", + "xo": "*" + }, + "directories": {}, + "dist": { + "shasum": "ed141a6ac043a849ea588498e7dca8b15330e90c", + "tarball": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "2dd0d8b880e4ebcc5cc33ae126b02647418e4440", + "homepage": "https://github.com/sindresorhus/pify", + "installable": true, + "keywords": [ + "async", + "bind", + "callback", + "cb", + "convert", + "denodeify", + "denodify", + "es2015", + "node", + "promise", + "promises", + "promisify", + "then", + "thenify", + "to", + "transform", + "wrap", + "wrapper" + ], + "license": "MIT", + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + } + ], + "name": "pify", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "https://github.com/sindresorhus/pify" + }, + "scripts": { + "optimization-test": "node --allow-natives-syntax optimization-test.js", + "test": "xo && ava && npm run optimization-test" + }, + "version": "2.3.0" +} diff --git a/tools/node_modules/pify/readme.md b/tools/node_modules/pify/readme.md new file mode 100644 index 00000000000000..c79ca8bf643927 --- /dev/null +++ b/tools/node_modules/pify/readme.md @@ -0,0 +1,119 @@ +# pify [![Build Status](https://travis-ci.org/sindresorhus/pify.svg?branch=master)](https://travis-ci.org/sindresorhus/pify) + +> Promisify a callback-style function + + +## Install + +``` +$ npm install --save pify +``` + + +## Usage + +```js +const fs = require('fs'); +const pify = require('pify'); + +// promisify a single function + +pify(fs.readFile)('package.json', 'utf8').then(data => { + console.log(JSON.parse(data).name); + //=> 'pify' +}); + +// or promisify all methods in a module + +pify(fs).readFile('package.json', 'utf8').then(data => { + console.log(JSON.parse(data).name); + //=> 'pify' +}); +``` + + +## API + +### pify(input, [promiseModule], [options]) + +Returns a promise wrapped version of the supplied function or module. + +#### input + +Type: `function`, `object` + +Callback-style function or module whose methods you want to promisify. + +#### promiseModule + +Type: `function` + +Custom promise module to use instead of the native one. + +Check out [`pinkie-promise`](https://github.com/floatdrop/pinkie-promise) if you need a tiny promise polyfill. + +#### options + +##### multiArgs + +Type: `boolean` +Default: `false` + +By default, the promisified function will only return the second argument from the callback, which works fine for most APIs. This option can be useful for modules like `request` that return multiple arguments. Turning this on will make it return an array of all arguments from the callback, excluding the error argument, instead of just the second argument. + +```js +const request = require('request'); +const pify = require('pify'); + +pify(request, {multiArgs: true})('https://sindresorhus.com').then(result => { + const [httpResponse, body] = result; +}); +``` + +##### include + +Type: `array` of (`string`|`regex`) + +Methods in a module to promisify. Remaining methods will be left untouched. + +##### exclude + +Type: `array` of (`string`|`regex`) +Default: `[/.+Sync$/]` + +Methods in a module **not** to promisify. Methods with names ending with `'Sync'` are excluded by default. + +##### excludeMain + +Type: `boolean` +Default: `false` + +By default, if given module is a function itself, this function will be promisified. Turn this option on if you want to promisify only methods of the module. + +```js +const pify = require('pify'); + +function fn() { + return true; +} + +fn.method = (data, callback) => { + setImmediate(() => { + callback(data, null); + }); +}; + +// promisify methods but not fn() +const promiseFn = pify(fn, {excludeMain: true}); + +if (promiseFn()) { + promiseFn.method('hi').then(data => { + console.log(data); + }); +} +``` + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/tools/node_modules/pinkie-promise/index.js b/tools/node_modules/pinkie-promise/index.js new file mode 100644 index 00000000000000..cc64b902c80b4b --- /dev/null +++ b/tools/node_modules/pinkie-promise/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = global.Promise || require('pinkie'); diff --git a/tools/node_modules/pinkie-promise/license b/tools/node_modules/pinkie-promise/license new file mode 100644 index 00000000000000..1aeb74fd25e171 --- /dev/null +++ b/tools/node_modules/pinkie-promise/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Vsevolod Strukchinsky (github.com/floatdrop) + +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. diff --git a/tools/node_modules/pinkie-promise/package.json b/tools/node_modules/pinkie-promise/package.json new file mode 100644 index 00000000000000..41b68e4a88733f --- /dev/null +++ b/tools/node_modules/pinkie-promise/package.json @@ -0,0 +1,89 @@ +{ + "_args": [ + [ + "pinkie-promise@^2.0.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\globby" + ] + ], + "_from": "pinkie-promise@>=2.0.0 <3.0.0", + "_id": "pinkie-promise@2.0.0", + "_inCache": true, + "_location": "/pinkie-promise", + "_nodeVersion": "4.2.0", + "_npmUser": { + "email": "floatdrop@gmail.com", + "name": "floatdrop" + }, + "_npmVersion": "2.14.7", + "_phantomChildren": {}, + "_requested": { + "name": "pinkie-promise", + "raw": "pinkie-promise@^2.0.0", + "rawSpec": "^2.0.0", + "scope": null, + "spec": ">=2.0.0 <3.0.0", + "type": "range" + }, + "_requiredBy": [ + "/globby" + ], + "_resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.0.tgz", + "_shasum": "4c83538de1f6e660c29e0a13446844f7a7e88259", + "_shrinkwrap": null, + "_spec": "pinkie-promise@^2.0.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\globby", + "author": { + "email": "floatdrop@gmail.com", + "name": "Vsevolod Strukchinsky", + "url": "github.com/floatdrop" + }, + "bugs": { + "url": "https://github.com/floatdrop/pinkie-promise/issues" + }, + "dependencies": { + "pinkie": "^2.0.0" + }, + "description": "ES2015 Promise ponyfill", + "devDependencies": { + "mocha": "*" + }, + "directories": {}, + "dist": { + "shasum": "4c83538de1f6e660c29e0a13446844f7a7e88259", + "tarball": "http://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.0.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "f90fcae9838bcae7ae1ae4ebc9b29f11e5db4980", + "homepage": "https://github.com/floatdrop/pinkie-promise", + "installable": true, + "keywords": [ + "es2015", + "es6", + "polyfill", + "ponyfill", + "promise", + "promises" + ], + "license": "MIT", + "maintainers": [ + { + "name": "floatdrop", + "email": "floatdrop@gmail.com" + } + ], + "name": "pinkie-promise", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "https://github.com/floatdrop/pinkie-promise" + }, + "scripts": { + "test": "mocha" + }, + "version": "2.0.0" +} diff --git a/tools/node_modules/pinkie-promise/readme.md b/tools/node_modules/pinkie-promise/readme.md new file mode 100644 index 00000000000000..78477f4297d677 --- /dev/null +++ b/tools/node_modules/pinkie-promise/readme.md @@ -0,0 +1,28 @@ +# pinkie-promise [![Build Status](https://travis-ci.org/floatdrop/pinkie-promise.svg?branch=master)](https://travis-ci.org/floatdrop/pinkie-promise) + +> [ES2015 Promise](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-promise-objects) ponyfill + +Module exports global Promise object (if available) or [`pinkie`](http://github.com/floatdrop/pinkie) Promise polyfill. + +## Install + +``` +$ npm install --save pinkie-promise +``` + +## Usage + +```js +var Promise = require('pinkie-promise'); + +new Promise(function (resolve) { resolve('unicorns'); }); +//=> Promise { 'unicorns' } +``` + +## Related + +- [pify](https://github.com/sindresorhus/pify) - Promisify a callback-style function + +## License + +MIT © [Vsevolod Strukchinsky](http://github.com/floatdrop) diff --git a/tools/node_modules/pinkie/index.js b/tools/node_modules/pinkie/index.js new file mode 100644 index 00000000000000..14ce1bfe3d4918 --- /dev/null +++ b/tools/node_modules/pinkie/index.js @@ -0,0 +1,292 @@ +'use strict'; + +var PENDING = 'pending'; +var SETTLED = 'settled'; +var FULFILLED = 'fulfilled'; +var REJECTED = 'rejected'; +var NOOP = function () {}; +var isNode = typeof global !== 'undefined' && typeof global.process !== 'undefined' && typeof global.process.emit === 'function'; + +var asyncSetTimer = typeof setImmediate === 'undefined' ? setTimeout : setImmediate; +var asyncQueue = []; +var asyncTimer; + +function asyncFlush() { + // run promise callbacks + for (var i = 0; i < asyncQueue.length; i++) { + asyncQueue[i][0](asyncQueue[i][1]); + } + + // reset async asyncQueue + asyncQueue = []; + asyncTimer = false; +} + +function asyncCall(callback, arg) { + asyncQueue.push([callback, arg]); + + if (!asyncTimer) { + asyncTimer = true; + asyncSetTimer(asyncFlush, 0); + } +} + +function invokeResolver(resolver, promise) { + function resolvePromise(value) { + resolve(promise, value); + } + + function rejectPromise(reason) { + reject(promise, reason); + } + + try { + resolver(resolvePromise, rejectPromise); + } catch (e) { + rejectPromise(e); + } +} + +function invokeCallback(subscriber) { + var owner = subscriber.owner; + var settled = owner._state; + var value = owner._data; + var callback = subscriber[settled]; + var promise = subscriber.then; + + if (typeof callback === 'function') { + settled = FULFILLED; + try { + value = callback(value); + } catch (e) { + reject(promise, e); + } + } + + if (!handleThenable(promise, value)) { + if (settled === FULFILLED) { + resolve(promise, value); + } + + if (settled === REJECTED) { + reject(promise, value); + } + } +} + +function handleThenable(promise, value) { + var resolved; + + try { + if (promise === value) { + throw new TypeError('A promises callback cannot return that same promise.'); + } + + if (value && (typeof value === 'function' || typeof value === 'object')) { + // then should be retrieved only once + var then = value.then; + + if (typeof then === 'function') { + then.call(value, function (val) { + if (!resolved) { + resolved = true; + + if (value === val) { + fulfill(promise, val); + } else { + resolve(promise, val); + } + } + }, function (reason) { + if (!resolved) { + resolved = true; + + reject(promise, reason); + } + }); + + return true; + } + } + } catch (e) { + if (!resolved) { + reject(promise, e); + } + + return true; + } + + return false; +} + +function resolve(promise, value) { + if (promise === value || !handleThenable(promise, value)) { + fulfill(promise, value); + } +} + +function fulfill(promise, value) { + if (promise._state === PENDING) { + promise._state = SETTLED; + promise._data = value; + + asyncCall(publishFulfillment, promise); + } +} + +function reject(promise, reason) { + if (promise._state === PENDING) { + promise._state = SETTLED; + promise._data = reason; + + asyncCall(publishRejection, promise); + } +} + +function publish(promise) { + promise._then = promise._then.forEach(invokeCallback); +} + +function publishFulfillment(promise) { + promise._state = FULFILLED; + publish(promise); +} + +function publishRejection(promise) { + promise._state = REJECTED; + publish(promise); + if (!promise._handled && isNode) { + global.process.emit('unhandledRejection', promise._data, promise); + } +} + +function notifyRejectionHandled(promise) { + global.process.emit('rejectionHandled', promise); +} + +/** + * @class + */ +function Promise(resolver) { + if (typeof resolver !== 'function') { + throw new TypeError('Promise resolver ' + resolver + ' is not a function'); + } + + if (this instanceof Promise === false) { + throw new TypeError('Failed to construct \'Promise\': Please use the \'new\' operator, this object constructor cannot be called as a function.'); + } + + this._then = []; + + invokeResolver(resolver, this); +} + +Promise.prototype = { + constructor: Promise, + + _state: PENDING, + _then: null, + _data: undefined, + _handled: false, + + then: function (onFulfillment, onRejection) { + var subscriber = { + owner: this, + then: new this.constructor(NOOP), + fulfilled: onFulfillment, + rejected: onRejection + }; + + if ((onRejection || onFulfillment) && !this._handled) { + this._handled = true; + if (this._state === REJECTED && isNode) { + asyncCall(notifyRejectionHandled, this); + } + } + + if (this._state === FULFILLED || this._state === REJECTED) { + // already resolved, call callback async + asyncCall(invokeCallback, subscriber); + } else { + // subscribe + this._then.push(subscriber); + } + + return subscriber.then; + }, + + catch: function (onRejection) { + return this.then(null, onRejection); + } +}; + +Promise.all = function (promises) { + if (!Array.isArray(promises)) { + throw new TypeError('You must pass an array to Promise.all().'); + } + + return new Promise(function (resolve, reject) { + var results = []; + var remaining = 0; + + function resolver(index) { + remaining++; + return function (value) { + results[index] = value; + if (!--remaining) { + resolve(results); + } + }; + } + + for (var i = 0, promise; i < promises.length; i++) { + promise = promises[i]; + + if (promise && typeof promise.then === 'function') { + promise.then(resolver(i), reject); + } else { + results[i] = promise; + } + } + + if (!remaining) { + resolve(results); + } + }); +}; + +Promise.race = function (promises) { + if (!Array.isArray(promises)) { + throw new TypeError('You must pass an array to Promise.race().'); + } + + return new Promise(function (resolve, reject) { + for (var i = 0, promise; i < promises.length; i++) { + promise = promises[i]; + + if (promise && typeof promise.then === 'function') { + promise.then(resolve, reject); + } else { + resolve(promise); + } + } + }); +}; + +Promise.resolve = function (value) { + if (value && typeof value === 'object' && value.constructor === Promise) { + return value; + } + + return new Promise(function (resolve) { + resolve(value); + }); +}; + +Promise.reject = function (reason) { + return new Promise(function (resolve, reject) { + reject(reason); + }); +}; + +module.exports = Promise; diff --git a/tools/node_modules/pinkie/license b/tools/node_modules/pinkie/license new file mode 100644 index 00000000000000..1aeb74fd25e171 --- /dev/null +++ b/tools/node_modules/pinkie/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Vsevolod Strukchinsky (github.com/floatdrop) + +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. diff --git a/tools/node_modules/pinkie/package.json b/tools/node_modules/pinkie/package.json new file mode 100644 index 00000000000000..e81eb46291647d --- /dev/null +++ b/tools/node_modules/pinkie/package.json @@ -0,0 +1,91 @@ +{ + "_args": [ + [ + "pinkie@^2.0.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\pinkie-promise" + ] + ], + "_from": "pinkie@>=2.0.0 <3.0.0", + "_id": "pinkie@2.0.4", + "_inCache": true, + "_location": "/pinkie", + "_nodeVersion": "4.2.4", + "_npmUser": { + "email": "floatdrop@gmail.com", + "name": "floatdrop" + }, + "_npmVersion": "2.14.12", + "_phantomChildren": {}, + "_requested": { + "name": "pinkie", + "raw": "pinkie@^2.0.0", + "rawSpec": "^2.0.0", + "scope": null, + "spec": ">=2.0.0 <3.0.0", + "type": "range" + }, + "_requiredBy": [ + "/pinkie-promise" + ], + "_resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", + "_shasum": "72556b80cfa0d48a974e80e77248e80ed4f7f870", + "_shrinkwrap": null, + "_spec": "pinkie@^2.0.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\pinkie-promise", + "author": { + "email": "floatdrop@gmail.com", + "name": "Vsevolod Strukchinsky", + "url": "github.com/floatdrop" + }, + "bugs": { + "url": "https://github.com/floatdrop/pinkie/issues" + }, + "dependencies": {}, + "description": "Itty bitty little widdle twinkie pinkie ES2015 Promise implementation", + "devDependencies": { + "core-assert": "^0.1.1", + "coveralls": "^2.11.4", + "mocha": "*", + "nyc": "^3.2.2", + "promises-aplus-tests": "*", + "xo": "^0.10.1" + }, + "directories": {}, + "dist": { + "shasum": "72556b80cfa0d48a974e80e77248e80ed4f7f870", + "tarball": "http://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "8d4a92447a5c62bff9f89756caeb4c9c8770579b", + "homepage": "https://github.com/floatdrop/pinkie", + "installable": true, + "keywords": [ + "es2015", + "es6", + "promise", + "promises" + ], + "license": "MIT", + "maintainers": [ + { + "name": "floatdrop", + "email": "floatdrop@gmail.com" + } + ], + "name": "pinkie", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "https://github.com/floatdrop/pinkie" + }, + "scripts": { + "coverage": "nyc report --reporter=text-lcov | coveralls", + "test": "xo && nyc mocha" + }, + "version": "2.0.4" +} diff --git a/tools/node_modules/pinkie/readme.md b/tools/node_modules/pinkie/readme.md new file mode 100644 index 00000000000000..1565f95889661b --- /dev/null +++ b/tools/node_modules/pinkie/readme.md @@ -0,0 +1,83 @@ +

    +
    + pinkie +
    +
    +

    + +> Itty bitty little widdle twinkie pinkie [ES2015 Promise](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-promise-objects) implementation + +[![Build Status](https://travis-ci.org/floatdrop/pinkie.svg?branch=master)](https://travis-ci.org/floatdrop/pinkie) [![Coverage Status](https://coveralls.io/repos/floatdrop/pinkie/badge.svg?branch=master&service=github)](https://coveralls.io/github/floatdrop/pinkie?branch=master) + +There are [tons of Promise implementations](https://github.com/promises-aplus/promises-spec/blob/master/implementations.md#standalone) out there, but all of them focus on browser compatibility and are often bloated with functionality. + +This module is an exact Promise specification polyfill (like [native-promise-only](https://github.com/getify/native-promise-only)), but in Node.js land (it should be browserify-able though). + + +## Install + +``` +$ npm install --save pinkie +``` + + +## Usage + +```js +var fs = require('fs'); +var Promise = require('pinkie'); + +new Promise(function (resolve, reject) { + fs.readFile('foo.json', 'utf8', function (err, data) { + if (err) { + reject(err); + return; + } + + resolve(data); + }); +}); +//=> Promise +``` + + +### API + +`pinkie` exports bare [ES2015 Promise](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-promise-objects) implementation and polyfills [Node.js rejection events](https://nodejs.org/api/process.html#process_event_unhandledrejection). In case you forgot: + +#### new Promise(executor) + +Returns new instance of `Promise`. + +##### executor + +*Required* +Type: `function` + +Function with two arguments `resolve` and `reject`. The first argument fulfills the promise, the second argument rejects it. + +#### pinkie.all(promises) + +Returns a promise that resolves when all of the promises in the `promises` Array argument have resolved. + +#### pinkie.race(promises) + +Returns a promise that resolves or rejects as soon as one of the promises in the `promises` Array resolves or rejects, with the value or reason from that promise. + +#### pinkie.reject(reason) + +Returns a Promise object that is rejected with the given `reason`. + +#### pinkie.resolve(value) + +Returns a Promise object that is resolved with the given `value`. If the `value` is a thenable (i.e. has a then method), the returned promise will "follow" that thenable, adopting its eventual state; otherwise the returned promise will be fulfilled with the `value`. + + +## Related + +- [pinkie-promise](https://github.com/floatdrop/pinkie-promise) - Returns the native Promise or this module + + +## License + +MIT © [Vsevolod Strukchinsky](http://github.com/floatdrop) diff --git a/tools/node_modules/plur/index.js b/tools/node_modules/plur/index.js new file mode 100644 index 00000000000000..ed3f9b06b94ae6 --- /dev/null +++ b/tools/node_modules/plur/index.js @@ -0,0 +1,20 @@ +'use strict'; +var irregularPlurals = require('irregular-plurals'); + +module.exports = function (str, plural, count) { + if (typeof plural === 'number') { + count = plural; + } + + if (str in irregularPlurals) { + plural = irregularPlurals[str]; + } else if (typeof plural !== 'string') { + plural = (str.replace(/(?:s|x|z|ch|sh)$/i, '$&e').replace(/([^aeiou])y$/i, '$1ie') + 's') + .replace(/i?e?s$/i, function (m) { + var isTailLowerCase = str.slice(-1) === str.slice(-1).toLowerCase(); + return isTailLowerCase ? m.toLowerCase() : m.toUpperCase(); + }); + } + + return count === 1 ? str : plural; +}; diff --git a/tools/node_modules/plur/license b/tools/node_modules/plur/license new file mode 100644 index 00000000000000..654d0bfe943437 --- /dev/null +++ b/tools/node_modules/plur/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tools/node_modules/plur/package.json b/tools/node_modules/plur/package.json new file mode 100644 index 00000000000000..48621519fb095d --- /dev/null +++ b/tools/node_modules/plur/package.json @@ -0,0 +1,96 @@ +{ + "_args": [ + [ + "plur@^2.0.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\vfile-reporter" + ] + ], + "_from": "plur@>=2.0.0 <3.0.0", + "_id": "plur@2.1.2", + "_inCache": true, + "_location": "/plur", + "_nodeVersion": "4.2.1", + "_npmUser": { + "email": "sindresorhus@gmail.com", + "name": "sindresorhus" + }, + "_npmVersion": "2.14.7", + "_phantomChildren": {}, + "_requested": { + "name": "plur", + "raw": "plur@^2.0.0", + "rawSpec": "^2.0.0", + "scope": null, + "spec": ">=2.0.0 <3.0.0", + "type": "range" + }, + "_requiredBy": [ + "/vfile-reporter" + ], + "_resolved": "https://registry.npmjs.org/plur/-/plur-2.1.2.tgz", + "_shasum": "7482452c1a0f508e3e344eaec312c91c29dc655a", + "_shrinkwrap": null, + "_spec": "plur@^2.0.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\vfile-reporter", + "author": { + "email": "sindresorhus@gmail.com", + "name": "Sindre Sorhus", + "url": "sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/sindresorhus/plur/issues" + }, + "dependencies": { + "irregular-plurals": "^1.0.0" + }, + "description": "Pluralize a word", + "devDependencies": { + "ava": "*", + "xo": "*" + }, + "directories": {}, + "dist": { + "shasum": "7482452c1a0f508e3e344eaec312c91c29dc655a", + "tarball": "http://registry.npmjs.org/plur/-/plur-2.1.2.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "d896377c1ccd97ac612c491e4926176b5f92d8a6", + "homepage": "https://github.com/sindresorhus/plur", + "installable": true, + "keywords": [ + "count", + "irregular", + "noun", + "nouns", + "plur", + "plural", + "pluralize", + "plurals", + "singular", + "str", + "string", + "word" + ], + "license": "MIT", + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + } + ], + "name": "plur", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "https://github.com/sindresorhus/plur" + }, + "scripts": { + "test": "xo && ava" + }, + "version": "2.1.2" +} diff --git a/tools/node_modules/plur/readme.md b/tools/node_modules/plur/readme.md new file mode 100644 index 00000000000000..40103d81a82700 --- /dev/null +++ b/tools/node_modules/plur/readme.md @@ -0,0 +1,67 @@ +# plur [![Build Status](https://travis-ci.org/sindresorhus/plur.svg?branch=master)](https://travis-ci.org/sindresorhus/plur) + +> Pluralize a word + + +## Install + +``` +$ npm install --save plur +``` + + +## Usage + +```js +const plur = require('plur'); + +plur('unicorn', 4); +//=> 'unicorns' + +plur('puppy', 2); +//=> 'puppies' + +plur('box', 2); +//=> 'boxes' + +plur('cactus', 2); +//=> 'cacti' +``` + + +## API + +### plur(word, [plural], count) + +#### word + +Type: `string` + +Word to pluralize. + +#### plural + +Type: `string` +Default: + +- Irregular nouns will use this [list](https://github.com/sindresorhus/irregular-plurals/blob/master/irregular-plurals.json). +- Words ending in *s*, *x*, *z*, *ch*, *sh* will be pluralized with *-es* (eg. *foxes*). +- Words ending in *y* that are preceded by a consonant will be pluralized by replacing *y* with *-ies* (eg. *puppies*). +- All other words will have "s" added to the end (eg. *days*). + +Pluralized word. + +The plural suffix will match the case of the last letter in the word. + +This option is only for extreme edge-cases. You probably won't need it. + +#### count + +Type: `number` + +Count to determine whether to use singular or plural. + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/tools/node_modules/preserve/.gitattributes b/tools/node_modules/preserve/.gitattributes new file mode 100644 index 00000000000000..759c2c5afdcbf6 --- /dev/null +++ b/tools/node_modules/preserve/.gitattributes @@ -0,0 +1,14 @@ +# Enforce Unix newlines +*.* text eol=lf +*.css text eol=lf +*.html text eol=lf +*.js text eol=lf +*.json text eol=lf +*.less text eol=lf +*.md text eol=lf +*.yml text eol=lf + +*.jpg binary +*.gif binary +*.png binary +*.jpeg binary \ No newline at end of file diff --git a/tools/node_modules/preserve/.jshintrc b/tools/node_modules/preserve/.jshintrc new file mode 100644 index 00000000000000..e72045d2b3dbc6 --- /dev/null +++ b/tools/node_modules/preserve/.jshintrc @@ -0,0 +1,24 @@ +{ + "asi": false, + "boss": true, + "curly": true, + "eqeqeq": true, + "eqnull": true, + "esnext": true, + "immed": true, + "latedef": true, + "laxcomma": false, + "newcap": true, + "noarg": true, + "node": true, + "sub": true, + "undef": true, + "unused": true, + "globals": { + "define": true, + "before": true, + "after": true, + "describe": true, + "it": true + } +} \ No newline at end of file diff --git a/tools/node_modules/preserve/.npmignore b/tools/node_modules/preserve/.npmignore new file mode 100644 index 00000000000000..1a2e47f0da042a --- /dev/null +++ b/tools/node_modules/preserve/.npmignore @@ -0,0 +1,53 @@ +# Numerous always-ignore extensions +*.csv +*.dat +*.diff +*.err +*.gz +*.log +*.orig +*.out +*.pid +*.rar +*.rej +*.seed +*.swo +*.swp +*.vi +*.yo-rc.json +*.zip +*~ +.ruby-version +lib-cov +npm-debug.log + +# Always-ignore dirs +/bower_components/ +/node_modules/ +/temp/ +/tmp/ +/vendor/ +_gh_pages + +# OS or Editor folders +*.esproj +*.komodoproject +.komodotools +*.sublime-* +._* +.cache +.DS_Store +.idea +.project +.settings +.tmproj +nbproject +Thumbs.db + +# grunt-html-validation +validation-status.json +validation-report.json + +# misc +TODO.md +benchmark \ No newline at end of file diff --git a/tools/node_modules/preserve/.travis.yml b/tools/node_modules/preserve/.travis.yml new file mode 100644 index 00000000000000..ff74a054e07e66 --- /dev/null +++ b/tools/node_modules/preserve/.travis.yml @@ -0,0 +1,3 @@ +language: node_js +node_js: + - '0.10' \ No newline at end of file diff --git a/tools/node_modules/preserve/.verb.md b/tools/node_modules/preserve/.verb.md new file mode 100644 index 00000000000000..72344a9eb30cae --- /dev/null +++ b/tools/node_modules/preserve/.verb.md @@ -0,0 +1,59 @@ +# {%= name %} {%= badge("fury") %} + +> {%= description %} + +Useful for protecting tokens, like templates in HTML, from being mutated when the string is transformed in some way, like from a formatter/beautifier. + +**Example without `preserve`** + +Let's say you want to use [js-beautify] on a string of html with Lo-Dash/Underscore templates, such as: `
    • <%= name %>
    `: + +js-beautify will render the template unusable (and apply incorrect formatting because of the unfamiliar syntax from the Lo-Dash template): + +```html +
      +
    • + <%=n ame %> +
    • +
    +``` + +**Example with `preserve`** + +Correct. + +```html +
      +
    • <%= name %>
    • +
    +``` + +For the record, this is just a random example, I've had very few issues with js-beautify in general. But with or without js-beautify, this kind of token mangling does happen sometimes when you use formatters, beautifiers or similar tools. + +## Install +{%= include("install-npm", {save: true}) %} + +## Run tests + +```bash +npm test +``` + +## API +{%= apidocs("index.js") %} + +## Contributing +Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue]({%= bugs.url %}) + +## Author +{%= include("author") %} + +## License +{%= copyright() %} +{%= license() %} + +*** + +{%= include("footer") %} + +[js-beautify]: https://github.com/beautify-web/js-beautify \ No newline at end of file diff --git a/tools/node_modules/preserve/LICENSE b/tools/node_modules/preserve/LICENSE new file mode 100644 index 00000000000000..5a9956a75dd7f2 --- /dev/null +++ b/tools/node_modules/preserve/LICENSE @@ -0,0 +1,24 @@ +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. diff --git a/tools/node_modules/preserve/README.md b/tools/node_modules/preserve/README.md new file mode 100644 index 00000000000000..75000b93349382 --- /dev/null +++ b/tools/node_modules/preserve/README.md @@ -0,0 +1,90 @@ +# preserve [![NPM version](https://badge.fury.io/js/preserve.svg)](http://badge.fury.io/js/preserve) + +> Temporarily substitute tokens in the given `string` with placeholders, then put them back after transforming the string. + +Useful for protecting tokens, like templates in HTML, from being mutated when the string is transformed in some way, like from a formatter/beautifier. + +**Example without `preserve`** + +Let's say you want to use [js-beautify] on a string of html with Lo-Dash/Underscore templates, such as: `
    • <%= name %>
    `: + +js-beautify will render the template unusable (and apply incorrect formatting because of the unfamiliar syntax from the Lo-Dash template): + +```html +
      +
    • + <%=n ame %> +
    • +
    +``` + +**Example with `preserve`** + +Correct. + +```html +
      +
    • <%= name %>
    • +
    +``` + +For the record, this is just a random example, I've had very few issues with js-beautify in general. But with or without js-beautify, this kind of token mangling does happen sometimes when you use formatters, beautifiers or similar tools. + +## Install +## Install with [npm](npmjs.org) + +```bash +npm i preserve --save +``` + +## Run tests + +```bash +npm test +``` + +## API +### [.before](index.js#L23) + +Replace tokens in `str` with a temporary, heuristic placeholder. + +* `str` **{String}** +* `returns` **{String}**: String with placeholders. + +```js +tokens.before('{a\\,b}'); +//=> '{__ID1__}' +``` + +### [.after](index.js#L44) + +Replace placeholders in `str` with original tokens. + +* `str` **{String}**: String with placeholders +* `returns` **{String}** `str`: String with original tokens. + +```js +tokens.after('{__ID1__}'); +//=> '{a\\,b}' +``` + + +## Contributing +Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/preserve/issues) + +## Author + +**Jon Schlinkert** + ++ [github/jonschlinkert](https://github.com/jonschlinkert) ++ [twitter/jonschlinkert](http://twitter.com/jonschlinkert) + +## License +Copyright (c) 2015-2015, Jon Schlinkert. +Released under the MIT license + +*** + +_This file was generated by [verb](https://github.com/assemble/verb) on January 10, 2015._ + +[js-beautify]: https://github.com/beautify-web/js-beautify \ No newline at end of file diff --git a/tools/node_modules/preserve/index.js b/tools/node_modules/preserve/index.js new file mode 100644 index 00000000000000..a6c5d481d454af --- /dev/null +++ b/tools/node_modules/preserve/index.js @@ -0,0 +1,54 @@ +/*! + * preserve + * + * Copyright (c) 2014-2015, Jon Schlinkert. + * Licensed under the MIT license. + */ + +'use strict'; + +/** + * Replace tokens in `str` with a temporary, heuristic placeholder. + * + * ```js + * tokens.before('{a\\,b}'); + * //=> '{__ID1__}' + * ``` + * + * @param {String} `str` + * @return {String} String with placeholders. + * @api public + */ + +exports.before = function before(str, re) { + return str.replace(re, function (match) { + var id = randomize(); + cache[id] = match; + return '__ID' + id + '__'; + }); +}; + +/** + * Replace placeholders in `str` with original tokens. + * + * ```js + * tokens.after('{__ID1__}'); + * //=> '{a\\,b}' + * ``` + * + * @param {String} `str` String with placeholders + * @return {String} `str` String with original tokens. + * @api public + */ + +exports.after = function after(str) { + return str.replace(/__ID(.{5})__/g, function (_, id) { + return cache[id]; + }); +}; + +function randomize() { + return Math.random().toString().slice(2, 7); +} + +var cache = {}; \ No newline at end of file diff --git a/tools/node_modules/preserve/package.json b/tools/node_modules/preserve/package.json new file mode 100644 index 00000000000000..219d7f30c953ef --- /dev/null +++ b/tools/node_modules/preserve/package.json @@ -0,0 +1,95 @@ +{ + "_args": [ + [ + "preserve@^0.2.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\braces" + ] + ], + "_from": "preserve@>=0.2.0 <0.3.0", + "_id": "preserve@0.2.0", + "_inCache": true, + "_location": "/preserve", + "_npmUser": { + "email": "github@sellside.com", + "name": "jonschlinkert" + }, + "_npmVersion": "1.4.23", + "_phantomChildren": {}, + "_requested": { + "name": "preserve", + "raw": "preserve@^0.2.0", + "rawSpec": "^0.2.0", + "scope": null, + "spec": ">=0.2.0 <0.3.0", + "type": "range" + }, + "_requiredBy": [ + "/braces" + ], + "_resolved": "https://registry.npmjs.org/preserve/-/preserve-0.2.0.tgz", + "_shasum": "815ed1f6ebc65926f865b310c0713bcb3315ce4b", + "_shrinkwrap": null, + "_spec": "preserve@^0.2.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\braces", + "author": { + "name": "Jon Schlinkert", + "url": "https://github.com/jonschlinkert" + }, + "bugs": { + "url": "https://github.com/jonschlinkert/preserve/issues" + }, + "dependencies": {}, + "description": "Temporarily substitute tokens in the given `string` with placeholders, then put them back after transforming the string.", + "devDependencies": { + "benchmarked": "^0.1.3", + "chalk": "^0.5.1", + "js-beautify": "^1.5.4", + "mocha": "*", + "should": "*" + }, + "directories": {}, + "dist": { + "shasum": "815ed1f6ebc65926f865b310c0713bcb3315ce4b", + "tarball": "http://registry.npmjs.org/preserve/-/preserve-0.2.0.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "gitHead": "1bf405d35e4aea06a2ee83db2d34dc54abc0a1f9", + "homepage": "https://github.com/jonschlinkert/preserve", + "installable": true, + "keywords": [ + "escape", + "format", + "placeholder", + "placeholders", + "prettify", + "regex", + "replace", + "template", + "templates", + "token", + "tokens" + ], + "license": { + "type": "MIT", + "url": "https://github.com/jonschlinkert/preserve/blob/master/LICENSE-MIT" + }, + "main": "index.js", + "maintainers": [ + { + "name": "jonschlinkert", + "email": "github@sellside.com" + } + ], + "name": "preserve", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git://github.com/jonschlinkert/preserve.git" + }, + "scripts": { + "test": "mocha -R spec" + }, + "version": "0.2.0" +} diff --git a/tools/node_modules/preserve/test.js b/tools/node_modules/preserve/test.js new file mode 100644 index 00000000000000..9bf174f121cff5 --- /dev/null +++ b/tools/node_modules/preserve/test.js @@ -0,0 +1,48 @@ +/*! + * preserve + * + * Copyright (c) 2014-2015, Jon Schlinkert. + * Licensed under the MIT License + */ + +'use strict'; + +var should = require('should'); +var tokens = require('./'); + +var re = /<%=\s*[^>]+%>/g; +var pretty = function(str) { + return require('js-beautify').html(str, { + indent_char: ' ', + indent_size: 2, + }); +}; + +describe('preserve tokens', function () { + var testRe = /__ID.{5}__\n__ID.{5}__\n__ID.{5}__/; + var re = /<%=\s*[^>]+%>/g; + + it('should (e.g. shouldn\'t, but will) mangle tokens in the given string', function () { + var html = pretty('
    • <%= name %>
    '); + html.should.equal('
      \n
    • \n <%=n ame %>\n
    • \n
    '); + }); + + it('should preserve tokens in the given string', function () { + var html = tokens.after(pretty(tokens.before('
    • <%= name %>
    ', re))); + html.should.equal('
      \n
    • <%= name %>
    • \n
    '); + }); + + describe('.before()', function () { + it('should replace matches with placeholder tokens:', function () { + tokens.before('<%= a %>\n<%= b %>\n<%= c %>', re).should.match(testRe); + }); + }); + + describe('tokens.after()', function () { + it('should replace placeholder tokens with original values:', function () { + var before = tokens.before('<%= a %>\n<%= b %>\n<%= c %>', re); + before.should.match(testRe); + tokens.after(before).should.equal('<%= a %>\n<%= b %>\n<%= c %>'); + }); + }); +}); diff --git a/tools/node_modules/process-nextick-args/.travis.yml b/tools/node_modules/process-nextick-args/.travis.yml new file mode 100644 index 00000000000000..36201b10017a5e --- /dev/null +++ b/tools/node_modules/process-nextick-args/.travis.yml @@ -0,0 +1,12 @@ +language: node_js +node_js: + - "0.8" + - "0.10" + - "0.11" + - "0.12" + - "1.7.1" + - 1 + - 2 + - 3 + - 4 + - 5 diff --git a/tools/node_modules/process-nextick-args/index.js b/tools/node_modules/process-nextick-args/index.js new file mode 100644 index 00000000000000..571c276783c779 --- /dev/null +++ b/tools/node_modules/process-nextick-args/index.js @@ -0,0 +1,20 @@ +'use strict'; + +if (!process.version || + process.version.indexOf('v0.') === 0 || + process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) { + module.exports = nextTick; +} else { + module.exports = process.nextTick; +} + +function nextTick(fn) { + var args = new Array(arguments.length - 1); + var i = 0; + while (i < args.length) { + args[i++] = arguments[i]; + } + process.nextTick(function afterTick() { + fn.apply(null, args); + }); +} diff --git a/tools/node_modules/process-nextick-args/license.md b/tools/node_modules/process-nextick-args/license.md new file mode 100644 index 00000000000000..c67e3532b54245 --- /dev/null +++ b/tools/node_modules/process-nextick-args/license.md @@ -0,0 +1,19 @@ +# Copyright (c) 2015 Calvin Metcalf + +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.** diff --git a/tools/node_modules/process-nextick-args/package.json b/tools/node_modules/process-nextick-args/package.json new file mode 100644 index 00000000000000..8656ad31e8c0fe --- /dev/null +++ b/tools/node_modules/process-nextick-args/package.json @@ -0,0 +1,70 @@ +{ + "_args": [ + [ + "process-nextick-args@~1.0.6", + "C:\\wamp\\www\\node\\tools\\node_modules\\readable-stream" + ] + ], + "_from": "process-nextick-args@>=1.0.6 <1.1.0", + "_id": "process-nextick-args@1.0.6", + "_inCache": true, + "_location": "/process-nextick-args", + "_nodeVersion": "4.1.1", + "_npmUser": { + "email": "calvin.metcalf@gmail.com", + "name": "cwmma" + }, + "_npmVersion": "2.14.4", + "_phantomChildren": {}, + "_requested": { + "name": "process-nextick-args", + "raw": "process-nextick-args@~1.0.6", + "rawSpec": "~1.0.6", + "scope": null, + "spec": ">=1.0.6 <1.1.0", + "type": "range" + }, + "_requiredBy": [ + "/readable-stream" + ], + "_resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.6.tgz", + "_shasum": "0f96b001cea90b12592ce566edb97ec11e69bd05", + "_shrinkwrap": null, + "_spec": "process-nextick-args@~1.0.6", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\readable-stream", + "author": "", + "bugs": { + "url": "https://github.com/calvinmetcalf/process-nextick-args/issues" + }, + "dependencies": {}, + "description": "process.nextTick but always with args", + "devDependencies": { + "tap": "~0.2.6" + }, + "directories": {}, + "dist": { + "shasum": "0f96b001cea90b12592ce566edb97ec11e69bd05", + "tarball": "http://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.6.tgz" + }, + "gitHead": "e85787b05a8c3c1adb714f332d822e9162699c78", + "homepage": "https://github.com/calvinmetcalf/process-nextick-args", + "installable": true, + "license": "MIT", + "main": "index.js", + "maintainers": [ + { + "name": "cwmma", + "email": "calvin.metcalf@gmail.com" + } + ], + "name": "process-nextick-args", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git+https://github.com/calvinmetcalf/process-nextick-args.git" + }, + "scripts": { + "test": "node test.js" + }, + "version": "1.0.6" +} diff --git a/tools/node_modules/process-nextick-args/readme.md b/tools/node_modules/process-nextick-args/readme.md new file mode 100644 index 00000000000000..78e7cfaeb7acde --- /dev/null +++ b/tools/node_modules/process-nextick-args/readme.md @@ -0,0 +1,18 @@ +process-nextick-args +===== + +[![Build Status](https://travis-ci.org/calvinmetcalf/process-nextick-args.svg?branch=master)](https://travis-ci.org/calvinmetcalf/process-nextick-args) + +```bash +npm install --save process-nextick-args +``` + +Always be able to pass arguments to process.nextTick, no matter the platform + +```js +var nextTick = require('process-nextick-args'); + +nextTick(function (a, b, c) { + console.log(a, b, c); +}, 'step', 3, 'profit'); +``` diff --git a/tools/node_modules/process-nextick-args/test.js b/tools/node_modules/process-nextick-args/test.js new file mode 100644 index 00000000000000..ef15721584ac99 --- /dev/null +++ b/tools/node_modules/process-nextick-args/test.js @@ -0,0 +1,24 @@ +var test = require("tap").test; +var nextTick = require('./'); + +test('should work', function (t) { + t.plan(5); + nextTick(function (a) { + t.ok(a); + nextTick(function (thing) { + t.equals(thing, 7); + }, 7); + }, true); + nextTick(function (a, b, c) { + t.equals(a, 'step'); + t.equals(b, 3); + t.equals(c, 'profit'); + }, 'step', 3, 'profit'); +}); + +test('correct number of arguments', function (t) { + t.plan(1); + nextTick(function () { + t.equals(2, arguments.length, 'correct number'); + }, 1, 2); +}); diff --git a/tools/node_modules/randomatic/LICENSE b/tools/node_modules/randomatic/LICENSE new file mode 100644 index 00000000000000..6d53705b1257aa --- /dev/null +++ b/tools/node_modules/randomatic/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2013-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. diff --git a/tools/node_modules/randomatic/README.md b/tools/node_modules/randomatic/README.md new file mode 100644 index 00000000000000..28b1ae03131e7e --- /dev/null +++ b/tools/node_modules/randomatic/README.md @@ -0,0 +1,132 @@ +# randomatic [![NPM version](https://img.shields.io/npm/v/randomatic.svg)](https://www.npmjs.com/package/randomatic) + +> Generate randomized strings of a specified length, fast. Only the length is necessary, but you can optionally generate patterns using any combination of numeric, alpha-numeric, alphabetical, special or custom characters. + +## Install + +Install with [npm](https://www.npmjs.com/) + +```sh +$ npm i randomatic --save +``` + +Install with [bower](http://bower.io/) + +```sh +$ bower install randomatic --save +``` + +## Usage + +```js +var randomize = require('randomatic'); +``` + +## API + +```js +randomize(pattern, length, options); +``` + +* `pattern` **{String}**: The pattern to use for randomizing +* `length` **{Object}**: The length of the string to generate + +### pattern + +> The pattern to use for randomizing + +Patterns can contain any combination of the below characters, specified in any order. + +**Example:** + +To generate a 10-character randomized string using all available characters: + +```js +randomize('*', 10); +//=> + +randomize('Aa0!', 10); +//=> +``` + +* `a`: Lowercase alpha characters (`abcdefghijklmnopqrstuvwxyz'`) +* `A`: Uppercase alpha characters (`ABCDEFGHIJKLMNOPQRSTUVWXYZ'`) +* `0`: Numeric characters (`0123456789'`) +* `!`: Special characters (`~!@#$%^&()_+-={}[];\',.`) +* `*`: All characters (all of the above combined) +* `?`: Custom characters (pass a string of custom characters to the options) + +### length + +> the length of the string to generate + +**Examples:** + +* `randomize('A', 5)` will generate a 5-character, uppercase, alphabetical, randomized string, e.g. `KDJWJ`. +* `randomize('0', 2)` will generate a 2-digit random number +* `randomize('0', 3)` will generate a 3-digit random number +* `randomize('0', 12)` will generate a 12-digit random number +* `randomize('A0', 16)` will generate a 16-character, alpha-numeric randomized string + +If `length` is left undefined, the length of the pattern in the first parameter will be used. For example: + ++ `randomize('00')` will generate a 2-digit random number +* `randomize('000')` will generate a 3-digit random number +* `randomize('0000')` will generate a 4-digit random number... +* `randomize('AAAAA')` will generate a 5-character, uppercase alphabetical random string... + +These are just examples, [see the tests](./test.js) for more use cases and examples. + +## options + +#### chars + +Type: `String` + +Default: `undefined` + +Define a custom string to be randomized. + +**Example:** + +* `randomize('?', 20, {chars: 'jonschlinkert'})` will generate a 20-character randomized string from the letters contained in `jonschlinkert`. +* `randomize('?', {chars: 'jonschlinkert'})` will generate a 13-character randomized string from the letters contained in `jonschlinkert`. + +## Usage Examples + +* `randomize('A', 4)` (_whitespace insenstive_) would result in randomized 4-digit uppercase letters, like, `ZAKH`, `UJSL`... etc. +* `randomize('AAAA')` is equivelant to `randomize('A', 4)` +* `randomize('AAA0')` and `randomize('AA00')` and `randomize('A0A0')` are equivelant to `randomize('A0', 4)` +* `randomize('aa')`: results in double-digit, randomized, lower-case letters (`abcdefghijklmnopqrstuvwxyz`) +* `randomize('AAA')`: results in triple-digit, randomized, upper-case letters (`ABCDEFGHIJKLMNOPQRSTUVWXYZ`) +* `randomize('0', 6)`: results in six-digit, randomized nubmers (`0123456789`) +* `randomize('!', 5)`: results in single-digit randomized, _valid_ non-letter characters (`~!@#$%^&()_+-={}[];\',.`) +* `randomize('A!a0', 9)`: results in nine-digit, randomized characters (any of the above) + +_The order in which the characters are defined is insignificant._ + +## Related + +* [pad-left](https://www.npmjs.com/package/pad-left): Left pad a string with zeros or a specified string. Fastest implementation. | [homepage](https://github.com/jonschlinkert/pad-left) +* [pad-right](https://www.npmjs.com/package/pad-right): Right pad a string with zeros or a specified string. Fastest implementation. | [homepage](https://github.com/jonschlinkert/pad-right) +* [repeat-string](https://www.npmjs.com/package/repeat-string): Repeat the given string n times. Fastest implementation for repeating a string. | [homepage](https://github.com/jonschlinkert/repeat-string) + +## Contributing + +Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/randomatic/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 10, 2015._ \ No newline at end of file diff --git a/tools/node_modules/randomatic/index.js b/tools/node_modules/randomatic/index.js new file mode 100644 index 00000000000000..85dbe21ca989bf --- /dev/null +++ b/tools/node_modules/randomatic/index.js @@ -0,0 +1,83 @@ +/*! + * randomatic + * + * This was originally inspired by + * Copyright (c) 2014-2015, Jon Schlinkert. + * Licensed under the MIT License (MIT) + */ + +'use strict'; + +var isNumber = require('is-number'); +var typeOf = require('kind-of'); + +/** + * Expose `randomatic` + */ + +module.exports = randomatic; + +/** + * Available mask characters + */ + +var type = { + lower: 'abcdefghijklmnopqrstuvwxyz', + upper: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', + number: '0123456789', + special: '~!@#$%^&()_+-={}[];\',.' +}; + +type.all = type.lower + type.upper + type.number; + +/** + * Generate random character sequences of a specified `length`, + * based on the given `pattern`. + * + * @param {String} `pattern` The pattern to use for generating the random string. + * @param {String} `length` The length of the string to generate. + * @param {String} `options` + * @return {String} + * @api public + */ + +function randomatic(pattern, length, options) { + if (typeof pattern === 'undefined') { + throw new Error('randomatic expects a string or number.'); + } + + var custom = false; + if (arguments.length === 1) { + if (typeof pattern === 'string') { + length = pattern.length; + + } else if (isNumber(pattern)) { + options = {}; length = pattern; pattern = '*'; + } + } + + if (typeOf(length) === 'object' && length.hasOwnProperty('chars')) { + options = length; + pattern = options.chars; + length = pattern.length; + custom = true; + } + + var opts = options || {}; + var mask = ''; + var res = ''; + + // Characters to be used + if (pattern.indexOf('?') !== -1) mask += opts.chars; + if (pattern.indexOf('a') !== -1) mask += type.lower; + if (pattern.indexOf('A') !== -1) mask += type.upper; + if (pattern.indexOf('0') !== -1) mask += type.number; + if (pattern.indexOf('!') !== -1) mask += type.special; + if (pattern.indexOf('*') !== -1) mask += type.all; + if (custom) mask += pattern; + + while (length--) { + res += mask.charAt(parseInt(Math.random() * mask.length, 10)); + } + return res; +}; diff --git a/tools/node_modules/randomatic/package.json b/tools/node_modules/randomatic/package.json new file mode 100644 index 00000000000000..7bf745aa46cafb --- /dev/null +++ b/tools/node_modules/randomatic/package.json @@ -0,0 +1,107 @@ +{ + "_args": [ + [ + "randomatic@^1.1.3", + "C:\\wamp\\www\\node\\tools\\node_modules\\fill-range" + ] + ], + "_from": "randomatic@>=1.1.3 <2.0.0", + "_id": "randomatic@1.1.5", + "_inCache": true, + "_location": "/randomatic", + "_nodeVersion": "5.0.0", + "_npmUser": { + "email": "github@sellside.com", + "name": "jonschlinkert" + }, + "_npmVersion": "3.3.6", + "_phantomChildren": {}, + "_requested": { + "name": "randomatic", + "raw": "randomatic@^1.1.3", + "rawSpec": "^1.1.3", + "scope": null, + "spec": ">=1.1.3 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/fill-range" + ], + "_resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.5.tgz", + "_shasum": "5e9ef5f2d573c67bd2b8124ae90b5156e457840b", + "_shrinkwrap": null, + "_spec": "randomatic@^1.1.3", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\fill-range", + "author": { + "name": "Jon Schlinkert", + "url": "https://github.com/jonschlinkert" + }, + "bugs": { + "url": "https://github.com/jonschlinkert/randomatic/issues" + }, + "dependencies": { + "is-number": "^2.0.2", + "kind-of": "^3.0.2" + }, + "description": "Generate randomized strings of a specified length, fast. Only the length is necessary, but you can optionally generate patterns using any combination of numeric, alpha-numeric, alphabetical, special or custom characters.", + "devDependencies": { + "ansi-bold": "^0.1.1", + "benchmarked": "^0.1.4", + "glob": "^5.0.15", + "mocha": "*", + "should": "*" + }, + "directories": {}, + "dist": { + "shasum": "5e9ef5f2d573c67bd2b8124ae90b5156e457840b", + "tarball": "http://registry.npmjs.org/randomatic/-/randomatic-1.1.5.tgz" + }, + "files": [ + "index.js" + ], + "gitHead": "8d74759d683a580412484e95ec5f1b87d93fd50c", + "homepage": "https://github.com/jonschlinkert/randomatic", + "installable": true, + "keywords": [ + "alpha", + "alpha-numeric", + "alphanumeric", + "characters", + "chars", + "numeric", + "rand", + "random", + "randomize", + "randomized" + ], + "license": "MIT", + "main": "index.js", + "maintainers": [ + { + "name": "jonschlinkert", + "email": "github@sellside.com" + } + ], + "name": "randomatic", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git+https://github.com/jonschlinkert/randomatic.git" + }, + "scripts": { + "test": "mocha" + }, + "verb": { + "plugins": [ + "gulp-format-md" + ], + "related": { + "list": [ + "pad-left", + "pad-right", + "repeat-string" + ] + } + }, + "version": "1.1.5" +} diff --git a/tools/node_modules/rc/.npmignore b/tools/node_modules/rc/.npmignore new file mode 100644 index 00000000000000..13abef4f588987 --- /dev/null +++ b/tools/node_modules/rc/.npmignore @@ -0,0 +1,3 @@ +node_modules +node_modules/* +npm_debug.log diff --git a/tools/node_modules/rc/LICENSE.APACHE2 b/tools/node_modules/rc/LICENSE.APACHE2 new file mode 100644 index 00000000000000..6366c04716fb9e --- /dev/null +++ b/tools/node_modules/rc/LICENSE.APACHE2 @@ -0,0 +1,15 @@ +Apache License, Version 2.0 + +Copyright (c) 2011 Dominic Tarr + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/tools/node_modules/rc/LICENSE.BSD b/tools/node_modules/rc/LICENSE.BSD new file mode 100644 index 00000000000000..96bb796aa5f2d2 --- /dev/null +++ b/tools/node_modules/rc/LICENSE.BSD @@ -0,0 +1,26 @@ +Copyright (c) 2013, Dominic Tarr +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL 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. + +The views and conclusions contained in the software and documentation are those +of the authors and should not be interpreted as representing official policies, +either expressed or implied, of the FreeBSD Project. diff --git a/tools/node_modules/rc/LICENSE.MIT b/tools/node_modules/rc/LICENSE.MIT new file mode 100644 index 00000000000000..6eafbd734a6e06 --- /dev/null +++ b/tools/node_modules/rc/LICENSE.MIT @@ -0,0 +1,24 @@ +The MIT License + +Copyright (c) 2011 Dominic Tarr + +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. diff --git a/tools/node_modules/rc/README.md b/tools/node_modules/rc/README.md new file mode 100644 index 00000000000000..65a5f0687cc013 --- /dev/null +++ b/tools/node_modules/rc/README.md @@ -0,0 +1,149 @@ +# rc + +The non-configurable configuration loader for lazy people. + +## Usage + +The only option is to pass rc the name of your app, and your default configuration. + +```javascript +var conf = require('rc')(appname, { + //defaults go here. + port: 2468, + + //defaults which are objects will be merged, not replaced + views: { + engine: 'jade' + } +}); +``` + +`rc` will return your configuration options merged with the defaults you specify. +If you pass in a predefined defaults object, it will be mutated: + +```javascript +var conf = {}; +require('rc')(appname, conf); +``` + +If `rc` finds any config files for your app, the returned config object will have +a `configs` array containing their paths: + +```javascript +var appCfg = require('rc')(appname, conf); +appCfg.configs[0] // /etc/appnamerc +appCfg.configs[1] // /home/dominictarr/.config/appname +appCfg.config // same as appCfg.configs[appCfg.configs.length - 1] +``` + +## Standards + +Given your application name (`appname`), rc will look in all the obvious places for configuration. + + * command line arguments (parsed by minimist) + * environment variables prefixed with `${appname}_` + * or use "\_\_" to indicate nested properties
    _(e.g. `appname_foo__bar__baz` => `foo.bar.baz`)_ + * if you passed an option `--config file` then from that file + * a local `.${appname}rc` or the first found looking in `./ ../ ../../ ../../../` etc. + * `$HOME/.${appname}rc` + * `$HOME/.${appname}/config` + * `$HOME/.config/${appname}` + * `$HOME/.config/${appname}/config` + * `/etc/${appname}rc` + * `/etc/${appname}/config` + * the defaults object you passed in. + +All configuration sources that were found will be flattened into one object, +so that sources **earlier** in this list override later ones. + + +## Configuration File Formats + +Configuration files (e.g. `.appnamerc`) may be in either [json](http://json.org/example) or [ini](http://en.wikipedia.org/wiki/INI_file) format. The example configurations below are equivalent: + + +#### Formatted as `ini` + +``` +; You can include comments in `ini` format if you want. + +dependsOn=0.10.0 + + +; `rc` has built-in support for ini sections, see? + +[commands] + www = ./commands/www + console = ./commands/repl + + +; You can even do nested sections + +[generators.options] + engine = ejs + +[generators.modules] + new = generate-new + engine = generate-backend + +``` + +#### Formatted as `json` + +```javascript +{ + // You can even comment your JSON, if you want + "dependsOn": "0.10.0", + "commands": { + "www": "./commands/www", + "console": "./commands/repl" + }, + "generators": { + "options": { + "engine": "ejs" + }, + "modules": { + "new": "generate-new", + "backend": "generate-backend" + } + } +} +``` + +Comments are stripped from JSON config via [strip-json-comments](https://github.com/sindresorhus/strip-json-comments). + +> Since ini, and env variables do not have a standard for types, your application needs be prepared for strings. + + + +## Advanced Usage + +#### Pass in your own `argv` + +You may pass in your own `argv` as the third argument to `rc`. This is in case you want to [use your own command-line opts parser](https://github.com/dominictarr/rc/pull/12). + +```javascript +require('rc')(appname, defaults, customArgvParser); +``` + +## Pass in your own parser + +If you have a special need to use a non-standard parser, +you can do so by passing in the parser as the 4th argument. +(leave the 3rd as null to get the default args parser) + +```javascript +require('rc')(appname, defaults, null, parser); +``` + +This may also be used to force a more strict format, +such as strict, valid JSON only. + +## Note on Performance + +`rc` is running `fs.statSync`-- so make sure you don't use it in a hot code path (e.g. a request handler) + + +## License + +Multi-licensed under the two-clause BSD License, MIT License, or Apache License, version 2.0 diff --git a/tools/node_modules/rc/browser.js b/tools/node_modules/rc/browser.js new file mode 100644 index 00000000000000..8c230c5cd2d397 --- /dev/null +++ b/tools/node_modules/rc/browser.js @@ -0,0 +1,7 @@ + +// when this is loaded into the browser, +// just use the defaults... + +module.exports = function (name, defaults) { + return defaults +} diff --git a/tools/node_modules/rc/index.js b/tools/node_modules/rc/index.js new file mode 100644 index 00000000000000..6f8f1139d7f19c --- /dev/null +++ b/tools/node_modules/rc/index.js @@ -0,0 +1,60 @@ +#! /usr/bin/env node +var cc = require('./lib/utils') +var join = require('path').join +var deepExtend = require('deep-extend') +var etc = '/etc' +var win = process.platform === "win32" +var home = win + ? process.env.USERPROFILE + : process.env.HOME + +module.exports = function (name, defaults, argv, parse) { + if('string' !== typeof name) + throw new Error('rc(name): name *must* be string') + if(!argv) + argv = require('minimist')(process.argv.slice(2)) + defaults = ( + 'string' === typeof defaults + ? cc.json(defaults) : defaults + ) || {} + + parse = parse || cc.parse + + var env = cc.env(name + '_') + + var configs = [defaults] + var configFiles = [] + function addConfigFile (file) { + if (configFiles.indexOf(file) >= 0) return + var fileConfig = cc.file(file) + if (fileConfig) { + configs.push(parse(fileConfig)) + configFiles.push(file) + } + } + + // which files do we look at? + if (!win) + [join(etc, name, 'config'), + join(etc, name + 'rc')].forEach(addConfigFile) + if (home) + [join(home, '.config', name, 'config'), + join(home, '.config', name), + join(home, '.' + name, 'config'), + join(home, '.' + name + 'rc')].forEach(addConfigFile) + addConfigFile(cc.find('.'+name+'rc')) + if (env.config) addConfigFile(env.config) + if (argv.config) addConfigFile(argv.config) + + return deepExtend.apply(null, configs.concat([ + env, + argv, + configFiles.length ? {configs: configFiles, config: configFiles[configFiles.length - 1]} : undefined, + ])) +} + +if(!module.parent) { + console.log( + JSON.stringify(module.exports(process.argv[2]), false, 2) + ) +} diff --git a/tools/node_modules/rc/lib/utils.js b/tools/node_modules/rc/lib/utils.js new file mode 100644 index 00000000000000..ae6dec0ba70be2 --- /dev/null +++ b/tools/node_modules/rc/lib/utils.js @@ -0,0 +1,103 @@ +'use strict'; +var fs = require('fs') +var ini = require('ini') +var path = require('path') +var stripJsonComments = require('strip-json-comments') + +var parse = exports.parse = function (content) { + + //if it ends in .json or starts with { then it must be json. + //must be done this way, because ini accepts everything. + //can't just try and parse it and let it throw if it's not ini. + //everything is ini. even json with a syntax error. + + if(/^\s*{/.test(content)) + return JSON.parse(stripJsonComments(content)) + return ini.parse(content) + +} + +var file = exports.file = function () { + var args = [].slice.call(arguments).filter(function (arg) { return arg != null }) + + //path.join breaks if it's a not a string, so just skip this. + for(var i in args) + if('string' !== typeof args[i]) + return + + var file = path.join.apply(null, args) + var content + try { + return fs.readFileSync(file,'utf-8') + } catch (err) { + return + } +} + +var json = exports.json = function () { + var content = file.apply(null, arguments) + return content ? parse(content) : null +} + +var env = exports.env = function (prefix, env) { + env = env || process.env + var obj = {} + var l = prefix.length + for(var k in env) { + if((k.indexOf(prefix)) === 0) { + + var keypath = k.substring(l).split('__') + + // Trim empty strings from keypath array + var _emptyStringIndex + while ((_emptyStringIndex=keypath.indexOf('')) > -1) { + keypath.splice(_emptyStringIndex, 1) + } + + var cursor = obj + keypath.forEach(function _buildSubObj(_subkey,i){ + + // (check for _subkey first so we ignore empty strings) + // (check for cursor to avoid assignment to primitive objects) + if (!_subkey || typeof cursor !== 'object') + return + + // If this is the last key, just stuff the value in there + // Assigns actual value from env variable to final key + // (unless it's just an empty string- in that case use the last valid key) + if (i === keypath.length-1) + cursor[_subkey] = env[k] + + + // Build sub-object if nothing already exists at the keypath + if (cursor[_subkey] === undefined) + cursor[_subkey] = {} + + // Increment cursor used to track the object at the current depth + cursor = cursor[_subkey] + + }) + + } + + } + + return obj +} + +var find = exports.find = function () { + var rel = path.join.apply(null, [].slice.call(arguments)) + + function find(start, rel) { + var file = path.join(start, rel) + try { + fs.statSync(file) + return file + } catch (err) { + if(path.dirname(start) !== start) // root + return find(path.dirname(start), rel) + } + } + return find(process.cwd(), rel) +} + diff --git a/tools/node_modules/rc/package.json b/tools/node_modules/rc/package.json new file mode 100644 index 00000000000000..6fa5e81f4e0a76 --- /dev/null +++ b/tools/node_modules/rc/package.json @@ -0,0 +1,87 @@ +{ + "_args": [ + [ + "rc@^1.1.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\npm-prefix" + ] + ], + "_from": "rc@>=1.1.0 <2.0.0", + "_id": "rc@1.1.6", + "_inCache": true, + "_location": "/rc", + "_nodeVersion": "4.2.3", + "_npmUser": { + "email": "dominic.tarr@gmail.com", + "name": "dominictarr" + }, + "_npmVersion": "3.5.1", + "_phantomChildren": {}, + "_requested": { + "name": "rc", + "raw": "rc@^1.1.0", + "rawSpec": "^1.1.0", + "scope": null, + "spec": ">=1.1.0 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/npm-prefix" + ], + "_resolved": "https://registry.npmjs.org/rc/-/rc-1.1.6.tgz", + "_shasum": "43651b76b6ae53b5c802f1151fa3fc3b059969c9", + "_shrinkwrap": null, + "_spec": "rc@^1.1.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\npm-prefix", + "author": { + "email": "dominic.tarr@gmail.com", + "name": "Dominic Tarr", + "url": "dominictarr.com" + }, + "bin": { + "rc": "./index.js" + }, + "browserify": "browser.js", + "bugs": { + "url": "https://github.com/dominictarr/rc/issues" + }, + "dependencies": { + "deep-extend": "~0.4.0", + "ini": "~1.3.0", + "minimist": "^1.2.0", + "strip-json-comments": "~1.0.4" + }, + "description": "hardwired configuration loader", + "devDependencies": {}, + "directories": {}, + "dist": { + "shasum": "43651b76b6ae53b5c802f1151fa3fc3b059969c9", + "tarball": "http://registry.npmjs.org/rc/-/rc-1.1.6.tgz" + }, + "gitHead": "132062de0e61881a025cc4784d9a2798409c2bf1", + "homepage": "https://github.com/dominictarr/rc#readme", + "installable": true, + "keywords": [ + "config", + "defaults", + "rc", + "unix" + ], + "license": "(BSD-2-Clause OR MIT OR Apache-2.0)", + "main": "index.js", + "maintainers": [ + { + "name": "dominictarr", + "email": "dominic.tarr@gmail.com" + } + ], + "name": "rc", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git+https://github.com/dominictarr/rc.git" + }, + "scripts": { + "test": "set -e; node test/test.js; node test/ini.js; node test/nested-env-vars.js" + }, + "version": "1.1.6" +} diff --git a/tools/node_modules/rc/test/ini.js b/tools/node_modules/rc/test/ini.js new file mode 100644 index 00000000000000..e6857f8b382cf9 --- /dev/null +++ b/tools/node_modules/rc/test/ini.js @@ -0,0 +1,16 @@ +var cc =require('../lib/utils') +var INI = require('ini') +var assert = require('assert') + +function test(obj) { + + var _json, _ini + var json = cc.parse (_json = JSON.stringify(obj)) + var ini = cc.parse (_ini = INI.stringify(obj)) + console.log(_ini, _json) + assert.deepEqual(json, ini) +} + + +test({hello: true}) + diff --git a/tools/node_modules/rc/test/nested-env-vars.js b/tools/node_modules/rc/test/nested-env-vars.js new file mode 100644 index 00000000000000..f576fb153b90f4 --- /dev/null +++ b/tools/node_modules/rc/test/nested-env-vars.js @@ -0,0 +1,40 @@ + +var n = 'rc'+Math.random() +var assert = require('assert') + + +// Basic usage +process.env[n+'_someOpt__a'] = 42 +process.env[n+'_someOpt__x__'] = 99 +process.env[n+'_someOpt__a__b'] = 186 +process.env[n+'_someOpt__a__b__c'] = 243 +process.env[n+'_someOpt__x__y'] = 1862 +process.env[n+'_someOpt__z'] = 186577 + +// Should ignore empty strings from orphaned '__' +process.env[n+'_someOpt__z__x__'] = 18629 +process.env[n+'_someOpt__w__w__'] = 18629 + +// Leading '__' should ignore everything up to 'z' +process.env[n+'___z__i__'] = 9999 + +var config = require('../')(n, { + option: true +}) + +console.log('\n\n------ nested-env-vars ------\n',config) + +assert.equal(config.option, true) +assert.equal(config.someOpt.a, 42) +assert.equal(config.someOpt.x, 99) +// Should not override `a` once it's been set +assert.equal(config.someOpt.a/*.b*/, 42) +// Should not override `x` once it's been set +assert.equal(config.someOpt.x/*.y*/, 99) +assert.equal(config.someOpt.z, 186577) +// Should not override `z` once it's been set +assert.equal(config.someOpt.z/*.x*/, 186577) +assert.equal(config.someOpt.w.w, 18629) +assert.equal(config.z.i, 9999) + + diff --git a/tools/node_modules/rc/test/test.js b/tools/node_modules/rc/test/test.js new file mode 100644 index 00000000000000..4f6335189b6f81 --- /dev/null +++ b/tools/node_modules/rc/test/test.js @@ -0,0 +1,59 @@ + +var n = 'rc'+Math.random() +var assert = require('assert') + +process.env[n+'_envOption'] = 42 + +var config = require('../')(n, { + option: true +}) + +console.log(config) + +assert.equal(config.option, true) +assert.equal(config.envOption, 42) + +var customArgv = require('../')(n, { + option: true +}, { // nopt-like argv + option: false, + envOption: 24, + argv: { + remain: [], + cooked: ['--no-option', '--envOption', '24'], + original: ['--no-option', '--envOption=24'] + } +}) + +console.log(customArgv) + +assert.equal(customArgv.option, false) +assert.equal(customArgv.envOption, 24) + +var fs = require('fs') +var path = require('path') +var jsonrc = path.resolve('.' + n + 'rc'); + +fs.writeFileSync(jsonrc, [ + '{', + '// json overrides default', + '"option": false,', + '/* env overrides json */', + '"envOption": 24', + '}' +].join('\n')); + +var commentedJSON = require('../')(n, { + option: true +}) + +fs.unlinkSync(jsonrc); + +console.log(commentedJSON) + +assert.equal(commentedJSON.option, false) +assert.equal(commentedJSON.envOption, 42) + +assert.equal(commentedJSON.config, jsonrc) +assert.equal(commentedJSON.configs.length, 1) +assert.equal(commentedJSON.configs[0], jsonrc) diff --git a/tools/node_modules/readable-stream/.npmignore b/tools/node_modules/readable-stream/.npmignore new file mode 100644 index 00000000000000..38344f87a62766 --- /dev/null +++ b/tools/node_modules/readable-stream/.npmignore @@ -0,0 +1,5 @@ +build/ +test/ +examples/ +fs.js +zlib.js \ No newline at end of file diff --git a/tools/node_modules/readable-stream/.travis.yml b/tools/node_modules/readable-stream/.travis.yml new file mode 100644 index 00000000000000..cfe1c9439388b6 --- /dev/null +++ b/tools/node_modules/readable-stream/.travis.yml @@ -0,0 +1,50 @@ +sudo: false +language: node_js +before_install: + - npm install -g npm@2 + - npm install -g npm +notifications: + email: false +matrix: + include: + - node_js: '0.8' + env: TASK=test + - node_js: '0.10' + env: TASK=test + - node_js: '0.11' + env: TASK=test + - node_js: '0.12' + env: TASK=test + - node_js: 1 + env: TASK=test + - node_js: 2 + env: TASK=test + - node_js: 3 + env: TASK=test + - node_js: 4 + env: TASK=test + - node_js: 5 + env: TASK=test + - node_js: node + env: TASK=test + - node_js: node + env: TASK=browser BROWSER_NAME=opera BROWSER_VERSION="11..latest" + - node_js: node + env: TASK=browser BROWSER_NAME=ie BROWSER_VERSION="9..latest" + - node_js: node + env: TASK=browser BROWSER_NAME=chrome BROWSER_VERSION="41..beta" + - node_js: node + env: TASK=browser BROWSER_NAME=firefox BROWSER_VERSION="36..latest" + - node_js: node + env: TASK=browser BROWSER_NAME=ipad BROWSER_VERSION="['6.1', '7.1', '8.2']" + - node_js: node + env: TASK=browser BROWSER_NAME=iphone BROWSER_VERSION="['6.1', '7.1', '8.2']" + - node_js: node + env: TASK=browser BROWSER_NAME=safari BROWSER_VERSION="5..latest" + - node_js: node + env: TASK=browser BROWSER_NAME=android BROWSER_VERSION="4.0..latest" +script: "npm run $TASK" +env: + global: + - secure: rE2Vvo7vnjabYNULNyLFxOyt98BoJexDqsiOnfiD6kLYYsiQGfr/sbZkPMOFm9qfQG7pjqx+zZWZjGSswhTt+626C0t/njXqug7Yps4c3dFblzGfreQHp7wNX5TFsvrxd6dAowVasMp61sJcRnB2w8cUzoe3RAYUDHyiHktwqMc= + - secure: g9YINaKAdMatsJ28G9jCGbSaguXCyxSTy+pBO6Ch0Cf57ZLOTka3HqDj8p3nV28LUIHZ3ut5WO43CeYKwt4AUtLpBS3a0dndHdY6D83uY6b2qh5hXlrcbeQTq2cvw2y95F7hm4D1kwrgZ7ViqaKggRcEupAL69YbJnxeUDKWEdI= diff --git a/tools/node_modules/readable-stream/.zuul.yml b/tools/node_modules/readable-stream/.zuul.yml new file mode 100644 index 00000000000000..96d9cfbd38662f --- /dev/null +++ b/tools/node_modules/readable-stream/.zuul.yml @@ -0,0 +1 @@ +ui: tape diff --git a/tools/node_modules/readable-stream/LICENSE b/tools/node_modules/readable-stream/LICENSE new file mode 100644 index 00000000000000..e3d4e695a4cff2 --- /dev/null +++ b/tools/node_modules/readable-stream/LICENSE @@ -0,0 +1,18 @@ +Copyright Joyent, Inc. and other Node contributors. All rights reserved. +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. diff --git a/tools/node_modules/readable-stream/README.md b/tools/node_modules/readable-stream/README.md new file mode 100644 index 00000000000000..f9fb5205987153 --- /dev/null +++ b/tools/node_modules/readable-stream/README.md @@ -0,0 +1,36 @@ +# readable-stream + +***Node-core streams for userland*** [![Build Status](https://travis-ci.org/nodejs/readable-stream.svg?branch=master)](https://travis-ci.org/nodejs/readable-stream) + + +[![NPM](https://nodei.co/npm/readable-stream.png?downloads=true&downloadRank=true)](https://nodei.co/npm/readable-stream/) +[![NPM](https://nodei.co/npm-dl/readable-stream.png?&months=6&height=3)](https://nodei.co/npm/readable-stream/) + + +[![Sauce Test Status](https://saucelabs.com/browser-matrix/readable-stream.svg)](https://saucelabs.com/u/readable-stream) + +```bash +npm install --save readable-stream +``` + +***Node-core streams for userland*** + +This package is a mirror of the Streams2 and Streams3 implementations in +Node-core, including [documentation](doc/stream.markdown). + +If you want to guarantee a stable streams base, regardless of what version of +Node you, or the users of your libraries are using, use **readable-stream** *only* and avoid the *"stream"* module in Node-core, for background see [this blogpost](http://r.va.gg/2014/06/why-i-dont-use-nodes-core-stream-module.html). + +As of version 2.0.0 **readable-stream** uses semantic versioning. + +# Streams WG Team Members + +* **Chris Dickinson** ([@chrisdickinson](https://github.com/chrisdickinson)) <christopher.s.dickinson@gmail.com> + - Release GPG key: 9554F04D7259F04124DE6B476D5A82AC7E37093B +* **Calvin Metcalf** ([@calvinmetcalf](https://github.com/calvinmetcalf)) <calvin.metcalf@gmail.com> + - Release GPG key: F3EF5F62A87FC27A22E643F714CE4FF5015AA242 +* **Rod Vagg** ([@rvagg](https://github.com/rvagg)) <rod@vagg.org> + - Release GPG key: DD8F2338BAE7501E3DD5AC78C273792F7D83545D +* **Sam Newman** ([@sonewman](https://github.com/sonewman)) <newmansam@outlook.com> +* **Mathias Buus** ([@mafintosh](https://github.com/mafintosh)) <mathiasbuus@gmail.com> +* **Domenic Denicola** ([@domenic](https://github.com/domenic)) <d@domenic.me> diff --git a/tools/node_modules/readable-stream/doc/stream.markdown b/tools/node_modules/readable-stream/doc/stream.markdown new file mode 100644 index 00000000000000..5602f0736e5065 --- /dev/null +++ b/tools/node_modules/readable-stream/doc/stream.markdown @@ -0,0 +1,1730 @@ +# Stream + + Stability: 2 - Stable + +A stream is an abstract interface implemented by various objects in +Node.js. For example a [request to an HTTP server][] is a stream, as is +[stdout][]. Streams are readable, writable, or both. All streams are +instances of [EventEmitter][] + +You can load the Stream base classes by doing `require('stream')`. +There are base classes provided for [Readable][] streams, [Writable][] +streams, [Duplex][] streams, and [Transform][] streams. + +This document is split up into 3 sections. The first explains the +parts of the API that you need to be aware of to use streams in your +programs. If you never implement a streaming API yourself, you can +stop there. + +The second section explains the parts of the API that you need to use +if you implement your own custom streams yourself. The API is +designed to make this easy for you to do. + +The third section goes into more depth about how streams work, +including some of the internal mechanisms and functions that you +should probably not modify unless you definitely know what you are +doing. + + +## API for Stream Consumers + + + +Streams can be either [Readable][], [Writable][], or both ([Duplex][]). + +All streams are EventEmitters, but they also have other custom methods +and properties depending on whether they are Readable, Writable, or +Duplex. + +If a stream is both Readable and Writable, then it implements all of +the methods and events below. So, a [Duplex][] or [Transform][] stream is +fully described by this API, though their implementation may be +somewhat different. + +It is not necessary to implement Stream interfaces in order to consume +streams in your programs. If you **are** implementing streaming +interfaces in your own program, please also refer to +[API for Stream Implementors][] below. + +Almost all Node.js programs, no matter how simple, use Streams in some +way. Here is an example of using Streams in an Node.js program: + +```javascript +var http = require('http'); + +var server = http.createServer(function (req, res) { + // req is an http.IncomingMessage, which is a Readable Stream + // res is an http.ServerResponse, which is a Writable Stream + + var body = ''; + // we want to get the data as utf8 strings + // If you don't set an encoding, then you'll get Buffer objects + req.setEncoding('utf8'); + + // Readable streams emit 'data' events once a listener is added + req.on('data', function (chunk) { + body += chunk; + }); + + // the end event tells you that you have entire body + req.on('end', function () { + try { + var data = JSON.parse(body); + } catch (er) { + // uh oh! bad json! + res.statusCode = 400; + return res.end('error: ' + er.message); + } + + // write back something interesting to the user: + res.write(typeof data); + res.end(); + }); +}); + +server.listen(1337); + +// $ curl localhost:1337 -d '{}' +// object +// $ curl localhost:1337 -d '"foo"' +// string +// $ curl localhost:1337 -d 'not json' +// error: Unexpected token o +``` + +### Class: stream.Duplex + +Duplex streams are streams that implement both the [Readable][] and +[Writable][] interfaces. See above for usage. + +Examples of Duplex streams include: + +* [tcp sockets][] +* [zlib streams][] +* [crypto streams][] + +### Class: stream.Readable + + + +The Readable stream interface is the abstraction for a *source* of +data that you are reading from. In other words, data comes *out* of a +Readable stream. + +A Readable stream will not start emitting data until you indicate that +you are ready to receive it. + +Readable streams have two "modes": a **flowing mode** and a **paused +mode**. When in flowing mode, data is read from the underlying system +and provided to your program as fast as possible. In paused mode, you +must explicitly call `stream.read()` to get chunks of data out. +Streams start out in paused mode. + +**Note**: If no data event handlers are attached, and there are no +[`pipe()`][] destinations, and the stream is switched into flowing +mode, then data will be lost. + +You can switch to flowing mode by doing any of the following: + +* Adding a [`'data'` event][] handler to listen for data. +* Calling the [`resume()`][] method to explicitly open the flow. +* Calling the [`pipe()`][] method to send the data to a [Writable][]. + +You can switch back to paused mode by doing either of the following: + +* If there are no pipe destinations, by calling the [`pause()`][] + method. +* If there are pipe destinations, by removing any [`'data'` event][] + handlers, and removing all pipe destinations by calling the + [`unpipe()`][] method. + +Note that, for backwards compatibility reasons, removing `'data'` +event handlers will **not** automatically pause the stream. Also, if +there are piped destinations, then calling `pause()` will not +guarantee that the stream will *remain* paused once those +destinations drain and ask for more data. + +Examples of readable streams include: + +* [http responses, on the client][] +* [http requests, on the server][] +* [fs read streams][] +* [zlib streams][] +* [crypto streams][] +* [tcp sockets][] +* [child process stdout and stderr][] +* [process.stdin][] + +#### Event: 'close' + +Emitted when the stream and any of its underlying resources (a file +descriptor, for example) have been closed. The event indicates that +no more events will be emitted, and no further computation will occur. + +Not all streams will emit the 'close' event. + +#### Event: 'data' + +* `chunk` {Buffer | String} The chunk of data. + +Attaching a `data` event listener to a stream that has not been +explicitly paused will switch the stream into flowing mode. Data will +then be passed as soon as it is available. + +If you just want to get all the data out of the stream as fast as +possible, this is the best way to do so. + +```javascript +var readable = getReadableStreamSomehow(); +readable.on('data', function(chunk) { + console.log('got %d bytes of data', chunk.length); +}); +``` + +#### Event: 'end' + +This event fires when there will be no more data to read. + +Note that the `end` event **will not fire** unless the data is +completely consumed. This can be done by switching into flowing mode, +or by calling `read()` repeatedly until you get to the end. + +```javascript +var readable = getReadableStreamSomehow(); +readable.on('data', function(chunk) { + console.log('got %d bytes of data', chunk.length); +}); +readable.on('end', function() { + console.log('there will be no more data.'); +}); +``` + +#### Event: 'error' + +* {Error Object} + +Emitted if there was an error receiving data. + +#### Event: 'readable' + +When a chunk of data can be read from the stream, it will emit a +`'readable'` event. + +In some cases, listening for a `'readable'` event will cause some data +to be read into the internal buffer from the underlying system, if it +hadn't already. + +```javascript +var readable = getReadableStreamSomehow(); +readable.on('readable', function() { + // there is some data to read now +}); +``` + +Once the internal buffer is drained, a `readable` event will fire +again when more data is available. + +The `readable` event is not emitted in the "flowing" mode with the +sole exception of the last one, on end-of-stream. + +The 'readable' event indicates that the stream has new information: +either new data is available or the end of the stream has been reached. +In the former case, `.read()` will return that data. In the latter case, +`.read()` will return null. For instance, in the following example, `foo.txt` +is an empty file: + +```javascript +var fs = require('fs'); +var rr = fs.createReadStream('foo.txt'); +rr.on('readable', function() { + console.log('readable:', rr.read()); +}); +rr.on('end', function() { + console.log('end'); +}); +``` + +The output of running this script is: + +``` +bash-3.2$ node test.js +readable: null +end +``` + +#### readable.isPaused() + +* Return: `Boolean` + +This method returns whether or not the `readable` has been **explicitly** +paused by client code (using `readable.pause()` without a corresponding +`readable.resume()`). + +```javascript +var readable = new stream.Readable + +readable.isPaused() // === false +readable.pause() +readable.isPaused() // === true +readable.resume() +readable.isPaused() // === false +``` + +#### readable.pause() + +* Return: `this` + +This method will cause a stream in flowing mode to stop emitting +`data` events, switching out of flowing mode. Any data that becomes +available will remain in the internal buffer. + +```javascript +var readable = getReadableStreamSomehow(); +readable.on('data', function(chunk) { + console.log('got %d bytes of data', chunk.length); + readable.pause(); + console.log('there will be no more data for 1 second'); + setTimeout(function() { + console.log('now data will start flowing again'); + readable.resume(); + }, 1000); +}); +``` + +#### readable.pipe(destination[, options]) + +* `destination` {[Writable][] Stream} The destination for writing data +* `options` {Object} Pipe options + * `end` {Boolean} End the writer when the reader ends. Default = `true` + +This method pulls all the data out of a readable stream, and writes it +to the supplied destination, automatically managing the flow so that +the destination is not overwhelmed by a fast readable stream. + +Multiple destinations can be piped to safely. + +```javascript +var readable = getReadableStreamSomehow(); +var writable = fs.createWriteStream('file.txt'); +// All the data from readable goes into 'file.txt' +readable.pipe(writable); +``` + +This function returns the destination stream, so you can set up pipe +chains like so: + +```javascript +var r = fs.createReadStream('file.txt'); +var z = zlib.createGzip(); +var w = fs.createWriteStream('file.txt.gz'); +r.pipe(z).pipe(w); +``` + +For example, emulating the Unix `cat` command: + +```javascript +process.stdin.pipe(process.stdout); +``` + +By default [`end()`][] is called on the destination when the source stream +emits `end`, so that `destination` is no longer writable. Pass `{ end: +false }` as `options` to keep the destination stream open. + +This keeps `writer` open so that "Goodbye" can be written at the +end. + +```javascript +reader.pipe(writer, { end: false }); +reader.on('end', function() { + writer.end('Goodbye\n'); +}); +``` + +Note that `process.stderr` and `process.stdout` are never closed until +the process exits, regardless of the specified options. + +#### readable.read([size]) + +* `size` {Number} Optional argument to specify how much data to read. +* Return {String | Buffer | null} + +The `read()` method pulls some data out of the internal buffer and +returns it. If there is no data available, then it will return +`null`. + +If you pass in a `size` argument, then it will return that many +bytes. If `size` bytes are not available, then it will return `null`, +unless we've ended, in which case it will return the data remaining +in the buffer. + +If you do not specify a `size` argument, then it will return all the +data in the internal buffer. + +This method should only be called in paused mode. In flowing mode, +this method is called automatically until the internal buffer is +drained. + +```javascript +var readable = getReadableStreamSomehow(); +readable.on('readable', function() { + var chunk; + while (null !== (chunk = readable.read())) { + console.log('got %d bytes of data', chunk.length); + } +}); +``` + +If this method returns a data chunk, then it will also trigger the +emission of a [`'data'` event][]. + +Note that calling `readable.read([size])` after the `end` event has been +triggered will return `null`. No runtime error will be raised. + +#### readable.resume() + +* Return: `this` + +This method will cause the readable stream to resume emitting `data` +events. + +This method will switch the stream into flowing mode. If you do *not* +want to consume the data from a stream, but you *do* want to get to +its `end` event, you can call [`readable.resume()`][] to open the flow of +data. + +```javascript +var readable = getReadableStreamSomehow(); +readable.resume(); +readable.on('end', function() { + console.log('got to the end, but did not read anything'); +}); +``` + +#### readable.setEncoding(encoding) + +* `encoding` {String} The encoding to use. +* Return: `this` + +Call this function to cause the stream to return strings of the +specified encoding instead of Buffer objects. For example, if you do +`readable.setEncoding('utf8')`, then the output data will be +interpreted as UTF-8 data, and returned as strings. If you do +`readable.setEncoding('hex')`, then the data will be encoded in +hexadecimal string format. + +This properly handles multi-byte characters that would otherwise be +potentially mangled if you simply pulled the Buffers directly and +called `buf.toString(encoding)` on them. If you want to read the data +as strings, always use this method. + +```javascript +var readable = getReadableStreamSomehow(); +readable.setEncoding('utf8'); +readable.on('data', function(chunk) { + assert.equal(typeof chunk, 'string'); + console.log('got %d characters of string data', chunk.length); +}); +``` + +#### readable.unpipe([destination]) + +* `destination` {[Writable][] Stream} Optional specific stream to unpipe + +This method will remove the hooks set up for a previous `pipe()` call. + +If the destination is not specified, then all pipes are removed. + +If the destination is specified, but no pipe is set up for it, then +this is a no-op. + +```javascript +var readable = getReadableStreamSomehow(); +var writable = fs.createWriteStream('file.txt'); +// All the data from readable goes into 'file.txt', +// but only for the first second +readable.pipe(writable); +setTimeout(function() { + console.log('stop writing to file.txt'); + readable.unpipe(writable); + console.log('manually close the file stream'); + writable.end(); +}, 1000); +``` + +#### readable.unshift(chunk) + +* `chunk` {Buffer | String} Chunk of data to unshift onto the read queue + +This is useful in certain cases where a stream is being consumed by a +parser, which needs to "un-consume" some data that it has +optimistically pulled out of the source, so that the stream can be +passed on to some other party. + +Note that `stream.unshift(chunk)` cannot be called after the `end` event +has been triggered; a runtime error will be raised. + +If you find that you must often call `stream.unshift(chunk)` in your +programs, consider implementing a [Transform][] stream instead. (See API +for Stream Implementors, below.) + +```javascript +// Pull off a header delimited by \n\n +// use unshift() if we get too much +// Call the callback with (error, header, stream) +var StringDecoder = require('string_decoder').StringDecoder; +function parseHeader(stream, callback) { + stream.on('error', callback); + stream.on('readable', onReadable); + var decoder = new StringDecoder('utf8'); + var header = ''; + function onReadable() { + var chunk; + while (null !== (chunk = stream.read())) { + var str = decoder.write(chunk); + if (str.match(/\n\n/)) { + // found the header boundary + var split = str.split(/\n\n/); + header += split.shift(); + var remaining = split.join('\n\n'); + var buf = new Buffer(remaining, 'utf8'); + if (buf.length) + stream.unshift(buf); + stream.removeListener('error', callback); + stream.removeListener('readable', onReadable); + // now the body of the message can be read from the stream. + callback(null, header, stream); + } else { + // still reading the header. + header += str; + } + } + } +} +``` +Note that, unlike `stream.push(chunk)`, `stream.unshift(chunk)` will not +end the reading process by resetting the internal reading state of the +stream. This can cause unexpected results if `unshift` is called during a +read (i.e. from within a `_read` implementation on a custom stream). Following +the call to `unshift` with an immediate `stream.push('')` will reset the +reading state appropriately, however it is best to simply avoid calling +`unshift` while in the process of performing a read. + +#### readable.wrap(stream) + +* `stream` {Stream} An "old style" readable stream + +Versions of Node.js prior to v0.10 had streams that did not implement the +entire Streams API as it is today. (See "Compatibility" below for +more information.) + +If you are using an older Node.js library that emits `'data'` events and +has a [`pause()`][] method that is advisory only, then you can use the +`wrap()` method to create a [Readable][] stream that uses the old stream +as its data source. + +You will very rarely ever need to call this function, but it exists +as a convenience for interacting with old Node.js programs and libraries. + +For example: + +```javascript +var OldReader = require('./old-api-module.js').OldReader; +var oreader = new OldReader; +var Readable = require('stream').Readable; +var myReader = new Readable().wrap(oreader); + +myReader.on('readable', function() { + myReader.read(); // etc. +}); +``` + +### Class: stream.Transform + +Transform streams are [Duplex][] streams where the output is in some way +computed from the input. They implement both the [Readable][] and +[Writable][] interfaces. See above for usage. + +Examples of Transform streams include: + +* [zlib streams][] +* [crypto streams][] + +### Class: stream.Writable + + + +The Writable stream interface is an abstraction for a *destination* +that you are writing data *to*. + +Examples of writable streams include: + +* [http requests, on the client][] +* [http responses, on the server][] +* [fs write streams][] +* [zlib streams][] +* [crypto streams][] +* [tcp sockets][] +* [child process stdin][] +* [process.stdout][], [process.stderr][] + +#### Event: 'drain' + +If a [`writable.write(chunk)`][] call returns false, then the `drain` +event will indicate when it is appropriate to begin writing more data +to the stream. + +```javascript +// Write the data to the supplied writable stream one million times. +// Be attentive to back-pressure. +function writeOneMillionTimes(writer, data, encoding, callback) { + var i = 1000000; + write(); + function write() { + var ok = true; + do { + i -= 1; + if (i === 0) { + // last time! + writer.write(data, encoding, callback); + } else { + // see if we should continue, or wait + // don't pass the callback, because we're not done yet. + ok = writer.write(data, encoding); + } + } while (i > 0 && ok); + if (i > 0) { + // had to stop early! + // write some more once it drains + writer.once('drain', write); + } + } +} +``` + +#### Event: 'error' + +* {Error object} + +Emitted if there was an error when writing or piping data. + +#### Event: 'finish' + +When the [`end()`][] method has been called, and all data has been flushed +to the underlying system, this event is emitted. + +```javascript +var writer = getWritableStreamSomehow(); +for (var i = 0; i < 100; i ++) { + writer.write('hello, #' + i + '!\n'); +} +writer.end('this is the end\n'); +writer.on('finish', function() { + console.error('all writes are now complete.'); +}); +``` + +#### Event: 'pipe' + +* `src` {[Readable][] Stream} source stream that is piping to this writable + +This is emitted whenever the `pipe()` method is called on a readable +stream, adding this writable to its set of destinations. + +```javascript +var writer = getWritableStreamSomehow(); +var reader = getReadableStreamSomehow(); +writer.on('pipe', function(src) { + console.error('something is piping into the writer'); + assert.equal(src, reader); +}); +reader.pipe(writer); +``` + +#### Event: 'unpipe' + +* `src` {[Readable][] Stream} The source stream that [unpiped][] this writable + +This is emitted whenever the [`unpipe()`][] method is called on a +readable stream, removing this writable from its set of destinations. + +```javascript +var writer = getWritableStreamSomehow(); +var reader = getReadableStreamSomehow(); +writer.on('unpipe', function(src) { + console.error('something has stopped piping into the writer'); + assert.equal(src, reader); +}); +reader.pipe(writer); +reader.unpipe(writer); +``` + +#### writable.cork() + +Forces buffering of all writes. + +Buffered data will be flushed either at `.uncork()` or at `.end()` call. + +#### writable.end([chunk][, encoding][, callback]) + +* `chunk` {String | Buffer} Optional data to write +* `encoding` {String} The encoding, if `chunk` is a String +* `callback` {Function} Optional callback for when the stream is finished + +Call this method when no more data will be written to the stream. If +supplied, the callback is attached as a listener on the `finish` event. + +Calling [`write()`][] after calling [`end()`][] will raise an error. + +```javascript +// write 'hello, ' and then end with 'world!' +var file = fs.createWriteStream('example.txt'); +file.write('hello, '); +file.end('world!'); +// writing more now is not allowed! +``` + +#### writable.setDefaultEncoding(encoding) + +* `encoding` {String} The new default encoding + +Sets the default encoding for a writable stream. + +#### writable.uncork() + +Flush all data, buffered since `.cork()` call. + +#### writable.write(chunk[, encoding][, callback]) + +* `chunk` {String | Buffer} The data to write +* `encoding` {String} The encoding, if `chunk` is a String +* `callback` {Function} Callback for when this chunk of data is flushed +* Returns: {Boolean} True if the data was handled completely. + +This method writes some data to the underlying system, and calls the +supplied callback once the data has been fully handled. + +The return value indicates if you should continue writing right now. +If the data had to be buffered internally, then it will return +`false`. Otherwise, it will return `true`. + +This return value is strictly advisory. You MAY continue to write, +even if it returns `false`. However, writes will be buffered in +memory, so it is best not to do this excessively. Instead, wait for +the `drain` event before writing more data. + + +## API for Stream Implementors + + + +To implement any sort of stream, the pattern is the same: + +1. Extend the appropriate parent class in your own subclass. (The + [`util.inherits`][] method is particularly helpful for this.) +2. Call the appropriate parent class constructor in your constructor, + to be sure that the internal mechanisms are set up properly. +2. Implement one or more specific methods, as detailed below. + +The class to extend and the method(s) to implement depend on the sort +of stream class you are writing: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +

    Use-case

    +
    +

    Class

    +
    +

    Method(s) to implement

    +
    +

    Reading only

    +
    +

    [Readable](#stream_class_stream_readable_1)

    +
    +

    [_read][]

    +
    +

    Writing only

    +
    +

    [Writable](#stream_class_stream_writable_1)

    +
    +

    [_write][], _writev

    +
    +

    Reading and writing

    +
    +

    [Duplex](#stream_class_stream_duplex_1)

    +
    +

    [_read][], [_write][], _writev

    +
    +

    Operate on written data, then read the result

    +
    +

    [Transform](#stream_class_stream_transform_1)

    +
    +

    _transform, _flush

    +
    + +In your implementation code, it is very important to never call the +methods described in [API for Stream Consumers][] above. Otherwise, you +can potentially cause adverse side effects in programs that consume +your streaming interfaces. + +### Class: stream.Duplex + + + +A "duplex" stream is one that is both Readable and Writable, such as a +TCP socket connection. + +Note that `stream.Duplex` is an abstract class designed to be extended +with an underlying implementation of the `_read(size)` and +[`_write(chunk, encoding, callback)`][] methods as you would with a +Readable or Writable stream class. + +Since JavaScript doesn't have multiple prototypal inheritance, this +class prototypally inherits from Readable, and then parasitically from +Writable. It is thus up to the user to implement both the lowlevel +`_read(n)` method as well as the lowlevel +[`_write(chunk, encoding, callback)`][] method on extension duplex classes. + +#### new stream.Duplex(options) + +* `options` {Object} Passed to both Writable and Readable + constructors. Also has the following fields: + * `allowHalfOpen` {Boolean} Default=true. If set to `false`, then + the stream will automatically end the readable side when the + writable side ends and vice versa. + * `readableObjectMode` {Boolean} Default=false. Sets `objectMode` + for readable side of the stream. Has no effect if `objectMode` + is `true`. + * `writableObjectMode` {Boolean} Default=false. Sets `objectMode` + for writable side of the stream. Has no effect if `objectMode` + is `true`. + +In classes that extend the Duplex class, make sure to call the +constructor so that the buffering settings can be properly +initialized. + +### Class: stream.PassThrough + +This is a trivial implementation of a [Transform][] stream that simply +passes the input bytes across to the output. Its purpose is mainly +for examples and testing, but there are occasionally use cases where +it can come in handy as a building block for novel sorts of streams. + +### Class: stream.Readable + + + +`stream.Readable` is an abstract class designed to be extended with an +underlying implementation of the [`_read(size)`][] method. + +Please see above under [API for Stream Consumers][] for how to consume +streams in your programs. What follows is an explanation of how to +implement Readable streams in your programs. + +#### new stream.Readable([options]) + +* `options` {Object} + * `highWaterMark` {Number} The maximum number of bytes to store in + the internal buffer before ceasing to read from the underlying + resource. Default=16kb, or 16 for `objectMode` streams + * `encoding` {String} If specified, then buffers will be decoded to + strings using the specified encoding. Default=null + * `objectMode` {Boolean} Whether this stream should behave + as a stream of objects. Meaning that stream.read(n) returns + a single value instead of a Buffer of size n. Default=false + +In classes that extend the Readable class, make sure to call the +Readable constructor so that the buffering settings can be properly +initialized. + +#### readable.\_read(size) + +* `size` {Number} Number of bytes to read asynchronously + +Note: **Implement this method, but do NOT call it directly.** + +This method is prefixed with an underscore because it is internal to the +class that defines it and should only be called by the internal Readable +class methods. All Readable stream implementations must provide a _read +method to fetch data from the underlying resource. + +When _read is called, if data is available from the resource, `_read` should +start pushing that data into the read queue by calling `this.push(dataChunk)`. +`_read` should continue reading from the resource and pushing data until push +returns false, at which point it should stop reading from the resource. Only +when _read is called again after it has stopped should it start reading +more data from the resource and pushing that data onto the queue. + +Note: once the `_read()` method is called, it will not be called again until +the `push` method is called. + +The `size` argument is advisory. Implementations where a "read" is a +single call that returns data can use this to know how much data to +fetch. Implementations where that is not relevant, such as TCP or +TLS, may ignore this argument, and simply provide data whenever it +becomes available. There is no need, for example to "wait" until +`size` bytes are available before calling [`stream.push(chunk)`][]. + +#### readable.push(chunk[, encoding]) + +* `chunk` {Buffer | null | String} Chunk of data to push into the read queue +* `encoding` {String} Encoding of String chunks. Must be a valid + Buffer encoding, such as `'utf8'` or `'ascii'` +* return {Boolean} Whether or not more pushes should be performed + +Note: **This method should be called by Readable implementors, NOT +by consumers of Readable streams.** + +If a value other than null is passed, The `push()` method adds a chunk of data +into the queue for subsequent stream processors to consume. If `null` is +passed, it signals the end of the stream (EOF), after which no more data +can be written. + +The data added with `push` can be pulled out by calling the `read()` method +when the `'readable'`event fires. + +This API is designed to be as flexible as possible. For example, +you may be wrapping a lower-level source which has some sort of +pause/resume mechanism, and a data callback. In those cases, you +could wrap the low-level source object by doing something like this: + +```javascript +// source is an object with readStop() and readStart() methods, +// and an `ondata` member that gets called when it has data, and +// an `onend` member that gets called when the data is over. + +util.inherits(SourceWrapper, Readable); + +function SourceWrapper(options) { + Readable.call(this, options); + + this._source = getLowlevelSourceObject(); + var self = this; + + // Every time there's data, we push it into the internal buffer. + this._source.ondata = function(chunk) { + // if push() returns false, then we need to stop reading from source + if (!self.push(chunk)) + self._source.readStop(); + }; + + // When the source ends, we push the EOF-signaling `null` chunk + this._source.onend = function() { + self.push(null); + }; +} + +// _read will be called when the stream wants to pull more data in +// the advisory size argument is ignored in this case. +SourceWrapper.prototype._read = function(size) { + this._source.readStart(); +}; +``` + +#### Example: A Counting Stream + + + +This is a basic example of a Readable stream. It emits the numerals +from 1 to 1,000,000 in ascending order, and then ends. + +```javascript +var Readable = require('stream').Readable; +var util = require('util'); +util.inherits(Counter, Readable); + +function Counter(opt) { + Readable.call(this, opt); + this._max = 1000000; + this._index = 1; +} + +Counter.prototype._read = function() { + var i = this._index++; + if (i > this._max) + this.push(null); + else { + var str = '' + i; + var buf = new Buffer(str, 'ascii'); + this.push(buf); + } +}; +``` + +#### Example: SimpleProtocol v1 (Sub-optimal) + +This is similar to the `parseHeader` function described above, but +implemented as a custom stream. Also, note that this implementation +does not convert the incoming data to a string. + +However, this would be better implemented as a [Transform][] stream. See +below for a better implementation. + +```javascript +// A parser for a simple data protocol. +// The "header" is a JSON object, followed by 2 \n characters, and +// then a message body. +// +// NOTE: This can be done more simply as a Transform stream! +// Using Readable directly for this is sub-optimal. See the +// alternative example below under the Transform section. + +var Readable = require('stream').Readable; +var util = require('util'); + +util.inherits(SimpleProtocol, Readable); + +function SimpleProtocol(source, options) { + if (!(this instanceof SimpleProtocol)) + return new SimpleProtocol(source, options); + + Readable.call(this, options); + this._inBody = false; + this._sawFirstCr = false; + + // source is a readable stream, such as a socket or file + this._source = source; + + var self = this; + source.on('end', function() { + self.push(null); + }); + + // give it a kick whenever the source is readable + // read(0) will not consume any bytes + source.on('readable', function() { + self.read(0); + }); + + this._rawHeader = []; + this.header = null; +} + +SimpleProtocol.prototype._read = function(n) { + if (!this._inBody) { + var chunk = this._source.read(); + + // if the source doesn't have data, we don't have data yet. + if (chunk === null) + return this.push(''); + + // check if the chunk has a \n\n + var split = -1; + for (var i = 0; i < chunk.length; i++) { + if (chunk[i] === 10) { // '\n' + if (this._sawFirstCr) { + split = i; + break; + } else { + this._sawFirstCr = true; + } + } else { + this._sawFirstCr = false; + } + } + + if (split === -1) { + // still waiting for the \n\n + // stash the chunk, and try again. + this._rawHeader.push(chunk); + this.push(''); + } else { + this._inBody = true; + var h = chunk.slice(0, split); + this._rawHeader.push(h); + var header = Buffer.concat(this._rawHeader).toString(); + try { + this.header = JSON.parse(header); + } catch (er) { + this.emit('error', new Error('invalid simple protocol data')); + return; + } + // now, because we got some extra data, unshift the rest + // back into the read queue so that our consumer will see it. + var b = chunk.slice(split); + this.unshift(b); + // calling unshift by itself does not reset the reading state + // of the stream; since we're inside _read, doing an additional + // push('') will reset the state appropriately. + this.push(''); + + // and let them know that we are done parsing the header. + this.emit('header', this.header); + } + } else { + // from there on, just provide the data to our consumer. + // careful not to push(null), since that would indicate EOF. + var chunk = this._source.read(); + if (chunk) this.push(chunk); + } +}; + +// Usage: +// var parser = new SimpleProtocol(source); +// Now parser is a readable stream that will emit 'header' +// with the parsed header data. +``` + +### Class: stream.Transform + +A "transform" stream is a duplex stream where the output is causally +connected in some way to the input, such as a [zlib][] stream or a +[crypto][] stream. + +There is no requirement that the output be the same size as the input, +the same number of chunks, or arrive at the same time. For example, a +Hash stream will only ever have a single chunk of output which is +provided when the input is ended. A zlib stream will produce output +that is either much smaller or much larger than its input. + +Rather than implement the [`_read()`][] and [`_write()`][] methods, Transform +classes must implement the `_transform()` method, and may optionally +also implement the `_flush()` method. (See below.) + +#### new stream.Transform([options]) + +* `options` {Object} Passed to both Writable and Readable + constructors. + +In classes that extend the Transform class, make sure to call the +constructor so that the buffering settings can be properly +initialized. + +#### Events: 'finish' and 'end' + +The [`finish`][] and [`end`][] events are from the parent Writable +and Readable classes respectively. The `finish` event is fired after +`.end()` is called and all chunks have been processed by `_transform`, +`end` is fired after all data has been output which is after the callback +in `_flush` has been called. + +#### transform.\_flush(callback) + +* `callback` {Function} Call this function (optionally with an error + argument) when you are done flushing any remaining data. + +Note: **This function MUST NOT be called directly.** It MAY be implemented +by child classes, and if so, will be called by the internal Transform +class methods only. + +In some cases, your transform operation may need to emit a bit more +data at the end of the stream. For example, a `Zlib` compression +stream will store up some internal state so that it can optimally +compress the output. At the end, however, it needs to do the best it +can with what is left, so that the data will be complete. + +In those cases, you can implement a `_flush` method, which will be +called at the very end, after all the written data is consumed, but +before emitting `end` to signal the end of the readable side. Just +like with `_transform`, call `transform.push(chunk)` zero or more +times, as appropriate, and call `callback` when the flush operation is +complete. + +This method is prefixed with an underscore because it is internal to +the class that defines it, and should not be called directly by user +programs. However, you **are** expected to override this method in +your own extension classes. + +#### transform.\_transform(chunk, encoding, callback) + +* `chunk` {Buffer | String} The chunk to be transformed. Will **always** + be a buffer unless the `decodeStrings` option was set to `false`. +* `encoding` {String} If the chunk is a string, then this is the + encoding type. If chunk is a buffer, then this is the special + value - 'buffer', ignore it in this case. +* `callback` {Function} Call this function (optionally with an error + argument and data) when you are done processing the supplied chunk. + +Note: **This function MUST NOT be called directly.** It should be +implemented by child classes, and called by the internal Transform +class methods only. + +All Transform stream implementations must provide a `_transform` +method to accept input and produce output. + +`_transform` should do whatever has to be done in this specific +Transform class, to handle the bytes being written, and pass them off +to the readable portion of the interface. Do asynchronous I/O, +process things, and so on. + +Call `transform.push(outputChunk)` 0 or more times to generate output +from this input chunk, depending on how much data you want to output +as a result of this chunk. + +Call the callback function only when the current chunk is completely +consumed. Note that there may or may not be output as a result of any +particular input chunk. If you supply a second argument to the callback +it will be passed to the push method. In other words the following are +equivalent: + +```javascript +transform.prototype._transform = function (data, encoding, callback) { + this.push(data); + callback(); +}; + +transform.prototype._transform = function (data, encoding, callback) { + callback(null, data); +}; +``` + +This method is prefixed with an underscore because it is internal to +the class that defines it, and should not be called directly by user +programs. However, you **are** expected to override this method in +your own extension classes. + +#### Example: `SimpleProtocol` parser v2 + +The example above of a simple protocol parser can be implemented +simply by using the higher level [Transform][] stream class, similar to +the `parseHeader` and `SimpleProtocol v1` examples above. + +In this example, rather than providing the input as an argument, it +would be piped into the parser, which is a more idiomatic Node.js stream +approach. + +```javascript +var util = require('util'); +var Transform = require('stream').Transform; +util.inherits(SimpleProtocol, Transform); + +function SimpleProtocol(options) { + if (!(this instanceof SimpleProtocol)) + return new SimpleProtocol(options); + + Transform.call(this, options); + this._inBody = false; + this._sawFirstCr = false; + this._rawHeader = []; + this.header = null; +} + +SimpleProtocol.prototype._transform = function(chunk, encoding, done) { + if (!this._inBody) { + // check if the chunk has a \n\n + var split = -1; + for (var i = 0; i < chunk.length; i++) { + if (chunk[i] === 10) { // '\n' + if (this._sawFirstCr) { + split = i; + break; + } else { + this._sawFirstCr = true; + } + } else { + this._sawFirstCr = false; + } + } + + if (split === -1) { + // still waiting for the \n\n + // stash the chunk, and try again. + this._rawHeader.push(chunk); + } else { + this._inBody = true; + var h = chunk.slice(0, split); + this._rawHeader.push(h); + var header = Buffer.concat(this._rawHeader).toString(); + try { + this.header = JSON.parse(header); + } catch (er) { + this.emit('error', new Error('invalid simple protocol data')); + return; + } + // and let them know that we are done parsing the header. + this.emit('header', this.header); + + // now, because we got some extra data, emit this first. + this.push(chunk.slice(split)); + } + } else { + // from there on, just provide the data to our consumer as-is. + this.push(chunk); + } + done(); +}; + +// Usage: +// var parser = new SimpleProtocol(); +// source.pipe(parser) +// Now parser is a readable stream that will emit 'header' +// with the parsed header data. +``` + +### Class: stream.Writable + + + +`stream.Writable` is an abstract class designed to be extended with an +underlying implementation of the [`_write(chunk, encoding, callback)`][] method. + +Please see above under [API for Stream Consumers][] for how to consume +writable streams in your programs. What follows is an explanation of +how to implement Writable streams in your programs. + +#### new stream.Writable([options]) + +* `options` {Object} + * `highWaterMark` {Number} Buffer level when [`write()`][] starts + returning false. Default=16kb, or 16 for `objectMode` streams + * `decodeStrings` {Boolean} Whether or not to decode strings into + Buffers before passing them to [`_write()`][]. Default=true + * `objectMode` {Boolean} Whether or not the `write(anyObj)` is + a valid operation. If set you can write arbitrary data instead + of only `Buffer` / `String` data. Default=false + +In classes that extend the Writable class, make sure to call the +constructor so that the buffering settings can be properly +initialized. + +#### writable.\_write(chunk, encoding, callback) + +* `chunk` {Buffer | String} The chunk to be written. Will **always** + be a buffer unless the `decodeStrings` option was set to `false`. +* `encoding` {String} If the chunk is a string, then this is the + encoding type. If chunk is a buffer, then this is the special + value - 'buffer', ignore it in this case. +* `callback` {Function} Call this function (optionally with an error + argument) when you are done processing the supplied chunk. + +All Writable stream implementations must provide a [`_write()`][] +method to send data to the underlying resource. + +Note: **This function MUST NOT be called directly.** It should be +implemented by child classes, and called by the internal Writable +class methods only. + +Call the callback using the standard `callback(error)` pattern to +signal that the write completed successfully or with an error. + +If the `decodeStrings` flag is set in the constructor options, then +`chunk` may be a string rather than a Buffer, and `encoding` will +indicate the sort of string that it is. This is to support +implementations that have an optimized handling for certain string +data encodings. If you do not explicitly set the `decodeStrings` +option to `false`, then you can safely ignore the `encoding` argument, +and assume that `chunk` will always be a Buffer. + +This method is prefixed with an underscore because it is internal to +the class that defines it, and should not be called directly by user +programs. However, you **are** expected to override this method in +your own extension classes. + +#### writable.\_writev(chunks, callback) + +* `chunks` {Array} The chunks to be written. Each chunk has following + format: `{ chunk: ..., encoding: ... }`. +* `callback` {Function} Call this function (optionally with an error + argument) when you are done processing the supplied chunks. + +Note: **This function MUST NOT be called directly.** It may be +implemented by child classes, and called by the internal Writable +class methods only. + +This function is completely optional to implement. In most cases it is +unnecessary. If implemented, it will be called with all the chunks +that are buffered in the write queue. + + +## Simplified Constructor API + + + +In simple cases there is now the added benefit of being able to construct a stream without inheritance. + +This can be done by passing the appropriate methods as constructor options: + +Examples: + +### Duplex +```javascript +var duplex = new stream.Duplex({ + read: function(n) { + // sets this._read under the hood + + // push data onto the read queue, passing null + // will signal the end of the stream (EOF) + this.push(chunk); + }, + write: function(chunk, encoding, next) { + // sets this._write under the hood + + // An optional error can be passed as the first argument + next() + } +}); + +// or + +var duplex = new stream.Duplex({ + read: function(n) { + // sets this._read under the hood + + // push data onto the read queue, passing null + // will signal the end of the stream (EOF) + this.push(chunk); + }, + writev: function(chunks, next) { + // sets this._writev under the hood + + // An optional error can be passed as the first argument + next() + } +}); +``` + +### Readable +```javascript +var readable = new stream.Readable({ + read: function(n) { + // sets this._read under the hood + + // push data onto the read queue, passing null + // will signal the end of the stream (EOF) + this.push(chunk); + } +}); +``` + +### Transform +```javascript +var transform = new stream.Transform({ + transform: function(chunk, encoding, next) { + // sets this._transform under the hood + + // generate output as many times as needed + // this.push(chunk); + + // call when the current chunk is consumed + next(); + }, + flush: function(done) { + // sets this._flush under the hood + + // generate output as many times as needed + // this.push(chunk); + + done(); + } +}); +``` + +### Writable +```javascript +var writable = new stream.Writable({ + write: function(chunk, encoding, next) { + // sets this._write under the hood + + // An optional error can be passed as the first argument + next() + } +}); + +// or + +var writable = new stream.Writable({ + writev: function(chunks, next) { + // sets this._writev under the hood + + // An optional error can be passed as the first argument + next() + } +}); +``` + +## Streams: Under the Hood + + + +### Buffering + + + +Both Writable and Readable streams will buffer data on an internal +object which can be retrieved from `_writableState.getBuffer()` or +`_readableState.buffer`, respectively. + +The amount of data that will potentially be buffered depends on the +`highWaterMark` option which is passed into the constructor. + +Buffering in Readable streams happens when the implementation calls +[`stream.push(chunk)`][]. If the consumer of the Stream does not call +`stream.read()`, then the data will sit in the internal queue until it +is consumed. + +Buffering in Writable streams happens when the user calls +[`stream.write(chunk)`][] repeatedly, even when `write()` returns `false`. + +The purpose of streams, especially with the `pipe()` method, is to +limit the buffering of data to acceptable levels, so that sources and +destinations of varying speed will not overwhelm the available memory. + +### Compatibility with Older Node.js Versions + + + +In versions of Node.js prior to v0.10, the Readable stream interface was +simpler, but also less powerful and less useful. + +* Rather than waiting for you to call the `read()` method, `'data'` + events would start emitting immediately. If you needed to do some + I/O to decide how to handle data, then you had to store the chunks + in some kind of buffer so that they would not be lost. +* The [`pause()`][] method was advisory, rather than guaranteed. This + meant that you still had to be prepared to receive `'data'` events + even when the stream was in a paused state. + +In Node.js v0.10, the Readable class described below was added. +For backwards compatibility with older Node.js programs, Readable streams +switch into "flowing mode" when a `'data'` event handler is added, or +when the [`resume()`][] method is called. The effect is that, even if +you are not using the new `read()` method and `'readable'` event, you +no longer have to worry about losing `'data'` chunks. + +Most programs will continue to function normally. However, this +introduces an edge case in the following conditions: + +* No [`'data'` event][] handler is added. +* The [`resume()`][] method is never called. +* The stream is not piped to any writable destination. + +For example, consider the following code: + +```javascript +// WARNING! BROKEN! +net.createServer(function(socket) { + + // we add an 'end' method, but never consume the data + socket.on('end', function() { + // It will never get here. + socket.end('I got your message (but didnt read it)\n'); + }); + +}).listen(1337); +``` + +In versions of Node.js prior to v0.10, the incoming message data would be +simply discarded. However, in Node.js v0.10 and beyond, +the socket will remain paused forever. + +The workaround in this situation is to call the `resume()` method to +start the flow of data: + +```javascript +// Workaround +net.createServer(function(socket) { + + socket.on('end', function() { + socket.end('I got your message (but didnt read it)\n'); + }); + + // start the flow of data, discarding it. + socket.resume(); + +}).listen(1337); +``` + +In addition to new Readable streams switching into flowing mode, +pre-v0.10 style streams can be wrapped in a Readable class using the +`wrap()` method. + + +### Object Mode + + + +Normally, Streams operate on Strings and Buffers exclusively. + +Streams that are in **object mode** can emit generic JavaScript values +other than Buffers and Strings. + +A Readable stream in object mode will always return a single item from +a call to `stream.read(size)`, regardless of what the size argument +is. + +A Writable stream in object mode will always ignore the `encoding` +argument to `stream.write(data, encoding)`. + +The special value `null` still retains its special value for object +mode streams. That is, for object mode readable streams, `null` as a +return value from `stream.read()` indicates that there is no more +data, and [`stream.push(null)`][] will signal the end of stream data +(`EOF`). + +No streams in Node.js core are object mode streams. This pattern is only +used by userland streaming libraries. + +You should set `objectMode` in your stream child class constructor on +the options object. Setting `objectMode` mid-stream is not safe. + +For Duplex streams `objectMode` can be set exclusively for readable or +writable side with `readableObjectMode` and `writableObjectMode` +respectively. These options can be used to implement parsers and +serializers with Transform streams. + +```javascript +var util = require('util'); +var StringDecoder = require('string_decoder').StringDecoder; +var Transform = require('stream').Transform; +util.inherits(JSONParseStream, Transform); + +// Gets \n-delimited JSON string data, and emits the parsed objects +function JSONParseStream() { + if (!(this instanceof JSONParseStream)) + return new JSONParseStream(); + + Transform.call(this, { readableObjectMode : true }); + + this._buffer = ''; + this._decoder = new StringDecoder('utf8'); +} + +JSONParseStream.prototype._transform = function(chunk, encoding, cb) { + this._buffer += this._decoder.write(chunk); + // split on newlines + var lines = this._buffer.split(/\r?\n/); + // keep the last partial line buffered + this._buffer = lines.pop(); + for (var l = 0; l < lines.length; l++) { + var line = lines[l]; + try { + var obj = JSON.parse(line); + } catch (er) { + this.emit('error', er); + return; + } + // push the parsed object out to the readable consumer + this.push(obj); + } + cb(); +}; + +JSONParseStream.prototype._flush = function(cb) { + // Just handle any leftover + var rem = this._buffer.trim(); + if (rem) { + try { + var obj = JSON.parse(rem); + } catch (er) { + this.emit('error', er); + return; + } + // push the parsed object out to the readable consumer + this.push(obj); + } + cb(); +}; +``` + +### `stream.read(0)` + +There are some cases where you want to trigger a refresh of the +underlying readable stream mechanisms, without actually consuming any +data. In that case, you can call `stream.read(0)`, which will always +return null. + +If the internal read buffer is below the `highWaterMark`, and the +stream is not currently reading, then calling `read(0)` will trigger +a low-level `_read` call. + +There is almost never a need to do this. However, you will see some +cases in Node.js's internals where this is done, particularly in the +Readable stream class internals. + +### `stream.push('')` + +Pushing a zero-byte string or Buffer (when not in [Object mode][]) has an +interesting side effect. Because it *is* a call to +[`stream.push()`][], it will end the `reading` process. However, it +does *not* add any data to the readable buffer, so there's nothing for +a user to consume. + +Very rarely, there are cases where you have no data to provide now, +but the consumer of your stream (or, perhaps, another bit of your own +code) will know when to check again, by calling `stream.read(0)`. In +those cases, you *may* call `stream.push('')`. + +So far, the only use case for this functionality is in the +[tls.CryptoStream][] class, which is deprecated in Node.js/io.js v1.0. If you +find that you have to use `stream.push('')`, please consider another +approach, because it almost certainly indicates that something is +horribly wrong. + +[request to an HTTP server]: https://nodejs.org/docs/v5.1.0/api/http.html#http_http_incomingmessage +[EventEmitter]: https://nodejs.org/docs/v5.1.0/api/events.html#events_class_events_eventemitter +[Object mode]: #stream_object_mode +[`stream.push(chunk)`]: #stream_readable_push_chunk_encoding +[`stream.push(null)`]: #stream_readable_push_chunk_encoding +[`stream.push()`]: #stream_readable_push_chunk_encoding +[`unpipe()`]: #stream_readable_unpipe_destination +[unpiped]: #stream_readable_unpipe_destination +[tcp sockets]: https://nodejs.org/docs/v5.1.0/api/net.html#net_class_net_socket +[http responses, on the client]: https://nodejs.org/docs/v5.1.0/api/http.html#http_http_incomingmessage +[http requests, on the server]: https://nodejs.org/docs/v5.1.0/api/http.html#http_http_incomingmessage +[http requests, on the client]: https://nodejs.org/docs/v5.1.0/api/http.html#http_class_http_clientrequest +[http responses, on the server]: https://nodejs.org/docs/v5.1.0/api/http.html#http_class_http_serverresponse +[fs read streams]: https://nodejs.org/docs/v5.1.0/api/fs.html#fs_class_fs_readstream +[fs write streams]: https://nodejs.org/docs/v5.1.0/api/fs.html#fs_class_fs_writestream +[zlib streams]: zlib.html +[zlib]: zlib.html +[crypto streams]: crypto.html +[crypto]: crypto.html +[tls.CryptoStream]: https://nodejs.org/docs/v5.1.0/api/tls.html#tls_class_cryptostream +[process.stdin]: https://nodejs.org/docs/v5.1.0/api/process.html#process_process_stdin +[stdout]: https://nodejs.org/docs/v5.1.0/api/process.html#process_process_stdout +[process.stdout]: https://nodejs.org/docs/v5.1.0/api/process.html#process_process_stdout +[process.stderr]: https://nodejs.org/docs/v5.1.0/api/process.html#process_process_stderr +[child process stdout and stderr]: https://nodejs.org/docs/v5.1.0/api/child_process.html#child_process_child_stdout +[child process stdin]: https://nodejs.org/docs/v5.1.0/api/child_process.html#child_process_child_stdin +[API for Stream Consumers]: #stream_api_for_stream_consumers +[API for Stream Implementors]: #stream_api_for_stream_implementors +[Readable]: #stream_class_stream_readable +[Writable]: #stream_class_stream_writable +[Duplex]: #stream_class_stream_duplex +[Transform]: #stream_class_stream_transform +[`end`]: #stream_event_end +[`finish`]: #stream_event_finish +[`_read(size)`]: #stream_readable_read_size_1 +[`_read()`]: #stream_readable_read_size_1 +[_read]: #stream_readable_read_size_1 +[`writable.write(chunk)`]: #stream_writable_write_chunk_encoding_callback +[`write(chunk, encoding, callback)`]: #stream_writable_write_chunk_encoding_callback +[`write()`]: #stream_writable_write_chunk_encoding_callback +[`stream.write(chunk)`]: #stream_writable_write_chunk_encoding_callback +[`_write(chunk, encoding, callback)`]: #stream_writable_write_chunk_encoding_callback_1 +[`_write()`]: #stream_writable_write_chunk_encoding_callback_1 +[_write]: #stream_writable_write_chunk_encoding_callback_1 +[`util.inherits`]: https://nodejs.org/docs/v5.1.0/api/util.html#util_util_inherits_constructor_superconstructor +[`end()`]: #stream_writable_end_chunk_encoding_callback +[`'data'` event]: #stream_event_data +[`resume()`]: #stream_readable_resume +[`readable.resume()`]: #stream_readable_resume +[`pause()`]: #stream_readable_pause +[`unpipe()`]: #stream_readable_unpipe_destination +[`pipe()`]: #stream_readable_pipe_destination_options diff --git a/tools/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md b/tools/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md new file mode 100644 index 00000000000000..83275f192e4077 --- /dev/null +++ b/tools/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md @@ -0,0 +1,60 @@ +# streams WG Meeting 2015-01-30 + +## Links + +* **Google Hangouts Video**: http://www.youtube.com/watch?v=I9nDOSGfwZg +* **GitHub Issue**: https://github.com/iojs/readable-stream/issues/106 +* **Original Minutes Google Doc**: https://docs.google.com/document/d/17aTgLnjMXIrfjgNaTUnHQO7m3xgzHR2VXBTmi03Qii4/ + +## Agenda + +Extracted from https://github.com/iojs/readable-stream/labels/wg-agenda prior to meeting. + +* adopt a charter [#105](https://github.com/iojs/readable-stream/issues/105) +* release and versioning strategy [#101](https://github.com/iojs/readable-stream/issues/101) +* simpler stream creation [#102](https://github.com/iojs/readable-stream/issues/102) +* proposal: deprecate implicit flowing of streams [#99](https://github.com/iojs/readable-stream/issues/99) + +## Minutes + +### adopt a charter + +* group: +1's all around + +### What versioning scheme should be adopted? +* group: +1’s 3.0.0 +* domenic+group: pulling in patches from other sources where appropriate +* mikeal: version independently, suggesting versions for io.js +* mikeal+domenic: work with TC to notify in advance of changes +simpler stream creation + +### streamline creation of streams +* sam: streamline creation of streams +* domenic: nice simple solution posted + but, we lose the opportunity to change the model + may not be backwards incompatible (double check keys) + + **action item:** domenic will check + +### remove implicit flowing of streams on(‘data’) +* add isFlowing / isPaused +* mikeal: worrying that we’re documenting polyfill methods – confuses users +* domenic: more reflective API is probably good, with warning labels for users +* new section for mad scientists (reflective stream access) +* calvin: name the “third state” +* mikeal: maybe borrow the name from whatwg? +* domenic: we’re missing the “third state” +* consensus: kind of difficult to name the third state +* mikeal: figure out differences in states / compat +* mathias: always flow on data – eliminates third state + * explore what it breaks + +**action items:** +* ask isaac for ability to list packages by what public io.js APIs they use (esp. Stream) +* ask rod/build for infrastructure +* **chris**: explore the “flow on data” approach +* add isPaused/isFlowing +* add new docs section +* move isPaused to that section + + diff --git a/tools/node_modules/readable-stream/duplex.js b/tools/node_modules/readable-stream/duplex.js new file mode 100644 index 00000000000000..ca807af87620dd --- /dev/null +++ b/tools/node_modules/readable-stream/duplex.js @@ -0,0 +1 @@ +module.exports = require("./lib/_stream_duplex.js") diff --git a/tools/node_modules/readable-stream/lib/_stream_duplex.js b/tools/node_modules/readable-stream/lib/_stream_duplex.js new file mode 100644 index 00000000000000..69558af037cd66 --- /dev/null +++ b/tools/node_modules/readable-stream/lib/_stream_duplex.js @@ -0,0 +1,82 @@ +// a duplex stream is just a stream that is both readable and writable. +// Since JS doesn't have multiple prototypal inheritance, this class +// prototypally inherits from Readable, and then parasitically from +// Writable. + +'use strict'; + +/**/ +var objectKeys = Object.keys || function (obj) { + var keys = []; + for (var key in obj) keys.push(key); + return keys; +} +/**/ + + +module.exports = Duplex; + +/**/ +var processNextTick = require('process-nextick-args'); +/**/ + + + +/**/ +var util = require('core-util-is'); +util.inherits = require('inherits'); +/**/ + +var Readable = require('./_stream_readable'); +var Writable = require('./_stream_writable'); + +util.inherits(Duplex, Readable); + +var keys = objectKeys(Writable.prototype); +for (var v = 0; v < keys.length; v++) { + var method = keys[v]; + if (!Duplex.prototype[method]) + Duplex.prototype[method] = Writable.prototype[method]; +} + +function Duplex(options) { + if (!(this instanceof Duplex)) + return new Duplex(options); + + Readable.call(this, options); + Writable.call(this, options); + + if (options && options.readable === false) + this.readable = false; + + if (options && options.writable === false) + this.writable = false; + + this.allowHalfOpen = true; + if (options && options.allowHalfOpen === false) + this.allowHalfOpen = false; + + this.once('end', onend); +} + +// the no-half-open enforcer +function onend() { + // if we allow half-open state, or if the writable side ended, + // then we're ok. + if (this.allowHalfOpen || this._writableState.ended) + return; + + // no more data can be written. + // But allow more writes to happen in this tick. + processNextTick(onEndNT, this); +} + +function onEndNT(self) { + self.end(); +} + +function forEach (xs, f) { + for (var i = 0, l = xs.length; i < l; i++) { + f(xs[i], i); + } +} diff --git a/tools/node_modules/readable-stream/lib/_stream_passthrough.js b/tools/node_modules/readable-stream/lib/_stream_passthrough.js new file mode 100644 index 00000000000000..bddfdd01537a40 --- /dev/null +++ b/tools/node_modules/readable-stream/lib/_stream_passthrough.js @@ -0,0 +1,27 @@ +// a passthrough stream. +// basically just the most minimal sort of Transform stream. +// Every written chunk gets output as-is. + +'use strict'; + +module.exports = PassThrough; + +var Transform = require('./_stream_transform'); + +/**/ +var util = require('core-util-is'); +util.inherits = require('inherits'); +/**/ + +util.inherits(PassThrough, Transform); + +function PassThrough(options) { + if (!(this instanceof PassThrough)) + return new PassThrough(options); + + Transform.call(this, options); +} + +PassThrough.prototype._transform = function(chunk, encoding, cb) { + cb(null, chunk); +}; diff --git a/tools/node_modules/readable-stream/lib/_stream_readable.js b/tools/node_modules/readable-stream/lib/_stream_readable.js new file mode 100644 index 00000000000000..50852aee7e6e02 --- /dev/null +++ b/tools/node_modules/readable-stream/lib/_stream_readable.js @@ -0,0 +1,975 @@ +'use strict'; + +module.exports = Readable; + +/**/ +var processNextTick = require('process-nextick-args'); +/**/ + + +/**/ +var isArray = require('isarray'); +/**/ + + +/**/ +var Buffer = require('buffer').Buffer; +/**/ + +Readable.ReadableState = ReadableState; + +var EE = require('events'); + +/**/ +var EElistenerCount = function(emitter, type) { + return emitter.listeners(type).length; +}; +/**/ + + + +/**/ +var Stream; +(function (){try{ + Stream = require('st' + 'ream'); +}catch(_){}finally{ + if (!Stream) + Stream = require('events').EventEmitter; +}}()) +/**/ + +var Buffer = require('buffer').Buffer; + +/**/ +var util = require('core-util-is'); +util.inherits = require('inherits'); +/**/ + + + +/**/ +var debugUtil = require('util'); +var debug; +if (debugUtil && debugUtil.debuglog) { + debug = debugUtil.debuglog('stream'); +} else { + debug = function () {}; +} +/**/ + +var StringDecoder; + +util.inherits(Readable, Stream); + +var Duplex; +function ReadableState(options, stream) { + Duplex = Duplex || require('./_stream_duplex'); + + options = options || {}; + + // object stream flag. Used to make read(n) ignore n and to + // make all the buffer merging and length checks go away + this.objectMode = !!options.objectMode; + + if (stream instanceof Duplex) + this.objectMode = this.objectMode || !!options.readableObjectMode; + + // the point at which it stops calling _read() to fill the buffer + // Note: 0 is a valid value, means "don't call _read preemptively ever" + var hwm = options.highWaterMark; + var defaultHwm = this.objectMode ? 16 : 16 * 1024; + this.highWaterMark = (hwm || hwm === 0) ? hwm : defaultHwm; + + // cast to ints. + this.highWaterMark = ~~this.highWaterMark; + + this.buffer = []; + this.length = 0; + this.pipes = null; + this.pipesCount = 0; + this.flowing = null; + this.ended = false; + this.endEmitted = false; + this.reading = false; + + // a flag to be able to tell if the onwrite cb is called immediately, + // or on a later tick. We set this to true at first, because any + // actions that shouldn't happen until "later" should generally also + // not happen before the first write call. + this.sync = true; + + // whenever we return null, then we set a flag to say + // that we're awaiting a 'readable' event emission. + this.needReadable = false; + this.emittedReadable = false; + this.readableListening = false; + + // Crypto is kind of old and crusty. Historically, its default string + // encoding is 'binary' so we have to make this configurable. + // Everything else in the universe uses 'utf8', though. + this.defaultEncoding = options.defaultEncoding || 'utf8'; + + // when piping, we only care about 'readable' events that happen + // after read()ing all the bytes and not getting any pushback. + this.ranOut = false; + + // the number of writers that are awaiting a drain event in .pipe()s + this.awaitDrain = 0; + + // if true, a maybeReadMore has been scheduled + this.readingMore = false; + + this.decoder = null; + this.encoding = null; + if (options.encoding) { + if (!StringDecoder) + StringDecoder = require('string_decoder/').StringDecoder; + this.decoder = new StringDecoder(options.encoding); + this.encoding = options.encoding; + } +} + +var Duplex; +function Readable(options) { + Duplex = Duplex || require('./_stream_duplex'); + + if (!(this instanceof Readable)) + return new Readable(options); + + this._readableState = new ReadableState(options, this); + + // legacy + this.readable = true; + + if (options && typeof options.read === 'function') + this._read = options.read; + + Stream.call(this); +} + +// Manually shove something into the read() buffer. +// This returns true if the highWaterMark has not been hit yet, +// similar to how Writable.write() returns true if you should +// write() some more. +Readable.prototype.push = function(chunk, encoding) { + var state = this._readableState; + + if (!state.objectMode && typeof chunk === 'string') { + encoding = encoding || state.defaultEncoding; + if (encoding !== state.encoding) { + chunk = new Buffer(chunk, encoding); + encoding = ''; + } + } + + return readableAddChunk(this, state, chunk, encoding, false); +}; + +// Unshift should *always* be something directly out of read() +Readable.prototype.unshift = function(chunk) { + var state = this._readableState; + return readableAddChunk(this, state, chunk, '', true); +}; + +Readable.prototype.isPaused = function() { + return this._readableState.flowing === false; +}; + +function readableAddChunk(stream, state, chunk, encoding, addToFront) { + var er = chunkInvalid(state, chunk); + if (er) { + stream.emit('error', er); + } else if (chunk === null) { + state.reading = false; + onEofChunk(stream, state); + } else if (state.objectMode || chunk && chunk.length > 0) { + if (state.ended && !addToFront) { + var e = new Error('stream.push() after EOF'); + stream.emit('error', e); + } else if (state.endEmitted && addToFront) { + var e = new Error('stream.unshift() after end event'); + stream.emit('error', e); + } else { + if (state.decoder && !addToFront && !encoding) + chunk = state.decoder.write(chunk); + + if (!addToFront) + state.reading = false; + + // if we want the data now, just emit it. + if (state.flowing && state.length === 0 && !state.sync) { + stream.emit('data', chunk); + stream.read(0); + } else { + // update the buffer info. + state.length += state.objectMode ? 1 : chunk.length; + if (addToFront) + state.buffer.unshift(chunk); + else + state.buffer.push(chunk); + + if (state.needReadable) + emitReadable(stream); + } + + maybeReadMore(stream, state); + } + } else if (!addToFront) { + state.reading = false; + } + + return needMoreData(state); +} + + +// if it's past the high water mark, we can push in some more. +// Also, if we have no data yet, we can stand some +// more bytes. This is to work around cases where hwm=0, +// such as the repl. Also, if the push() triggered a +// readable event, and the user called read(largeNumber) such that +// needReadable was set, then we ought to push more, so that another +// 'readable' event will be triggered. +function needMoreData(state) { + return !state.ended && + (state.needReadable || + state.length < state.highWaterMark || + state.length === 0); +} + +// backwards compatibility. +Readable.prototype.setEncoding = function(enc) { + if (!StringDecoder) + StringDecoder = require('string_decoder/').StringDecoder; + this._readableState.decoder = new StringDecoder(enc); + this._readableState.encoding = enc; + return this; +}; + +// Don't raise the hwm > 8MB +var MAX_HWM = 0x800000; +function computeNewHighWaterMark(n) { + if (n >= MAX_HWM) { + n = MAX_HWM; + } else { + // Get the next highest power of 2 + n--; + n |= n >>> 1; + n |= n >>> 2; + n |= n >>> 4; + n |= n >>> 8; + n |= n >>> 16; + n++; + } + return n; +} + +function howMuchToRead(n, state) { + if (state.length === 0 && state.ended) + return 0; + + if (state.objectMode) + return n === 0 ? 0 : 1; + + if (n === null || isNaN(n)) { + // only flow one buffer at a time + if (state.flowing && state.buffer.length) + return state.buffer[0].length; + else + return state.length; + } + + if (n <= 0) + return 0; + + // If we're asking for more than the target buffer level, + // then raise the water mark. Bump up to the next highest + // power of 2, to prevent increasing it excessively in tiny + // amounts. + if (n > state.highWaterMark) + state.highWaterMark = computeNewHighWaterMark(n); + + // don't have that much. return null, unless we've ended. + if (n > state.length) { + if (!state.ended) { + state.needReadable = true; + return 0; + } else { + return state.length; + } + } + + return n; +} + +// you can override either this method, or the async _read(n) below. +Readable.prototype.read = function(n) { + debug('read', n); + var state = this._readableState; + var nOrig = n; + + if (typeof n !== 'number' || n > 0) + state.emittedReadable = false; + + // if we're doing read(0) to trigger a readable event, but we + // already have a bunch of data in the buffer, then just trigger + // the 'readable' event and move on. + if (n === 0 && + state.needReadable && + (state.length >= state.highWaterMark || state.ended)) { + debug('read: emitReadable', state.length, state.ended); + if (state.length === 0 && state.ended) + endReadable(this); + else + emitReadable(this); + return null; + } + + n = howMuchToRead(n, state); + + // if we've ended, and we're now clear, then finish it up. + if (n === 0 && state.ended) { + if (state.length === 0) + endReadable(this); + return null; + } + + // All the actual chunk generation logic needs to be + // *below* the call to _read. The reason is that in certain + // synthetic stream cases, such as passthrough streams, _read + // may be a completely synchronous operation which may change + // the state of the read buffer, providing enough data when + // before there was *not* enough. + // + // So, the steps are: + // 1. Figure out what the state of things will be after we do + // a read from the buffer. + // + // 2. If that resulting state will trigger a _read, then call _read. + // Note that this may be asynchronous, or synchronous. Yes, it is + // deeply ugly to write APIs this way, but that still doesn't mean + // that the Readable class should behave improperly, as streams are + // designed to be sync/async agnostic. + // Take note if the _read call is sync or async (ie, if the read call + // has returned yet), so that we know whether or not it's safe to emit + // 'readable' etc. + // + // 3. Actually pull the requested chunks out of the buffer and return. + + // if we need a readable event, then we need to do some reading. + var doRead = state.needReadable; + debug('need readable', doRead); + + // if we currently have less than the highWaterMark, then also read some + if (state.length === 0 || state.length - n < state.highWaterMark) { + doRead = true; + debug('length less than watermark', doRead); + } + + // however, if we've ended, then there's no point, and if we're already + // reading, then it's unnecessary. + if (state.ended || state.reading) { + doRead = false; + debug('reading or ended', doRead); + } + + if (doRead) { + debug('do read'); + state.reading = true; + state.sync = true; + // if the length is currently zero, then we *need* a readable event. + if (state.length === 0) + state.needReadable = true; + // call internal read method + this._read(state.highWaterMark); + state.sync = false; + } + + // If _read pushed data synchronously, then `reading` will be false, + // and we need to re-evaluate how much data we can return to the user. + if (doRead && !state.reading) + n = howMuchToRead(nOrig, state); + + var ret; + if (n > 0) + ret = fromList(n, state); + else + ret = null; + + if (ret === null) { + state.needReadable = true; + n = 0; + } + + state.length -= n; + + // If we have nothing in the buffer, then we want to know + // as soon as we *do* get something into the buffer. + if (state.length === 0 && !state.ended) + state.needReadable = true; + + // If we tried to read() past the EOF, then emit end on the next tick. + if (nOrig !== n && state.ended && state.length === 0) + endReadable(this); + + if (ret !== null) + this.emit('data', ret); + + return ret; +}; + +function chunkInvalid(state, chunk) { + var er = null; + if (!(Buffer.isBuffer(chunk)) && + typeof chunk !== 'string' && + chunk !== null && + chunk !== undefined && + !state.objectMode) { + er = new TypeError('Invalid non-string/buffer chunk'); + } + return er; +} + + +function onEofChunk(stream, state) { + if (state.ended) return; + if (state.decoder) { + var chunk = state.decoder.end(); + if (chunk && chunk.length) { + state.buffer.push(chunk); + state.length += state.objectMode ? 1 : chunk.length; + } + } + state.ended = true; + + // emit 'readable' now to make sure it gets picked up. + emitReadable(stream); +} + +// Don't emit readable right away in sync mode, because this can trigger +// another read() call => stack overflow. This way, it might trigger +// a nextTick recursion warning, but that's not so bad. +function emitReadable(stream) { + var state = stream._readableState; + state.needReadable = false; + if (!state.emittedReadable) { + debug('emitReadable', state.flowing); + state.emittedReadable = true; + if (state.sync) + processNextTick(emitReadable_, stream); + else + emitReadable_(stream); + } +} + +function emitReadable_(stream) { + debug('emit readable'); + stream.emit('readable'); + flow(stream); +} + + +// at this point, the user has presumably seen the 'readable' event, +// and called read() to consume some data. that may have triggered +// in turn another _read(n) call, in which case reading = true if +// it's in progress. +// However, if we're not ended, or reading, and the length < hwm, +// then go ahead and try to read some more preemptively. +function maybeReadMore(stream, state) { + if (!state.readingMore) { + state.readingMore = true; + processNextTick(maybeReadMore_, stream, state); + } +} + +function maybeReadMore_(stream, state) { + var len = state.length; + while (!state.reading && !state.flowing && !state.ended && + state.length < state.highWaterMark) { + debug('maybeReadMore read 0'); + stream.read(0); + if (len === state.length) + // didn't get any data, stop spinning. + break; + else + len = state.length; + } + state.readingMore = false; +} + +// abstract method. to be overridden in specific implementation classes. +// call cb(er, data) where data is <= n in length. +// for virtual (non-string, non-buffer) streams, "length" is somewhat +// arbitrary, and perhaps not very meaningful. +Readable.prototype._read = function(n) { + this.emit('error', new Error('not implemented')); +}; + +Readable.prototype.pipe = function(dest, pipeOpts) { + var src = this; + var state = this._readableState; + + switch (state.pipesCount) { + case 0: + state.pipes = dest; + break; + case 1: + state.pipes = [state.pipes, dest]; + break; + default: + state.pipes.push(dest); + break; + } + state.pipesCount += 1; + debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts); + + var doEnd = (!pipeOpts || pipeOpts.end !== false) && + dest !== process.stdout && + dest !== process.stderr; + + var endFn = doEnd ? onend : cleanup; + if (state.endEmitted) + processNextTick(endFn); + else + src.once('end', endFn); + + dest.on('unpipe', onunpipe); + function onunpipe(readable) { + debug('onunpipe'); + if (readable === src) { + cleanup(); + } + } + + function onend() { + debug('onend'); + dest.end(); + } + + // when the dest drains, it reduces the awaitDrain counter + // on the source. This would be more elegant with a .once() + // handler in flow(), but adding and removing repeatedly is + // too slow. + var ondrain = pipeOnDrain(src); + dest.on('drain', ondrain); + + var cleanedUp = false; + function cleanup() { + debug('cleanup'); + // cleanup event handlers once the pipe is broken + dest.removeListener('close', onclose); + dest.removeListener('finish', onfinish); + dest.removeListener('drain', ondrain); + dest.removeListener('error', onerror); + dest.removeListener('unpipe', onunpipe); + src.removeListener('end', onend); + src.removeListener('end', cleanup); + src.removeListener('data', ondata); + + cleanedUp = true; + + // if the reader is waiting for a drain event from this + // specific writer, then it would cause it to never start + // flowing again. + // So, if this is awaiting a drain, then we just call it now. + // If we don't know, then assume that we are waiting for one. + if (state.awaitDrain && + (!dest._writableState || dest._writableState.needDrain)) + ondrain(); + } + + src.on('data', ondata); + function ondata(chunk) { + debug('ondata'); + var ret = dest.write(chunk); + if (false === ret) { + // If the user unpiped during `dest.write()`, it is possible + // to get stuck in a permanently paused state if that write + // also returned false. + if (state.pipesCount === 1 && + state.pipes[0] === dest && + src.listenerCount('data') === 1 && + !cleanedUp) { + debug('false write response, pause', src._readableState.awaitDrain); + src._readableState.awaitDrain++; + } + src.pause(); + } + } + + // if the dest has an error, then stop piping into it. + // however, don't suppress the throwing behavior for this. + function onerror(er) { + debug('onerror', er); + unpipe(); + dest.removeListener('error', onerror); + if (EElistenerCount(dest, 'error') === 0) + dest.emit('error', er); + } + // This is a brutally ugly hack to make sure that our error handler + // is attached before any userland ones. NEVER DO THIS. + if (!dest._events || !dest._events.error) + dest.on('error', onerror); + else if (isArray(dest._events.error)) + dest._events.error.unshift(onerror); + else + dest._events.error = [onerror, dest._events.error]; + + + // Both close and finish should trigger unpipe, but only once. + function onclose() { + dest.removeListener('finish', onfinish); + unpipe(); + } + dest.once('close', onclose); + function onfinish() { + debug('onfinish'); + dest.removeListener('close', onclose); + unpipe(); + } + dest.once('finish', onfinish); + + function unpipe() { + debug('unpipe'); + src.unpipe(dest); + } + + // tell the dest that it's being piped to + dest.emit('pipe', src); + + // start the flow if it hasn't been started already. + if (!state.flowing) { + debug('pipe resume'); + src.resume(); + } + + return dest; +}; + +function pipeOnDrain(src) { + return function() { + var state = src._readableState; + debug('pipeOnDrain', state.awaitDrain); + if (state.awaitDrain) + state.awaitDrain--; + if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) { + state.flowing = true; + flow(src); + } + }; +} + + +Readable.prototype.unpipe = function(dest) { + var state = this._readableState; + + // if we're not piping anywhere, then do nothing. + if (state.pipesCount === 0) + return this; + + // just one destination. most common case. + if (state.pipesCount === 1) { + // passed in one, but it's not the right one. + if (dest && dest !== state.pipes) + return this; + + if (!dest) + dest = state.pipes; + + // got a match. + state.pipes = null; + state.pipesCount = 0; + state.flowing = false; + if (dest) + dest.emit('unpipe', this); + return this; + } + + // slow case. multiple pipe destinations. + + if (!dest) { + // remove all. + var dests = state.pipes; + var len = state.pipesCount; + state.pipes = null; + state.pipesCount = 0; + state.flowing = false; + + for (var i = 0; i < len; i++) + dests[i].emit('unpipe', this); + return this; + } + + // try to find the right one. + var i = indexOf(state.pipes, dest); + if (i === -1) + return this; + + state.pipes.splice(i, 1); + state.pipesCount -= 1; + if (state.pipesCount === 1) + state.pipes = state.pipes[0]; + + dest.emit('unpipe', this); + + return this; +}; + +// set up data events if they are asked for +// Ensure readable listeners eventually get something +Readable.prototype.on = function(ev, fn) { + var res = Stream.prototype.on.call(this, ev, fn); + + // If listening to data, and it has not explicitly been paused, + // then call resume to start the flow of data on the next tick. + if (ev === 'data' && false !== this._readableState.flowing) { + this.resume(); + } + + if (ev === 'readable' && this.readable) { + var state = this._readableState; + if (!state.readableListening) { + state.readableListening = true; + state.emittedReadable = false; + state.needReadable = true; + if (!state.reading) { + processNextTick(nReadingNextTick, this); + } else if (state.length) { + emitReadable(this, state); + } + } + } + + return res; +}; +Readable.prototype.addListener = Readable.prototype.on; + +function nReadingNextTick(self) { + debug('readable nexttick read 0'); + self.read(0); +} + +// pause() and resume() are remnants of the legacy readable stream API +// If the user uses them, then switch into old mode. +Readable.prototype.resume = function() { + var state = this._readableState; + if (!state.flowing) { + debug('resume'); + state.flowing = true; + resume(this, state); + } + return this; +}; + +function resume(stream, state) { + if (!state.resumeScheduled) { + state.resumeScheduled = true; + processNextTick(resume_, stream, state); + } +} + +function resume_(stream, state) { + if (!state.reading) { + debug('resume read 0'); + stream.read(0); + } + + state.resumeScheduled = false; + stream.emit('resume'); + flow(stream); + if (state.flowing && !state.reading) + stream.read(0); +} + +Readable.prototype.pause = function() { + debug('call pause flowing=%j', this._readableState.flowing); + if (false !== this._readableState.flowing) { + debug('pause'); + this._readableState.flowing = false; + this.emit('pause'); + } + return this; +}; + +function flow(stream) { + var state = stream._readableState; + debug('flow', state.flowing); + if (state.flowing) { + do { + var chunk = stream.read(); + } while (null !== chunk && state.flowing); + } +} + +// wrap an old-style stream as the async data source. +// This is *not* part of the readable stream interface. +// It is an ugly unfortunate mess of history. +Readable.prototype.wrap = function(stream) { + var state = this._readableState; + var paused = false; + + var self = this; + stream.on('end', function() { + debug('wrapped end'); + if (state.decoder && !state.ended) { + var chunk = state.decoder.end(); + if (chunk && chunk.length) + self.push(chunk); + } + + self.push(null); + }); + + stream.on('data', function(chunk) { + debug('wrapped data'); + if (state.decoder) + chunk = state.decoder.write(chunk); + + // don't skip over falsy values in objectMode + if (state.objectMode && (chunk === null || chunk === undefined)) + return; + else if (!state.objectMode && (!chunk || !chunk.length)) + return; + + var ret = self.push(chunk); + if (!ret) { + paused = true; + stream.pause(); + } + }); + + // proxy all the other methods. + // important when wrapping filters and duplexes. + for (var i in stream) { + if (this[i] === undefined && typeof stream[i] === 'function') { + this[i] = function(method) { return function() { + return stream[method].apply(stream, arguments); + }; }(i); + } + } + + // proxy certain important events. + var events = ['error', 'close', 'destroy', 'pause', 'resume']; + forEach(events, function(ev) { + stream.on(ev, self.emit.bind(self, ev)); + }); + + // when we try to consume some more bytes, simply unpause the + // underlying stream. + self._read = function(n) { + debug('wrapped _read', n); + if (paused) { + paused = false; + stream.resume(); + } + }; + + return self; +}; + + +// exposed for testing purposes only. +Readable._fromList = fromList; + +// Pluck off n bytes from an array of buffers. +// Length is the combined lengths of all the buffers in the list. +function fromList(n, state) { + var list = state.buffer; + var length = state.length; + var stringMode = !!state.decoder; + var objectMode = !!state.objectMode; + var ret; + + // nothing in the list, definitely empty. + if (list.length === 0) + return null; + + if (length === 0) + ret = null; + else if (objectMode) + ret = list.shift(); + else if (!n || n >= length) { + // read it all, truncate the array. + if (stringMode) + ret = list.join(''); + else if (list.length === 1) + ret = list[0]; + else + ret = Buffer.concat(list, length); + list.length = 0; + } else { + // read just some of it. + if (n < list[0].length) { + // just take a part of the first list item. + // slice is the same for buffers and strings. + var buf = list[0]; + ret = buf.slice(0, n); + list[0] = buf.slice(n); + } else if (n === list[0].length) { + // first list is a perfect match + ret = list.shift(); + } else { + // complex case. + // we have enough to cover it, but it spans past the first buffer. + if (stringMode) + ret = ''; + else + ret = new Buffer(n); + + var c = 0; + for (var i = 0, l = list.length; i < l && c < n; i++) { + var buf = list[0]; + var cpy = Math.min(n - c, buf.length); + + if (stringMode) + ret += buf.slice(0, cpy); + else + buf.copy(ret, c, 0, cpy); + + if (cpy < buf.length) + list[0] = buf.slice(cpy); + else + list.shift(); + + c += cpy; + } + } + } + + return ret; +} + +function endReadable(stream) { + var state = stream._readableState; + + // If we get here before consuming all the bytes, then that is a + // bug in node. Should never happen. + if (state.length > 0) + throw new Error('endReadable called on non-empty stream'); + + if (!state.endEmitted) { + state.ended = true; + processNextTick(endReadableNT, state, stream); + } +} + +function endReadableNT(state, stream) { + // Check that we didn't get one last unshift. + if (!state.endEmitted && state.length === 0) { + state.endEmitted = true; + stream.readable = false; + stream.emit('end'); + } +} + +function forEach (xs, f) { + for (var i = 0, l = xs.length; i < l; i++) { + f(xs[i], i); + } +} + +function indexOf (xs, x) { + for (var i = 0, l = xs.length; i < l; i++) { + if (xs[i] === x) return i; + } + return -1; +} diff --git a/tools/node_modules/readable-stream/lib/_stream_transform.js b/tools/node_modules/readable-stream/lib/_stream_transform.js new file mode 100644 index 00000000000000..3675d18d915610 --- /dev/null +++ b/tools/node_modules/readable-stream/lib/_stream_transform.js @@ -0,0 +1,197 @@ +// a transform stream is a readable/writable stream where you do +// something with the data. Sometimes it's called a "filter", +// but that's not a great name for it, since that implies a thing where +// some bits pass through, and others are simply ignored. (That would +// be a valid example of a transform, of course.) +// +// While the output is causally related to the input, it's not a +// necessarily symmetric or synchronous transformation. For example, +// a zlib stream might take multiple plain-text writes(), and then +// emit a single compressed chunk some time in the future. +// +// Here's how this works: +// +// The Transform stream has all the aspects of the readable and writable +// stream classes. When you write(chunk), that calls _write(chunk,cb) +// internally, and returns false if there's a lot of pending writes +// buffered up. When you call read(), that calls _read(n) until +// there's enough pending readable data buffered up. +// +// In a transform stream, the written data is placed in a buffer. When +// _read(n) is called, it transforms the queued up data, calling the +// buffered _write cb's as it consumes chunks. If consuming a single +// written chunk would result in multiple output chunks, then the first +// outputted bit calls the readcb, and subsequent chunks just go into +// the read buffer, and will cause it to emit 'readable' if necessary. +// +// This way, back-pressure is actually determined by the reading side, +// since _read has to be called to start processing a new chunk. However, +// a pathological inflate type of transform can cause excessive buffering +// here. For example, imagine a stream where every byte of input is +// interpreted as an integer from 0-255, and then results in that many +// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in +// 1kb of data being output. In this case, you could write a very small +// amount of input, and end up with a very large amount of output. In +// such a pathological inflating mechanism, there'd be no way to tell +// the system to stop doing the transform. A single 4MB write could +// cause the system to run out of memory. +// +// However, even in such a pathological case, only a single written chunk +// would be consumed, and then the rest would wait (un-transformed) until +// the results of the previous transformed chunk were consumed. + +'use strict'; + +module.exports = Transform; + +var Duplex = require('./_stream_duplex'); + +/**/ +var util = require('core-util-is'); +util.inherits = require('inherits'); +/**/ + +util.inherits(Transform, Duplex); + + +function TransformState(stream) { + this.afterTransform = function(er, data) { + return afterTransform(stream, er, data); + }; + + this.needTransform = false; + this.transforming = false; + this.writecb = null; + this.writechunk = null; +} + +function afterTransform(stream, er, data) { + var ts = stream._transformState; + ts.transforming = false; + + var cb = ts.writecb; + + if (!cb) + return stream.emit('error', new Error('no writecb in Transform class')); + + ts.writechunk = null; + ts.writecb = null; + + if (data !== null && data !== undefined) + stream.push(data); + + if (cb) + cb(er); + + var rs = stream._readableState; + rs.reading = false; + if (rs.needReadable || rs.length < rs.highWaterMark) { + stream._read(rs.highWaterMark); + } +} + + +function Transform(options) { + if (!(this instanceof Transform)) + return new Transform(options); + + Duplex.call(this, options); + + this._transformState = new TransformState(this); + + // when the writable side finishes, then flush out anything remaining. + var stream = this; + + // start out asking for a readable event once data is transformed. + this._readableState.needReadable = true; + + // we have implemented the _read method, and done the other things + // that Readable wants before the first _read call, so unset the + // sync guard flag. + this._readableState.sync = false; + + if (options) { + if (typeof options.transform === 'function') + this._transform = options.transform; + + if (typeof options.flush === 'function') + this._flush = options.flush; + } + + this.once('prefinish', function() { + if (typeof this._flush === 'function') + this._flush(function(er) { + done(stream, er); + }); + else + done(stream); + }); +} + +Transform.prototype.push = function(chunk, encoding) { + this._transformState.needTransform = false; + return Duplex.prototype.push.call(this, chunk, encoding); +}; + +// This is the part where you do stuff! +// override this function in implementation classes. +// 'chunk' is an input chunk. +// +// Call `push(newChunk)` to pass along transformed output +// to the readable side. You may call 'push' zero or more times. +// +// Call `cb(err)` when you are done with this chunk. If you pass +// an error, then that'll put the hurt on the whole operation. If you +// never call cb(), then you'll never get another chunk. +Transform.prototype._transform = function(chunk, encoding, cb) { + throw new Error('not implemented'); +}; + +Transform.prototype._write = function(chunk, encoding, cb) { + var ts = this._transformState; + ts.writecb = cb; + ts.writechunk = chunk; + ts.writeencoding = encoding; + if (!ts.transforming) { + var rs = this._readableState; + if (ts.needTransform || + rs.needReadable || + rs.length < rs.highWaterMark) + this._read(rs.highWaterMark); + } +}; + +// Doesn't matter what the args are here. +// _transform does all the work. +// That we got here means that the readable side wants more data. +Transform.prototype._read = function(n) { + var ts = this._transformState; + + if (ts.writechunk !== null && ts.writecb && !ts.transforming) { + ts.transforming = true; + this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform); + } else { + // mark that we need a transform, so that any data that comes in + // will get processed, now that we've asked for it. + ts.needTransform = true; + } +}; + + +function done(stream, er) { + if (er) + return stream.emit('error', er); + + // if there's nothing in the write buffer, then that means + // that nothing more will ever be provided + var ws = stream._writableState; + var ts = stream._transformState; + + if (ws.length) + throw new Error('calling transform done when ws.length != 0'); + + if (ts.transforming) + throw new Error('calling transform done when still transforming'); + + return stream.push(null); +} diff --git a/tools/node_modules/readable-stream/lib/_stream_writable.js b/tools/node_modules/readable-stream/lib/_stream_writable.js new file mode 100644 index 00000000000000..1fa5eb695adde6 --- /dev/null +++ b/tools/node_modules/readable-stream/lib/_stream_writable.js @@ -0,0 +1,529 @@ +// A bit simpler than readable streams. +// Implement an async ._write(chunk, encoding, cb), and it'll handle all +// the drain event emission and buffering. + +'use strict'; + +module.exports = Writable; + +/**/ +var processNextTick = require('process-nextick-args'); +/**/ + + +/**/ +var Buffer = require('buffer').Buffer; +/**/ + +Writable.WritableState = WritableState; + + +/**/ +var util = require('core-util-is'); +util.inherits = require('inherits'); +/**/ + + +/**/ +var internalUtil = { + deprecate: require('util-deprecate') +}; +/**/ + + + +/**/ +var Stream; +(function (){try{ + Stream = require('st' + 'ream'); +}catch(_){}finally{ + if (!Stream) + Stream = require('events').EventEmitter; +}}()) +/**/ + +var Buffer = require('buffer').Buffer; + +util.inherits(Writable, Stream); + +function nop() {} + +function WriteReq(chunk, encoding, cb) { + this.chunk = chunk; + this.encoding = encoding; + this.callback = cb; + this.next = null; +} + +var Duplex; +function WritableState(options, stream) { + Duplex = Duplex || require('./_stream_duplex'); + + options = options || {}; + + // object stream flag to indicate whether or not this stream + // contains buffers or objects. + this.objectMode = !!options.objectMode; + + if (stream instanceof Duplex) + this.objectMode = this.objectMode || !!options.writableObjectMode; + + // the point at which write() starts returning false + // Note: 0 is a valid value, means that we always return false if + // the entire buffer is not flushed immediately on write() + var hwm = options.highWaterMark; + var defaultHwm = this.objectMode ? 16 : 16 * 1024; + this.highWaterMark = (hwm || hwm === 0) ? hwm : defaultHwm; + + // cast to ints. + this.highWaterMark = ~~this.highWaterMark; + + this.needDrain = false; + // at the start of calling end() + this.ending = false; + // when end() has been called, and returned + this.ended = false; + // when 'finish' is emitted + this.finished = false; + + // should we decode strings into buffers before passing to _write? + // this is here so that some node-core streams can optimize string + // handling at a lower level. + var noDecode = options.decodeStrings === false; + this.decodeStrings = !noDecode; + + // Crypto is kind of old and crusty. Historically, its default string + // encoding is 'binary' so we have to make this configurable. + // Everything else in the universe uses 'utf8', though. + this.defaultEncoding = options.defaultEncoding || 'utf8'; + + // not an actual buffer we keep track of, but a measurement + // of how much we're waiting to get pushed to some underlying + // socket or file. + this.length = 0; + + // a flag to see when we're in the middle of a write. + this.writing = false; + + // when true all writes will be buffered until .uncork() call + this.corked = 0; + + // a flag to be able to tell if the onwrite cb is called immediately, + // or on a later tick. We set this to true at first, because any + // actions that shouldn't happen until "later" should generally also + // not happen before the first write call. + this.sync = true; + + // a flag to know if we're processing previously buffered items, which + // may call the _write() callback in the same tick, so that we don't + // end up in an overlapped onwrite situation. + this.bufferProcessing = false; + + // the callback that's passed to _write(chunk,cb) + this.onwrite = function(er) { + onwrite(stream, er); + }; + + // the callback that the user supplies to write(chunk,encoding,cb) + this.writecb = null; + + // the amount that is being written when _write is called. + this.writelen = 0; + + this.bufferedRequest = null; + this.lastBufferedRequest = null; + + // number of pending user-supplied write callbacks + // this must be 0 before 'finish' can be emitted + this.pendingcb = 0; + + // emit prefinish if the only thing we're waiting for is _write cbs + // This is relevant for synchronous Transform streams + this.prefinished = false; + + // True if the error was already emitted and should not be thrown again + this.errorEmitted = false; +} + +WritableState.prototype.getBuffer = function writableStateGetBuffer() { + var current = this.bufferedRequest; + var out = []; + while (current) { + out.push(current); + current = current.next; + } + return out; +}; + +(function (){try { +Object.defineProperty(WritableState.prototype, 'buffer', { + get: internalUtil.deprecate(function() { + return this.getBuffer(); + }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + + 'instead.') +}); +}catch(_){}}()); + + +var Duplex; +function Writable(options) { + Duplex = Duplex || require('./_stream_duplex'); + + // Writable ctor is applied to Duplexes, though they're not + // instanceof Writable, they're instanceof Readable. + if (!(this instanceof Writable) && !(this instanceof Duplex)) + return new Writable(options); + + this._writableState = new WritableState(options, this); + + // legacy. + this.writable = true; + + if (options) { + if (typeof options.write === 'function') + this._write = options.write; + + if (typeof options.writev === 'function') + this._writev = options.writev; + } + + Stream.call(this); +} + +// Otherwise people can pipe Writable streams, which is just wrong. +Writable.prototype.pipe = function() { + this.emit('error', new Error('Cannot pipe. Not readable.')); +}; + + +function writeAfterEnd(stream, cb) { + var er = new Error('write after end'); + // TODO: defer error events consistently everywhere, not just the cb + stream.emit('error', er); + processNextTick(cb, er); +} + +// If we get something that is not a buffer, string, null, or undefined, +// and we're not in objectMode, then that's an error. +// Otherwise stream chunks are all considered to be of length=1, and the +// watermarks determine how many objects to keep in the buffer, rather than +// how many bytes or characters. +function validChunk(stream, state, chunk, cb) { + var valid = true; + + if (!(Buffer.isBuffer(chunk)) && + typeof chunk !== 'string' && + chunk !== null && + chunk !== undefined && + !state.objectMode) { + var er = new TypeError('Invalid non-string/buffer chunk'); + stream.emit('error', er); + processNextTick(cb, er); + valid = false; + } + return valid; +} + +Writable.prototype.write = function(chunk, encoding, cb) { + var state = this._writableState; + var ret = false; + + if (typeof encoding === 'function') { + cb = encoding; + encoding = null; + } + + if (Buffer.isBuffer(chunk)) + encoding = 'buffer'; + else if (!encoding) + encoding = state.defaultEncoding; + + if (typeof cb !== 'function') + cb = nop; + + if (state.ended) + writeAfterEnd(this, cb); + else if (validChunk(this, state, chunk, cb)) { + state.pendingcb++; + ret = writeOrBuffer(this, state, chunk, encoding, cb); + } + + return ret; +}; + +Writable.prototype.cork = function() { + var state = this._writableState; + + state.corked++; +}; + +Writable.prototype.uncork = function() { + var state = this._writableState; + + if (state.corked) { + state.corked--; + + if (!state.writing && + !state.corked && + !state.finished && + !state.bufferProcessing && + state.bufferedRequest) + clearBuffer(this, state); + } +}; + +Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) { + // node::ParseEncoding() requires lower case. + if (typeof encoding === 'string') + encoding = encoding.toLowerCase(); + if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', +'ucs2', 'ucs-2','utf16le', 'utf-16le', 'raw'] +.indexOf((encoding + '').toLowerCase()) > -1)) + throw new TypeError('Unknown encoding: ' + encoding); + this._writableState.defaultEncoding = encoding; +}; + +function decodeChunk(state, chunk, encoding) { + if (!state.objectMode && + state.decodeStrings !== false && + typeof chunk === 'string') { + chunk = new Buffer(chunk, encoding); + } + return chunk; +} + +// if we're already writing something, then just put this +// in the queue, and wait our turn. Otherwise, call _write +// If we return false, then we need a drain event, so set that flag. +function writeOrBuffer(stream, state, chunk, encoding, cb) { + chunk = decodeChunk(state, chunk, encoding); + + if (Buffer.isBuffer(chunk)) + encoding = 'buffer'; + var len = state.objectMode ? 1 : chunk.length; + + state.length += len; + + var ret = state.length < state.highWaterMark; + // we must ensure that previous needDrain will not be reset to false. + if (!ret) + state.needDrain = true; + + if (state.writing || state.corked) { + var last = state.lastBufferedRequest; + state.lastBufferedRequest = new WriteReq(chunk, encoding, cb); + if (last) { + last.next = state.lastBufferedRequest; + } else { + state.bufferedRequest = state.lastBufferedRequest; + } + } else { + doWrite(stream, state, false, len, chunk, encoding, cb); + } + + return ret; +} + +function doWrite(stream, state, writev, len, chunk, encoding, cb) { + state.writelen = len; + state.writecb = cb; + state.writing = true; + state.sync = true; + if (writev) + stream._writev(chunk, state.onwrite); + else + stream._write(chunk, encoding, state.onwrite); + state.sync = false; +} + +function onwriteError(stream, state, sync, er, cb) { + --state.pendingcb; + if (sync) + processNextTick(cb, er); + else + cb(er); + + stream._writableState.errorEmitted = true; + stream.emit('error', er); +} + +function onwriteStateUpdate(state) { + state.writing = false; + state.writecb = null; + state.length -= state.writelen; + state.writelen = 0; +} + +function onwrite(stream, er) { + var state = stream._writableState; + var sync = state.sync; + var cb = state.writecb; + + onwriteStateUpdate(state); + + if (er) + onwriteError(stream, state, sync, er, cb); + else { + // Check if we're actually ready to finish, but don't emit yet + var finished = needFinish(state); + + if (!finished && + !state.corked && + !state.bufferProcessing && + state.bufferedRequest) { + clearBuffer(stream, state); + } + + if (sync) { + processNextTick(afterWrite, stream, state, finished, cb); + } else { + afterWrite(stream, state, finished, cb); + } + } +} + +function afterWrite(stream, state, finished, cb) { + if (!finished) + onwriteDrain(stream, state); + state.pendingcb--; + cb(); + finishMaybe(stream, state); +} + +// Must force callback to be called on nextTick, so that we don't +// emit 'drain' before the write() consumer gets the 'false' return +// value, and has a chance to attach a 'drain' listener. +function onwriteDrain(stream, state) { + if (state.length === 0 && state.needDrain) { + state.needDrain = false; + stream.emit('drain'); + } +} + + +// if there's something in the buffer waiting, then process it +function clearBuffer(stream, state) { + state.bufferProcessing = true; + var entry = state.bufferedRequest; + + if (stream._writev && entry && entry.next) { + // Fast case, write everything using _writev() + var buffer = []; + var cbs = []; + while (entry) { + cbs.push(entry.callback); + buffer.push(entry); + entry = entry.next; + } + + // count the one we are adding, as well. + // TODO(isaacs) clean this up + state.pendingcb++; + state.lastBufferedRequest = null; + doWrite(stream, state, true, state.length, buffer, '', function(err) { + for (var i = 0; i < cbs.length; i++) { + state.pendingcb--; + cbs[i](err); + } + }); + + // Clear buffer + } else { + // Slow case, write chunks one-by-one + while (entry) { + var chunk = entry.chunk; + var encoding = entry.encoding; + var cb = entry.callback; + var len = state.objectMode ? 1 : chunk.length; + + doWrite(stream, state, false, len, chunk, encoding, cb); + entry = entry.next; + // if we didn't call the onwrite immediately, then + // it means that we need to wait until it does. + // also, that means that the chunk and cb are currently + // being processed, so move the buffer counter past them. + if (state.writing) { + break; + } + } + + if (entry === null) + state.lastBufferedRequest = null; + } + state.bufferedRequest = entry; + state.bufferProcessing = false; +} + +Writable.prototype._write = function(chunk, encoding, cb) { + cb(new Error('not implemented')); +}; + +Writable.prototype._writev = null; + +Writable.prototype.end = function(chunk, encoding, cb) { + var state = this._writableState; + + if (typeof chunk === 'function') { + cb = chunk; + chunk = null; + encoding = null; + } else if (typeof encoding === 'function') { + cb = encoding; + encoding = null; + } + + if (chunk !== null && chunk !== undefined) + this.write(chunk, encoding); + + // .end() fully uncorks + if (state.corked) { + state.corked = 1; + this.uncork(); + } + + // ignore unnecessary end() calls. + if (!state.ending && !state.finished) + endWritable(this, state, cb); +}; + + +function needFinish(state) { + return (state.ending && + state.length === 0 && + state.bufferedRequest === null && + !state.finished && + !state.writing); +} + +function prefinish(stream, state) { + if (!state.prefinished) { + state.prefinished = true; + stream.emit('prefinish'); + } +} + +function finishMaybe(stream, state) { + var need = needFinish(state); + if (need) { + if (state.pendingcb === 0) { + prefinish(stream, state); + state.finished = true; + stream.emit('finish'); + } else { + prefinish(stream, state); + } + } + return need; +} + +function endWritable(stream, state, cb) { + state.ending = true; + finishMaybe(stream, state); + if (cb) { + if (state.finished) + processNextTick(cb); + else + stream.once('finish', cb); + } + state.ended = true; +} diff --git a/tools/node_modules/readable-stream/package.json b/tools/node_modules/readable-stream/package.json new file mode 100644 index 00000000000000..e360c07f995e8b --- /dev/null +++ b/tools/node_modules/readable-stream/package.json @@ -0,0 +1,101 @@ +{ + "_args": [ + [ + "readable-stream@^2.0.2", + "C:\\wamp\\www\\node\\tools\\node_modules\\readdirp" + ] + ], + "_from": "readable-stream@>=2.0.2 <3.0.0", + "_id": "readable-stream@2.0.5", + "_inCache": true, + "_location": "/readable-stream", + "_nodeVersion": "5.1.1", + "_npmUser": { + "email": "calvin.metcalf@gmail.com", + "name": "cwmma" + }, + "_npmVersion": "3.3.12", + "_phantomChildren": {}, + "_requested": { + "name": "readable-stream", + "raw": "readable-stream@^2.0.2", + "rawSpec": "^2.0.2", + "scope": null, + "spec": ">=2.0.2 <3.0.0", + "type": "range" + }, + "_requiredBy": [ + "/concat-stream", + "/readdirp" + ], + "_resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.0.5.tgz", + "_shasum": "a2426f8dcd4551c77a33f96edf2886a23c829669", + "_shrinkwrap": null, + "_spec": "readable-stream@^2.0.2", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\readdirp", + "browser": { + "util": false + }, + "bugs": { + "url": "https://github.com/nodejs/readable-stream/issues" + }, + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "0.0.1", + "process-nextick-args": "~1.0.6", + "string_decoder": "~0.10.x", + "util-deprecate": "~1.0.1" + }, + "description": "Streams3, a user-land copy of the stream library from iojs v2.x", + "devDependencies": { + "tap": "~0.2.6", + "tape": "~4.0.0", + "zuul": "~3.0.0" + }, + "directories": {}, + "dist": { + "shasum": "a2426f8dcd4551c77a33f96edf2886a23c829669", + "tarball": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.0.5.tgz" + }, + "gitHead": "a4f23d8e451267684a8160679ce16e16149fe72b", + "homepage": "https://github.com/nodejs/readable-stream#readme", + "installable": true, + "keywords": [ + "pipe", + "readable", + "stream" + ], + "license": "MIT", + "main": "readable.js", + "maintainers": [ + { + "name": "isaacs", + "email": "isaacs@npmjs.com" + }, + { + "name": "tootallnate", + "email": "nathan@tootallnate.net" + }, + { + "name": "rvagg", + "email": "rod@vagg.org" + }, + { + "name": "cwmma", + "email": "calvin.metcalf@gmail.com" + } + ], + "name": "readable-stream", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git://github.com/nodejs/readable-stream.git" + }, + "scripts": { + "browser": "npm run write-zuul && zuul -- test/browser.js", + "test": "tap test/parallel/*.js", + "write-zuul": "printf \"ui: tape\nbrowsers:\n - name: $BROWSER_NAME\n version: $BROWSER_VERSION\n\">.zuul.yml" + }, + "version": "2.0.5" +} diff --git a/tools/node_modules/readable-stream/passthrough.js b/tools/node_modules/readable-stream/passthrough.js new file mode 100644 index 00000000000000..27e8d8a55165f9 --- /dev/null +++ b/tools/node_modules/readable-stream/passthrough.js @@ -0,0 +1 @@ +module.exports = require("./lib/_stream_passthrough.js") diff --git a/tools/node_modules/readable-stream/readable.js b/tools/node_modules/readable-stream/readable.js new file mode 100644 index 00000000000000..6222a579864dd2 --- /dev/null +++ b/tools/node_modules/readable-stream/readable.js @@ -0,0 +1,12 @@ +var Stream = (function (){ + try { + return require('st' + 'ream'); // hack to fix a circular dependency issue when used with browserify + } catch(_){} +}()); +exports = module.exports = require('./lib/_stream_readable.js'); +exports.Stream = Stream || exports; +exports.Readable = exports; +exports.Writable = require('./lib/_stream_writable.js'); +exports.Duplex = require('./lib/_stream_duplex.js'); +exports.Transform = require('./lib/_stream_transform.js'); +exports.PassThrough = require('./lib/_stream_passthrough.js'); diff --git a/tools/node_modules/readable-stream/transform.js b/tools/node_modules/readable-stream/transform.js new file mode 100644 index 00000000000000..5d482f0780e993 --- /dev/null +++ b/tools/node_modules/readable-stream/transform.js @@ -0,0 +1 @@ +module.exports = require("./lib/_stream_transform.js") diff --git a/tools/node_modules/readable-stream/writable.js b/tools/node_modules/readable-stream/writable.js new file mode 100644 index 00000000000000..e1e9efdf3c12e9 --- /dev/null +++ b/tools/node_modules/readable-stream/writable.js @@ -0,0 +1 @@ +module.exports = require("./lib/_stream_writable.js") diff --git a/tools/node_modules/readdirp/.npmignore b/tools/node_modules/readdirp/.npmignore new file mode 100644 index 00000000000000..7dccd970766aff --- /dev/null +++ b/tools/node_modules/readdirp/.npmignore @@ -0,0 +1,15 @@ +lib-cov +*.seed +*.log +*.csv +*.dat +*.out +*.pid +*.gz + +pids +logs +results + +node_modules +npm-debug.log \ No newline at end of file diff --git a/tools/node_modules/readdirp/.travis.yml b/tools/node_modules/readdirp/.travis.yml new file mode 100644 index 00000000000000..b2029dfbf61b00 --- /dev/null +++ b/tools/node_modules/readdirp/.travis.yml @@ -0,0 +1,8 @@ +language: node_js +node_js: + - "0.8" + - "0.10" + - "0.12" + - "iojs-v2.4" +before_install: + - if [ "$TRAVIS_NODE_VERSION" == "0.8" ]; then npm update -g npm; fi diff --git a/tools/node_modules/readdirp/LICENSE b/tools/node_modules/readdirp/LICENSE new file mode 100644 index 00000000000000..ee27ba4b4412b0 --- /dev/null +++ b/tools/node_modules/readdirp/LICENSE @@ -0,0 +1,18 @@ +This software is released under the MIT license: + +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. diff --git a/tools/node_modules/readdirp/README.md b/tools/node_modules/readdirp/README.md new file mode 100644 index 00000000000000..b0c1626ac2fc09 --- /dev/null +++ b/tools/node_modules/readdirp/README.md @@ -0,0 +1,233 @@ +# readdirp [![Build Status](https://secure.travis-ci.org/thlorenz/readdirp.png)](http://travis-ci.org/thlorenz/readdirp) + +[![NPM](https://nodei.co/npm/readdirp.png?downloads=true&stars=true)](https://nodei.co/npm/readdirp/) + +Recursive version of [fs.readdir](http://nodejs.org/docs/latest/api/fs.html#fs_fs_readdir_path_callback). Exposes a **stream api**. + +```javascript +var readdirp = require('readdirp') + , path = require('path') + , es = require('event-stream'); + +// print out all JavaScript files along with their size + +var stream = readdirp({ root: path.join(__dirname), fileFilter: '*.js' }); +stream + .on('warn', function (err) { + console.error('non-fatal error', err); + // optionally call stream.destroy() here in order to abort and cause 'close' to be emitted + }) + .on('error', function (err) { console.error('fatal error', err); }) + .pipe(es.mapSync(function (entry) { + return { path: entry.path, size: entry.stat.size }; + })) + .pipe(es.stringify()) + .pipe(process.stdout); +``` + +Meant to be one of the recursive versions of [fs](http://nodejs.org/docs/latest/api/fs.html) functions, e.g., like [mkdirp](https://github.com/substack/node-mkdirp). + +**Table of Contents** *generated with [DocToc](http://doctoc.herokuapp.com/)* + +- [Installation](#installation) +- [API](#api) + - [entry stream](#entry-stream) + - [options](#options) + - [entry info](#entry-info) + - [Filters](#filters) + - [Callback API](#callback-api) + - [allProcessed ](#allprocessed) + - [fileProcessed](#fileprocessed) +- [More Examples](#more-examples) + - [stream api](#stream-api) + - [stream api pipe](#stream-api-pipe) + - [grep](#grep) + - [using callback api](#using-callback-api) + - [tests](#tests) + + +# Installation + + npm install readdirp + +# API + +***var entryStream = readdirp (options)*** + +Reads given root recursively and returns a `stream` of [entry info](#entry-info)s. + +## entry stream + +Behaves as follows: + +- `emit('data')` passes an [entry info](#entry-info) whenever one is found +- `emit('warn')` passes a non-fatal `Error` that prevents a file/directory from being processed (i.e., if it is + inaccessible to the user) +- `emit('error')` passes a fatal `Error` which also ends the stream (i.e., when illegal options where passed) +- `emit('end')` called when all entries were found and no more will be emitted (i.e., we are done) +- `emit('close')` called when the stream is destroyed via `stream.destroy()` (which could be useful if you want to + manually abort even on a non fatal error) - at that point the stream is no longer `readable` and no more entries, + warning or errors are emitted +- to learn more about streams, consult the very detailed + [nodejs streams documentation](http://nodejs.org/api/stream.html) or the + [stream-handbook](https://github.com/substack/stream-handbook) + + +## options + +- **root**: path in which to start reading and recursing into subdirectories + +- **fileFilter**: filter to include/exclude files found (see [Filters](#filters) for more) + +- **directoryFilter**: filter to include/exclude directories found and to recurse into (see [Filters](#filters) for more) + +- **depth**: depth at which to stop recursing even if more subdirectories are found + +- **entryType**: determines if data events on the stream should be emitted for `'files'`, `'directories'`, `'both'`, or `'all'`. Setting to `'all'` will also include entries for other types of file descriptors like character devices, unix sockets and named pipes. Defaults to `'files'`. + +- **lstat**: if `true`, readdirp uses `fs.lstat` instead of `fs.stat` in order to stat files and includes symlink entries in the stream along with files. + +## entry info + +Has the following properties: + +- **parentDir** : directory in which entry was found (relative to given root) +- **fullParentDir** : full path to parent directory +- **name** : name of the file/directory +- **path** : path to the file/directory (relative to given root) +- **fullPath** : full path to the file/directory found +- **stat** : built in [stat object](http://nodejs.org/docs/v0.4.9/api/fs.html#fs.Stats) +- **Example**: (assuming root was `/User/dev/readdirp`) + + parentDir : 'test/bed/root_dir1', + fullParentDir : '/User/dev/readdirp/test/bed/root_dir1', + name : 'root_dir1_subdir1', + path : 'test/bed/root_dir1/root_dir1_subdir1', + fullPath : '/User/dev/readdirp/test/bed/root_dir1/root_dir1_subdir1', + stat : [ ... ] + +## Filters + +There are three different ways to specify filters for files and directories respectively. + +- **function**: a function that takes an entry info as a parameter and returns true to include or false to exclude the entry + +- **glob string**: a string (e.g., `*.js`) which is matched using [minimatch](https://github.com/isaacs/minimatch), so go there for more + information. + + Globstars (`**`) are not supported since specifiying a recursive pattern for an already recursive function doesn't make sense. + + Negated globs (as explained in the minimatch documentation) are allowed, e.g., `!*.txt` matches everything but text files. + +- **array of glob strings**: either need to be all inclusive or all exclusive (negated) patterns otherwise an error is thrown. + + `[ '*.json', '*.js' ]` includes all JavaScript and Json files. + + + `[ '!.git', '!node_modules' ]` includes all directories except the '.git' and 'node_modules'. + +Directories that do not pass a filter will not be recursed into. + +## Callback API + +Although the stream api is recommended, readdirp also exposes a callback based api. + +***readdirp (options, callback1 [, callback2])*** + +If callback2 is given, callback1 functions as the **fileProcessed** callback, and callback2 as the **allProcessed** callback. + +If only callback1 is given, it functions as the **allProcessed** callback. + +### allProcessed + +- function with err and res parameters, e.g., `function (err, res) { ... }` +- **err**: array of errors that occurred during the operation, **res may still be present, even if errors occurred** +- **res**: collection of file/directory [entry infos](#entry-info) + +### fileProcessed + +- function with [entry info](#entry-info) parameter e.g., `function (entryInfo) { ... }` + + +# More Examples + +`on('error', ..)`, `on('warn', ..)` and `on('end', ..)` handling omitted for brevity + +```javascript +var readdirp = require('readdirp'); + +// Glob file filter +readdirp({ root: './test/bed', fileFilter: '*.js' }) + .on('data', function (entry) { + // do something with each JavaScript file entry + }); + +// Combined glob file filters +readdirp({ root: './test/bed', fileFilter: [ '*.js', '*.json' ] }) + .on('data', function (entry) { + // do something with each JavaScript and Json file entry + }); + +// Combined negated directory filters +readdirp({ root: './test/bed', directoryFilter: [ '!.git', '!*modules' ] }) + .on('data', function (entry) { + // do something with each file entry found outside '.git' or any modules directory + }); + +// Function directory filter +readdirp({ root: './test/bed', directoryFilter: function (di) { return di.name.length === 9; } }) + .on('data', function (entry) { + // do something with each file entry found inside directories whose name has length 9 + }); + +// Limiting depth +readdirp({ root: './test/bed', depth: 1 }) + .on('data', function (entry) { + // do something with each file entry found up to 1 subdirectory deep + }); + +// callback api +readdirp( + { root: '.' } + , function(fileInfo) { + // do something with file entry here + } + , function (err, res) { + // all done, move on or do final step for all file entries here + } +); +``` + +Try more examples by following [instructions](https://github.com/thlorenz/readdirp/blob/master/examples/Readme.md) +on how to get going. + +## stream api + +[stream-api.js](https://github.com/thlorenz/readdirp/blob/master/examples/stream-api.js) + +Demonstrates error and data handling by listening to events emitted from the readdirp stream. + +## stream api pipe + +[stream-api-pipe.js](https://github.com/thlorenz/readdirp/blob/master/examples/stream-api-pipe.js) + +Demonstrates error handling by listening to events emitted from the readdirp stream and how to pipe the data stream into +another destination stream. + +## grep + +[grep.js](https://github.com/thlorenz/readdirp/blob/master/examples/grep.js) + +Very naive implementation of grep, for demonstration purposes only. + +## using callback api + +[callback-api.js](https://github.com/thlorenz/readdirp/blob/master/examples/callback-api.js) + +Shows how to pass callbacks in order to handle errors and/or data. + +## tests + +The [readdirp tests](https://github.com/thlorenz/readdirp/blob/master/test/readdirp.js) also will give you a good idea on +how things work. + diff --git a/tools/node_modules/readdirp/examples/Readme.md b/tools/node_modules/readdirp/examples/Readme.md new file mode 100644 index 00000000000000..55fc4611bc787b --- /dev/null +++ b/tools/node_modules/readdirp/examples/Readme.md @@ -0,0 +1,37 @@ +# readdirp examples + +## How to run the examples + +Assuming you installed readdirp (`npm install readdirp`), you can do the following: + +1. `npm explore readdirp` +2. `cd examples` +3. `npm install` + +At that point you can run the examples with node, i.e., `node grep`. + +## stream api + +[stream-api.js](https://github.com/thlorenz/readdirp/blob/master/examples/stream-api.js) + +Demonstrates error and data handling by listening to events emitted from the readdirp stream. + +## stream api pipe + +[stream-api-pipe.js](https://github.com/thlorenz/readdirp/blob/master/examples/stream-api-pipe.js) + +Demonstrates error handling by listening to events emitted from the readdirp stream and how to pipe the data stream into +another destination stream. + +## grep + +[grep.js](https://github.com/thlorenz/readdirp/blob/master/examples/grep.js) + +Very naive implementation of grep, for demonstration purposes only. + +## using callback api + +[callback-api.js](https://github.com/thlorenz/readdirp/blob/master/examples/callback-api.js) + +Shows how to pass callbacks in order to handle errors and/or data. + diff --git a/tools/node_modules/readdirp/examples/callback-api.js b/tools/node_modules/readdirp/examples/callback-api.js new file mode 100644 index 00000000000000..39bd2d79806421 --- /dev/null +++ b/tools/node_modules/readdirp/examples/callback-api.js @@ -0,0 +1,10 @@ +var readdirp = require('..'); + +readdirp({ root: '.', fileFilter: '*.js' }, function (errors, res) { + if (errors) { + errors.forEach(function (err) { + console.error('Error: ', err); + }); + } + console.log('all javascript files', res); +}); diff --git a/tools/node_modules/readdirp/examples/grep.js b/tools/node_modules/readdirp/examples/grep.js new file mode 100644 index 00000000000000..01d5f2954ca625 --- /dev/null +++ b/tools/node_modules/readdirp/examples/grep.js @@ -0,0 +1,71 @@ +'use strict'; +var readdirp = require('..') + , util = require('util') + , fs = require('fs') + , path = require('path') + , es = require('event-stream') + ; + +function findLinesMatching (searchTerm) { + + return es.through(function (entry) { + var lineno = 0 + , matchingLines = [] + , fileStream = this; + + function filter () { + return es.mapSync(function (line) { + lineno++; + return ~line.indexOf(searchTerm) ? lineno + ': ' + line : undefined; + }); + } + + function aggregate () { + return es.through( + function write (data) { + matchingLines.push(data); + } + , function end () { + + // drop files that had no matches + if (matchingLines.length) { + var result = { file: entry, lines: matchingLines }; + + // pass result on to file stream + fileStream.emit('data', result); + } + this.emit('end'); + } + ); + } + + fs.createReadStream(entry.fullPath, { encoding: 'utf-8' }) + + // handle file contents line by line + .pipe(es.split('\n')) + + // keep only the lines that matched the term + .pipe(filter()) + + // aggregate all matching lines and delegate control back to the file stream + .pipe(aggregate()) + ; + }); +} + +console.log('grepping for "arguments"'); + +// create a stream of all javascript files found in this and all sub directories +readdirp({ root: path.join(__dirname), fileFilter: '*.js' }) + + // find all lines matching the term for each file (if none found, that file is ignored) + .pipe(findLinesMatching('arguments')) + + // format the results and output + .pipe( + es.mapSync(function (res) { + return '\n\n' + res.file.path + '\n\t' + res.lines.join('\n\t'); + }) + ) + .pipe(process.stdout) + ; diff --git a/tools/node_modules/readdirp/examples/package.json b/tools/node_modules/readdirp/examples/package.json new file mode 100644 index 00000000000000..2d9b3411973a9d --- /dev/null +++ b/tools/node_modules/readdirp/examples/package.json @@ -0,0 +1,9 @@ +{ + "name": "readdirp-examples", + "version": "0.0.0", + "description": "Examples for readdirp.", + "dependencies": { + "tap-stream": "~0.1.0", + "event-stream": "~3.0.7" + } +} diff --git a/tools/node_modules/readdirp/examples/stream-api-pipe.js b/tools/node_modules/readdirp/examples/stream-api-pipe.js new file mode 100644 index 00000000000000..4003be8d3a3477 --- /dev/null +++ b/tools/node_modules/readdirp/examples/stream-api-pipe.js @@ -0,0 +1,19 @@ +var readdirp = require('..') + , path = require('path') + , through = require('through2') + +// print out all JavaScript files along with their size +readdirp({ root: path.join(__dirname), fileFilter: '*.js' }) + .on('warn', function (err) { console.error('non-fatal error', err); }) + .on('error', function (err) { console.error('fatal error', err); }) + .pipe(through.obj(function (entry, _, cb) { + this.push({ path: entry.path, size: entry.stat.size }); + cb(); + })) + .pipe(through.obj( + function (res, _, cb) { + this.push(JSON.stringify(res) + '\n'); + cb(); + }) + ) + .pipe(process.stdout); diff --git a/tools/node_modules/readdirp/examples/stream-api.js b/tools/node_modules/readdirp/examples/stream-api.js new file mode 100644 index 00000000000000..0f7b327eb06256 --- /dev/null +++ b/tools/node_modules/readdirp/examples/stream-api.js @@ -0,0 +1,15 @@ +var readdirp = require('..') + , path = require('path'); + +readdirp({ root: path.join(__dirname), fileFilter: '*.js' }) + .on('warn', function (err) { + console.error('something went wrong when processing an entry', err); + }) + .on('error', function (err) { + console.error('something went fatally wrong and the stream was aborted', err); + }) + .on('data', function (entry) { + console.log('%s is ready for processing', entry.path); + // process entry here + }); + diff --git a/tools/node_modules/readdirp/node_modules/minimatch/LICENSE b/tools/node_modules/readdirp/node_modules/minimatch/LICENSE new file mode 100644 index 00000000000000..19129e315fe593 --- /dev/null +++ b/tools/node_modules/readdirp/node_modules/minimatch/LICENSE @@ -0,0 +1,15 @@ +The ISC License + +Copyright (c) Isaac Z. Schlueter and Contributors + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR +IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/tools/node_modules/readdirp/node_modules/minimatch/README.md b/tools/node_modules/readdirp/node_modules/minimatch/README.md new file mode 100644 index 00000000000000..d458bc2e0a6b03 --- /dev/null +++ b/tools/node_modules/readdirp/node_modules/minimatch/README.md @@ -0,0 +1,216 @@ +# minimatch + +A minimal matching utility. + +[![Build Status](https://secure.travis-ci.org/isaacs/minimatch.png)](http://travis-ci.org/isaacs/minimatch) + + +This is the matching library used internally by npm. + +It works by converting glob expressions into JavaScript `RegExp` +objects. + +## Usage + +```javascript +var minimatch = require("minimatch") + +minimatch("bar.foo", "*.foo") // true! +minimatch("bar.foo", "*.bar") // false! +minimatch("bar.foo", "*.+(bar|foo)", { debug: true }) // true, and noisy! +``` + +## Features + +Supports these glob features: + +* Brace Expansion +* Extended glob matching +* "Globstar" `**` matching + +See: + +* `man sh` +* `man bash` +* `man 3 fnmatch` +* `man 5 gitignore` + +## Minimatch Class + +Create a minimatch object by instanting the `minimatch.Minimatch` class. + +```javascript +var Minimatch = require("minimatch").Minimatch +var mm = new Minimatch(pattern, options) +``` + +### Properties + +* `pattern` The original pattern the minimatch object represents. +* `options` The options supplied to the constructor. +* `set` A 2-dimensional array of regexp or string expressions. + Each row in the + array corresponds to a brace-expanded pattern. Each item in the row + corresponds to a single path-part. For example, the pattern + `{a,b/c}/d` would expand to a set of patterns like: + + [ [ a, d ] + , [ b, c, d ] ] + + If a portion of the pattern doesn't have any "magic" in it + (that is, it's something like `"foo"` rather than `fo*o?`), then it + will be left as a string rather than converted to a regular + expression. + +* `regexp` Created by the `makeRe` method. A single regular expression + expressing the entire pattern. This is useful in cases where you wish + to use the pattern somewhat like `fnmatch(3)` with `FNM_PATH` enabled. +* `negate` True if the pattern is negated. +* `comment` True if the pattern is a comment. +* `empty` True if the pattern is `""`. + +### Methods + +* `makeRe` Generate the `regexp` member if necessary, and return it. + Will return `false` if the pattern is invalid. +* `match(fname)` Return true if the filename matches the pattern, or + false otherwise. +* `matchOne(fileArray, patternArray, partial)` Take a `/`-split + filename, and match it against a single row in the `regExpSet`. This + method is mainly for internal use, but is exposed so that it can be + used by a glob-walker that needs to avoid excessive filesystem calls. + +All other methods are internal, and will be called as necessary. + +## Functions + +The top-level exported function has a `cache` property, which is an LRU +cache set to store 100 items. So, calling these methods repeatedly +with the same pattern and options will use the same Minimatch object, +saving the cost of parsing it multiple times. + +### minimatch(path, pattern, options) + +Main export. Tests a path against the pattern using the options. + +```javascript +var isJS = minimatch(file, "*.js", { matchBase: true }) +``` + +### minimatch.filter(pattern, options) + +Returns a function that tests its +supplied argument, suitable for use with `Array.filter`. Example: + +```javascript +var javascripts = fileList.filter(minimatch.filter("*.js", {matchBase: true})) +``` + +### minimatch.match(list, pattern, options) + +Match against the list of +files, in the style of fnmatch or glob. If nothing is matched, and +options.nonull is set, then return a list containing the pattern itself. + +```javascript +var javascripts = minimatch.match(fileList, "*.js", {matchBase: true})) +``` + +### minimatch.makeRe(pattern, options) + +Make a regular expression object from the pattern. + +## Options + +All options are `false` by default. + +### debug + +Dump a ton of stuff to stderr. + +### nobrace + +Do not expand `{a,b}` and `{1..3}` brace sets. + +### noglobstar + +Disable `**` matching against multiple folder names. + +### dot + +Allow patterns to match filenames starting with a period, even if +the pattern does not explicitly have a period in that spot. + +Note that by default, `a/**/b` will **not** match `a/.d/b`, unless `dot` +is set. + +### noext + +Disable "extglob" style patterns like `+(a|b)`. + +### nocase + +Perform a case-insensitive match. + +### nonull + +When a match is not found by `minimatch.match`, return a list containing +the pattern itself if this option is set. When not set, an empty list +is returned if there are no matches. + +### matchBase + +If set, then patterns without slashes will be matched +against the basename of the path if it contains slashes. For example, +`a?b` would match the path `/xyz/123/acb`, but not `/xyz/acb/123`. + +### nocomment + +Suppress the behavior of treating `#` at the start of a pattern as a +comment. + +### nonegate + +Suppress the behavior of treating a leading `!` character as negation. + +### flipNegate + +Returns from negate expressions the same as if they were not negated. +(Ie, true on a hit, false on a miss.) + + +## Comparisons to other fnmatch/glob implementations + +While strict compliance with the existing standards is a worthwhile +goal, some discrepancies exist between minimatch and other +implementations, and are intentional. + +If the pattern starts with a `!` character, then it is negated. Set the +`nonegate` flag to suppress this behavior, and treat leading `!` +characters normally. This is perhaps relevant if you wish to start the +pattern with a negative extglob pattern like `!(a|B)`. Multiple `!` +characters at the start of a pattern will negate the pattern multiple +times. + +If a pattern starts with `#`, then it is treated as a comment, and +will not match anything. Use `\#` to match a literal `#` at the +start of a line, or set the `nocomment` flag to suppress this behavior. + +The double-star character `**` is supported by default, unless the +`noglobstar` flag is set. This is supported in the manner of bsdglob +and bash 4.1, where `**` only has special significance if it is the only +thing in a path part. That is, `a/**/b` will match `a/x/y/b`, but +`a/**b` will not. + +If an escaped pattern has no matches, and the `nonull` flag is set, +then minimatch.match returns the pattern as-provided, rather than +interpreting the character escapes. For example, +`minimatch.match([], "\\*a\\?")` will return `"\\*a\\?"` rather than +`"*a?"`. This is akin to setting the `nullglob` option in bash, except +that it does not resolve escaped pattern characters. + +If brace expansion is not disabled, then it is performed before any +other interpretation of the glob pattern. Thus, a pattern like +`+(a|{b),c)}`, which would not be valid in bash or zsh, is expanded +**first** into the set of `+(a|b)` and `+(a|c)`, and those patterns are +checked for validity. Since those two are valid, matching proceeds. diff --git a/tools/node_modules/readdirp/node_modules/minimatch/browser.js b/tools/node_modules/readdirp/node_modules/minimatch/browser.js new file mode 100644 index 00000000000000..7d0515920e5cb3 --- /dev/null +++ b/tools/node_modules/readdirp/node_modules/minimatch/browser.js @@ -0,0 +1,1159 @@ +(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.minimatch = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o any number of characters +var star = qmark + '*?' + +// ** when dots are allowed. Anything goes, except .. and . +// not (^ or / followed by one or two dots followed by $ or /), +// followed by anything, any number of times. +var twoStarDot = '(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?' + +// not a ^ or / followed by a dot, +// followed by anything, any number of times. +var twoStarNoDot = '(?:(?!(?:\\\/|^)\\.).)*?' + +// characters that need to be escaped in RegExp. +var reSpecials = charSet('().*{}+?[]^$\\!') + +// "abc" -> { a:true, b:true, c:true } +function charSet (s) { + return s.split('').reduce(function (set, c) { + set[c] = true + return set + }, {}) +} + +// normalizes slashes. +var slashSplit = /\/+/ + +minimatch.filter = filter +function filter (pattern, options) { + options = options || {} + return function (p, i, list) { + return minimatch(p, pattern, options) + } +} + +function ext (a, b) { + a = a || {} + b = b || {} + var t = {} + Object.keys(b).forEach(function (k) { + t[k] = b[k] + }) + Object.keys(a).forEach(function (k) { + t[k] = a[k] + }) + return t +} + +minimatch.defaults = function (def) { + if (!def || !Object.keys(def).length) return minimatch + + var orig = minimatch + + var m = function minimatch (p, pattern, options) { + return orig.minimatch(p, pattern, ext(def, options)) + } + + m.Minimatch = function Minimatch (pattern, options) { + return new orig.Minimatch(pattern, ext(def, options)) + } + + return m +} + +Minimatch.defaults = function (def) { + if (!def || !Object.keys(def).length) return Minimatch + return minimatch.defaults(def).Minimatch +} + +function minimatch (p, pattern, options) { + if (typeof pattern !== 'string') { + throw new TypeError('glob pattern string required') + } + + if (!options) options = {} + + // shortcut: comments match nothing. + if (!options.nocomment && pattern.charAt(0) === '#') { + return false + } + + // "" only matches "" + if (pattern.trim() === '') return p === '' + + return new Minimatch(pattern, options).match(p) +} + +function Minimatch (pattern, options) { + if (!(this instanceof Minimatch)) { + return new Minimatch(pattern, options) + } + + if (typeof pattern !== 'string') { + throw new TypeError('glob pattern string required') + } + + if (!options) options = {} + pattern = pattern.trim() + + // windows support: need to use /, not \ + if (path.sep !== '/') { + pattern = pattern.split(path.sep).join('/') + } + + this.options = options + this.set = [] + this.pattern = pattern + this.regexp = null + this.negate = false + this.comment = false + this.empty = false + + // make the set of regexps etc. + this.make() +} + +Minimatch.prototype.debug = function () {} + +Minimatch.prototype.make = make +function make () { + // don't do it more than once. + if (this._made) return + + var pattern = this.pattern + var options = this.options + + // empty patterns and comments match nothing. + if (!options.nocomment && pattern.charAt(0) === '#') { + this.comment = true + return + } + if (!pattern) { + this.empty = true + return + } + + // step 1: figure out negation, etc. + this.parseNegate() + + // step 2: expand braces + var set = this.globSet = this.braceExpand() + + if (options.debug) this.debug = console.error + + this.debug(this.pattern, set) + + // step 3: now we have a set, so turn each one into a series of path-portion + // matching patterns. + // These will be regexps, except in the case of "**", which is + // set to the GLOBSTAR object for globstar behavior, + // and will not contain any / characters + set = this.globParts = set.map(function (s) { + return s.split(slashSplit) + }) + + this.debug(this.pattern, set) + + // glob --> regexps + set = set.map(function (s, si, set) { + return s.map(this.parse, this) + }, this) + + this.debug(this.pattern, set) + + // filter out everything that didn't compile properly. + set = set.filter(function (s) { + return s.indexOf(false) === -1 + }) + + this.debug(this.pattern, set) + + this.set = set +} + +Minimatch.prototype.parseNegate = parseNegate +function parseNegate () { + var pattern = this.pattern + var negate = false + var options = this.options + var negateOffset = 0 + + if (options.nonegate) return + + for (var i = 0, l = pattern.length + ; i < l && pattern.charAt(i) === '!' + ; i++) { + negate = !negate + negateOffset++ + } + + if (negateOffset) this.pattern = pattern.substr(negateOffset) + this.negate = negate +} + +// Brace expansion: +// a{b,c}d -> abd acd +// a{b,}c -> abc ac +// a{0..3}d -> a0d a1d a2d a3d +// a{b,c{d,e}f}g -> abg acdfg acefg +// a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg +// +// Invalid sets are not expanded. +// a{2..}b -> a{2..}b +// a{b}c -> a{b}c +minimatch.braceExpand = function (pattern, options) { + return braceExpand(pattern, options) +} + +Minimatch.prototype.braceExpand = braceExpand + +function braceExpand (pattern, options) { + if (!options) { + if (this instanceof Minimatch) { + options = this.options + } else { + options = {} + } + } + + pattern = typeof pattern === 'undefined' + ? this.pattern : pattern + + if (typeof pattern === 'undefined') { + throw new Error('undefined pattern') + } + + if (options.nobrace || + !pattern.match(/\{.*\}/)) { + // shortcut. no need to expand. + return [pattern] + } + + return expand(pattern) +} + +// parse a component of the expanded set. +// At this point, no pattern may contain "/" in it +// so we're going to return a 2d array, where each entry is the full +// pattern, split on '/', and then turned into a regular expression. +// A regexp is made at the end which joins each array with an +// escaped /, and another full one which joins each regexp with |. +// +// Following the lead of Bash 4.1, note that "**" only has special meaning +// when it is the *only* thing in a path portion. Otherwise, any series +// of * is equivalent to a single *. Globstar behavior is enabled by +// default, and can be disabled by setting options.noglobstar. +Minimatch.prototype.parse = parse +var SUBPARSE = {} +function parse (pattern, isSub) { + var options = this.options + + // shortcuts + if (!options.noglobstar && pattern === '**') return GLOBSTAR + if (pattern === '') return '' + + var re = '' + var hasMagic = !!options.nocase + var escaping = false + // ? => one single character + var patternListStack = [] + var negativeLists = [] + var plType + var stateChar + var inClass = false + var reClassStart = -1 + var classStart = -1 + // . and .. never match anything that doesn't start with ., + // even when options.dot is set. + var patternStart = pattern.charAt(0) === '.' ? '' // anything + // not (start or / followed by . or .. followed by / or end) + : options.dot ? '(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))' + : '(?!\\.)' + var self = this + + function clearStateChar () { + if (stateChar) { + // we had some state-tracking character + // that wasn't consumed by this pass. + switch (stateChar) { + case '*': + re += star + hasMagic = true + break + case '?': + re += qmark + hasMagic = true + break + default: + re += '\\' + stateChar + break + } + self.debug('clearStateChar %j %j', stateChar, re) + stateChar = false + } + } + + for (var i = 0, len = pattern.length, c + ; (i < len) && (c = pattern.charAt(i)) + ; i++) { + this.debug('%s\t%s %s %j', pattern, i, re, c) + + // skip over any that are escaped. + if (escaping && reSpecials[c]) { + re += '\\' + c + escaping = false + continue + } + + switch (c) { + case '/': + // completely not allowed, even escaped. + // Should already be path-split by now. + return false + + case '\\': + clearStateChar() + escaping = true + continue + + // the various stateChar values + // for the "extglob" stuff. + case '?': + case '*': + case '+': + case '@': + case '!': + this.debug('%s\t%s %s %j <-- stateChar', pattern, i, re, c) + + // all of those are literals inside a class, except that + // the glob [!a] means [^a] in regexp + if (inClass) { + this.debug(' in class') + if (c === '!' && i === classStart + 1) c = '^' + re += c + continue + } + + // if we already have a stateChar, then it means + // that there was something like ** or +? in there. + // Handle the stateChar, then proceed with this one. + self.debug('call clearStateChar %j', stateChar) + clearStateChar() + stateChar = c + // if extglob is disabled, then +(asdf|foo) isn't a thing. + // just clear the statechar *now*, rather than even diving into + // the patternList stuff. + if (options.noext) clearStateChar() + continue + + case '(': + if (inClass) { + re += '(' + continue + } + + if (!stateChar) { + re += '\\(' + continue + } + + plType = stateChar + patternListStack.push({ + type: plType, + start: i - 1, + reStart: re.length + }) + // negation is (?:(?!js)[^/]*) + re += stateChar === '!' ? '(?:(?!(?:' : '(?:' + this.debug('plType %j %j', stateChar, re) + stateChar = false + continue + + case ')': + if (inClass || !patternListStack.length) { + re += '\\)' + continue + } + + clearStateChar() + hasMagic = true + re += ')' + var pl = patternListStack.pop() + plType = pl.type + // negation is (?:(?!js)[^/]*) + // The others are (?:) + switch (plType) { + case '!': + negativeLists.push(pl) + re += ')[^/]*?)' + pl.reEnd = re.length + break + case '?': + case '+': + case '*': + re += plType + break + case '@': break // the default anyway + } + continue + + case '|': + if (inClass || !patternListStack.length || escaping) { + re += '\\|' + escaping = false + continue + } + + clearStateChar() + re += '|' + continue + + // these are mostly the same in regexp and glob + case '[': + // swallow any state-tracking char before the [ + clearStateChar() + + if (inClass) { + re += '\\' + c + continue + } + + inClass = true + classStart = i + reClassStart = re.length + re += c + continue + + case ']': + // a right bracket shall lose its special + // meaning and represent itself in + // a bracket expression if it occurs + // first in the list. -- POSIX.2 2.8.3.2 + if (i === classStart + 1 || !inClass) { + re += '\\' + c + escaping = false + continue + } + + // handle the case where we left a class open. + // "[z-a]" is valid, equivalent to "\[z-a\]" + if (inClass) { + // split where the last [ was, make sure we don't have + // an invalid re. if so, re-walk the contents of the + // would-be class to re-translate any characters that + // were passed through as-is + // TODO: It would probably be faster to determine this + // without a try/catch and a new RegExp, but it's tricky + // to do safely. For now, this is safe and works. + var cs = pattern.substring(classStart + 1, i) + try { + RegExp('[' + cs + ']') + } catch (er) { + // not a valid class! + var sp = this.parse(cs, SUBPARSE) + re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]' + hasMagic = hasMagic || sp[1] + inClass = false + continue + } + } + + // finish up the class. + hasMagic = true + inClass = false + re += c + continue + + default: + // swallow any state char that wasn't consumed + clearStateChar() + + if (escaping) { + // no need + escaping = false + } else if (reSpecials[c] + && !(c === '^' && inClass)) { + re += '\\' + } + + re += c + + } // switch + } // for + + // handle the case where we left a class open. + // "[abc" is valid, equivalent to "\[abc" + if (inClass) { + // split where the last [ was, and escape it + // this is a huge pita. We now have to re-walk + // the contents of the would-be class to re-translate + // any characters that were passed through as-is + cs = pattern.substr(classStart + 1) + sp = this.parse(cs, SUBPARSE) + re = re.substr(0, reClassStart) + '\\[' + sp[0] + hasMagic = hasMagic || sp[1] + } + + // handle the case where we had a +( thing at the *end* + // of the pattern. + // each pattern list stack adds 3 chars, and we need to go through + // and escape any | chars that were passed through as-is for the regexp. + // Go through and escape them, taking care not to double-escape any + // | chars that were already escaped. + for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) { + var tail = re.slice(pl.reStart + 3) + // maybe some even number of \, then maybe 1 \, followed by a | + tail = tail.replace(/((?:\\{2})*)(\\?)\|/g, function (_, $1, $2) { + if (!$2) { + // the | isn't already escaped, so escape it. + $2 = '\\' + } + + // need to escape all those slashes *again*, without escaping the + // one that we need for escaping the | character. As it works out, + // escaping an even number of slashes can be done by simply repeating + // it exactly after itself. That's why this trick works. + // + // I am sorry that you have to see this. + return $1 + $1 + $2 + '|' + }) + + this.debug('tail=%j\n %s', tail, tail) + var t = pl.type === '*' ? star + : pl.type === '?' ? qmark + : '\\' + pl.type + + hasMagic = true + re = re.slice(0, pl.reStart) + t + '\\(' + tail + } + + // handle trailing things that only matter at the very end. + clearStateChar() + if (escaping) { + // trailing \\ + re += '\\\\' + } + + // only need to apply the nodot start if the re starts with + // something that could conceivably capture a dot + var addPatternStart = false + switch (re.charAt(0)) { + case '.': + case '[': + case '(': addPatternStart = true + } + + // Hack to work around lack of negative lookbehind in JS + // A pattern like: *.!(x).!(y|z) needs to ensure that a name + // like 'a.xyz.yz' doesn't match. So, the first negative + // lookahead, has to look ALL the way ahead, to the end of + // the pattern. + for (var n = negativeLists.length - 1; n > -1; n--) { + var nl = negativeLists[n] + + var nlBefore = re.slice(0, nl.reStart) + var nlFirst = re.slice(nl.reStart, nl.reEnd - 8) + var nlLast = re.slice(nl.reEnd - 8, nl.reEnd) + var nlAfter = re.slice(nl.reEnd) + + nlLast += nlAfter + + // Handle nested stuff like *(*.js|!(*.json)), where open parens + // mean that we should *not* include the ) in the bit that is considered + // "after" the negated section. + var openParensBefore = nlBefore.split('(').length - 1 + var cleanAfter = nlAfter + for (i = 0; i < openParensBefore; i++) { + cleanAfter = cleanAfter.replace(/\)[+*?]?/, '') + } + nlAfter = cleanAfter + + var dollar = '' + if (nlAfter === '' && isSub !== SUBPARSE) { + dollar = '$' + } + var newRe = nlBefore + nlFirst + nlAfter + dollar + nlLast + re = newRe + } + + // if the re is not "" at this point, then we need to make sure + // it doesn't match against an empty path part. + // Otherwise a/* will match a/, which it should not. + if (re !== '' && hasMagic) { + re = '(?=.)' + re + } + + if (addPatternStart) { + re = patternStart + re + } + + // parsing just a piece of a larger pattern. + if (isSub === SUBPARSE) { + return [re, hasMagic] + } + + // skip the regexp for non-magical patterns + // unescape anything in it, though, so that it'll be + // an exact match against a file etc. + if (!hasMagic) { + return globUnescape(pattern) + } + + var flags = options.nocase ? 'i' : '' + var regExp = new RegExp('^' + re + '$', flags) + + regExp._glob = pattern + regExp._src = re + + return regExp +} + +minimatch.makeRe = function (pattern, options) { + return new Minimatch(pattern, options || {}).makeRe() +} + +Minimatch.prototype.makeRe = makeRe +function makeRe () { + if (this.regexp || this.regexp === false) return this.regexp + + // at this point, this.set is a 2d array of partial + // pattern strings, or "**". + // + // It's better to use .match(). This function shouldn't + // be used, really, but it's pretty convenient sometimes, + // when you just want to work with a regex. + var set = this.set + + if (!set.length) { + this.regexp = false + return this.regexp + } + var options = this.options + + var twoStar = options.noglobstar ? star + : options.dot ? twoStarDot + : twoStarNoDot + var flags = options.nocase ? 'i' : '' + + var re = set.map(function (pattern) { + return pattern.map(function (p) { + return (p === GLOBSTAR) ? twoStar + : (typeof p === 'string') ? regExpEscape(p) + : p._src + }).join('\\\/') + }).join('|') + + // must match entire pattern + // ending in a * or ** will make it less strict. + re = '^(?:' + re + ')$' + + // can match anything, as long as it's not this. + if (this.negate) re = '^(?!' + re + ').*$' + + try { + this.regexp = new RegExp(re, flags) + } catch (ex) { + this.regexp = false + } + return this.regexp +} + +minimatch.match = function (list, pattern, options) { + options = options || {} + var mm = new Minimatch(pattern, options) + list = list.filter(function (f) { + return mm.match(f) + }) + if (mm.options.nonull && !list.length) { + list.push(pattern) + } + return list +} + +Minimatch.prototype.match = match +function match (f, partial) { + this.debug('match', f, this.pattern) + // short-circuit in the case of busted things. + // comments, etc. + if (this.comment) return false + if (this.empty) return f === '' + + if (f === '/' && partial) return true + + var options = this.options + + // windows: need to use /, not \ + if (path.sep !== '/') { + f = f.split(path.sep).join('/') + } + + // treat the test path as a set of pathparts. + f = f.split(slashSplit) + this.debug(this.pattern, 'split', f) + + // just ONE of the pattern sets in this.set needs to match + // in order for it to be valid. If negating, then just one + // match means that we have failed. + // Either way, return on the first hit. + + var set = this.set + this.debug(this.pattern, 'set', set) + + // Find the basename of the path by looking for the last non-empty segment + var filename + var i + for (i = f.length - 1; i >= 0; i--) { + filename = f[i] + if (filename) break + } + + for (i = 0; i < set.length; i++) { + var pattern = set[i] + var file = f + if (options.matchBase && pattern.length === 1) { + file = [filename] + } + var hit = this.matchOne(file, pattern, partial) + if (hit) { + if (options.flipNegate) return true + return !this.negate + } + } + + // didn't get any hits. this is success if it's a negative + // pattern, failure otherwise. + if (options.flipNegate) return false + return this.negate +} + +// set partial to true to test if, for example, +// "/a/b" matches the start of "/*/b/*/d" +// Partial means, if you run out of file before you run +// out of pattern, then that's fine, as long as all +// the parts match. +Minimatch.prototype.matchOne = function (file, pattern, partial) { + var options = this.options + + this.debug('matchOne', + { 'this': this, file: file, pattern: pattern }) + + this.debug('matchOne', file.length, pattern.length) + + for (var fi = 0, + pi = 0, + fl = file.length, + pl = pattern.length + ; (fi < fl) && (pi < pl) + ; fi++, pi++) { + this.debug('matchOne loop') + var p = pattern[pi] + var f = file[fi] + + this.debug(pattern, p, f) + + // should be impossible. + // some invalid regexp stuff in the set. + if (p === false) return false + + if (p === GLOBSTAR) { + this.debug('GLOBSTAR', [pattern, p, f]) + + // "**" + // a/**/b/**/c would match the following: + // a/b/x/y/z/c + // a/x/y/z/b/c + // a/b/x/b/x/c + // a/b/c + // To do this, take the rest of the pattern after + // the **, and see if it would match the file remainder. + // If so, return success. + // If not, the ** "swallows" a segment, and try again. + // This is recursively awful. + // + // a/**/b/**/c matching a/b/x/y/z/c + // - a matches a + // - doublestar + // - matchOne(b/x/y/z/c, b/**/c) + // - b matches b + // - doublestar + // - matchOne(x/y/z/c, c) -> no + // - matchOne(y/z/c, c) -> no + // - matchOne(z/c, c) -> no + // - matchOne(c, c) yes, hit + var fr = fi + var pr = pi + 1 + if (pr === pl) { + this.debug('** at the end') + // a ** at the end will just swallow the rest. + // We have found a match. + // however, it will not swallow /.x, unless + // options.dot is set. + // . and .. are *never* matched by **, for explosively + // exponential reasons. + for (; fi < fl; fi++) { + if (file[fi] === '.' || file[fi] === '..' || + (!options.dot && file[fi].charAt(0) === '.')) return false + } + return true + } + + // ok, let's see if we can swallow whatever we can. + while (fr < fl) { + var swallowee = file[fr] + + this.debug('\nglobstar while', file, fr, pattern, pr, swallowee) + + // XXX remove this slice. Just pass the start index. + if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) { + this.debug('globstar found match!', fr, fl, swallowee) + // found a match. + return true + } else { + // can't swallow "." or ".." ever. + // can only swallow ".foo" when explicitly asked. + if (swallowee === '.' || swallowee === '..' || + (!options.dot && swallowee.charAt(0) === '.')) { + this.debug('dot detected!', file, fr, pattern, pr) + break + } + + // ** swallows a segment, and continue. + this.debug('globstar swallow a segment, and continue') + fr++ + } + } + + // no match was found. + // However, in partial mode, we can't say this is necessarily over. + // If there's more *pattern* left, then + if (partial) { + // ran out of file + this.debug('\n>>> no match, partial?', file, fr, pattern, pr) + if (fr === fl) return true + } + return false + } + + // something other than ** + // non-magic patterns just have to match exactly + // patterns with magic have been turned into regexps. + var hit + if (typeof p === 'string') { + if (options.nocase) { + hit = f.toLowerCase() === p.toLowerCase() + } else { + hit = f === p + } + this.debug('string match', p, f, hit) + } else { + hit = f.match(p) + this.debug('pattern match', p, f, hit) + } + + if (!hit) return false + } + + // Note: ending in / means that we'll get a final "" + // at the end of the pattern. This can only match a + // corresponding "" at the end of the file. + // If the file ends in /, then it can only match a + // a pattern that ends in /, unless the pattern just + // doesn't have any more for it. But, a/b/ should *not* + // match "a/b/*", even though "" matches against the + // [^/]*? pattern, except in partial mode, where it might + // simply not be reached yet. + // However, a/b/ should still satisfy a/* + + // now either we fell off the end of the pattern, or we're done. + if (fi === fl && pi === pl) { + // ran out of pattern and filename at the same time. + // an exact hit! + return true + } else if (fi === fl) { + // ran out of file, but still had pattern left. + // this is ok if we're doing the match as part of + // a glob fs traversal. + return partial + } else if (pi === pl) { + // ran out of pattern, still have file left. + // this is only acceptable if we're on the very last + // empty segment of a file with a trailing slash. + // a/* should match a/b/ + var emptyFileEnd = (fi === fl - 1) && (file[fi] === '') + return emptyFileEnd + } + + // should be unreachable. + throw new Error('wtf?') +} + +// replace stuff like \* with * +function globUnescape (s) { + return s.replace(/\\(.)/g, '$1') +} + +function regExpEscape (s) { + return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&') +} + +},{"brace-expansion":2,"path":undefined}],2:[function(require,module,exports){ +var concatMap = require('concat-map'); +var balanced = require('balanced-match'); + +module.exports = expandTop; + +var escSlash = '\0SLASH'+Math.random()+'\0'; +var escOpen = '\0OPEN'+Math.random()+'\0'; +var escClose = '\0CLOSE'+Math.random()+'\0'; +var escComma = '\0COMMA'+Math.random()+'\0'; +var escPeriod = '\0PERIOD'+Math.random()+'\0'; + +function numeric(str) { + return parseInt(str, 10) == str + ? parseInt(str, 10) + : str.charCodeAt(0); +} + +function escapeBraces(str) { + return str.split('\\\\').join(escSlash) + .split('\\{').join(escOpen) + .split('\\}').join(escClose) + .split('\\,').join(escComma) + .split('\\.').join(escPeriod); +} + +function unescapeBraces(str) { + return str.split(escSlash).join('\\') + .split(escOpen).join('{') + .split(escClose).join('}') + .split(escComma).join(',') + .split(escPeriod).join('.'); +} + + +// Basically just str.split(","), but handling cases +// where we have nested braced sections, which should be +// treated as individual members, like {a,{b,c},d} +function parseCommaParts(str) { + if (!str) + return ['']; + + var parts = []; + var m = balanced('{', '}', str); + + if (!m) + return str.split(','); + + var pre = m.pre; + var body = m.body; + var post = m.post; + var p = pre.split(','); + + p[p.length-1] += '{' + body + '}'; + var postParts = parseCommaParts(post); + if (post.length) { + p[p.length-1] += postParts.shift(); + p.push.apply(p, postParts); + } + + parts.push.apply(parts, p); + + return parts; +} + +function expandTop(str) { + if (!str) + return []; + + var expansions = expand(escapeBraces(str)); + return expansions.filter(identity).map(unescapeBraces); +} + +function identity(e) { + return e; +} + +function embrace(str) { + return '{' + str + '}'; +} +function isPadded(el) { + return /^-?0\d/.test(el); +} + +function lte(i, y) { + return i <= y; +} +function gte(i, y) { + return i >= y; +} + +function expand(str) { + var expansions = []; + + var m = balanced('{', '}', str); + if (!m || /\$$/.test(m.pre)) return [str]; + + var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body); + var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body); + var isSequence = isNumericSequence || isAlphaSequence; + var isOptions = /^(.*,)+(.+)?$/.test(m.body); + if (!isSequence && !isOptions) { + // {a},b} + if (m.post.match(/,.*}/)) { + str = m.pre + '{' + m.body + escClose + m.post; + return expand(str); + } + return [str]; + } + + var n; + if (isSequence) { + n = m.body.split(/\.\./); + } else { + n = parseCommaParts(m.body); + if (n.length === 1) { + // x{{a,b}}y ==> x{a}y x{b}y + n = expand(n[0]).map(embrace); + if (n.length === 1) { + var post = m.post.length + ? expand(m.post) + : ['']; + return post.map(function(p) { + return m.pre + n[0] + p; + }); + } + } + } + + // at this point, n is the parts, and we know it's not a comma set + // with a single entry. + + // no need to expand pre, since it is guaranteed to be free of brace-sets + var pre = m.pre; + var post = m.post.length + ? expand(m.post) + : ['']; + + var N; + + if (isSequence) { + var x = numeric(n[0]); + var y = numeric(n[1]); + var width = Math.max(n[0].length, n[1].length) + var incr = n.length == 3 + ? Math.abs(numeric(n[2])) + : 1; + var test = lte; + var reverse = y < x; + if (reverse) { + incr *= -1; + test = gte; + } + var pad = n.some(isPadded); + + N = []; + + for (var i = x; test(i, y); i += incr) { + var c; + if (isAlphaSequence) { + c = String.fromCharCode(i); + if (c === '\\') + c = ''; + } else { + c = String(i); + if (pad) { + var need = width - c.length; + if (need > 0) { + var z = new Array(need + 1).join('0'); + if (i < 0) + c = '-' + z + c.slice(1); + else + c = z + c; + } + } + } + N.push(c); + } + } else { + N = concatMap(n, function(el) { return expand(el) }); + } + + for (var j = 0; j < N.length; j++) { + for (var k = 0; k < post.length; k++) { + expansions.push([pre, N[j], post[k]].join('')) + } + } + + return expansions; +} + + +},{"balanced-match":3,"concat-map":4}],3:[function(require,module,exports){ +module.exports = balanced; +function balanced(a, b, str) { + var bal = 0; + var m = {}; + var ended = false; + + for (var i = 0; i < str.length; i++) { + if (a == str.substr(i, a.length)) { + if (!('start' in m)) m.start = i; + bal++; + } + else if (b == str.substr(i, b.length) && 'start' in m) { + ended = true; + bal--; + if (!bal) { + m.end = i; + m.pre = str.substr(0, m.start); + m.body = (m.end - m.start > 1) + ? str.substring(m.start + a.length, m.end) + : ''; + m.post = str.slice(m.end + b.length); + return m; + } + } + } + + // if we opened more than we closed, find the one we closed + if (bal && ended) { + var start = m.start + a.length; + m = balanced(a, b, str.substr(start)); + if (m) { + m.start += start; + m.end += start; + m.pre = str.slice(0, start) + m.pre; + } + return m; + } +} + +},{}],4:[function(require,module,exports){ +module.exports = function (xs, fn) { + var res = []; + for (var i = 0; i < xs.length; i++) { + var x = fn(xs[i], i); + if (Array.isArray(x)) res.push.apply(res, x); + else res.push(x); + } + return res; +}; + +},{}]},{},[1])(1) +}); \ No newline at end of file diff --git a/tools/node_modules/readdirp/node_modules/minimatch/minimatch.js b/tools/node_modules/readdirp/node_modules/minimatch/minimatch.js new file mode 100644 index 00000000000000..ec4c05c570c52e --- /dev/null +++ b/tools/node_modules/readdirp/node_modules/minimatch/minimatch.js @@ -0,0 +1,912 @@ +module.exports = minimatch +minimatch.Minimatch = Minimatch + +var path = { sep: '/' } +try { + path = require('path') +} catch (er) {} + +var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {} +var expand = require('brace-expansion') + +// any single thing other than / +// don't need to escape / when using new RegExp() +var qmark = '[^/]' + +// * => any number of characters +var star = qmark + '*?' + +// ** when dots are allowed. Anything goes, except .. and . +// not (^ or / followed by one or two dots followed by $ or /), +// followed by anything, any number of times. +var twoStarDot = '(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?' + +// not a ^ or / followed by a dot, +// followed by anything, any number of times. +var twoStarNoDot = '(?:(?!(?:\\\/|^)\\.).)*?' + +// characters that need to be escaped in RegExp. +var reSpecials = charSet('().*{}+?[]^$\\!') + +// "abc" -> { a:true, b:true, c:true } +function charSet (s) { + return s.split('').reduce(function (set, c) { + set[c] = true + return set + }, {}) +} + +// normalizes slashes. +var slashSplit = /\/+/ + +minimatch.filter = filter +function filter (pattern, options) { + options = options || {} + return function (p, i, list) { + return minimatch(p, pattern, options) + } +} + +function ext (a, b) { + a = a || {} + b = b || {} + var t = {} + Object.keys(b).forEach(function (k) { + t[k] = b[k] + }) + Object.keys(a).forEach(function (k) { + t[k] = a[k] + }) + return t +} + +minimatch.defaults = function (def) { + if (!def || !Object.keys(def).length) return minimatch + + var orig = minimatch + + var m = function minimatch (p, pattern, options) { + return orig.minimatch(p, pattern, ext(def, options)) + } + + m.Minimatch = function Minimatch (pattern, options) { + return new orig.Minimatch(pattern, ext(def, options)) + } + + return m +} + +Minimatch.defaults = function (def) { + if (!def || !Object.keys(def).length) return Minimatch + return minimatch.defaults(def).Minimatch +} + +function minimatch (p, pattern, options) { + if (typeof pattern !== 'string') { + throw new TypeError('glob pattern string required') + } + + if (!options) options = {} + + // shortcut: comments match nothing. + if (!options.nocomment && pattern.charAt(0) === '#') { + return false + } + + // "" only matches "" + if (pattern.trim() === '') return p === '' + + return new Minimatch(pattern, options).match(p) +} + +function Minimatch (pattern, options) { + if (!(this instanceof Minimatch)) { + return new Minimatch(pattern, options) + } + + if (typeof pattern !== 'string') { + throw new TypeError('glob pattern string required') + } + + if (!options) options = {} + pattern = pattern.trim() + + // windows support: need to use /, not \ + if (path.sep !== '/') { + pattern = pattern.split(path.sep).join('/') + } + + this.options = options + this.set = [] + this.pattern = pattern + this.regexp = null + this.negate = false + this.comment = false + this.empty = false + + // make the set of regexps etc. + this.make() +} + +Minimatch.prototype.debug = function () {} + +Minimatch.prototype.make = make +function make () { + // don't do it more than once. + if (this._made) return + + var pattern = this.pattern + var options = this.options + + // empty patterns and comments match nothing. + if (!options.nocomment && pattern.charAt(0) === '#') { + this.comment = true + return + } + if (!pattern) { + this.empty = true + return + } + + // step 1: figure out negation, etc. + this.parseNegate() + + // step 2: expand braces + var set = this.globSet = this.braceExpand() + + if (options.debug) this.debug = console.error + + this.debug(this.pattern, set) + + // step 3: now we have a set, so turn each one into a series of path-portion + // matching patterns. + // These will be regexps, except in the case of "**", which is + // set to the GLOBSTAR object for globstar behavior, + // and will not contain any / characters + set = this.globParts = set.map(function (s) { + return s.split(slashSplit) + }) + + this.debug(this.pattern, set) + + // glob --> regexps + set = set.map(function (s, si, set) { + return s.map(this.parse, this) + }, this) + + this.debug(this.pattern, set) + + // filter out everything that didn't compile properly. + set = set.filter(function (s) { + return s.indexOf(false) === -1 + }) + + this.debug(this.pattern, set) + + this.set = set +} + +Minimatch.prototype.parseNegate = parseNegate +function parseNegate () { + var pattern = this.pattern + var negate = false + var options = this.options + var negateOffset = 0 + + if (options.nonegate) return + + for (var i = 0, l = pattern.length + ; i < l && pattern.charAt(i) === '!' + ; i++) { + negate = !negate + negateOffset++ + } + + if (negateOffset) this.pattern = pattern.substr(negateOffset) + this.negate = negate +} + +// Brace expansion: +// a{b,c}d -> abd acd +// a{b,}c -> abc ac +// a{0..3}d -> a0d a1d a2d a3d +// a{b,c{d,e}f}g -> abg acdfg acefg +// a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg +// +// Invalid sets are not expanded. +// a{2..}b -> a{2..}b +// a{b}c -> a{b}c +minimatch.braceExpand = function (pattern, options) { + return braceExpand(pattern, options) +} + +Minimatch.prototype.braceExpand = braceExpand + +function braceExpand (pattern, options) { + if (!options) { + if (this instanceof Minimatch) { + options = this.options + } else { + options = {} + } + } + + pattern = typeof pattern === 'undefined' + ? this.pattern : pattern + + if (typeof pattern === 'undefined') { + throw new Error('undefined pattern') + } + + if (options.nobrace || + !pattern.match(/\{.*\}/)) { + // shortcut. no need to expand. + return [pattern] + } + + return expand(pattern) +} + +// parse a component of the expanded set. +// At this point, no pattern may contain "/" in it +// so we're going to return a 2d array, where each entry is the full +// pattern, split on '/', and then turned into a regular expression. +// A regexp is made at the end which joins each array with an +// escaped /, and another full one which joins each regexp with |. +// +// Following the lead of Bash 4.1, note that "**" only has special meaning +// when it is the *only* thing in a path portion. Otherwise, any series +// of * is equivalent to a single *. Globstar behavior is enabled by +// default, and can be disabled by setting options.noglobstar. +Minimatch.prototype.parse = parse +var SUBPARSE = {} +function parse (pattern, isSub) { + var options = this.options + + // shortcuts + if (!options.noglobstar && pattern === '**') return GLOBSTAR + if (pattern === '') return '' + + var re = '' + var hasMagic = !!options.nocase + var escaping = false + // ? => one single character + var patternListStack = [] + var negativeLists = [] + var plType + var stateChar + var inClass = false + var reClassStart = -1 + var classStart = -1 + // . and .. never match anything that doesn't start with ., + // even when options.dot is set. + var patternStart = pattern.charAt(0) === '.' ? '' // anything + // not (start or / followed by . or .. followed by / or end) + : options.dot ? '(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))' + : '(?!\\.)' + var self = this + + function clearStateChar () { + if (stateChar) { + // we had some state-tracking character + // that wasn't consumed by this pass. + switch (stateChar) { + case '*': + re += star + hasMagic = true + break + case '?': + re += qmark + hasMagic = true + break + default: + re += '\\' + stateChar + break + } + self.debug('clearStateChar %j %j', stateChar, re) + stateChar = false + } + } + + for (var i = 0, len = pattern.length, c + ; (i < len) && (c = pattern.charAt(i)) + ; i++) { + this.debug('%s\t%s %s %j', pattern, i, re, c) + + // skip over any that are escaped. + if (escaping && reSpecials[c]) { + re += '\\' + c + escaping = false + continue + } + + switch (c) { + case '/': + // completely not allowed, even escaped. + // Should already be path-split by now. + return false + + case '\\': + clearStateChar() + escaping = true + continue + + // the various stateChar values + // for the "extglob" stuff. + case '?': + case '*': + case '+': + case '@': + case '!': + this.debug('%s\t%s %s %j <-- stateChar', pattern, i, re, c) + + // all of those are literals inside a class, except that + // the glob [!a] means [^a] in regexp + if (inClass) { + this.debug(' in class') + if (c === '!' && i === classStart + 1) c = '^' + re += c + continue + } + + // if we already have a stateChar, then it means + // that there was something like ** or +? in there. + // Handle the stateChar, then proceed with this one. + self.debug('call clearStateChar %j', stateChar) + clearStateChar() + stateChar = c + // if extglob is disabled, then +(asdf|foo) isn't a thing. + // just clear the statechar *now*, rather than even diving into + // the patternList stuff. + if (options.noext) clearStateChar() + continue + + case '(': + if (inClass) { + re += '(' + continue + } + + if (!stateChar) { + re += '\\(' + continue + } + + plType = stateChar + patternListStack.push({ + type: plType, + start: i - 1, + reStart: re.length + }) + // negation is (?:(?!js)[^/]*) + re += stateChar === '!' ? '(?:(?!(?:' : '(?:' + this.debug('plType %j %j', stateChar, re) + stateChar = false + continue + + case ')': + if (inClass || !patternListStack.length) { + re += '\\)' + continue + } + + clearStateChar() + hasMagic = true + re += ')' + var pl = patternListStack.pop() + plType = pl.type + // negation is (?:(?!js)[^/]*) + // The others are (?:) + switch (plType) { + case '!': + negativeLists.push(pl) + re += ')[^/]*?)' + pl.reEnd = re.length + break + case '?': + case '+': + case '*': + re += plType + break + case '@': break // the default anyway + } + continue + + case '|': + if (inClass || !patternListStack.length || escaping) { + re += '\\|' + escaping = false + continue + } + + clearStateChar() + re += '|' + continue + + // these are mostly the same in regexp and glob + case '[': + // swallow any state-tracking char before the [ + clearStateChar() + + if (inClass) { + re += '\\' + c + continue + } + + inClass = true + classStart = i + reClassStart = re.length + re += c + continue + + case ']': + // a right bracket shall lose its special + // meaning and represent itself in + // a bracket expression if it occurs + // first in the list. -- POSIX.2 2.8.3.2 + if (i === classStart + 1 || !inClass) { + re += '\\' + c + escaping = false + continue + } + + // handle the case where we left a class open. + // "[z-a]" is valid, equivalent to "\[z-a\]" + if (inClass) { + // split where the last [ was, make sure we don't have + // an invalid re. if so, re-walk the contents of the + // would-be class to re-translate any characters that + // were passed through as-is + // TODO: It would probably be faster to determine this + // without a try/catch and a new RegExp, but it's tricky + // to do safely. For now, this is safe and works. + var cs = pattern.substring(classStart + 1, i) + try { + RegExp('[' + cs + ']') + } catch (er) { + // not a valid class! + var sp = this.parse(cs, SUBPARSE) + re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]' + hasMagic = hasMagic || sp[1] + inClass = false + continue + } + } + + // finish up the class. + hasMagic = true + inClass = false + re += c + continue + + default: + // swallow any state char that wasn't consumed + clearStateChar() + + if (escaping) { + // no need + escaping = false + } else if (reSpecials[c] + && !(c === '^' && inClass)) { + re += '\\' + } + + re += c + + } // switch + } // for + + // handle the case where we left a class open. + // "[abc" is valid, equivalent to "\[abc" + if (inClass) { + // split where the last [ was, and escape it + // this is a huge pita. We now have to re-walk + // the contents of the would-be class to re-translate + // any characters that were passed through as-is + cs = pattern.substr(classStart + 1) + sp = this.parse(cs, SUBPARSE) + re = re.substr(0, reClassStart) + '\\[' + sp[0] + hasMagic = hasMagic || sp[1] + } + + // handle the case where we had a +( thing at the *end* + // of the pattern. + // each pattern list stack adds 3 chars, and we need to go through + // and escape any | chars that were passed through as-is for the regexp. + // Go through and escape them, taking care not to double-escape any + // | chars that were already escaped. + for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) { + var tail = re.slice(pl.reStart + 3) + // maybe some even number of \, then maybe 1 \, followed by a | + tail = tail.replace(/((?:\\{2})*)(\\?)\|/g, function (_, $1, $2) { + if (!$2) { + // the | isn't already escaped, so escape it. + $2 = '\\' + } + + // need to escape all those slashes *again*, without escaping the + // one that we need for escaping the | character. As it works out, + // escaping an even number of slashes can be done by simply repeating + // it exactly after itself. That's why this trick works. + // + // I am sorry that you have to see this. + return $1 + $1 + $2 + '|' + }) + + this.debug('tail=%j\n %s', tail, tail) + var t = pl.type === '*' ? star + : pl.type === '?' ? qmark + : '\\' + pl.type + + hasMagic = true + re = re.slice(0, pl.reStart) + t + '\\(' + tail + } + + // handle trailing things that only matter at the very end. + clearStateChar() + if (escaping) { + // trailing \\ + re += '\\\\' + } + + // only need to apply the nodot start if the re starts with + // something that could conceivably capture a dot + var addPatternStart = false + switch (re.charAt(0)) { + case '.': + case '[': + case '(': addPatternStart = true + } + + // Hack to work around lack of negative lookbehind in JS + // A pattern like: *.!(x).!(y|z) needs to ensure that a name + // like 'a.xyz.yz' doesn't match. So, the first negative + // lookahead, has to look ALL the way ahead, to the end of + // the pattern. + for (var n = negativeLists.length - 1; n > -1; n--) { + var nl = negativeLists[n] + + var nlBefore = re.slice(0, nl.reStart) + var nlFirst = re.slice(nl.reStart, nl.reEnd - 8) + var nlLast = re.slice(nl.reEnd - 8, nl.reEnd) + var nlAfter = re.slice(nl.reEnd) + + nlLast += nlAfter + + // Handle nested stuff like *(*.js|!(*.json)), where open parens + // mean that we should *not* include the ) in the bit that is considered + // "after" the negated section. + var openParensBefore = nlBefore.split('(').length - 1 + var cleanAfter = nlAfter + for (i = 0; i < openParensBefore; i++) { + cleanAfter = cleanAfter.replace(/\)[+*?]?/, '') + } + nlAfter = cleanAfter + + var dollar = '' + if (nlAfter === '' && isSub !== SUBPARSE) { + dollar = '$' + } + var newRe = nlBefore + nlFirst + nlAfter + dollar + nlLast + re = newRe + } + + // if the re is not "" at this point, then we need to make sure + // it doesn't match against an empty path part. + // Otherwise a/* will match a/, which it should not. + if (re !== '' && hasMagic) { + re = '(?=.)' + re + } + + if (addPatternStart) { + re = patternStart + re + } + + // parsing just a piece of a larger pattern. + if (isSub === SUBPARSE) { + return [re, hasMagic] + } + + // skip the regexp for non-magical patterns + // unescape anything in it, though, so that it'll be + // an exact match against a file etc. + if (!hasMagic) { + return globUnescape(pattern) + } + + var flags = options.nocase ? 'i' : '' + var regExp = new RegExp('^' + re + '$', flags) + + regExp._glob = pattern + regExp._src = re + + return regExp +} + +minimatch.makeRe = function (pattern, options) { + return new Minimatch(pattern, options || {}).makeRe() +} + +Minimatch.prototype.makeRe = makeRe +function makeRe () { + if (this.regexp || this.regexp === false) return this.regexp + + // at this point, this.set is a 2d array of partial + // pattern strings, or "**". + // + // It's better to use .match(). This function shouldn't + // be used, really, but it's pretty convenient sometimes, + // when you just want to work with a regex. + var set = this.set + + if (!set.length) { + this.regexp = false + return this.regexp + } + var options = this.options + + var twoStar = options.noglobstar ? star + : options.dot ? twoStarDot + : twoStarNoDot + var flags = options.nocase ? 'i' : '' + + var re = set.map(function (pattern) { + return pattern.map(function (p) { + return (p === GLOBSTAR) ? twoStar + : (typeof p === 'string') ? regExpEscape(p) + : p._src + }).join('\\\/') + }).join('|') + + // must match entire pattern + // ending in a * or ** will make it less strict. + re = '^(?:' + re + ')$' + + // can match anything, as long as it's not this. + if (this.negate) re = '^(?!' + re + ').*$' + + try { + this.regexp = new RegExp(re, flags) + } catch (ex) { + this.regexp = false + } + return this.regexp +} + +minimatch.match = function (list, pattern, options) { + options = options || {} + var mm = new Minimatch(pattern, options) + list = list.filter(function (f) { + return mm.match(f) + }) + if (mm.options.nonull && !list.length) { + list.push(pattern) + } + return list +} + +Minimatch.prototype.match = match +function match (f, partial) { + this.debug('match', f, this.pattern) + // short-circuit in the case of busted things. + // comments, etc. + if (this.comment) return false + if (this.empty) return f === '' + + if (f === '/' && partial) return true + + var options = this.options + + // windows: need to use /, not \ + if (path.sep !== '/') { + f = f.split(path.sep).join('/') + } + + // treat the test path as a set of pathparts. + f = f.split(slashSplit) + this.debug(this.pattern, 'split', f) + + // just ONE of the pattern sets in this.set needs to match + // in order for it to be valid. If negating, then just one + // match means that we have failed. + // Either way, return on the first hit. + + var set = this.set + this.debug(this.pattern, 'set', set) + + // Find the basename of the path by looking for the last non-empty segment + var filename + var i + for (i = f.length - 1; i >= 0; i--) { + filename = f[i] + if (filename) break + } + + for (i = 0; i < set.length; i++) { + var pattern = set[i] + var file = f + if (options.matchBase && pattern.length === 1) { + file = [filename] + } + var hit = this.matchOne(file, pattern, partial) + if (hit) { + if (options.flipNegate) return true + return !this.negate + } + } + + // didn't get any hits. this is success if it's a negative + // pattern, failure otherwise. + if (options.flipNegate) return false + return this.negate +} + +// set partial to true to test if, for example, +// "/a/b" matches the start of "/*/b/*/d" +// Partial means, if you run out of file before you run +// out of pattern, then that's fine, as long as all +// the parts match. +Minimatch.prototype.matchOne = function (file, pattern, partial) { + var options = this.options + + this.debug('matchOne', + { 'this': this, file: file, pattern: pattern }) + + this.debug('matchOne', file.length, pattern.length) + + for (var fi = 0, + pi = 0, + fl = file.length, + pl = pattern.length + ; (fi < fl) && (pi < pl) + ; fi++, pi++) { + this.debug('matchOne loop') + var p = pattern[pi] + var f = file[fi] + + this.debug(pattern, p, f) + + // should be impossible. + // some invalid regexp stuff in the set. + if (p === false) return false + + if (p === GLOBSTAR) { + this.debug('GLOBSTAR', [pattern, p, f]) + + // "**" + // a/**/b/**/c would match the following: + // a/b/x/y/z/c + // a/x/y/z/b/c + // a/b/x/b/x/c + // a/b/c + // To do this, take the rest of the pattern after + // the **, and see if it would match the file remainder. + // If so, return success. + // If not, the ** "swallows" a segment, and try again. + // This is recursively awful. + // + // a/**/b/**/c matching a/b/x/y/z/c + // - a matches a + // - doublestar + // - matchOne(b/x/y/z/c, b/**/c) + // - b matches b + // - doublestar + // - matchOne(x/y/z/c, c) -> no + // - matchOne(y/z/c, c) -> no + // - matchOne(z/c, c) -> no + // - matchOne(c, c) yes, hit + var fr = fi + var pr = pi + 1 + if (pr === pl) { + this.debug('** at the end') + // a ** at the end will just swallow the rest. + // We have found a match. + // however, it will not swallow /.x, unless + // options.dot is set. + // . and .. are *never* matched by **, for explosively + // exponential reasons. + for (; fi < fl; fi++) { + if (file[fi] === '.' || file[fi] === '..' || + (!options.dot && file[fi].charAt(0) === '.')) return false + } + return true + } + + // ok, let's see if we can swallow whatever we can. + while (fr < fl) { + var swallowee = file[fr] + + this.debug('\nglobstar while', file, fr, pattern, pr, swallowee) + + // XXX remove this slice. Just pass the start index. + if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) { + this.debug('globstar found match!', fr, fl, swallowee) + // found a match. + return true + } else { + // can't swallow "." or ".." ever. + // can only swallow ".foo" when explicitly asked. + if (swallowee === '.' || swallowee === '..' || + (!options.dot && swallowee.charAt(0) === '.')) { + this.debug('dot detected!', file, fr, pattern, pr) + break + } + + // ** swallows a segment, and continue. + this.debug('globstar swallow a segment, and continue') + fr++ + } + } + + // no match was found. + // However, in partial mode, we can't say this is necessarily over. + // If there's more *pattern* left, then + if (partial) { + // ran out of file + this.debug('\n>>> no match, partial?', file, fr, pattern, pr) + if (fr === fl) return true + } + return false + } + + // something other than ** + // non-magic patterns just have to match exactly + // patterns with magic have been turned into regexps. + var hit + if (typeof p === 'string') { + if (options.nocase) { + hit = f.toLowerCase() === p.toLowerCase() + } else { + hit = f === p + } + this.debug('string match', p, f, hit) + } else { + hit = f.match(p) + this.debug('pattern match', p, f, hit) + } + + if (!hit) return false + } + + // Note: ending in / means that we'll get a final "" + // at the end of the pattern. This can only match a + // corresponding "" at the end of the file. + // If the file ends in /, then it can only match a + // a pattern that ends in /, unless the pattern just + // doesn't have any more for it. But, a/b/ should *not* + // match "a/b/*", even though "" matches against the + // [^/]*? pattern, except in partial mode, where it might + // simply not be reached yet. + // However, a/b/ should still satisfy a/* + + // now either we fell off the end of the pattern, or we're done. + if (fi === fl && pi === pl) { + // ran out of pattern and filename at the same time. + // an exact hit! + return true + } else if (fi === fl) { + // ran out of file, but still had pattern left. + // this is ok if we're doing the match as part of + // a glob fs traversal. + return partial + } else if (pi === pl) { + // ran out of pattern, still have file left. + // this is only acceptable if we're on the very last + // empty segment of a file with a trailing slash. + // a/* should match a/b/ + var emptyFileEnd = (fi === fl - 1) && (file[fi] === '') + return emptyFileEnd + } + + // should be unreachable. + throw new Error('wtf?') +} + +// replace stuff like \* with * +function globUnescape (s) { + return s.replace(/\\(.)/g, '$1') +} + +function regExpEscape (s) { + return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&') +} diff --git a/tools/node_modules/readdirp/node_modules/minimatch/package.json b/tools/node_modules/readdirp/node_modules/minimatch/package.json new file mode 100644 index 00000000000000..f72f8bf6e24d22 --- /dev/null +++ b/tools/node_modules/readdirp/node_modules/minimatch/package.json @@ -0,0 +1,87 @@ +{ + "_args": [ + [ + "minimatch@^2.0.10", + "C:\\wamp\\www\\node\\tools\\node_modules\\readdirp" + ] + ], + "_from": "minimatch@>=2.0.10 <3.0.0", + "_id": "minimatch@2.0.10", + "_inCache": true, + "_location": "/readdirp/minimatch", + "_nodeVersion": "2.2.1", + "_npmUser": { + "email": "isaacs@npmjs.com", + "name": "isaacs" + }, + "_npmVersion": "3.1.0", + "_phantomChildren": {}, + "_requested": { + "name": "minimatch", + "raw": "minimatch@^2.0.10", + "rawSpec": "^2.0.10", + "scope": null, + "spec": ">=2.0.10 <3.0.0", + "type": "range" + }, + "_requiredBy": [ + "/readdirp" + ], + "_resolved": "https://registry.npmjs.org/minimatch/-/minimatch-2.0.10.tgz", + "_shasum": "8d087c39c6b38c001b97fca7ce6d0e1e80afbac7", + "_shrinkwrap": null, + "_spec": "minimatch@^2.0.10", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\readdirp", + "author": { + "email": "i@izs.me", + "name": "Isaac Z. Schlueter", + "url": "http://blog.izs.me" + }, + "bugs": { + "url": "https://github.com/isaacs/minimatch/issues" + }, + "dependencies": { + "brace-expansion": "^1.0.0" + }, + "description": "a glob matcher in javascript", + "devDependencies": { + "browserify": "^9.0.3", + "standard": "^3.7.2", + "tap": "^1.2.0" + }, + "directories": {}, + "dist": { + "shasum": "8d087c39c6b38c001b97fca7ce6d0e1e80afbac7", + "tarball": "http://registry.npmjs.org/minimatch/-/minimatch-2.0.10.tgz" + }, + "engines": { + "node": "*" + }, + "files": [ + "browser.js", + "minimatch.js" + ], + "gitHead": "6afb85f0c324b321f76a38df81891e562693e257", + "homepage": "https://github.com/isaacs/minimatch#readme", + "installable": true, + "license": "ISC", + "main": "minimatch.js", + "maintainers": [ + { + "name": "isaacs", + "email": "i@izs.me" + } + ], + "name": "minimatch", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git://github.com/isaacs/minimatch.git" + }, + "scripts": { + "posttest": "standard minimatch.js test/*.js", + "prepublish": "browserify -o browser.js -e minimatch.js -s minimatch --bare", + "test": "tap test/*.js" + }, + "version": "2.0.10" +} diff --git a/tools/node_modules/readdirp/package.json b/tools/node_modules/readdirp/package.json new file mode 100644 index 00000000000000..6508f5b30b7457 --- /dev/null +++ b/tools/node_modules/readdirp/package.json @@ -0,0 +1,100 @@ +{ + "_args": [ + [ + "readdirp@^2.0.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\chokidar" + ] + ], + "_from": "readdirp@>=2.0.0 <3.0.0", + "_id": "readdirp@2.0.0", + "_inCache": true, + "_location": "/readdirp", + "_npmUser": { + "email": "thlorenz@gmx.de", + "name": "thlorenz" + }, + "_npmVersion": "1.4.28", + "_phantomChildren": { + "brace-expansion": "1.1.2" + }, + "_requested": { + "name": "readdirp", + "raw": "readdirp@^2.0.0", + "rawSpec": "^2.0.0", + "scope": null, + "spec": ">=2.0.0 <3.0.0", + "type": "range" + }, + "_requiredBy": [ + "/chokidar" + ], + "_resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.0.0.tgz", + "_shasum": "cc09ba5d12d8feb864bc75f6e2ebc137060cbd82", + "_shrinkwrap": null, + "_spec": "readdirp@^2.0.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\chokidar", + "author": { + "email": "thlorenz@gmx.de", + "name": "Thorsten Lorenz", + "url": "thlorenz.com" + }, + "bugs": { + "url": "https://github.com/thlorenz/readdirp/issues" + }, + "dependencies": { + "graceful-fs": "^4.1.2", + "minimatch": "^2.0.10", + "readable-stream": "^2.0.2" + }, + "description": "Recursive version of fs.readdir with streaming api.", + "devDependencies": { + "nave": "^0.5.1", + "tap": "^1.3.2", + "through2": "^2.0.0" + }, + "directories": {}, + "dist": { + "shasum": "cc09ba5d12d8feb864bc75f6e2ebc137060cbd82", + "tarball": "http://registry.npmjs.org/readdirp/-/readdirp-2.0.0.tgz" + }, + "engines": { + "node": ">=0.6" + }, + "gitHead": "480af1e35d413ebb36e427808dcaa65d47cdc490", + "homepage": "https://github.com/thlorenz/readdirp", + "installable": true, + "keywords": [ + "filesystem", + "filter", + "find", + "fs", + "readdir", + "recursive", + "stream", + "streams" + ], + "license": "MIT", + "main": "readdirp.js", + "maintainers": [ + { + "name": "thlorenz", + "email": "thlorenz@gmx.de" + } + ], + "name": "readdirp", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git://github.com/thlorenz/readdirp.git" + }, + "scripts": { + "test": "if [ -e $TRAVIS ]; then npm run test-all; else npm run test-main; fi", + "test-0.10": "nave use 0.10 npm run test-main", + "test-0.12": "nave use 0.12 npm run test-main", + "test-0.8": "nave use 0.8 npm run test-main", + "test-2.4": "nave use 2.4 npm run test-main", + "test-all": "npm run test-main && npm run test-0.8 && npm run test-0.10 && npm run test-0.12 && npm run test-2.4", + "test-main": "(cd test && set -e; for t in ./*.js; do node $t; done)" + }, + "version": "2.0.0" +} diff --git a/tools/node_modules/readdirp/readdirp.js b/tools/node_modules/readdirp/readdirp.js new file mode 100644 index 00000000000000..fd28b7d6643169 --- /dev/null +++ b/tools/node_modules/readdirp/readdirp.js @@ -0,0 +1,288 @@ +'use strict'; + +var fs = require('graceful-fs') + , path = require('path') + , minimatch = require('minimatch') + , toString = Object.prototype.toString + ; + +// Standard helpers +function isFunction (obj) { + return toString.call(obj) === '[object Function]'; +} + +function isString (obj) { + return toString.call(obj) === '[object String]'; +} + +function isRegExp (obj) { + return toString.call(obj) === '[object RegExp]'; +} + +function isUndefined (obj) { + return obj === void 0; +} + +/** + * Main function which ends up calling readdirRec and reads all files and directories in given root recursively. + * @param { Object } opts Options to specify root (start directory), filters and recursion depth + * @param { function } callback1 When callback2 is given calls back for each processed file - function (fileInfo) { ... }, + * when callback2 is not given, it behaves like explained in callback2 + * @param { function } callback2 Calls back once all files have been processed with an array of errors and file infos + * function (err, fileInfos) { ... } + */ +function readdir(opts, callback1, callback2) { + var stream + , handleError + , handleFatalError + , pending = 0 + , errors = [] + , readdirResult = { + directories: [] + , files: [] + } + , fileProcessed + , allProcessed + , realRoot + , aborted = false + ; + + // If no callbacks were given we will use a streaming interface + if (isUndefined(callback1)) { + var api = require('./stream-api')(); + stream = api.stream; + callback1 = api.processEntry; + callback2 = api.done; + handleError = api.handleError; + handleFatalError = api.handleFatalError; + + stream.on('close', function () { aborted = true; }); + } else { + handleError = function (err) { errors.push(err); }; + handleFatalError = function (err) { + handleError(err); + allProcessed(errors, null); + }; + } + + if (isUndefined(opts)){ + handleFatalError(new Error ( + 'Need to pass at least one argument: opts! \n' + + 'https://github.com/thlorenz/readdirp#options' + ) + ); + return stream; + } + + opts.root = opts.root || '.'; + opts.fileFilter = opts.fileFilter || function() { return true; }; + opts.directoryFilter = opts.directoryFilter || function() { return true; }; + opts.depth = typeof opts.depth === 'undefined' ? 999999999 : opts.depth; + opts.entryType = opts.entryType || 'files'; + + var statfn = opts.lstat === true ? fs.lstat.bind(fs) : fs.stat.bind(fs); + + if (isUndefined(callback2)) { + fileProcessed = function() { }; + allProcessed = callback1; + } else { + fileProcessed = callback1; + allProcessed = callback2; + } + + function normalizeFilter (filter) { + + if (isUndefined(filter)) return undefined; + + function isNegated (filters) { + + function negated(f) { + return f.indexOf('!') === 0; + } + + var some = filters.some(negated); + if (!some) { + return false; + } else { + if (filters.every(negated)) { + return true; + } else { + // if we detect illegal filters, bail out immediately + throw new Error( + 'Cannot mix negated with non negated glob filters: ' + filters + '\n' + + 'https://github.com/thlorenz/readdirp#filters' + ); + } + } + } + + // Turn all filters into a function + if (isFunction(filter)) { + + return filter; + + } else if (isString(filter)) { + + return function (entryInfo) { + return minimatch(entryInfo.name, filter.trim()); + }; + + } else if (filter && Array.isArray(filter)) { + + if (filter) filter = filter.map(function (f) { + return f.trim(); + }); + + return isNegated(filter) ? + // use AND to concat multiple negated filters + function (entryInfo) { + return filter.every(function (f) { + return minimatch(entryInfo.name, f); + }); + } + : + // use OR to concat multiple inclusive filters + function (entryInfo) { + return filter.some(function (f) { + return minimatch(entryInfo.name, f); + }); + }; + } + } + + function processDir(currentDir, entries, callProcessed) { + if (aborted) return; + var total = entries.length + , processed = 0 + , entryInfos = [] + ; + + fs.realpath(currentDir, function(err, realCurrentDir) { + if (aborted) return; + if (err) { + handleError(err); + callProcessed(entryInfos); + return; + } + + var relDir = path.relative(realRoot, realCurrentDir); + + if (entries.length === 0) { + callProcessed([]); + } else { + entries.forEach(function (entry) { + + var fullPath = path.join(realCurrentDir, entry) + , relPath = path.join(relDir, entry); + + statfn(fullPath, function (err, stat) { + if (err) { + handleError(err); + } else { + entryInfos.push({ + name : entry + , path : relPath // relative to root + , fullPath : fullPath + + , parentDir : relDir // relative to root + , fullParentDir : realCurrentDir + + , stat : stat + }); + } + processed++; + if (processed === total) callProcessed(entryInfos); + }); + }); + } + }); + } + + function readdirRec(currentDir, depth, callCurrentDirProcessed) { + if (aborted) return; + + fs.readdir(currentDir, function (err, entries) { + if (err) { + handleError(err); + callCurrentDirProcessed(); + return; + } + + processDir(currentDir, entries, function(entryInfos) { + + var subdirs = entryInfos + .filter(function (ei) { return ei.stat.isDirectory() && opts.directoryFilter(ei); }); + + subdirs.forEach(function (di) { + if(opts.entryType === 'directories' || opts.entryType === 'both' || opts.entryType === 'all') { + fileProcessed(di); + } + readdirResult.directories.push(di); + }); + + entryInfos + .filter(function(ei) { + var isCorrectType = opts.entryType === 'all' ? + !ei.stat.isDirectory() : ei.stat.isFile() || ei.stat.isSymbolicLink(); + return isCorrectType && opts.fileFilter(ei); + }) + .forEach(function (fi) { + if(opts.entryType === 'files' || opts.entryType === 'both' || opts.entryType === 'all') { + fileProcessed(fi); + } + readdirResult.files.push(fi); + }); + + var pendingSubdirs = subdirs.length; + + // Be done if no more subfolders exist or we reached the maximum desired depth + if(pendingSubdirs === 0 || depth === opts.depth) { + callCurrentDirProcessed(); + } else { + // recurse into subdirs, keeping track of which ones are done + // and call back once all are processed + subdirs.forEach(function (subdir) { + readdirRec(subdir.fullPath, depth + 1, function () { + pendingSubdirs = pendingSubdirs - 1; + if(pendingSubdirs === 0) { + callCurrentDirProcessed(); + } + }); + }); + } + }); + }); + } + + // Validate and normalize filters + try { + opts.fileFilter = normalizeFilter(opts.fileFilter); + opts.directoryFilter = normalizeFilter(opts.directoryFilter); + } catch (err) { + // if we detect illegal filters, bail out immediately + handleFatalError(err); + return stream; + } + + // If filters were valid get on with the show + fs.realpath(opts.root, function(err, res) { + if (err) { + handleFatalError(err); + return stream; + } + + realRoot = res; + readdirRec(opts.root, 0, function () { + // All errors are collected into the errors array + if (errors.length > 0) { + allProcessed(errors, readdirResult); + } else { + allProcessed(null, readdirResult); + } + }); + }); + + return stream; +} + +module.exports = readdir; diff --git a/tools/node_modules/readdirp/stream-api.js b/tools/node_modules/readdirp/stream-api.js new file mode 100644 index 00000000000000..7cd2fef4f98d46 --- /dev/null +++ b/tools/node_modules/readdirp/stream-api.js @@ -0,0 +1,100 @@ +'use strict'; + +var si = typeof setImmediate !== 'undefined' ? setImmediate : function (fn) { setTimeout(fn, 0) }; + +var stream = require('readable-stream'); +var util = require('util'); + +var Readable = stream.Readable; + +module.exports = ReaddirpReadable; + +util.inherits(ReaddirpReadable, Readable); + +function ReaddirpReadable (opts) { + if (!(this instanceof ReaddirpReadable)) return new ReaddirpReadable(opts); + + opts = opts || {}; + + opts.objectMode = true; + Readable.call(this, opts); + + // backpressure not implemented at this point + this.highWaterMark = Infinity; + + this._destroyed = false; + this._paused = false; + this._warnings = []; + this._errors = []; + + this._pauseResumeErrors(); +} + +var proto = ReaddirpReadable.prototype; + +proto._pauseResumeErrors = function () { + var self = this; + self.on('pause', function () { self._paused = true }); + self.on('resume', function () { + if (self._destroyed) return; + self._paused = false; + + self._warnings.forEach(function (err) { self.emit('warn', err) }); + self._warnings.length = 0; + + self._errors.forEach(function (err) { self.emit('error', err) }); + self._errors.length = 0; + }) +} + +// called for each entry +proto._processEntry = function (entry) { + if (this._destroyed) return; + this.push(entry); +} + +proto._read = function () { } + +proto.destroy = function () { + // when stream is destroyed it will emit nothing further, not even errors or warnings + this.push(null); + this.readable = false; + this._destroyed = true; + this.emit('close'); +} + +proto._done = function () { + this.push(null); +} + +// we emit errors and warnings async since we may handle errors like invalid args +// within the initial event loop before any event listeners subscribed +proto._handleError = function (err) { + var self = this; + si(function () { + if (self._paused) return self._warnings.push(err); + if (!self._destroyed) self.emit('warn', err); + }); +} + +proto._handleFatalError = function (err) { + var self = this; + si(function () { + if (self._paused) return self._errors.push(err); + if (!self._destroyed) self.emit('error', err); + }); +} + +function createStreamAPI () { + var stream = new ReaddirpReadable(); + + return { + stream : stream + , processEntry : stream._processEntry.bind(stream) + , done : stream._done.bind(stream) + , handleError : stream._handleError.bind(stream) + , handleFatalError : stream._handleFatalError.bind(stream) + }; +} + +module.exports = createStreamAPI; diff --git a/tools/node_modules/readdirp/test/bed/root_dir1/root_dir1_file1.ext1 b/tools/node_modules/readdirp/test/bed/root_dir1/root_dir1_file1.ext1 new file mode 100644 index 00000000000000..e69de29bb2d1d6 diff --git a/tools/node_modules/readdirp/test/bed/root_dir1/root_dir1_file2.ext2 b/tools/node_modules/readdirp/test/bed/root_dir1/root_dir1_file2.ext2 new file mode 100644 index 00000000000000..e69de29bb2d1d6 diff --git a/tools/node_modules/readdirp/test/bed/root_dir1/root_dir1_file3.ext3 b/tools/node_modules/readdirp/test/bed/root_dir1/root_dir1_file3.ext3 new file mode 100644 index 00000000000000..e69de29bb2d1d6 diff --git a/tools/node_modules/readdirp/test/bed/root_dir1/root_dir1_subdir1/root1_dir1_subdir1_file1.ext1 b/tools/node_modules/readdirp/test/bed/root_dir1/root_dir1_subdir1/root1_dir1_subdir1_file1.ext1 new file mode 100644 index 00000000000000..e69de29bb2d1d6 diff --git a/tools/node_modules/readdirp/test/bed/root_dir2/root_dir2_file1.ext1 b/tools/node_modules/readdirp/test/bed/root_dir2/root_dir2_file1.ext1 new file mode 100644 index 00000000000000..e69de29bb2d1d6 diff --git a/tools/node_modules/readdirp/test/bed/root_dir2/root_dir2_file2.ext2 b/tools/node_modules/readdirp/test/bed/root_dir2/root_dir2_file2.ext2 new file mode 100644 index 00000000000000..e69de29bb2d1d6 diff --git a/tools/node_modules/readdirp/test/bed/root_file1.ext1 b/tools/node_modules/readdirp/test/bed/root_file1.ext1 new file mode 100644 index 00000000000000..e69de29bb2d1d6 diff --git a/tools/node_modules/readdirp/test/bed/root_file2.ext2 b/tools/node_modules/readdirp/test/bed/root_file2.ext2 new file mode 100644 index 00000000000000..e69de29bb2d1d6 diff --git a/tools/node_modules/readdirp/test/bed/root_file3.ext3 b/tools/node_modules/readdirp/test/bed/root_file3.ext3 new file mode 100644 index 00000000000000..e69de29bb2d1d6 diff --git a/tools/node_modules/readdirp/test/readdirp-stream.js b/tools/node_modules/readdirp/test/readdirp-stream.js new file mode 100644 index 00000000000000..b05688d8d7913e --- /dev/null +++ b/tools/node_modules/readdirp/test/readdirp-stream.js @@ -0,0 +1,310 @@ +/*jshint asi:true */ + +var debug //= true; +var test = debug ? function () {} : require('tap').test +var test_ = !debug ? function () {} : require('tap').test + , path = require('path') + , fs = require('fs') + , util = require('util') + , TransformStream = require('readable-stream').Transform + , through = require('through2') + , streamapi = require('../stream-api') + , readdirp = require('..') + , root = path.join(__dirname, 'bed') + , totalDirs = 6 + , totalFiles = 12 + , ext1Files = 4 + , ext2Files = 3 + , ext3Files = 2 + ; + +// see test/readdirp.js for test bed layout + +function opts (extend) { + var o = { root: root }; + + if (extend) { + for (var prop in extend) { + o[prop] = extend[prop]; + } + } + return o; +} + +function capture () { + var result = { entries: [], errors: [], ended: false } + , dst = new TransformStream({ objectMode: true }); + + dst._transform = function (entry, _, cb) { + result.entries.push(entry); + cb(); + } + + dst._flush = function (cb) { + result.ended = true; + this.push(result); + cb(); + } + + return dst; +} + +test('\nintegrated', function (t) { + t.test('\n# reading root without filter', function (t) { + t.plan(2); + + readdirp(opts()) + .on('error', function (err) { + t.fail('should not throw error', err); + }) + .pipe(capture()) + .pipe(through.obj( + function (result, _ , cb) { + t.equals(result.entries.length, totalFiles, 'emits all files'); + t.ok(result.ended, 'ends stream'); + t.end(); + cb(); + } + )); + }) + + t.test('\n# normal: ["*.ext1", "*.ext3"]', function (t) { + t.plan(2); + + readdirp(opts( { fileFilter: [ '*.ext1', '*.ext3' ] } )) + .on('error', function (err) { + t.fail('should not throw error', err); + }) + .pipe(capture()) + .pipe(through.obj( + function (result, _ , cb) { + t.equals(result.entries.length, ext1Files + ext3Files, 'all ext1 and ext3 files'); + t.ok(result.ended, 'ends stream'); + t.end(); + cb(); + } + )) + }) + + t.test('\n# files only', function (t) { + t.plan(2); + + readdirp(opts( { entryType: 'files' } )) + .on('error', function (err) { + t.fail('should not throw error', err); + }) + .pipe(capture()) + .pipe(through.obj( + function (result, _ , cb) { + t.equals(result.entries.length, totalFiles, 'returned files'); + t.ok(result.ended, 'ends stream'); + t.end(); + cb(); + } + )) + }) + + t.test('\n# directories only', function (t) { + t.plan(2); + + readdirp(opts( { entryType: 'directories' } )) + .on('error', function (err) { + t.fail('should not throw error', err); + }) + .pipe(capture()) + .pipe(through.obj( + function (result, _ , cb) { + t.equals(result.entries.length, totalDirs, 'returned directories'); + t.ok(result.ended, 'ends stream'); + t.end(); + cb(); + } + )) + }) + + t.test('\n# both directories + files', function (t) { + t.plan(2); + + readdirp(opts( { entryType: 'both' } )) + .on('error', function (err) { + t.fail('should not throw error', err); + }) + .pipe(capture()) + .pipe(through.obj( + function (result, _ , cb) { + t.equals(result.entries.length, totalDirs + totalFiles, 'returned everything'); + t.ok(result.ended, 'ends stream'); + t.end(); + cb(); + } + )) + }) + + t.test('\n# directory filter with directories only', function (t) { + t.plan(2); + + readdirp(opts( { entryType: 'directories', directoryFilter: [ 'root_dir1', '*dir1_subdir1' ] } )) + .on('error', function (err) { + t.fail('should not throw error', err); + }) + .pipe(capture()) + .pipe(through.obj( + function (result, _ , cb) { + t.equals(result.entries.length, 2, 'two directories'); + t.ok(result.ended, 'ends stream'); + t.end(); + cb(); + } + )) + }) + + t.test('\n# directory and file filters with both entries', function (t) { + t.plan(2); + + readdirp(opts( { entryType: 'both', directoryFilter: [ 'root_dir1', '*dir1_subdir1' ], fileFilter: [ '!*.ext1' ] } )) + .on('error', function (err) { + t.fail('should not throw error', err); + }) + .pipe(capture()) + .pipe(through.obj( + function (result, _ , cb) { + t.equals(result.entries.length, 6, '2 directories and 4 files'); + t.ok(result.ended, 'ends stream'); + t.end(); + cb(); + } + )) + }) + + t.test('\n# negated: ["!*.ext1", "!*.ext3"]', function (t) { + t.plan(2); + + readdirp(opts( { fileFilter: [ '!*.ext1', '!*.ext3' ] } )) + .on('error', function (err) { + t.fail('should not throw error', err); + }) + .pipe(capture()) + .pipe(through.obj( + function (result, _ , cb) { + t.equals(result.entries.length, totalFiles - ext1Files - ext3Files, 'all but ext1 and ext3 files'); + t.ok(result.ended, 'ends stream'); + t.end(); + } + )) + }) + + t.test('\n# no options given', function (t) { + t.plan(1); + readdirp() + .on('error', function (err) { + t.similar(err.toString() , /Need to pass at least one argument/ , 'emits meaningful error'); + t.end(); + }) + }) + + t.test('\n# mixed: ["*.ext1", "!*.ext3"]', function (t) { + t.plan(1); + + readdirp(opts( { fileFilter: [ '*.ext1', '!*.ext3' ] } )) + .on('error', function (err) { + t.similar(err.toString() , /Cannot mix negated with non negated glob filters/ , 'emits meaningful error'); + t.end(); + }) + }) +}) + + +test('\napi separately', function (t) { + + + t.test('\n# handleError', function (t) { + t.plan(1); + + var api = streamapi() + , warning = new Error('some file caused problems'); + + api.stream + .on('warn', function (err) { + t.equals(err, warning, 'warns with the handled error'); + }) + api.handleError(warning); + }) + + t.test('\n# when stream is paused and then resumed', function (t) { + t.plan(6); + var api = streamapi() + , resumed = false + , fatalError = new Error('fatal!') + , nonfatalError = new Error('nonfatal!') + , processedData = 'some data' + ; + + api.stream + .on('warn', function (err) { + t.equals(err, nonfatalError, 'emits the buffered warning'); + t.ok(resumed, 'emits warning only after it was resumed'); + }) + .on('error', function (err) { + t.equals(err, fatalError, 'emits the buffered fatal error'); + t.ok(resumed, 'emits errors only after it was resumed'); + }) + .on('data', function (data) { + t.equals(data, processedData, 'emits the buffered data'); + t.ok(resumed, 'emits data only after it was resumed'); + }) + .pause() + + api.processEntry(processedData); + api.handleError(nonfatalError); + api.handleFatalError(fatalError); + + setTimeout(function () { + resumed = true; + api.stream.resume(); + }, 1) + }) + + + t.test('\n# when a stream is destroyed, it emits "closed", but no longer emits "data", "warn" and "error"', function (t) { + var api = streamapi() + , fatalError = new Error('fatal!') + , nonfatalError = new Error('nonfatal!') + , processedData = 'some data' + , plan = 0; + + t.plan(6) + var stream = api.stream + .on('warn', function (err) { + t.ok(!stream._destroyed, 'emits warning until destroyed'); + }) + .on('error', function (err) { + t.ok(!stream._destroyed, 'emits errors until destroyed'); + }) + .on('data', function (data) { + t.ok(!stream._destroyed, 'emits data until destroyed'); + }) + .on('close', function () { + t.ok(stream._destroyed, 'emits close when stream is destroyed'); + }) + + + api.processEntry(processedData); + api.handleError(nonfatalError); + api.handleFatalError(fatalError); + + setTimeout(function () { + stream.destroy() + + t.notOk(stream.readable, 'stream is no longer readable after it is destroyed') + + api.processEntry(processedData); + api.handleError(nonfatalError); + api.handleFatalError(fatalError); + + process.nextTick(function () { + t.pass('emits no more data, warn or error events after it was destroyed') + t.end(); + }) + }, 10) + }) +}) diff --git a/tools/node_modules/readdirp/test/readdirp.js b/tools/node_modules/readdirp/test/readdirp.js new file mode 100644 index 00000000000000..812afbbb9982e6 --- /dev/null +++ b/tools/node_modules/readdirp/test/readdirp.js @@ -0,0 +1,289 @@ +/*jshint asi:true */ + +var test = require('tap').test + , path = require('path') + , fs = require('fs') + , util = require('util') + , net = require('net') + , readdirp = require('../readdirp.js') + , root = path.join(__dirname, '../test/bed') + , totalDirs = 6 + , totalFiles = 12 + , ext1Files = 4 + , ext2Files = 3 + , ext3Files = 2 + , rootDir2Files = 2 + , nameHasLength9Dirs = 2 + , depth1Files = 8 + , depth0Files = 3 + ; + +/* +Structure of test bed: + . + ├── root_dir1 + │   ├── root_dir1_file1.ext1 + │   ├── root_dir1_file2.ext2 + │   ├── root_dir1_file3.ext3 + │   ├── root_dir1_subdir1 + │   │   └── root1_dir1_subdir1_file1.ext1 + │   └── root_dir1_subdir2 + │   └── .gitignore + ├── root_dir2 + │   ├── root_dir2_file1.ext1 + │   ├── root_dir2_file2.ext2 + │   ├── root_dir2_subdir1 + │   │   └── .gitignore + │   └── root_dir2_subdir2 + │   └── .gitignore + ├── root_file1.ext1 + ├── root_file2.ext2 + └── root_file3.ext3 + + 6 directories, 13 files +*/ + +// console.log('\033[2J'); // clear console + +function opts (extend) { + var o = { root: root }; + + if (extend) { + for (var prop in extend) { + o[prop] = extend[prop]; + } + } + return o; +} + +test('\nreading root without filter', function (t) { + t.plan(2); + readdirp(opts(), function (err, res) { + t.equals(res.directories.length, totalDirs, 'all directories'); + t.equals(res.files.length, totalFiles, 'all files'); + t.end(); + }) +}) + +test('\nreading root without filter using lstat', function (t) { + t.plan(2); + readdirp(opts({ lstat: true }), function (err, res) { + t.equals(res.directories.length, totalDirs, 'all directories'); + t.equals(res.files.length, totalFiles, 'all files'); + t.end(); + }) +}) + +test('\nreading root with symlinks using lstat', function (t) { + t.plan(2); + fs.symlinkSync(path.join(root, 'root_dir1'), path.join(root, 'dirlink')); + fs.symlinkSync(path.join(root, 'root_file1.ext1'), path.join(root, 'link.ext1')); + readdirp(opts({ lstat: true }), function (err, res) { + t.equals(res.directories.length, totalDirs, 'all directories'); + t.equals(res.files.length, totalFiles + 2, 'all files + symlinks'); + fs.unlinkSync(path.join(root, 'dirlink')); + fs.unlinkSync(path.join(root, 'link.ext1')); + t.end(); + }) +}) + +test('\nreading non-standard fds', function (t) { + t.plan(2); + var server = net.createServer().listen(path.join(root, 'test.sock'), function(){ + readdirp(opts({ entryType: 'all' }), function (err, res) { + t.equals(res.files.length, totalFiles + 1, 'all files + socket'); + readdirp(opts({ entryType: 'both' }), function (err, res) { + t.equals(res.files.length, totalFiles, 'all regular files only'); + server.close(); + t.end(); + }) + }) + }); +}) + +test('\nreading root using glob filter', function (t) { + // normal + t.test('\n# "*.ext1"', function (t) { + t.plan(1); + readdirp(opts( { fileFilter: '*.ext1' } ), function (err, res) { + t.equals(res.files.length, ext1Files, 'all ext1 files'); + t.end(); + }) + }) + t.test('\n# ["*.ext1", "*.ext3"]', function (t) { + t.plan(1); + readdirp(opts( { fileFilter: [ '*.ext1', '*.ext3' ] } ), function (err, res) { + t.equals(res.files.length, ext1Files + ext3Files, 'all ext1 and ext3 files'); + t.end(); + }) + }) + t.test('\n# "root_dir1"', function (t) { + t.plan(1); + readdirp(opts( { directoryFilter: 'root_dir1' }), function (err, res) { + t.equals(res.directories.length, 1, 'one directory'); + t.end(); + }) + }) + t.test('\n# ["root_dir1", "*dir1_subdir1"]', function (t) { + t.plan(1); + readdirp(opts( { directoryFilter: [ 'root_dir1', '*dir1_subdir1' ]}), function (err, res) { + t.equals(res.directories.length, 2, 'two directories'); + t.end(); + }) + }) + + t.test('\n# negated: "!*.ext1"', function (t) { + t.plan(1); + readdirp(opts( { fileFilter: '!*.ext1' } ), function (err, res) { + t.equals(res.files.length, totalFiles - ext1Files, 'all but ext1 files'); + t.end(); + }) + }) + t.test('\n# negated: ["!*.ext1", "!*.ext3"]', function (t) { + t.plan(1); + readdirp(opts( { fileFilter: [ '!*.ext1', '!*.ext3' ] } ), function (err, res) { + t.equals(res.files.length, totalFiles - ext1Files - ext3Files, 'all but ext1 and ext3 files'); + t.end(); + }) + }) + + t.test('\n# mixed: ["*.ext1", "!*.ext3"]', function (t) { + t.plan(1); + readdirp(opts( { fileFilter: [ '*.ext1', '!*.ext3' ] } ), function (err, res) { + t.similar(err[0].toString(), /Cannot mix negated with non negated glob filters/, 'returns meaningfull error'); + t.end(); + }) + }) + + t.test('\n# leading and trailing spaces: [" *.ext1", "*.ext3 "]', function (t) { + t.plan(1); + readdirp(opts( { fileFilter: [ ' *.ext1', '*.ext3 ' ] } ), function (err, res) { + t.equals(res.files.length, ext1Files + ext3Files, 'all ext1 and ext3 files'); + t.end(); + }) + }) + t.test('\n# leading and trailing spaces: [" !*.ext1", " !*.ext3 "]', function (t) { + t.plan(1); + readdirp(opts( { fileFilter: [ ' !*.ext1', ' !*.ext3' ] } ), function (err, res) { + t.equals(res.files.length, totalFiles - ext1Files - ext3Files, 'all but ext1 and ext3 files'); + t.end(); + }) + }) + + t.test('\n# ** glob pattern', function (t) { + t.plan(1); + readdirp(opts( { fileFilter: '**/*.ext1' } ), function (err, res) { + t.equals(res.files.length, ext1Files, 'ignores ** in **/*.ext1 -> only *.ext1 files'); + t.end(); + }) + }) +}) + +test('\n\nreading root using function filter', function (t) { + t.test('\n# file filter -> "contains root_dir2"', function (t) { + t.plan(1); + readdirp( + opts( { fileFilter: function (fi) { return fi.name.indexOf('root_dir2') >= 0; } }) + , function (err, res) { + t.equals(res.files.length, rootDir2Files, 'all rootDir2Files'); + t.end(); + } + ) + }) + + t.test('\n# directory filter -> "name has length 9"', function (t) { + t.plan(1); + readdirp( + opts( { directoryFilter: function (di) { return di.name.length === 9; } }) + , function (err, res) { + t.equals(res.directories.length, nameHasLength9Dirs, 'all all dirs with name length 9'); + t.end(); + } + ) + }) +}) + +test('\nreading root specifying maximum depth', function (t) { + t.test('\n# depth 1', function (t) { + t.plan(1); + readdirp(opts( { depth: 1 } ), function (err, res) { + t.equals(res.files.length, depth1Files, 'does not return files at depth 2'); + }) + }) +}) + +test('\nreading root with no recursion', function (t) { + t.test('\n# depth 0', function (t) { + t.plan(1); + readdirp(opts( { depth: 0 } ), function (err, res) { + t.equals(res.files.length, depth0Files, 'does not return files at depth 0'); + }) + }) +}) + +test('\nprogress callbacks', function (t) { + t.plan(2); + + var pluckName = function(fi) { return fi.name; } + , processedFiles = []; + + readdirp( + opts() + , function(fi) { + processedFiles.push(fi); + } + , function (err, res) { + t.equals(processedFiles.length, res.files.length, 'calls back for each file processed'); + t.deepEquals(processedFiles.map(pluckName).sort(),res.files.map(pluckName).sort(), 'same file names'); + t.end(); + } + ) +}) + +test('resolving of name, full and relative paths', function (t) { + var expected = { + name : 'root_dir1_file1.ext1' + , parentDirName : 'root_dir1' + , path : 'root_dir1/root_dir1_file1.ext1' + , fullPath : 'test/bed/root_dir1/root_dir1_file1.ext1' + } + , opts = [ + { root: './bed' , prefix: '' } + , { root: './bed/' , prefix: '' } + , { root: 'bed' , prefix: '' } + , { root: 'bed/' , prefix: '' } + , { root: '../test/bed/' , prefix: '' } + , { root: '.' , prefix: 'bed' } + ] + t.plan(opts.length); + + opts.forEach(function (op) { + op.fileFilter = 'root_dir1_file1.ext1'; + + t.test('\n' + util.inspect(op), function (t) { + t.plan(4); + + readdirp (op, function(err, res) { + t.equals(res.files[0].name, expected.name, 'correct name'); + t.equals(res.files[0].path, path.join(op.prefix, expected.path), 'correct path'); + }) + + fs.realpath(op.root, function(err, fullRoot) { + readdirp (op, function(err, res) { + t.equals( + res.files[0].fullParentDir + , path.join(fullRoot, op.prefix, expected.parentDirName) + , 'correct parentDir' + ); + t.equals( + res.files[0].fullPath + , path.join(fullRoot, op.prefix, expected.parentDirName, expected.name) + , 'correct fullPath' + ); + }) + }) + }) + }) +}) + + diff --git a/tools/node_modules/regex-cache/LICENSE b/tools/node_modules/regex-cache/LICENSE new file mode 100644 index 00000000000000..33754daecd9a43 --- /dev/null +++ b/tools/node_modules/regex-cache/LICENSE @@ -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. diff --git a/tools/node_modules/regex-cache/README.md b/tools/node_modules/regex-cache/README.md new file mode 100644 index 00000000000000..512de06cf84ab0 --- /dev/null +++ b/tools/node_modules/regex-cache/README.md @@ -0,0 +1,148 @@ +# regex-cache [![NPM version](https://badge.fury.io/js/regex-cache.svg)](http://badge.fury.io/js/regex-cache) [![Build Status](https://travis-ci.org/jonschlinkert/regex-cache.svg)](https://travis-ci.org/jonschlinkert/regex-cache) + +> Memoize the results of a call to the RegExp constructor, avoiding repetitious runtime compilation of the same string and options, resulting in dramatic speed improvements. + +- Read [what this does](#what-this-does). +- See [the benchmarks](#benchmarks) + +## Install with [npm](npmjs.org) + +```bash +npm i regex-cache --save +``` + +## Usage + +Wrap a function like this: + +```js +var cache = require('regex-cache'); +var someRegex = cache(require('some-regex-lib')); +``` + +**Caching a regex** + +If you want to cache a regex after calling `new RegExp()`, or you're requiring a module that returns a regex, wrap it with a function first: + +```js +var cache = require('regex-cache'); + +function yourRegex(str, opts) { + // do stuff to str and opts + return new RegExp(str, opts.flags); +} + +var regex = cache(yourRegex); +``` + +## Recommendations + +### Use this when... + +* **No options are passed** to the function that creates the regex. Regardless of how big or small the regex is, when zero options are passed, caching will be faster than not. +* **A few options are passed**, and the values are primitives. The limited benchmarks I did show that caching is beneficial when up to 8 or 9 options are passed. + +### Do not use this when... + +* **The values of options are not primitives**. When non-primitives must be compared for equality, the time to compare the options is most likely as long or longer than the time to just create a new regex. + + +### Example benchmarks + +Performance results, with and without regex-cache: + +```bash +# no args passed (defaults) + with-cache x 8,699,231 ops/sec ±0.86% (93 runs sampled) + without-cache x 2,777,551 ops/sec ±0.63% (95 runs sampled) + +# string and six options passed + with-cache x 1,885,934 ops/sec ±0.80% (93 runs sampled) + without-cache x 1,256,893 ops/sec ±0.65% (97 runs sampled) + +# string only + with-cache x 7,723,256 ops/sec ±0.87% (92 runs sampled) + without-cache x 2,303,060 ops/sec ±0.47% (99 runs sampled) + +# one option passed + with-cache x 4,179,877 ops/sec ±0.53% (100 runs sampled) + without-cache x 2,198,422 ops/sec ±0.47% (95 runs sampled) + +# two options passed + with-cache x 3,256,222 ops/sec ±0.51% (99 runs sampled) + without-cache x 2,121,401 ops/sec ±0.79% (97 runs sampled) + +# six options passed + with-cache x 1,816,018 ops/sec ±1.08% (96 runs sampled) + without-cache x 1,157,176 ops/sec ±0.53% (100 runs sampled) + +# +# diminishing returns happen about here +# + +# ten options passed + with-cache x 1,210,598 ops/sec ±0.56% (92 runs sampled) + without-cache x 1,665,588 ops/sec ±1.07% (100 runs sampled) + +# twelve options passed + with-cache x 1,042,096 ops/sec ±0.68% (92 runs sampled) + without-cache x 1,389,414 ops/sec ±0.68% (97 runs sampled) + +# twenty options passed + with-cache x 661,125 ops/sec ±0.80% (93 runs sampled) + without-cache x 1,208,757 ops/sec ±0.65% (97 runs sampled) + +# +# when non-primitive values are compared +# + +# single value on the options is an object + with-cache x 1,398,313 ops/sec ±1.05% (95 runs sampled) + without-cache x 2,228,281 ops/sec ±0.56% (99 runs sampled) +``` + +## Run benchmarks + +Install dev dependencies: + +```bash +npm i -d && npm run benchmarks +``` + + +## What this does + +If you're using `new RegExp('foo')` instead of a regex literal, it's probably because you need to dyamically generate a regex based on user options or some other potentially changing factors. + +When your function creates a string based on user inputs and passes it to the `RegExp` constructor, regex-cache caches the results. The next time the function is called if the key of a cached regex matches the user input (or no input was given), the cached regex is returned, avoiding unnecessary runtime compilation. + +Using the RegExp constructor offers a lot of flexibility, but the runtime compilation comes at a price - it's slow. Not specifically because of the call to the RegExp constructor, but **because you have to build up the string before `new RegExp()` is even called**. + + +## Run tests + +Install dev dependencies: + +```bash +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/regex-cache/issues) + +## Author + +**Jon Schlinkert** + ++ [github/jonschlinkert](https://github.com/jonschlinkert) ++ [twitter/jonschlinkert](http://twitter.com/jonschlinkert) + +## License +Copyright (c) 2015 Jon Schlinkert +Released under the MIT license + +*** + +_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on March 25, 2015._ + +[mentions-regex]: https://github.com/regexps/mentions-regex \ No newline at end of file diff --git a/tools/node_modules/regex-cache/index.js b/tools/node_modules/regex-cache/index.js new file mode 100644 index 00000000000000..ce0ddda3258f88 --- /dev/null +++ b/tools/node_modules/regex-cache/index.js @@ -0,0 +1,67 @@ +/*! + * regex-cache + * + * Copyright (c) 2015 Jon Schlinkert. + * Licensed under the MIT license. + */ + +'use strict'; + +var isPrimitive = require('is-primitive'); +var equal = require('is-equal-shallow'); + +/** + * Expose `regexCache` + */ + +module.exports = regexCache; + +/** + * Memoize the results of a call to the new RegExp constructor. + * + * @param {Function} fn [description] + * @param {String} str [description] + * @param {Options} options [description] + * @param {Boolean} nocompare [description] + * @return {RegExp} + */ + +function regexCache(fn, str, opts) { + var key = '_default_', regex, cached; + + if (!str && !opts) { + if (typeof fn !== 'function') { + return fn; + } + return basic[key] || (basic[key] = fn()); + } + + var isString = typeof str === 'string'; + if (isString) { + if (!opts) { + return basic[str] || (basic[str] = fn(str)); + } + key = str; + } else { + opts = str; + } + + cached = cache[key]; + if (cached && equal(cached.opts, opts)) { + return cached.regex; + } + + memo(key, opts, (regex = fn(str, opts))); + return regex; +} + +function memo(key, opts, regex) { + cache[key] = {regex: regex, opts: opts}; +} + +/** + * Expose `cache` + */ + +var cache = module.exports.cache = {}; +var basic = module.exports.basic = {}; diff --git a/tools/node_modules/regex-cache/package.json b/tools/node_modules/regex-cache/package.json new file mode 100644 index 00000000000000..c9c50770bf0037 --- /dev/null +++ b/tools/node_modules/regex-cache/package.json @@ -0,0 +1,100 @@ +{ + "_args": [ + [ + "regex-cache@^0.4.2", + "C:\\wamp\\www\\node\\tools\\node_modules\\micromatch" + ] + ], + "_from": "regex-cache@>=0.4.2 <0.5.0", + "_id": "regex-cache@0.4.2", + "_inCache": true, + "_location": "/regex-cache", + "_nodeVersion": "1.6.2", + "_npmUser": { + "email": "github@sellside.com", + "name": "jonschlinkert" + }, + "_npmVersion": "2.7.1", + "_phantomChildren": {}, + "_requested": { + "name": "regex-cache", + "raw": "regex-cache@^0.4.2", + "rawSpec": "^0.4.2", + "scope": null, + "spec": ">=0.4.2 <0.5.0", + "type": "range" + }, + "_requiredBy": [ + "/micromatch" + ], + "_resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.2.tgz", + "_shasum": "6e4f89c266bc03c33fd129c062184687f4663487", + "_shrinkwrap": null, + "_spec": "regex-cache@^0.4.2", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\micromatch", + "author": { + "name": "Jon Schlinkert", + "url": "https://github.com/jonschlinkert" + }, + "bugs": { + "url": "https://github.com/jonschlinkert/regex-cache/issues" + }, + "dependencies": { + "is-equal-shallow": "^0.1.1", + "is-primitive": "^2.0.0" + }, + "description": "Memoize the results of a call to the RegExp constructor, avoiding repetitious runtime compilation of the same string and options, resulting in dramatic speed improvements.", + "devDependencies": { + "benchmarked": "^0.1.4", + "chalk": "^1.0.0", + "micromatch": "^2.1.0", + "mocha": "^2.1.0", + "should": "*" + }, + "directories": {}, + "dist": { + "shasum": "6e4f89c266bc03c33fd129c062184687f4663487", + "tarball": "http://registry.npmjs.org/regex-cache/-/regex-cache-0.4.2.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "9478eec6d9322a96a6ceb3e5488cd8433295a95f", + "homepage": "https://github.com/jonschlinkert/regex-cache", + "installable": true, + "keywords": [ + "cache", + "expression", + "regex", + "regexp", + "regular", + "regular expression", + "store", + "to-regex" + ], + "license": { + "type": "MIT", + "url": "https://github.com/jonschlinkert/regex-cache/blob/master/LICENSE" + }, + "main": "index.js", + "maintainers": [ + { + "name": "jonschlinkert", + "email": "github@sellside.com" + } + ], + "name": "regex-cache", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git://github.com/jonschlinkert/regex-cache.git" + }, + "scripts": { + "benchmarks": "node benchmark", + "test": "mocha" + }, + "version": "0.4.2" +} diff --git a/tools/node_modules/remark/LICENSE b/tools/node_modules/remark/LICENSE new file mode 100644 index 00000000000000..5c1b55c9995a76 --- /dev/null +++ b/tools/node_modules/remark/LICENSE @@ -0,0 +1,22 @@ +(The MIT License) + +Copyright (c) 2014-2016 Titus Wormer +Copyright (c) 2011-2014, Christopher Jeffrey (https://github.com/chjj/) + +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. diff --git a/tools/node_modules/remark/bin/remark b/tools/node_modules/remark/bin/remark new file mode 100644 index 00000000000000..965587ce588dbb --- /dev/null +++ b/tools/node_modules/remark/bin/remark @@ -0,0 +1,64 @@ +#!/usr/bin/env node +'use strict'; + +/* eslint-env node */ + +/* + * Dependencies. + */ + +var cli = require('../lib/cli'); + +/* + * Methods. + */ + +var stderr = process.stderr; +var argv = process.argv; + +/* + * Constants. + */ + +var exitStatus = 0; + +/** + * Failure handler. + * + * @param {Error?} exception + */ +function fail(exception, success) { + if (exception) { + stderr.write((exception.stack || exception) + '\n'); + } + + if (exception || !success) { + exitStatus = 1; + } +} + +/* + * Set-up. + */ + +var position = argv.indexOf('--'); + +if (position !== -1) { + argv = argv.slice(0, position); +} + +/* + * Process. + */ + +cli(argv, fail); + +/* + * Exit. + */ + +process.on('exit', function () { + /* eslint-disable no-process-exit */ + process.exit(exitStatus); + /* eslint-enable no-process-exit */ +}); diff --git a/tools/node_modules/remark/history.md b/tools/node_modules/remark/history.md new file mode 100644 index 00000000000000..7d9cf0913ac00f --- /dev/null +++ b/tools/node_modules/remark/history.md @@ -0,0 +1,155 @@ + + + + +3.2.2 / 2016-01-21 +================== + +* Refactor internal ignore API in remark(1) ([`c94c7df`](https://github.com/wooorm/remark/commit/c94c7df)) + +3.2.1 / 2016-01-19 +================== + +* Fix empty list-item bug in remark(3) ([`8a62652`](https://github.com/wooorm/remark/commit/8a62652)) +* Add support for default arguments to remark(1) ([`9ab6dc8`](https://github.com/wooorm/remark/commit/9ab6dc8)) +* Fix injecting virtual files on remark(1) ([`397028a`](https://github.com/wooorm/remark/commit/397028a)) +* Add natural-language validation ([`d1c52a3`](https://github.com/wooorm/remark/commit/d1c52a3)) + +3.2.0 / 2016-01-10 +================== + +* Fix void list-items in remark(3) ([`6a42de4`](https://github.com/wooorm/remark/commit/6a42de4)) +* Add Gitter badge to `readme.md` ([`4cc1109`](https://github.com/wooorm/remark/commit/4cc1109)) +* Fix tables without final newline in remark(3) ([`fd2f281`](https://github.com/wooorm/remark/commit/fd2f281)) + +3.1.3 / 2016-01-04 +================== + +* Fix table without body support to remark(3) ([`9a3bc47`](https://github.com/wooorm/remark/commit/9a3bc47)) +* Refactor output of `-h, --help` in remark(1) ([`1d36801`](https://github.com/wooorm/remark/commit/1d36801)) +* Add docs for fileglob support in remark(1) ([`f9f9a36`](https://github.com/wooorm/remark/commit/f9f9a36)) + +3.1.2 / 2016-01-03 +================== + +* Fix globs to files without extension in remark(1) ([`20e253f`](https://github.com/wooorm/remark/commit/20e253f)) + +3.1.1 / 2016-01-02 +================== + +* Update copyright date references to 2016 ([`48151aa`](https://github.com/wooorm/remark/commit/48151aa)) +* Fix stdin(4) detection on Windows ([`c2562bc`](https://github.com/wooorm/remark/commit/c2562bc)) +* Add `remark-license`, `remark-vdom` to list of plugins ([`6ca52bb`](https://github.com/wooorm/remark/commit/6ca52bb)) + +3.1.0 / 2015-12-31 +================== + +* Add support for injecting plugins into remark(1) ([`4e65d70`](https://github.com/wooorm/remark/commit/4e65d70)) + +3.0.1 / 2015-12-27 +================== + +* Fix files without extension in remark(1) ([`6d8bcd5`](https://github.com/wooorm/remark/commit/6d8bcd5)) +* Refactor remark(1) examples in docs to be valid ([`fb0cbe8`](https://github.com/wooorm/remark/commit/fb0cbe8)) +* Add `remark-textr` to list of plugins ([`098052a`](https://github.com/wooorm/remark/commit/098052a)) +* Update list of plugins with renames ([`caf5232`](https://github.com/wooorm/remark/commit/caf5232)) + +3.0.0 / 2015-12-25 +================== + +* Add migration guide and temporary warnings ([`269f521`](https://github.com/wooorm/remark/commit/269f521)) +* Update list of plugins with project renames ([`fb0fea9`](https://github.com/wooorm/remark/commit/fb0fea9)) +* Rename `mdast` to `remark` ([`38fe53d`](https://github.com/wooorm/remark/commit/38fe53d)) +* Fix bug where blockquotes had trailing spaces ([`a51f112`](https://github.com/wooorm/remark/commit/a51f112)) +* Refactor support for entities ([`0c7b649`](https://github.com/wooorm/remark/commit/0c7b649)) +* Refactor code-style ([`3dc2485`](https://github.com/wooorm/remark/commit/3dc2485)) +* Add documentation for interfacing with the parser ([`7a5d16d`](https://github.com/wooorm/remark/commit/7a5d16d)) +* Fix footnote definitions without spacing ([`46714b2`](https://github.com/wooorm/remark/commit/46714b2)) +* Fix empty `alt` value for `imageReference`, `image` ([`698d569`](https://github.com/wooorm/remark/commit/698d569)) +* Fix unclosed angle-bracketed definition ([`acebf81`](https://github.com/wooorm/remark/commit/acebf81)) +* Add escaping to compiler ([`d1fe019`](https://github.com/wooorm/remark/commit/d1fe019)) +* Fix handling of definitions in commonmark-mode ([`b7d6e53`](https://github.com/wooorm/remark/commit/b7d6e53)) +* Fix handling of list-item bullets in gfm-mode ([`6e74759`](https://github.com/wooorm/remark/commit/6e74759)) +* Refactor to remove regexes ([`25a26f2`](https://github.com/wooorm/remark/commit/25a26f2)) + +2.3.2 / 2015-12-21 +================== + +* Fix missing link in `history.md` ([`49453f7`](https://github.com/wooorm/remark/commit/49453f7)) + +2.3.1 / 2015-12-21 +================== + +* Fix `package.json` files not loading on mdast(1) ([`1ef6e05`](https://github.com/wooorm/remark/commit/1ef6e05)) + +2.3.0 / 2015-12-01 +================== + +* Refactor to prefer prefixed plug-ins in mdast(1) ([`44d4daa`](https://github.com/wooorm/remark/commit/44d4daa)) +* Fix recursive `plugins` key handling in mdast(1) ([`4bb02b2`](https://github.com/wooorm/remark/commit/4bb02b2)) +* Add getting-started documentation ([`a20d9d0`](https://github.com/wooorm/remark/commit/a20d9d0)) +* Fix stdout(4) and stderr(4) usage ([`501a377`](https://github.com/wooorm/remark/commit/501a377)) + +2.2.2 / 2015-11-21 +================== + +* Fix premature reporting ([`a82d018`](https://github.com/wooorm/remark/commit/a82d018)) +* Remove distribution files from version control ([`f068edd`](https://github.com/wooorm/remark/commit/f068edd)) +* Remove support for bower ([`61162be`](https://github.com/wooorm/remark/commit/61162be)) + +2.2.1 / 2015-11-20 +================== + +* Fix silent exit when without `.mdastignore` file ([`7233fb2`](https://github.com/wooorm/remark/commit/7233fb2)) + +2.2.0 / 2015-11-19 +================== + +* Update dependencies ([`c2aca8f`](https://github.com/wooorm/remark/commit/c2aca8f)) +* Refactor to externalise file finding ([`517d483`](https://github.com/wooorm/remark/commit/517d483)) +* Refactor to make node to `encode` optional ([`03c3361`](https://github.com/wooorm/remark/commit/03c3361)) +* Add version to library, distribution files ([`e245a43`](https://github.com/wooorm/remark/commit/e245a43)) +* Remove output to stdout(4) when watching ([`594a45f`](https://github.com/wooorm/remark/commit/594a45f)) +* Remove variable capturing groups from regexes ([`c17228c`](https://github.com/wooorm/remark/commit/c17228c)) + +2.1.0 / 2015-10-05 +================== + +* Fix pipes inside code in tables ([`baad536`](https://github.com/wooorm/remark/commit/baad536)) +* Add processing of just the changed watched file to mdast(1) ([`e3748d2`](https://github.com/wooorm/remark/commit/e3748d2)) +* Add error when pedantic is used with incompatible options ([`3326a89`](https://github.com/wooorm/remark/commit/3326a89)) + +2.0.0 / 2015-09-20 +================== + +* Update unified ([`3dec23f`](https://github.com/wooorm/remark/commit/3dec23f)) +* Update AUTHORS with recent contributors ([`49ec46f`](https://github.com/wooorm/remark/commit/49ec46f)) +* Add support for watching files for changes to mdast(1) ([`b3078f9`](https://github.com/wooorm/remark/commit/b3078f9)) +* Fix stdin detection in child-processes ([`8f1d7f1`](https://github.com/wooorm/remark/commit/8f1d7f1)) +* Add list of tools built with mdast ([`d7ad2ac`](https://github.com/wooorm/remark/commit/d7ad2ac)) + +1.2.0 / 2015-09-07 +================== + +* Fix bug where colour on mdast(1) persisted ([`ca2c53a`](https://github.com/wooorm/remark/commit/ca2c53a)) +* Add support for loading global plugins ([`5e2d32e`](https://github.com/wooorm/remark/commit/5e2d32e)) +* Add more mdastplugin(3) examples ([`8664a03`](https://github.com/wooorm/remark/commit/8664a03)) +* Move all info output of mdast(1) to stderr(4) ([`daed42f`](https://github.com/wooorm/remark/commit/daed42f)) +* Refactor miscellaneous docs ([`72412af`](https://github.com/wooorm/remark/commit/72412af)) + +1.1.0 / 2015-08-21 +================== + +* Fix typo in man-page ([`d435999`](https://github.com/wooorm/remark/commit/d435999)) +* Update list of plug-ins ([`4add9e6`](https://github.com/wooorm/remark/commit/4add9e6)) +* Refactor to externalise reporter ([`8c80af9`](https://github.com/wooorm/remark/commit/8c80af9)) +* Refactor mdast(1) to externalise `to-vfile` ([`69629d5`](https://github.com/wooorm/remark/commit/69629d5)) + +1.0.0 / 2015-08-12 +================== + +Nothing much changed, just that **mdast** is now officially stable! +Thanks all for the 100 stars :wink:. + +The pre-stable change-log was removed from the working-copy. +View the changelog at [`1.0.0`](https://github.com/wooorm/remark/blob/1.0.0/history.md) diff --git a/tools/node_modules/remark/index.js b/tools/node_modules/remark/index.js new file mode 100644 index 00000000000000..9cafde19ee0eba --- /dev/null +++ b/tools/node_modules/remark/index.js @@ -0,0 +1,34 @@ +/** + * @author Titus Wormer + * @copyright 2015-2016 Titus Wormer + * @license MIT + * @module remark + * @version 3.2.2 + * @fileoverview Markdown processor powered by plugins. + */ + +'use strict'; + +/* eslint-env commonjs */ + +/* + * Dependencies. + */ + +var unified = require('unified'); +var Parser = require('./lib/parse.js'); +var Compiler = require('./lib/stringify.js'); +var escape = require('./lib/escape.json'); + +/* + * Exports. + */ + +module.exports = unified({ + 'name': 'mdast', + 'Parser': Parser, + 'Compiler': Compiler, + 'data': { + 'escape': escape + } +}); diff --git a/tools/node_modules/remark/lib/block-elements.json b/tools/node_modules/remark/lib/block-elements.json new file mode 100644 index 00000000000000..af5e657cbeab61 --- /dev/null +++ b/tools/node_modules/remark/lib/block-elements.json @@ -0,0 +1,52 @@ +[ + "article", + "header", + "aside", + "hgroup", + "blockquote", + "hr", + "iframe", + "body", + "li", + "map", + "button", + "object", + "canvas", + "ol", + "caption", + "output", + "col", + "p", + "colgroup", + "pre", + "dd", + "progress", + "div", + "section", + "dl", + "table", + "td", + "dt", + "tbody", + "embed", + "textarea", + "fieldset", + "tfoot", + "figcaption", + "th", + "figure", + "thead", + "footer", + "tr", + "form", + "ul", + "h1", + "h2", + "h3", + "h4", + "h5", + "h6", + "video", + "script", + "style" +] diff --git a/tools/node_modules/remark/lib/cli/cli.js b/tools/node_modules/remark/lib/cli/cli.js new file mode 100644 index 00000000000000..aec17dec3e9565 --- /dev/null +++ b/tools/node_modules/remark/lib/cli/cli.js @@ -0,0 +1,381 @@ +/** + * @author Titus Wormer + * @copyright 2015-2016 Titus Wormer + * @license MIT + * @module remark:cli:cli + * @version 3.2.2 + * @fileoverview Bridge between CLI options and node. + */ + +'use strict'; + +/* eslint-env node */ + +/* eslint-disable no-console */ + +/* + * Dependencies. + */ + +var util = require('util'); +var events = require('events'); +var commander = require('commander'); +var camelcase = require('camelcase'); +var pack = require('../../package.json'); +var Cache = require('./watch-output-cache'); +var Spinner = require('./spinner'); + +/* + * Methods. + */ + +var Emitter = events.EventEmitter; +var Command = commander.Command; + +/* + * Constants. + */ + +var SPLITTER = / *[,;] */g; +var EXTENSIONS = ['md', 'markdown', 'mkd', 'mkdn', 'mkdown', 'ron']; + +/* + * Set-up. + */ + +var COMMAND = Object.keys(pack.bin)[0]; + +/** + * Parse a (lazy?) JSON config. + * + * @example + * parseJSON('foo:true') // {'foo': true} + * + * parseJSON('foo-bar: 1, baz-qux: -1') // {'foo-bar': 1, baz-qux: -1} + * + * parseJSON('foo: ["bar", "baz"]') // {'foo': ['bar', 'baz']} + * + * @param {string} value - Value to parse as JSON. + * @return {Object} - Parsed `value`. + * @throws {Error} - When the augmented options could not + * be parsed. + */ +function parseJSON(value) { + /* + * Quote unquoted property keys. + */ + + value = value.replace(/([a-zA-Z0-9\-\/]+)(?=\s*:)/g, '\"$&\"'); + + return JSON.parse('{' + value + '}'); +} + +/** + * Transform the keys on an object to camel-case, + * recursivly. + * + * @example + * toCamelCase({"foo-bar": {"qux-quux": "baz"}}); + * // {"fooBar": {"quxQuux": "baz"}} + * + * @param {Object} object - Object to transform. + * @return {Object} - New object, with camel-case keys. + */ +function toCamelCase(object) { + var result = {}; + var value; + var key; + + for (key in object) { + value = object[key]; + + if (value && typeof value === 'object' && !('length' in value)) { + value = toCamelCase(value); + } + + result[camelcase(key)] = value; + } + + return result; +} + +/** + * Parse settings into an object. + * + * @example + * var cache = {}; + * options('commonmark: true', cache); + * + * @param {string} flags - Command line settings. These + * are just JSON, although the keys do not need double + * quotes to work. + * @param {Object} cache - Settings store. + * @return {Object} - `cache`. + */ +function options(flags, cache) { + var flag; + + try { + flags = toCamelCase(parseJSON(flags)); + } catch (exception) { + exception.message = 'Cannot parse CLI settings: \nError: ' + + exception.message; + + throw exception; + } + + for (flag in flags) { + cache[flag] = flags[flag]; + } + + return cache; +} + +/** + * Parse a plugin into its name and options. + * + * @example + * var plugin = parsePlugin('remark-toc=heading:"foo"'); + * + * @param {string} plugin - Plugin name with options. + * @return {Object} - Map with a `name`, referring to + * the parser name, and a `value`, which when available, + * contains the plug-in options. + */ +function parsePlugin(plugin) { + var index = plugin.indexOf('='); + var name; + var value; + + if (index === -1) { + name = plugin; + value = null; + } else { + name = plugin.slice(0, index); + value = options(plugin.slice(index + 1), {}); + } + + return { + 'name': name, + 'value': value + }; +} + +/** + * Parse plugins into a list. + * + * @example + * var cache = {}; + * plugins('foo=bar:false', cache); + * + * @param {string} plugin - Plugin name with options. + * @param {Object} cache - Plugin store. + * @return {Object} - `cache`. + */ +function plugins(plugin, cache) { + plugin = parsePlugin(plugin); + + cache[plugin.name] = plugin.value; + + return cache; +} + +/** + * Parse extensions into a list. + * + * @example + * var res = extensions('markdown,ron', ['md']); + * + * @param {string} extension - List of extensions. + * @param {Array.} cache - Extension store. + * @return {Array.} - New extensions store. + */ +function extensions(extension, cache) { + return cache.concat(extension.split(SPLITTER)); +} + +/** + * Help. + */ +function help() { + console.log([ + ' See also: man 1 remark, man 3 remark,', + ' man 3 remarkplugin, man 5 remarkrc,', + ' man 5 remarkignore, man 7 remarksetting,', + ' man 7 remarkconfig, man 7 remarkplugin.', + '', + ' Examples:', + '', + ' # Process `readme.md`', + ' $ ' + COMMAND + ' readme.md -o readme-new.md', + '', + ' # Pass stdin(4) through remark, with settings, to stdout(4)', + ' $ ' + COMMAND + ' --setting "setext: true, bullet: \\"*\\""' + + ' < readme.md > readme-new.md', + '', + ' # Use a plugin (with options)', + ' $ npm install remark-toc', + ' $ ' + COMMAND + ' readme.md --use "toc=heading:\\"contents\\""' + + ' -o', + '', + ' # Rewrite markdown in a directory', + ' $ ' + COMMAND + ' . -o' + ].join('\n')); +} + +/* + * Module. + */ + +var program = new Command(pack.name) + .version(pack.version) + .description(pack.description) + .usage('[options] ') + .option('-o, --output [path]', 'specify output location') + .option('-c, --config-path ', 'specify configuration location') + .option('-i, --ignore-path ', 'specify ignore location') + .option('-s, --setting ', 'specify settings', options, {}) + .option('-u, --use ', 'use transform plugin(s)', plugins, {}) + .option('-e, --ext ', 'specify extensions', extensions, []) + .option('-w, --watch', 'watch for changes and reprocess', false) + .option('-a, --ast', 'output AST information', false) + .option('-q, --quiet', 'output only warnings and errors', false) + .option('-S, --silent', 'output only errors', false) + .option('-f, --frail', 'exit with 1 on warnings', false) + .option('--file-path ', 'specify file path to process as', false) + .option('--no-stdout', 'disable writing to stdout', true) + .option('--no-color', 'disable color in output', false) + .option('--no-rc', 'disable configuration from .remarkrc', false) + .option('--no-ignore', 'disable ignore from .remarkignore', false); + +/* + * Listen. + */ + +program.on('--help', help); + +/** + * CLI. + * + * @example + * var program = new CLI('--use lint .'); + * + * @constructor + * @class {CLI} + * @param {Array.|Object} argv - CLI arguments. + */ +function CLI(argv) { + var self = this; + var config = argv; + + /* + * Allow passing in a CLI object. + */ + + if (argv instanceof CLI) { + return argv; + } + + self.cache = new Cache(); + self.spinner = new Spinner(); + self.injectedPlugins = []; + + if ('length' in config) { + program.parse(argv); + + self.globs = program.args; + self.extensions = [].concat(program.ext, EXTENSIONS); + self.output = program.output; + self.settings = program.setting; + self.plugins = program.use; + self.color = program.color; + self.out = program.stdout; + self.ast = program.ast; + self.detectRC = program.rc; + self.detectIgnore = program.ignore; + self.quiet = program.quiet; + self.silent = program.silent; + self.frail = program.frail; + self.filePath = program.filePath; + self.configPath = program.configPath; + self.ignorePath = program.ignorePath; + self.watch = program.watch; + } else { + self.globs = [].concat(config.files || []); + self.extensions = [].concat(config.extensions || [], EXTENSIONS); + self.output = config.output; + self.settings = config.settings; + self.plugins = config.plugins; + self.color = config.color; + self.out = config.stdout; + self.ast = config.ast; + self.detectRC = config.detectRC; + self.detectIgnore = config.detectIgnore; + self.quiet = config.quiet; + self.silent = config.silent; + self.frail = config.frail; + self.filePath = config.filePath; + self.configPath = config.configPath; + self.ignorePath = config.ignorePath; + self.watch = config.watch; + } + + self.cwd = config.cwd || process.cwd(); + + Emitter.call(self); +} + +/** + * Log messages. + * + * @this {CLI} + */ +function log() { + var self = this; + var stdout = self.stdout; + + if (!self.silent && !self.quiet) { + stdout.write.apply(stdout, arguments); + } +} + +/** + * Output usage. + * + * @this {CLI} + */ +function usage() { + return program.outputHelp(); +} + +/** + * Cache plug-ins. + * + * @param {Function} plugin - Plugin to use. + * @param {Object?} [options] - Optional plug-in + * configuration. + * @this {CLI} + */ +function use(plugin, options) { + this.injectedPlugins.push([plugin, options]); + + return this; +} + +/* + * Prototype. + */ + +util.inherits(CLI, Emitter); + +CLI.prototype.stdout = process.stdout; +CLI.prototype.stderr = process.stderr; +CLI.prototype.log = log; +CLI.prototype.usage = usage; +CLI.prototype.use = use; + +/* + * Expose. + */ + +module.exports = CLI; diff --git a/tools/node_modules/remark/lib/cli/configuration.js b/tools/node_modules/remark/lib/cli/configuration.js new file mode 100644 index 00000000000000..12045b205d010f --- /dev/null +++ b/tools/node_modules/remark/lib/cli/configuration.js @@ -0,0 +1,318 @@ +/** + * @author Titus Wormer + * @copyright 2015-2016 Titus Wormer + * @license MIT + * @module remark:cli:configuration + * @version 3.2.2 + * @fileoverview Find remark rc files. + */ + +'use strict'; + +/* eslint-env node */ + +/* + * Dependencies. + */ + +var fs = require('fs'); +var path = require('path'); +var debug = require('debug')('remark:cli:configuration'); +var home = require('user-home'); +var findUp = require('vfile-find-up'); +var extend = require('extend.js'); +var defaults = require('../defaults'); + +/* + * Constants. + */ + +var RC_NAME = '.remarkrc'; +var PLUGIN_KEY = 'plugins'; +var PACKAGE_NAME = 'package'; +var PACKAGE_EXTENSION = 'json'; +var PACKAGE_FILENAME = [PACKAGE_NAME, PACKAGE_EXTENSION].join('.'); +var PACKAGE_FIELD = 'remarkConfig'; +var PERSONAL_CONFIGURATION = home ? path.join(home, RC_NAME) : null; + +/* + * Methods. + */ + +var read = fs.readFileSync; +var exists = fs.existsSync; +var has = Object.prototype.hasOwnProperty; +var concat = Array.prototype.concat; + +/* + * Set-up. + */ + +var base = { + 'settings': {} +}; + +extend(base.settings, defaults.parse); +extend(base.settings, defaults.stringify); + +/** + * Merge two configurations, `configuration` into + * `target`. + * + * @example + * var target = {}; + * merge(target, current); + * + * @param {Object} target - Configuration to merge into. + * @param {Object} configuration - Configuration to merge + * from. + * @param {boolean} [recursive] - Used internally no ensure + * the plug-in key is only escaped at root-level. + * @return {Object} - `target`. + */ +function merge(target, configuration, recursive) { + var key; + var value; + var index; + var length; + var result; + + for (key in configuration) { + if (has.call(configuration, key)) { + value = configuration[key]; + result = target[key]; + + if (key === PLUGIN_KEY && !recursive) { + if (!result) { + result = {}; + + target[key] = result; + } + + if ('length' in value) { + index = -1; + length = value.length; + + while (++index < length) { + if (!(value[index] in result)) { + result[value[index]] = null; + } + } + } else { + target[key] = merge(result, value, true); + } + } else if (typeof value === 'object' && value !== null) { + if ('length' in value) { + target[key] = concat.apply(value); + } else { + target[key] = merge(result || {}, value, true); + } + } else if (value !== undefined) { + target[key] = value; + } + } + } + + return target; +} + +/** + * Parse a JSON configuration object from a file. + * + * @example + * var rawConfig = load('package.json'); + * + * @throws {Error} - Throws when `filePath` is not found. + * @param {string} filePath - File location. + * @return {Object} - Parsed JSON. + */ +function load(filePath) { + var configuration = {}; + + if (filePath) { + try { + configuration = JSON.parse(read(filePath, 'utf8')) || {}; + } catch (exception) { + exception.message = 'Cannot read configuration file: ' + + filePath + '\n' + exception.message; + + throw exception; + } + } + + return configuration; +} + +/** + * Get personal configuration object from `~`. + * + * @example + * var config = getUserConfiguration(); + * + * @return {Object} - Parsed JSON. + */ +function getUserConfiguration() { + var configuration = {}; + + if (PERSONAL_CONFIGURATION && exists(PERSONAL_CONFIGURATION)) { + configuration = load(PERSONAL_CONFIGURATION); + } + + return configuration; +} + +/** + * Get a local configuration object, by walking from + * `directory` upwards and mergin all configurations. + * If no configuration was found by walking upwards, the + * current user's config (at `~`) is used. + * + * @example + * var configuration = new Configuration(); + * var config = getLocalConfiguration(configuration, '~/bar'); + * + * @param {Configuration} context - Configuration object to use. + * @param {string} directory - Location to search. + * @param {Function} callback - Invoked with `files`. + */ +function getLocalConfiguration(context, directory, callback) { + findUp.all([RC_NAME, PACKAGE_FILENAME], directory, function (err, files) { + var configuration = {}; + var index = files && files.length; + var file; + var local; + var found; + + while (index--) { + file = files[index]; + + local = load(file.filePath()); + + if ( + file.filename === PACKAGE_NAME && + file.extension === PACKAGE_EXTENSION + ) { + local = local[PACKAGE_FIELD] || {}; + } + + found = true; + + debug('Using ' + file.filePath()); + + merge(configuration, local); + } + + if (!found) { + debug('Using personal configuration'); + + merge(configuration, getUserConfiguration()); + } + + callback(err, configuration); + }); +} + +/** + * Configuration. + * + * @example + * var configuration = new Configuration(); + * + * @constructor + * @class Configuration + * @param {Object} options - Options to be passed in. + */ +function Configuration(options) { + var self = this; + var settings = options || {}; + var file = settings.file; + var cliConfiguration = {}; + + self.cache = {}; + + self.cwd = settings.cwd || process.cwd(); + + self.settings = settings.settings || {}; + self.plugins = settings.plugins || {}; + self.output = settings.output; + self.detectRC = settings.detectRC; + + if (file) { + debug('Using command line configuration `' + file + '`'); + + cliConfiguration = load(path.resolve(self.cwd, file)); + } + + self.cliConfiguration = cliConfiguration; +} + +/** + * Defaults. + * + * @type {Object} - Default settings. + */ +Configuration.prototype.base = base; + +/** + * Build a configuration object. + * + * @example + * new Configuration().getConfiguration('~/foo', console.log); + * + * @param {string} filePath - File location. + * @param {Function} callback - Callback invoked with + * configuration. + */ +Configuration.prototype.getConfiguration = function (filePath, callback) { + var self = this; + var directory = filePath ? path.dirname(filePath) : self.cwd; + var configuration = self.cache[directory]; + + debug('Constructing configuration for `' + (filePath || self.cwd) + '`'); + + /** + * Handle (possible) local config result. + * + * @param {Error?} [err] - Loading error. + * @param {Object?} [localConfiguration] - Configuration. + */ + function handleLocalConfiguration(err, localConfiguration) { + if (localConfiguration) { + merge(configuration, localConfiguration); + } + + merge(configuration, self.cliConfiguration); + + merge(configuration, { + 'settings': self.settings, + 'plugins': self.plugins, + 'output': self.output + }); + + self.cache[directory] = configuration; + + callback(err, configuration); + } + + if (configuration) { + debug('Using configuration from cache'); + callback(null, configuration); + } else { + configuration = {}; + + merge(configuration, self.base); + + if (!self.detectRC) { + debug('Ignoring .rc files'); + handleLocalConfiguration(); + } else { + getLocalConfiguration(self, directory, handleLocalConfiguration); + } + } +}; + +/* + * Expose. + */ + +module.exports = Configuration; diff --git a/tools/node_modules/remark/lib/cli/file-pipeline/configure.js b/tools/node_modules/remark/lib/cli/file-pipeline/configure.js new file mode 100644 index 00000000000000..5a6f6588d110fb --- /dev/null +++ b/tools/node_modules/remark/lib/cli/file-pipeline/configure.js @@ -0,0 +1,255 @@ +/** + * @author Titus Wormer + * @copyright 2015-2016 Titus Wormer + * @license MIT + * @module remark:cli:file-pipeline:configure + * @version 3.2.2 + * @fileoverview Configure a file. + */ + +'use strict'; + +/* eslint-env node */ + +/* + * Dependencies. + */ + +var fs = require('fs'); +var path = require('path'); +var debug = require('debug')('remark:cli:file-pipeline:configure'); +var npmPrefix = require('npm-prefix')(); +var remark = require('../../..'); + +/* + * Methods. + */ + +var exists = fs.existsSync; +var join = path.join; +var resolve = path.resolve; + +/* + * Constants. + */ + +var SEPERATOR = path.sep; +var MODULES = 'node_modules'; +var isWindows = process.platform === 'win32'; +var isGlobal = process.argv[1].indexOf(npmPrefix) === 0; +var globals = resolve(npmPrefix, isWindows ? '' : 'lib', MODULES); + +/* + * Utilities. + */ + +/** + * Find root of a node module: parent directory of + * `package.json`, or, the given directory if no + * ancestral `package.json` is found. + * + * @example + * findRoot('remark/test'); // 'remark' + * + * @todo Externalise. + * @param {string} base - Path to directory. + * @return {string} - Path to an ancestral project + * directory. + */ +function findRoot(base) { + var location = base; + var parts = base.split(SEPERATOR); + + while (!exists(join(location, 'package.json')) && parts.length > 1) { + parts.pop(); + + location = parts.join(SEPERATOR); + } + + return parts.length ? location : base; +} + +/** + * Require a plugin. Checks, in this order: + * + * - `$package/$pathlike`; + * - `$package/$pathlike.js`; + * - `$package/node_modules/$pathlike`; + * - `$package/node_modules/remark-$pathlike`; + * - `$cwd/node_modules/$pathlike`; + * - `$cwd/node_modules/remark-$pathlike`; + * - `$pathlike`. + * + * Where `$package` is an ancestral package directory. + * + * When using a globally installed executable, the + * following are also included: + * + * - `$modules/$pathlike`; + * - `$modules/remark-$pathlike`. + * + * Where `$modules` is the directory of globally installed + * npm packages. + * + * @see https://docs.npmjs.com/files/folders#node-modules + * + * @example + * var plugin = findPlugin('toc'); + * + * @todo Externalise. + * @throws {Error} - Fails when `pathlike` cannot be + * resolved. + * @param {string} pathlike - Reference to plugin. + * @param {string?} [cwd] - Relative working directory, + * defaults to the current working directory. + * @return {Object} - Result of `require`ing `plugin`. + */ +function findPlugin(pathlike, cwd) { + var root = findRoot(cwd); + var pluginlike = 'remark-' + pathlike; + var index = -1; + var plugin = pathlike; + var length; + var paths = [ + resolve(root, pathlike), + resolve(root, pathlike + '.js'), + resolve(root, MODULES, pluginlike), + resolve(root, MODULES, pathlike), + resolve(cwd, MODULES, pluginlike), + resolve(cwd, MODULES, pathlike) + ]; + + if (isGlobal) { + paths.push( + resolve(globals, pathlike), + resolve(globals, pluginlike) + ); + } + + length = paths.length; + + while (++index < length) { + if (exists(paths[index])) { + plugin = paths[index]; + break; + } + } + + debug('Using plug-in `%s` at `%s`', pathlike, plugin); + + return require(plugin); +} + +/** + * Collect configuration for a file based on the context. + * + * @example + * var fileSet = new FileSet(cli); + * var file = new File({ + * 'directory': '~', + * 'filename': 'example', + * 'extension': 'md' + * }); + * + * configure({'file': file, 'fileSet': fileSet}); + * + * @param {Object} context - Context object. + * @param {function(Error?)} next - Callback invoked when + * done. + */ +function configure(context, next) { + var file = context.file; + var cli = context.fileSet.cli; + var config = cli.configuration; + var processor = remark(); + var plugins; + + if (file.hasFailed()) { + next(); + return; + } + + config.getConfiguration(file.filePath(), function (err, options) { + var option; + var plugin; + var length; + var index; + var name; + + debug('Setting output `%s`', options.output); + + debug('Using settings `%j`', options.settings); + + plugins = Object.keys(options.plugins); + length = plugins.length; + index = -1; + + debug('Using plug-ins `%j`', plugins); + + while (++index < length) { + name = plugins[index]; + option = options.plugins[name]; + + if (option === false) { + debug('Ignoring plug-in `%s`', name); + continue; + } + + /* + * Allow for default arguments. + */ + + if (option === null) { + option = undefined; + } + + try { + plugin = findPlugin(name, cli.cwd); + + debug('Applying options `%j` to `%s`', option, name); + + processor.use(plugin, option, context.fileSet); + } catch (err) { + next(err); + return; + } + } + + plugins = cli.injectedPlugins; + length = plugins.length; + index = -1; + + debug('Using `%d` injected plugins', length); + + while (++index < length) { + plugin = plugins[index][0]; + option = plugins[index][1]; + name = plugin.displayName || plugin.name || ''; + + try { + debug('Applying options `%j` to `%s`', option, name); + + processor.use(plugin, option, context.fileSet); + } catch (err) { + next(err); + return; + } + } + + /* + * Store some configuration on the context object. + */ + + context.output = options.output; + context.settings = options.settings; + context.processor = processor; + + next(); + }); +} + +/* + * Expose. + */ + +module.exports = configure; diff --git a/tools/node_modules/remark/lib/cli/file-pipeline/copy.js b/tools/node_modules/remark/lib/cli/file-pipeline/copy.js new file mode 100644 index 00000000000000..6aafd4f87105d1 --- /dev/null +++ b/tools/node_modules/remark/lib/cli/file-pipeline/copy.js @@ -0,0 +1,123 @@ +/** + * @author Titus Wormer + * @copyright 2015-2016 Titus Wormer + * @license MIT + * @module remark:cli:file-pipeline:copy + * @version 3.2.2 + * @fileoverview Move a file. + */ + +'use strict'; + +/* eslint-env node */ + +/* + * Dependencies. + */ + +var fs = require('fs'); +var path = require('path'); +var debug = require('debug')('remark:cli:file-pipeline:copy'); + +/* + * Methods. + */ + +var stat = fs.statSync; +var basename = path.basename; +var extname = path.extname; +var dirname = path.dirname; +var resolve = path.resolve; + +/* + * Constants. + */ + +var SEPERATOR = path.sep; + +/** + * Move a file. + * + * @example + * var fileSet = new FileSet(cli); + * + * var file = new File({ + * 'directory': '~', + * 'filename': 'example', + * 'extension': 'md', + * 'contents': '# Hello' + * }); + * + * fileSet.add(file); + * + * copy({ + * 'output': 'foo/', + * 'file': file, + * 'fileSet': fileSet + * }); + * + * @param {Object} context - Context object. + */ +function copy(context) { + var fileSet = context.fileSet; + var file = context.file; + var outpath = context.output; + var multi = fileSet.length > 1; + var currentPath = file.filePath(); + var isDir; + var extension; + + if (typeof outpath !== 'string') { + debug('Not copying'); + + return; + } + + debug('Copying `%s`', currentPath); + + try { + isDir = stat(resolve(outpath)).isDirectory(); + } catch (err) { + if ( + err.code !== 'ENOENT' || + outpath.charAt(outpath.length - 1) === SEPERATOR + ) { + err.message = 'Cannot read output directory. Error:\n' + + err.message; + + throw err; + } + + /* + * This throws, or the parent exists, which + * is a directory, but we should keep the + * filename and extension of the given + * file. + */ + + stat(resolve(dirname(outpath))).isDirectory(); + isDir = false; + } + + if (!isDir && multi) { + throw new Error( + 'Cannot write multiple files to single output: ' + outpath + ); + } + + extension = extname(outpath); + + file.move({ + 'extension': isDir ? '' : extension ? extension.slice(1) : '', + 'filename': isDir ? '' : basename(outpath, extension), + 'directory': isDir ? outpath : dirname(outpath) + }); + + debug('Copying document from %s to %s', currentPath, file.filePath()); +} + +/* + * Expose. + */ + +module.exports = copy; diff --git a/tools/node_modules/remark/lib/cli/file-pipeline/file-system.js b/tools/node_modules/remark/lib/cli/file-pipeline/file-system.js new file mode 100644 index 00000000000000..6b8236fe34592f --- /dev/null +++ b/tools/node_modules/remark/lib/cli/file-pipeline/file-system.js @@ -0,0 +1,107 @@ +/** + * @author Titus Wormer + * @copyright 2015-2016 Titus Wormer + * @license MIT + * @module remark:cli:file-pipeline:file-system + * @version 3.2.2 + * @fileoverview Write a file to the file system. + */ + +'use strict'; + +/* eslint-env node */ + +/* + * Dependencies. + */ + +var fs = require('fs'); +var debug = require('debug')('remark:cli:file-pipeline:file-system'); + +/* + * Methods. + */ + +var writeFile = fs.writeFile; + +/** + * Write a virtual file to the file-system. + * Ignored when `output` is not given. + * + * @example + * var file = new File({ + * 'directory': '~', + * 'filename': 'example', + * 'extension': 'md', + * 'contents': '# Hello' + * }); + * + * file.given = true; + * + * fileSystem({ + * 'output': true, + * 'file': file + * }); + * + * @param {Object} context - Context object. + * @param {function(Error?)} done - Completion handler. + */ +function fileSystem(context, done) { + var file = context.file; + var fileSet = context.fileSet; + var cli = fileSet.cli; + var sourcePaths = fileSet.sourcePaths; + var destinationPath; + + if (!context.output) { + debug('Ignoring writing to file-system'); + + done(); + + return; + } + + if (!file.namespace('remark:cli').given) { + debug('Ignoring programmatically added file'); + + done(); + + return; + } + + destinationPath = file.filePath(); + + if (!destinationPath) { + debug('Ignoring file without output location'); + + done(); + + return; + } + + /* + * When watching, `sourcePath`s are watched. Thus, we + * check if we are planning on writing to a watched + * file-path. In which case we exit. + */ + + if (cli.watch && (sourcePaths.indexOf(destinationPath) !== -1)) { + debug('Caching document as `%s` is watched', destinationPath); + + cli.cache.add(file); + + done(); + } else { + debug('Writing document to `%s`', destinationPath); + + file.stored = true; + + writeFile(destinationPath, file.toString(), done); + } +} + +/* + * Expose. + */ + +module.exports = fileSystem; diff --git a/tools/node_modules/remark/lib/cli/file-pipeline/index.js b/tools/node_modules/remark/lib/cli/file-pipeline/index.js new file mode 100644 index 00000000000000..5d75dc373cda0d --- /dev/null +++ b/tools/node_modules/remark/lib/cli/file-pipeline/index.js @@ -0,0 +1,86 @@ +/** + * @author Titus Wormer + * @copyright 2015-2016 Titus Wormer + * @license MIT + * @module remark:cli:file-pipeline + * @version 3.2.2 + * @fileoverview Process a file. + */ + +'use strict'; + +/* eslint-env node */ + +/* + * Dependencies. + */ + +var ware = require('ware'); +var read = require('./read'); +var configure = require('./configure'); +var parse = require('./parse'); +var transform = require('./transform'); +var queue = require('./queue'); +var stringify = require('./stringify'); +var copy = require('./copy'); +var stdout = require('./stdout'); +var fileSystem = require('./file-system'); + +/** + * Factory to run a pipe. Wraps a pipe to trigger an + * error on the `file` in `context`, but still call + * `next`. + * + * @param {Ware} pipe - Middelware. + * @return {function(Object, Function)} - Runner. + */ +function runFactory(pipe) { + /** + * Run `context` through a bound pipe. + * Always invokes `next` (without error). + * + * @param {Object} context - File context. + * @param {function()} next - Next. + */ + function run(context, next) { + pipe.run(context, function (err) { + if (err) { + context.file.quiet = true; + context.file.fail(err); + } + + next(); + }); + } + + return run; +} + +/* + * Middleware, this ensures each of the four pipes + * always runs (so even if the read pipe fails), + * queue, write, and log trigger. + */ + +var pipe = ware() + .use(runFactory( + ware() + .use(read) + .use(configure) + .use(parse) + .use(transform) + )) + .use(runFactory(ware().use(queue))) + .use(runFactory( + ware() + .use(stringify) + .use(copy) + .use(stdout) + .use(fileSystem) + )); + +/* + * Expose. + */ + +module.exports = pipe; diff --git a/tools/node_modules/remark/lib/cli/file-pipeline/parse.js b/tools/node_modules/remark/lib/cli/file-pipeline/parse.js new file mode 100644 index 00000000000000..76969653d50fae --- /dev/null +++ b/tools/node_modules/remark/lib/cli/file-pipeline/parse.js @@ -0,0 +1,54 @@ +/** + * @author Titus Wormer + * @copyright 2015-2016 Titus Wormer + * @license MIT + * @module remark:cli:file-pipeline:parse + * @version 3.2.2 + * @fileoverview Parse a file into an AST. + */ + +'use strict'; + +/* eslint-env node */ + +/* + * Dependencies. + */ + +var debug = require('debug')('remark:cli:file-pipeline:parse'); + +/** + * Fill a file with an ast. + * + * @example + * var file = new File({ + * 'contents': '# Hello' + * }); + * + * vat settings = {'position': false}; + * + * parse({'file': file, 'settings': settings}); + * + * file.namespace('mdast').tree.type; // 'root' + * + * @param {Object} context - Context object. + */ +function parse(context) { + var file = context.file; + + if (file.hasFailed()) { + return; + } + + debug('Parsing document'); + + context.processor.parse(file, context.settings); + + debug('Parsed document'); +} + +/* + * Expose. + */ + +module.exports = parse; diff --git a/tools/node_modules/remark/lib/cli/file-pipeline/queue.js b/tools/node_modules/remark/lib/cli/file-pipeline/queue.js new file mode 100644 index 00000000000000..6c96530223e8c6 --- /dev/null +++ b/tools/node_modules/remark/lib/cli/file-pipeline/queue.js @@ -0,0 +1,87 @@ +/** + * @author Titus Wormer + * @copyright 2015-2016 Titus Wormer + * @license MIT + * @module remark:cli:file-pipeline:queue + * @version 3.2.2 + * @fileoverview Queue all files which came this far. + */ + +'use strict'; + +/* eslint-env node */ + +/* + * Dependencies. + */ + +var debug = require('debug')('remark:cli:file-pipeline:queue'); + +/** + * Queue all files which came this far. + * When the last file gets here, run the file-set pipeline + * and flush the queue. + * + * @example + * var fileSet = new FileSet(cli); + * var file = new File(); + * + * file.sourcePath = '~/foo/bar.md'; + * fileSet.add(file); + * + * queue({'file': file, 'fileSet': fileSet}, console.log); + * + * @param {Object} context - Context object. + * @param {function(Error?)} done - Completion handler. + */ +function queue(context, done) { + var fileSet = context.fileSet; + var original = context.file.sourcePath; + var complete = true; + var map = fileSet.complete; + + if (!map) { + map = fileSet.complete = {}; + } + + debug('Queueing %s', original); + + map[original] = done; + + fileSet.valueOf().forEach(function (file) { + var key = file.sourcePath; + + if (file.hasFailed()) { + return; + } + + if (typeof map[key] !== 'function') { + debug('Interupting flush as %s is not finished', key); + complete = false; + } else { + debug('Can flush for `%s`', key); + } + }); + + if (!complete) { + debug('Not flushing'); + return; + } + + fileSet.pipeline.run(fileSet, function (err) { + debug('Flushing'); + /* + * Flush. + */ + + for (original in map) { + map[original](err); + } + }); +} + +/* + * Expose. + */ + +module.exports = queue; diff --git a/tools/node_modules/remark/lib/cli/file-pipeline/read.js b/tools/node_modules/remark/lib/cli/file-pipeline/read.js new file mode 100644 index 00000000000000..18d02e0093166f --- /dev/null +++ b/tools/node_modules/remark/lib/cli/file-pipeline/read.js @@ -0,0 +1,70 @@ +/** + * @author Titus Wormer + * @copyright 2015-2016 Titus Wormer + * @license MIT + * @module remark:cli:file-pipeline:read + * @version 3.2.2 + * @fileoverview Read a file if not already filled. + */ + +'use strict'; + +/* eslint-env node */ + +/* + * Dependencies. + */ + +var fs = require('fs'); +var debug = require('debug')('remark:cli:file-pipeline:read'); + +/* + * Methods. + */ + +var readFile = fs.readFile; + +/* + * Constants. + */ + +var ENCODING = 'utf-8'; + +/** + * Fill a file with its contents when not already filled. + * + * @example + * var file = new File({ + * 'directory': '~', + * 'filename': 'example', + * 'extension': 'md' + * }); + * + * read({'file': file}, console.log); + * + * @param {Object} context - Context object. + * @param {function(Error?)} done - Completion handler. + */ +function read(context, done) { + var file = context.file; + var filePath = file.filePath(); + + if (file.contents || file.hasFailed()) { + done(); + } else { + debug('Reading `%s` in `%s`', filePath, ENCODING); + + readFile(filePath, ENCODING, function (err, contents) { + debug('Read `%s` (err: %s)', filePath, err); + file.contents = contents || ''; + + done(err); + }); + } +} + +/* + * Expose. + */ + +module.exports = read; diff --git a/tools/node_modules/remark/lib/cli/file-pipeline/stdout.js b/tools/node_modules/remark/lib/cli/file-pipeline/stdout.js new file mode 100644 index 00000000000000..4059d671bb15e2 --- /dev/null +++ b/tools/node_modules/remark/lib/cli/file-pipeline/stdout.js @@ -0,0 +1,72 @@ +/** + * @author Titus Wormer + * @copyright 2015-2016 Titus Wormer + * @license MIT + * @module remark:cli:file-pipeline:stdout + * @version 3.2.2 + * @fileoverview Write a file to stdout(4). + */ + +'use strict'; + +/* eslint-env node */ + +/* + * Dependencies. + */ + +var debug = require('debug')('remark:cli:file-pipeline:stdout'); + +/** + * Write a virtual file to stdout(4). + * Ignored when `output` is given, more than one file + * was processed, or `stdout` is false. + * + * @example + * var cli = {'stdout': process.stdout.write}; + * var fileSet = new FileSet(cli); + * var file = new File({ + * 'directory': '~', + * 'filename': 'example', + * 'extension': 'md', + * 'contents': '# Hello' + * }); + * fileSet.add(file); + * + * stdout({ + * 'output': false, + * 'file': file, + * 'fileSet': fileSet + * }); + * + * @param {Object} context - Context object. + */ +function stdout(context) { + var fileSet = context.fileSet; + var file = context.file; + + if ( + !fileSet.cli.watch && + fileSet.cli.out && + fileSet.length === 1 && + (!context.output || !file.filePath()) + ) { + if (!file.namespace('remark:cli').given) { + debug('Ignoring programmatically added file'); + + return; + } + + debug('Writing document to standard out'); + + fileSet.cli.stdout.write(context.file.toString()); + } else { + debug('Ignoring writing to standard out'); + } +} + +/* + * Expose. + */ + +module.exports = stdout; diff --git a/tools/node_modules/remark/lib/cli/file-pipeline/stringify.js b/tools/node_modules/remark/lib/cli/file-pipeline/stringify.js new file mode 100644 index 00000000000000..d5ee3ad6f7dd14 --- /dev/null +++ b/tools/node_modules/remark/lib/cli/file-pipeline/stringify.js @@ -0,0 +1,68 @@ +/** + * @author Titus Wormer + * @copyright 2015-2016 Titus Wormer + * @license MIT + * @module remark:cli:file-pipeline:stringify + * @version 3.2.2 + * @fileoverview Compile an AST into a file. + */ + +'use strict'; + +/* eslint-env node */ + +/* + * Dependencies. + */ + +var debug = require('debug')('remark:cli:file-pipeline:stringify'); + +/** + * Stringify an AST. + * + * @example + * var fileSet = new FileSet(cli); + * var file = new File({ + * 'contents': '# Hello' + * }); + * fileSet.add(file); + * + * var context = {'processor': remark(), 'file': file, 'fileSet': fileSet}; + * + * parse(context); + * stringify(context); + * + * @param {Object} context - Context object. + */ +function stringify(context) { + var cli = context.fileSet.cli; + var file = context.file; + var value; + + if (!context.processor || context.ast) { + debug('Not compiling failed document'); + return; + } + + debug('Compiling document'); + + if (cli.ast) { + file.move({ + 'extension': 'json' + }); + + value = JSON.stringify(file.namespace('mdast').tree, null, 2); + } else { + value = context.processor.stringify(file, context.settings); + } + + file.contents = value; + + debug('Compiled document to %s', file.extension || 'markdown'); +} + +/* + * Expose. + */ + +module.exports = stringify; diff --git a/tools/node_modules/remark/lib/cli/file-pipeline/transform.js b/tools/node_modules/remark/lib/cli/file-pipeline/transform.js new file mode 100644 index 00000000000000..b4f29cc9df79ae --- /dev/null +++ b/tools/node_modules/remark/lib/cli/file-pipeline/transform.js @@ -0,0 +1,61 @@ +/** + * @author Titus Wormer + * @copyright 2015-2016 Titus Wormer + * @license MIT + * @module remark:cli:file-pipeline:transform + * @version 3.2.2 + * @fileoverview Transform an AST associated with a file. + */ + +'use strict'; + +/* eslint-env node */ + +/* + * Dependencies. + */ + +var debug = require('debug')('remark:cli:file-pipeline:transform'); + +/** + * Transform the `ast` associated with a file with + * configured plug-ins. + * + * @example + * var file = new File(); + * + * file.namespace('mdast').tree = { + * 'type': 'paragraph', + * 'children': [{ + * 'type': 'text', + * 'value': 'Foo.' + * }] + * }; + * + * transform({'file': file}, console.log); + * + * @param {Object} context - Context object. + * @param {function(Error?)} done - Completion handler. + */ +function transform(context, done) { + var file = context.file; + + if (file.hasFailed()) { + done(); + return; + } + + debug('Transforming document', file.filePath()); + + context.processor.run(file.namespace('mdast').tree, file, function (err) { + debug('Transformed document (error: %s)', err); + + done(err); + }); +} + +/* + * Expose. + */ + +module.exports = transform; diff --git a/tools/node_modules/remark/lib/cli/file-set-pipeline/configure.js b/tools/node_modules/remark/lib/cli/file-set-pipeline/configure.js new file mode 100644 index 00000000000000..438fd4310ff466 --- /dev/null +++ b/tools/node_modules/remark/lib/cli/file-set-pipeline/configure.js @@ -0,0 +1,48 @@ +/** + * @author Titus Wormer + * @copyright 2015-2016 Titus Wormer + * @license MIT + * @module remark:cli:file-set-pipeline:configure + * @version 3.2.2 + * @fileoverview Configure a collection of files. + */ + +'use strict'; + +/* eslint-env node */ + +/* + * Dependencies. + */ + +var Configuration = require('../configuration'); + +/** + * Configure the CLI. + * + * @example + * configure({ + * 'detectRC': true, + * 'settings': {'position': false}, + * }); + * + * @param {Object} context - Context object. + */ +function configure(context) { + if (!context.configuration) { + context.configuration = new Configuration({ + 'detectRC': context.detectRC, + 'file': context.configPath, + 'settings': context.settings, + 'plugins': context.plugins, + 'output': context.output, + 'cwd': context.cwd + }); + } +} + +/* + * Expose. + */ + +module.exports = configure; diff --git a/tools/node_modules/remark/lib/cli/file-set-pipeline/file-system.js b/tools/node_modules/remark/lib/cli/file-set-pipeline/file-system.js new file mode 100644 index 00000000000000..43545b682e80b6 --- /dev/null +++ b/tools/node_modules/remark/lib/cli/file-set-pipeline/file-system.js @@ -0,0 +1,75 @@ +/** + * @author Titus Wormer + * @copyright 2015-2016 Titus Wormer + * @license MIT + * @module remark:cli:file-set-pipeline:traverse + * @version 3.2.2 + * @fileoverview Find files from the file-system. + */ + +'use strict'; + +/* eslint-env node */ + +/* + * Dependencies. + */ + +var Ignore = require('../ignore'); +var Finder = require('../finder'); + +/** + * Find files from the file-system. + * + * @example + * traverse({ + * 'extensions': ['markdown'] + * }); + * + * @param {Object} context - Context object. + * @param {function(Error?)} done - Callback invoked when + * done. + */ +function traverse(context, done) { + var ignore; + + /** Traverse. */ + function next() { + /* + * Use the files when they were injected, + * which we now because there are no globs. + */ + + if (context.files && !context.globs.length) { + done(); + return; + } + + context.traverser.find(context.globs, function (err, files) { + context.files = files || []; + done(err); + }); + } + + if (context.traverser) { + next(); + } else { + ignore = new Ignore({ + 'file': context.ignorePath, + 'detectIgnore': context.detectIgnore + }); + + context.traverser = new Finder({ + 'extensions': context.extensions, + 'ignore': ignore + }); + + ignore.loadPatterns(next); + } +} + +/* + * Expose. + */ + +module.exports = traverse; diff --git a/tools/node_modules/remark/lib/cli/file-set-pipeline/index.js b/tools/node_modules/remark/lib/cli/file-set-pipeline/index.js new file mode 100644 index 00000000000000..9c9785f5b4bc61 --- /dev/null +++ b/tools/node_modules/remark/lib/cli/file-set-pipeline/index.js @@ -0,0 +1,40 @@ +/** + * @author Titus Wormer + * @copyright 2015-2016 Titus Wormer + * @license MIT + * @module remark:cli:file-set-pipeline + * @version 3.2.2 + * @fileoverview Process a collection of files. + */ + +'use strict'; + +/* eslint-env node */ + +/* + * Dependencies. + */ + +var ware = require('ware'); +var configure = require('./configure'); +var fileSystem = require('./file-system'); +var stdin = require('./stdin'); +var transform = require('./transform'); +var log = require('./log'); + +/* + * Middleware. + */ + +var fileSetPipeline = ware() + .use(configure) + .use(fileSystem) + .use(stdin) + .use(transform) + .use(log); + +/* + * Expose. + */ + +module.exports = fileSetPipeline; diff --git a/tools/node_modules/remark/lib/cli/file-set-pipeline/log.js b/tools/node_modules/remark/lib/cli/file-set-pipeline/log.js new file mode 100644 index 00000000000000..e1fe8b7ad8dbde --- /dev/null +++ b/tools/node_modules/remark/lib/cli/file-set-pipeline/log.js @@ -0,0 +1,55 @@ +/** + * @author Titus Wormer + * @copyright 2015-2016 Titus Wormer + * @license MIT + * @module remark:cli:log + * @version 3.2.2 + * @fileoverview Log a file context on successful completion. + */ + +'use strict'; + +/* eslint-env node */ + +/* + * Dependencies. + */ + +var chalk = require('chalk'); +var report = require('vfile-reporter'); + +/** + * Whether a file is given by the user on remark(1). + * + * @param {VFile} file - Virtual file. + * @return {boolean} - Whether given by user. + */ +function given(file) { + return file.namespace('remark:cli').given; +} + +/** + * Output diagnostics to stdout(4) or stderr(4). + * + * @param {CLI} context - CLI engine. + */ +function log(context) { + var diagnostics = report(context.files.filter(given), { + 'quiet': context.quiet, + 'silent': context.silent + }); + + if (!context.color) { + diagnostics = chalk.stripColor(diagnostics); + } + + if (diagnostics) { + context.stderr.write(diagnostics + '\n'); + } +} + +/* + * Expose. + */ + +module.exports = log; diff --git a/tools/node_modules/remark/lib/cli/file-set-pipeline/stdin.js b/tools/node_modules/remark/lib/cli/file-set-pipeline/stdin.js new file mode 100644 index 00000000000000..df9446d7a637a3 --- /dev/null +++ b/tools/node_modules/remark/lib/cli/file-set-pipeline/stdin.js @@ -0,0 +1,90 @@ +/** + * @author Titus Wormer + * @copyright 2015-2016 Titus Wormer + * @license MIT + * @module remark:cli:file-set-pipeline:stdin + * @version 3.2.2 + * @fileoverview Read from stdin. + */ + +'use strict'; + +/* eslint-env node */ + +/* + * Dependencies. + */ + +var debug = require('debug')('remark:cli:file-set-pipeline:stdin'); +var fs = require('fs'); +var toVFile = require('to-vfile'); +var concat = require('concat-stream'); + +/* + * Constants. + */ + +var isTTY = process.stdin.isTTY; +var isFIFO; + +try { isFIFO = fs.fstatSync(0).isFIFO(); } catch (e) { /* Empty */ } + +var definitelyTTY = isTTY === true || isFIFO === true; +var expextPipeIn = !isTTY; + +/** + * Read from standard in. + * + * @param {Object} context - Context object. + * @param {function(Error?)} done - Completion handler. + */ +function stdin(context, done) { + var err; + + debug('Checking stdin'); + + if (context.files.length) { + debug('Ignoring stdin'); + + if (definitelyTTY && expextPipeIn) { + err = new Error('remark does not accept both files and stdin'); + } else if (context.filePath) { + err = new Error( + 'remark does not accept `--file-path` for real files.\n' + + 'Did you mean to pass stdin?' + ); + } + + done(err); + + return; + } + + if (definitelyTTY && !expextPipeIn) { + done(new Error('No input')); + + return; + } + + debug('Reading from stdin'); + + process.stdin.pipe(concat({ + 'encoding': 'string' + }, function (value) { + var file = toVFile(context.filePath || ''); + var space = file.namespace('remark:cli'); + + debug('Read from stdin'); + + file.contents = value; + file.quiet = true; + space.isFile = true; + space.given = true; + + context.files = [file]; + + done(); + })); +} + +module.exports = stdin; diff --git a/tools/node_modules/remark/lib/cli/file-set-pipeline/transform.js b/tools/node_modules/remark/lib/cli/file-set-pipeline/transform.js new file mode 100644 index 00000000000000..900838e7034cca --- /dev/null +++ b/tools/node_modules/remark/lib/cli/file-set-pipeline/transform.js @@ -0,0 +1,44 @@ +/** + * @author Titus Wormer + * @copyright 2015-2016 Titus Wormer + * @license MIT + * @module remark:cli:file-set-pipeline:transform + * @version 3.2.2 + * @fileoverview Transform all files. + */ + +'use strict'; + +/* eslint-env node */ + +/* + * Dependencies. + */ + +var FileSet = require('../file-set'); + +/** + * Transform all files. + * + * @example + * var context = new CLI(['.', '-u toc']); + * transform(context, console.log); + * + * @param {Object} context - Context object. + * @param {function(Error?)} done - Completion handler. + */ +function transform(context, done) { + var fileSet = new FileSet(context); + + fileSet.done = done; + + context.files.forEach(fileSet.add, fileSet); + + context.fileSet = fileSet; +} + +/* + * Expose. + */ + +module.exports = transform; diff --git a/tools/node_modules/remark/lib/cli/file-set.js b/tools/node_modules/remark/lib/cli/file-set.js new file mode 100644 index 00000000000000..90bbfd2c3a4856 --- /dev/null +++ b/tools/node_modules/remark/lib/cli/file-set.js @@ -0,0 +1,273 @@ +/** + * @author Titus Wormer + * @copyright 2015-2016 Titus Wormer + * @license MIT + * @module remark:cli:file-set + * @version 3.2.2 + * @fileoverview Collection of virtual files. + */ + +'use strict'; + +/* eslint-env node */ + +/* + * Dependencies. + */ + +var ware = require('ware'); +var toVFile = require('to-vfile'); +var filePipeline = require('./file-pipeline'); + +/** + * Locked `VFile#move`. + * + * @this {VFile} + * @memberof {VFile} + * @return {VFile} - Context object. + */ +function locked() { + return this; +} + +/** + * Utility invoked when a single file has completed it's + * pipeline, invoking `fileSet.done` when all files are + * done. + * + * @example + * var fileSet = new FileSet(cli); + * fileSet.done = function () {console.log('done!');} + * + * fileSet.add(new File()) + * fileSet.add(new File()) + * + * one(fileSet); + * one(fileSet); + * // 'done!' + * + * @param {FileSet} fileSet - Set in which a file + * completed. + */ +function one(fileSet) { + fileSet.count++; + + if (fileSet.count >= fileSet.length && fileSet.done) { + fileSet.done(); + fileSet.done = null; + } +} + +/** + * Construct a new file-set. + * + * @example + * var fileSet = new FileSet(cli); + * + * @constructor + * @class {FileSet} + * @param {CLI|Object} cli - As returned by `lib/cli/cli`. + */ +function FileSet(cli) { + var self = this; + + /** + * Files in the set. + * + * @member {Array.} contents + */ + self.contents = []; + + /** + * Number of files in the set. + * + * @member {number} length + */ + self.length = 0; + + /** + * Number of processed files. + * + * @member {number} count + */ + self.count = 0; + + /** + * File-paths to the original location of files in + * the set. + * + * @member {Array.} soucePaths + */ + self.sourcePaths = []; + + /** + * CLI executing the set. + * + * @member {CLI} cli + */ + self.cli = cli; + + /** + * Pipeline to run when all files in the file-set + * are processed. + * + * @member {Ware} pipeline + */ + self.pipeline = ware(); +} + +/** + * Create an array representation of `fileSet`. + * + * @example + * var fileSet = new FileSet(cli); + * fileSet.valueOf() // [] + * fileSet.toJSON() // [] + * + * @this {FileSet} + * @return {Array.} - Value at the `contents` property + * in context. + */ +function valueOf() { + return this.contents; +} + +/** + * Attach middleware to the pipeline on `fileSet`. + * + * A plug-in (function) can have an `pluginId` property, + * which is used to ignore duplicate attachment. + * + * This pipeline will later be run when when all attached + * files are after the transforming stage. + * + * @example + * var fileSet = new FileSet(cli); + * fileSet.use(console.log); + * + * @this {FileSet} + * @param {Function} plugin - Middleware. + * @return {FileSet} - `this`; context object. + */ +function use(plugin) { + var self = this; + var pipeline = self.pipeline; + var duplicate = false; + + if (plugin && plugin.pluginId) { + duplicate = pipeline.fns.some(function (fn) { + return fn.pluginId === plugin.pluginId; + }); + } + + if (!duplicate && pipeline.fns.indexOf(plugin) !== -1) { + duplicate = true; + } + + if (!duplicate) { + pipeline.use(plugin); + } + + return this; +} + +/** + * Add a file to be processed. + * + * Ignores duplicate files (based on the `filePath` at time + * of addition). + * + * Only runs `file-pipeline` on files which have not + * `failed` before addition. + * + * @example + * var fileSet = new FileSet(cli); + * var fileA = new File({ + * 'directory': '~', + * 'filename': 'example', + * 'extension': 'md' + * }); + * var fileB = new File({ + * 'directory': '~', + * 'filename': 'example', + * 'extension': 'md' + * }); + * + * fileSet.add(fileA); + * fileSet.length; // 1 + * + * fileSet.add(fileB); + * fileSet.length; // 1 + * + * @this {FileSet} + * @param {File|string} file - Virtual file, or path. + * @return {FileSet} - `this`; context object. + */ +function add(file) { + var self = this; + var paths = self.sourcePaths; + var sourcePath; + var context; + + if (typeof file === 'string') { + file = toVFile(file); + } + + sourcePath = file.filePath(); + + if (paths.indexOf(sourcePath) !== -1) { + return self; + } + + paths.push(sourcePath); + + file.sourcePath = sourcePath; + + if (!file.namespace('remark:cli').given) { + file.move = locked; + } + + self.length++; + + self.valueOf().push(file); + + context = { + 'file': file, + 'fileSet': self + }; + + /* + * Force an asynchronous operation. + * This ensures that files which fall through + * the file pipeline quicker that expected (e.g., + * when already fatally failed) still queue up + * correctly. + */ + + setImmediate(function () { + filePipeline.run(context, function (err) { + if (err) { + file.fail(err); + } + + one(self); + }); + }); + + return self; +} + +/* + * Expose methods. + */ + +FileSet.prototype.valueOf = valueOf; +FileSet.prototype.toJSON = valueOf; +FileSet.prototype.use = use; +FileSet.prototype.add = add; + +/* + * Expose. + */ + +module.exports = FileSet; diff --git a/tools/node_modules/remark/lib/cli/finder.js b/tools/node_modules/remark/lib/cli/finder.js new file mode 100644 index 00000000000000..d79c9a92d4b73c --- /dev/null +++ b/tools/node_modules/remark/lib/cli/finder.js @@ -0,0 +1,159 @@ +/** + * @author Titus Wormer + * @copyright 2015-2016 Titus Wormer + * @license MIT + * @module remark:cli:traverser + * @version 3.2.2 + * @fileoverview Get applicable input files from + * the file system to be processed by remark, respecting + * ignored paths and applicable extensions. + */ + +'use strict'; + +/* eslint-env node */ + +/* + * Dependencies. + */ + +var fs = require('fs'); +var globby = require('globby'); +var hasMagic = require('glob').hasMagic; +var minimatch = require('minimatch'); +var toVFile = require('to-vfile'); +var findDown = require('vfile-find-down'); + +/* + * Methods. + */ + +var stat = fs.statSync; + +/** + * Check if `file` matches `pattern`. + * + * @example + * match('baz.md', '*.md'); // true + * + * @param {string} filePath - File location. + * @param {string} pattern - Glob pattern. + * @return {boolean} - Whether `file` matches `pattern`. + */ +function match(filePath, pattern) { + return minimatch(filePath, pattern) || + minimatch(filePath, pattern + '/**'); +} + +/** + * Construct a new finder. + * + * @example + * var finder = new Finder({ + * 'extensions': ['text', 'txt'] + * }); + * + * @constructor + * @class {Finder} + * @param {Object} [options={}] - Settings. + * @param {Ignore} [options.ignore] + * - File-paths to ignore. + * @param {Array.} [options.extensions=[]] + * - Extensions to search. + */ +function Finder(options) { + var self = this; + var settings = options || {}; + + self.ignore = settings.ignore; + self.extensions = settings.extensions || []; +} + +/** + * Find files matching `globs` and the bound settings. + * + * @example + * var finder = new Finder(); + * finder.find(['readme.md'], console.log); + * + * @this {Finder} + * @param {Array.} globs - Globs to search for. + * @param {Function} callback - Callback to invoke when + * done. + */ +function find(globs, callback) { + var self = this; + var ignore = self.ignore; + var extensions = self.extensions; + var given = []; + var failed = []; + + globs.forEach(function (glob) { + var file; + + if (hasMagic(glob)) { + return; + } + + given.push(glob); + + try { + stat(glob); + } catch (err) { + file = toVFile(glob); + file.quiet = true; + + file.fail('No such file or directory'); + + failed.push(file); + } + }); + + globby(globs).then(function (filePaths) { + findDown.all(function (file) { + var filePath = file.filePath(); + var extension = file.extension; + var mask; + + if (ignore.shouldIgnore(filePath)) { + mask = findDown.SKIP; + + if (given.indexOf(filePath) !== -1) { + mask = mask | findDown.INCLUDE; + + file.fail( + 'Ignoring file specified on CLI as it is ' + + 'ignored by `.remarkignore`' + ); + } + + return mask; + } + + if (extension && extensions.indexOf(extension) !== -1) { + return true; + } + + return globs.some(function (glob) { + return match(filePath, glob) && stat(filePath).isFile(); + }); + }, filePaths, function (err, files) { + callback(err, failed.concat(files).map(function (file) { + file.namespace('remark:cli').given = true; + return file; + })); + }); + }, callback); +} + +/* + * Methods. + */ + +Finder.prototype.find = find; + +/* + * Expose. + */ + +module.exports = Finder; diff --git a/tools/node_modules/remark/lib/cli/ignore.js b/tools/node_modules/remark/lib/cli/ignore.js new file mode 100644 index 00000000000000..bf28bc59d2cf08 --- /dev/null +++ b/tools/node_modules/remark/lib/cli/ignore.js @@ -0,0 +1,247 @@ +/** + * @author Titus Wormer + * @copyright 2015-2016 Titus Wormer + * @license MIT + * @module remark:cli:ignore + * @version 3.2.2 + * @fileoverview Find remark ignore files. + */ + +'use strict'; + +/* eslint-env node */ + +/* + * Dependencies. + */ + +var fs = require('fs'); +var path = require('path'); +var minimatch = require('minimatch'); +var debug = require('debug')('remark:cli:ignore'); +var findUp = require('vfile-find-up'); + +/* + * Constants. + */ + +var IGNORE_NAME = '.remarkignore'; +var C_BACKSLASH = '\\'; +var C_SLASH = '/'; +var C_EXCLAMATION = '!'; +var CD = './'; +var EMPTY = ''; + +var defaults = [ + 'node_modules/' +]; + +/* + * Methods. + */ + +var read = fs.readFileSync; +var resolve = path.resolve; +var has = Object.prototype.hasOwnProperty; + +/** + * Check if `file` matches `pattern`. + * + * @example + * match('baz.md', '*.md'); // true + * + * @param {string} filePath - File location. + * @param {string} pattern - Glob pattern. + * @return {boolean} - Whether `file` matches `pattern`. + */ +function match(filePath, pattern) { + return minimatch(filePath, pattern) || + minimatch(filePath, pattern + '/**'); +} + +/** + * Check if a pattern-like line is an applicable pattern. + * + * @example + * isApplicable('node_modules'); // true + * isApplicable(' #node_modules'); // false + * + * @param {string} value - Line to check. + * @return {boolean} - Whether `value` is an applicable + * pattern. + */ +function isApplicable(value) { + var line = value && value.trim(); + + return line && line.length && line.charAt(0) !== '#'; +} + +/** + * Parse an ignore file. + * + * @example + * var ignore = load('~/.remarkignore'); + * + * @throws {Error} - Throws when `filePath` is not found. + * @param {string} filePath - File location. + * @return {Object} - List of applicable patterns. + */ +function load(filePath) { + var ignore = []; + + if (filePath) { + try { + ignore = read(filePath, 'utf8'); + + ignore = ignore.split(/\r?\n/).filter(isApplicable); + } catch (exception) { + exception.message = 'Cannot read ignore file: ' + + filePath + '\n' + 'Error: ' + exception.message; + + throw exception; + } + } + + return ignore; +} + +/** + * Find ignore-patterns. + * + * @example + * var ignore = new Ignore({ + * 'file': '.gitignore' + * }); + * + * @constructor + * @class {Ignore} + * @param {Object?} [options] - Configuration. + */ +function Ignore(options) { + var self = this; + var settings = options || {}; + var file = settings.file; + + self.cache = {}; + self.cwd = options.cwd || process.cwd(); + + self.detectIgnore = settings.detectIgnore; + + if (file) { + debug('Using command line ignore `' + file + '`'); + + self.cliIgnore = load(resolve(self.cwd, file)); + } +} + +/** + * Get patterns belonging to `filePath`. + * + * @example + * var ignore = new Ignore(); + * var patterns = ignore(); + * + * @this {Ignore} + * @param {Function} callback - Invoked with an array of + * ignored paths. + */ +function loadPatterns(callback) { + var self = this; + var directory = self.cwd; + var ignore = self.cache[directory]; + + debug('Constructing ignore for `' + directory + '`'); + + if (self.cliIgnore) { + debug('Using ignore from CLI'); + + ignore = self.cliIgnore.concat(self.defaults); + } else if (!self.detectIgnore) { + ignore = self.defaults; + } else if (has.call(self.cache, directory)) { + debug('Using ignore from cache'); + + ignore = self.cache[directory]; + } else { + findUp.one([IGNORE_NAME], directory, function (err, file) { + var result; + + if (err) { + callback(err); + return; + } + + try { + result = load(file && file.filePath()); + } catch (err) { + callback(err); + return; + } + + ignore = (result ? result : []).concat(self.defaults); + + self.patterns = self.cache[directory] = ignore; + + callback(null, ignore); + }); + + ignore = null; + } + + if (ignore) { + self.patterns = ignore; + + callback(null); + } +} + +/** + * Check whether `filePath` should be ignored based on + * the given `patterns`. + * + * @example + * ignore.shouldIgnore('readme.md'); // false + * + * @this {Ignore} ignore - Context. + * @param {string} filePath - File-path to check. + * @return {boolean} - whether `filePath` should be ignored + * based on the given `patterns`. + */ +function shouldIgnore(filePath) { + var normalized = filePath + .replace(C_BACKSLASH, C_SLASH) + .replace(CD, EMPTY); + + return this.patterns.reduce(function (isIgnored, pattern) { + var isNegated = pattern.charAt(0) === C_EXCLAMATION; + + if (isNegated) { + pattern = pattern.slice(1); + } + + if (pattern.indexOf(CD) === 0) { + pattern = pattern.slice(CD.length); + } + + return match(normalized, pattern) ? !isNegated : isIgnored; + }, false); +} + +/* + * Expose methods. + */ + +Ignore.prototype.shouldIgnore = shouldIgnore; +Ignore.prototype.loadPatterns = loadPatterns; + +/* + * Expose defaults. + */ + +Ignore.prototype.defaults = defaults; + +/* + * Expose. + */ + +module.exports = Ignore; diff --git a/tools/node_modules/remark/lib/cli/index.js b/tools/node_modules/remark/lib/cli/index.js new file mode 100644 index 00000000000000..e189c5e6ffb2a1 --- /dev/null +++ b/tools/node_modules/remark/lib/cli/index.js @@ -0,0 +1,131 @@ +/** + * @author Titus Wormer + * @copyright 2015-2016 Titus Wormer + * @license MIT + * @module remark:cli + * @version 3.2.2 + * @fileoverview CLI Engine. + */ + +'use strict'; + +/* eslint-env node */ + +/* + * Dependencies. + */ + +var chalk = require('chalk'); +var chokidar = require('chokidar'); +var CLI = require('./cli'); +var fileSetPipeline = require('./file-set-pipeline'); + +/** + * Run the file set pipeline once. + * + * @param {CLI} cli - A CLI instance. + * @param {function(Error?, boolean)} done - Callback + * invoked when done. + */ +function run(cli, done) { + cli.spinner.stop(); + + fileSetPipeline.run(cli, function (err) { + /* + * Check if any file has failed. + */ + + var hasFailed = (cli.files || []).some(function (file) { + return (file.messages || []).some(function (message) { + return message.fatal === true || + (message.fatal === false && cli.frail); + }); + }); + + done(err, !hasFailed); + + if (!err && cli.watch) { + cli.spinner.start(); + } + }); +} + +/** + * CLI engine. This is used by `bin/remark`. + * + * @example + * engine('--use toc . --output --quiet', console.log); + * + * @param {Array.<*>|Object} argv - CLI arguments. + * @param {function(Error?, boolean)} done - Callback + * invoked when done. + */ +function engine(argv, done) { + var cli = new CLI(argv); + var enabled = chalk.enabled; + var watcher; + + chalk.enabled = cli.color; + + if (cli.watch) { + cli.stdout.write( + chalk.bold('Watching...') + ' (press CTRL+C to exit)\n' + ); + } + + run(cli, function (err, success) { + chalk.enabled = enabled; + + done(err, success); + + /* + * Exit when not-watching, or when an error + * has occurred. + */ + + if (err || !cli.watch) { + return; + } + + /* + * Trigger warning when files need to be cached. + */ + + if (cli.cache.length) { + cli.stderr.write( + chalk.yellow('Warning') + ': remark does not overwrite ' + + 'watched files until exit.\nMessages and other files are ' + + 'not affected.\n' + ); + } + + /* + * Watch files source-locations of files in + * the file-set. + */ + + watcher = chokidar.watch(cli.fileSet.sourcePaths, { + 'ignoreInitial': true + }).on('all', function (type, filePath) { + if (type === 'add' || type === 'change') { + cli.globs = [filePath]; + + run(cli, done); + } + }).on('error', done); + + process.on('SIGINT', function () { + cli.cache.writeAll(); + + if (watcher) { + watcher.close(); + } + }); + }); +} + +/* + * Expose. + */ + +module.exports = engine; diff --git a/tools/node_modules/remark/lib/cli/spinner.js b/tools/node_modules/remark/lib/cli/spinner.js new file mode 100644 index 00000000000000..a86e3337974298 --- /dev/null +++ b/tools/node_modules/remark/lib/cli/spinner.js @@ -0,0 +1,90 @@ +/** + * @author Titus Wormer + * @copyright 2015-2016 Titus Wormer + * @license MIT + * @module remark:cli:spinner + * @version 3.2.2 + * @fileoverview A spinner for stdout(4). + */ + +'use strict'; + +/* eslint-env node */ + +/* + * Dependencies. + */ + +var logUpdate = require('log-update'); +var spinner = require('elegant-spinner'); + +/** + * Spinner. + * + * @example + * var spinner = new Spinner(); + * + * @constructor + * @class {FileSet} + */ +function Spinner() {} + +/** + * Start spinning. + * + * @example + * new Spinner().start(); + * + * @this {Spinner} + * @return {Spinner} - Self. + */ +function start() { + var self = this; + var spin = spinner(); + + if (!self.id) { + self.id = setInterval(function () { + logUpdate(spin()); + }, 100); + } + + return self; +} + +/** + * Stop spinning. + * + * @example + * spinner = new Spinner().start(); + * setTimeout(function () { spinner.stop(); }, 1000); + * + * @this {Spinner} + * @return {Spinner} - Self. + */ +function stop() { + var self = this; + + if (self.id) { + logUpdate(''); + logUpdate.clear(); + clearInterval(self.id); + self.id = null; + } + + return self; +} + +/* + * Attach. + */ + +var proto = Spinner.prototype; + +proto.start = start; +proto.stop = stop; + +/* + * Expose. + */ + +module.exports = Spinner; diff --git a/tools/node_modules/remark/lib/cli/watch-output-cache.js b/tools/node_modules/remark/lib/cli/watch-output-cache.js new file mode 100644 index 00000000000000..416cbb4b86c0ed --- /dev/null +++ b/tools/node_modules/remark/lib/cli/watch-output-cache.js @@ -0,0 +1,107 @@ +/** + * @author YJ Yang + * @copyright 2015-2016 Titus Wormer + * @license MIT + * @version 3.2.2 + * @module remark:cli:watch-output-cache + * @fileoverview Cache changed files which are also watched. + */ + +'use strict'; + +/* eslint-env node */ + +/* + * Dependencies. + */ + +var debug = require('debug')('remark:cli:watch-output-cache'); +var fs = require('fs'); + +/** + * Construct a new cache. + * + * @example + * var cache = new Cache(); + * + * @constructor + * @class {Cache} + */ +function Cache() { + /** + * Map of file-path’s to files, containing changed files + * which are also watched. + * + * @member {Object} + */ + this.cache = {}; + + /** + * Number of cached files. + * + * @member {number} + */ + this.length = 0; +} + +/** + * Add a VFile to the cache so that its content can later be used. + * + * @this {Cache} + * @param {VFile} file - The file to add to the cache. + */ +function add(file) { + var filePath = file.filePath(); + + this.cache[filePath] = file; + this.length++; + + debug('Add document at %s to cache', filePath); +} + +/** + * Write to all the files in the cache. + * This function is synchronous. + * + * @this {Cache} + */ +function writeAll() { + var self = this; + var cache = self.cache; + + Object.keys(cache).forEach(function (path) { + var file = cache[path]; + var destinationPath = file.filePath(); + + debug('Writing document to `%s`', destinationPath); + + file.stored = true; + + /* + * Chokidar’s watcher stops the process abruptly, + * so we need to use synchronous writes here. + */ + + fs.writeFileSync(destinationPath, file.toString()); + }); + + self.length = 0; + self.cache = {}; + + debug('Written all cached documents'); +} + +/* + * Attach. + */ + +var proto = Cache.prototype; + +proto.add = add; +proto.writeAll = writeAll; + +/* + * Expose. + */ + +module.exports = Cache; diff --git a/tools/node_modules/remark/lib/defaults.js b/tools/node_modules/remark/lib/defaults.js new file mode 100644 index 00000000000000..3974a2ad70a8af --- /dev/null +++ b/tools/node_modules/remark/lib/defaults.js @@ -0,0 +1,48 @@ +/** + * @author Titus Wormer + * @copyright 2015-2016 Titus Wormer + * @license MIT + * @module remark:defaults + * @version 3.2.2 + * @fileoverview Default values for parse and + * stringification settings. + */ + +'use strict'; + +/* eslint-env commonjs */ + +/* + * Note that `stringify.entities` is a string. + */ + +module.exports = { + 'parse': { + 'position': true, + 'gfm': true, + 'yaml': true, + 'commonmark': false, + 'footnotes': false, + 'pedantic': false, + 'breaks': false + }, + 'stringify': { + 'gfm': true, + 'commonmark': false, + 'entities': 'false', + 'setext': false, + 'closeAtx': false, + 'looseTable': false, + 'spacedTable': true, + 'incrementListMarker': true, + 'fences': false, + 'fence': '`', + 'bullet': '-', + 'listItemIndent': 'tab', + 'rule': '*', + 'ruleSpaces': true, + 'ruleRepetition': 3, + 'strong': '*', + 'emphasis': '_' + } +}; diff --git a/tools/node_modules/remark/lib/escape.json b/tools/node_modules/remark/lib/escape.json new file mode 100644 index 00000000000000..f74e70cfdaa149 --- /dev/null +++ b/tools/node_modules/remark/lib/escape.json @@ -0,0 +1,75 @@ +{ + "default": [ + "\\", + "`", + "*", + "{", + "}", + "[", + "]", + "(", + ")", + "#", + "+", + "-", + ".", + "!", + "_", + ">" + ], + "gfm": [ + "\\", + "`", + "*", + "{", + "}", + "[", + "]", + "(", + ")", + "#", + "+", + "-", + ".", + "!", + "_", + ">", + "~", + "|" + ], + "commonmark": [ + "\\", + "`", + "*", + "{", + "}", + "[", + "]", + "(", + ")", + "#", + "+", + "-", + ".", + "!", + "_", + ">", + "~", + "|", + "\n", + "\"", + "$", + "%", + "&", + "'", + ",", + "/", + ":", + ";", + "<", + "=", + "?", + "@", + "^" + ] +} diff --git a/tools/node_modules/remark/lib/parse.js b/tools/node_modules/remark/lib/parse.js new file mode 100644 index 00000000000000..263c80d8c2295a --- /dev/null +++ b/tools/node_modules/remark/lib/parse.js @@ -0,0 +1,6146 @@ +/** + * @author Titus Wormer + * @copyright 2015-2016 Titus Wormer + * @license MIT + * @module remark:parse + * @version 3.2.2 + * @fileoverview Parse a markdown document into an + * abstract syntax tree. + */ + +'use strict'; + +/* eslint-env commonjs */ + +/* + * Dependencies. + */ + +var decode = require('parse-entities'); +var repeat = require('repeat-string'); +var trim = require('trim'); +var trimTrailingLines = require('trim-trailing-lines'); +var extend = require('extend.js'); +var utilities = require('./utilities.js'); +var defaultOptions = require('./defaults.js').parse; +var blockElements = require('./block-elements.json'); + +/* + * Methods. + */ + +var raise = utilities.raise; +var clean = utilities.clean; +var validate = utilities.validate; +var normalize = utilities.normalizeIdentifier; +var stateToggler = utilities.stateToggler; +var mergeable = utilities.mergeable; +var MERGEABLE_NODES = utilities.MERGEABLE_NODES; +var has = {}.hasOwnProperty; + +/* + * Numeric constants. + */ + +var SPACE_SIZE = 1; +var TAB_SIZE = 4; +var CODE_INDENT_LENGTH = 4; +var MIN_FENCE_COUNT = 3; +var MAX_ATX_COUNT = 6; +var MAX_LINE_HEADING_INDENT = 3; +var HORIZONTAL_RULE_MARKER_COUNT = 3; +var MIN_CLOSING_HTML_NEWLINE_COUNT = 2; +var MIN_BREAK_LENGTH = 2; +var MIN_TABLE_COLUMNS = 2; +var MIN_TABLE_ROWS = 2; + +/* + * Error messages. + */ + +var ERR_INFINITE_LOOP = 'Infinite loop'; +var ERR_MISSING_LOCATOR = 'Missing locator: '; +var ERR_INCORRECTLY_EATEN = 'Incorrectly eaten value: please report this ' + + 'warning on http://git.io/vUYWz'; + +/* + * Expressions. + */ + +var EXPRESSION_BULLET = /^([ \t]*)([*+-]|\d+[.)])( {1,4}(?! )| |\t|$|(?=\n))([^\n]*)/; +var EXPRESSION_PEDANTIC_BULLET = /^([ \t]*)([*+-]|\d+[.)])([ \t]+)/; +var EXPRESSION_INITIAL_INDENT = /^( {1,4}|\t)?/gm; +var EXPRESSION_INITIAL_TAB = /^( {4}|\t)?/gm; +var EXPRESSION_HTML_LINK_OPEN = /^
    /i; +var EXPRESSION_LOOSE_LIST_ITEM = /\n\n(?!\s*$)/; +var EXPRESSION_TASK_ITEM = /^\[([\ \t]|x|X)\][\ \t]/; + +/* + * Characters. + */ + +var C_BACKSLASH = '\\'; +var C_UNDERSCORE = '_'; +var C_ASTERISK = '*'; +var C_TICK = '`'; +var C_AT_SIGN = '@'; +var C_HASH = '#'; +var C_PLUS = '+'; +var C_DASH = '-'; +var C_DOT = '.'; +var C_PIPE = '|'; +var C_DOUBLE_QUOTE = '"'; +var C_SINGLE_QUOTE = '\''; +var C_COMMA = ','; +var C_SLASH = '/'; +var C_COLON = ':'; +var C_SEMI_COLON = ';'; +var C_QUESTION_MARK = '?'; +var C_CARET = '^'; +var C_EQUALS = '='; +var C_EXCLAMATION_MARK = '!'; +var C_TILDE = '~'; +var C_LT = '<'; +var C_GT = '>'; +var C_BRACKET_OPEN = '['; +var C_BRACKET_CLOSE = ']'; +var C_PAREN_OPEN = '('; +var C_PAREN_CLOSE = ')'; +var C_SPACE = ' '; +var C_FORM_FEED = '\f'; +var C_NEWLINE = '\n'; +var C_CARRIAGE_RETURN = '\r'; +var C_TAB = '\t'; +var C_VERTICAL_TAB = '\v'; +var C_NO_BREAK_SPACE = '\u00a0'; +var C_OGHAM_SPACE = '\u1680'; +var C_MONGOLIAN_VOWEL_SEPARATOR = '\u180e'; +var C_EN_QUAD = '\u2000'; +var C_EM_QUAD = '\u2001'; +var C_EN_SPACE = '\u2002'; +var C_EM_SPACE = '\u2003'; +var C_THREE_PER_EM_SPACE = '\u2004'; +var C_FOUR_PER_EM_SPACE = '\u2005'; +var C_SIX_PER_EM_SPACE = '\u2006'; +var C_FIGURE_SPACE = '\u2007'; +var C_PUNCTUATION_SPACE = '\u2008'; +var C_THIN_SPACE = '\u2009'; +var C_HAIR_SPACE = '\u200a'; +var C_LINE_SEPARATOR = '​\u2028'; +var C_PARAGRAPH_SEPARATOR = '​\u2029'; +var C_NARROW_NO_BREAK_SPACE = '\u202f'; +var C_IDEOGRAPHIC_SPACE = '\u3000'; +var C_ZERO_WIDTH_NO_BREAK_SPACE = '\ufeff'; +var C_X_LOWER = 'x'; + +/* + * Character codes. + */ + +var CC_A_LOWER = 'a'.charCodeAt(0); +var CC_A_UPPER = 'A'.charCodeAt(0); +var CC_Z_LOWER = 'z'.charCodeAt(0); +var CC_Z_UPPER = 'Z'.charCodeAt(0); +var CC_0 = '0'.charCodeAt(0); +var CC_9 = '9'.charCodeAt(0); + +/* + * Protocols. + */ + +var HTTP_PROTOCOL = 'http://'; +var HTTPS_PROTOCOL = 'https://'; +var MAILTO_PROTOCOL = 'mailto:'; + +var PROTOCOLS = [ + HTTP_PROTOCOL, + HTTPS_PROTOCOL, + MAILTO_PROTOCOL +]; + +var PROTOCOLS_LENGTH = PROTOCOLS.length; + +/* + * Textual constants. + */ + +var YAML_FENCE = repeat(C_DASH, 3); +var CODE_INDENT = repeat(C_SPACE, CODE_INDENT_LENGTH); +var EMPTY = ''; +var BLOCK = 'block'; +var INLINE = 'inline'; +var COMMENT_START = ''; +var CDATA_START = ''; +var COMMENT_END_CHAR = COMMENT_END.charAt(0); +var CDATA_END_CHAR = CDATA_END.charAt(0); +var COMMENT_START_LENGTH = COMMENT_START.length; +var COMMENT_END_LENGTH = COMMENT_END.length; +var CDATA_START_LENGTH = CDATA_START.length; +var CDATA_END_LENGTH = CDATA_END.length; + +/* + * Node types. + */ + +var T_HORIZONTAL_RULE = 'horizontalRule'; +var T_HTML = 'html'; +var T_YAML = 'yaml'; +var T_TABLE = 'table'; +var T_TABLE_CELL = 'tableCell'; +var T_TABLE_HEADER = 'tableHeader'; +var T_TABLE_ROW = 'tableRow'; +var T_PARAGRAPH = 'paragraph'; +var T_TEXT = 'text'; +var T_CODE = 'code'; +var T_LIST = 'list'; +var T_LIST_ITEM = 'listItem'; +var T_DEFINITION = 'definition'; +var T_FOOTNOTE_DEFINITION = 'footnoteDefinition'; +var T_HEADING = 'heading'; +var T_BLOCKQUOTE = 'blockquote'; +var T_LINK = 'link'; +var T_IMAGE = 'image'; +var T_FOOTNOTE = 'footnote'; +var T_STRONG = 'strong'; +var T_EMPHASIS = 'emphasis'; +var T_DELETE = 'delete'; +var T_INLINE_CODE = 'inlineCode'; +var T_BREAK = 'break'; +var T_ROOT = 'root'; + +/* + * Available table alignments. + */ + +var TABLE_ALIGN_LEFT = 'left'; +var TABLE_ALIGN_CENTER = 'center'; +var TABLE_ALIGN_RIGHT = 'right'; +var TABLE_ALIGN_NONE = null; + +/* + * Available reference types. + */ + +var REFERENCE_TYPE_SHORTCUT = 'shortcut'; +var REFERENCE_TYPE_COLLAPSED = 'collapsed'; +var REFERENCE_TYPE_FULL = 'full'; + +/* + * A map of characters, and their column length, + * which can be used as indentation. + */ + +var INDENTATION_CHARACTERS = {}; + +INDENTATION_CHARACTERS[C_SPACE] = SPACE_SIZE; +INDENTATION_CHARACTERS[C_TAB] = TAB_SIZE; + +/* + * A map of characters, which can be used to mark emphasis. + */ + +var EMPHASIS_MARKERS = {}; + +EMPHASIS_MARKERS[C_ASTERISK] = true; +EMPHASIS_MARKERS[C_UNDERSCORE] = true; + +/* + * A map of characters, which can be used to mark rules. + */ + +var RULE_MARKERS = {}; + +RULE_MARKERS[C_ASTERISK] = true; +RULE_MARKERS[C_UNDERSCORE] = true; +RULE_MARKERS[C_DASH] = true; + +/* + * A map of characters which can be used to mark + * list-items. + */ + +var LIST_UNORDERED_MARKERS = {}; + +LIST_UNORDERED_MARKERS[C_ASTERISK] = true; +LIST_UNORDERED_MARKERS[C_PLUS] = true; +LIST_UNORDERED_MARKERS[C_DASH] = true; + +/* + * A map of characters which can be used to mark + * list-items after a digit. + */ + +var LIST_ORDERED_MARKERS = {}; + +LIST_ORDERED_MARKERS[C_DOT] = true; + +/* + * A map of characters which can be used to mark + * list-items after a digit. + */ + +var LIST_ORDERED_COMMONMARK_MARKERS = {}; + +LIST_ORDERED_COMMONMARK_MARKERS[C_DOT] = true; +LIST_ORDERED_COMMONMARK_MARKERS[C_PAREN_CLOSE] = true; + +/* + * A map of characters, which can be used to mark link + * and image titles. + */ + +var LINK_TITLE_MARKERS = {}; + +LINK_TITLE_MARKERS[C_DOUBLE_QUOTE] = C_DOUBLE_QUOTE; +LINK_TITLE_MARKERS[C_SINGLE_QUOTE] = C_SINGLE_QUOTE; + +/* + * A map of characters, which can be used to mark link + * and image titles in commonmark-mode. + */ + +var COMMONMARK_LINK_TITLE_MARKERS = {}; + +COMMONMARK_LINK_TITLE_MARKERS[C_DOUBLE_QUOTE] = C_DOUBLE_QUOTE; +COMMONMARK_LINK_TITLE_MARKERS[C_SINGLE_QUOTE] = C_SINGLE_QUOTE; +COMMONMARK_LINK_TITLE_MARKERS[C_PAREN_OPEN] = C_PAREN_CLOSE; + +/* + * A map of characters which can be used to mark setext + * headers, mapping to their corresponding depth. + */ + +var SETEXT_MARKERS = {}; + +SETEXT_MARKERS[C_EQUALS] = 1; +SETEXT_MARKERS[C_DASH] = 2; + +/* + * A map of two functions which can create list items. + */ + +var LIST_ITEM_MAP = {}; + +LIST_ITEM_MAP.true = renderPedanticListItem; +LIST_ITEM_MAP.false = renderNormalListItem; + +/** + * Check whether `character` is alphabetic. + * + * @param {string} character - Single character to check. + * @return {boolean} - Whether or not `character` is + * alphabetic. + */ +function isAlphabetic(character) { + var code = character.charCodeAt(0); + + return (code >= CC_A_LOWER && code <= CC_Z_LOWER) || + (code >= CC_A_UPPER && code <= CC_Z_UPPER); +} + +/** + * Check whether `character` is numeric. + * + * @param {string} character - Single character to check. + * @return {boolean} - Whether or not `character` is + * numeric. + */ +function isNumeric(character) { + var code = character.charCodeAt(0); + + return code >= CC_0 && code <= CC_9; +} + +/** + * Check whether `character` is a word character. + * + * @param {string} character - Single character to check. + * @return {boolean} - Whether or not `character` is a + * word character. + */ +function isWordCharacter(character) { + return character === C_UNDERSCORE || + isAlphabetic(character) || + isNumeric(character); +} + +/** + * Check whether `character` is white-space. + * + * @param {string} character - Single character to check. + * @return {boolean} - Whether or not `character` is + * white-space. + */ +function isWhiteSpace(character) { + return character === C_SPACE || + character === C_FORM_FEED || + character === C_NEWLINE || + character === C_CARRIAGE_RETURN || + character === C_TAB || + character === C_VERTICAL_TAB || + character === C_NO_BREAK_SPACE || + character === C_OGHAM_SPACE || + character === C_MONGOLIAN_VOWEL_SEPARATOR || + character === C_EN_QUAD || + character === C_EM_QUAD || + character === C_EN_SPACE || + character === C_EM_SPACE || + character === C_THREE_PER_EM_SPACE || + character === C_FOUR_PER_EM_SPACE || + character === C_SIX_PER_EM_SPACE || + character === C_FIGURE_SPACE || + character === C_PUNCTUATION_SPACE || + character === C_THIN_SPACE || + character === C_HAIR_SPACE || + character === C_LINE_SEPARATOR || + character === C_PARAGRAPH_SEPARATOR || + character === C_NARROW_NO_BREAK_SPACE || + character === C_IDEOGRAPHIC_SPACE || + character === C_ZERO_WIDTH_NO_BREAK_SPACE; +} + +/** + * Check whether `character` can be inside an unquoted + * attribute value. + * + * @param {string} character - Single character to check. + * @return {boolean} - Whether or not `character` can be + * inside an unquoted attribute value. + */ +function isUnquotedAttributeCharacter(character) { + return character !== C_DOUBLE_QUOTE && + character !== C_SINGLE_QUOTE && + character !== C_EQUALS && + character !== C_LT && + character !== C_GT && + character !== C_TICK; +} + +/** + * Check whether `character` can be inside a double-quoted + * attribute value. + * + * @property {string} delimiter - Closing delimiter. + * @param {string} character - Single character to check. + * @return {boolean} - Whether or not `character` can be + * inside a double-quoted attribute value. + */ +function isDoubleQuotedAttributeCharacter(character) { + return character !== C_DOUBLE_QUOTE; +} + +isDoubleQuotedAttributeCharacter.delimiter = C_DOUBLE_QUOTE; + +/** + * Check whether `character` can be inside a single-quoted + * attribute value. + * + * @property {string} delimiter - Closing delimiter. + * @param {string} character - Single character to check. + * @return {boolean} - Whether or not `character` can be + * inside a single-quoted attribute value. + */ +function isSingleQuotedAttributeCharacter(character) { + return character !== C_SINGLE_QUOTE; +} + +isSingleQuotedAttributeCharacter.delimiter = C_SINGLE_QUOTE; + +/** + * Check whether `character` can be inside an enclosed + * URI. + * + * @property {string} delimiter - Closing delimiter. + * @param {string} character - Character to test. + * @return {boolean} - Whether or not `character` can be + * inside an enclosed URI. + */ +function isEnclosedURLCharacter(character) { + return character !== C_GT && + character !== C_BRACKET_OPEN && + character !== C_BRACKET_CLOSE; +} + +isEnclosedURLCharacter.delimiter = C_GT; + +/** + * Check whether `character` can be inside an unclosed + * URI. + * + * @param {string} character - Character to test. + * @return {boolean} - Whether or not `character` can be + * inside an unclosed URI. + */ +function isUnclosedURLCharacter(character) { + return character !== C_BRACKET_OPEN && + character !== C_BRACKET_CLOSE && + !isWhiteSpace(character); +} + +/** + * Factory to create an entity decoder. + * + * @param {Object} context - Context to attach to, e.g., + * a parser. + * @return {Function} - See `decode`. + */ +function decodeFactory(context) { + /** + * Normalize `position` to add an `indent`. + * + * @param {Position} position - Reference + * @return {Position} - Augmented with `indent`. + */ + function normalize(position) { + return { + 'start': position, + 'indent': context.getIndent(position.line) + }; + } + + /** + * Handle a warning. + * + * @this {VFile} - Virtual file. + * @param {string} reason - Reason for warning. + * @param {Position} position - Place of warning. + * @param {number} code - Code for warning. + */ + function handleWarning(reason, position, code) { + if (code === 3) { + return; + } + + context.file.warn(reason, position); + } + + /** + * Decode `value` (at `position`) into text-nodes. + * + * @param {string} value - Value to parse. + * @param {Position} position - Position to start parsing at. + * @param {Function} handler - Node handler. + */ + function decoder(value, position, handler) { + var hasPosition = context.options.position; + + decode(value, { + 'position': position && normalize(position), + 'warning': hasPosition && handleWarning, + 'text': handler, + 'reference': handler, + 'textContext': context, + 'referenceContext': context + }); + } + + /** + * Decode `value` (at `position`) into a string. + * + * @param {string} value - Value to parse. + * @param {Position} position - Position to start + * parsing at. + * @return {string} - Plain-text. + */ + function decodeRaw(value, position) { + return decode(value, { + 'position': position && normalize(position), + 'warning': context.options.position && handleWarning + }); + } + + decoder.raw = decodeRaw; + + return decoder; +} + +/** + * Factory to de-escape a value, based on a list at `key` + * in `scope`. + * + * @example + * var scope = {escape: ['a']} + * var descape = descapeFactory(scope, 'escape'); + * + * @param {Object} scope - List of escapable characters. + * @param {string} key - Key in `map` at which the list + * exists. + * @return {function(string): string} - Function which + * takes a value and returns its unescaped version. + */ +function descapeFactory(scope, key) { + /** + * De-escape a string using the expression at `key` + * in `scope`. + * + * @example + * var scope = {escape: ['a']} + * var descape = descapeFactory(scope, 'escape'); + * descape('\a \b'); // 'a \b' + * + * @param {string} value - Escaped string. + * @return {string} - Unescaped string. + */ + function descape(value) { + var prev = 0; + var index = value.indexOf(C_BACKSLASH); + var escape = scope[key]; + var queue = []; + var character; + + while (index !== -1) { + queue.push(value.slice(prev, index)); + prev = index + 1; + character = value.charAt(prev); + + /* + * If the following character is not a valid escape, + * add the slash. + */ + + if (!character || escape.indexOf(character) === -1) { + queue.push(C_BACKSLASH); + } + + index = value.indexOf(C_BACKSLASH, prev); + } + + queue.push(value.slice(prev)); + + return queue.join(EMPTY); + } + + return descape; +} + +/** + * Gets indentation information for a line. + * + * @example + * getIndent(' foo'); + * // {indent: 2, stops: {1: 0, 2: 1}} + * + * getIndent('\tfoo'); + * // {indent: 4, stops: {4: 0}} + * + * getIndent(' \tfoo'); + * // {indent: 4, stops: {1: 0, 2: 1, 4: 2}} + * + * getIndent('\t foo') + * // {indent: 6, stops: {4: 0, 5: 1, 6: 2}} + * + * @param {string} value - Indented line. + * @return {Object} - Indetation information. + */ +function getIndent(value) { + var index = 0; + var indent = 0; + var character = value.charAt(index); + var stops = {}; + var size; + + while (character in INDENTATION_CHARACTERS) { + size = INDENTATION_CHARACTERS[character]; + + indent += size; + + if (size > 1) { + indent = Math.floor(indent / size) * size; + } + + stops[indent] = index; + + character = value.charAt(++index); + } + + return { + 'indent': indent, + 'stops': stops + }; +} + +/** + * Remove the minimum indent from every line in `value`. + * Supports both tab, spaced, and mixed indentation (as + * well as possible). + * + * @example + * removeIndentation(' foo'); // 'foo' + * removeIndentation(' foo', 2); // ' foo' + * removeIndentation('\tfoo', 2); // ' foo' + * removeIndentation(' foo\n bar'); // ' foo\n bar' + * + * @param {string} value - Value to trim. + * @param {number?} [maximum] - Maximum indentation + * to remove. + * @return {string} - Unindented `value`. + */ +function removeIndentation(value, maximum) { + var values = value.split(C_NEWLINE); + var position = values.length + 1; + var minIndent = Infinity; + var matrix = []; + var index; + var indentation; + var stops; + var padding; + + values.unshift(repeat(C_SPACE, maximum) + C_EXCLAMATION_MARK); + + while (position--) { + indentation = getIndent(values[position]); + + matrix[position] = indentation.stops; + + if (trim(values[position]).length === 0) { + continue; + } + + if (indentation.indent) { + if (indentation.indent > 0 && indentation.indent < minIndent) { + minIndent = indentation.indent; + } + } else { + minIndent = Infinity; + + break; + } + } + + if (minIndent !== Infinity) { + position = values.length; + + while (position--) { + stops = matrix[position]; + index = minIndent; + + while (index && !(index in stops)) { + index--; + } + + if ( + trim(values[position]).length !== 0 && + minIndent && + index !== minIndent + ) { + padding = C_TAB; + } else { + padding = EMPTY; + } + + values[position] = padding + values[position].slice( + index in stops ? stops[index] + 1 : 0 + ); + } + } + + values.shift(); + + return values.join(C_NEWLINE); +} + +/** + * Tokenise a line. + * + * @example + * tokenizeNewline(eat, '\n\n'); + * + * @param {function(string)} eat - Eater. + * @param {string} value - Rest of content. + * @param {boolean?} [silent] - Whether this is a dry run. + * @return {boolean?} - `true` when matching. + */ +function tokenizeNewline(eat, value, silent) { + var character = value.charAt(0); + var length; + var subvalue; + var queue; + var index; + + if (character !== C_NEWLINE) { + return; + } + + /* istanbul ignore if - never used (yet) */ + if (silent) { + return true; + } + + index = 1; + length = value.length; + subvalue = C_NEWLINE; + queue = EMPTY; + + while (index < length) { + character = value.charAt(index); + + if (!isWhiteSpace(character)) { + break; + } + + queue += character; + + if (character === C_NEWLINE) { + subvalue += queue; + queue = EMPTY; + } + + index++; + } + + eat(subvalue); +} + +/** + * Tokenise an indented code block. + * + * @example + * tokenizeCode(eat, '\tfoo'); + * + * @param {function(string)} eat - Eater. + * @param {string} value - Rest of content. + * @param {boolean?} [silent] - Whether this is a dry run. + * @return {Node?|boolean} - `code` node. + */ +function tokenizeCode(eat, value, silent) { + var self = this; + var index = -1; + var length = value.length; + var character; + var subvalue = EMPTY; + var content = EMPTY; + var subvalueQueue = EMPTY; + var contentQueue = EMPTY; + var blankQueue; + var indent; + + while (++index < length) { + character = value.charAt(index); + + if (indent) { + indent = false; + + subvalue += subvalueQueue; + content += contentQueue; + subvalueQueue = contentQueue = EMPTY; + + if (character === C_NEWLINE) { + subvalueQueue = contentQueue = character; + } else { + subvalue += character; + content += character; + + while (++index < length) { + character = value.charAt(index); + + if (!character || character === C_NEWLINE) { + contentQueue = subvalueQueue = character; + break; + } + + subvalue += character; + content += character; + } + } + } else if ( + character === C_SPACE && + value.charAt(index + 1) === C_SPACE && + value.charAt(index + 2) === C_SPACE && + value.charAt(index + 3) === C_SPACE + ) { + subvalueQueue += CODE_INDENT; + index += 3; + indent = true; + } else if (character === C_TAB) { + subvalueQueue += character; + indent = true; + } else { + blankQueue = EMPTY; + + while (character === C_TAB || character === C_SPACE) { + blankQueue += character; + character = value.charAt(++index); + } + + if (character !== C_NEWLINE) { + break; + } + + subvalueQueue += blankQueue + character; + contentQueue += character; + } + } + + if (content) { + if (silent) { + return true; + } + + return eat(subvalue)(self.renderCodeBlock(content)); + } +} + +/** + * Tokenise a fenced code block. + * + * @example + * tokenizeFences(eat, '```js\nfoo()\n```'); + * + * @param {function(string)} eat - Eater. + * @param {string} value - Rest of content. + * @param {boolean?} [silent] - Whether this is a dry run. + * @return {Node?|boolean} - `code` node. + */ +function tokenizeFences(eat, value, silent) { + var self = this; + var settings = self.options; + var length = value.length + 1; + var index = 0; + var subvalue = EMPTY; + var fenceCount; + var marker; + var character; + var flag; + var queue; + var content; + var exdentedContent; + var closing; + var exdentedClosing; + var indent; + var now; + + if (!settings.gfm) { + return; + } + + /* + * Eat initial spacing. + */ + + while (index < length) { + character = value.charAt(index); + + if (character !== C_SPACE && character !== C_TAB) { + break; + } + + subvalue += character; + index++; + } + + indent = index; // TODO: CHECK. + + /* + * Eat the fence. + */ + + character = value.charAt(index); + + if (character !== C_TILDE && character !== C_TICK) { + return; + } + + index++; + marker = character; + fenceCount = 1; + subvalue += character; + + while (index < length) { + character = value.charAt(index); + + if (character !== marker) { + break; + } + + subvalue += character; + fenceCount++; + index++; + } + + if (fenceCount < MIN_FENCE_COUNT) { + return; + } + + /* + * Eat spacing before flag. + */ + + while (index < length) { + character = value.charAt(index); + + if (character !== C_SPACE && character !== C_TAB) { + break; + } + + subvalue += character; + index++; + } + + /* + * Eat flag. + */ + + flag = queue = EMPTY; + + while (index < length) { + character = value.charAt(index); + + if ( + character === C_NEWLINE || + character === C_TILDE || + character === C_TICK + ) { + break; + } + + if (character === C_SPACE || character === C_TAB) { + queue += character; + } else { + flag += queue + character; + queue = EMPTY; + } + + index++; + } + + character = value.charAt(index); + + if (character && character !== C_NEWLINE) { + return; + } + + if (silent) { + return true; + } + + now = eat.now(); + now.column += subvalue.length; + + subvalue += flag; + flag = self.decode.raw(self.descape(flag), now); + + if (queue) { + subvalue += queue; + } + + queue = closing = exdentedClosing = content = exdentedContent = EMPTY; + + /* + * Eat content. + */ + + while (index < length) { + character = value.charAt(index); + content += closing; + exdentedContent += exdentedClosing; + closing = exdentedClosing = EMPTY; + + if (character !== C_NEWLINE) { + content += character; + exdentedClosing += character; + index++; + continue; + } + + /* + * Add the newline to `subvalue` if its the first + * character. Otherwise, add it to the `closing` + * queue. + */ + + if (!content) { + subvalue += character; + } else { + closing += character; + exdentedClosing += character; + } + + queue = EMPTY; + index++; + + while (index < length) { + character = value.charAt(index); + + if (character !== C_SPACE) { + break; + } + + queue += character; + index++; + } + + closing += queue; + exdentedClosing += queue.slice(indent); + + if (queue.length >= CODE_INDENT_LENGTH) { + continue; + } + + queue = EMPTY; + + while (index < length) { + character = value.charAt(index); + + if (character !== marker) { + break; + } + + queue += character; + index++; + } + + closing += queue; + exdentedClosing += queue; + + if (queue.length < fenceCount) { + continue; + } + + queue = EMPTY; + + while (index < length) { + character = value.charAt(index); + + if (character !== C_SPACE && character !== C_TAB) { + break; + } + + closing += character; + exdentedClosing += character; + index++; + } + + if (!character || character === C_NEWLINE) { + break; + } + } + + subvalue += content + closing; + + return eat(subvalue)(self.renderCodeBlock(exdentedContent, flag)); +} + +/** + * Tokenise an ATX-style heading. + * + * @example + * tokenizeHeading(eat, ' # foo'); + * + * @param {function(string)} eat - Eater. + * @param {string} value - Rest of content. + * @param {boolean?} [silent] - Whether this is a dry run. + * @return {Node?|boolean} - `heading` node. + */ +function tokenizeHeading(eat, value, silent) { + var self = this; + var settings = self.options; + var length = value.length + 1; + var index = -1; + var now = eat.now(); + var subvalue = EMPTY; + var content = EMPTY; + var character; + var queue; + var depth; + + /* + * Eat initial spacing. + */ + + while (++index < length) { + character = value.charAt(index); + + if (character !== C_SPACE && character !== C_TAB) { + index--; + break; + } + + subvalue += character; + } + + /* + * Eat hashes. + */ + + depth = 0; + length = index + MAX_ATX_COUNT + 1; + + while (++index <= length) { + character = value.charAt(index); + + if (character !== C_HASH) { + index--; + break; + } + + subvalue += character; + depth++; + } + + if ( + !depth || + (!settings.pedantic && value.charAt(index + 1) === C_HASH) + ) { + return; + } + + length = value.length + 1; + + /* + * Eat intermediate white-space. + */ + + queue = EMPTY; + + while (++index < length) { + character = value.charAt(index); + + if (character !== C_SPACE && character !== C_TAB) { + index--; + break; + } + + queue += character; + } + + /* + * Exit when not in pedantic mode without spacing. + */ + + if ( + !settings.pedantic && + !queue.length && + character && + character !== C_NEWLINE + ) { + return; + } + + if (silent) { + return true; + } + + /* + * Eat content. + */ + + subvalue += queue; + queue = content = EMPTY; + + while (++index < length) { + character = value.charAt(index); + + if (!character || character === C_NEWLINE) { + break; + } + + if ( + character !== C_SPACE && + character !== C_TAB && + character !== C_HASH + ) { + content += queue + character; + queue = EMPTY; + continue; + } + + while (character === C_SPACE || character === C_TAB) { + queue += character; + character = value.charAt(++index); + } + + while (character === C_HASH) { + queue += character; + character = value.charAt(++index); + } + + while (character === C_SPACE || character === C_TAB) { + queue += character; + character = value.charAt(++index); + } + + index--; + } + + now.column += subvalue.length; + subvalue += content + queue; + + return eat(subvalue)(self.renderHeading(content, depth, now)); +} + +/** + * Tokenise a Setext-style heading. + * + * @example + * tokenizeLineHeading(eat, 'foo\n==='); + * + * @param {function(string)} eat - Eater. + * @param {string} value - Rest of content. + * @param {boolean?} [silent] - Whether this is a dry run. + * @return {Node?|boolean} - `heading` node. + */ +function tokenizeLineHeading(eat, value, silent) { + var self = this; + var now = eat.now(); + var length = value.length; + var index = -1; + var subvalue = EMPTY; + var content; + var queue; + var character; + var marker; + var depth; + + /* + * Eat initial indentation. + */ + + while (++index < length) { + character = value.charAt(index); + + if (character !== C_SPACE || index >= MAX_LINE_HEADING_INDENT) { + index--; + break; + } + + subvalue += character; + } + + /* + * Eat content. + */ + + content = queue = EMPTY; + + while (++index < length) { + character = value.charAt(index); + + if (character === C_NEWLINE) { + index--; + break; + } + + if (character === C_SPACE || character === C_TAB) { + queue += character; + } else { + content += queue + character; + queue = EMPTY; + } + } + + now.column += subvalue.length; + subvalue += content + queue; + + /* + * Ensure the content is followed by a newline and a + * valid marker. + */ + + character = value.charAt(++index); + marker = value.charAt(++index); + + if ( + character !== C_NEWLINE || + !SETEXT_MARKERS[marker] + ) { + return; + } + + if (silent) { + return true; + } + + subvalue += character; + + /* + * Eat Setext-line. + */ + + queue = marker; + depth = SETEXT_MARKERS[marker]; + + while (++index < length) { + character = value.charAt(index); + + if (character !== marker) { + if (character !== C_NEWLINE) { + return; + } + + index--; + break; + } + + queue += character; + } + + return eat(subvalue + queue)(self.renderHeading(content, depth, now)); +} + +/** + * Tokenise a horizontal rule. + * + * @example + * tokenizeHorizontalRule(eat, '***'); + * + * @param {function(string)} eat - Eater. + * @param {string} value - Rest of content. + * @param {boolean?} [silent] - Whether this is a dry run. + * @return {Node?|boolean} - `horizontalRule` node. + */ +function tokenizeHorizontalRule(eat, value, silent) { + var self = this; + var index = -1; + var length = value.length + 1; + var subvalue = EMPTY; + var character; + var marker; + var markerCount; + var queue; + + while (++index < length) { + character = value.charAt(index); + + if (character !== C_TAB && character !== C_SPACE) { + break; + } + + subvalue += character; + } + + if (RULE_MARKERS[character] !== true) { + return; + } + + marker = character; + subvalue += character; + markerCount = 1; + queue = EMPTY; + + while (++index < length) { + character = value.charAt(index); + + if (character === marker) { + markerCount++; + subvalue += queue + marker; + queue = EMPTY; + } else if (character === C_SPACE) { + queue += character; + } else if ( + markerCount >= HORIZONTAL_RULE_MARKER_COUNT && + (!character || character === C_NEWLINE) + ) { + subvalue += queue; + + if (silent) { + return true; + } + + return eat(subvalue)(self.renderVoid(T_HORIZONTAL_RULE)); + } else { + return; + } + } +} + +/** + * Tokenise a blockquote. + * + * @example + * tokenizeBlockquote(eat, '> Foo'); + * + * @param {function(string)} eat - Eater. + * @param {string} value - Rest of content. + * @param {boolean?} [silent] - Whether this is a dry run. + * @return {Node?|boolean} - `blockquote` node. + */ +function tokenizeBlockquote(eat, value, silent) { + var self = this; + var commonmark = self.options.commonmark; + var now = eat.now(); + var indent = self.indent(now.line); + var length = value.length; + var values = []; + var contents = []; + var indents = []; + var add; + var tokenizers; + var index = 0; + var character; + var rest; + var nextIndex; + var content; + var line; + var startIndex; + var prefixed; + + while (index < length) { + character = value.charAt(index); + + if (character !== C_SPACE && character !== C_TAB) { + break; + } + + index++; + } + + if (value.charAt(index) !== C_GT) { + return; + } + + if (silent) { + return true; + } + + tokenizers = self.blockTokenizers; + index = 0; + + while (index < length) { + nextIndex = value.indexOf(C_NEWLINE, index); + startIndex = index; + prefixed = false; + + if (nextIndex === -1) { + nextIndex = length; + } + + while (index < length) { + character = value.charAt(index); + + if (character !== C_SPACE && character !== C_TAB) { + break; + } + + index++; + } + + if (value.charAt(index) === C_GT) { + index++; + prefixed = true; + + if (value.charAt(index) === C_SPACE) { + index++; + } + } else { + index = startIndex; + } + + content = value.slice(index, nextIndex); + + if (!prefixed && !trim(content)) { + index = startIndex; + break; + } + + if (!prefixed) { + rest = value.slice(index); + + if ( + commonmark && + ( + tokenizers.code.call(self, eat, rest, true) || + tokenizers.fences.call(self, eat, rest, true) || + tokenizers.heading.call(self, eat, rest, true) || + tokenizers.lineHeading.call(self, eat, rest, true) || + tokenizers.horizontalRule.call(self, eat, rest, true) || + tokenizers.html.call(self, eat, rest, true) || + tokenizers.list.call(self, eat, rest, true) + ) + ) { + break; + } + + if ( + !commonmark && + ( + tokenizers.definition.call(self, eat, rest, true) || + tokenizers.footnoteDefinition.call(self, eat, rest, true) + ) + ) { + break; + } + } + + line = startIndex === index ? + content : + value.slice(startIndex, nextIndex); + + indents.push(index - startIndex); + values.push(line); + contents.push(content); + + index = nextIndex + 1; + } + + index = -1; + length = indents.length; + add = eat(values.join(C_NEWLINE)); + + while (++index < length) { + indent(indents[index]); + } + + return add(self.renderBlockquote(contents.join(C_NEWLINE), now)); +} + +/** + * Tokenise a list. + * + * @example + * tokenizeList(eat, '- Foo'); + * + * @param {function(string)} eat - Eater. + * @param {string} value - Rest of content. + * @param {boolean?} [silent] - Whether this is a dry run. + * @return {Node?|boolean} - `list` node. + */ +function tokenizeList(eat, value, silent) { + var self = this; + var commonmark = self.options.commonmark; + var pedantic = self.options.pedantic; + var tokenizers = self.blockTokenizers; + var markers; + var index = 0; + var length = value.length; + var start = null; + var queue; + var ordered; + var character; + var marker; + var nextIndex; + var startIndex; + var prefixed; + var currentMarker; + var content; + var line; + var prevEmpty; + var empty; + var items; + var allLines; + var emptyLines; + var item; + var enterTop; + var exitBlockquote; + var isLoose; + var node; + var now; + var end; + var indented; + var size; + + while (index < length) { + character = value.charAt(index); + + if (character !== C_SPACE && character !== C_TAB) { + break; + } + + index++; + } + + character = value.charAt(index); + + markers = commonmark ? + LIST_ORDERED_COMMONMARK_MARKERS : + LIST_ORDERED_MARKERS; + + if (LIST_UNORDERED_MARKERS[character] === true) { + marker = character; + ordered = false; + } else { + ordered = true; + queue = EMPTY; + + while (index < length) { + character = value.charAt(index); + + if (!isNumeric(character)) { + break; + } + + queue += character; + index++; + } + + character = value.charAt(index); + + if (!queue || markers[character] !== true) { + return; + } + + start = parseInt(queue, 10); + marker = character; + } + + character = value.charAt(++index); + + if (character !== C_SPACE && character !== C_TAB) { + return; + } + + if (silent) { + return true; + } + + index = 0; + items = []; + allLines = []; + emptyLines = []; + + while (index < length) { + nextIndex = value.indexOf(C_NEWLINE, index); + startIndex = index; + prefixed = false; + indented = false; + + if (nextIndex === -1) { + nextIndex = length; + } + + end = index + TAB_SIZE; + size = 0; + + while (index < length) { + character = value.charAt(index); + + if (character === C_TAB) { + size += TAB_SIZE - size % TAB_SIZE; + } else if (character === C_SPACE) { + size++; + } else { + break; + } + + index++; + } + + if (size >= TAB_SIZE) { + indented = true; + } + + if (item && size >= item.indent) { + indented = true; + } + + character = value.charAt(index); + currentMarker = null; + + if (!indented) { + if (LIST_UNORDERED_MARKERS[character] === true) { + currentMarker = character; + index++; + size++; + } else { + queue = EMPTY; + + while (index < length) { + character = value.charAt(index); + + if (!isNumeric(character)) { + break; + } + + queue += character; + index++; + } + + character = value.charAt(index); + index++; + + if (queue && markers[character] === true) { + currentMarker = character; + size += queue.length + 1; + } + } + + if (currentMarker) { + character = value.charAt(index); + + if (character === C_TAB) { + size += TAB_SIZE - size % TAB_SIZE; + index++; + } else if (character === C_SPACE) { + end = index + TAB_SIZE; + + while (index < end) { + if (value.charAt(index) !== C_SPACE) { + break; + } + + index++; + size++; + } + + if (index === end && value.charAt(index) === C_SPACE) { + index -= TAB_SIZE - 1; + size -= TAB_SIZE - 1; + } + } else if ( + character !== C_NEWLINE && + character !== EMPTY + ) { + currentMarker = null; + } + } + } + + if (currentMarker) { + if (commonmark && marker !== currentMarker) { + break; + } + + prefixed = true; + } else { + if ( + !commonmark && + !indented && + value.charAt(startIndex) === C_SPACE + ) { + indented = true; + } else if ( + commonmark && + item + ) { + indented = size >= item.indent || size > TAB_SIZE; + } + + prefixed = false; + index = startIndex; + } + + line = value.slice(startIndex, nextIndex); + content = startIndex === index ? line : value.slice(index, nextIndex); + + if (currentMarker && RULE_MARKERS[currentMarker] === true) { + if ( + tokenizers.horizontalRule.call(self, eat, line, true) + ) { + break; + } + } + + prevEmpty = empty; + empty = !trim(content).length; + + if (indented && item) { + item.value = item.value.concat(emptyLines, line); + allLines = allLines.concat(emptyLines, line); + emptyLines = []; + } else if (prefixed) { + if (emptyLines.length) { + item.value.push(EMPTY); + item.trail = emptyLines.concat(); + } + + item = { + // 'bullet': value.slice(startIndex, index), + 'value': [line], + 'indent': size, + 'trail': [] + }; + + items.push(item); + allLines = allLines.concat(emptyLines, line); + emptyLines = []; + } else if (empty) { + // TODO: disable when in pedantic-mode. + if (prevEmpty) { + break; + } + + emptyLines.push(line); + } else { + if (prevEmpty) { + break; + } + + if ( + !pedantic && + tokenizers.horizontalRule.call(self, eat, line, true) + ) { + break; + } + + if (!commonmark) { + if ( + tokenizers.definition.call(self, eat, line, true) || + tokenizers.footnoteDefinition.call(self, eat, line, true) + ) { + break; + } + } + + item.value = item.value.concat(emptyLines, line); + allLines = allLines.concat(emptyLines, line); + emptyLines = []; + } + + index = nextIndex + 1; + } + + node = eat(allLines.join(C_NEWLINE)).reset({ + 'type': T_LIST, + 'ordered': ordered, + 'start': start, + 'loose': null, + 'children': [] + }); + + enterTop = self.exitTop(); + exitBlockquote = self.enterBlockquote(); + isLoose = false; + index = -1; + length = items.length; + + while (++index < length) { + item = items[index].value.join(C_NEWLINE); + now = eat.now(); + + item = eat(item)(self.renderListItem(item, now), node); + + if (item.loose) { + isLoose = true; + } + + item = items[index].trail.join(C_NEWLINE); + + if (index !== length - 1) { + item += C_NEWLINE; + } + + eat(item); + } + + enterTop(); + exitBlockquote(); + + node.loose = isLoose; + + return node; +} + +/** + * Try to match comment. + * + * @param {string} value - Value to parse. + * @param {Object} settings - Configuration as available on + * a parser. + * @return {string?} - When applicable, the comment at the + * start of `value`. + */ +function eatHTMLComment(value, settings) { + var index = COMMENT_START_LENGTH; + var queue = COMMENT_START; + var length = value.length; + var commonmark = settings.commonmark; + var character; + var hasNonDash; + + if (value.slice(0, index) === queue) { + while (index < length) { + character = value.charAt(index); + + if ( + character === COMMENT_END_CHAR && + value.slice(index, index + COMMENT_END_LENGTH) === COMMENT_END + ) { + return queue + COMMENT_END; + } + + if (commonmark) { + if (character === C_GT && !hasNonDash) { + return; + } + + if (character === C_DASH) { + if (value.charAt(index + 1) === C_DASH) { + return; + } + } else { + hasNonDash = true; + } + } + + queue += character; + index++; + } + } +} + +/** + * Try to match CDATA. + * + * @param {string} value - Value to parse. + * @return {string?} - When applicable, the CDATA at the + * start of `value`. + */ +function eatHTMLCDATA(value) { + var index = CDATA_START_LENGTH; + var queue = value.slice(0, index); + var length = value.length; + var character; + + if (queue.toUpperCase() === CDATA_START) { + while (index < length) { + character = value.charAt(index); + + if ( + character === CDATA_END_CHAR && + value.slice(index, index + CDATA_END_LENGTH) === CDATA_END + ) { + return queue + CDATA_END; + } + + queue += character; + index++; + } + } +} + +/** + * Try to match a processing instruction. + * + * @param {string} value - Value to parse. + * @return {string?} - When applicable, the processing + * instruction at the start of `value`. + */ +function eatHTMLProcessingInstruction(value) { + var index = 0; + var queue = EMPTY; + var length = value.length; + var character; + + if ( + value.charAt(index) === C_LT && + value.charAt(++index) === C_QUESTION_MARK + ) { + queue = C_LT + C_QUESTION_MARK; + index++; + + while (index < length) { + character = value.charAt(index); + + if ( + character === C_QUESTION_MARK && + value.charAt(index + 1) === C_GT + ) { + return queue + character + C_GT; + } + + queue += character; + index++; + } + } +} + +/** + * Try to match a declaration. + * + * @param {string} value - Value to parse. + * @return {string?} - When applicable, the declaration at + * the start of `value`. + */ +function eatHTMLDeclaration(value) { + var index = 0; + var length = value.length; + var queue = EMPTY; + var subqueue = EMPTY; + var character; + + if ( + value.charAt(index) === C_LT && + value.charAt(++index) === C_EXCLAMATION_MARK + ) { + queue = C_LT + C_EXCLAMATION_MARK; + index++; + + /* + * Eat as many alphabetic characters as + * possible. + */ + + while (index < length) { + character = value.charAt(index); + + if (!isAlphabetic(character)) { + break; + } + + subqueue += character; + index++; + } + + character = value.charAt(index); + + if (!subqueue || !isWhiteSpace(character)) { + return; + } + + queue += subqueue + character; + index++; + + while (index < length) { + character = value.charAt(index); + + if (character === C_GT) { + return queue; + } + + queue += character; + index++; + } + } +} + +/** + * Try to match a closing tag. + * + * @param {string} value - Value to parse. + * @param {boolean?} [isBlock] - Whether the tag-name + * must be a known block-level node to match. + * @return {string?} - When applicable, the closing tag at + * the start of `value`. + */ +function eatHTMLClosingTag(value, isBlock) { + var index = 0; + var length = value.length; + var queue = EMPTY; + var subqueue = EMPTY; + var character; + + if ( + value.charAt(index) === C_LT && + value.charAt(++index) === C_SLASH + ) { + queue = C_LT + C_SLASH; + subqueue = character = value.charAt(++index); + + if (!isAlphabetic(character)) { + return; + } + + index++; + + /* + * Eat as many alphabetic characters as + * possible. + */ + + while (index < length) { + character = value.charAt(index); + + if (!isAlphabetic(character) && !isNumeric(character)) { + break; + } + + subqueue += character; + index++; + } + + if (isBlock && blockElements.indexOf(subqueue.toLowerCase()) === -1) { + return; + } + + queue += subqueue; + + /* + * Eat white-space. + */ + + while (index < length) { + character = value.charAt(index); + + if (!isWhiteSpace(character)) { + break; + } + + queue += character; + index++; + } + + if (value.charAt(index) === C_GT) { + return queue + C_GT; + } + } +} + +/** + * Try to match an opening tag. + * + * @param {string} value - Value to parse. + * @param {boolean?} [isBlock] - Whether the tag-name + * must be a known block-level node to match. + * @return {string?} - When applicable, the opening tag at + * the start of `value`. + */ +function eatHTMLOpeningTag(value, isBlock) { + var index = 0; + var length = value.length; + var queue = EMPTY; + var subqueue = EMPTY; + var character = value.charAt(index); + var hasEquals; + var test; + + if (character === C_LT) { + queue = character; + subqueue = character = value.charAt(++index); + + if (!isAlphabetic(character)) { + return; + } + + index++; + + /* + * Eat as many alphabetic characters as + * possible. + */ + + while (index < length) { + character = value.charAt(index); + + if (!isAlphabetic(character) && !isNumeric(character)) { + break; + } + + subqueue += character; + index++; + } + + if (isBlock && blockElements.indexOf(subqueue.toLowerCase()) === -1) { + return; + } + + queue += subqueue; + subqueue = EMPTY; + + /* + * Find attributes. + */ + + while (index < length) { + /* + * Eat white-space. + */ + + while (index < length) { + character = value.charAt(index); + + if (!isWhiteSpace(character)) { + break; + } + + subqueue += character; + index++; + } + + if (!subqueue) { + break; + } + + /* + * Eat an attribute name. + */ + + queue += subqueue; + subqueue = EMPTY; + character = value.charAt(index); + + if ( + isAlphabetic(character) || + character === C_UNDERSCORE || + character === C_COLON + ) { + subqueue = character; + index++; + + while (index < length) { + character = value.charAt(index); + + if ( + !isAlphabetic(character) && + !isNumeric(character) && + character !== C_UNDERSCORE && + character !== C_COLON && + character !== C_DOT && + character !== C_DASH + ) { + break; + } + + subqueue += character; + index++; + } + } + + if (!subqueue) { + break; + } + + queue += subqueue; + subqueue = EMPTY; + hasEquals = false; + + /* + * Eat zero or more white-space and one + * equals sign. + */ + + while (index < length) { + character = value.charAt(index); + + if (!isWhiteSpace(character)) { + if (!hasEquals && character === C_EQUALS) { + hasEquals = true; + } else { + break; + } + } + + subqueue += character; + index++; + } + + queue += subqueue; + subqueue = EMPTY; + + if (!hasEquals) { + queue += subqueue; + } else { + character = value.charAt(index); + queue += subqueue; + + if (character === C_DOUBLE_QUOTE) { + test = isDoubleQuotedAttributeCharacter; + subqueue = character; + index++; + } else if (character === C_SINGLE_QUOTE) { + test = isSingleQuotedAttributeCharacter; + subqueue = character; + index++; + } else { + test = isUnquotedAttributeCharacter; + subqueue = EMPTY; + } + + while (index < length) { + character = value.charAt(index); + + if (!test(character)) { + break; + } + + subqueue += character; + index++; + } + + character = value.charAt(index); + index++; + + if (!test.delimiter) { + if (!subqueue.length) { + return; + } + + index--; + } else if (character === test.delimiter) { + subqueue += character; + } else { + return; + } + + queue += subqueue; + subqueue = EMPTY; + } + } + + /* + * More white-space is already eaten by the + * attributes subroutine. + */ + + character = value.charAt(index); + + /* + * Eat an optional backslash (for self-closing + * tags). + */ + + if (character === C_SLASH) { + queue += character; + character = value.charAt(++index); + } + + return character === C_GT ? queue + character : null; + } +} + +/** + * Tokenise HTML. + * + * @example + * tokenizeHTML(eat, 'foo'); + * + * @param {function(string)} eat - Eater. + * @param {string} value - Rest of content. + * @param {boolean?} [silent] - Whether this is a dry run. + * @return {Node?|boolean} - `html` node. + */ +function tokenizeHTML(eat, value, silent) { + var self = this; + var index = 0; + var length = value.length; + var subvalue = EMPTY; + var offset; + var lineCount; + var character; + var queue; + + /* + * Eat initial spacing. + */ + + while (index < length) { + character = value.charAt(index); + + if (character !== C_TAB && character !== C_SPACE) { + break; + } + + subvalue += character; + index++; + } + + offset = index; + value = value.slice(offset); + + /* + * Try to eat an HTML thing. + */ + + queue = eatHTMLComment(value, self.options) || + eatHTMLCDATA(value) || + eatHTMLProcessingInstruction(value) || + eatHTMLDeclaration(value) || + eatHTMLClosingTag(value, true) || + eatHTMLOpeningTag(value, true); + + if (!queue) { + return; + } + + if (silent) { + return true; + } + + subvalue += queue; + index = subvalue.length - offset; + queue = EMPTY; + + while (index < length) { + character = value.charAt(index); + + if (character === C_NEWLINE) { + queue += character; + lineCount++; + } else if (queue.length < MIN_CLOSING_HTML_NEWLINE_COUNT) { + subvalue += queue + character; + queue = EMPTY; + } else { + break; + } + + index++; + } + + return eat(subvalue)(self.renderRaw(T_HTML, subvalue)); +} + +/** + * Tokenise a definition. + * + * @example + * var value = '[foo]: http://example.com "Example Domain"'; + * tokenizeDefinition(eat, value); + * + * @property {boolean} onlyAtTop + * @property {boolean} notInBlockquote + * @param {function(string)} eat - Eater. + * @param {string} value - Rest of content. + * @param {boolean?} [silent] - Whether this is a dry run. + * @return {Node?|boolean} - `definition` node. + */ +function tokenizeDefinition(eat, value, silent) { + var self = this; + var commonmark = self.options.commonmark; + var index = 0; + var length = value.length; + var subvalue = EMPTY; + var beforeURL; + var beforeTitle; + var queue; + var character; + var test; + var identifier; + var url; + var title; + + while (index < length) { + character = value.charAt(index); + + if (character !== C_SPACE && character !== C_TAB) { + break; + } + + subvalue += character; + index++; + } + + character = value.charAt(index); + + if (character !== C_BRACKET_OPEN) { + return; + } + + index++; + subvalue += character; + queue = EMPTY; + + while (index < length) { + character = value.charAt(index); + + if (character === C_BRACKET_CLOSE) { + break; + } else if (character === C_BACKSLASH) { + queue += character; + index++; + character = value.charAt(index); + } + + queue += character; + index++; + } + + if ( + !queue || + value.charAt(index) !== C_BRACKET_CLOSE || + value.charAt(index + 1) !== C_COLON + ) { + return; + } + + identifier = queue; + subvalue += queue + C_BRACKET_CLOSE + C_COLON; + index = subvalue.length; + queue = EMPTY; + + while (index < length) { + character = value.charAt(index); + + if ( + character !== C_TAB && + character !== C_SPACE && + character !== C_NEWLINE + ) { + break; + } + + subvalue += character; + index++; + } + + character = value.charAt(index); + queue = EMPTY; + beforeURL = subvalue; + + if (character === C_LT) { + index++; + + while (index < length) { + character = value.charAt(index); + + if (!isEnclosedURLCharacter(character)) { + break; + } + + queue += character; + index++; + } + + character = value.charAt(index); + + if (character !== isEnclosedURLCharacter.delimiter) { + if (commonmark) { + return; + } + + index -= queue.length + 1; + queue = EMPTY; + } else { + subvalue += C_LT + queue + character; + index++; + } + } + + if (!queue) { + while (index < length) { + character = value.charAt(index); + + if (!isUnclosedURLCharacter(character)) { + break; + } + + queue += character; + index++; + } + + subvalue += queue; + } + + if (!queue) { + return; + } + + url = queue; + queue = EMPTY; + + while (index < length) { + character = value.charAt(index); + + if ( + character !== C_TAB && + character !== C_SPACE && + character !== C_NEWLINE + ) { + break; + } + + queue += character; + index++; + } + + character = value.charAt(index); + test = null; + + if (character === C_DOUBLE_QUOTE) { + test = C_DOUBLE_QUOTE; + } else if (character === C_SINGLE_QUOTE) { + test = C_SINGLE_QUOTE; + } else if (character === C_PAREN_OPEN) { + test = C_PAREN_CLOSE; + } + + if (!test) { + queue = EMPTY; + index = subvalue.length; + } else if (!queue) { + return; + } else { + subvalue += queue + character; + index = subvalue.length; + queue = EMPTY; + + while (index < length) { + character = value.charAt(index); + + if (character === test) { + break; + } + + if (character === C_NEWLINE) { + index++; + character = value.charAt(index); + + if (character === C_NEWLINE || character === test) { + return; + } + + queue += C_NEWLINE; + } + + queue += character; + index++; + } + + character = value.charAt(index); + + if (character !== test) { + return; + } + + beforeTitle = subvalue; + subvalue += queue + character; + index++; + title = queue; + queue = EMPTY; + } + + while (index < length) { + character = value.charAt(index); + + if (character !== C_TAB && character !== C_SPACE) { + break; + } + + subvalue += character; + index++; + } + + character = value.charAt(index); + + if (!character || character === C_NEWLINE) { + if (silent) { + return true; + } + + beforeURL = eat(beforeURL).test().end; + url = self.decode.raw(self.descape(url), beforeURL); + + if (title) { + beforeTitle = eat(beforeTitle).test().end; + title = self.decode.raw(self.descape(title), beforeTitle); + } + + return eat(subvalue)({ + 'type': T_DEFINITION, + 'identifier': normalize(identifier), + 'title': title || null, + 'link': url + }); + } +} + +tokenizeDefinition.onlyAtTop = true; +tokenizeDefinition.notInBlockquote = true; + +/** + * Tokenise YAML front matter. + * + * @example + * tokenizeYAMLFrontMatter(eat, '---\nfoo: bar\n---'); + * + * @property {boolean} onlyAtStart + * @param {function(string)} eat - Eater. + * @param {string} value - Rest of content. + * @param {boolean?} [silent] - Whether this is a dry run. + * @return {Node?|boolean} - `yaml` node. + */ +function tokenizeYAMLFrontMatter(eat, value, silent) { + var self = this; + var subvalue; + var content; + var index; + var length; + var character; + var queue; + + if ( + !self.options.yaml || + value.charAt(0) !== C_DASH || + value.charAt(1) !== C_DASH || + value.charAt(2) !== C_DASH || + value.charAt(3) !== C_NEWLINE + ) { + return; + } + + subvalue = YAML_FENCE + C_NEWLINE; + content = queue = EMPTY; + index = 3; + length = value.length; + + while (++index < length) { + character = value.charAt(index); + + if ( + character === C_DASH && + (queue || !content) && + value.charAt(index + 1) === C_DASH && + value.charAt(index + 2) === C_DASH + ) { + /* istanbul ignore if - never used (yet) */ + if (silent) { + return true; + } + + subvalue += queue + YAML_FENCE; + + return eat(subvalue)(self.renderRaw(T_YAML, content)); + } + + if (character === C_NEWLINE) { + queue += character; + } else { + subvalue += queue + character; + content += queue + character; + queue = EMPTY; + } + } +} + +tokenizeYAMLFrontMatter.onlyAtStart = true; + +/** + * Tokenise a footnote definition. + * + * @example + * tokenizeFootnoteDefinition(eat, '[^foo]: Bar.'); + * + * @property {boolean} onlyAtTop + * @property {boolean} notInBlockquote + * @param {function(string)} eat - Eater. + * @param {string} value - Rest of content. + * @param {boolean?} [silent] - Whether this is a dry run. + * @return {Node?|boolean} - `footnoteDefinition` node. + */ +function tokenizeFootnoteDefinition(eat, value, silent) { + var self = this; + var index; + var length; + var subvalue; + var now; + var indent; + var content; + var queue; + var subqueue; + var character; + var identifier; + + if (!self.options.footnotes) { + return; + } + + index = 0; + length = value.length; + subvalue = EMPTY; + now = eat.now(); + indent = self.indent(now.line); + + while (index < length) { + character = value.charAt(index); + + if (!isWhiteSpace(character)) { + break; + } + + subvalue += character; + index++; + } + + if ( + value.charAt(index) !== C_BRACKET_OPEN || + value.charAt(index + 1) !== C_CARET + ) { + return; + } + + subvalue += C_BRACKET_OPEN + C_CARET; + index = subvalue.length; + queue = EMPTY; + + while (index < length) { + character = value.charAt(index); + + if (character === C_BRACKET_CLOSE) { + break; + } else if (character === C_BACKSLASH) { + queue += character; + index++; + character = value.charAt(index); + } + + queue += character; + index++; + } + + if ( + !queue || + value.charAt(index) !== C_BRACKET_CLOSE || + value.charAt(index + 1) !== C_COLON + ) { + return; + } + + if (silent) { + return true; + } + + identifier = normalize(queue); + subvalue += queue + C_BRACKET_CLOSE + C_COLON; + index = subvalue.length; + + while (index < length) { + character = value.charAt(index); + + if ( + character !== C_TAB && + character !== C_SPACE + ) { + break; + } + + subvalue += character; + index++; + } + + now.column += subvalue.length; + queue = content = subqueue = EMPTY; + + while (index < length) { + character = value.charAt(index); + + if (character === C_NEWLINE) { + subqueue = character; + index++; + + while (index < length) { + character = value.charAt(index); + + if (character !== C_NEWLINE) { + break; + } + + subqueue += character; + index++; + } + + queue += subqueue; + subqueue = EMPTY; + + while (index < length) { + character = value.charAt(index); + + if (character !== C_SPACE) { + break; + } + + subqueue += character; + index++; + } + + if (!subqueue.length) { + break; + } + + queue += subqueue; + } + + if (queue) { + content += queue; + queue = EMPTY; + } + + content += character; + index++; + } + + subvalue += content; + + content = content.replace(EXPRESSION_INITIAL_TAB, function (line) { + indent(line.length); + + return EMPTY; + }); + + return eat(subvalue)( + self.renderFootnoteDefinition(identifier, content, now) + ); +} + +tokenizeFootnoteDefinition.onlyAtTop = true; +tokenizeFootnoteDefinition.notInBlockquote = true; + +/** + * Tokenise a table. + * + * @example + * tokenizeTable(eat, ' | foo |\n | --- |\n | bar |'); + * + * @property {boolean} onlyAtTop + * @param {function(string)} eat - Eater. + * @param {string} value - Rest of content. + * @param {boolean?} [silent] - Whether this is a dry run. + * @return {Node?|boolean} - `table` node. + */ +function tokenizeTable(eat, value, silent) { + var self = this; + var index; + var alignments; + var alignment; + var subvalue; + var row; + var length; + var lines; + var queue; + var character; + var hasDash; + var align; + var cell; + var preamble; + var count; + var opening; + var now; + var position; + var lineCount; + var line; + var rows; + var table; + var lineIndex; + var pipeIndex; + var first; + + /* + * Exit when not in gfm-mode. + */ + + if (!self.options.gfm) { + return; + } + + /* + * Get the rows. + * Detecting tables soon is hard, so there are some + * checks for performance here, such as the minimum + * number of rows, and allowed characters in the + * alignment row. + */ + + index = lineCount = 0; + length = value.length + 1; + lines = []; + + while (index < length) { + lineIndex = value.indexOf(C_NEWLINE, index); + pipeIndex = value.indexOf(C_PIPE, index + 1); + + if (lineIndex === -1) { + lineIndex = value.length; + } + + if ( + pipeIndex === -1 || + pipeIndex > lineIndex + ) { + if (lineCount < MIN_TABLE_ROWS) { + return; + } + + break; + } + + lines.push(value.slice(index, lineIndex)); + lineCount++; + index = lineIndex + 1; + } + + /* + * Parse the alignment row. + */ + + subvalue = lines.join(C_NEWLINE); + alignments = lines.splice(1, 1)[0]; + index = 0; + length = alignments.length; + lineCount--; + alignment = false; + align = []; + + while (index < length) { + character = alignments.charAt(index); + + if (character === C_PIPE) { + hasDash = null; + + if (alignment === false) { + if (first === false) { + return; + } + } else { + align.push(alignment); + alignment = false; + } + + first = false; + } else if (character === C_DASH) { + hasDash = true; + alignment = alignment || TABLE_ALIGN_NONE; + } else if (character === C_COLON) { + if (alignment === TABLE_ALIGN_LEFT) { + alignment = TABLE_ALIGN_CENTER; + } else if (hasDash && alignment === TABLE_ALIGN_NONE) { + alignment = TABLE_ALIGN_RIGHT; + } else { + alignment = TABLE_ALIGN_LEFT; + } + } else if (!isWhiteSpace(character)) { + return; + } + + index++; + } + + if (alignment !== false) { + align.push(alignment); + } + + /* + * Exit when without enough columns. + */ + + if (align.length < MIN_TABLE_COLUMNS) { + return; + } + + /* istanbul ignore if - never used (yet) */ + if (silent) { + return true; + } + + /* + * Parse the rows. + */ + + position = -1; + rows = []; + + table = eat(subvalue).reset({ + 'type': T_TABLE, + 'align': align, + 'children': rows + }); + + while (++position < lineCount) { + line = lines[position]; + row = self.renderParent(position ? T_TABLE_ROW : T_TABLE_HEADER, []); + + /* + * Eat a newline character when this is not the + * first row. + */ + + if (position) { + eat(C_NEWLINE); + } + + /* + * Eat the row. + */ + + eat(line).reset(row, table); + + length = line.length + 1; + index = 0; + queue = EMPTY; + cell = EMPTY; + preamble = true; + count = opening = null; + + while (index < length) { + character = line.charAt(index); + + if (character === C_TAB || character === C_SPACE) { + if (cell) { + queue += character; + } else { + eat(character); + } + + index++; + continue; + } + + if (character === EMPTY || character === C_PIPE) { + if (preamble) { + eat(character); + } else { + if (character && opening) { + queue += character; + index++; + continue; + } + + if ((cell || character) && !preamble) { + subvalue = cell; + + if (queue.length > 1) { + if (character) { + subvalue += queue.slice(0, queue.length - 1); + queue = queue.charAt(queue.length - 1); + } else { + subvalue += queue; + queue = EMPTY; + } + } + + now = eat.now(); + + eat(subvalue)( + self.renderInline(T_TABLE_CELL, cell, now), row + ); + } + + eat(queue + character); + + queue = EMPTY; + cell = EMPTY; + } + } else { + if (queue) { + cell += queue; + queue = EMPTY; + } + + cell += character; + + if (character === C_BACKSLASH && index !== length - 2) { + cell += line.charAt(index + 1); + index++; + } + + if (character === C_TICK) { + count = 1; + + while (line.charAt(index + 1) === character) { + cell += character; + index++; + count++; + } + + if (!opening) { + opening = count; + } else if (count >= opening) { + opening = 0; + } + } + } + + preamble = false; + index++; + } + + /* + * Eat the alignment row. + */ + + if (!position) { + eat(C_NEWLINE + alignments); + } + } + + return table; +} + +tokenizeTable.onlyAtTop = true; + +/** + * Tokenise a paragraph node. + * + * @example + * tokenizeParagraph(eat, 'Foo.'); + * + * @param {function(string)} eat - Eater. + * @param {string} value - Rest of content. + * @param {boolean?} [silent] - Whether this is a dry run. + * @return {Node?|boolean} - `paragraph` node. + */ +function tokenizeParagraph(eat, value, silent) { + var self = this; + var settings = self.options; + var commonmark = settings.commonmark; + var gfm = settings.gfm; + var tokenizers = self.blockTokenizers; + var index = value.indexOf(C_NEWLINE); + var length = value.length; + var position; + var subvalue; + var character; + var size; + var now; + + while (index < length) { + /* + * Eat everything if there’s no following newline. + */ + + if (index === -1) { + index = length; + break; + } + + /* + * Stop if the next character is NEWLINE. + */ + + if (value.charAt(index + 1) === C_NEWLINE) { + break; + } + + /* + * In commonmark-mode, following indented lines + * are part of the paragraph. + */ + + if (commonmark) { + size = 0; + position = index + 1; + + while (position < length) { + character = value.charAt(position); + + if (character === C_TAB) { + size = TAB_SIZE; + break; + } else if (character === C_SPACE) { + size++; + } else { + break; + } + + position++; + } + + if (size >= TAB_SIZE) { + index = value.indexOf(C_NEWLINE, index + 1); + continue; + } + } + + /* + * Check if the following code contains a possible + * block. + */ + + subvalue = value.slice(index + 1); + + if ( + tokenizers.horizontalRule.call(self, eat, subvalue, true) || + tokenizers.heading.call(self, eat, subvalue, true) || + tokenizers.fences.call(self, eat, subvalue, true) || + tokenizers.blockquote.call(self, eat, subvalue, true) || + tokenizers.html.call(self, eat, subvalue, true) + ) { + break; + } + + if (gfm && tokenizers.list.call(self, eat, subvalue, true)) { + break; + } + + if ( + !commonmark && + ( + tokenizers.lineHeading.call(self, eat, subvalue, true) || + tokenizers.definition.call(self, eat, subvalue, true) || + tokenizers.footnoteDefinition.call(self, eat, subvalue, true) + ) + ) { + break; + } + + index = value.indexOf(C_NEWLINE, index + 1); + } + + subvalue = value.slice(0, index); + + if (trim(subvalue) === EMPTY) { + eat(subvalue); + + return null; + } + + /* istanbul ignore if - never used (yet) */ + if (silent) { + return true; + } + + now = eat.now(); + subvalue = trimTrailingLines(subvalue); + + return eat(subvalue)(self.renderInline(T_PARAGRAPH, subvalue, now)); +} + +/** + * Tokenise a text node. + * + * @example + * tokenizeText(eat, 'foo'); + * + * @param {function(string)} eat - Eater. + * @param {string} value - Rest of content. + * @param {boolean?} [silent] - Whether this is a dry run. + * @return {Node?|boolean} - `text` node. + */ +function tokenizeText(eat, value, silent) { + var self = this; + var methods; + var tokenizers; + var index; + var length; + var subvalue; + var position; + var tokenizer; + var name; + var min; + var now; + + /* istanbul ignore if - never used (yet) */ + if (silent) { + return true; + } + + methods = self.inlineMethods; + length = methods.length; + tokenizers = self.inlineTokenizers; + index = -1; + min = value.length; + + while (++index < length) { + name = methods[index]; + + if (name === 'inlineText' || !tokenizers[name]) { + continue; + } + + tokenizer = tokenizers[name].locator; + + if (!tokenizer) { + eat.file.fail(ERR_MISSING_LOCATOR + C_TICK + name + C_TICK); + continue; + } + + position = tokenizer.call(self, value, 1); + + if (position !== -1 && position < min) { + min = position; + } + } + + subvalue = value.slice(0, min); + now = eat.now(); + + self.decode(subvalue, now, function (content, position, source) { + eat(source || content)(self.renderRaw(T_TEXT, content)); + }); +} + +/** + * Create a code-block node. + * + * @example + * renderCodeBlock('foo()', 'js', now()); + * + * @param {string?} [value] - Code. + * @param {string?} [language] - Optional language flag. + * @param {Function} eat - Eater. + * @return {Object} - `code` node. + */ +function renderCodeBlock(value, language) { + return { + 'type': T_CODE, + 'lang': language || null, + 'value': trimTrailingLines(value || EMPTY) + }; +} + +/** + * Create a list-item using overly simple mechanics. + * + * @example + * renderPedanticListItem('- _foo_', now()); + * + * @param {string} value - List-item. + * @param {Object} position - List-item location. + * @return {string} - Cleaned `value`. + */ +function renderPedanticListItem(value, position) { + var self = this; + var indent = self.indent(position.line); + + /** + * A simple replacer which removed all matches, + * and adds their length to `offset`. + * + * @param {string} $0 - Indentation to subtract. + * @return {string} - An empty string. + */ + function replacer($0) { + indent($0.length); + + return EMPTY; + } + + /* + * Remove the list-item’s bullet. + */ + + value = value.replace(EXPRESSION_PEDANTIC_BULLET, replacer); + + /* + * The initial line was also matched by the below, so + * we reset the `line`. + */ + + indent = self.indent(position.line); + + return value.replace(EXPRESSION_INITIAL_INDENT, replacer); +} + +/** + * Create a list-item using sane mechanics. + * + * @example + * renderNormalListItem('- _foo_', now()); + * + * @param {string} value - List-item. + * @param {Object} position - List-item location. + * @return {string} - Cleaned `value`. + */ +function renderNormalListItem(value, position) { + var self = this; + var indent = self.indent(position.line); + var max; + var bullet; + var rest; + var lines; + var trimmedLines; + var index; + var length; + + /* + * Remove the list-item’s bullet. + */ + + value = value.replace(EXPRESSION_BULLET, function ($0, $1, $2, $3, $4) { + bullet = $1 + $2 + $3; + rest = $4; + + /* + * Make sure that the first nine numbered list items + * can indent with an extra space. That is, when + * the bullet did not receive an extra final space. + */ + + if (Number($2) < 10 && bullet.length % 2 === 1) { + $2 = C_SPACE + $2; + } + + max = $1 + repeat(C_SPACE, $2.length) + $3; + + return max + rest; + }); + + lines = value.split(C_NEWLINE); + + trimmedLines = removeIndentation( + value, getIndent(max).indent + ).split(C_NEWLINE); + + /* + * We replaced the initial bullet with something + * else above, which was used to trick + * `removeIndentation` into removing some more + * characters when possible. However, that could + * result in the initial line to be stripped more + * than it should be. + */ + + trimmedLines[0] = rest; + + indent(bullet.length); + + index = 0; + length = lines.length; + + while (++index < length) { + indent(lines[index].length - trimmedLines[index].length); + } + + return trimmedLines.join(C_NEWLINE); +} + +/** + * Create a list-item node. + * + * @example + * renderListItem('- _foo_', now()); + * + * @param {Object} value - List-item. + * @param {Object} position - List-item location. + * @return {Object} - `listItem` node. + */ +function renderListItem(value, position) { + var self = this; + var checked = null; + var node; + var task; + var indent; + + value = LIST_ITEM_MAP[self.options.pedantic].apply(self, arguments); + + if (self.options.gfm) { + task = value.match(EXPRESSION_TASK_ITEM); + + if (task) { + indent = task[0].length; + checked = task[1].toLowerCase() === C_X_LOWER; + + self.indent(position.line)(indent); + value = value.slice(indent); + } + } + + node = { + 'type': T_LIST_ITEM, + 'loose': EXPRESSION_LOOSE_LIST_ITEM.test(value) || + value.charAt(value.length - 1) === C_NEWLINE + }; + + if (self.options.gfm) { + node.checked = checked; + } + + node.children = self.tokenizeBlock(value, position); + + return node; +} + +/** + * Create a footnote-definition node. + * + * @example + * renderFootnoteDefinition('1', '_foo_', now()); + * + * @param {string} identifier - Unique reference. + * @param {string} value - Contents + * @param {Object} position - Definition location. + * @return {Object} - `footnoteDefinition` node. + */ +function renderFootnoteDefinition(identifier, value, position) { + var self = this; + var exitBlockquote = self.enterBlockquote(); + var node; + + node = { + 'type': T_FOOTNOTE_DEFINITION, + 'identifier': identifier, + 'children': self.tokenizeBlock(value, position) + }; + + exitBlockquote(); + + return node; +} + +/** + * Create a heading node. + * + * @example + * renderHeading('_foo_', 1, now()); + * + * @param {string} value - Content. + * @param {number} depth - Heading depth. + * @param {Object} position - Heading content location. + * @return {Object} - `heading` node + */ +function renderHeading(value, depth, position) { + return { + 'type': T_HEADING, + 'depth': depth, + 'children': this.tokenizeInline(value, position) + }; +} + +/** + * Create a blockquote node. + * + * @example + * renderBlockquote('_foo_', eat); + * + * @param {string} value - Content. + * @param {Object} now - Position. + * @return {Object} - `blockquote` node. + */ +function renderBlockquote(value, now) { + var self = this; + var exitBlockquote = self.enterBlockquote(); + var node = { + 'type': T_BLOCKQUOTE, + 'children': self.tokenizeBlock(value, now) + }; + + exitBlockquote(); + + return node; +} + +/** + * Create a void node. + * + * @example + * renderVoid('horizontalRule'); + * + * @param {string} type - Node type. + * @return {Object} - Node of type `type`. + */ +function renderVoid(type) { + return { + 'type': type + }; +} + +/** + * Create a parent. + * + * @example + * renderParent('paragraph', '_foo_'); + * + * @param {string} type - Node type. + * @param {Array.} children - Child nodes. + * @return {Object} - Node of type `type`. + */ +function renderParent(type, children) { + return { + 'type': type, + 'children': children + }; +} + +/** + * Create a raw node. + * + * @example + * renderRaw('inlineCode', 'foo()'); + * + * @param {string} type - Node type. + * @param {string} value - Contents. + * @return {Object} - Node of type `type`. + */ +function renderRaw(type, value) { + return { + 'type': type, + 'value': value + }; +} + +/** + * Create a link node. + * + * @example + * renderLink(true, 'example.com', 'example', 'Example Domain', now(), eat); + * renderLink(false, 'fav.ico', 'example', 'Example Domain', now(), eat); + * + * @param {boolean} isLink - Whether linking to a document + * or an image. + * @param {string} href - URI reference. + * @param {string} text - Content. + * @param {string?} title - Title. + * @param {Object} position - Location of link. + * @return {Object} - `link` or `image` node. + */ +function renderLink(isLink, href, text, title, position) { + var self = this; + var exitLink = self.enterLink(); + var node; + + node = { + 'type': isLink ? T_LINK : T_IMAGE, + 'title': title || null + }; + + if (isLink) { + node.href = href; + node.children = self.tokenizeInline(text, position); + } else { + node.src = href; + node.alt = text ? + self.decode.raw(self.descape(text), position) : + null; + } + + exitLink(); + + return node; +} + +/** + * Create a footnote node. + * + * @example + * renderFootnote('_foo_', now()); + * + * @param {string} value - Contents. + * @param {Object} position - Location of footnote. + * @return {Object} - `footnote` node. + */ +function renderFootnote(value, position) { + return this.renderInline(T_FOOTNOTE, value, position); +} + +/** + * Add a node with inline content. + * + * @example + * renderInline('strong', '_foo_', now()); + * + * @param {string} type - Node type. + * @param {string} value - Contents. + * @param {Object} position - Location of node. + * @return {Object} - Node of type `type`. + */ +function renderInline(type, value, position) { + return this.renderParent(type, this.tokenizeInline(value, position)); +} + +/** + * Add a node with block content. + * + * @example + * renderBlock('blockquote', 'Foo.', now()); + * + * @param {string} type - Node type. + * @param {string} value - Contents. + * @param {Object} position - Location of node. + * @return {Object} - Node of type `type`. + */ +function renderBlock(type, value, position) { + return this.renderParent(type, this.tokenizeBlock(value, position)); +} + +/** + * Find a possible escape sequence. + * + * @example + * locateEscape('foo \- bar'); // 4 + * + * @param {string} value - Value to search. + * @param {number} fromIndex - Index to start searching at. + * @return {number} - Location of possible escape sequence. + */ +function locateEscape(value, fromIndex) { + return value.indexOf(C_BACKSLASH, fromIndex); +} + +/** + * Tokenise an escape sequence. + * + * @example + * tokenizeEscape(eat, '\\a'); + * + * @property {Function} locator - Escape locator. + * @param {function(string)} eat - Eater. + * @param {string} value - Rest of content. + * @param {boolean?} [silent] - Whether this is a dry run. + * @return {Node?|boolean} - `text` or `break` node. + */ +function tokenizeEscape(eat, value, silent) { + var self = this; + var character; + + if (value.charAt(0) === C_BACKSLASH) { + character = value.charAt(1); + + if (self.escape.indexOf(character) !== -1) { + /* istanbul ignore if - never used (yet) */ + if (silent) { + return true; + } + + return eat(C_BACKSLASH + character)( + character === C_NEWLINE ? + self.renderVoid(T_BREAK) : + self.renderRaw(T_TEXT, character) + ); + } + } +} + +tokenizeEscape.locator = locateEscape; + +/** + * Find a possible auto-link. + * + * @example + * locateAutoLink('foo '); + * + * @property {boolean} notInLink + * @property {Function} locator - Auto-link locator. + * @param {function(string)} eat - Eater. + * @param {string} value - Rest of content. + * @param {boolean?} [silent] - Whether this is a dry run. + * @return {Node?|boolean} - `link` node. + */ +function tokenizeAutoLink(eat, value, silent) { + var self; + var subvalue; + var length; + var index; + var queue; + var character; + var hasAtCharacter; + var link; + var now; + var content; + var tokenize; + var node; + + if (value.charAt(0) !== C_LT) { + return; + } + + self = this; + subvalue = EMPTY; + length = value.length; + index = 0; + queue = EMPTY; + hasAtCharacter = false; + link = EMPTY; + + index++; + subvalue = C_LT; + + while (index < length) { + character = value.charAt(index); + + if ( + character === C_SPACE || + character === C_GT || + character === C_AT_SIGN || + (character === C_COLON && value.charAt(index + 1) === C_SLASH) + ) { + break; + } + + queue += character; + index++; + } + + if (!queue) { + return; + } + + link += queue; + queue = EMPTY; + + character = value.charAt(index); + link += character; + index++; + + if (character === C_AT_SIGN) { + hasAtCharacter = true; + } else { + if ( + character !== C_COLON || + value.charAt(index + 1) !== C_SLASH + ) { + return; + } + + link += C_SLASH; + index++; + } + + while (index < length) { + character = value.charAt(index); + + if (character === C_SPACE || character === C_GT) { + break; + } + + queue += character; + index++; + } + + character = value.charAt(index); + + if (!queue || character !== C_GT) { + return; + } + + /* istanbul ignore if - never used (yet) */ + if (silent) { + return true; + } + + link += queue; + content = link; + subvalue += link + character; + now = eat.now(); + now.column++; + + if (hasAtCharacter) { + if ( + link.substr(0, MAILTO_PROTOCOL.length).toLowerCase() !== + MAILTO_PROTOCOL + ) { + link = MAILTO_PROTOCOL + link; + } else { + content = content.substr(MAILTO_PROTOCOL.length); + now.column += MAILTO_PROTOCOL.length; + } + } + + /* + * Temporarily remove support for escapes in autolinks. + */ + + tokenize = self.inlineTokenizers.escape; + self.inlineTokenizers.escape = null; + + node = eat(subvalue)( + self.renderLink(true, decode(link), content, null, now, eat) + ); + + self.inlineTokenizers.escape = tokenize; + + return node; +} + +tokenizeAutoLink.notInLink = true; +tokenizeAutoLink.locator = locateAutoLink; + +/** + * Find a possible URL. + * + * @example + * locateURL('foo http://bar'); // 4 + * + * @param {string} value - Value to search. + * @param {number} fromIndex - Index to start searching at. + * @return {number} - Location of possible URL. + */ +function locateURL(value, fromIndex) { + var index = -1; + var min = -1; + var position; + + if (!this.options.gfm) { + return -1; + } + + while (++index < PROTOCOLS_LENGTH) { + position = value.indexOf(PROTOCOLS[index], fromIndex); + + if (position !== -1 && (position < min || min === -1)) { + min = position; + } + } + + return min; +} + +/** + * Tokenise a URL in text. + * + * @example + * tokenizeURL(eat, 'http://foo.bar'); + * + * @property {boolean} notInLink + * @property {Function} locator - URL locator. + * @param {function(string)} eat - Eater. + * @param {string} value - Rest of content. + * @param {boolean?} [silent] - Whether this is a dry run. + * @return {Node?|boolean} - `link` node. + */ +function tokenizeURL(eat, value, silent) { + var self = this; + var subvalue; + var content; + var character; + var index; + var position; + var protocol; + var match; + var length; + var queue; + var once; + var now; + + if (!self.options.gfm) { + return; + } + + subvalue = EMPTY; + index = -1; + length = PROTOCOLS_LENGTH; + + while (++index < length) { + protocol = PROTOCOLS[index]; + match = value.slice(0, protocol.length); + + if (match.toLowerCase() === protocol) { + subvalue = match; + break; + } + } + + if (!subvalue) { + return; + } + + index = subvalue.length; + length = value.length; + queue = EMPTY; + + while (index < length) { + character = value.charAt(index); + + if (isWhiteSpace(character) || character === C_LT) { + break; + } + + if ( + character === C_DOT || + character === C_COMMA || + character === C_COLON || + character === C_SEMI_COLON || + character === C_DOUBLE_QUOTE || + character === C_SINGLE_QUOTE || + character === C_PAREN_CLOSE || + character === C_BRACKET_CLOSE + ) { + if (once) { + break; + } + + once = true; + } + + queue += character; + index++; + } + + if (!queue) { + return; + } + + subvalue += queue; + content = subvalue; + + if (protocol === MAILTO_PROTOCOL) { + position = queue.indexOf(C_AT_SIGN); + + if (position === -1 || position === length - 1) { + return; + } + + content = content.substr(MAILTO_PROTOCOL.length); + } + + /* istanbul ignore if - never used (yet) */ + if (silent) { + return true; + } + + now = eat.now(); + + return eat(subvalue)( + self.renderLink(true, decode(subvalue), content, null, now, eat) + ); +} + +tokenizeURL.notInLink = true; +tokenizeURL.locator = locateURL; + +/** + * Find a possible tag. + * + * @example + * locateTag('foo '); + * + * @property {Function} locator - Tag locator. + * @param {function(string)} eat - Eater. + * @param {string} value - Rest of content. + * @param {boolean?} [silent] - Whether this is a dry run. + * @return {Node?|boolean} - `html` node. + */ +function tokenizeTag(eat, value, silent) { + var self = this; + var subvalue = eatHTMLComment(value, self.options) || + eatHTMLCDATA(value) || + eatHTMLProcessingInstruction(value) || + eatHTMLDeclaration(value) || + eatHTMLClosingTag(value) || + eatHTMLOpeningTag(value); + + if (!subvalue) { + return; + } + + /* istanbul ignore if - never used (yet) */ + if (silent) { + return true; + } + + if (!self.inLink && EXPRESSION_HTML_LINK_OPEN.test(subvalue)) { + self.inLink = true; + } else if (self.inLink && EXPRESSION_HTML_LINK_CLOSE.test(subvalue)) { + self.inLink = false; + } + + return eat(subvalue)(self.renderRaw(T_HTML, subvalue)); +} + +tokenizeTag.locator = locateTag; + +/** + * Find a possible link. + * + * @example + * locateLink('foo ![bar'); // 4 + * + * @param {string} value - Value to search. + * @param {number} fromIndex - Index to start searching at. + * @return {number} - Location of possible link. + */ +function locateLink(value, fromIndex) { + var link = value.indexOf(C_BRACKET_OPEN, fromIndex); + var image = value.indexOf(C_EXCLAMATION_MARK + C_BRACKET_OPEN, fromIndex); + + if (image === -1) { + return link; + } + + /* + * Link can never be `-1` if an image is found, so we don’t need to + * check for that :) + */ + + return link < image ? link : image; +} + +/** + * Tokenise a link. + * + * @example + * tokenizeLink(eat, '![foo](fav.ico "Favicon")); + * + * @property {Function} locator - Link locator. + * @param {function(string)} eat - Eater. + * @param {string} value - Rest of content. + * @param {boolean?} [silent] - Whether this is a dry run. + * @return {Node?|boolean} - `link` or `image` node. + */ +function tokenizeLink(eat, value, silent) { + var self = this; + var subvalue = EMPTY; + var index = 0; + var character = value.charAt(0); + var beforeURL; + var beforeTitle; + var whiteSpaceQueue; + var commonmark; + var openCount; + var hasMarker; + var markers; + var isImage; + var content; + var marker; + var length; + var title; + var depth; + var queue; + var url; + var now; + + /* + * Detect whether this is an image. + */ + + if (character === C_EXCLAMATION_MARK) { + isImage = true; + subvalue = character; + character = value.charAt(++index); + } + + /* + * Eat the opening. + */ + + if (character !== C_BRACKET_OPEN) { + return; + } + + /* + * Exit when this is a link and we’re already inside + * a link. + */ + + if (!isImage && self.inLink) { + return; + } + + subvalue += character; + queue = EMPTY; + index++; + + /* + * Eat the content. + */ + + commonmark = self.options.commonmark; + length = value.length; + now = eat.now(); + depth = 0; + + now.column += index; + + while (index < length) { + character = value.charAt(index); + + if (character === C_BRACKET_OPEN) { + depth++; + } else if (character === C_BRACKET_CLOSE) { + /* + * Allow a single closing bracket when not in + * commonmark-mode. + */ + + if (!commonmark && !depth) { + if (value.charAt(index + 1) === C_PAREN_OPEN) { + break; + } + + depth++; + } + + if (depth === 0) { + break; + } + + depth--; + } + + queue += character; + index++; + } + + /* + * Eat the content closing. + */ + + if ( + value.charAt(index) !== C_BRACKET_CLOSE || + value.charAt(++index) !== C_PAREN_OPEN + ) { + return; + } + + subvalue += queue + C_BRACKET_CLOSE + C_PAREN_OPEN; + index++; + content = queue; + + /* + * Eat white-space. + */ + + while (index < length) { + character = value.charAt(index); + + if (!isWhiteSpace(character)) { + break; + } + + subvalue += character; + index++; + } + + /* + * Eat the URL. + */ + + character = value.charAt(index); + markers = commonmark ? COMMONMARK_LINK_TITLE_MARKERS : LINK_TITLE_MARKERS; + openCount = 0; + queue = EMPTY; + beforeURL = subvalue; + + if (character === C_LT) { + index++; + beforeURL += C_LT; + + while (index < length) { + character = value.charAt(index); + + if (character === C_GT) { + break; + } + + if (commonmark && character === C_NEWLINE) { + return; + } + + queue += character; + index++; + } + + if (value.charAt(index) !== C_GT) { + return; + } + + subvalue += C_LT + queue + C_GT; + url = queue; + index++; + } else { + character = null; + whiteSpaceQueue = EMPTY; + + while (index < length) { + character = value.charAt(index); + + if (whiteSpaceQueue && has.call(markers, character)) { + break; + } + + if (isWhiteSpace(character)) { + if (commonmark) { + break; + } + + whiteSpaceQueue += character; + } else { + if (character === C_PAREN_OPEN) { + depth++; + openCount++; + } else if (character === C_PAREN_CLOSE) { + if (depth === 0) { + break; + } + + depth--; + } + + queue += whiteSpaceQueue; + whiteSpaceQueue = EMPTY; + + if (character === C_BACKSLASH) { + queue += C_BACKSLASH; + character = value.charAt(++index); + } + + queue += character; + } + + index++; + } + + queue = queue; + subvalue += queue; + url = queue; + index = subvalue.length; + } + + /* + * Eat white-space. + */ + + queue = EMPTY; + + while (index < length) { + character = value.charAt(index); + + if (!isWhiteSpace(character)) { + break; + } + + queue += character; + index++; + } + + character = value.charAt(index); + subvalue += queue; + + /* + * Eat the title. + */ + + if (queue && has.call(markers, character)) { + index++; + subvalue += character; + queue = EMPTY; + marker = markers[character]; + beforeTitle = subvalue; + + /* + * In commonmark-mode, things are pretty easy: the + * marker cannot occur inside the title. + * + * Non-commonmark does, however, support nested + * delimiters. + */ + + if (commonmark) { + while (index < length) { + character = value.charAt(index); + + if (character === marker) { + break; + } + + if (character === C_BACKSLASH) { + queue += C_BACKSLASH; + character = value.charAt(++index); + } + + index++; + queue += character; + } + + character = value.charAt(index); + + if (character !== marker) { + return; + } + + title = queue; + subvalue += queue + character; + index++; + + while (index < length) { + character = value.charAt(index); + + if (!isWhiteSpace(character)) { + break; + } + + subvalue += character; + index++; + } + } else { + whiteSpaceQueue = EMPTY; + + while (index < length) { + character = value.charAt(index); + + if (character === marker) { + if (hasMarker) { + queue += marker + whiteSpaceQueue; + whiteSpaceQueue = EMPTY; + } + + hasMarker = true; + } else if (!hasMarker) { + queue += character; + } else if (character === C_PAREN_CLOSE) { + subvalue += queue + marker + whiteSpaceQueue; + title = queue; + break; + } else if (isWhiteSpace(character)) { + whiteSpaceQueue += character; + } else { + queue += marker + whiteSpaceQueue + character; + whiteSpaceQueue = EMPTY; + hasMarker = false; + } + + index++; + } + } + } + + if (value.charAt(index) !== C_PAREN_CLOSE) { + return; + } + + /* istanbul ignore if - never used (yet) */ + if (silent) { + return true; + } + + subvalue += C_PAREN_CLOSE; + + url = self.decode.raw(self.descape(url), eat(beforeURL).test().end); + + if (title) { + beforeTitle = eat(beforeTitle).test().end; + title = self.decode.raw(self.descape(title), beforeTitle); + } + + return eat(subvalue)( + self.renderLink(!isImage, url, content, title, now, eat) + ); +} + +tokenizeLink.locator = locateLink; + +/** + * Tokenise a reference link, image, or footnote; + * shortcut reference link, or footnote. + * + * @example + * tokenizeReference(eat, '[foo]'); + * tokenizeReference(eat, '[foo][]'); + * tokenizeReference(eat, '[foo][bar]'); + * + * @property {Function} locator - Reference locator. + * @param {function(string)} eat - Eater. + * @param {string} value - Rest of content. + * @param {boolean?} [silent] - Whether this is a dry run. + * @return {Node?|boolean} - Reference node. + */ +function tokenizeReference(eat, value, silent) { + var self = this; + var character = value.charAt(0); + var index = 0; + var length = value.length; + var subvalue = EMPTY; + var intro = EMPTY; + var type = T_LINK; + var referenceType = REFERENCE_TYPE_SHORTCUT; + var text; + var identifier; + var now; + var node; + var exitLink; + var queue; + var bracketed; + var depth; + + /* + * Check whether we’re eating an image. + */ + + if (character === C_EXCLAMATION_MARK) { + type = T_IMAGE; + intro = character; + character = value.charAt(++index); + } + + if (character !== C_BRACKET_OPEN) { + return; + } + + index++; + intro += character; + queue = EMPTY; + + /* + * Check whether we’re eating a footnote. + */ + + if ( + self.options.footnotes && + type === T_LINK && + value.charAt(index) === C_CARET + ) { + intro += C_CARET; + index++; + type = T_FOOTNOTE; + } + + /* + * Eat the text. + */ + + depth = 0; + + while (index < length) { + character = value.charAt(index); + + if (character === C_BRACKET_OPEN) { + bracketed = true; + depth++; + } else if (character === C_BRACKET_CLOSE) { + if (!depth) { + break; + } + + depth--; + } + + if (character === C_BACKSLASH) { + queue += C_BACKSLASH; + character = value.charAt(++index); + } + + queue += character; + index++; + } + + subvalue = text = queue; + character = value.charAt(index); + + if (character !== C_BRACKET_CLOSE) { + return; + } + + index++; + subvalue += character; + queue = EMPTY; + + while (index < length) { + character = value.charAt(index); + + if (!isWhiteSpace(character)) { + break; + } + + queue += character; + index++; + } + + character = value.charAt(index); + + if (character !== C_BRACKET_OPEN) { + if (!text) { + return; + } + + identifier = text; + } else { + identifier = EMPTY; + queue += character; + index++; + + while (index < length) { + character = value.charAt(index); + + if ( + character === C_BRACKET_OPEN || + character === C_BRACKET_CLOSE + ) { + break; + } + + if (character === C_BACKSLASH) { + identifier += C_BACKSLASH; + character = value.charAt(++index); + } + + identifier += character; + index++; + } + + character = value.charAt(index); + + if (character === C_BRACKET_CLOSE) { + queue += identifier + character; + index++; + + referenceType = identifier ? + REFERENCE_TYPE_FULL : + REFERENCE_TYPE_COLLAPSED; + } else { + identifier = EMPTY; + } + + subvalue += queue; + queue = EMPTY; + } + + /* + * Brackets cannot be inside the identifier. + */ + + if (referenceType !== REFERENCE_TYPE_FULL && bracketed) { + return; + } + + /* + * Inline footnotes cannot have an identifier. + */ + + if (type === T_FOOTNOTE && referenceType !== REFERENCE_TYPE_SHORTCUT) { + type = T_LINK; + intro = C_BRACKET_OPEN + C_CARET; + text = C_CARET + text; + } + + subvalue = intro + subvalue; + + if (type === T_LINK && self.inLink) { + return null; + } + + /* istanbul ignore if - never used (yet) */ + if (silent) { + return true; + } + + if (type === T_FOOTNOTE && text.indexOf(C_SPACE) !== -1) { + return eat(subvalue)(self.renderFootnote(text, eat.now())); + } + + now = eat.now(); + now.column += intro.length; + identifier = referenceType === REFERENCE_TYPE_FULL ? identifier : text; + + node = { + 'type': type + 'Reference', + 'identifier': normalize(identifier) + }; + + if (type === T_LINK || type === T_IMAGE) { + node.referenceType = referenceType; + } + + if (type === T_LINK) { + exitLink = self.enterLink(); + node.children = self.tokenizeInline(text, now); + exitLink(); + } else if (type === T_IMAGE) { + node.alt = self.decode.raw(self.descape(text), now) || null; + } + + return eat(subvalue)(node); +} + +tokenizeReference.locator = locateLink; + +/** + * Find a possible strong emphasis. + * + * @example + * locateStrong('foo **bar'); // 4 + * + * @param {string} value - Value to search. + * @param {number} fromIndex - Index to start searching at. + * @return {number} - Location of possible strong emphasis. + */ +function locateStrong(value, fromIndex) { + var asterisk = value.indexOf(C_ASTERISK + C_ASTERISK, fromIndex); + var underscore = value.indexOf(C_UNDERSCORE + C_UNDERSCORE, fromIndex); + + if (underscore === -1) { + return asterisk; + } + + if (asterisk === -1) { + return underscore; + } + + return underscore < asterisk ? underscore : asterisk; +} + +/** + * Tokenise strong emphasis. + * + * @example + * tokenizeStrong(eat, '**foo**'); + * tokenizeStrong(eat, '__foo__'); + * + * @property {Function} locator - Strong emphasis locator. + * @param {function(string)} eat - Eater. + * @param {string} value - Rest of content. + * @param {boolean?} [silent] - Whether this is a dry run. + * @return {Node?|boolean} - `strong` node. + */ +function tokenizeStrong(eat, value, silent) { + var self = this; + var index = 0; + var character = value.charAt(index); + var now; + var pedantic; + var marker; + var queue; + var subvalue; + var length; + var prev; + + if ( + EMPHASIS_MARKERS[character] !== true || + value.charAt(++index) !== character + ) { + return; + } + + pedantic = self.options.pedantic; + marker = character; + subvalue = marker + marker; + length = value.length; + index++; + queue = character = EMPTY; + + if (pedantic && isWhiteSpace(value.charAt(index))) { + return; + } + + while (index < length) { + prev = character; + character = value.charAt(index); + + if ( + character === marker && + value.charAt(index + 1) === marker && + (!pedantic || !isWhiteSpace(prev)) + ) { + character = value.charAt(index + 2); + + if (character !== marker) { + if (!trim(queue)) { + return; + } + + /* istanbul ignore if - never used (yet) */ + if (silent) { + return true; + } + + now = eat.now(); + now.column += 2; + + return eat(subvalue + queue + subvalue)( + self.renderInline(T_STRONG, queue, now) + ); + } + } + + if (!pedantic && character === C_BACKSLASH) { + queue += character; + character = value.charAt(++index); + } + + queue += character; + index++; + } +} + +tokenizeStrong.locator = locateStrong; + +/** + * Find possible slight emphasis. + * + * @example + * locateEmphasis('foo *bar'); // 4 + * + * @param {string} value - Value to search. + * @param {number} fromIndex - Index to start searching at. + * @return {number} - Location of possible slight emphasis. + */ +function locateEmphasis(value, fromIndex) { + var asterisk = value.indexOf(C_ASTERISK, fromIndex); + var underscore = value.indexOf(C_UNDERSCORE, fromIndex); + + if (underscore === -1) { + return asterisk; + } + + if (asterisk === -1) { + return underscore; + } + + return underscore < asterisk ? underscore : asterisk; +} + +/** + * Tokenise slight emphasis. + * + * @example + * tokenizeEmphasis(eat, '*foo*'); + * tokenizeEmphasis(eat, '_foo_'); + * + * @property {Function} locator - Slight emphasis locator. + * @param {function(string)} eat - Eater. + * @param {string} value - Rest of content. + * @param {boolean?} [silent] - Whether this is a dry run. + * @return {Node?|boolean} - `emphasis` node. + */ +function tokenizeEmphasis(eat, value, silent) { + var self = this; + var index = 0; + var character = value.charAt(index); + var now; + var pedantic; + var marker; + var queue; + var subvalue; + var length; + var prev; + + if (EMPHASIS_MARKERS[character] !== true) { + return; + } + + pedantic = self.options.pedantic; + subvalue = marker = character; + length = value.length; + index++; + queue = character = EMPTY; + + if (pedantic && isWhiteSpace(value.charAt(index))) { + return; + } + + while (index < length) { + prev = character; + character = value.charAt(index); + + if ( + character === marker && + (!pedantic || !isWhiteSpace(prev)) + ) { + character = value.charAt(++index); + + if (character !== marker) { + if (!trim(queue) || prev === marker) { + return; + } + + if ( + pedantic || + marker !== C_UNDERSCORE || + !isWordCharacter(character) + ) { + /* istanbul ignore if - never used (yet) */ + if (silent) { + return true; + } + + now = eat.now(); + now.column++; + + return eat(subvalue + queue + marker)( + self.renderInline(T_EMPHASIS, queue, now) + ); + } + } + + queue += marker; + } + + if (!pedantic && character === C_BACKSLASH) { + queue += character; + character = value.charAt(++index); + } + + queue += character; + index++; + } +} + +tokenizeEmphasis.locator = locateEmphasis; + +/** + * Find a possible deletion. + * + * @example + * locateDeletion('foo ~~bar'); // 4 + * + * @param {string} value - Value to search. + * @param {number} fromIndex - Index to start searching at. + * @return {number} - Location of possible deletion. + */ +function locateDeletion(value, fromIndex) { + return value.indexOf(C_TILDE + C_TILDE, fromIndex); +} + +/** + * Tokenise a deletion. + * + * @example + * tokenizeDeletion(eat, '~~foo~~'); + * + * @property {Function} locator - Deletion locator. + * @param {function(string)} eat - Eater. + * @param {string} value - Rest of content. + * @param {boolean?} [silent] - Whether this is a dry run. + * @return {Node?|boolean} - `delete` node. + */ +function tokenizeDeletion(eat, value, silent) { + var self = this; + var character = EMPTY; + var previous = EMPTY; + var preceding = EMPTY; + var subvalue = EMPTY; + var index; + var length; + var now; + + if ( + !self.options.gfm || + value.charAt(0) !== C_TILDE || + value.charAt(1) !== C_TILDE || + isWhiteSpace(value.charAt(2)) + ) { + return; + } + + index = 1; + length = value.length; + now = eat.now(); + now.column += 2; + + while (++index < length) { + character = value.charAt(index); + + if ( + character === C_TILDE && + previous === C_TILDE && + (!preceding || !isWhiteSpace(preceding)) + ) { + /* istanbul ignore if - never used (yet) */ + if (silent) { + return true; + } + + return eat(C_TILDE + C_TILDE + subvalue + C_TILDE + C_TILDE)( + self.renderInline(T_DELETE, subvalue, now) + ); + } + + subvalue += previous; + preceding = previous; + previous = character; + } +} + +tokenizeDeletion.locator = locateDeletion; + +/** + * Find possible inline code. + * + * @example + * locateInlineCode('foo `bar'); // 4 + * + * @param {string} value - Value to search. + * @param {number} fromIndex - Index to start searching at. + * @return {number} - Location of possible inline code. + */ +function locateInlineCode(value, fromIndex) { + return value.indexOf(C_TICK, fromIndex); +} + +/** + * Tokenise inline code. + * + * @example + * tokenizeInlineCode(eat, '`foo()`'); + * + * @property {Function} locator - Inline code locator. + * @param {function(string)} eat - Eater. + * @param {string} value - Rest of content. + * @param {boolean?} [silent] - Whether this is a dry run. + * @return {Node?|boolean} - `inlineCode` node. + */ +function tokenizeInlineCode(eat, value, silent) { + var self = this; + var length = value.length; + var index = 0; + var queue = EMPTY; + var tickQueue = EMPTY; + var contentQueue; + var whiteSpaceQueue; + var count; + var openingCount; + var subvalue; + var character; + var found; + var next; + + while (index < length) { + if (value.charAt(index) !== C_TICK) { + break; + } + + queue += C_TICK; + index++; + } + + if (!queue) { + return; + } + + subvalue = queue; + openingCount = index; + queue = EMPTY; + next = value.charAt(index); + count = 0; + + while (index < length) { + character = next; + next = value.charAt(index + 1); + + if (character === C_TICK) { + count++; + tickQueue += character; + } else { + count = 0; + queue += character; + } + + if (count && next !== C_TICK) { + if (count === openingCount) { + subvalue += queue + tickQueue; + found = true; + break; + } + + queue += tickQueue; + tickQueue = EMPTY; + } + + index++; + } + + if (!found) { + if (openingCount % 2 !== 0) { + return; + } + + queue = EMPTY; + } + + /* istanbul ignore if - never used (yet) */ + if (silent) { + return true; + } + + contentQueue = whiteSpaceQueue = EMPTY; + length = queue.length; + index = -1; + + while (++index < length) { + character = queue.charAt(index); + + if (isWhiteSpace(character)) { + whiteSpaceQueue += character; + continue; + } + + if (whiteSpaceQueue) { + if (contentQueue) { + contentQueue += whiteSpaceQueue; + } + + whiteSpaceQueue = EMPTY; + } + + contentQueue += character; + } + + return eat(subvalue)(self.renderRaw(T_INLINE_CODE, contentQueue)); +} + +tokenizeInlineCode.locator = locateInlineCode; + +/** + * Find a possible break. + * + * @example + * locateBreak('foo \nbar'); // 3 + * + * @param {string} value - Value to search. + * @param {number} fromIndex - Index to start searching at. + * @return {number} - Location of possible break. + */ +function locateBreak(value, fromIndex) { + var index = value.indexOf(C_NEWLINE, fromIndex); + + while (index > fromIndex) { + if (value.charAt(index - 1) !== C_SPACE) { + break; + } + + index--; + } + + return index; +} + +/** + * Tokenise a break. + * + * @example + * tokenizeBreak(eat, ' \n'); + * + * @property {Function} locator - Break locator. + * @param {function(string)} eat - Eater. + * @param {string} value - Rest of content. + * @param {boolean?} [silent] - Whether this is a dry run. + * @return {Node?|boolean} - `break` node. + */ +function tokenizeBreak(eat, value, silent) { + var self = this; + var breaks = self.options.breaks; + var length = value.length; + var index = -1; + var queue = EMPTY; + var character; + + while (++index < length) { + character = value.charAt(index); + + if (character === C_NEWLINE) { + if (!breaks && index < MIN_BREAK_LENGTH) { + return; + } + + /* istanbul ignore if - never used (yet) */ + if (silent) { + return true; + } + + queue += character; + return eat(queue)(self.renderVoid(T_BREAK)); + } + + if (character !== C_SPACE) { + return; + } + + queue += character; + } +} + +tokenizeBreak.locator = locateBreak; + +/** + * Construct a new parser. + * + * @example + * var parser = new Parser(new VFile('Foo')); + * + * @constructor + * @class {Parser} + * @param {VFile} file - File to parse. + * @param {Object?} [options] - Passed to + * `Parser#setOptions()`. + */ +function Parser(file, options, processor) { + var self = this; + + self.file = file; + self.inLink = false; + self.atTop = true; + self.atStart = true; + self.inBlockquote = false; + self.data = processor.data; + + self.descape = descapeFactory(self, 'escape'); + self.decode = decodeFactory(self); + + self.options = extend({}, self.options); + + self.setOptions(options); +} + +/** + * Set options. Does not overwrite previously set + * options. + * + * @example + * var parser = new Parser(); + * parser.setOptions({gfm: true}); + * + * @this {Parser} + * @throws {Error} - When an option is invalid. + * @param {Object?} [options] - Parse settings. + * @return {Parser} - `self`. + */ +Parser.prototype.setOptions = function (options) { + var self = this; + var escape = self.data.escape; + var current = self.options; + var key; + + if (options === null || options === undefined) { + options = {}; + } else if (typeof options === 'object') { + options = extend({}, options); + } else { + raise(options, 'options'); + } + + for (key in defaultOptions) { + validate.boolean(options, key, current[key]); + } + + self.options = options; + + if (options.commonmark) { + self.escape = escape.commonmark; + } else if (options.gfm) { + self.escape = escape.gfm; + } else { + self.escape = escape.default; + } + + return self; +}; + +/* + * Expose `defaults`. + */ + +Parser.prototype.options = defaultOptions; + +/** + * Factory to track indentation for each line corresponding + * to the given `start` and the number of invocations. + * + * @param {number} start - Starting line. + * @return {function(offset)} - Indenter. + */ +Parser.prototype.indent = function (start) { + var self = this; + var line = start; + + /** + * Intender which increments the global offset, + * starting at the bound line, and further incrementing + * each line for each invocation. + * + * @example + * indenter(2); + * + * @param {number} offset - Number to increment the + * offset. + */ + function indenter(offset) { + self.offset[line] = (self.offset[line] || 0) + offset; + + line++; + } + + return indenter; +}; + +/** + * Get found offsets starting at `start`. + * + * @param {number} start - Starting line. + * @return {Array.} - Offsets starting at `start`. + */ +Parser.prototype.getIndent = function (start) { + var offset = this.offset; + var result = []; + + while (++start) { + if (!(start in offset)) { + break; + } + + result.push((offset[start] || 0) + 1); + } + + return result; +}; + +/** + * Parse the bound file. + * + * @example + * new Parser(new File('_Foo_.')).parse(); + * + * @this {Parser} + * @return {Object} - `root` node. + */ +Parser.prototype.parse = function () { + var self = this; + var value = clean(String(self.file)); + var node; + + /* + * Add an `offset` matrix, used to keep track of + * syntax and white space indentation per line. + */ + + self.offset = {}; + + node = self.renderBlock(T_ROOT, value); + + if (self.options.position) { + node.position = { + 'start': { + 'line': 1, + 'column': 1 + } + }; + + node.position.end = self.eof || node.position.start; + } + + return node; +}; + +/* + * Enter and exit helpers. + */ + +Parser.prototype.enterLink = stateToggler('inLink', false); +Parser.prototype.exitTop = stateToggler('atTop', true); +Parser.prototype.exitStart = stateToggler('atStart', true); +Parser.prototype.enterBlockquote = stateToggler('inBlockquote', false); + +/* + * Expose helpers + */ + +Parser.prototype.renderRaw = renderRaw; +Parser.prototype.renderVoid = renderVoid; +Parser.prototype.renderParent = renderParent; +Parser.prototype.renderInline = renderInline; +Parser.prototype.renderBlock = renderBlock; + +Parser.prototype.renderLink = renderLink; +Parser.prototype.renderCodeBlock = renderCodeBlock; +Parser.prototype.renderBlockquote = renderBlockquote; +Parser.prototype.renderListItem = renderListItem; +Parser.prototype.renderFootnoteDefinition = renderFootnoteDefinition; +Parser.prototype.renderHeading = renderHeading; +Parser.prototype.renderFootnote = renderFootnote; + +/** + * Construct a tokenizer. This creates both + * `tokenizeInline` and `tokenizeBlock`. + * + * @example + * Parser.prototype.tokenizeInline = tokenizeFactory('inline'); + * + * @param {string} type - Name of parser, used to find + * its expressions (`%sMethods`) and tokenizers + * (`%Tokenizers`). + * @return {Function} - Tokenizer. + */ +function tokenizeFactory(type) { + /** + * Tokenizer for a bound `type` + * + * @example + * parser = new Parser(); + * parser.tokenizeInline('_foo_'); + * + * @param {string} value - Content. + * @param {Object?} [location] - Offset at which `value` + * starts. + * @return {Array.} - Nodes. + */ + function tokenize(value, location) { + var self = this; + var offset = self.offset; + var tokens = []; + var methods = self[type + 'Methods']; + var tokenizers = self[type + 'Tokenizers']; + var line = location ? location.line : 1; + var column = location ? location.column : 1; + var patchPosition = self.options.position; + var add; + var index; + var length; + var method; + var name; + var matched; + var valueLength; + var eater; + + /* + * Trim white space only lines. + */ + + if (!value) { + return tokens; + } + + /** + * Update line and column based on `value`. + * + * @example + * updatePosition('foo'); + * + * @param {string} subvalue - Subvalue to eat. + */ + function updatePosition(subvalue) { + var lastIndex = -1; + var index = subvalue.indexOf(C_NEWLINE); + + while (index !== -1) { + line++; + lastIndex = index; + index = subvalue.indexOf(C_NEWLINE, index + 1); + } + + if (lastIndex === -1) { + column = column + subvalue.length; + } else { + column = subvalue.length - lastIndex; + } + + if (line in offset) { + if (lastIndex !== -1) { + column += offset[line]; + } else if (column <= offset[line]) { + column = offset[line] + 1; + } + } + } + + /** + * Get offset. Called before the first character is + * eaten to retrieve the range's offsets. + * + * @return {Function} - `done`, to be called when + * the last character is eaten. + */ + function getOffset() { + var indentation = []; + var pos = line + 1; + + /** + * Done. Called when the last character is + * eaten to retrieve the range’s offsets. + * + * @return {Array.} - Offset. + */ + function done() { + var last = line + 1; + + while (pos < last) { + indentation.push((offset[pos] || 0) + 1); + + pos++; + } + + return indentation; + } + + return done; + } + + /** + * Get the current position. + * + * @example + * position = now(); // {line: 1, column: 1} + * + * @return {Object} - Current Position. + */ + function now() { + return { + 'line': line, + 'column': column + }; + } + + /** + * Store position information for a node. + * + * @example + * start = now(); + * updatePosition('foo'); + * location = new Position(start); + * // {start: {line: 1, column: 1}, end: {line: 1, column: 3}} + * + * @param {Object} start - Starting position. + */ + function Position(start) { + this.start = start; + this.end = now(); + } + + /** + * Throw when a value is incorrectly eaten. + * This shouldn’t happen but will throw on new, + * incorrect rules. + * + * @example + * // When the current value is set to `foo bar`. + * validateEat('foo'); + * eat('foo'); + * + * validateEat('bar'); + * // throws, because the space is not eaten. + * + * @param {string} subvalue - Value to be eaten. + * @throws {Error} - When `subvalue` cannot be eaten. + */ + function validateEat(subvalue) { + /* istanbul ignore if */ + if (value.substring(0, subvalue.length) !== subvalue) { + self.file.fail(ERR_INCORRECTLY_EATEN, now()); + } + } + + /** + * Mark position and patch `node.position`. + * + * @example + * var update = position(); + * updatePosition('foo'); + * update({}); + * // { + * // position: { + * // start: {line: 1, column: 1} + * // end: {line: 1, column: 3} + * // } + * // } + * + * @returns {Function} - Updater. + */ + function position() { + var before = now(); + + /** + * Add the position to a node. + * + * @example + * update({type: 'text', value: 'foo'}); + * + * @param {Node} node - Node to attach position + * on. + * @param {Array} [indent] - Indentation for + * `node`. + * @return {Node} - `node`. + */ + function update(node, indent) { + var prev = node.position; + var start = prev ? prev.start : before; + var combined = []; + var n = prev && prev.end.line; + var l = before.line; + + node.position = new Position(start); + + /* + * If there was already a `position`, this + * node was merged. Fixing `start` wasn’t + * hard, but the indent is different. + * Especially because some information, the + * indent between `n` and `l` wasn’t + * tracked. Luckily, that space is + * (should be?) empty, so we can safely + * check for it now. + */ + + if (prev && indent && prev.indent) { + combined = prev.indent; + + if (n < l) { + while (++n < l) { + combined.push((offset[n] || 0) + 1); + } + + combined.push(before.column); + } + + indent = combined.concat(indent); + } + + node.position.indent = indent || []; + + return node; + } + + return update; + } + + /** + * Add `node` to `parent`s children or to `tokens`. + * Performs merges where possible. + * + * @example + * add({}); + * + * add({}, {children: []}); + * + * @param {Object} node - Node to add. + * @param {Object} [parent] - Parent to insert into. + * @return {Object} - Added or merged into node. + */ + add = function (node, parent) { + var prev; + var children; + + if (!parent) { + children = tokens; + } else { + children = parent.children; + } + + prev = children[children.length - 1]; + + if ( + prev && + node.type === prev.type && + node.type in MERGEABLE_NODES && + mergeable(prev) && + mergeable(node) + ) { + node = MERGEABLE_NODES[node.type].call( + self, prev, node + ); + } + + if (node !== prev) { + children.push(node); + } + + if (self.atStart && tokens.length) { + self.exitStart(); + } + + return node; + }; + + /** + * Remove `subvalue` from `value`. + * Expects `subvalue` to be at the start from + * `value`, and applies no validation. + * + * @example + * eat('foo')({type: 'text', value: 'foo'}); + * + * @param {string} subvalue - Removed from `value`, + * and passed to `updatePosition`. + * @return {Function} - Wrapper around `add`, which + * also adds `position` to node. + */ + function eat(subvalue) { + var indent = getOffset(); + var pos = position(); + var current = now(); + + validateEat(subvalue); + + /** + * Add the given arguments, add `position` to + * the returned node, and return the node. + * + * @param {Object} node - Node to add. + * @param {Object} [parent] - Node to insert into. + * @return {Node} - Added node. + */ + function apply(node, parent) { + return pos(add(pos(node), parent), indent); + } + + /** + * Functions just like apply, but resets the + * content: the line and column are reversed, + * and the eaten value is re-added. + * + * This is useful for nodes with a single + * type of content, such as lists and tables. + * + * See `apply` above for what parameters are + * expected. + * + * @return {Node} - Added node. + */ + function reset() { + var node = apply.apply(null, arguments); + + line = current.line; + column = current.column; + value = subvalue + value; + + return node; + } + + /** + * Test the position, after eating, and reverse + * to a not-eaten state. + * + * @return {Position} - Position after eating `subvalue`. + */ + function test() { + var result = pos({}); + + line = current.line; + column = current.column; + value = subvalue + value; + + return result.position; + } + + apply.reset = reset; + apply.test = reset.test = test; + + value = value.substring(subvalue.length); + + updatePosition(subvalue); + + indent = indent(); + + return apply; + } + + /** + * Same as `eat` above, but will not add positional + * information to nodes. + * + * @example + * noEat('foo')({type: 'text', value: 'foo'}); + * + * @param {string} subvalue - Removed from `value`. + * @return {Function} - Wrapper around `add`. + */ + function noEat(subvalue) { + validateEat(subvalue); + + /** + * Add the given arguments, and return the + * node. + * + * @return {Node} - Added node. + */ + function apply() { + return add.apply(null, arguments); + } + + /** + * Functions just like apply, but resets the + * content: the eaten value is re-added. + * + * @return {Node} - Added node. + */ + function reset() { + var node = apply.apply(null, arguments); + + value = subvalue + value; + + return node; + } + + /** + * Test the position, which in this mode is an + * empty object. + * + * @return {Object} - Empty position object. + */ + function test() { + value = subvalue + value; + + return {}; + } + + apply.reset = reset; + apply.test = reset.test = test; + + value = value.substring(subvalue.length); + + return apply; + } + + /* + * Expose the eater, depending on if `position`s + * should be patched on nodes. + */ + + eater = patchPosition ? eat : noEat; + + /* + * Expose `now` on `eater`. + */ + + eater.now = now; + + /* + * Expose `file` on `eater`. + */ + + eater.file = self.file; + + /* + * Sync initial offset. + */ + + updatePosition(EMPTY); + + /* + * Iterate over `value`, and iterate over all + * tokenizers. When one eats something, re-iterate + * with the remaining value. If no tokenizer eats, + * something failed (should not happen) and an + * exception is thrown. + */ + + while (value) { + index = -1; + length = methods.length; + matched = false; + + while (++index < length) { + name = methods[index]; + method = tokenizers[name]; + + if ( + method && + (!method.onlyAtStart || self.atStart) && + (!method.onlyAtTop || self.atTop) && + (!method.notInBlockquote || !self.inBlockquote) && + (!method.notInLink || !self.inLink) + ) { + valueLength = value.length; + + method.apply(self, [eater, value]); + + matched = valueLength !== value.length; + + if (matched) { + break; + } + } + } + + /* istanbul ignore if */ + if (!matched) { + self.file.fail(ERR_INFINITE_LOOP, eater.now()); + + /* + * Errors are not thrown on `File#fail` + * when `quiet: true`. + */ + + break; + } + } + + self.eof = now(); + + return tokens; + } + + return tokenize; +} + +/* + * Expose tokenizers for block-level nodes. + */ + +Parser.prototype.blockTokenizers = { + 'yamlFrontMatter': tokenizeYAMLFrontMatter, + 'newline': tokenizeNewline, + 'code': tokenizeCode, + 'fences': tokenizeFences, + 'heading': tokenizeHeading, + 'lineHeading': tokenizeLineHeading, + 'horizontalRule': tokenizeHorizontalRule, + 'blockquote': tokenizeBlockquote, + 'list': tokenizeList, + 'html': tokenizeHTML, + 'definition': tokenizeDefinition, + 'footnoteDefinition': tokenizeFootnoteDefinition, + 'table': tokenizeTable, + 'paragraph': tokenizeParagraph +}; + +/* + * Expose order in which to parse block-level nodes. + */ + +Parser.prototype.blockMethods = [ + 'yamlFrontMatter', + 'newline', + 'code', + 'fences', + 'blockquote', + 'heading', + 'horizontalRule', + 'list', + 'lineHeading', + 'html', + 'footnoteDefinition', + 'definition', + 'looseTable', + 'table', + 'paragraph' +]; + +/** + * Block tokenizer. + * + * @example + * var parser = new Parser(); + * parser.tokenizeBlock('> foo.'); + * + * @param {string} value - Content. + * @return {Array.} - Nodes. + */ + +Parser.prototype.tokenizeBlock = tokenizeFactory(BLOCK); + +/* + * Expose tokenizers for inline-level nodes. + */ + +Parser.prototype.inlineTokenizers = { + 'escape': tokenizeEscape, + 'autoLink': tokenizeAutoLink, + 'url': tokenizeURL, + 'tag': tokenizeTag, + 'link': tokenizeLink, + 'reference': tokenizeReference, + 'strong': tokenizeStrong, + 'emphasis': tokenizeEmphasis, + 'deletion': tokenizeDeletion, + 'inlineCode': tokenizeInlineCode, + 'break': tokenizeBreak, + 'inlineText': tokenizeText +}; + +/* + * Expose order in which to parse inline-level nodes. + */ + +Parser.prototype.inlineMethods = [ + 'escape', + 'autoLink', + 'url', + 'tag', + 'link', + 'reference', + 'shortcutReference', + 'strong', + 'emphasis', + 'deletion', + 'inlineCode', + 'break', + 'inlineText' +]; + +/** + * Inline tokenizer. + * + * @example + * var parser = new Parser(); + * parser.tokenizeInline('_foo_'); + * + * @param {string} value - Content. + * @return {Array.} - Nodes. + */ + +Parser.prototype.tokenizeInline = tokenizeFactory(INLINE); + +/* + * Expose `tokenizeFactory` so dependencies could create + * their own tokenizers. + */ + +Parser.prototype.tokenizeFactory = tokenizeFactory; + +/* + * Expose `parse` on `module.exports`. + */ + +module.exports = Parser; diff --git a/tools/node_modules/remark/lib/stringify.js b/tools/node_modules/remark/lib/stringify.js new file mode 100644 index 00000000000000..d5b7389301d1b1 --- /dev/null +++ b/tools/node_modules/remark/lib/stringify.js @@ -0,0 +1,2250 @@ +/** + * @author Titus Wormer + * @copyright 2015-2016 Titus Wormer + * @license MIT + * @module remark:stringify + * @version 3.2.2 + * @fileoverview Compile an abstract syntax tree into + * a markdown document. + */ + +'use strict'; + +/* eslint-env commonjs */ + +/* + * Dependencies. + */ + +var decode = require('parse-entities'); +var encode = require('stringify-entities'); +var table = require('markdown-table'); +var repeat = require('repeat-string'); +var extend = require('extend.js'); +var ccount = require('ccount'); +var longestStreak = require('longest-streak'); +var utilities = require('./utilities.js'); +var defaultOptions = require('./defaults.js').stringify; + +/* + * Methods. + */ + +var raise = utilities.raise; +var validate = utilities.validate; +var stateToggler = utilities.stateToggler; +var mergeable = utilities.mergeable; +var MERGEABLE_NODES = utilities.MERGEABLE_NODES; + +/* + * Constants. + */ + +var INDENT = 4; +var MINIMUM_CODE_FENCE_LENGTH = 3; +var YAML_FENCE_LENGTH = 3; +var MINIMUM_RULE_LENGTH = 3; +var MAILTO = 'mailto:'; +var ERROR_LIST_ITEM_INDENT = 'Cannot indent code properly. See ' + + 'http://git.io/mdast-lii'; + +/* + * Expressions. + */ + +var EXPRESSIONS_WHITE_SPACE = /\s/; + +/* + * Naive fence expression. + */ + +var FENCE = /([`~])\1{2}/; + +/* + * Expression for a protocol. + * + * @see http://en.wikipedia.org/wiki/URI_scheme#Generic_syntax + */ + +var PROTOCOL = /^[a-z][a-z+.-]+:\/?/i; + +/* + * Punctuation characters. + */ + +var PUNCTUATION = /[-!"#$%&'()*+,.\/:;<=>?@\[\\\]^`{|}~_]/; + +/* + * Characters. + */ + +var ANGLE_BRACKET_CLOSE = '>'; +var ANGLE_BRACKET_OPEN = '<'; +var ASTERISK = '*'; +var BACKSLASH = '\\'; +var CARET = '^'; +var COLON = ':'; +var SEMICOLON = ';'; +var DASH = '-'; +var DOT = '.'; +var EMPTY = ''; +var EQUALS = '='; +var EXCLAMATION_MARK = '!'; +var HASH = '#'; +var AMPERSAND = '&'; +var LINE = '\n'; +var CARRIAGE = '\r'; +var FORM_FEED = '\f'; +var PARENTHESIS_OPEN = '('; +var PARENTHESIS_CLOSE = ')'; +var PIPE = '|'; +var PLUS = '+'; +var QUOTE_DOUBLE = '"'; +var QUOTE_SINGLE = '\''; +var SPACE = ' '; +var TAB = '\t'; +var VERTICAL_TAB = '\u000B'; +var SQUARE_BRACKET_OPEN = '['; +var SQUARE_BRACKET_CLOSE = ']'; +var TICK = '`'; +var TILDE = '~'; +var UNDERSCORE = '_'; + +/* + * Entities. + */ + +var ENTITY_AMPERSAND = AMPERSAND + 'amp' + SEMICOLON; +var ENTITY_ANGLE_BRACKET_OPEN = AMPERSAND + 'lt' + SEMICOLON; +var ENTITY_COLON = AMPERSAND + '#x3A' + SEMICOLON; + +/* + * Character combinations. + */ + +var BREAK = LINE + LINE; +var GAP = BREAK + LINE; +var DOUBLE_TILDE = TILDE + TILDE; + +/* + * Allowed entity options. + */ + +var ENTITY_OPTIONS = {}; + +ENTITY_OPTIONS.true = true; +ENTITY_OPTIONS.false = true; +ENTITY_OPTIONS.numbers = true; +ENTITY_OPTIONS.escape = true; + +/* + * Allowed list-bullet characters. + */ + +var LIST_BULLETS = {}; + +LIST_BULLETS[ASTERISK] = true; +LIST_BULLETS[DASH] = true; +LIST_BULLETS[PLUS] = true; + +/* + * Allowed horizontal-rule bullet characters. + */ + +var HORIZONTAL_RULE_BULLETS = {}; + +HORIZONTAL_RULE_BULLETS[ASTERISK] = true; +HORIZONTAL_RULE_BULLETS[DASH] = true; +HORIZONTAL_RULE_BULLETS[UNDERSCORE] = true; + +/* + * Allowed emphasis characters. + */ + +var EMPHASIS_MARKERS = {}; + +EMPHASIS_MARKERS[UNDERSCORE] = true; +EMPHASIS_MARKERS[ASTERISK] = true; + +/* + * Allowed fence markers. + */ + +var FENCE_MARKERS = {}; + +FENCE_MARKERS[TICK] = true; +FENCE_MARKERS[TILDE] = true; + +/* + * Which method to use based on `list.ordered`. + */ + +var ORDERED_MAP = {}; + +ORDERED_MAP.true = 'visitOrderedItems'; +ORDERED_MAP.false = 'visitUnorderedItems'; + +/* + * Allowed list-item-indent's. + */ + +var LIST_ITEM_INDENTS = {}; + +var LIST_ITEM_TAB = 'tab'; +var LIST_ITEM_ONE = '1'; +var LIST_ITEM_MIXED = 'mixed'; + +LIST_ITEM_INDENTS[LIST_ITEM_ONE] = true; +LIST_ITEM_INDENTS[LIST_ITEM_TAB] = true; +LIST_ITEM_INDENTS[LIST_ITEM_MIXED] = true; + +/* + * Which checkbox to use. + */ + +var CHECKBOX_MAP = {}; + +CHECKBOX_MAP.null = EMPTY; +CHECKBOX_MAP.undefined = EMPTY; +CHECKBOX_MAP.true = SQUARE_BRACKET_OPEN + 'x' + SQUARE_BRACKET_CLOSE + SPACE; +CHECKBOX_MAP.false = SQUARE_BRACKET_OPEN + SPACE + SQUARE_BRACKET_CLOSE + + SPACE; + +/** + * Encode noop. + * Simply returns the given value. + * + * @example + * var encode = encodeNoop(); + * encode('AT&T') // 'AT&T' + * + * @param {string} value - Content. + * @return {string} - Content, without any modifications. + */ +function encodeNoop(value) { + return value; +} + +/** + * Factory to encode HTML entities. + * Creates a no-operation function when `type` is + * `'false'`, a function which encodes using named + * references when `type` is `'true'`, and a function + * which encodes using numbered references when `type` is + * `'numbers'`. + * + * @example + * encodeFactory('false')('AT&T') // 'AT&T' + * encodeFactory('true')('AT&T') // 'AT&T' + * encodeFactory('numbers')('AT&T') // 'ATT&T' + * + * @param {string} type - Either `'true'`, `'false'`, or + * `'numbers'`. + * @return {function(string): string} - Function which + * takes a value and returns its encoded version. + */ +function encodeFactory(type) { + var options = {}; + + if (type === 'false') { + return encodeNoop; + } + + if (type === 'true') { + options.useNamedReferences = true; + } + + if (type === 'escape') { + options.escapeOnly = options.useNamedReferences = true; + } + + /** + * Encode HTML entities using `he` using bound options. + * + * @see https://github.com/mathiasbynens/he#strict + * + * @example + * // When `type` is `'true'`. + * encode('AT&T'); // 'AT&T' + * + * // When `type` is `'numbers'`. + * encode('AT&T'); // 'ATT&T' + * + * @param {string} value - Content. + * @param {Object} [node] - Node which is compiled. + * @return {string} - Encoded content. + * @throws {Error} - When `file.quiet` is not `true`. + * However, by default `he` does not throw on + * parse errors, but when + * `he.encode.options.strict: true`, they occur on + * invalid HTML. + */ + function encoder(value) { + return encode(value, options); + } + + return encoder; +} + +/** + * Check if a string starts with HTML entity. + * + * @example + * startsWithEntity('©cat') // true + * startsWithEntity('&foo & &bar') // false + * + * @param {string} value - Value to check. + * @return {boolean} - Whether `value` starts an entity. + */ +function startsWithEntity(value) { + var prefix; + + /* istanbul ignore if - Currently also tested for at + * implemention, but we keep it here because that’s + * proper. */ + if (value.charAt(0) !== AMPERSAND) { + return false; + } + + prefix = value.split(AMPERSAND, 2).join(AMPERSAND); + + return decode(prefix).length !== prefix.length; +} + +/** + * Check if `character` is a valid alignment row character. + * + * @example + * isAlignmentRowCharacter(':') // true + * isAlignmentRowCharacter('=') // false + * + * @param {string} character - Character to check. + * @return {boolean} - Whether `character` is a valid + * alignment row character. + */ +function isAlignmentRowCharacter(character) { + return character === COLON || + character === DASH || + character === SPACE || + character === PIPE; +} + +/** + * Check if `index` in `value` is inside an alignment row. + * + * @example + * isInAlignmentRow(':--:', 2) // true + * isInAlignmentRow(':--:\n:-*-:', 9) // false + * + * @param {string} value - Value to check. + * @param {number} index - Position in `value` to check. + * @return {boolean} - Whether `index` in `value` is in + * an alignment row. + */ +function isInAlignmentRow(value, index) { + var length = value.length; + var start = index; + var character; + + while (++index < length) { + character = value.charAt(index); + + if (character === LINE) { + break; + } + + if (!isAlignmentRowCharacter(character)) { + return false; + } + } + + index = start; + + while (--index > -1) { + character = value.charAt(index); + + if (character === LINE) { + break; + } + + if (!isAlignmentRowCharacter(character)) { + return false; + } + } + + return true; +} + +/** + * Factory to escape characters. + * + * @example + * var escape = escapeFactory({ commonmark: true }); + * escape('x*x', { type: 'text', value: 'x*x' }) // 'x\\*x' + * + * @param {Object} options - Compiler options. + * @return {function(value, node, parent): string} - Function which + * takes a value and a node and (optionally) its parent and returns + * its escaped value. + */ +function escapeFactory(options) { + /** + * Escape punctuation characters in a node's value. + * + * @param {string} value - Value to escape. + * @param {Object} node - Node in which `value` exists. + * @param {Object} [parent] - Parent of `node`. + * @return {string} - Escaped `value`. + */ + return function escape(value, node, parent) { + var self = this; + var gfm = options.gfm; + var commonmark = options.commonmark; + var siblings = parent && parent.children; + var index = siblings && siblings.indexOf(node); + var prev = siblings && siblings[index - 1]; + var next = siblings && siblings[index + 1]; + var length = value.length; + var position = -1; + var queue = []; + var escaped = queue; + var afterNewLine; + var character; + + if (prev) { + afterNewLine = prev.type === 'text' && /\n\s*$/.test(prev.value); + } else if (parent) { + afterNewLine = parent.type === 'paragraph'; + } + + while (++position < length) { + character = value.charAt(position); + + if ( + character === BACKSLASH || + character === TICK || + character === ASTERISK || + character === SQUARE_BRACKET_OPEN || + character === UNDERSCORE || + (self.inLink && character === SQUARE_BRACKET_CLOSE) || + ( + gfm && + character === PIPE && + ( + self.inTable || + isInAlignmentRow(value, position) + ) + ) + ) { + afterNewLine = false; + queue.push(BACKSLASH); + } else if (character === ANGLE_BRACKET_OPEN) { + afterNewLine = false; + + if (commonmark) { + queue.push(BACKSLASH); + } else { + queue.push(ENTITY_ANGLE_BRACKET_OPEN); + continue; + } + } else if ( + gfm && + !self.inLink && + character === COLON && + ( + queue.slice(-6).join(EMPTY) === 'mailto' || + queue.slice(-5).join(EMPTY) === 'https' || + queue.slice(-4).join(EMPTY) === 'http' + ) + ) { + afterNewLine = false; + + if (commonmark) { + queue.push(BACKSLASH); + } else { + queue.push(ENTITY_COLON); + continue; + } + /* istanbul ignore if - Impossible to test with + * the current set-up. We need tests which try + * to force markdown content into the tree. */ + } else if ( + character === AMPERSAND && + startsWithEntity(value.slice(position)) + ) { + afterNewLine = false; + + if (commonmark) { + queue.push(BACKSLASH); + } else { + queue.push(ENTITY_AMPERSAND); + continue; + } + } else if ( + gfm && + character === TILDE && + value.charAt(position + 1) === TILDE + ) { + queue.push(BACKSLASH, TILDE); + afterNewLine = false; + position += 1; + } else if (character === LINE) { + afterNewLine = true; + } else if (afterNewLine) { + if ( + character === ANGLE_BRACKET_CLOSE || + character === HASH || + LIST_BULLETS[character] + ) { + queue.push(BACKSLASH); + afterNewLine = false; + } else if ( + character !== SPACE && + character !== TAB && + character !== CARRIAGE && + character !== VERTICAL_TAB && + character !== FORM_FEED + ) { + afterNewLine = false; + } + } + + queue.push(character); + } + + /* + * Multi-node versions. + */ + + if (siblings && node.type === 'text') { + /* + * Check for an opening parentheses after a + * link-reference (which can be joined by + * white-space). + */ + + if ( + prev && + prev.referenceType === 'shortcut' + ) { + position = -1; + length = escaped.length; + + while (++position < length) { + character = escaped[position]; + + if (character === SPACE || character === TAB) { + continue; + } + + if (character === PARENTHESIS_OPEN) { + escaped[position] = BACKSLASH + character; + } + + if (character === COLON) { + if (commonmark) { + escaped[position] = BACKSLASH + character; + } else { + escaped[position] = ENTITY_COLON; + } + } + + break; + } + } + + /* + * Ensure non-auto-links are not seen as links. + * This pattern needs to check the preceding + * nodes too. + */ + + if ( + gfm && + !self.inLink && + prev && + prev.type === 'text' && + value.charAt(0) === COLON + ) { + queue = prev.value.slice(-6); + + if ( + queue === 'mailto' || + queue.slice(-5) === 'https' || + queue.slice(-4) === 'http' + ) { + if (commonmark) { + escaped.unshift(BACKSLASH); + } else { + escaped.splice(0, 1, ENTITY_COLON); + } + } + } + + /* + * Escape ampersand if it would otherwise + * start an entity. + */ + + if ( + next && + next.type === 'text' && + value.slice(-1) === AMPERSAND && + startsWithEntity(AMPERSAND + next.value) + ) { + if (commonmark) { + escaped.splice(escaped.length - 1, 0, BACKSLASH); + } else { + escaped.push('amp', SEMICOLON); + } + } + + /* + * Escape double tildes in GFM. + */ + + if ( + gfm && + next && + next.type === 'text' && + value.slice(-1) === TILDE && + next.value.charAt(0) === TILDE + ) { + escaped.splice(escaped.length - 1, 0, BACKSLASH); + } + } + + return escaped.join(EMPTY); + }; +} + +/** + * Wrap `url` in angle brackets when needed, or when + * forced. + * + * In links, images, and definitions, the URL part needs + * to be enclosed when it: + * + * - has a length of `0`; + * - contains white-space; + * - has more or less opening than closing parentheses. + * + * @example + * encloseURI('foo bar') // '' + * encloseURI('foo(bar(baz)') // '' + * encloseURI('') // '<>' + * encloseURI('example.com') // 'example.com' + * encloseURI('example.com', true) // '' + * + * @param {string} uri - URI to enclose. + * @param {boolean?} [always] - Force enclosing. + * @return {boolean} - Properly enclosed `uri`. + */ +function encloseURI(uri, always) { + if ( + always || + !uri.length || + EXPRESSIONS_WHITE_SPACE.test(uri) || + ccount(uri, PARENTHESIS_OPEN) !== ccount(uri, PARENTHESIS_CLOSE) + ) { + return ANGLE_BRACKET_OPEN + uri + ANGLE_BRACKET_CLOSE; + } + + return uri; +} + +/** + * There is currently no way to support nested delimiters + * across Markdown.pl, CommonMark, and GitHub (RedCarpet). + * The following code supports Markdown.pl and GitHub. + * CommonMark is not supported when mixing double- and + * single quotes inside a title. + * + * @see https://github.com/vmg/redcarpet/issues/473 + * @see https://github.com/jgm/CommonMark/issues/308 + * + * @example + * encloseTitle('foo') // '"foo"' + * encloseTitle('foo \'bar\' baz') // '"foo \'bar\' baz"' + * encloseTitle('foo "bar" baz') // '\'foo "bar" baz\'' + * encloseTitle('foo "bar" \'baz\'') // '"foo "bar" \'baz\'"' + * + * @param {string} title - Content. + * @return {string} - Properly enclosed title. + */ +function encloseTitle(title) { + var delimiter = QUOTE_DOUBLE; + + if (title.indexOf(delimiter) !== -1) { + delimiter = QUOTE_SINGLE; + } + + return delimiter + title + delimiter; +} + +/** + * Pad `value` with `level * INDENT` spaces. Respects + * lines. Ignores empty lines. + * + * @example + * pad('foo', 1) // ' foo' + * + * @param {string} value - Content. + * @param {number} level - Indentation level. + * @return {string} - Padded `value`. + */ +function pad(value, level) { + var index; + var padding; + + value = value.split(LINE); + + index = value.length; + padding = repeat(SPACE, level * INDENT); + + while (index--) { + if (value[index].length !== 0) { + value[index] = padding + value[index]; + } + } + + return value.join(LINE); +} + +/** + * Construct a new compiler. + * + * @example + * var compiler = new Compiler(new File('> foo.')); + * + * @constructor + * @class {Compiler} + * @param {File} file - Virtual file. + * @param {Object?} [options] - Passed to + * `Compiler#setOptions()`. + */ +function Compiler(file, options) { + var self = this; + + self.file = file; + + self.options = extend({}, self.options); + + self.setOptions(options); +} + +/* + * Cache prototype. + */ + +var compilerPrototype = Compiler.prototype; + +/* + * Expose defaults. + */ + +compilerPrototype.options = defaultOptions; + +/* + * Map of applicable enum's. + */ + +var maps = { + 'entities': ENTITY_OPTIONS, + 'bullet': LIST_BULLETS, + 'rule': HORIZONTAL_RULE_BULLETS, + 'listItemIndent': LIST_ITEM_INDENTS, + 'emphasis': EMPHASIS_MARKERS, + 'strong': EMPHASIS_MARKERS, + 'fence': FENCE_MARKERS +}; + +/** + * Set options. Does not overwrite previously set + * options. + * + * @example + * var compiler = new Compiler(); + * compiler.setOptions({bullet: '*'}); + * + * @this {Compiler} + * @throws {Error} - When an option is invalid. + * @param {Object?} [options] - Stringify settings. + * @return {Compiler} - `self`. + */ +compilerPrototype.setOptions = function (options) { + var self = this; + var current = self.options; + var ruleRepetition; + var key; + + if (options === null || options === undefined) { + options = {}; + } else if (typeof options === 'object') { + options = extend({}, options); + } else { + raise(options, 'options'); + } + + for (key in defaultOptions) { + validate[typeof current[key]]( + options, key, current[key], maps[key] + ); + } + + ruleRepetition = options.ruleRepetition; + + if (ruleRepetition && ruleRepetition < MINIMUM_RULE_LENGTH) { + raise(ruleRepetition, 'options.ruleRepetition'); + } + + self.encode = encodeFactory(String(options.entities)); + self.escape = escapeFactory(options); + + self.options = options; + + return self; +}; + +/* + * Enter and exit helpers. + */ + +compilerPrototype.enterLink = stateToggler('inLink', false); +compilerPrototype.enterTable = stateToggler('inTable', false); + +/** + * Visit a node. + * + * @example + * var compiler = new Compiler(); + * + * compiler.visit({ + * type: 'strong', + * children: [{ + * type: 'text', + * value: 'Foo' + * }] + * }); + * // '**Foo**' + * + * @param {Object} node - Node. + * @param {Object?} [parent] - `node`s parent. + * @return {string} - Compiled `node`. + */ +compilerPrototype.visit = function (node, parent) { + var self = this; + + /* + * Fail on unknown nodes. + */ + + if (typeof self[node.type] !== 'function') { + self.file.fail( + 'Missing compiler for node of type `' + + node.type + '`: `' + node + '`', + node + ); + } + + return self[node.type](node, parent); +}; + +/** + * Visit all children of `parent`. + * + * @example + * var compiler = new Compiler(); + * + * compiler.all({ + * type: 'strong', + * children: [{ + * type: 'text', + * value: 'Foo' + * }, + * { + * type: 'text', + * value: 'Bar' + * }] + * }); + * // ['Foo', 'Bar'] + * + * @param {Object} parent - Parent node of children. + * @return {Array.} - List of compiled children. + */ +compilerPrototype.all = function (parent) { + var self = this; + var children = parent.children; + var values = []; + var index = 0; + var length = children.length; + var node = children[0]; + var next; + + if (length === 0) { + return values; + } + + while (++index < length) { + next = children[index]; + + if ( + node.type === next.type && + node.type in MERGEABLE_NODES && + mergeable(node) && + mergeable(next) + ) { + node = MERGEABLE_NODES[node.type].call(self, node, next); + } else { + values.push(self.visit(node, parent)); + node = next; + } + } + + values.push(self.visit(node, parent)); + + return values; +}; + +/** + * Visit ordered list items. + * + * Starts the list with + * `node.start` and increments each following list item + * bullet by one: + * + * 2. foo + * 3. bar + * + * In `incrementListMarker: false` mode, does not increment + * each marker and stays on `node.start`: + * + * 1. foo + * 1. bar + * + * Adds an extra line after an item if it has + * `loose: true`. + * + * @example + * var compiler = new Compiler(); + * + * compiler.visitOrderedItems({ + * type: 'list', + * ordered: true, + * children: [{ + * type: 'listItem', + * children: [{ + * type: 'text', + * value: 'bar' + * }] + * }] + * }); + * // '1. bar' + * + * @param {Object} node - `list` node with + * `ordered: true`. + * @return {string} - Markdown list. + */ +compilerPrototype.visitOrderedItems = function (node) { + var self = this; + var increment = self.options.incrementListMarker; + var values = []; + var start = node.start; + var children = node.children; + var length = children.length; + var index = -1; + var bullet; + + while (++index < length) { + bullet = (increment ? start + index : start) + DOT; + values[index] = self.listItem(children[index], node, index, bullet); + } + + return values.join(LINE); +}; + +/** + * Visit unordered list items. + * + * Uses `options.bullet` as each item's bullet. + * + * Adds an extra line after an item if it has + * `loose: true`. + * + * @example + * var compiler = new Compiler(); + * + * compiler.visitUnorderedItems({ + * type: 'list', + * ordered: false, + * children: [{ + * type: 'listItem', + * children: [{ + * type: 'text', + * value: 'bar' + * }] + * }] + * }); + * // '- bar' + * + * @param {Object} node - `list` node with + * `ordered: false`. + * @return {string} - Markdown list. + */ +compilerPrototype.visitUnorderedItems = function (node) { + var self = this; + var values = []; + var children = node.children; + var length = children.length; + var index = -1; + var bullet = self.options.bullet; + + while (++index < length) { + values[index] = self.listItem(children[index], node, index, bullet); + } + + return values.join(LINE); +}; + +/** + * Stringify a block node with block children (e.g., `root` + * or `blockquote`). + * + * Knows about code following a list, or adjacent lists + * with similar bullets, and places an extra newline + * between them. + * + * @example + * var compiler = new Compiler(); + * + * compiler.block({ + * type: 'root', + * children: [{ + * type: 'paragraph', + * children: [{ + * type: 'text', + * value: 'bar' + * }] + * }] + * }); + * // 'bar' + * + * @param {Object} node - `root` node. + * @return {string} - Markdown block content. + */ +compilerPrototype.block = function (node) { + var self = this; + var values = []; + var children = node.children; + var length = children.length; + var index = -1; + var child; + var prev; + + while (++index < length) { + child = children[index]; + + if (prev) { + /* + * Duplicate nodes, such as a list + * directly following another list, + * often need multiple new lines. + * + * Additionally, code blocks following a list + * might easily be mistaken for a paragraph + * in the list itself. + */ + + if (child.type === prev.type && prev.type === 'list') { + values.push(prev.ordered === child.ordered ? GAP : BREAK); + } else if ( + prev.type === 'list' && + child.type === 'code' && + !child.lang + ) { + values.push(GAP); + } else { + values.push(BREAK); + } + } + + values.push(self.visit(child, node)); + + prev = child; + } + + return values.join(EMPTY); +}; + +/** + * Stringify a root. + * + * Adds a final newline to ensure valid POSIX files. + * + * @example + * var compiler = new Compiler(); + * + * compiler.root({ + * type: 'root', + * children: [{ + * type: 'paragraph', + * children: [{ + * type: 'text', + * value: 'bar' + * }] + * }] + * }); + * // 'bar' + * + * @param {Object} node - `root` node. + * @return {string} - Markdown document. + */ +compilerPrototype.root = function (node) { + return this.block(node) + LINE; +}; + +/** + * Stringify a heading. + * + * In `setext: true` mode and when `depth` is smaller than + * three, creates a setext header: + * + * Foo + * === + * + * Otherwise, an ATX header is generated: + * + * ### Foo + * + * In `closeAtx: true` mode, the header is closed with + * hashes: + * + * ### Foo ### + * + * @example + * var compiler = new Compiler(); + * + * compiler.heading({ + * type: 'heading', + * depth: 2, + * children: [{ + * type: 'strong', + * children: [{ + * type: 'text', + * value: 'bar' + * }] + * }] + * }); + * // '## **bar**' + * + * @param {Object} node - `heading` node. + * @return {string} - Markdown heading. + */ +compilerPrototype.heading = function (node) { + var self = this; + var setext = self.options.setext; + var closeAtx = self.options.closeAtx; + var depth = node.depth; + var content = self.all(node).join(EMPTY); + var prefix; + + if (setext && depth < 3) { + return content + LINE + + repeat(depth === 1 ? EQUALS : DASH, content.length); + } + + prefix = repeat(HASH, node.depth); + content = prefix + SPACE + content; + + if (closeAtx) { + content += SPACE + prefix; + } + + return content; +}; + +/** + * Stringify text. + * + * Supports named entities in `settings.encode: true` mode: + * + * AT&T + * + * Supports numbered entities in `settings.encode: numbers` + * mode: + * + * AT&T + * + * @example + * var compiler = new Compiler(); + * + * compiler.text({ + * type: 'text', + * value: 'foo' + * }); + * // 'foo' + * + * @param {Object} node - `text` node. + * @param {Object} parent - Parent of `node`. + * @return {string} - Raw markdown text. + */ +compilerPrototype.text = function (node, parent) { + return this.encode(this.escape(node.value, node, parent), node); +}; + +/** + * Stringify a paragraph. + * + * @example + * var compiler = new Compiler(); + * + * compiler.paragraph({ + * type: 'paragraph', + * children: [{ + * type: 'strong', + * children: [{ + * type: 'text', + * value: 'bar' + * }] + * }] + * }); + * // '**bar**' + * + * @param {Object} node - `paragraph` node. + * @return {string} - Markdown paragraph. + */ +compilerPrototype.paragraph = function (node) { + return this.all(node).join(EMPTY); +}; + +/** + * Stringify a block quote. + * + * @example + * var compiler = new Compiler(); + * + * compiler.paragraph({ + * type: 'blockquote', + * children: [{ + * type: 'paragraph', + * children: [{ + * type: 'strong', + * children: [{ + * type: 'text', + * value: 'bar' + * }] + * }] + * }] + * }); + * // '> **bar**' + * + * @param {Object} node - `blockquote` node. + * @return {string} - Markdown block quote. + */ +compilerPrototype.blockquote = function (node) { + var values = this.block(node).split(LINE); + var result = []; + var length = values.length; + var index = -1; + var value; + + while (++index < length) { + value = values[index]; + result[index] = (value ? SPACE : EMPTY) + value; + } + + return ANGLE_BRACKET_CLOSE + result.join(LINE + ANGLE_BRACKET_CLOSE); +}; + +/** + * Stringify a list. See `Compiler#visitOrderedList()` and + * `Compiler#visitUnorderedList()` for internal working. + * + * @example + * var compiler = new Compiler(); + * + * compiler.visitUnorderedItems({ + * type: 'list', + * ordered: false, + * children: [{ + * type: 'listItem', + * children: [{ + * type: 'text', + * value: 'bar' + * }] + * }] + * }); + * // '- bar' + * + * @param {Object} node - `list` node. + * @return {string} - Markdown list. + */ +compilerPrototype.list = function (node) { + return this[ORDERED_MAP[node.ordered]](node); +}; + +/** + * Stringify a list item. + * + * Prefixes the content with a checked checkbox when + * `checked: true`: + * + * [x] foo + * + * Prefixes the content with an unchecked checkbox when + * `checked: false`: + * + * [ ] foo + * + * @example + * var compiler = new Compiler(); + * + * compiler.listItem({ + * type: 'listItem', + * checked: true, + * children: [{ + * type: 'text', + * value: 'bar' + * }] + * }, { + * type: 'list', + * ordered: false, + * children: [{ + * type: 'listItem', + * checked: true, + * children: [{ + * type: 'text', + * value: 'bar' + * }] + * }] + * }, 0, '*'); + * '- [x] bar' + * + * @param {Object} node - `listItem` node. + * @param {Object} parent - `list` node. + * @param {number} position - Index of `node` in `parent`. + * @param {string} bullet - Bullet to use. This, and the + * `listItemIndent` setting define the used indent. + * @return {string} - Markdown list item. + */ +compilerPrototype.listItem = function (node, parent, position, bullet) { + var self = this; + var style = self.options.listItemIndent; + var children = node.children; + var values = []; + var index = -1; + var length = children.length; + var loose = node.loose; + var value; + var indent; + var spacing; + + while (++index < length) { + values[index] = self.visit(children[index], node); + } + + value = CHECKBOX_MAP[node.checked] + values.join(loose ? BREAK : LINE); + + if ( + style === LIST_ITEM_ONE || + (style === LIST_ITEM_MIXED && value.indexOf(LINE) === -1) + ) { + indent = bullet.length + 1; + spacing = SPACE; + } else { + indent = Math.ceil((bullet.length + 1) / INDENT) * INDENT; + spacing = repeat(SPACE, indent - bullet.length); + } + + value = bullet + spacing + pad(value, indent / INDENT).slice(indent); + + if (loose && parent.children.length - 1 !== position) { + value += LINE; + } + + return value; +}; + +/** + * Stringify inline code. + * + * Knows about internal ticks (`\``), and ensures one more + * tick is used to enclose the inline code: + * + * ```foo ``bar`` baz``` + * + * Even knows about inital and final ticks: + * + * `` `foo `` + * `` foo` `` + * + * @example + * var compiler = new Compiler(); + * + * compiler.inlineCode({ + * type: 'inlineCode', + * value: 'foo(); `bar`; baz()' + * }); + * // '``foo(); `bar`; baz()``' + * + * @param {Object} node - `inlineCode` node. + * @return {string} - Markdown inline code. + */ +compilerPrototype.inlineCode = function (node) { + var value = node.value; + var ticks = repeat(TICK, longestStreak(value, TICK) + 1); + var start = ticks; + var end = ticks; + + if (value.charAt(0) === TICK) { + start += SPACE; + } + + if (value.charAt(value.length - 1) === TICK) { + end = SPACE + end; + } + + return start + node.value + end; +}; + +/** + * Stringify YAML front matter. + * + * @example + * var compiler = new Compiler(); + * + * compiler.yaml({ + * type: 'yaml', + * value: 'foo: bar' + * }); + * // '---\nfoo: bar\n---' + * + * @param {Object} node - `yaml` node. + * @return {string} - Markdown YAML document. + */ +compilerPrototype.yaml = function (node) { + var delimiter = repeat(DASH, YAML_FENCE_LENGTH); + var value = node.value ? LINE + node.value : EMPTY; + + return delimiter + value + LINE + delimiter; +}; + +/** + * Stringify a code block. + * + * Creates indented code when: + * + * - No language tag exists; + * - Not in `fences: true` mode; + * - A non-empty value exists. + * + * Otherwise, GFM fenced code is created: + * + * ```js + * foo(); + * ``` + * + * When in ``fence: `~` `` mode, uses tildes as fences: + * + * ~~~js + * foo(); + * ~~~ + * + * Knows about internal fences (Note: GitHub/Kramdown does + * not support this): + * + * ````javascript + * ```markdown + * foo + * ``` + * ```` + * + * Supports named entities in the language flag with + * `settings.encode` mode. + * + * @example + * var compiler = new Compiler(); + * + * compiler.code({ + * type: 'code', + * lang: 'js', + * value: 'fooo();' + * }); + * // '```js\nfooo();\n```' + * + * @param {Object} node - `code` node. + * @param {Object} parent - Parent of `node`. + * @return {string} - Markdown code block. + */ +compilerPrototype.code = function (node, parent) { + var self = this; + var value = node.value; + var options = self.options; + var marker = options.fence; + var language = self.encode(node.lang || EMPTY, node); + var fence; + + /* + * Without (needed) fences. + */ + + if (!language && !options.fences && value) { + /* + * Throw when pedantic, in a list item which + * isn’t compiled using a tab. + */ + + if ( + parent && + parent.type === 'listItem' && + options.listItemIndent !== LIST_ITEM_TAB && + options.pedantic + ) { + self.file.fail(ERROR_LIST_ITEM_INDENT, node.position); + } + + return pad(value, 1); + } + + fence = longestStreak(value, marker) + 1; + + /* + * Fix GFM / RedCarpet bug, where fence-like characters + * inside fenced code can exit a code-block. + * Yes, even when the outer fence uses different + * characters, or is longer. + * Thus, we can only pad the code to make it work. + */ + + if (FENCE.test(value)) { + value = pad(value, 1); + } + + fence = repeat(marker, Math.max(fence, MINIMUM_CODE_FENCE_LENGTH)); + + return fence + language + LINE + value + LINE + fence; +}; + +/** + * Stringify HTML. + * + * @example + * var compiler = new Compiler(); + * + * compiler.html({ + * type: 'html', + * value: '
    bar
    ' + * }); + * // '
    bar
    ' + * + * @param {Object} node - `html` node. + * @return {string} - Markdown HTML. + */ +compilerPrototype.html = function (node) { + return node.value; +}; + +/** + * Stringify a horizontal rule. + * + * The character used is configurable by `rule`: (`'_'`) + * + * ___ + * + * The number of repititions is defined through + * `ruleRepetition`: (`6`) + * + * ****** + * + * Whether spaces delimit each character, is configured + * through `ruleSpaces`: (`true`) + * + * * * * + * + * @example + * var compiler = new Compiler(); + * + * compiler.horizontalRule({ + * type: 'horizontalRule' + * }); + * // '***' + * + * @return {string} - Markdown rule. + */ +compilerPrototype.horizontalRule = function () { + var options = this.options; + var rule = repeat(options.rule, options.ruleRepetition); + + if (options.ruleSpaces) { + rule = rule.split(EMPTY).join(SPACE); + } + + return rule; +}; + +/** + * Stringify a strong. + * + * The marker used is configurable by `strong`, which + * defaults to an asterisk (`'*'`) but also accepts an + * underscore (`'_'`): + * + * _foo_ + * + * @example + * var compiler = new Compiler(); + * + * compiler.strong({ + * type: 'strong', + * children: [{ + * type: 'text', + * value: 'Foo' + * }] + * }); + * // '**Foo**' + * + * @param {Object} node - `strong` node. + * @return {string} - Markdown strong-emphasised text. + */ +compilerPrototype.strong = function (node) { + var marker = this.options.strong; + + marker = marker + marker; + + return marker + this.all(node).join(EMPTY) + marker; +}; + +/** + * Stringify an emphasis. + * + * The marker used is configurable by `emphasis`, which + * defaults to an underscore (`'_'`) but also accepts an + * asterisk (`'*'`): + * + * *foo* + * + * @example + * var compiler = new Compiler(); + * + * compiler.emphasis({ + * type: 'emphasis', + * children: [{ + * type: 'text', + * value: 'Foo' + * }] + * }); + * // '_Foo_' + * + * @param {Object} node - `emphasis` node. + * @return {string} - Markdown emphasised text. + */ +compilerPrototype.emphasis = function (node) { + var marker = this.options.emphasis; + + return marker + this.all(node).join(EMPTY) + marker; +}; + +/** + * Stringify a hard break. + * + * In Commonmark mode, trailing backslash form is used in order + * to preserve trailing whitespace that the line may end with, + * and also for better visibility. + * + * @example + * var compiler = new Compiler(); + * + * compiler.break({ + * type: 'break' + * }); + * // ' \n' + * + * @return {string} - Hard markdown break. + */ +compilerPrototype.break = function () { + return this.options.commonmark ? BACKSLASH + LINE : SPACE + SPACE + LINE; +}; + +/** + * Stringify a delete. + * + * @example + * var compiler = new Compiler(); + * + * compiler.delete({ + * type: 'delete', + * children: [{ + * type: 'text', + * value: 'Foo' + * }] + * }); + * // '~~Foo~~' + * + * @param {Object} node - `delete` node. + * @return {string} - Markdown strike-through. + */ +compilerPrototype.delete = function (node) { + return DOUBLE_TILDE + this.all(node).join(EMPTY) + DOUBLE_TILDE; +}; + +/** + * Stringify a link. + * + * When no title exists, the compiled `children` equal + * `href`, and `href` starts with a protocol, an auto + * link is created: + * + * + * + * Otherwise, is smart about enclosing `href` (see + * `encloseURI()`) and `title` (see `encloseTitle()`). + * + * [foo]( 'An "example" e-mail') + * + * Supports named entities in the `href` and `title` when + * in `settings.encode` mode. + * + * @example + * var compiler = new Compiler(); + * + * compiler.link({ + * type: 'link', + * href: 'http://example.com', + * title: 'Example Domain', + * children: [{ + * type: 'text', + * value: 'Foo' + * }] + * }); + * // '[Foo](http://example.com "Example Domain")' + * + * @param {Object} node - `link` node. + * @return {string} - Markdown link. + */ +compilerPrototype.link = function (node) { + var self = this; + var url = self.encode(node.href, node); + var exit = self.enterLink(); + var escapedURL = self.encode(self.escape(node.href, node)); + var value = self.all(node).join(EMPTY); + + exit(); + + if ( + node.title === null && + PROTOCOL.test(url) && + (escapedURL === value || escapedURL === MAILTO + value) + ) { + /* + * Backslash escapes do not work in autolinks, + * so we do not escape. + */ + + return encloseURI(self.encode(node.href), true); + } + + url = encloseURI(url); + + if (node.title) { + url += SPACE + encloseTitle(self.encode(self.escape( + node.title, node + ), node)); + } + + value = SQUARE_BRACKET_OPEN + value + SQUARE_BRACKET_CLOSE; + + value += PARENTHESIS_OPEN + url + PARENTHESIS_CLOSE; + + return value; +}; + +/** + * Stringify a link label. + * + * Because link references are easily, mistakingly, + * created (for example, `[foo]`), reference nodes have + * an extra property depicting how it looked in the + * original document, so stringification can cause minimal + * changes. + * + * @example + * label({ + * type: 'referenceImage', + * referenceType: 'full', + * identifier: 'foo' + * }); + * // '[foo]' + * + * label({ + * type: 'referenceImage', + * referenceType: 'collapsed', + * identifier: 'foo' + * }); + * // '[]' + * + * label({ + * type: 'referenceImage', + * referenceType: 'shortcut', + * identifier: 'foo' + * }); + * // '' + * + * @param {Object} node - `linkReference` or + * `imageReference` node. + * @return {string} - Markdown label reference. + */ +function label(node) { + var value = EMPTY; + var type = node.referenceType; + + if (type === 'full') { + value = node.identifier; + } + + if (type !== 'shortcut') { + value = SQUARE_BRACKET_OPEN + value + SQUARE_BRACKET_CLOSE; + } + + return value; +} + +/** + * For shortcut reference links, the contents is also an + * identifier, and for identifiers extra backslashes do + * matter. + * + * This function takes an escaped value from shortcut's children + * and an identifier and removes extra backslashes. + * + * @example + * unescapeShortcutLinkReference('a\\*b', 'a*b') + * // 'a*b' + * + * @param {string} value - Escaped and stringified link value. + * @param {string} identifier - Link identifier, in one of its + * equivalent forms. + * @return {string} - Link value with some characters unescaped. + */ +function unescapeShortcutLinkReference(value, identifier) { + var index = 0; + var position = 0; + var length = value.length; + var count = identifier.length; + var result = []; + var start; + + while (index < length) { + /* + * Take next non-punctuation characters from `value`. + */ + + start = index; + + while ( + index < length && + !PUNCTUATION.test(value.charAt(index)) + ) { + index += 1; + } + + result.push(value.slice(start, index)); + + /* + * Advance `position` to the next punctuation character. + */ + while ( + position < count && + !PUNCTUATION.test(identifier.charAt(position)) + ) { + position += 1; + } + + /* + * Take next punctuation characters from `identifier`. + */ + start = position; + + while ( + position < count && + PUNCTUATION.test(identifier.charAt(position)) + ) { + position += 1; + } + + result.push(identifier.slice(start, position)); + + /* + * Advance `index` to the next non-punctuation character. + */ + while (index < length && PUNCTUATION.test(value.charAt(index))) { + index += 1; + } + } + + return result.join(EMPTY); +} + +/** + * Stringify a link reference. + * + * See `label()` on how reference labels are created. + * + * @example + * var compiler = new Compiler(); + * + * compiler.linkReference({ + * type: 'linkReference', + * referenceType: 'collapsed', + * identifier: 'foo', + * children: [{ + * type: 'text', + * value: 'Foo' + * }] + * }); + * // '[Foo][]' + * + * @param {Object} node - `linkReference` node. + * @return {string} - Markdown link reference. + */ +compilerPrototype.linkReference = function (node) { + var self = this; + var exitLink = self.enterLink(); + var value = self.all(node).join(EMPTY); + + exitLink(); + + if (node.referenceType == 'shortcut') { + value = unescapeShortcutLinkReference(value, node.identifier); + } + + return SQUARE_BRACKET_OPEN + value + SQUARE_BRACKET_CLOSE + label(node); +}; + +/** + * Stringify an image reference. + * + * See `label()` on how reference labels are created. + * + * Supports named entities in the `alt` when + * in `settings.encode` mode. + * + * @example + * var compiler = new Compiler(); + * + * compiler.imageReference({ + * type: 'imageReference', + * referenceType: 'full', + * identifier: 'foo', + * alt: 'Foo' + * }); + * // '![Foo][foo]' + * + * @param {Object} node - `imageReference` node. + * @return {string} - Markdown image reference. + */ +compilerPrototype.imageReference = function (node) { + var alt = this.encode(node.alt, node) || EMPTY; + + return EXCLAMATION_MARK + + SQUARE_BRACKET_OPEN + alt + SQUARE_BRACKET_CLOSE + + label(node); +}; + +/** + * Stringify a footnote reference. + * + * @example + * var compiler = new Compiler(); + * + * compiler.footnoteReference({ + * type: 'footnoteReference', + * identifier: 'foo' + * }); + * // '[^foo]' + * + * @param {Object} node - `footnoteReference` node. + * @return {string} - Markdown footnote reference. + */ +compilerPrototype.footnoteReference = function (node) { + return SQUARE_BRACKET_OPEN + CARET + node.identifier + + SQUARE_BRACKET_CLOSE; +}; + +/** + * Stringify an link- or image definition. + * + * Is smart about enclosing `href` (see `encloseURI()`) and + * `title` (see `encloseTitle()`). + * + * [foo]: 'An "example" e-mail' + * + * @example + * var compiler = new Compiler(); + * + * compiler.definition({ + * type: 'definition', + * link: 'http://example.com', + * title: 'Example Domain', + * identifier: 'foo' + * }); + * // '[foo]: http://example.com "Example Domain"' + * + * @param {Object} node - `definition` node. + * @return {string} - Markdown link- or image definition. + */ +compilerPrototype.definition = function (node) { + var value = SQUARE_BRACKET_OPEN + node.identifier + SQUARE_BRACKET_CLOSE; + var url = encloseURI(node.link); + + if (node.title) { + url += SPACE + encloseTitle(node.title); + } + + return value + COLON + SPACE + url; +}; + +/** + * Stringify an image. + * + * Is smart about enclosing `href` (see `encloseURI()`) and + * `title` (see `encloseTitle()`). + * + * ![foo]( 'My "favourite" icon') + * + * Supports named entities in `src`, `alt`, and `title` + * when in `settings.encode` mode. + * + * @example + * var compiler = new Compiler(); + * + * compiler.image({ + * type: 'image', + * href: 'http://example.png/favicon.png', + * title: 'Example Icon', + * alt: 'Foo' + * }); + * // '![Foo](http://example.png/favicon.png "Example Icon")' + * + * @param {Object} node - `image` node. + * @return {string} - Markdown image. + */ +compilerPrototype.image = function (node) { + var url = encloseURI(this.encode(node.src, node)); + var value; + + if (node.title) { + url += SPACE + encloseTitle(this.encode(node.title, node)); + } + + value = EXCLAMATION_MARK + + SQUARE_BRACKET_OPEN + this.encode(node.alt || EMPTY, node) + + SQUARE_BRACKET_CLOSE; + + value += PARENTHESIS_OPEN + url + PARENTHESIS_CLOSE; + + return value; +}; + +/** + * Stringify a footnote. + * + * @example + * var compiler = new Compiler(); + * + * compiler.footnote({ + * type: 'footnote', + * children: [{ + * type: 'text', + * value: 'Foo' + * }] + * }); + * // '[^Foo]' + * + * @param {Object} node - `footnote` node. + * @return {string} - Markdown footnote. + */ +compilerPrototype.footnote = function (node) { + return SQUARE_BRACKET_OPEN + CARET + this.all(node).join(EMPTY) + + SQUARE_BRACKET_CLOSE; +}; + +/** + * Stringify a footnote definition. + * + * @example + * var compiler = new Compiler(); + * + * compiler.footnoteDefinition({ + * type: 'footnoteDefinition', + * identifier: 'foo', + * children: [{ + * type: 'paragraph', + * children: [{ + * type: 'text', + * value: 'bar' + * }] + * }] + * }); + * // '[^foo]: bar' + * + * @param {Object} node - `footnoteDefinition` node. + * @return {string} - Markdown footnote definition. + */ +compilerPrototype.footnoteDefinition = function (node) { + var id = node.identifier.toLowerCase(); + + return SQUARE_BRACKET_OPEN + CARET + id + + SQUARE_BRACKET_CLOSE + COLON + SPACE + + this.all(node).join(BREAK + repeat(SPACE, INDENT)); +}; + +/** + * Stringify table. + * + * Creates a fenced table by default, but not in + * `looseTable: true` mode: + * + * Foo | Bar + * :-: | --- + * Baz | Qux + * + * NOTE: Be careful with `looseTable: true` mode, as a + * loose table inside an indented code block on GitHub + * renders as an actual table! + * + * Creates a spaces table by default, but not in + * `spacedTable: false`: + * + * |Foo|Bar| + * |:-:|---| + * |Baz|Qux| + * + * @example + * var compiler = new Compiler(); + * + * compiler.table({ + * type: 'table', + * align: ['center', null], + * children: [ + * { + * type: 'tableHeader', + * children: [ + * { + * type: 'tableCell' + * children: [{ + * type: 'text' + * value: 'Foo' + * }] + * }, + * { + * type: 'tableCell' + * children: [{ + * type: 'text' + * value: 'Bar' + * }] + * } + * ] + * }, + * { + * type: 'tableRow', + * children: [ + * { + * type: 'tableCell' + * children: [{ + * type: 'text' + * value: 'Baz' + * }] + * }, + * { + * type: 'tableCell' + * children: [{ + * type: 'text' + * value: 'Qux' + * }] + * } + * ] + * } + * ] + * }); + * // '| Foo | Bar |\n| :-: | --- |\n| Baz | Qux |' + * + * @param {Object} node - `table` node. + * @return {string} - Markdown table. + */ +compilerPrototype.table = function (node) { + var self = this; + var loose = self.options.looseTable; + var spaced = self.options.spacedTable; + var rows = node.children; + var index = rows.length; + var exit = self.enterTable(); + var result = []; + var start; + + while (index--) { + result[index] = self.all(rows[index]); + } + + exit(); + + start = loose ? EMPTY : spaced ? PIPE + SPACE : PIPE; + + return table(result, { + 'align': node.align, + 'start': start, + 'end': start.split(EMPTY).reverse().join(EMPTY), + 'delimiter': spaced ? SPACE + PIPE + SPACE : PIPE + }); +}; + +/** + * Stringify a table cell. + * + * @example + * var compiler = new Compiler(); + * + * compiler.tableCell({ + * type: 'tableCell', + * children: [{ + * type: 'text' + * value: 'Qux' + * }] + * }); + * // 'Qux' + * + * @param {Object} node - `tableCell` node. + * @return {string} - Markdown table cell. + */ +compilerPrototype.tableCell = function (node) { + return this.all(node).join(EMPTY); +}; + +/** + * Stringify the bound file. + * + * @example + * var file = new VFile('__Foo__'); + * + * file.namespace('mdast').tree = { + * type: 'strong', + * children: [{ + * type: 'text', + * value: 'Foo' + * }] + * }); + * + * new Compiler(file).compile(); + * // '**Foo**' + * + * @this {Compiler} + * @return {string} - Markdown document. + */ +compilerPrototype.compile = function () { + return this.visit(this.file.namespace('mdast').tree); +}; + +/* + * Expose `stringify` on `module.exports`. + */ + +module.exports = Compiler; diff --git a/tools/node_modules/remark/lib/utilities.js b/tools/node_modules/remark/lib/utilities.js new file mode 100644 index 00000000000000..26fa88e07dd2ec --- /dev/null +++ b/tools/node_modules/remark/lib/utilities.js @@ -0,0 +1,299 @@ +/** + * @author Titus Wormer + * @copyright 2015-2016 Titus Wormer + * @license MIT + * @module remark:utilities + * @version 3.2.2 + * @fileoverview Collection of tiny helpers useful for + * both parsing and compiling markdown. + */ + +'use strict'; + +/* eslint-env commonjs */ + +/* + * Dependencies. + */ + +var collapseWhiteSpace = require('collapse-white-space'); + +/* + * Expressions. + */ + +var EXPRESSION_LINE_BREAKS = /\r\n|\r/g; +var EXPRESSION_SYMBOL_FOR_NEW_LINE = /\u2424/g; +var EXPRESSION_BOM = /^\ufeff/; + +/** + * Throw an exception with in its `message` `value` + * and `name`. + * + * @param {*} value - Invalid value. + * @param {string} name - Setting name. + */ +function raise(value, name) { + throw new Error( + 'Invalid value `' + value + '` ' + + 'for setting `' + name + '`' + ); +} + +/** + * Validate a value to be boolean. Defaults to `def`. + * Raises an exception with `context[name]` when not + * a boolean. + * + * @example + * validateBoolean({foo: null}, 'foo', true) // true + * validateBoolean({foo: false}, 'foo', true) // false + * validateBoolean({foo: 'bar'}, 'foo', true) // Throws + * + * @throws {Error} - When a setting is neither omitted nor + * a boolean. + * @param {Object} context - Settings. + * @param {string} name - Setting name. + * @param {boolean} def - Default value. + */ +function validateBoolean(context, name, def) { + var value = context[name]; + + if (value === null || value === undefined) { + value = def; + } + + if (typeof value !== 'boolean') { + raise(value, 'options.' + name); + } + + context[name] = value; +} + +/** + * Validate a value to be boolean. Defaults to `def`. + * Raises an exception with `context[name]` when not + * a boolean. + * + * @example + * validateNumber({foo: null}, 'foo', 1) // 1 + * validateNumber({foo: 2}, 'foo', 1) // 2 + * validateNumber({foo: 'bar'}, 'foo', 1) // Throws + * + * @throws {Error} - When a setting is neither omitted nor + * a number. + * @param {Object} context - Settings. + * @param {string} name - Setting name. + * @param {number} def - Default value. + */ +function validateNumber(context, name, def) { + var value = context[name]; + + if (value === null || value === undefined) { + value = def; + } + + if (typeof value !== 'number' || value !== value) { + raise(value, 'options.' + name); + } + + context[name] = value; +} + +/** + * Validate a value to be in `map`. Defaults to `def`. + * Raises an exception with `context[name]` when not + * not in `map`. + * + * @example + * var map = {bar: true, baz: true}; + * validateString({foo: null}, 'foo', 'bar', map) // 'bar' + * validateString({foo: 'baz'}, 'foo', 'bar', map) // 'baz' + * validateString({foo: true}, 'foo', 'bar', map) // Throws + * + * @throws {Error} - When a setting is neither omitted nor + * in `map`. + * @param {Object} context - Settings. + * @param {string} name - Setting name. + * @param {string} def - Default value. + * @param {Object} map - Enum. + */ +function validateString(context, name, def, map) { + var value = context[name]; + + if (value === null || value === undefined) { + value = def; + } + + if (!(value in map)) { + raise(value, 'options.' + name); + } + + context[name] = value; +} + +/** + * Clean a string in preperation of parsing. + * + * @example + * clean('\ufefffoo'); // 'foo' + * clean('foo\r\nbar'); // 'foo\nbar' + * clean('foo\u2424bar'); // 'foo\nbar' + * + * @param {string} value - Content to clean. + * @return {string} - Cleaned content. + */ +function clean(value) { + return String(value) + .replace(EXPRESSION_BOM, '') + .replace(EXPRESSION_LINE_BREAKS, '\n') + .replace(EXPRESSION_SYMBOL_FOR_NEW_LINE, '\n'); +} + +/** + * Normalize an identifier. Collapses multiple white space + * characters into a single space, and removes casing. + * + * @example + * normalizeIdentifier('FOO\t bar'); // 'foo bar' + * + * @param {string} value - Content to normalize. + * @return {string} - Normalized content. + */ +function normalizeIdentifier(value) { + return collapseWhiteSpace(value).toLowerCase(); +} + +/** + * Construct a state `toggler`: a function which inverses + * `property` in context based on its current value. + * The by `toggler` returned function restores that value. + * + * @example + * var context = {}; + * var key = 'foo'; + * var val = true; + * context[key] = val; + * context.enter = stateToggler(key, val); + * context[key]; // true + * var exit = context.enter(); + * context[key]; // false + * var nested = context.enter(); + * context[key]; // false + * nested(); + * context[key]; // false + * exit(); + * context[key]; // true + * + * @param {string} key - Property to toggle. + * @param {boolean} state - It's default state. + * @return {function(): function()} - Enter. + */ +function stateToggler(key, state) { + /** + * Construct a toggler for the bound `key`. + * + * @return {Function} - Exit state. + */ + function enter() { + var self = this; + var current = self[key]; + + self[key] = !state; + + /** + * State canceler, cancels the state, if allowed. + */ + function exit() { + self[key] = current; + } + + return exit; + } + + return enter; +} + +/* + * Define nodes of a type which can be merged. + */ + +var MERGEABLE_NODES = {}; + +/** + * Check whether a node is mergeable with adjacent nodes. + * + * @param {Object} node - Node to check. + * @return {boolean} - Whether `node` is mergable. + */ +function mergeable(node) { + var start; + var end; + + if (node.type !== 'text' || !node.position) { + return true; + } + + start = node.position.start; + end = node.position.end; + + /* + * Only merge nodes which occupy the same size as their + * `value`. + */ + + return start.line !== end.line || + end.column - start.column === node.value.length; +} + +/** + * Merge two text nodes: `node` into `prev`. + * + * @param {Object} prev - Preceding sibling. + * @param {Object} node - Following sibling. + * @return {Object} - `prev`. + */ +MERGEABLE_NODES.text = function (prev, node) { + prev.value += node.value; + + return prev; +}; + +/** + * Merge two blockquotes: `node` into `prev`, unless in + * CommonMark mode. + * + * @param {Object} prev - Preceding sibling. + * @param {Object} node - Following sibling. + * @return {Object} - `prev`, or `node` in CommonMark mode. + */ +MERGEABLE_NODES.blockquote = function (prev, node) { + if (this.options.commonmark) { + return node; + } + + prev.children = prev.children.concat(node.children); + + return prev; +}; + +/* + * Expose `validate`. + */ + +exports.validate = { + 'boolean': validateBoolean, + 'string': validateString, + 'number': validateNumber +}; + +/* + * Expose. + */ + +exports.normalizeIdentifier = normalizeIdentifier; +exports.clean = clean; +exports.raise = raise; +exports.stateToggler = stateToggler; +exports.mergeable = mergeable; +exports.MERGEABLE_NODES = MERGEABLE_NODES; diff --git a/tools/node_modules/remark/man/remark.1 b/tools/node_modules/remark/man/remark.1 new file mode 100644 index 00000000000000..c19c63db2ef9c8 --- /dev/null +++ b/tools/node_modules/remark/man/remark.1 @@ -0,0 +1,226 @@ +.TH "REMARK" "1" "January 2016" "3.2.2" "remark manual" +.SH "NAME" +\fBremark\fR - Markdown processor +.SH "SYNOPSIS" +.P +\fBremark\fR \[lB]\fBoptions\fR\[rB] <\fIpathspec\fR...> +.SH "DESCRIPTION" +.P +\fBremark\fR is a markdown processor powered by plugins. +.P +<\fIpathspec\fR...> refers to files to process. Fileglobs (e.g., \fB*.md\fR) can be given to add all matching files. Directories can be given (e.g. \fBdir\fR to add \fBdir\[sl]readme.md\fR and \fBdir\[sl]sub\[sl]history.mkd\fR) to add files with a known markdown extension (see the \fB-e\fR, \fB--ext\fR flag). +.P +Logs verbose debugging information when \fB\[Do]DEBUG\fR is set to \fB\[dq]*\[dq]\fR. +.SH "OPTIONS" +.SS "\fB-h\fR, \fB--help\fR" +.P +.RS 2 +.nf +remark --help +.fi +.RE +.P +Output short usage information. +.SS "\fB-v\fR, \fB--version\fR" +.P +.RS 2 +.nf +remark --version +.fi +.RE +.P +Output CLI version number. +.SS "\fB-o\fR, \fB--output\fR \[lB]\fIpath\fR\[rB]" +.P +.RS 2 +.nf +remark . --output +remark . --output doc +remark readme.md --output doc\[sl]foo.bar +.fi +.RE +.P +Specify output. +.RS 0 +.IP \(bu 4 +If output is \fBnot\fR given and one file is processed, the file is written to \fBstdout\fR(4). See \fB--no-stdout\fR to disable this behaviour; +.IP \(bu 4 +Otherwise, if output is \fBnot\fR given and multiple files are processed, files are neither written to \fBstdout\fR(4) nor to the file-system; +.IP \(bu 4 +Otherwise, if output is given but \fBwithout\fR path, input files are overwritten; +.IP \(bu 4 +Otherwise, if a path to an existing directory is given, files are written to that directory; +.IP \(bu 4 +Otherwise, if one file is processed and the parent directory of the given path exists, the file is written to the given path; +.IP \(bu 4 +Otherwise, a fatal error is thrown. +.RE 0 + +.SS "\fB-c\fR, \fB--config-path\fR <\fIpath\fR>" +.P +.RS 2 +.nf +remark . --config-path remarkrc.json +.fi +.RE +.P +Specify configuration location. This loads an \fBremarkrc\fR(5) file which cannot be detected (either because \fB--no-rc\fR is given or because it has a different name) in addition to other detected files. +.SS "\fB-i\fR, \fB--ignore-path\fR <\fIpath\fR>" +.P +.RS 2 +.nf +remark . --ignore-path .gitignore +.fi +.RE +.P +Specify ignore location. This loads an \fBremarkignore\fR(5) file which cannot be detected (either because \fB--no-ignore\fR is given or because it has a different name) in addition to other detected files. +.SS "\fB-s\fR, \fB--setting\fR <\fIsettings\fR>" +.P +.RS 2 +.nf +remark readme.md --setting commonmark:true +.fi +.RE +.P +Specify settings (see \fBremarksetting\fR(7)). This must be a valid JSON object except for a few differences. See \fBremarkconfig\fR(7) COMMAND LINE SETTINGS for more information. +.SS "\fB-u\fR, \fB--use\fR <\fIplugin\fR>" +.P +.RS 2 +.nf +remark readme.md --use man +.fi +.RE +.P +Specify a plug-in to use, optionally with options. See \fBremarkplugin\fR(7) COMMAND LINE USAGE for more information. +.SS "\fB-e\fR, \fB--ext\fR <\fIextensions\fR>" +.P +.RS 2 +.nf +remark . --ext doc +.fi +.RE +.P +Specify one or more extensions to include when searching for files. This will add the given \fBextensions\fR to the internal list, which includes \fB\[aq]md\[aq]\fR, \fB\[aq]markdown\[aq]\fR, \fB\[aq]mkd\[aq]\fR, \fB\[aq]mkdn\[aq]\fR, \fB\[aq]mkdown\[aq]\fR, and \fB\[aq]ron\[aq]\fR. +.P +The given \fBextensions\fR can be comma or semi-colon separated. +.SS "\fB-w\fR, \fB--watch\fR" +.P +.RS 2 +.nf +remark . -w +.fi +.RE +.P +Watch all files and reprocess when they change. +.P +When watching files which would normally regenerate, this behaviour is ignored until the watch is closed. +.P +.RS 2 +.nf +\[Do] remark --no-rc readme.md -oqw +\[sh] Watching... (press CTRL\[pl]C to exit) +\[sh] Warning: remark does not overwrite watched files until exit. +\[sh] Messages and other files are not affected. +.fi +.RE +.P +The watch is stopped when \fBSIGINT\fR is received (usually done by pressing \fBCTRL-C\fR). +.SS "\fB-a\fR, \fB--ast\fR" +.P +.RS 2 +.nf +remark readme.md --ast +.fi +.RE +.P +Instead of outputting document the internally used AST is exposed. +.SS "\fB-q\fR, \fB--quiet\fR" +.P +.RS 2 +.nf +remark readme.md --quiet +.fi +.RE +.P +Do not output non-essential text, only warnings and errors. +.SS "\fB-S\fR, \fB--silent\fR" +.P +.RS 2 +.nf +remark readme.md --silent +.fi +.RE +.P +Do not output non-essential text or warning, only errors. +.SS "\fB-f\fR, \fB--frail\fR" +.P +.RS 2 +.nf +remark readme.md --frail +.fi +.RE +.P +Exit with a status code of \fB1\fR if warnings or errors occur, instead of the default of only exiting with \fB1\fR on errors. +.SS "\fB--file-path\fR <\fIpath\fR>" +.P +.RS 2 +.nf +remark --file-path readme.md < readme.md > doc\[sl]out.md +.fi +.RE +.P +Process the piped-in document as if it was a file at \fBpath\fR. +.SS "\fB--no-stdout\fR" +.P +.RS 2 +.nf +remark readme.md --no-stdout +.fi +.RE +.P +Do not write a processed file to \fBstdout\fR(4). +.SS "\fB--no-color\fR" +.P +.RS 2 +.nf +remark readme.md --no-color +.fi +.RE +.P +Disable ANSI codes in output. +.SS "\fB--no-rc\fR" +.P +.RS 2 +.nf +remark readme.md --no-rc +.fi +.RE +.P +Disables configuration from \fBremarkrc\fR(5) files. This does not apply to explicitly provided files through \fB-c\fR, \fB--config-path\fR. +.SS "\fB--no-ignore\fR" +.P +.RS 2 +.nf +remark . --no-ignore +.fi +.RE +.P +Disables configuration from \fBremarkignore\fR(5) files. This does not apply to explicitly provided files through \fB-i\fR, \fB--ignore-path\fR. +.SS "\fB--\fR" +.P +.RS 2 +.nf +remark . -- +.fi +.RE +.P +If a \fB--\fR argument is found, argument parsing is stopped. +.SH "DIAGNOSTICS" +.P +\fBremark\fR exits 0 on success, and 1 otherwise. +.SH "BUGS" +.P +\fI\(lahttps:\[sl]\[sl]github.com\[sl]wooorm\[sl]remark\[sl]issues\(ra\fR +.SH "SEE ALSO" +.P +\fBremarkignore\fR(5), \fBremarkrc\fR(5), \fBremarkconfig\fR(7), \fBremarkplugin\fR(7), \fBremarksetting\fR(7) diff --git a/tools/node_modules/remark/man/remark.3 b/tools/node_modules/remark/man/remark.3 new file mode 100644 index 00000000000000..03a3fe1d47f937 --- /dev/null +++ b/tools/node_modules/remark/man/remark.3 @@ -0,0 +1,296 @@ +.TH "REMARK" "3" "January 2016" "3.2.2" "remark manual" +.SH "NAME" +\fBremark\fR - Markdown processor +.SH "SYNOPSIS" +.P +.RS 2 +.nf +\[sl]\[sl] Load dependencies: +var remark \[eq] require(\[aq].\[sl]index.js\[aq]); +var html \[eq] require(\[aq]remark-html\[aq]); +var yamlConfig \[eq] require(\[aq]remark-yaml-config\[aq]); + +\[sl]\[sl] Use plugins: +var processor \[eq] remark().use(yamlConfig).use(html); + +\[sl]\[sl] Process the document: +var doc \[eq] processor.process(\[lB] + \[aq]---\[aq], + \[aq]remark:\[aq], + \[aq] commonmark: true\[aq], + \[aq]---\[aq], + \[aq]\[aq], + \[aq]2) Some *emphasis*, **strongness**, and \[ga]code\[ga].\[aq] +\[rB].join(\[aq]\[rs]n\[aq])); +.fi +.RE +.SH "DESCRIPTION" +.P +These are the docs for the application programming interface of \fBremark\fR. To find documentation for the command line interface, see \fBremark\fR(1). +.SH "\FBREMARK.USE(PLUGIN\[LB], OPTIONS\[RB])\FR" +.P +Change the way \fBremark\fR works by using a plugin. Plugins are documented at on GitHub. +.P +\fBSignatures\fR +.RS 0 +.IP \(bu 4 +\fBprocessor \[eq] remark.use(plugin\[lB], options\[rB])\fR; +.IP \(bu 4 +\fBprocessor \[eq] remark.use(plugins)\fR. +.RE 0 + +.P +\fBParameters\fR +.RS 0 +.IP \(bu 4 +\fBplugin\fR (\fBFunction\fR) \[em] Plugin. +.IP \(bu 4 +\fBplugins\fR (\fBArray.\fR) \[em] List of plugins. +.IP \(bu 4 +\fBoptions\fR (\fBObject?\fR) \[em] Passed to plugin. Specified by its documentation. +.RE 0 + +.P +\fBReturns\fR +.P +\fBObject\fR \[em] An instance of \fBRemark\fR. The instance functions just like the \fBremark\fR object itself (it has the same methods), but caches the \fBuse\fRd plugins. +.SH "\FBREMARK.PARSE(FILE\[LB], OPTIONS\[RB])\FR" +.P +Parse a markdown document into an \fBmdast\fR node. +.P +\fBSignatures\fR +.RS 0 +.IP \(bu 4 +\fBnode \[eq] remark.parse(file\[ba]value\[lB], options\[rB])\fR. +.RE 0 + +.P +\fBParameters\fR +.RS 0 +.IP \(bu 4 +\fBfile\fR (\fBVFile\fR) \[em] Virtual file; +.IP \(bu 4 +\fBvalue\fR (\fBstring\fR) \[em] String representation of a file; +.IP \(bu 4 +\fBoptions\fR (\fBObject\fR) \[em] Configuration given to the parser. +.RE 0 + +.P +\fBReturns\fR +.P +\fBNode\fR \[em] Node. Nodes are documented at \fBmdast\fR. +.SH "\FBREMARK.RUN(NODE\[LB], FILE\[RB]\[LB], DONE\[RB])\FR" +.P +Transform a node by applying plug-ins to it. Either a node or a file which was previously passed to \fBparse()\fR, must be given. +.P +\fBSignatures\fR +.RS 0 +.IP \(bu 4 +\fBnode \[eq] remark.run(node\[lB], file\[ba]value\[rB]\[lB], done\[rB])\fR; +.IP \(bu 4 +\fBnode \[eq] remark.run(file\[lB], done\[rB])\fR. +.RE 0 + +.P +\fBParameters\fR +.RS 0 +.IP \(bu 4 +\fBnode\fR (\fBObject\fR) \[em] Node as returned by \fBparse()\fR, see \fBmdast\fR; +.IP \(bu 4 +\fBfile\fR (\fBVFile\fR) \[em] Virtual file; +.IP \(bu 4 +\fBvalue\fR (\fBstring\fR) \[em] String representation of a file; +.IP \(bu 4 +\fBdone\fR (\fBfunction done(err, node, file)\fR) \[em] See FUNCTION DONE(ERR, NODE, FILE). +.RE 0 + +.P +\fBReturns\fR +.P +\fBNode\fR \[em] The given node. +.P +\fBThrows\fR +.P +When no \fBnode\fR was given and no node was found on the file. +.SS "\fBfunction done(err, node, file)\fR" +.P +Invoked when transformation is complete. +.P +\fBSignatures\fR +.RS 0 +.IP \(bu 4 +\fBfunction done(err)\fR; +.IP \(bu 4 +\fBfunction done(null, node, file)\fR. +.RE 0 + +.P +\fBParameters\fR +.RS 0 +.IP \(bu 4 +\fBerr\fR (\fBError\fR) \[em] Failure; +.IP \(bu 4 +\fBnode\fR (\fBNode\fR) \[em] Transformed node; +.IP \(bu 4 +\fBfile\fR (\fBFile\fR) \[em] File object representing the input file; +.RE 0 + +.SH "\FBREMARK.STRINGIFY(NODE\[LB], FILE\[RB]\[LB], OPTIONS\[RB])\FR" +.P +Compile a node into a document. +.P +\fBSignatures\fR +.RS 0 +.IP \(bu 4 +\fBdoc \[eq] remark.stringify(node\[lB], file\[ba]value\[rB]\[lB], options\[rB])\fR; +.IP \(bu 4 +\fBdoc \[eq] remark.stringify(file\[lB], options\[rB])\fR. +.RE 0 + +.P +\fBParameters\fR +.RS 0 +.IP \(bu 4 +\fBnode\fR (\fBObject\fR) \[em] Node as returned by \fBparse()\fR, see \fBmdast\fR; +.IP \(bu 4 +\fBfile\fR (\fBVFile\fR) \[em] Virtual file; +.IP \(bu 4 +\fBvalue\fR (\fBstring\fR) \[em] String representation of a file; +.IP \(bu 4 +\fBoptions\fR (\fBObject\fR) \[em] Configuration. +.RE 0 + +.P +\fBReturns\fR +.P +\fBdoc\fR (\fBstring\fR) \[em] Document. +.P +\fBThrows\fR +.P +When no \fBnode\fR was given and no node was found on the file. +.SH "\FBREMARK.PROCESS(FILE\[LB], OPTIONS\[RB]\[LB], DONE\[RB])\FR" +.P +Parse, transform, and compile markdown into something else. +.P +\fBSignatures\fR +.RS 0 +.IP \(bu 4 +\fBdoc? \[eq] remark.process(file\[ba]value\[lB], options\[rB]\[lB], done\[rB])\fR. +.RE 0 + +.P +\fBParameters\fR +.RS 0 +.IP \(bu 4 +\fBfile\fR (\fBFile\fR) \[em] Virtual file; +.IP \(bu 4 +\fBvalue\fR (\fBstring\fR) \[em] Source of a (virtual) file; +.IP \(bu 4 +\fBoptions\fR (\fBObject\fR) \[em] Settings. See \fBremarksetting\fR(7); +.IP \(bu 4 +\fBdone\fR (\fBfunction done(err?, doc?, file?)\fR. +.RE 0 + +.P +\fBReturns\fR +.P +\fBstring?\fR \[em] Document. Formatted in markdown by default, or in whatever a asynchronous generates. When an async transformer is used, \fBnull\fR is returned and \fBdone\fR must be given to receive the results upon completion. +.SS "\fBfunction done(err\[lB], doc\[lB], file\[rB]\[rB])\fR" +.P +Invoked when processing is complete. +.P +\fBSignatures\fR +.RS 0 +.IP \(bu 4 +\fBfunction done(err)\fR; +.IP \(bu 4 +\fBfunction done(null, doc, file)\fR. +.RE 0 + +.P +\fBParameters\fR +.RS 0 +.IP \(bu 4 +\fBerr\fR (\fBError\fR) \[em] Failure; +.IP \(bu 4 +\fBdoc\fR (\fBstring\fR) \[em] Document generated by the process; +.IP \(bu 4 +\fBfile\fR (\fBFile\fR) \[em] File object representing the input file; +.RE 0 + +.SH "\FBFILESET()\FR" +.P +\fBremark\fR(1) compiles multiple files using a \fBFileSet\fR instance. This set is exposed to plug-ins as an argument to the attacher. \fBFileSet\fRs should not be created by plug-ins. +.SH "\FBFILESET.VALUEOF()\FR" +.SH "\FBFILESET.TOJSON()\FR" +.P +Get access to the file objects in a set. +.P +\fBSignatures\fR +.RS 0 +.IP \(bu 4 +\fBfiles \[eq] fileSet.valueOf()\fR. +.RE 0 + +.P +\fBReturns\fR +.P +\fBArray.\fR \[em] List of files being processed by \fBremark\fR(1). +.SH "\FBFILESET.USE(COMPLETER)\FR" +.P +Add a completer to the middleware pipeline of a file-set. When all files are transformed, this pipeline is run and \fBcompleter\fR is invoked with \fBfileSet\fR. +.P +\fBSignatures\fR +.RS 0 +.IP \(bu 4 +\fBfileSet.use(completer)\fR. +.RE 0 + +.P +\fBParameters\fR +.RS 0 +.IP \(bu 4 +\fBcompleter\fR (\fBFunction\fR). +.RE 0 + +.SH "\FBFILESET.ADD(FILE \[BA] FILEPATH)\FR" +.P +Add a new file to be processed by \fBremark\fR(1). The given file is processed just like other files, with a few differences. +.P +Programmatically added files are: +.RS 0 +.IP \(bu 4 +Ignored when their file-path is already added; +.IP \(bu 4 +Never written to the file-system; +.IP \(bu 4 +Not logged about. +.RE 0 + +.P +\fBSignatures\fR +.RS 0 +.IP \(bu 4 +\fBfileSet.use(filePath)\fR; +.IP \(bu 4 +\fBfileSet.use(file)\fR. +.RE 0 + +.P +\fBParameters\fR +.RS 0 +.IP \(bu 4 +\fBfilePath\fR (\fBstring\fR) - Path to virtual file; +.IP \(bu 4 +\fBfile\fR (\fBFile\fR) - Virtual file. +.RE 0 + +.SH "BUGS" +.P +\fI\(lahttps:\[sl]\[sl]github.com\[sl]wooorm\[sl]remark\[sl]issues\(ra\fR +.SH "SEE ALSO" +.P +\fBremark\fR(1), \fBremarkconfig\fR(7), \fBremarksetting\fR(7) +.SH "NOTES" +.P +See also \fI\(lahttps:\[sl]\[sl]github.com\[sl]wooorm\[sl]mdast\(ra\fR. diff --git a/tools/node_modules/remark/man/remarkconfig.7 b/tools/node_modules/remark/man/remarkconfig.7 new file mode 100644 index 00000000000000..5ad144397a8ec3 --- /dev/null +++ b/tools/node_modules/remark/man/remarkconfig.7 @@ -0,0 +1,58 @@ +.TH "REMARKCONFIG" "7" "January 2016" "3.2.2" "remark manual" +.SH "NAME" +\fBremarkconfig\fR - remark configuration +.SH "SYNOPSIS" +.P +\fBremark\fR(1), \fBremark\fR(3), \fBremarkrc\fR(5) +.SH "DESCRIPTION" +.P +\fBremark\fR is configured from multiple sources: +.RS 0 +.IP \(bu 4 +\fBremark\fR(3) accepts configuration as a parameter to its \fBparse()\fR, \fBrun()\fR, and \fBstringify()\fR methods; +.IP \(bu 4 +\fBremark\fR(1) accepts configuration as command line flags through \fB-s\fR, \fB--setting\fR \fIsettings\fR; +.IP \(bu 4 +\fBremark\fR(1) additionally accepts configuration through a \fBsettings\fR key in \fBremarkrc\fR(5) configuration files; +.IP \(bu 4 +Plug-ins can configure \fBremark\fR. For example, \fBremark-yaml-config\fR allows configuration to be set through YAML front-matter. +.RE 0 + +.P +For a list of available configuration settings, see \fBremarksetting\fR(7). +.SH "SETTINGS FOR \FBPROCESS\FR, \FBPARSE\FR, AND \FBSTRINGIFY\FR" +.P +To configure the programmatic interface of \fBremark\fR, pass an object as a second parameter to \fBprocess()\fR, \fBparse()\fR, and \fBstringify()\fR. +.SH "COMMAND LINE SETTINGS" +.P +To configure the shell interface of \fBremark\fR, pass a string to the \fB--setting\fR (or \fB-s\fR) flag. +.P +Command line settings are just JSON, with two exceptions: +.RS 0 +.IP \(bu 4 +Keys do not need to be escaped, thus, both \fB\[dq]foo\[dq]: \[dq]bar\[dq]\fR and \fBfoo: \[dq]bar\[dq]\fR are considered equal; +.IP \(bu 4 +The surrounding braces must not be used: \fB\[dq]foo\[dq]: 1\fR, is first wrapped as \fB\[lC]\[dq]foo\[dq]: 1\[rC]\fR, and then passed to \fBJSON.parse\fR. +.RE 0 + +.P +Valid examples are: +.P +.RS 2 +.nf +remark --setting \[dq]foo:true\[dq] --setting \[dq]\[rs]\[dq]bar\[rs]\[dq]: \[rs]\[dq]baz\[rs]\[dq]\[dq] +remark --setting \[dq]foo-bar:-2\[dq] +remark --setting \[dq]foo: false, bar-baz: \[lB]\[rs]\[dq]qux\[rs]\[dq], 1\[rB]\[dq] +.fi +.RE +.P +Command Line Settings can be specified both in camel- and dash-case: \fBfoo-bar: true\fR and \fBfooBar: true\fR are treated equally. +.SH "CONFIGURATION FILES" +.P +Specify directory specific settings with \fB.remarkrc\fR and \fBpackage.json\fR files. See \fBremarkrc\fR(5) for more information. +.SH "BUGS" +.P +\fI\(lahttps:\[sl]\[sl]github.com\[sl]wooorm\[sl]remark\[sl]issues\(ra\fR +.SH "SEE ALSO" +.P +\fBremark\fR(1), \fBremark\fR(3), \fBremarkignore\fR(5), \fBremarkrc\fR(5), \fBremarksetting\fR(7) diff --git a/tools/node_modules/remark/man/remarkignore.5 b/tools/node_modules/remark/man/remarkignore.5 new file mode 100644 index 00000000000000..b54751842259b8 --- /dev/null +++ b/tools/node_modules/remark/man/remarkignore.5 @@ -0,0 +1,47 @@ +.TH "REMARKIGNORE" "5" "January 2016" "3.2.2" "remark manual" +.SH "NAME" +\fBremarkignore\fR - remark ignore files +.SH "SYNOPSIS" +.P +\fB.remarkignore\fR +.SH "DESCRIPTION" +.P +When \fBremark\fR(1) searches for applicable files, you can tell it to ignore certain globs by placing an \fI.remarkignore\fR file in the current working directory or its ancestral directories. +.P +Unlike \fBremarkrc\fR(5) configuration files, \fBremarkignore\fR(5) files do not cascade: when one is found (or given), the program stops looking for further files. +.SH "FILES" +.P +Each line in a \fBremarkignore\fR(5) file provides a pattern which describes to \fBremark\fR whether or not to process a given path. +.RS 0 +.IP \(bu 4 +Lines are trimmed of initial and final white space; +.IP \(bu 4 +Empty lines are ignored; +.IP \(bu 4 +Lines which start with an octothorp (\fB\[sh]\fR) are ignored; +.IP \(bu 4 +Lines which start with a interrogation-mark (\fB!\fR) negate, thus re-adding a previously ignored file path; +.RE 0 + +.P +For documentation regarding support of wild-cards (\fB*\fR, \fB?\fR), brace expressions (\fB\[lC]one,two\[rC]\fR), and more, see \fB\fBminimatch\fR\fR \fI\(lahttps:\[sl]\[sl]github.com\[sl]isaacs\[sl]minimatch\(ra\fR. +.P +You can pass a \fBgitignore\fR(5) file to \fBremark\fR(1), because it has the same format as \fBremarkignore\fR(5): +.P +.RS 2 +.nf +remark --ignore-path .gitignore +.fi +.RE +.P +\fBremark\fR(1) searches for files with \fI.md\fR, \fI.mkd\fR, \fI.mkdn\fR, \fI.mkdown\fR, \fI.markdown\fR, or \fI.ron\fR as extension. Other files can be explicitly provided to \fBremark\fR(1), or an \fBextension\fR can be given to \fBremark\fR(1) using the \fB--extension, -e\fR flag. +.P +In addition to patterns in \fBremarkignore\fR(5) files, \fInode\[ul]modules\[sl]**\fR are always excluded. +.P +Unless provided directly to \fBremark\fR(1), hidden directories (such as \fI.git\fR) are excluded. +.SH "BUGS" +.P +\fI\(lahttps:\[sl]\[sl]github.com\[sl]wooorm\[sl]remark\[sl]issues\(ra\fR +.SH "SEE ALSO" +.P +\fBremark\fR(1), \fBremarkrc\fR(5), \fBgitignore\fR(5), \fBremarkconfig\fR(7), \fBremarksetting\fR(7) diff --git a/tools/node_modules/remark/man/remarkplugin.3 b/tools/node_modules/remark/man/remarkplugin.3 new file mode 100644 index 00000000000000..f6e7762be0d023 --- /dev/null +++ b/tools/node_modules/remark/man/remarkplugin.3 @@ -0,0 +1,271 @@ +.TH "REMARKPLUGIN" "3" "January 2016" "3.2.2" "remark manual" +.SH "NAME" +\fBremarkplugin\fR - remark plug-in creation +.SH "SYNOPSIS" +.P +.RS 2 +.nf +\[sl]** + * Change a file-extension to \[ga]\[aq]html\[aq]\[ga]. + *\[sl] +function transformer(ast, file) \[lC] + file.move(\[lC] + \[aq]extension\[aq]: \[aq]html\[aq] + \[rC]); +\[rC] + +\[sl]** + * Expose. + * This plugin can be used as \[ga]remark.use(plugin)\[ga]. + *\[sl] +module.exports \[eq] function () \[lC] + return transformer; +\[rC]; +.fi +.RE +.SH "DESCRIPTION" +.P +This manual contains information on how \fBremark\fR(3) plugins work. It focusses on how to create plugins, rather than on how to implement them. To implement plugins, see \fBremark\fR(3) and \fBremarkplugin\fR(7). +.P +An \fBremark\fR plugin does up to three things: +.RS 0 +.IP \(bu 4 +It modifies the processor: the parser, the compiler; +.IP \(bu 4 +It transforms the AST; +.IP \(bu 4 +It adds new files to be processed by \fBremark\fR(1). +.RE 0 + +.P +All have their own function. The first is called an \[lq]attacher\[rq] (see \fBATTACHER\fR). The second is named a \[lq]transformer\[rq] (see \fBTRANSFORMER\fR). The third is named a \[lq]completer\[rq] (see \fBCOMPLETER\fR). An \[lq]attacher\[rq] may return a \[lq]transformer\[rq] and attach a \[lq]completer\[rq]. +.P +An attacher has access to the parser, which provides its own pluggable interface, consisting of tokenizers (see \fBTOKENIZER\fR) and locators (see \fBLOCATOR\fR). +.SH "\FBFUNCTION ATTACHER(REMARK\[LB], OPTIONS\[RB]\[LB], FILESET\[RB])\FR" +.P +.RS 2 +.nf +\[sl]** + * Add an extension. + * The \[ga]processor\[ga] is the instance of remark this attacher + * is \[ga]use\[ga]d on. + * This plugin can be used as \[ga]remark.use(plugin, \[lC]ext: \[aq]html\[aq]\[rC])\[ga]. + *\[sl] +module.exports \[eq] function (processor, options) \[lC] + var extension \[eq] (options \[ba]\[ba] \[lC]\[rC]).ext; + + \[sl]** + * Change a file-extension to \[ga]extension\[ga]. + *\[sl] + function transformer(ast, file) \[lC] + file.move(\[lC] + \[aq]extension\[aq]: extension + \[rC]); + \[rC] + + return transformer; +\[rC]; +.fi +.RE +.P +To modify the parser, the compiler, or access the file-set on \fBremark\fR(1), create an attacher. +.P +An attacher is the thing passed to \fBuse()\fR. It can receive plugin specific options, but that is entirely up to the developer. An \fBattacher\fR is invoked when the plugin is \fBuse\fRd on an \fBremark\fR instance, and can return a \fBtransformer\fR which will be called on subsequent processes. +.P +Note that \fBremark\fR(1) invokes \fBattacher\fR for each file, not just once. +.P +\fBSignatures\fR +.RS 0 +.IP \(bu 4 +\fBtransformer? \[eq] attacher(remark, options\[lB], fileSet\[rB])\fR. +.RE 0 + +.P +\fBParameters\fR +.RS 0 +.IP \(bu 4 +\fBremark\fR (\fBObject\fR) \[em] Context on which the plugin was \fBuse\fRd; +.IP \(bu 4 +\fBoptions\fR (\fBObject\fR, optional) \[em] Plugin specific options; +.IP \(bu 4 +\fBfileSet\fR (\fBFileSet\fR, optional) \[em] Access to all files being processed by \fBremark\fR(1). Only passed on the Command-Line. See \fBremark\fR(3) for more information regarding file-sets. +.RE 0 + +.P +\fBReturns\fR +.P +\fBtransformer\fR (optional) \[em] See FUNCTION TRANSFORMER(NODE, FILE\[lB], NEXT\[rB]). +.SH "\FBFUNCTION TRANSFORMER(NODE, FILE\[LB], NEXT\[RB])\FR" +.P +.RS 2 +.nf +var visit \[eq] require(\[aq]unist-util-visit\[aq]); + +\[sl]** + * Add a \[ga]js\[ga] language flag to code nodes when without flag. + *\[sl] +function transformer(ast, file) \[lC] + visit(ast, \[aq]code\[aq], function (node) \[lC] + if (!node.lang) \[lC] + node.lang \[eq] \[aq]js\[aq]; + \[rC] + \[rC]); +\[rC] + +\[sl]** + * Expose. + * This plugin can be used as \[ga]remark.use(plugin)\[ga]. + *\[sl] +module.exports \[eq] function () \[lC] + return transformer; +\[rC]; +.fi +.RE +.P +To transform an \fBmdast\fR node, create a \fBtransformer\fR. A \fBtransformer\fR is a simple function which is invoked each time a document is processed by a \fBremark\fR processor. A transformer should transform \fBnode\fR or modify \fBfile\fR. +.P +\fBSignatures\fR +.RS 0 +.IP \(bu 4 +\fBerr? \[eq] transformer(node, file, \[lB]next\[rB])\fR. +.RE 0 + +.P +\fBParameters\fR +.RS 0 +.IP \(bu 4 +\fBnode\fR (\fBNode\fR) \[em] See \fBmdast\fR; +.IP \(bu 4 +\fBfile\fR (\fBVFile\fR) \[em] Virtual file; +.IP \(bu 4 +\fBnext\fR (\fBfunction(err?)\fR, optional) \[em] If the signature includes \fBnode\fR, \fBfile\fR, and \fBnext\fR, \fBtransformer\fR \fBmay\fR finish asynchronous, and \fBmust\fR invoke \fBnext()\fR on completion with an optional error. +.RE 0 + +.P +\fBReturns\fR +.P +\fBerr\fR (\fBError\fR, optional) \[em] Exception which will be thrown. +.SH "\FBFUNCTION COMPLETER(FILESET\[LB], NEXT\[RB])\FR" +.P +To access all files once they are transformed, create a \fBcompleter\fR. A \fBcompleter\fR is invoked before files are compiled, written, and logged, but after reading, parsing, and transforming. Thus, a completer can still change files or add messages. +.P +\fBSignatures\fR +.RS 0 +.IP \(bu 4 +\fBerr? \[eq] completer(fileSet\[lB], next\[rB])\fR. +.RE 0 + +.P +\fBProperties\fR +.RS 0 +.IP \(bu 4 +\fBpluginId\fR (\fB*\fR) \[em] \fBattacher\fR is invoked for each file, so if it \fBuse\fRs \fBcompleter\fR on the file-set, it would attach multiple times. By providing \fBpluginId\fR on \fBcompleter\fR, \fBremark\fR will ensure only one \fBcompleter\fR with that identifier is will be added. +.RE 0 + +.P +\fBParameters\fR +.RS 0 +.IP \(bu 4 +\fBfileSet\fR (\fBFileSet\fR) \[em] All files being processed by \fBremark\fR(1); +.IP \(bu 4 +\fBnext\fR (\fBfunction(err?)\fR, optional) \[em] If the signature includes \fBfileSet\fR and \fBnext\fR, \fBcompleter\fR \fBmay\fR finish asynchronous, and \fBmust\fR invoke \fBnext()\fR on completion with an optional error. +.RE 0 + +.P +\fBReturns\fR +.P +\fBerr\fR (\fBError\fR, optional) \[em] Exception which will be thrown. +.SH "\FBFUNCTION TOKENIZER(EAT, VALUE, SILENT)\FR" +.P +.RS 2 +.nf +function mention(eat, value) \[lC] + var match \[eq] \[sl]\[ha]\[at](\[rs]w\[pl])\[sl].exec(value); + + if (match) \[lC] + if (silent) \[lC] + return true; + \[rC] + + return eat(match\[lB]0\[rB])(\[lC] + \[aq]type\[aq]: \[aq]link\[aq], + \[aq]href\[aq]: \[aq]https:\[sl]\[sl]my-social-network\[sl]\[aq] \[pl] match\[lB]1\[rB], + \[aq]children\[aq]: \[lB]\[lC] + \[aq]type\[aq]: \[aq]text\[aq], + \[aq]value\[aq]: match\[lB]0\[rB] + \[rC]\[rB] + \[rC]); + \[rC] +\[rC] +.fi +.RE +.P +Most often, using transformers to manipulate a syntax-tree produces the desired output. Sometimes, mainly when there is a need to introduce new syntactic entities with a certain level of precedence, interfacing with the parser is necessary. \fBremark\fR knows two types of tokenizers based on the kinds of markdown nodes: block level (e.g., paragraphs or fenced code blocks) and inline level (e.g., emphasis or inline code spans). Block level tokenizers are the same as inline level tokenizers, with the exception that the latter require \fBlocator\fR functions. +.P +Tokenizers \fItest\fR whether a certain given documents starts with a certain syntactic entity. When that occurs, they consume that token, a process which is called \[lq]eating\[rq] in \fBremark\fR. Locators enable tokenizers to function faster by providing information on the where the next entity occurs. +.P +For a complete example, see \fB\fBtest\[sl]mentions.js\fR\fR \fI\(lahttps:\[sl]\[sl]github.com\[sl]wooorm\[sl]remark\[sl]blob\[sl]master\[sl]test\[sl]mentions.js\(ra\fR and how it utilises and attaches a tokenizer and a locator. +.P +\fBSignatures\fR +.RS 0 +.IP \(bu 4 +\fBNode? \[eq] transformer(eat, value)\fR; +.IP \(bu 4 +\fBboolean? \[eq] transformer(eat, value, silent\[rB]\fR. +.RE 0 + +.P +\fBParameters\fR +.RS 0 +.IP \(bu 4 +\fBeat\fR (\fBFunction\fR) \[em] Function used to eat, when applicable, an entity; +.IP \(bu 4 +\fBvalue\fR (\fBstring\fR) \[em] Value which might start an entity; +.IP \(bu 4 +\fBsilent\fR (\fBboolean\fR, optional) \[em] When \fBtrue\fR, instead of actually eating a value, the tokenizer must return whether a node can definitely be found at the start of \fBvalue\fR. +.RE 0 + +.P +\fBReturns\fR +.P +In \fInormal\fR mode, optionally an \fBmdast\fR node representing the eaten entity. Otherwise, in \fIsilent\fR mode, a truthy value must be returned when the tokenizer predicts with certainty an entity could be found. +.SH "\FBFUNCTION LOCATOR(VALUE, FROMINDEX)\FR" +.P +.RS 2 +.nf +function locator(value, fromIndex) \[lC] + return value.indexOf(\[aq]\[at]\[aq], fromIndex); +\[rC] +.fi +.RE +.P +As mentioned in the previous section, locators are required for inline tokenization in order to keep the process performant. Locators enable inline tokenizers to function faster by providing information on the where the next entity occurs. +.P +\fBSignatures\fR +.RS 0 +.IP \(bu 4 +\fBnumber \[eq] locator(value, fromIndex)\fR. +.RE 0 + +.P +\fBParameters\fR +.RS 0 +.IP \(bu 4 +\fBvalue\fR (\fBstring\fR) \[em] Value which might contain an entity; +.IP \(bu 4 +\fBfromIndex\fR (\fBnumber\fR) \[em] Position to start searching at. +.RE 0 + +.P +\fBReturns\fR +.P +The index at which the entity might start, and \fB-1\fR otherwise. +.SH "BUGS" +.P +\fI\(lahttps:\[sl]\[sl]github.com\[sl]wooorm\[sl]remark\[sl]issues\(ra\fR +.SH "SEE ALSO" +.P +\fBremark\fR(1), \fBremark\fR(3), \fBremarkplugin\fR(7) +.SH "NOTES" +.P +See also \fI\(lahttps:\[sl]\[sl]github.com\[sl]wooorm\[sl]mdast\(ra\fR. diff --git a/tools/node_modules/remark/man/remarkplugin.7 b/tools/node_modules/remark/man/remarkplugin.7 new file mode 100644 index 00000000000000..2884ccc22dee4c --- /dev/null +++ b/tools/node_modules/remark/man/remarkplugin.7 @@ -0,0 +1,84 @@ +.TH "REMARKPLUGIN" "7" "January 2016" "3.2.2" "remark manual" +.SH "NAME" +\fBremarkplugin\fR - remark plug-in usage +.SH "SYNOPSIS" +.P +On \fBremark\fR(1) +.P +.RS 2 +.nf +npm install remark-lint +remark --use lint example.md +.fi +.RE +.P +On \fBremark\fR(3) +.P +.RS 2 +.nf +var remark \[eq] require(\[aq]remark\[aq]); +var lint \[eq] require(\[aq]remark-lint\[aq]); + +remark.use(lint).process(\[aq]Alpha **Bravo** Charlie\[aq]); +.fi +.RE +.SH "DESCRIPTION" +.P +This manual contains information on how \fBremark\fR(3) plugins can be used. To create plugins, see \fBremarkplugin\fR(3). +.P +\fBremark\fR plugins lie at the core of \fBremark\fR\[cq]s vision. As they operate on the same syntax tree, there is no start-up time penalty when using more than one plug-in\[em]something which traditional tools, which need to re-compile to markdown to connect together, can be immense on large documents. +.SH "USING PLUGINS" +.SS "PROGRAMMATIC USAGE" +.P +To use plugins in \fBremark\fR(3), the JavaScript API, pass a plugin to \fBremark.use(plugin, options)\fR. +.P +See \fBremark\fR(3)\[cq]s USE section for more information. +.SS "COMMAND LINE USAGE" +.P +To use plugins from the CLI, use the \fB--use\fR key (short: \fB-u\fR), which can be passed a single npm plugin, or a path to any CommonJS JavaScript file which exposes a plugin. When referencing an npm plugin, and the plugin\[cq]s name is prefixed by \fBremark-\fR, this prefix can be omitted. +.P +To pass options, follow the plugin\[cq]s location by an equals sign (\fB\[eq]\fR), which is then followed by settings. For example, \fB--use toc\[eq]heading:contents\fR. +.P +Each setting is delimited by a comma or a semi-colon, and each key is separated with a colon from its value. +.P +See \fBremark\fR(1)\[cq]s \fB-u\fR, \fB--use\fR option for more information. +.SS ".remarkrc" +.P +\fB.remarkrc\fR and \fBpackage.json\fR files can declare which plugins should be used by including either a list of plugins or a map of plugin\[en]options pairs on a \fBplugins\fR field in the exposed object. When referencing an npm plugin, and the plugin\[cq]s name is prefixed by \fBremark-\fR, this prefix can be omitted. +.P +For example, the following \fB.remarkrc\fR file will use \fB\fBremark-lint\fR\fR \fI\(lahttps:\[sl]\[sl]www.npmjs.com\[sl]package\[sl]remark-lint\(ra\fR: +.P +.RS 2 +.nf +\[lC] + \[dq]plugins\[dq]: \[lB] + \[dq]lint\[dq] + \[rB] +\[rC] +.fi +.RE +.P +The following \fB.remarkrc\fR file does the same, but additionally provides options to the plugin: +.P +.RS 2 +.nf +\[lC] + \[dq]plugins\[dq]: \[lC] + \[dq]lint\[dq]: \[lC] + \[dq]maximum-line-length\[dq]: 70 + \[rC] + \[rC] +\[rC] +.fi +.RE +.P +See \fBremarkrc\fR(5) for more information. +.SH "BUGS" +.P +\fI\(lahttps:\[sl]\[sl]github.com\[sl]wooorm\[sl]remark\[sl]issues\(ra\fR +.SH "SEE ALSO" +.P +\fBremark\fR(1), \fBremark\fR(3), \fBremarkplugin\fR(7) +.SH "NOTES" +.P +See also \fI\(lahttps:\[sl]\[sl]github.com\[sl]wooorm\[sl]mdast\(ra\fR. diff --git a/tools/node_modules/remark/man/remarkrc.5 b/tools/node_modules/remark/man/remarkrc.5 new file mode 100644 index 00000000000000..072e12386f5a2b --- /dev/null +++ b/tools/node_modules/remark/man/remarkrc.5 @@ -0,0 +1,152 @@ +.TH "REMARKRC" "5" "January 2016" "3.2.2" "remark manual" +.SH "NAME" +\fBremarkrc\fR - remark config files +.SH "SYNOPSIS" +.P +\fB.remarkrc\fR, \fBpackage.json\fR +.SH "DESCRIPTION" +.P +\fBremark\fR gets its configuration from the command line and \fBremarkrc\fR files. +.P +For a list of available configuration options, see \fBremark\fR(1) or \fBremarksetting\fR(7). +.SH "FILES" +.P +All \fBremarkrc\fR(5) configuration files are in JSON. +.P +Automatically detected files named \fBpackage.json\fR use the \fBremarkConfig\fR field, whereas other files are used as a whole. +.SH "FIELDS" +.SS "output" +.P +.RS 2 +.nf +\[lC] + \[dq]output\[dq]: \[dq]man\[sl]\[dq] +\[rC] +.fi +.RE +.P +The \fBoutput\fR field specifies whether or not files should be written to the file-system (similar to \fB-o\fR, \fB--output\fR \fIpath\fR on \fBremark\fR(1)). It can be either a boolean, or a string. In the case of a string, the value is treated as the \fBtarget\fR or \fBdirectory\fR field for \fBmv\fR(1). +.SS "settings" +.P +.RS 2 +.nf +\[lC] + \[dq]settings\[dq]: \[lC] + \[dq]commonmark\[dq]: true, + \[dq]bullet\[dq]: \[dq]*\[dq] + \[rC] +\[rC] +.fi +.RE +.P +Settings contains an object mapping a setting to a value. See \fBremarksetting\fR(7) for available settings. +.SS "plugins" +.P +List: +.P +.RS 2 +.nf +\[lC] + \[dq]plugins\[dq]: \[lB] + \[dq]toc\[dq] + \[rB] +\[rC] +.fi +.RE +.P +Options: +.P +.RS 2 +.nf +\[lC] + \[dq]plugins\[dq]: \[lC] + \[dq]github\[dq]: \[lC] + \[dq]repository\[dq]: \[dq]foo\[sl]bar\[dq] + \[rC] + \[rC] +\[rC] +.fi +.RE +.P +The \fBplugins\fR field contains either an array of plugins, or an object mapping plugins to their options. +.P +When a plugin is prefixed with \fBremark-\fR (which is recommended), the prefix can be omitted in the plugin list or map. +.SH "CASCADE" +.P +Precedence is as follows: +.RS 0 +.IP \(bu 4 +Plug-ins and settings passed to \fBremark\fR(1); +.IP \(bu 4 +Files passed to \fBremark\fR(1); +.IP \(bu 4 +Files named \fB.remarkrc\fR and \fBremarkConfig\fR fields in \fBpackage.json\fR in the directory of the processed file, and in ancestral directories; +.IP \(bu 4 +If no \fB.remarkrc\fR and \fBpackage.json\fR were detected in the directory of the file or its ancestral directories, a per-user configuration file (\fB\[ti]\[sl].remarkrc\fR) is used; +.RE 0 + +.P +If both \fB.remarkrc\fR and \fBpackage.json\fR exist in a directory, the file named \fB.remarkrc\fR takes precedence in the cascade over \fBpackage.json\fR. +.P +For example, for the following project: +.P +.RS 2 +.nf +project +\[ba]-- docs +\[ba] \[ba]-- .remarkrc +\[ba] \[ba]-- doc.md +\[ba] +\[ba]-- .remarkrc +\[ba]-- package.json +\[ba]-- readme.md +.fi +.RE +.P +Where \fBdocs\[sl].remarkrc\fR looks as follows: +.P +.RS 2 +.nf +\[lC] + \[dq]settings\[dq]: \[lC] + \[dq]bullet\[dq]: \[dq]\[pl]\[dq] + \[rC] +\[rC] +.fi +.RE +.P +And \fBpackage.json\fR contains: +.P +.RS 2 +.nf +\[lC] + \[dq]remarkConfig\[dq]: \[lC] + \[dq]settings\[dq]: \[lC] + \[dq]bullet\[dq]: \[dq]*\[dq] + \[rC] + \[rC] +\[rC] +.fi +.RE +.P +And \fB.remarkrc\fR contains: +.P +.RS 2 +.nf +\[lC] + \[dq]settings\[dq]: \[lC] + \[dq]bullet\[dq]: \[dq]-\[dq] + \[rC] +\[rC] +.fi +.RE +.P +Then, when compiling \fBdocs\[sl]doc.md\fR, \fBremark\fR(1) would use \fBbullet: \[dq]\[pl]\[dq]\fR because \fBdocs\[sl].remarkrc\fR takes precedence over \fB.remarkrc\fR and \fBpackage.json\fR. +.P +When compiling \fBreadme.md\fR, \fBremark\fR(1) would use \fBbullet: \[dq]-\[dq]\fR, because \fB.remarkrc\fR takes precedence over \fBpackage.json\fR. +.SH "BUGS" +.P +\fI\(lahttps:\[sl]\[sl]github.com\[sl]wooorm\[sl]remark\[sl]issues\(ra\fR +.SH "SEE ALSO" +.P +\fBremark\fR(1), \fBremarkignore\fR(5), \fBremarksetting\fR(7) diff --git a/tools/node_modules/remark/man/remarksetting.7 b/tools/node_modules/remark/man/remarksetting.7 new file mode 100644 index 00000000000000..e478031e019f17 --- /dev/null +++ b/tools/node_modules/remark/man/remarksetting.7 @@ -0,0 +1,1542 @@ +.TH "REMARKSETTING" "7" "January 2016" "3.2.2" "remark manual" +.SH "NAME" +\fBremarksetting\fR - remark settings +.SH "SYNOPSIS" +.P +\fBremark\fR(1), \fBremark\fR(3), \fBremarkrc\fR(5) +.SH "DESCRIPTION" +.P +This page contains information and usage examples regarding available options for \fBremark\fR(3)\[cq]s \fBparse()\fR and \fBstringify()\fR. +.SH "TABLE OF CONTENTS" +.RS 0 +.IP \(bu 4 +\fBParse\fR \fI(Parse)\fR +.RS 4 +.IP \(bu 4 +\fBBreaks\fR \fI(Breaks)\fR +.IP \(bu 4 +\fBCommonMark\fR \fI(CommonMark)\fR +.IP \(bu 4 +\fBFootnotes\fR \fI(Footnotes)\fR +.IP \(bu 4 +\fBGitHub Flavoured Markdown\fR \fI(GitHub Flavoured Markdown)\fR +.IP \(bu 4 +\fBPedantic\fR \fI(Pedantic)\fR +.IP \(bu 4 +\fBPosition\fR \fI(Position)\fR +.IP \(bu 4 +\fBYAML\fR \fI(YAML)\fR +.RE 0 + +.IP \(bu 4 +\fBStringify\fR \fI(Stringify)\fR +.RS 4 +.IP \(bu 4 +\fBList Item Bullets\fR \fI(List Item Bullets)\fR +.IP \(bu 4 +\fBClosed ATX Headings\fR \fI(Closed ATX Headings)\fR +.IP \(bu 4 +\fBEmphasis Markers\fR \fI(Emphasis Markers)\fR +.IP \(bu 4 +\fBEncoding Entities\fR \fI(Encoding Entities)\fR +.IP \(bu 4 +\fBFence\fR \fI(Fence)\fR +.IP \(bu 4 +\fBFences\fR \fI(Fences)\fR +.IP \(bu 4 +\fBList Item Indent\fR \fI(List Item Indent)\fR +.IP \(bu 4 +\fBLoose Tables\fR \fI(Loose Tables)\fR +.IP \(bu 4 +\fBList Marker Increase\fR \fI(List Marker Increase)\fR +.IP \(bu 4 +\fBHorizontal Rules\fR \fI(Horizontal Rules)\fR +.IP \(bu 4 +\fBSetext Headings\fR \fI(Setext Headings)\fR +.IP \(bu 4 +\fBSpaced Tables\fR \fI(Spaced Tables)\fR +.RE 0 + +.RE 0 + +.SH "PARSE" +.SS "Breaks" +.P +Setting \fBbreaks: true\fR (default: \fBfalse\fR) exposes new line characters inside Paragraphs as Breaks. +.P +The following document: +.P +.RS 2 +.nf +A +paragraph. +.fi +.RE +.P +And the below JavaScript: +.P +.RS 2 +.nf +var ast \[eq] remark.parse(document, \[lC] + \[dq]breaks\[dq]: true +\[rC]); +.fi +.RE +.P +Yields: +.P +.RS 2 +.nf +\[lC] + \[dq]type\[dq]: \[dq]root\[dq], + \[dq]children\[dq]: \[lB] + \[lC] + \[dq]type\[dq]: \[dq]paragraph\[dq], + \[dq]children\[dq]: \[lB] + \[lC] + \[dq]type\[dq]: \[dq]text\[dq], + \[dq]value\[dq]: \[dq]A\[dq], + \[dq]position\[dq]: \[lC] + \[dq]start\[dq]: \[lC] + \[dq]line\[dq]: 1, + \[dq]column\[dq]: 1 + \[rC], + \[dq]end\[dq]: \[lC] + \[dq]line\[dq]: 1, + \[dq]column\[dq]: 2 + \[rC], + \[dq]indent\[dq]: \[lB]\[rB] + \[rC] + \[rC], + \[lC] + \[dq]type\[dq]: \[dq]break\[dq], + \[dq]position\[dq]: \[lC] + \[dq]start\[dq]: \[lC] + \[dq]line\[dq]: 1, + \[dq]column\[dq]: 2 + \[rC], + \[dq]end\[dq]: \[lC] + \[dq]line\[dq]: 2, + \[dq]column\[dq]: 1 + \[rC], + \[dq]indent\[dq]: \[lB] + 1 + \[rB] + \[rC] + \[rC], + \[lC] + \[dq]type\[dq]: \[dq]text\[dq], + \[dq]value\[dq]: \[dq]paragraph.\[dq], + \[dq]position\[dq]: \[lC] + \[dq]start\[dq]: \[lC] + \[dq]line\[dq]: 2, + \[dq]column\[dq]: 1 + \[rC], + \[dq]end\[dq]: \[lC] + \[dq]line\[dq]: 2, + \[dq]column\[dq]: 11 + \[rC], + \[dq]indent\[dq]: \[lB]\[rB] + \[rC] + \[rC] + \[rB], + \[dq]position\[dq]: \[lC] + \[dq]start\[dq]: \[lC] + \[dq]line\[dq]: 1, + \[dq]column\[dq]: 1 + \[rC], + \[dq]end\[dq]: \[lC] + \[dq]line\[dq]: 2, + \[dq]column\[dq]: 11 + \[rC], + \[dq]indent\[dq]: \[lB] + 1 + \[rB] + \[rC] + \[rC] + \[rB], + \[dq]position\[dq]: \[lC] + \[dq]start\[dq]: \[lC] + \[dq]line\[dq]: 1, + \[dq]column\[dq]: 1 + \[rC], + \[dq]end\[dq]: \[lC] + \[dq]line\[dq]: 3, + \[dq]column\[dq]: 1 + \[rC] + \[rC] +\[rC] +.fi +.RE +.SS "CommonMark" +.P +Setting \fBcommonmark: true\fR (default: \fBfalse\fR) allows and disallows several constructs. +.P +The following constructs are allowed: +.RS 0 +.IP \(bu 4 +Empty lines to split \fBBlockquotes\fR; +.IP \(bu 4 +Parentheses (\fB(\fR and \fB)\fR) as delimiters for \fBLink\fR and \fBImage\fR titles; +.IP \(bu 4 +Any escaped \fBASCII-punctuation\fR \fI\(lahttp:\[sl]\[sl]spec.commonmark.org\[sl]0.18\[sl]\[sh]backslash-escapes\(ra\fR character; +.IP \(bu 4 +Ordered list-items with a closing parenthesis (\fB)\fR); +.IP \(bu 4 +Link (and footnote, when enabled) reference definitions in blockquotes; +.RE 0 + +.P +The following constructs are not allowed: +.RS 0 +.IP \(bu 4 +\fBCode\fR directly following a \fBParagraph\fR; +.IP \(bu 4 +ATX-headings (\fB\[sh] Hash headings\fR) without spacing after initial hashes or and before closing hashes; +.IP \(bu 4 +Setext headings (\fBUnderline headings\[rs]n---\fR) when following a paragraph; +.IP \(bu 4 +Newlines in \fBLink\fR and \fBImage\fR titles; +.IP \(bu 4 +White space in \fBLink\fR and \fBImage\fR URLs in auto-links (links in brackets, \fB<\fR and \fB>\fR); +.IP \(bu 4 +Lazy \fBBlockquote\fR continuation\[em]lines not preceded by a closing angle bracket (\fB>\fR)\[em]for \fBList\fRs, \fBCode\fR, and \fBHorizontalRule\fR. +.RE 0 + +.P +The following document: +.P +.RS 2 +.nf +This is a paragraph + and this is also part of the preceding paragraph. +.fi +.RE +.P +And the below JavaScript: +.P +.RS 2 +.nf +var ast \[eq] remark.parse(document, \[lC] + \[dq]commonmark\[dq]: true +\[rC]); +.fi +.RE +.P +Yields: +.P +.RS 2 +.nf +\[lC] + \[dq]type\[dq]: \[dq]root\[dq], + \[dq]children\[dq]: \[lB] + \[lC] + \[dq]type\[dq]: \[dq]paragraph\[dq], + \[dq]children\[dq]: \[lB] + \[lC] + \[dq]type\[dq]: \[dq]text\[dq], + \[dq]value\[dq]: \[dq]This is a paragraph\[rs]n and this is also part of the preceding paragraph.\[dq], + \[dq]position\[dq]: \[lC] + \[dq]start\[dq]: \[lC] + \[dq]line\[dq]: 1, + \[dq]column\[dq]: 1 + \[rC], + \[dq]end\[dq]: \[lC] + \[dq]line\[dq]: 2, + \[dq]column\[dq]: 54 + \[rC], + \[dq]indent\[dq]: \[lB] + 1 + \[rB] + \[rC] + \[rC] + \[rB], + \[dq]position\[dq]: \[lC] + \[dq]start\[dq]: \[lC] + \[dq]line\[dq]: 1, + \[dq]column\[dq]: 1 + \[rC], + \[dq]end\[dq]: \[lC] + \[dq]line\[dq]: 2, + \[dq]column\[dq]: 54 + \[rC], + \[dq]indent\[dq]: \[lB] + 1 + \[rB] + \[rC] + \[rC] + \[rB], + \[dq]position\[dq]: \[lC] + \[dq]start\[dq]: \[lC] + \[dq]line\[dq]: 1, + \[dq]column\[dq]: 1 + \[rC], + \[dq]end\[dq]: \[lC] + \[dq]line\[dq]: 3, + \[dq]column\[dq]: 1 + \[rC] + \[rC] +\[rC] +.fi +.RE +.SS "Footnotes" +.P +Setting \fBfootnotes: true\fR (default: \fBfalse\fR) enables inline and reference footnotes. +.P +Footnotes are wrapped in square brackets, and preceded by a caret (\fB\[ha]\fR). +.P +It is possible to reference other footnotes inside footnotes. +.P +The following document: +.P +.RS 2 +.nf +Something something\[lB]\[ha]or something?\[rB]. + +And something else\[lB]\[ha]1\[rB]. + +\[lB]\[ha]1\[rB]: This reference style footnote can contains paragraphs. + + - and lists +.fi +.RE +.P +And the below JavaScript: +.P +.RS 2 +.nf +var ast \[eq] remark.parse(document, \[lC] + \[dq]footnotes\[dq]: true +\[rC]); +.fi +.RE +.P +Yields: +.P +.RS 2 +.nf +\[lC] + \[dq]type\[dq]: \[dq]root\[dq], + \[dq]children\[dq]: \[lB] + \[lC] + \[dq]type\[dq]: \[dq]paragraph\[dq], + \[dq]children\[dq]: \[lB] + \[lC] + \[dq]type\[dq]: \[dq]text\[dq], + \[dq]value\[dq]: \[dq]Something something\[dq], + \[dq]position\[dq]: \[lC] + \[dq]start\[dq]: \[lC] + \[dq]line\[dq]: 1, + \[dq]column\[dq]: 1 + \[rC], + \[dq]end\[dq]: \[lC] + \[dq]line\[dq]: 1, + \[dq]column\[dq]: 20 + \[rC], + \[dq]indent\[dq]: \[lB]\[rB] + \[rC] + \[rC], + \[lC] + \[dq]type\[dq]: \[dq]footnote\[dq], + \[dq]children\[dq]: \[lB] + \[lC] + \[dq]type\[dq]: \[dq]text\[dq], + \[dq]value\[dq]: \[dq]or something?\[dq], + \[dq]position\[dq]: \[lC] + \[dq]start\[dq]: \[lC] + \[dq]line\[dq]: 1, + \[dq]column\[dq]: 36 + \[rC], + \[dq]end\[dq]: \[lC] + \[dq]line\[dq]: 1, + \[dq]column\[dq]: 49 + \[rC], + \[dq]indent\[dq]: \[lB]\[rB] + \[rC] + \[rC] + \[rB], + \[dq]position\[dq]: \[lC] + \[dq]start\[dq]: \[lC] + \[dq]line\[dq]: 1, + \[dq]column\[dq]: 20 + \[rC], + \[dq]end\[dq]: \[lC] + \[dq]line\[dq]: 1, + \[dq]column\[dq]: 36 + \[rC], + \[dq]indent\[dq]: \[lB]\[rB] + \[rC] + \[rC], + \[lC] + \[dq]type\[dq]: \[dq]text\[dq], + \[dq]value\[dq]: \[dq].\[dq], + \[dq]position\[dq]: \[lC] + \[dq]start\[dq]: \[lC] + \[dq]line\[dq]: 1, + \[dq]column\[dq]: 36 + \[rC], + \[dq]end\[dq]: \[lC] + \[dq]line\[dq]: 1, + \[dq]column\[dq]: 37 + \[rC], + \[dq]indent\[dq]: \[lB]\[rB] + \[rC] + \[rC] + \[rB], + \[dq]position\[dq]: \[lC] + \[dq]start\[dq]: \[lC] + \[dq]line\[dq]: 1, + \[dq]column\[dq]: 1 + \[rC], + \[dq]end\[dq]: \[lC] + \[dq]line\[dq]: 1, + \[dq]column\[dq]: 37 + \[rC], + \[dq]indent\[dq]: \[lB]\[rB] + \[rC] + \[rC], + \[lC] + \[dq]type\[dq]: \[dq]paragraph\[dq], + \[dq]children\[dq]: \[lB] + \[lC] + \[dq]type\[dq]: \[dq]text\[dq], + \[dq]value\[dq]: \[dq]And something else\[dq], + \[dq]position\[dq]: \[lC] + \[dq]start\[dq]: \[lC] + \[dq]line\[dq]: 3, + \[dq]column\[dq]: 1 + \[rC], + \[dq]end\[dq]: \[lC] + \[dq]line\[dq]: 3, + \[dq]column\[dq]: 19 + \[rC], + \[dq]indent\[dq]: \[lB]\[rB] + \[rC] + \[rC], + \[lC] + \[dq]type\[dq]: \[dq]footnoteReference\[dq], + \[dq]identifier\[dq]: \[dq]1\[dq], + \[dq]position\[dq]: \[lC] + \[dq]start\[dq]: \[lC] + \[dq]line\[dq]: 3, + \[dq]column\[dq]: 19 + \[rC], + \[dq]end\[dq]: \[lC] + \[dq]line\[dq]: 3, + \[dq]column\[dq]: 23 + \[rC], + \[dq]indent\[dq]: \[lB]\[rB] + \[rC] + \[rC], + \[lC] + \[dq]type\[dq]: \[dq]text\[dq], + \[dq]value\[dq]: \[dq].\[dq], + \[dq]position\[dq]: \[lC] + \[dq]start\[dq]: \[lC] + \[dq]line\[dq]: 3, + \[dq]column\[dq]: 23 + \[rC], + \[dq]end\[dq]: \[lC] + \[dq]line\[dq]: 3, + \[dq]column\[dq]: 24 + \[rC], + \[dq]indent\[dq]: \[lB]\[rB] + \[rC] + \[rC] + \[rB], + \[dq]position\[dq]: \[lC] + \[dq]start\[dq]: \[lC] + \[dq]line\[dq]: 3, + \[dq]column\[dq]: 1 + \[rC], + \[dq]end\[dq]: \[lC] + \[dq]line\[dq]: 3, + \[dq]column\[dq]: 24 + \[rC], + \[dq]indent\[dq]: \[lB]\[rB] + \[rC] + \[rC], + \[lC] + \[dq]type\[dq]: \[dq]footnoteDefinition\[dq], + \[dq]identifier\[dq]: \[dq]1\[dq], + \[dq]children\[dq]: \[lB] + \[lC] + \[dq]type\[dq]: \[dq]paragraph\[dq], + \[dq]children\[dq]: \[lB] + \[lC] + \[dq]type\[dq]: \[dq]text\[dq], + \[dq]value\[dq]: \[dq]This reference style footnote can contains paragraphs.\[dq], + \[dq]position\[dq]: \[lC] + \[dq]start\[dq]: \[lC] + \[dq]line\[dq]: 5, + \[dq]column\[dq]: 7 + \[rC], + \[dq]end\[dq]: \[lC] + \[dq]line\[dq]: 5, + \[dq]column\[dq]: 61 + \[rC], + \[dq]indent\[dq]: \[lB]\[rB] + \[rC] + \[rC] + \[rB], + \[dq]position\[dq]: \[lC] + \[dq]start\[dq]: \[lC] + \[dq]line\[dq]: 5, + \[dq]column\[dq]: 7 + \[rC], + \[dq]end\[dq]: \[lC] + \[dq]line\[dq]: 5, + \[dq]column\[dq]: 61 + \[rC], + \[dq]indent\[dq]: \[lB]\[rB] + \[rC] + \[rC], + \[lC] + \[dq]type\[dq]: \[dq]list\[dq], + \[dq]ordered\[dq]: false, + \[dq]start\[dq]: null, + \[dq]loose\[dq]: false, + \[dq]children\[dq]: \[lB] + \[lC] + \[dq]type\[dq]: \[dq]listItem\[dq], + \[dq]loose\[dq]: false, + \[dq]checked\[dq]: null, + \[dq]children\[dq]: \[lB] + \[lC] + \[dq]type\[dq]: \[dq]paragraph\[dq], + \[dq]children\[dq]: \[lB] + \[lC] + \[dq]type\[dq]: \[dq]text\[dq], + \[dq]value\[dq]: \[dq]and lists\[dq], + \[dq]position\[dq]: \[lC] + \[dq]start\[dq]: \[lC] + \[dq]line\[dq]: 7, + \[dq]column\[dq]: 6 + \[rC], + \[dq]end\[dq]: \[lC] + \[dq]line\[dq]: 7, + \[dq]column\[dq]: 15 + \[rC], + \[dq]indent\[dq]: \[lB]\[rB] + \[rC] + \[rC] + \[rB], + \[dq]position\[dq]: \[lC] + \[dq]start\[dq]: \[lC] + \[dq]line\[dq]: 7, + \[dq]column\[dq]: 6 + \[rC], + \[dq]end\[dq]: \[lC] + \[dq]line\[dq]: 7, + \[dq]column\[dq]: 15 + \[rC], + \[dq]indent\[dq]: \[lB]\[rB] + \[rC] + \[rC] + \[rB], + \[dq]position\[dq]: \[lC] + \[dq]start\[dq]: \[lC] + \[dq]line\[dq]: 7, + \[dq]column\[dq]: 1 + \[rC], + \[dq]end\[dq]: \[lC] + \[dq]line\[dq]: 7, + \[dq]column\[dq]: 15 + \[rC], + \[dq]indent\[dq]: \[lB]\[rB] + \[rC] + \[rC] + \[rB], + \[dq]position\[dq]: \[lC] + \[dq]start\[dq]: \[lC] + \[dq]line\[dq]: 7, + \[dq]column\[dq]: 1 + \[rC], + \[dq]end\[dq]: \[lC] + \[dq]line\[dq]: 7, + \[dq]column\[dq]: 15 + \[rC], + \[dq]indent\[dq]: \[lB]\[rB] + \[rC] + \[rC] + \[rB], + \[dq]position\[dq]: \[lC] + \[dq]start\[dq]: \[lC] + \[dq]line\[dq]: 5, + \[dq]column\[dq]: 1 + \[rC], + \[dq]end\[dq]: \[lC] + \[dq]line\[dq]: 7, + \[dq]column\[dq]: 15 + \[rC], + \[dq]indent\[dq]: \[lB] + 1, + 1 + \[rB] + \[rC] + \[rC] + \[rB], + \[dq]position\[dq]: \[lC] + \[dq]start\[dq]: \[lC] + \[dq]line\[dq]: 1, + \[dq]column\[dq]: 1 + \[rC], + \[dq]end\[dq]: \[lC] + \[dq]line\[dq]: 8, + \[dq]column\[dq]: 1 + \[rC] + \[rC] +\[rC] +.fi +.RE +.SS "GitHub Flavoured Markdown" +.P +Setting \fBgfm: true\fR (default: \fBtrue\fR) enables: +.RS 0 +.IP \(bu 4 +\fBFenced code blocks\fR \fI\(lahttps:\[sl]\[sl]help.github.com\[sl]articles\[sl]github-flavored-markdown\[sl]\[sh]fenced-code-blocks\(ra\fR; +.IP \(bu 4 +\fBAutolinking of URLs\fR \fI\(lahttps:\[sl]\[sl]help.github.com\[sl]articles\[sl]github-flavored-markdown\[sl]\[sh]url-autolinking\(ra\fR; +.IP \(bu 4 +\fBDeletions (strikethrough)\fR \fI\(lahttps:\[sl]\[sl]help.github.com\[sl]articles\[sl]github-flavored-markdown\[sl]\[sh]strikethrough\(ra\fR; +.IP \(bu 4 +\fBTask lists\fR \fI\(lahttps:\[sl]\[sl]help.github.com\[sl]articles\[sl]writing-on-github\[sl]\[sh]task-lists\(ra\fR; +.IP \(bu 4 +\fBTables\fR \fI\(lahttps:\[sl]\[sl]help.github.com\[sl]articles\[sl]github-flavored-markdown\[sl]\[sh]tables\(ra\fR. +.RE 0 + +.P +The following document: +.P +.RS 2 +.nf +hello \[ti]\[ti]hi\[ti]\[ti] world +.fi +.RE +.P +And the below JavaScript: +.P +.RS 2 +.nf +var ast \[eq] remark.parse(document, \[lC] + \[dq]gfm\[dq]: true +\[rC]); +.fi +.RE +.P +Yields: +.P +.RS 2 +.nf +\[lC] + \[dq]type\[dq]: \[dq]root\[dq], + \[dq]children\[dq]: \[lB] + \[lC] + \[dq]type\[dq]: \[dq]paragraph\[dq], + \[dq]children\[dq]: \[lB] + \[lC] + \[dq]type\[dq]: \[dq]text\[dq], + \[dq]value\[dq]: \[dq]hello \[dq], + \[dq]position\[dq]: \[lC] + \[dq]start\[dq]: \[lC] + \[dq]line\[dq]: 1, + \[dq]column\[dq]: 1 + \[rC], + \[dq]end\[dq]: \[lC] + \[dq]line\[dq]: 1, + \[dq]column\[dq]: 7 + \[rC], + \[dq]indent\[dq]: \[lB]\[rB] + \[rC] + \[rC], + \[lC] + \[dq]type\[dq]: \[dq]delete\[dq], + \[dq]children\[dq]: \[lB] + \[lC] + \[dq]type\[dq]: \[dq]text\[dq], + \[dq]value\[dq]: \[dq]hi\[dq], + \[dq]position\[dq]: \[lC] + \[dq]start\[dq]: \[lC] + \[dq]line\[dq]: 1, + \[dq]column\[dq]: 9 + \[rC], + \[dq]end\[dq]: \[lC] + \[dq]line\[dq]: 1, + \[dq]column\[dq]: 11 + \[rC], + \[dq]indent\[dq]: \[lB]\[rB] + \[rC] + \[rC] + \[rB], + \[dq]position\[dq]: \[lC] + \[dq]start\[dq]: \[lC] + \[dq]line\[dq]: 1, + \[dq]column\[dq]: 7 + \[rC], + \[dq]end\[dq]: \[lC] + \[dq]line\[dq]: 1, + \[dq]column\[dq]: 13 + \[rC], + \[dq]indent\[dq]: \[lB]\[rB] + \[rC] + \[rC], + \[lC] + \[dq]type\[dq]: \[dq]text\[dq], + \[dq]value\[dq]: \[dq] world\[dq], + \[dq]position\[dq]: \[lC] + \[dq]start\[dq]: \[lC] + \[dq]line\[dq]: 1, + \[dq]column\[dq]: 13 + \[rC], + \[dq]end\[dq]: \[lC] + \[dq]line\[dq]: 1, + \[dq]column\[dq]: 19 + \[rC], + \[dq]indent\[dq]: \[lB]\[rB] + \[rC] + \[rC] + \[rB], + \[dq]position\[dq]: \[lC] + \[dq]start\[dq]: \[lC] + \[dq]line\[dq]: 1, + \[dq]column\[dq]: 1 + \[rC], + \[dq]end\[dq]: \[lC] + \[dq]line\[dq]: 1, + \[dq]column\[dq]: 19 + \[rC], + \[dq]indent\[dq]: \[lB]\[rB] + \[rC] + \[rC] + \[rB], + \[dq]position\[dq]: \[lC] + \[dq]start\[dq]: \[lC] + \[dq]line\[dq]: 1, + \[dq]column\[dq]: 1 + \[rC], + \[dq]end\[dq]: \[lC] + \[dq]line\[dq]: 2, + \[dq]column\[dq]: 1 + \[rC] + \[rC] +\[rC] +.fi +.RE +.SS "Pedantic" +.P +Setting \fBpedantic: true\fR (default: \fBfalse\fR): +.RS 0 +.IP \(bu 4 +Adds support for emphasis and strongness, with underscores (\fB\[ul]\fR), inside words; +.IP \(bu 4 +Adds support for different list bullets (\fB*\fR, \fB-\fR, \fB\[pl]\fR) for the same list (when in \fBcommonmark: true\fR mode, the same goes for both ordered list delimiters: \fB.\fR and \fB)\fR); +.IP \(bu 4 +Removes less spaces in list-items (a maximum of four instead of the whole indent). +.RE 0 + +.P +The following document: +.P +.RS 2 +.nf +Check out some\[ul]file\[ul]name.txt +.fi +.RE +.P +And the below JavaScript: +.P +.RS 2 +.nf +var ast \[eq] remark.parse(document, \[lC] + \[dq]pedantic\[dq]: true +\[rC]); +.fi +.RE +.P +Yields: +.P +.RS 2 +.nf +\[lC] + \[dq]type\[dq]: \[dq]root\[dq], + \[dq]children\[dq]: \[lB] + \[lC] + \[dq]type\[dq]: \[dq]paragraph\[dq], + \[dq]children\[dq]: \[lB] + \[lC] + \[dq]type\[dq]: \[dq]text\[dq], + \[dq]value\[dq]: \[dq]Check out some\[dq], + \[dq]position\[dq]: \[lC] + \[dq]start\[dq]: \[lC] + \[dq]line\[dq]: 1, + \[dq]column\[dq]: 1 + \[rC], + \[dq]end\[dq]: \[lC] + \[dq]line\[dq]: 1, + \[dq]column\[dq]: 15 + \[rC], + \[dq]indent\[dq]: \[lB]\[rB] + \[rC] + \[rC], + \[lC] + \[dq]type\[dq]: \[dq]emphasis\[dq], + \[dq]children\[dq]: \[lB] + \[lC] + \[dq]type\[dq]: \[dq]text\[dq], + \[dq]value\[dq]: \[dq]file\[dq], + \[dq]position\[dq]: \[lC] + \[dq]start\[dq]: \[lC] + \[dq]line\[dq]: 1, + \[dq]column\[dq]: 16 + \[rC], + \[dq]end\[dq]: \[lC] + \[dq]line\[dq]: 1, + \[dq]column\[dq]: 20 + \[rC], + \[dq]indent\[dq]: \[lB]\[rB] + \[rC] + \[rC] + \[rB], + \[dq]position\[dq]: \[lC] + \[dq]start\[dq]: \[lC] + \[dq]line\[dq]: 1, + \[dq]column\[dq]: 15 + \[rC], + \[dq]end\[dq]: \[lC] + \[dq]line\[dq]: 1, + \[dq]column\[dq]: 21 + \[rC], + \[dq]indent\[dq]: \[lB]\[rB] + \[rC] + \[rC], + \[lC] + \[dq]type\[dq]: \[dq]text\[dq], + \[dq]value\[dq]: \[dq]name.txt\[dq], + \[dq]position\[dq]: \[lC] + \[dq]start\[dq]: \[lC] + \[dq]line\[dq]: 1, + \[dq]column\[dq]: 21 + \[rC], + \[dq]end\[dq]: \[lC] + \[dq]line\[dq]: 1, + \[dq]column\[dq]: 29 + \[rC], + \[dq]indent\[dq]: \[lB]\[rB] + \[rC] + \[rC] + \[rB], + \[dq]position\[dq]: \[lC] + \[dq]start\[dq]: \[lC] + \[dq]line\[dq]: 1, + \[dq]column\[dq]: 1 + \[rC], + \[dq]end\[dq]: \[lC] + \[dq]line\[dq]: 1, + \[dq]column\[dq]: 29 + \[rC], + \[dq]indent\[dq]: \[lB]\[rB] + \[rC] + \[rC] + \[rB], + \[dq]position\[dq]: \[lC] + \[dq]start\[dq]: \[lC] + \[dq]line\[dq]: 1, + \[dq]column\[dq]: 1 + \[rC], + \[dq]end\[dq]: \[lC] + \[dq]line\[dq]: 2, + \[dq]column\[dq]: 1 + \[rC] + \[rC] +\[rC] +.fi +.RE +.SS "Position" +.P +Setting \fBposition: false\fR (default: \fBtrue\fR) disables positions on nodes. Positions show where each node was originally located in the document. +.RS 0 +.P +\fBCareful! Disabling this will stop some plug-ins from working and will no longer show line\[sl]column information in warnings!\fR +.RE 0 + +.P +The following document: +.P +.RS 2 +.nf +Hello **world**! +.fi +.RE +.P +And the below JavaScript: +.P +.RS 2 +.nf +var ast \[eq] remark.parse(document, \[lC] + \[dq]position\[dq]: false +\[rC]); +.fi +.RE +.P +Yields: +.P +.RS 2 +.nf +\[lC] + \[dq]type\[dq]: \[dq]root\[dq], + \[dq]children\[dq]: \[lB] + \[lC] + \[dq]type\[dq]: \[dq]paragraph\[dq], + \[dq]children\[dq]: \[lB] + \[lC] + \[dq]type\[dq]: \[dq]text\[dq], + \[dq]value\[dq]: \[dq]Hello \[dq] + \[rC], + \[lC] + \[dq]type\[dq]: \[dq]strong\[dq], + \[dq]children\[dq]: \[lB] + \[lC] + \[dq]type\[dq]: \[dq]text\[dq], + \[dq]value\[dq]: \[dq]world\[dq] + \[rC] + \[rB] + \[rC], + \[lC] + \[dq]type\[dq]: \[dq]text\[dq], + \[dq]value\[dq]: \[dq]!\[dq] + \[rC] + \[rB] + \[rC] + \[rB] +\[rC] +.fi +.RE +.SS "YAML" +.P +Setting \fByaml: true\fR (default: \fBtrue\fR) enables raw YAML front matter to be detected (thus ignoring markdown-like syntax). +.P +The following document: +.P +.RS 2 +.nf +--- +title: YAML is Cool +--- + +\[sh] YAML is Cool +.fi +.RE +.P +And the below JavaScript: +.P +.RS 2 +.nf +var ast \[eq] remark.parse(document, \[lC] + \[dq]yaml\[dq]: true +\[rC]); +.fi +.RE +.P +Yields: +.P +.RS 2 +.nf +\[lC] + \[dq]type\[dq]: \[dq]root\[dq], + \[dq]children\[dq]: \[lB] + \[lC] + \[dq]type\[dq]: \[dq]yaml\[dq], + \[dq]value\[dq]: \[dq]title: YAML is Cool\[dq], + \[dq]position\[dq]: \[lC] + \[dq]start\[dq]: \[lC] + \[dq]line\[dq]: 1, + \[dq]column\[dq]: 1 + \[rC], + \[dq]end\[dq]: \[lC] + \[dq]line\[dq]: 3, + \[dq]column\[dq]: 4 + \[rC], + \[dq]indent\[dq]: \[lB] + 1, + 1 + \[rB] + \[rC] + \[rC], + \[lC] + \[dq]type\[dq]: \[dq]heading\[dq], + \[dq]depth\[dq]: 1, + \[dq]children\[dq]: \[lB] + \[lC] + \[dq]type\[dq]: \[dq]text\[dq], + \[dq]value\[dq]: \[dq]YAML is Cool\[dq], + \[dq]position\[dq]: \[lC] + \[dq]start\[dq]: \[lC] + \[dq]line\[dq]: 5, + \[dq]column\[dq]: 3 + \[rC], + \[dq]end\[dq]: \[lC] + \[dq]line\[dq]: 5, + \[dq]column\[dq]: 15 + \[rC], + \[dq]indent\[dq]: \[lB]\[rB] + \[rC] + \[rC] + \[rB], + \[dq]position\[dq]: \[lC] + \[dq]start\[dq]: \[lC] + \[dq]line\[dq]: 5, + \[dq]column\[dq]: 1 + \[rC], + \[dq]end\[dq]: \[lC] + \[dq]line\[dq]: 5, + \[dq]column\[dq]: 15 + \[rC], + \[dq]indent\[dq]: \[lB]\[rB] + \[rC] + \[rC] + \[rB], + \[dq]position\[dq]: \[lC] + \[dq]start\[dq]: \[lC] + \[dq]line\[dq]: 1, + \[dq]column\[dq]: 1 + \[rC], + \[dq]end\[dq]: \[lC] + \[dq]line\[dq]: 6, + \[dq]column\[dq]: 1 + \[rC] + \[rC] +\[rC] +.fi +.RE +.SH "STRINGIFY" +.SS "List Item Bullets" +.P +Setting \fBbullet: string\fR (\fB\[dq]-\[dq]\fR, \fB\[dq]*\[dq]\fR, or \fB\[dq]\[pl]\[dq]\fR, default: \fB\[dq]-\[dq]\fR) will stringify list items in unordered lists using the provided character as bullets. +.P +The following document: +.P +.RS 2 +.nf +- First level + + - Second level + + - Third level +.fi +.RE +.P +And the below JavaScript: +.P +.RS 2 +.nf +var ast \[eq] remark.parse(document); + +remark.stringify(ast, \[lC] + \[dq]bullet\[dq]: \[dq]*\[dq] +\[rC]); +.fi +.RE +.P +Yields: +.P +.RS 2 +.nf +* First level + + * Second level + + * Third level +.fi +.RE +.SS "Closed ATX Headings" +.P +Setting \fBcloseAtx: true\fR (default: \fBfalse\fR) will stringify ATX headings with additional hash-marks after the heading. +.P +The following document: +.P +.RS 2 +.nf +\[sh] First level + +\[sh]\[sh] Second level + +\[sh]\[sh]\[sh] Third level +.fi +.RE +.P +And the below JavaScript: +.P +.RS 2 +.nf +var ast \[eq] remark.parse(document); + +remark.stringify(ast, \[lC] + \[dq]closeAtx\[dq]: true +\[rC]); +.fi +.RE +.P +Yields: +.P +.RS 2 +.nf +\[sh] First level \[sh] + +\[sh]\[sh] Second level \[sh]\[sh] + +\[sh]\[sh]\[sh] Third level \[sh]\[sh]\[sh] +.fi +.RE +.SS "Emphasis Markers" +.P +Two options are provided to customise how slight- and strong emphasis are compiled: +.RS 0 +.IP \(bu 4 +\fBemphasis: string\fR (\fB\[dq]\[ul]\[dq]\fR or \fB\[dq]*\[dq]\fR, default: \fB\[dq]\[ul]\[dq]\fR) will wrap slight emphasis in the provided character; +.IP \(bu 4 +\fBstrong: string\fR (\fB\[dq]\[ul]\[dq]\fR or \fB\[dq]*\[dq]\fR, default: \fB\[dq]*\[dq]\fR) will wrap strong emphasis with the provided character (twice). +.RE 0 + +.P +The following document: +.P +.RS 2 +.nf +*emphasis* + +\[ul]\[ul]strong\[ul]\[ul] +.fi +.RE +.P +And the below JavaScript: +.P +.RS 2 +.nf +var ast \[eq] remark.parse(document); + +remark.stringify(ast, \[lC] + \[dq]emphasis\[dq]: \[dq]\[ul]\[dq], + \[dq]strong\[dq]: \[dq]*\[dq] +\[rC]); +.fi +.RE +.P +Yields: +.P +.RS 2 +.nf +\[ul]emphasis\[ul] + +**strong** +.fi +.RE +.SS "Encoding Entities" +.P +Setting \fBentities: true\fR (default: \fBfalse\fR) will \fBencode\fR \fI\(lahttps:\[sl]\[sl]github.com\[sl]mathiasbynens\[sl]he\[sh]heencodetext-options\(ra\fR any symbols that are not printable ASCII symbols and special HTML characters (\fB&\fR, \fB<\fR, \fB>\fR, \fB\[dq]\fR, \fB\[aq]\fR, and \fB\[ga]\fR). +.P +When \fBtrue\fR, named entities are generated (\fB&\fR > \fB&\fR); when \fB\[dq]numbers\[dq]\fR, numbered entities are generated (\fB&\fR > \fB&\[sh]x26;\fR); when \fB\[dq]escape\[dq]\fR, only special HTML characters are encoded (\fB&\fR > \fB&\fR, but \fBö\fR remains \fBö\fR). +.P +Although markdown does not need to encode HTML entities, they can be useful to ensure an ASCII document. +.P +The following document: +.P +.RS 2 +.nf +AT&T, \[lB]AT&T\[rB](http:\[sl]\[sl]at&t.com \[dq]AT&T\[dq]), !\[lB]AT&T\[rB](http:\[sl]\[sl]at&t.com\[sl]fav.ico \[dq]AT&T\[dq]) +.fi +.RE +.P +And the below JavaScript: +.P +.RS 2 +.nf +var ast \[eq] remark.parse(document); + +remark.stringify(ast, \[lC] + \[dq]entities\[dq]: true +\[rC]); +.fi +.RE +.P +Yields: +.P +.RS 2 +.nf +AT&T, \[lB]AT&T\[rB](http:\[sl]\[sl]at&t.com \[dq]AT&T\[dq]), !\[lB]AT&T\[rB](http:\[sl]\[sl]at&t.com\[sl]fav.ico \[dq]AT&T\[dq]) +.fi +.RE +.SS "Fence" +.P +It\[aq]s possible to customise how GFM code fences are compiled: +.RS 0 +.IP \(bu 4 +\fBfence: string\fR (\fB\[dq]\[ti]\[dq]\fR or \fB\[dq]\[ga]\[dq]\fR, default: \fB\[dq]\[ga]\[dq]\fR) will wrap code blocks in the provided character. +.RE 0 + +.P +To render all code blocks with fences (the default behaviour is to only use non-standard fences when a language-flag is present), use \fBfences: true\fR. +.P +The following document: +.P +.RS 2 +.nf + \[ga]\[ga]\[ga]javascript + alert(\[aq]Hello World!\[aq]); + \[ga]\[ga]\[ga] +.fi +.RE +.P +And the below JavaScript: +.P +.RS 2 +.nf +var ast \[eq] remark.parse(document); + +remark.stringify(ast, \[lC] + \[dq]fence\[dq]: \[dq]\[ti]\[dq] +\[rC]); +.fi +.RE +.P +Yields: +.P +.RS 2 +.nf + \[ti]\[ti]\[ti]javascript + alert(\[aq]Hello World!\[aq]); + \[ti]\[ti]\[ti] +.fi +.RE +.SS "Fences" +.P +Setting \fBfences: true\fR (default: \fBfalse\fR) will stringify code blocks without programming-language flags using heredoc-style fences. +.P +To use different fence markers, use \fBfence: string\fR. +.P +The following document: +.P +.RS 2 +.nf +A code block: + + alert(\[aq]Hello World!\[aq]); +.fi +.RE +.P +And the below JavaScript: +.P +.RS 2 +.nf +var ast \[eq] remark.parse(document); + +remark.stringify(ast, \[lC] + \[dq]fences\[dq]: true +\[rC]); +.fi +.RE +.P +Yields: +.P +.RS 2 +.nf + A code block: + + \[ga]\[ga]\[ga] + alert(\[aq]Hello World!\[aq]); + \[ga]\[ga]\[ga] +.fi +.RE +.SS "List Item Indent" +.P +Setting \fBlistItemIndent: \[dq]1\[dq]\fR (\fB\[dq]tab\[dq]\fR, \fB\[dq]mixed\[dq]\fR, or \fB\[dq]1\[dq]\fR, default: \fB\[dq]tab\[dq]\fR) will stringify list items with a single space following the bullet. +.P +The default, \fB\[dq]tab\[dq]\fR, will compile to bullets and spacing set to tab-stops (multiples of 4). +.P +The other value, \fB\[dq]mixed\[dq]\fR, uses \fB\[dq]tab\[dq]\fR when the list item spans multiple lines, and \fB\[dq]1\[dq]\fR otherwise. +.RS 0 +.P +\fBNote\fR: choosing \fB\[dq]tab\[dq]\fR results in the greatest support across vendors when mixing lists, block quotes, indented code, etcetera. +.RE 0 + +.P +The following document: +.P +.RS 2 +.nf +1. foo bar baz. + + + +99. foo bar baz. + + + +999. foo bar baz. + + + +1. foo bar baz. + foo bar baz. + + + +99. foo bar baz. + foo bar baz. + + + +999. foo bar baz. + foo bar baz. +.fi +.RE +.P +And the below JavaScript: +.P +.RS 2 +.nf +var ast \[eq] remark.parse(document); + +remark.stringify(ast, \[lC] + \[dq]listItemIndent\[dq]: \[dq]mixed\[dq] +\[rC]); +.fi +.RE +.P +Yields: +.P +.RS 2 +.nf +1. foo bar baz. + + + +99. foo bar baz. + + + +999. foo bar baz. + + + +1. foo bar baz. + foo bar baz. + + + +99. foo bar baz. + foo bar baz. + + + +999. foo bar baz. + foo bar baz. +.fi +.RE +.SS "Loose Tables" +.P +Setting \fBlooseTable: true\fR (default: \fBfalse\fR) will stringify GFM tables with neither starting nor ending pipes. +.P +The following document: +.P +.RS 2 +.nf +\[ba] Hello \[ba] World \[ba] +\[ba] :---- \[ba] -----: \[ba] +\[ba] How \[ba] are \[ba] +\[ba] you \[ba] today? \[ba] +.fi +.RE +.P +And the below JavaScript: +.P +.RS 2 +.nf +var ast \[eq] remark.parse(document); + +remark.stringify(ast, \[lC] + \[dq]looseTable\[dq]: true +\[rC]); +.fi +.RE +.P +Yields: +.P +.RS 2 +.nf +Hello \[ba] World +:---- \[ba] -----: +How \[ba] are +you \[ba] today? +.fi +.RE +.SS "List Marker Increase" +.P +Setting \fBincrementListMarker: false\fR (default: \fBtrue\fR) will stringify ordered list items based on the first item\[cq]s marker and will not increment further list items. +.P +The following document: +.P +.RS 2 +.nf +1. Alpha; +2. Bravo; +3. Charley. + + +3. Delta; +4. Echo; +5. Foxtrott. +.fi +.RE +.P +And the below JavaScript: +.P +.RS 2 +.nf +var ast \[eq] remark.parse(document); + +remark.stringify(ast, \[lC] + \[dq]incrementListMarker\[dq]: false +\[rC]); +.fi +.RE +.P +Yields: +.P +.RS 2 +.nf +1. Alpha; +1. Bravo; +1. Charley. + + +3. Delta; +3. Echo; +3. Foxtrott. +.fi +.RE +.SS "Horizontal Rules" +.P +Three options are provided to customise how horizontal rules will be compiled: +.RS 0 +.IP \(bu 4 +\fBrule: string\fR (\fB\[dq]-\[dq]\fR, \fB\[dq]*\[dq]\fR, or \fB\[dq]\[ul]\[dq]\fR, default: \fB\[dq]*\[dq]\fR) will stringify horizontal rules using the provided character as its bullets; +.IP \(bu 4 +\fBruleSpaces: true\fR (default: \fBfalse\fR) will stringify horizontal rules using spaces; +.IP \(bu 4 +\fBruleRepetition: number\fR (default: \fB3\fR) will stringify horizontal rules with the provided amount of repetitions. +.RE 0 + +.P +The following document: +.P +.RS 2 +.nf +A rule: + +--- +.fi +.RE +.P +And the below JavaScript: +.P +.RS 2 +.nf +var ast \[eq] remark.parse(document); + +remark.stringify(ast, \[lC] + \[dq]rule\[dq]: \[dq]*\[dq], + \[dq]ruleRepetition\[dq]: 40, + \[dq]ruleSpaces\[dq]: true +\[rC]); +.fi +.RE +.P +Yields: +.P +.RS 2 +.nf +A rule: + +* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +.fi +.RE +.SS "Setext Headings" +.P +Setting \fBsetext: true\fR (default: \fBfalse\fR) will stringify headings as \fBSetext\fR \fI\(lahttp:\[sl]\[sl]en.wikipedia.org\[sl]wiki\[sl]Setext\[sh]Setext\[ul]tags\(ra\fR (underlines) when possible. +.P +Respectively, primary headings are compiled with a row of equals-signs (\fB\[eq]\fR), and secondary headings with a row of dashes (\fB-\fR). +.P +The following document: +.P +.RS 2 +.nf +\[sh] First level + +\[sh]\[sh] Second level + +\[sh]\[sh]\[sh] Third level +.fi +.RE +.P +And the below JavaScript: +.P +.RS 2 +.nf +var ast \[eq] remark.parse(document); + +remark.stringify(ast, \[lC] + \[dq]setext\[dq]: true +\[rC]); +.fi +.RE +.P +Yields: +.P +.RS 2 +.nf +First level +\[eq]\[eq]\[eq]\[eq]\[eq]\[eq]\[eq]\[eq]\[eq]\[eq]\[eq] + +Second level +------------ + +\[sh]\[sh]\[sh] Third level +.fi +.RE +.SS "Spaced Tables" +.P +Setting \fBspacedTable: false\fR (default: \fBtrue\fR) will stringify GFM tables without spaces after starting pipes, before ending pipes, and surrounding delimiting pipes. +.P +The following document: +.P +.RS 2 +.nf +\[ba] Hello \[ba] World \[ba] +\[ba] :---- \[ba] -----: \[ba] +\[ba] How \[ba] are \[ba] +\[ba] you \[ba] today? \[ba] +.fi +.RE +.P +And the below JavaScript: +.P +.RS 2 +.nf +var ast \[eq] remark.parse(document); + +remark.stringify(ast, \[lC] + \[dq]spacedTable\[dq]: false +\[rC]); +.fi +.RE +.P +Yields: +.P +.RS 2 +.nf +\[ba]Hello\[ba] World\[ba] +\[ba]:----\[ba]-----:\[ba] +\[ba]How \[ba] are\[ba] +\[ba]you \[ba]today?\[ba] +.fi +.RE diff --git a/tools/node_modules/remark/package.json b/tools/node_modules/remark/package.json new file mode 100644 index 00000000000000..ca06d6d4c65221 --- /dev/null +++ b/tools/node_modules/remark/package.json @@ -0,0 +1,184 @@ +{ + "_args": [ + [ + "remark@^3.2.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\eslint-plugin-markdown" + ] + ], + "_from": "remark@>=3.2.0 <4.0.0", + "_id": "remark@3.2.2", + "_inCache": true, + "_location": "/remark", + "_nodeVersion": "0.11.16", + "_npmUser": { + "email": "tituswormer@gmail.com", + "name": "wooorm" + }, + "_npmVersion": "2.3.0", + "_phantomChildren": {}, + "_requested": { + "name": "remark", + "raw": "remark@^3.2.0", + "rawSpec": "^3.2.0", + "scope": null, + "spec": ">=3.2.0 <4.0.0", + "type": "range" + }, + "_requiredBy": [ + "/eslint-plugin-markdown" + ], + "_resolved": "https://registry.npmjs.org/remark/-/remark-3.2.2.tgz", + "_shasum": "28a59c2a8308b3b08ad7d68a3745cdaf44a004cb", + "_shrinkwrap": null, + "_spec": "remark@^3.2.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\eslint-plugin-markdown", + "author": { + "email": "tituswormer@gmail.com", + "name": "Titus Wormer" + }, + "bin": { + "remark": "bin/remark" + }, + "bugs": { + "url": "https://github.com/wooorm/remark/issues" + }, + "contributors": [ + { + "name": "Christopher Jeffrey" + } + ], + "dependencies": { + "camelcase": "^2.0.0", + "ccount": "^1.0.0", + "chalk": "^1.0.0", + "chokidar": "^1.0.5", + "collapse-white-space": "^1.0.0", + "commander": "^2.0.0", + "concat-stream": "^1.0.0", + "debug": "^2.0.0", + "elegant-spinner": "^1.0.0", + "extend.js": "0.0.2", + "glob": "^6.0.1", + "globby": "^4.0.0", + "he": "^0.5.0", + "log-update": "^1.0.1", + "longest-streak": "^1.0.0", + "markdown-table": "^0.4.0", + "minimatch": "^3.0.0", + "npm-prefix": "^1.0.1", + "parse-entities": "^1.0.0", + "repeat-string": "^1.5.0", + "stringify-entities": "^1.0.0", + "to-vfile": "^1.0.0", + "trim": "^0.0.1", + "trim-trailing-lines": "^1.0.0", + "unified": "^2.0.0", + "user-home": "^2.0.0", + "vfile": "^1.1.0", + "vfile-find-down": "^1.0.0", + "vfile-find-up": "^1.0.0", + "vfile-reporter": "^1.5.0", + "ware": "^1.3.0" + }, + "description": "Markdown processor powered by plugins", + "devDependencies": { + "bail": "^1.0.0", + "browserify": "^13.0.0", + "clone": "^1.0.1", + "escodegen": "^1.7.0", + "eslint": "^1.1.0", + "esmangle": "^1.0.0", + "esprima": "^2.6.0", + "istanbul": "^0.4.0", + "jscs": "^2.0.0", + "jscs-jsdoc": "^1.0.0", + "mocha": "^2.0.0", + "remark-comment-config": "^2.0.0", + "remark-github": "^3.0.0", + "remark-html": "^2.0.0", + "remark-lint": "^2.0.0", + "remark-man": "^2.0.0", + "remark-retext": "^1.0.1", + "remark-toc": "^2.0.0", + "remark-usage": "^2.0.0", + "remark-validate-links": "^2.0.0", + "remark-yaml-config": "^2.0.0", + "retext": "^1.0.0", + "retext-equality": "^1.6.4", + "retext-readability": "^1.0.0" + }, + "directories": { + "man": "./man" + }, + "dist": { + "shasum": "28a59c2a8308b3b08ad7d68a3745cdaf44a004cb", + "tarball": "http://registry.npmjs.org/remark/-/remark-3.2.2.tgz" + }, + "files": [ + "bin", + "index.js", + "lib", + "man" + ], + "gitHead": "6c38cc7ff0260bcceea106ad54474e0eb8966159", + "homepage": "https://github.com/wooorm/remark", + "installable": true, + "keywords": [ + "abstract", + "ast", + "bin", + "cli", + "json", + "markdown", + "markup", + "parse", + "stringify", + "syntax", + "tree" + ], + "license": "MIT", + "maintainers": [ + { + "name": "jongleberry", + "email": "jonathanrichardong@gmail.com" + }, + { + "name": "wooorm", + "email": "tituswormer@gmail.com" + } + ], + "man": [ + "/home/travis/build/wooorm/remark/man/remark.1", + "/home/travis/build/wooorm/remark/man/remark.3", + "/home/travis/build/wooorm/remark/man/remarkconfig.7", + "/home/travis/build/wooorm/remark/man/remarkignore.5", + "/home/travis/build/wooorm/remark/man/remarkplugin.3", + "/home/travis/build/wooorm/remark/man/remarkplugin.7", + "/home/travis/build/wooorm/remark/man/remarkrc.5", + "/home/travis/build/wooorm/remark/man/remarksetting.7" + ], + "name": "remark", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "https://github.com/wooorm/remark.git" + }, + "scripts": { + "build": "npm run build-version && npm run build-md && npm run build-options && npm run build-man && npm run build-bundle", + "build-bundle": "node script/build-bundle.js", + "build-man": "bin/remark doc/*.?.md --config-path .remarkrc-man --quiet", + "build-md": "bin/remark . --quiet --frail", + "build-options": "node script/build-options.js", + "build-version": "node script/build-version.js", + "lint": "npm run lint-api && npm run lint-style", + "lint-api": "eslint .", + "lint-style": "jscs --reporter inline .", + "test": "npm run build && npm run lint && npm run test-coverage && npm run test-cli", + "test-api": "mocha --check-leaks test/index.js", + "test-api-extensive": "TEST_EXTENDED=true npm run test-api", + "test-cli": "bash test/cli.sh", + "test-coverage": "istanbul cover _mocha -- -- test/index.js", + "test-travis": "npm run build-md && npm run build-bundle && npm run lint && npm run test-coverage && npm run test-cli" + }, + "version": "3.2.2" +} diff --git a/tools/node_modules/remark/readme.md b/tools/node_modules/remark/readme.md new file mode 100644 index 00000000000000..51dcc26cc208c9 --- /dev/null +++ b/tools/node_modules/remark/readme.md @@ -0,0 +1,229 @@ +# ![remark](https://cdn.rawgit.com/wooorm/remark/master/logo.svg) + +[![Build Status](https://img.shields.io/travis/wooorm/remark.svg)](https://travis-ci.org/wooorm/remark) [![Coverage Status](https://img.shields.io/codecov/c/github/wooorm/remark.svg)](https://codecov.io/github/wooorm/remark) [![Inline docs](https://img.shields.io/badge/docs-A-brightgreen.svg)](http://inch-ci.org/github/wooorm/remark) [![Chat](https://img.shields.io/gitter/room/wooorm/remark.svg)](https://gitter.im/wooorm/remark) + +> **remark** recently changed its name from **mdast**. [Read more about +> what changed and how to migrate »](https://github.com/wooorm/remark/releases/tag/3.0.0) + +**remark** is a markdown processor powered by plugins. Lots of tests. Node, +io.js, and the browser. 100% coverage. + +**remark** is not just another markdown to HTML compiler. It can generate, +and reformat, markdown too. It is powered by [plugins](doc/plugins.md) to do +all kinds of things: [validate your markdown](https://github.com/wooorm/remark-lint), +[add links for GitHub references](https://github.com/wooorm/remark-github), or +[add a table of contents](https://github.com/wooorm/remark-toc). + +The project contains both an extensive [JavaScript API](doc/remark.3.md) for +parsing, modifying, and compiling markdown, and a friendly [Command Line +Interface](doc/remark.1.md) making it easy to validate, prepare, and compile +markdown in a build step. + +## Table of Contents + +* [Installation](#installation) + +* [Usage](#usage) + +* [API](#api) + + * [remark.process(value\[, options\]\[, done\])](#remarkprocessvalue-options-done) + * [remark.use(plugin\[, options\])](#remarkuseplugin-options) + +* [CLI](#cli) + +* [License](#license) + +## Installation + +[npm](https://docs.npmjs.com/cli/install): + +```bash +npm install remark +``` + +[Read more about alternative ways to install and use »](doc/installation.md) + +## Usage + +Load dependencies: + +```javascript +var remark = require('remark'); +var html = require('remark-html'); +var yamlConfig = require('remark-yaml-config'); +``` + +Use plugins: + +```javascript +var processor = remark().use(yamlConfig).use(html); +``` + +Process the document: + +```javascript +var doc = processor.process([ + '---', + 'remark:', + ' commonmark: true', + '---', + '', + '2) Some *emphasis*, **strongness**, and `code`.' +].join('\n')); +``` + +Yields: + +```html +
      +
    1. Some emphasis, strongness, and code.
    2. +
    +``` + +## API + +[**Get Started with the API** »](doc/getting-started.md#application-programming-interface) + +### `remark.process(value[, options][, done])` + +Parse a markdown document, apply plugins to it, and compile it into +something else. + +**Signatures** + +* `doc = remark.process(value, options?, done?)`. + +**Parameters** + +* `value` (`string`) — Markdown document; + +* `options` (`Object`) — Settings: + + * `gfm` (`boolean`, default: `true`) — See [GitHub Flavoured Markdown](doc/remarksetting.7.md#github-flavoured-markdown); + * `yaml` (`boolean`, default: `true`) — See [YAML](doc/remarksetting.7.md#yaml); + * `commonmark` (`boolean`, default: `false`) — See [CommonMark](doc/remarksetting.7.md#commonmark); + * `footnotes` (`boolean`, default: `false`) — See [Footnotes](doc/remarksetting.7.md#footnotes); + * `pedantic` (`boolean`, default: `false`) — See [Pedantic](doc/remarksetting.7.md#pedantic); + * `breaks` (`boolean`, default: `false`) — See [Breaks](doc/remarksetting.7.md#breaks); + * `entities` (`boolean`, default: `false`) — See [Encoding Entities](doc/remarksetting.7.md#encoding-entities); + * `setext` (`boolean`, default: `false`) — See [Setext Headings](doc/remarksetting.7.md#setext-headings); + * `closeAtx` (`boolean`, default: `false`) — See [Closed ATX Headings](doc/remarksetting.7.md#closed-atx-headings); + * `looseTable` (`boolean`, default: `false`) — See [Loose Tables](doc/remarksetting.7.md#loose-tables); + * `spacedTable` (`boolean`, default: `true`) — See [Spaced Tables](doc/remarksetting.7.md#spaced-tables); + * `fence` (`"~"` or ``"`"``, default: ``"`"``) — See [Fence](doc/remarksetting.7.md#fence); + * `fences` (`boolean`, default: `false`) — See [Fences](doc/remarksetting.7.md#fences); + * `bullet` (`"-"`, `"*"`, or `"+"`, default: `"-"`) — See [List Item Bullets](doc/remarksetting.7.md#list-item-bullets); + * `listItemIndent` (`"tab"`, `"mixed"` or `"1"`, default: `"tab"`) — See [List Item Indent](doc/remarksetting.7.md#list-item-indent); + * `incrementListMarker` (`boolean`, default: `true`) — See [List Marker Increase](doc/remarksetting.7.md#list-marker-increase); + * `rule` (`"-"`, `"*"`, or `"_"`, default: `"*"`) — See [Horizontal Rules](doc/remarksetting.7.md#horizontal-rules); + * `ruleRepetition` (`number`, default: `3`) — See [Horizontal Rules](doc/remarksetting.7.md#horizontal-rules); + * `ruleSpaces` (`boolean`, default `true`) — See [Horizontal Rules](doc/remarksetting.7.md#horizontal-rules); + * `strong` (`"_"`, or `"*"`, default `"*"`) — See [Emphasis Markers](doc/remarksetting.7.md#emphasis-markers); + * `emphasis` (`"_"`, or `"*"`, default `"_"`) — See [Emphasis Markers](doc/remarksetting.7.md#emphasis-markers). + * `position` (`boolean`, default: `true`) — See [Position](doc/remarksetting.7.md#position); + +* `done` (`function(Error?, string?)`) — Callback invoked when the output + is generated with either an error, or a result. Only strictly needed when + asynchronous plugins are used. + +All options (including the options object itself) can be `null` or `undefined` +to default to their default values. + +**Returns** + +`string` or `null`: A document. Formatted in markdown by default, or in +whatever a plugin generates. +The result is `null` if a plugin is asynchronous, in which case the callback +`done` should’ve been passed (do not worry: plugin creators make sure you know +its asynchronous). + +### `remark.use(plugin[, options])` + +Change the way [`remark`](#api) works by using a [`plugin`](doc/plugins.md). + +**Signatures** + +* `processor = remark.use(plugin, options?)`; +* `processor = remark.use(plugins)`. + +**Parameters** + +* `plugin` (`Function`) — A [**Plugin**](doc/plugins.md); +* `plugins` (`Array.`) — A list of [**Plugin**](doc/plugins.md)s; +* `options` (`Object?`) — Passed to plugin. Specified by its documentation. + +**Returns** + +`Object`: an instance of Remark: The returned object functions just like +**remark** (it has the same methods), but caches the `use`d plugins. This +provides the ability to chain `use` calls to use multiple plugins, but +ensures the functioning of the **remark** module does not change for other +dependents. + +## CLI + +[**Get Started with the CLI** »](doc/getting-started.md#command-line-interface) + +Install: + +```bash +npm install --global remark +``` + +Use: + +```text +Usage: remark [options] + +Markdown processor powered by plugins + +Options: + + -h, --help output usage information + -V, --version output the version number + -o, --output [path] specify output location + -c, --config-path specify configuration location + -i, --ignore-path specify ignore location + -s, --setting specify settings + -u, --use use transform plugin(s) + -e, --ext specify extensions + -w, --watch watch for changes and reprocess + -a, --ast output AST information + -q, --quiet output only warnings and errors + -S, --silent output only errors + -f, --frail exit with 1 on warnings + --file-path specify file path to process as + --no-stdout disable writing to stdout + --no-color disable color in output + --no-rc disable configuration from .remarkrc + --no-ignore disable ignore from .remarkignore + +See also: man 1 remark, man 3 remark, + man 3 remarkplugin, man 5 remarkrc, + man 5 remarkignore, man 7 remarksetting, + man 7 remarkconfig, man 7 remarkplugin. + +Examples: + + # Process `readme.md` + $ remark readme.md -o readme-new.md + + # Pass stdin(4) through remark, with settings, to stdout(4) + $ remark --setting "setext: true, bullet: \"*\"" < readme.md > readme-new.md + + # Use a plugin (with options) + $ npm install remark-toc + $ remark readme.md --use "toc=heading:\"contents\"" -o + + # Rewrite markdown in a directory + $ remark . -o +``` + +## License + +[MIT](LICENSE) © [Titus Wormer](http://wooorm.com) + +> This project was initially a fork of [marked](https://github.com/chjj/marked). + +Copyright (c) 2011-2014, Christopher Jeffrey. (MIT License) diff --git a/tools/node_modules/repeat-element/LICENSE b/tools/node_modules/repeat-element/LICENSE new file mode 100644 index 00000000000000..33754daecd9a43 --- /dev/null +++ b/tools/node_modules/repeat-element/LICENSE @@ -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. diff --git a/tools/node_modules/repeat-element/README.md b/tools/node_modules/repeat-element/README.md new file mode 100644 index 00000000000000..008e20ead40e58 --- /dev/null +++ b/tools/node_modules/repeat-element/README.md @@ -0,0 +1,71 @@ +# repeat-element [![NPM version](https://badge.fury.io/js/repeat-element.svg)](http://badge.fury.io/js/repeat-element) + +> Create an array by repeating the given value n times. + +## Install + +Install with [npm](https://www.npmjs.com/) + +```bash +npm i repeat-element --save +``` + +## Usage + +```js +var repeat = require('repeat-element'); + +repeat('a', 5); +//=> ['a', 'a', 'a', 'a', 'a'] + +repeat('a', 1); +//=> ['a'] + +repeat('a', 0); +//=> [] + +repeat(null, 5) +//» [ null, null, null, null, null ] + +repeat({some: 'object'}, 5) +//» [ { some: 'object' }, +// { some: 'object' }, +// { some: 'object' }, +// { some: 'object' }, +// { some: 'object' } ] + +repeat(5, 5) +//» [ 5, 5, 5, 5, 5 ] +``` + +## Related projects + +[repeat-string](https://github.com/jonschlinkert/repeat-string): Repeat the given string n times. Fastest implementation for repeating a string. + +## Running tests + +Install dev dependencies: + +```bash +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/repeat-element/issues) + +## Author + +**Jon Schlinkert** + ++ [github/jonschlinkert](https://github.com/jonschlinkert) ++ [twitter/jonschlinkert](http://twitter.com/jonschlinkert) + +## License + +Copyright (c) 2015 Jon Schlinkert +Released under the MIT license. + +*** + +_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on May 06, 2015._ diff --git a/tools/node_modules/repeat-element/index.js b/tools/node_modules/repeat-element/index.js new file mode 100644 index 00000000000000..0ad45ab46d527e --- /dev/null +++ b/tools/node_modules/repeat-element/index.js @@ -0,0 +1,18 @@ +/*! + * repeat-element + * + * Copyright (c) 2015 Jon Schlinkert. + * Licensed under the MIT license. + */ + +'use strict'; + +module.exports = function repeat(ele, num) { + var arr = new Array(num); + + for (var i = 0; i < num; i++) { + arr[i] = ele; + } + + return arr; +}; diff --git a/tools/node_modules/repeat-element/package.json b/tools/node_modules/repeat-element/package.json new file mode 100644 index 00000000000000..9a1fff90e8b024 --- /dev/null +++ b/tools/node_modules/repeat-element/package.json @@ -0,0 +1,93 @@ +{ + "_args": [ + [ + "repeat-element@^1.1.2", + "C:\\wamp\\www\\node\\tools\\node_modules\\braces" + ] + ], + "_from": "repeat-element@>=1.1.2 <2.0.0", + "_id": "repeat-element@1.1.2", + "_inCache": true, + "_location": "/repeat-element", + "_nodeVersion": "0.12.0", + "_npmUser": { + "email": "github@sellside.com", + "name": "jonschlinkert" + }, + "_npmVersion": "2.5.1", + "_phantomChildren": {}, + "_requested": { + "name": "repeat-element", + "raw": "repeat-element@^1.1.2", + "rawSpec": "^1.1.2", + "scope": null, + "spec": ">=1.1.2 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/braces", + "/fill-range" + ], + "_resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.2.tgz", + "_shasum": "ef089a178d1483baae4d93eb98b4f9e4e11d990a", + "_shrinkwrap": null, + "_spec": "repeat-element@^1.1.2", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\braces", + "author": { + "name": "Jon Schlinkert", + "url": "https://github.com/jonschlinkert" + }, + "bugs": { + "url": "https://github.com/jonschlinkert/repeat-element/issues" + }, + "dependencies": {}, + "description": "Create an array by repeating the given value n times.", + "devDependencies": { + "benchmarked": "^0.1.4", + "chalk": "^1.0.0", + "glob": "^5.0.5", + "minimist": "^1.1.1", + "mocha": "^2.2.4" + }, + "directories": {}, + "dist": { + "shasum": "ef089a178d1483baae4d93eb98b4f9e4e11d990a", + "tarball": "http://registry.npmjs.org/repeat-element/-/repeat-element-1.1.2.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "7a6b21d58eafcc44fc8de133c70a8398ee9fdd8d", + "homepage": "https://github.com/jonschlinkert/repeat-element", + "installable": true, + "keywords": [ + "array", + "element", + "repeat", + "string" + ], + "license": { + "type": "MIT", + "url": "https://github.com/jonschlinkert/repeat-element/blob/master/LICENSE" + }, + "main": "index.js", + "maintainers": [ + { + "name": "jonschlinkert", + "email": "github@sellside.com" + } + ], + "name": "repeat-element", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git://github.com/jonschlinkert/repeat-element.git" + }, + "scripts": { + "test": "mocha" + }, + "version": "1.1.2" +} diff --git a/tools/node_modules/repeat-string/LICENSE b/tools/node_modules/repeat-string/LICENSE new file mode 100644 index 00000000000000..5a9956a75dd7f2 --- /dev/null +++ b/tools/node_modules/repeat-string/LICENSE @@ -0,0 +1,24 @@ +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. diff --git a/tools/node_modules/repeat-string/README.md b/tools/node_modules/repeat-string/README.md new file mode 100644 index 00000000000000..cee7d174c96c2e --- /dev/null +++ b/tools/node_modules/repeat-string/README.md @@ -0,0 +1,94 @@ +# repeat-string [![NPM version](https://badge.fury.io/js/repeat-string.svg)](http://badge.fury.io/js/repeat-string) [![Build Status](https://travis-ci.org/jonschlinkert/repeat-string.svg)](https://travis-ci.org/jonschlinkert/repeat-string) + +> Repeat the given string n times. Fastest implementation for repeating a string. + +## Install with [npm](npmjs.org) + +```bash +npm i repeat-string --save +``` +## Install with [bower](https://github.com/bower/bower) + +```bash +bower install repeat-string --save +``` + +## Usage + +### [repeat](./index.js#L34) + +Repeat the given `string` the specified `number` of times. + +* `string` **{String}**: The string to repeat +* `number` **{Number}**: The number of times to repeat the string +* `returns` **{String}**: Repeated string + +**Example:** + +```js +var repeat = require('repeat-string'); +repeat('A', 5); +//=> AAAAA +``` + +## Benchmarks + +Repeat string is significantly faster than [repeating](https://github.com/sindresorhus/repeating). + +```bash +# 20,000x + repeat-string.js x 16,634,213 ops/sec ±0.92% (93 runs sampled) + repeating.js x 5,883,928 ops/sec ±0.95% (93 runs sampled) + +# 2,000x + repeat-string.js x 17,438,654 ops/sec ±0.76% (97 runs sampled) + repeating.js x 6,639,978 ops/sec ±0.84% (97 runs sampled) + +# 250x + repeat-string.js x 16,246,885 ops/sec ±0.81% (92 runs sampled) + repeating.js x 7,659,342 ops/sec ±0.67% (99 runs sampled) + +# 50x + repeat-string.js x 15,803,340 ops/sec ±0.74% (92 runs sampled) + repeating.js x 9,668,300 ops/sec ±0.89% (98 runs sampled) + +# 5x + repeat-string.js x 16,926,291 ops/sec ±0.78% (97 runs sampled) + repeating.js x 12,215,384 ops/sec ±1.01% (96 runs sampled) +``` + +**Run the benchmarks** + +Install dev dependencies: + +```bash +npm i -d && node benchmark +``` + +### Other javascript/node.js utils +[repeat-element](https://github.com/jonschlinkert/repeat-element): Create an array by repeating the given string n times. + +## Contributing +Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/repeat-string/issues) + +## Running tests +Install dev dependencies: + +```bash +npm i -d && npm test +``` + +## Author + +**Jon Schlinkert** + ++ [github/jonschlinkert](https://github.com/jonschlinkert) ++ [twitter/jonschlinkert](http://twitter.com/jonschlinkert) + +## License +Copyright (c) 2015 Jon Schlinkert +Released under the MIT license + +*** + +_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on April 01, 2015._ diff --git a/tools/node_modules/repeat-string/index.js b/tools/node_modules/repeat-string/index.js new file mode 100644 index 00000000000000..c781229b2cd07e --- /dev/null +++ b/tools/node_modules/repeat-string/index.js @@ -0,0 +1,66 @@ +/*! + * repeat-string + * + * Copyright (c) 2014-2015, Jon Schlinkert. + * Licensed under the MIT License. + */ + +'use strict'; + +/** + * Expose `repeat` + */ + +module.exports = repeat; + +/** + * Repeat the given `string` the specified `number` + * of times. + * + * **Example:** + * + * ```js + * var repeat = require('repeat-string'); + * repeat('A', 5); + * //=> AAAAA + * ``` + * + * @param {String} `string` The string to repeat + * @param {Number} `number` The number of times to repeat the string + * @return {String} Repeated string + * @api public + */ + +function repeat(str, num) { + if (typeof str !== 'string') { + throw new TypeError('repeat-string expects a string.'); + } + + if (num === 1) return str; + if (num === 2) return str + str; + + var max = str.length * num; + if (cache !== str || typeof cache === 'undefined') { + cache = str; + res = ''; + } + + while (max > res.length && num > 0) { + if (num & 1) { + res += str; + } + + num >>= 1; + if (!num) break; + str += str; + } + + return res.substr(0, max); +} + +/** + * Results cache + */ + +var res = ''; +var cache; diff --git a/tools/node_modules/repeat-string/package.json b/tools/node_modules/repeat-string/package.json new file mode 100644 index 00000000000000..8e28df21a95879 --- /dev/null +++ b/tools/node_modules/repeat-string/package.json @@ -0,0 +1,106 @@ +{ + "_args": [ + [ + "repeat-string@^1.5.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\remark" + ] + ], + "_from": "repeat-string@>=1.5.0 <2.0.0", + "_id": "repeat-string@1.5.2", + "_inCache": true, + "_location": "/repeat-string", + "_nodeVersion": "0.12.0", + "_npmUser": { + "email": "github@sellside.com", + "name": "jonschlinkert" + }, + "_npmVersion": "2.5.1", + "_phantomChildren": {}, + "_requested": { + "name": "repeat-string", + "raw": "repeat-string@^1.5.0", + "rawSpec": "^1.5.0", + "scope": null, + "spec": ">=1.5.0 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/fill-range", + "/remark", + "/vfile-reporter" + ], + "_resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.5.2.tgz", + "_shasum": "21065f70727ad053a0dd5e957ac9e00c7560d90a", + "_shrinkwrap": null, + "_spec": "repeat-string@^1.5.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\remark", + "author": { + "name": "Jon Schlinkert", + "url": "http://github.com/jonschlinkert/" + }, + "bugs": { + "url": "https://github.com/jonschlinkert/repeat-string/issues" + }, + "dependencies": {}, + "description": "Repeat the given string n times. Fastest implementation for repeating a string.", + "devDependencies": { + "benchmarked": "^0.1.3", + "chalk": "^0.5.1", + "glob": "^4.3.5", + "mocha": "^2.2.1", + "repeating": "^1.1.1", + "should": "^4.0.4" + }, + "directories": {}, + "dist": { + "shasum": "21065f70727ad053a0dd5e957ac9e00c7560d90a", + "tarball": "http://registry.npmjs.org/repeat-string/-/repeat-string-1.5.2.tgz" + }, + "engines": { + "node": ">=0.10" + }, + "files": [ + "index.js" + ], + "gitHead": "bf20e5dc1414305bec6ff26d90988378a5bad6ec", + "homepage": "https://github.com/jonschlinkert/repeat-string", + "installable": true, + "keywords": [ + "fast", + "fastest", + "fill", + "left", + "left-pad", + "multiple", + "pad", + "padding", + "repeat", + "repeating", + "repetition", + "right", + "right-pad", + "string", + "times" + ], + "license": { + "type": "MIT", + "url": "https://github.com/jonschlinkert/repeat-string/blob/master/LICENSE" + }, + "main": "index.js", + "maintainers": [ + { + "name": "jonschlinkert", + "email": "github@sellside.com" + } + ], + "name": "repeat-string", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git://github.com/jonschlinkert/repeat-string.git" + }, + "scripts": { + "test": "mocha" + }, + "version": "1.5.2" +} diff --git a/tools/node_modules/restore-cursor/index.js b/tools/node_modules/restore-cursor/index.js new file mode 100644 index 00000000000000..c3da545b52590f --- /dev/null +++ b/tools/node_modules/restore-cursor/index.js @@ -0,0 +1,9 @@ +'use strict'; +var onetime = require('onetime'); +var exitHook = require('exit-hook'); + +module.exports = onetime(function () { + exitHook(function () { + process.stdout.write('\u001b[?25h'); + }); +}); diff --git a/tools/node_modules/restore-cursor/license b/tools/node_modules/restore-cursor/license new file mode 100644 index 00000000000000..654d0bfe943437 --- /dev/null +++ b/tools/node_modules/restore-cursor/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tools/node_modules/restore-cursor/package.json b/tools/node_modules/restore-cursor/package.json new file mode 100644 index 00000000000000..2a1a2a7f02bc35 --- /dev/null +++ b/tools/node_modules/restore-cursor/package.json @@ -0,0 +1,100 @@ +{ + "_args": [ + [ + "restore-cursor@^1.0.1", + "C:\\wamp\\www\\node\\tools\\node_modules\\cli-cursor" + ] + ], + "_from": "restore-cursor@>=1.0.1 <2.0.0", + "_id": "restore-cursor@1.0.1", + "_inCache": true, + "_location": "/restore-cursor", + "_nodeVersion": "4.1.0", + "_npmUser": { + "email": "sindresorhus@gmail.com", + "name": "sindresorhus" + }, + "_npmVersion": "2.14.3", + "_phantomChildren": {}, + "_requested": { + "name": "restore-cursor", + "raw": "restore-cursor@^1.0.1", + "rawSpec": "^1.0.1", + "scope": null, + "spec": ">=1.0.1 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/cli-cursor" + ], + "_resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-1.0.1.tgz", + "_shasum": "34661f46886327fed2991479152252df92daa541", + "_shrinkwrap": null, + "_spec": "restore-cursor@^1.0.1", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\cli-cursor", + "author": { + "email": "sindresorhus@gmail.com", + "name": "Sindre Sorhus", + "url": "http://sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/sindresorhus/restore-cursor/issues" + }, + "dependencies": { + "exit-hook": "^1.0.0", + "onetime": "^1.0.0" + }, + "description": "Gracefully restore the CLI cursor on exit", + "devDependencies": {}, + "directories": {}, + "dist": { + "shasum": "34661f46886327fed2991479152252df92daa541", + "tarball": "http://registry.npmjs.org/restore-cursor/-/restore-cursor-1.0.1.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "91542e5be16d7ccda8e42a63d56cc783d2cfaba2", + "homepage": "https://github.com/sindresorhus/restore-cursor#readme", + "installable": true, + "keywords": [ + "ansi", + "cli", + "command-line", + "console", + "cursor", + "exit", + "graceful", + "kill", + "process", + "quit", + "shell", + "show", + "shutdown", + "sigint", + "sigterm", + "stop", + "term", + "terminal", + "terminate", + "tty" + ], + "license": "MIT", + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + } + ], + "name": "restore-cursor", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git+https://github.com/sindresorhus/restore-cursor.git" + }, + "scripts": {}, + "version": "1.0.1" +} diff --git a/tools/node_modules/restore-cursor/readme.md b/tools/node_modules/restore-cursor/readme.md new file mode 100644 index 00000000000000..be085608d2d32d --- /dev/null +++ b/tools/node_modules/restore-cursor/readme.md @@ -0,0 +1,25 @@ +# restore-cursor + +> Gracefully restore the CLI cursor on exit + +Prevent the cursor you've hidden interactively to remain hidden if the process crashes. + + +## Install + +```sh +$ npm install --save restore-cursor +``` + + +## Usage + +```js +var restoreCursor = require('restore-cursor'); +restoreCursor(); +``` + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/tools/node_modules/string-width/index.js b/tools/node_modules/string-width/index.js new file mode 100644 index 00000000000000..aa2f839b6dd2ce --- /dev/null +++ b/tools/node_modules/string-width/index.js @@ -0,0 +1,32 @@ +'use strict'; +var stripAnsi = require('strip-ansi'); +var codePointAt = require('code-point-at'); +var isFullwidthCodePoint = require('is-fullwidth-code-point'); + +// https://github.com/nodejs/io.js/blob/cff7300a578be1b10001f2d967aaedc88aee6402/lib/readline.js#L1345 +module.exports = function (str) { + if (typeof str !== 'string' || str.length === 0) { + return 0; + } + + var width = 0; + + str = stripAnsi(str); + + for (var i = 0; i < str.length; i++) { + var code = codePointAt(str, i); + + // surrogates + if (code >= 0x10000) { + i++; + } + + if (isFullwidthCodePoint(code)) { + width += 2; + } else { + width++; + } + } + + return width; +}; diff --git a/tools/node_modules/string-width/license b/tools/node_modules/string-width/license new file mode 100644 index 00000000000000..654d0bfe943437 --- /dev/null +++ b/tools/node_modules/string-width/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tools/node_modules/string-width/package.json b/tools/node_modules/string-width/package.json new file mode 100644 index 00000000000000..0cfac8d4d7e8e0 --- /dev/null +++ b/tools/node_modules/string-width/package.json @@ -0,0 +1,109 @@ +{ + "_args": [ + [ + "string-width@^1.0.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\vfile-reporter" + ] + ], + "_from": "string-width@>=1.0.0 <2.0.0", + "_id": "string-width@1.0.1", + "_inCache": true, + "_location": "/string-width", + "_nodeVersion": "0.12.5", + "_npmUser": { + "email": "sindresorhus@gmail.com", + "name": "sindresorhus" + }, + "_npmVersion": "2.11.2", + "_phantomChildren": {}, + "_requested": { + "name": "string-width", + "raw": "string-width@^1.0.0", + "rawSpec": "^1.0.0", + "scope": null, + "spec": ">=1.0.0 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/vfile-reporter" + ], + "_resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.1.tgz", + "_shasum": "c92129b6f1d7f52acf9af424a26e3864a05ceb0a", + "_shrinkwrap": null, + "_spec": "string-width@^1.0.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\vfile-reporter", + "author": { + "email": "sindresorhus@gmail.com", + "name": "Sindre Sorhus", + "url": "sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/sindresorhus/string-width/issues" + }, + "dependencies": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + }, + "description": "Get the visual width of a string - the number of columns required to display it", + "devDependencies": { + "ava": "0.0.4" + }, + "directories": {}, + "dist": { + "shasum": "c92129b6f1d7f52acf9af424a26e3864a05ceb0a", + "tarball": "http://registry.npmjs.org/string-width/-/string-width-1.0.1.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "f279cfd14835f0a3c8df69ba18e9a3960156e135", + "homepage": "https://github.com/sindresorhus/string-width", + "installable": true, + "keywords": [ + "ansi", + "char", + "character", + "chinese", + "cjk", + "cli", + "codes", + "column", + "columns", + "command-line", + "console", + "escape", + "fixed-width", + "full", + "full-width", + "fullwidth", + "japanese", + "korean", + "str", + "string", + "terminal", + "unicode", + "visual", + "width" + ], + "license": "MIT", + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + } + ], + "name": "string-width", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "https://github.com/sindresorhus/string-width" + }, + "scripts": { + "test": "node test.js" + }, + "version": "1.0.1" +} diff --git a/tools/node_modules/string-width/readme.md b/tools/node_modules/string-width/readme.md new file mode 100644 index 00000000000000..a7737a986c5736 --- /dev/null +++ b/tools/node_modules/string-width/readme.md @@ -0,0 +1,41 @@ +# string-width [![Build Status](https://travis-ci.org/sindresorhus/string-width.svg?branch=master)](https://travis-ci.org/sindresorhus/string-width) + +> Get the visual width of a string - the number of columns required to display it + +Some Unicode characters are [fullwidth](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms) and use double the normal width. + +Useful to be able to measure the actual width of command-line output. + + +## Install + +``` +$ npm install --save string-width +``` + + +## Usage + +```js +var stringWidth = require('string-width'); + +stringWidth('古'); +//=> 2 + +stringWidth('\u001b[1m古\u001b[22m'); +//=> 2 + +stringWidth('a'); +//=> 1 +``` + + +## Related + +- [string-width-cli](https://github.com/sindresorhus/string-width-cli) - CLI for this module +- [string-length](https://github.com/sindresorhus/string-length) - Get the real length of a string + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/tools/node_modules/string_decoder/.npmignore b/tools/node_modules/string_decoder/.npmignore new file mode 100644 index 00000000000000..206320cc1d21b9 --- /dev/null +++ b/tools/node_modules/string_decoder/.npmignore @@ -0,0 +1,2 @@ +build +test diff --git a/tools/node_modules/string_decoder/LICENSE b/tools/node_modules/string_decoder/LICENSE new file mode 100644 index 00000000000000..6de584a48f5c89 --- /dev/null +++ b/tools/node_modules/string_decoder/LICENSE @@ -0,0 +1,20 @@ +Copyright Joyent, Inc. and other Node contributors. + +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. diff --git a/tools/node_modules/string_decoder/README.md b/tools/node_modules/string_decoder/README.md new file mode 100644 index 00000000000000..4d2aa001501107 --- /dev/null +++ b/tools/node_modules/string_decoder/README.md @@ -0,0 +1,7 @@ +**string_decoder.js** (`require('string_decoder')`) from Node.js core + +Copyright Joyent, Inc. and other Node contributors. See LICENCE file for details. + +Version numbers match the versions found in Node core, e.g. 0.10.24 matches Node 0.10.24, likewise 0.11.10 matches Node 0.11.10. **Prefer the stable version over the unstable.** + +The *build/* directory contains a build script that will scrape the source from the [joyent/node](https://github.com/joyent/node) repo given a specific Node version. \ No newline at end of file diff --git a/tools/node_modules/string_decoder/index.js b/tools/node_modules/string_decoder/index.js new file mode 100644 index 00000000000000..b00e54fb790982 --- /dev/null +++ b/tools/node_modules/string_decoder/index.js @@ -0,0 +1,221 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +var Buffer = require('buffer').Buffer; + +var isBufferEncoding = Buffer.isEncoding + || function(encoding) { + switch (encoding && encoding.toLowerCase()) { + case 'hex': case 'utf8': case 'utf-8': case 'ascii': case 'binary': case 'base64': case 'ucs2': case 'ucs-2': case 'utf16le': case 'utf-16le': case 'raw': return true; + default: return false; + } + } + + +function assertEncoding(encoding) { + if (encoding && !isBufferEncoding(encoding)) { + throw new Error('Unknown encoding: ' + encoding); + } +} + +// StringDecoder provides an interface for efficiently splitting a series of +// buffers into a series of JS strings without breaking apart multi-byte +// characters. CESU-8 is handled as part of the UTF-8 encoding. +// +// @TODO Handling all encodings inside a single object makes it very difficult +// to reason about this code, so it should be split up in the future. +// @TODO There should be a utf8-strict encoding that rejects invalid UTF-8 code +// points as used by CESU-8. +var StringDecoder = exports.StringDecoder = function(encoding) { + this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, ''); + assertEncoding(encoding); + switch (this.encoding) { + case 'utf8': + // CESU-8 represents each of Surrogate Pair by 3-bytes + this.surrogateSize = 3; + break; + case 'ucs2': + case 'utf16le': + // UTF-16 represents each of Surrogate Pair by 2-bytes + this.surrogateSize = 2; + this.detectIncompleteChar = utf16DetectIncompleteChar; + break; + case 'base64': + // Base-64 stores 3 bytes in 4 chars, and pads the remainder. + this.surrogateSize = 3; + this.detectIncompleteChar = base64DetectIncompleteChar; + break; + default: + this.write = passThroughWrite; + return; + } + + // Enough space to store all bytes of a single character. UTF-8 needs 4 + // bytes, but CESU-8 may require up to 6 (3 bytes per surrogate). + this.charBuffer = new Buffer(6); + // Number of bytes received for the current incomplete multi-byte character. + this.charReceived = 0; + // Number of bytes expected for the current incomplete multi-byte character. + this.charLength = 0; +}; + + +// write decodes the given buffer and returns it as JS string that is +// guaranteed to not contain any partial multi-byte characters. Any partial +// character found at the end of the buffer is buffered up, and will be +// returned when calling write again with the remaining bytes. +// +// Note: Converting a Buffer containing an orphan surrogate to a String +// currently works, but converting a String to a Buffer (via `new Buffer`, or +// Buffer#write) will replace incomplete surrogates with the unicode +// replacement character. See https://codereview.chromium.org/121173009/ . +StringDecoder.prototype.write = function(buffer) { + var charStr = ''; + // if our last write ended with an incomplete multibyte character + while (this.charLength) { + // determine how many remaining bytes this buffer has to offer for this char + var available = (buffer.length >= this.charLength - this.charReceived) ? + this.charLength - this.charReceived : + buffer.length; + + // add the new bytes to the char buffer + buffer.copy(this.charBuffer, this.charReceived, 0, available); + this.charReceived += available; + + if (this.charReceived < this.charLength) { + // still not enough chars in this buffer? wait for more ... + return ''; + } + + // remove bytes belonging to the current character from the buffer + buffer = buffer.slice(available, buffer.length); + + // get the character that was split + charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding); + + // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character + var charCode = charStr.charCodeAt(charStr.length - 1); + if (charCode >= 0xD800 && charCode <= 0xDBFF) { + this.charLength += this.surrogateSize; + charStr = ''; + continue; + } + this.charReceived = this.charLength = 0; + + // if there are no more bytes in this buffer, just emit our char + if (buffer.length === 0) { + return charStr; + } + break; + } + + // determine and set charLength / charReceived + this.detectIncompleteChar(buffer); + + var end = buffer.length; + if (this.charLength) { + // buffer the incomplete character bytes we got + buffer.copy(this.charBuffer, 0, buffer.length - this.charReceived, end); + end -= this.charReceived; + } + + charStr += buffer.toString(this.encoding, 0, end); + + var end = charStr.length - 1; + var charCode = charStr.charCodeAt(end); + // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character + if (charCode >= 0xD800 && charCode <= 0xDBFF) { + var size = this.surrogateSize; + this.charLength += size; + this.charReceived += size; + this.charBuffer.copy(this.charBuffer, size, 0, size); + buffer.copy(this.charBuffer, 0, 0, size); + return charStr.substring(0, end); + } + + // or just emit the charStr + return charStr; +}; + +// detectIncompleteChar determines if there is an incomplete UTF-8 character at +// the end of the given buffer. If so, it sets this.charLength to the byte +// length that character, and sets this.charReceived to the number of bytes +// that are available for this character. +StringDecoder.prototype.detectIncompleteChar = function(buffer) { + // determine how many bytes we have to check at the end of this buffer + var i = (buffer.length >= 3) ? 3 : buffer.length; + + // Figure out if one of the last i bytes of our buffer announces an + // incomplete char. + for (; i > 0; i--) { + var c = buffer[buffer.length - i]; + + // See http://en.wikipedia.org/wiki/UTF-8#Description + + // 110XXXXX + if (i == 1 && c >> 5 == 0x06) { + this.charLength = 2; + break; + } + + // 1110XXXX + if (i <= 2 && c >> 4 == 0x0E) { + this.charLength = 3; + break; + } + + // 11110XXX + if (i <= 3 && c >> 3 == 0x1E) { + this.charLength = 4; + break; + } + } + this.charReceived = i; +}; + +StringDecoder.prototype.end = function(buffer) { + var res = ''; + if (buffer && buffer.length) + res = this.write(buffer); + + if (this.charReceived) { + var cr = this.charReceived; + var buf = this.charBuffer; + var enc = this.encoding; + res += buf.slice(0, cr).toString(enc); + } + + return res; +}; + +function passThroughWrite(buffer) { + return buffer.toString(this.encoding); +} + +function utf16DetectIncompleteChar(buffer) { + this.charReceived = buffer.length % 2; + this.charLength = this.charReceived ? 2 : 0; +} + +function base64DetectIncompleteChar(buffer) { + this.charReceived = buffer.length % 3; + this.charLength = this.charReceived ? 3 : 0; +} diff --git a/tools/node_modules/string_decoder/package.json b/tools/node_modules/string_decoder/package.json new file mode 100644 index 00000000000000..76e01de078108e --- /dev/null +++ b/tools/node_modules/string_decoder/package.json @@ -0,0 +1,78 @@ +{ + "_args": [ + [ + "string_decoder@~0.10.x", + "C:\\wamp\\www\\node\\tools\\node_modules\\readable-stream" + ] + ], + "_from": "string_decoder@>=0.10.0 <0.11.0", + "_id": "string_decoder@0.10.31", + "_inCache": true, + "_location": "/string_decoder", + "_npmUser": { + "email": "rod@vagg.org", + "name": "rvagg" + }, + "_npmVersion": "1.4.23", + "_phantomChildren": {}, + "_requested": { + "name": "string_decoder", + "raw": "string_decoder@~0.10.x", + "rawSpec": "~0.10.x", + "scope": null, + "spec": ">=0.10.0 <0.11.0", + "type": "range" + }, + "_requiredBy": [ + "/readable-stream" + ], + "_resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "_shasum": "62e203bc41766c6c28c9fc84301dab1c5310fa94", + "_shrinkwrap": null, + "_spec": "string_decoder@~0.10.x", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\readable-stream", + "bugs": { + "url": "https://github.com/rvagg/string_decoder/issues" + }, + "dependencies": {}, + "description": "The string_decoder module from Node core", + "devDependencies": { + "tap": "~0.4.8" + }, + "directories": {}, + "dist": { + "shasum": "62e203bc41766c6c28c9fc84301dab1c5310fa94", + "tarball": "http://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz" + }, + "gitHead": "d46d4fd87cf1d06e031c23f1ba170ca7d4ade9a0", + "homepage": "https://github.com/rvagg/string_decoder", + "installable": true, + "keywords": [ + "browser", + "browserify", + "decoder", + "string" + ], + "license": "MIT", + "main": "index.js", + "maintainers": [ + { + "name": "substack", + "email": "mail@substack.net" + }, + { + "name": "rvagg", + "email": "rod@vagg.org" + } + ], + "name": "string_decoder", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git://github.com/rvagg/string_decoder.git" + }, + "scripts": { + "test": "tap test/simple/*.js" + }, + "version": "0.10.31" +} diff --git a/tools/node_modules/stringify-entities/LICENSE b/tools/node_modules/stringify-entities/LICENSE new file mode 100644 index 00000000000000..611b67581bb8e2 --- /dev/null +++ b/tools/node_modules/stringify-entities/LICENSE @@ -0,0 +1,22 @@ +(The MIT License) + +Copyright (c) 2015 Titus Wormer + +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. diff --git a/tools/node_modules/stringify-entities/history.md b/tools/node_modules/stringify-entities/history.md new file mode 100644 index 00000000000000..5f5f4a2d7b3cd4 --- /dev/null +++ b/tools/node_modules/stringify-entities/history.md @@ -0,0 +1,13 @@ + + + + +1.0.1 / 2015-12-27 +================== + +* Fix typo in `readme.md` ([fca0bc9](https://github.com/wooorm/stringify-entities/commit/fca0bc9)) +* Fix typo in `component.json` ([fe7ecec](https://github.com/wooorm/stringify-entities/commit/fe7ecec)) +* Fix typographic styling in readme.md` ([b5c09db](https://github.com/wooorm/stringify-entities/commit/b5c09db)) + +1.0.0 / 2015-11-22 +================== diff --git a/tools/node_modules/stringify-entities/index.js b/tools/node_modules/stringify-entities/index.js new file mode 100644 index 00000000000000..e52847caab538d --- /dev/null +++ b/tools/node_modules/stringify-entities/index.js @@ -0,0 +1,155 @@ +/** + * @author Titus Wormer + * @copyright 2015 Titus Wormer + * @license MIT + * @module stringify-entities + * @fileoverview Encode HTML character references and character entities. + */ + +'use strict'; + +/* eslint-env commonjs */ + +/* + * Dependencies. + */ + +var entities = require('character-entities-html4'); +var EXPRESSION_NAMED = require('./lib/expression.js'); + +/* + * Methods. + */ + +var has = {}.hasOwnProperty; + +/* + * List of enforced escapes. + */ + +var escapes = ['"', '\'', '<', '>', '&', '`']; + +/* + * Map of characters to names. + */ + +var characters = {}; + +(function () { + var name; + + for (name in entities) { + characters[entities[name]] = name; + } +})(); + +/* + * Regular expressions. + */ + +var EXPRESSION_ESCAPE = new RegExp('[' + escapes.join('') + ']', 'g'); +var EXPRESSION_SURROGATE_PAIR = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g; +var EXPRESSION_BMP = /[\x01-\t\x0B\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g; + +/** + * Transform `code` into a hexadecimal character reference. + * + * @param {number} code - Number to encode. + * @return {string} - `code` encoded as hexadecimal. + */ +function characterCodeToHexadecimalReference(code) { + return '&#x' + code.toString(16).toUpperCase() + ';'; +} + +/** + * Transform `character` into a hexadecimal character + * reference. + * + * @param {string} character - Character to encode. + * @return {string} - `character` encoded as hexadecimal. + */ +function characterToHexadecimalReference(character) { + return characterCodeToHexadecimalReference(character.charCodeAt(0)); +} + +/** + * Transform `code` into an entity. + * + * @param {string} name - Name to wrap. + * @return {string} - `name` encoded as hexadecimal. + */ +function toNamedEntity(name) { + return '&' + name + ';'; +} + +/** + * Transform `code` into an entity. + * + * @param {string} character - Character to encode. + * @return {string} - `name` encoded as hexadecimal. + */ +function characterToNamedEntity(character) { + return toNamedEntity(characters[character]); +} + +/** + * Encode special characters in `value`. + * + * @param {string} value - Value to encode. + * @param {Object?} [options] - Configuration. + * @param {boolean?} [options.escapeOnly=false] + * - Whether to only escape required characters. + * @param {boolean?} [options.useNamedReferences=false] + * - Whether to use entities where possible. + * @return {string} - Encoded `value`. + */ +function encode(value, options) { + var settings = options || {}; + var escapeOnly = settings.escapeOnly; + var named = settings.useNamedReferences; + var map = named ? characters : null; + + value = value.replace(EXPRESSION_ESCAPE, function (character) { + return map && has.call(map, character) ? + toNamedEntity(map[character]) : + characterToHexadecimalReference(character); + }); + + if (escapeOnly) { + return value; + } + + if (named) { + value = value.replace(EXPRESSION_NAMED, characterToNamedEntity); + } + + return value + .replace(EXPRESSION_SURROGATE_PAIR, function (pair) { + return characterCodeToHexadecimalReference( + (pair.charCodeAt(0) - 0xD800) * 0x400 + + pair.charCodeAt(1) - 0xDC00 + 0x10000 + ); + }) + .replace(EXPRESSION_BMP, characterToHexadecimalReference); +} + +/** + * Shortcut to escape special characters in HTML. + * + * @param {string} value - Value to encode. + * @return {string} - Encoded `value`. + */ +function escape(value) { + return encode(value, { + 'escapeOnly': true, + 'useNamedReferences': true + }); +} + +encode.escape = escape; + +/* + * Expose. + */ + +module.exports = encode; diff --git a/tools/node_modules/stringify-entities/lib/expression.js b/tools/node_modules/stringify-entities/lib/expression.js new file mode 100644 index 00000000000000..4d1746f40452c9 --- /dev/null +++ b/tools/node_modules/stringify-entities/lib/expression.js @@ -0,0 +1,8 @@ +/* This script was generated by `script/generate-expression.js` */ + +'use strict'; + +/* eslint-env commonjs */ +/* eslint-disable no-irregular-whitespace */ + +module.exports = /[ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿƒΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψωϑϒϖ•…′″‾⁄℘ℑℜ™ℵ←↑→↓↔↵⇐⇑⇒⇓⇔∀∂∃∅∇∈∉∋∏∑−∗√∝∞∠∧∨∩∪∫∴∼≅≈≠≡≤≥⊂⊃⊄⊆⊇⊕⊗⊥⋅⌈⌉⌊⌋〈〉◊♠♣♥♦ŒœŠšŸˆ˜   ‌‍‎‏–—‘’‚“”„†‡‰‹›€]/g; diff --git a/tools/node_modules/stringify-entities/package.json b/tools/node_modules/stringify-entities/package.json new file mode 100644 index 00000000000000..7f6b1829b6b933 --- /dev/null +++ b/tools/node_modules/stringify-entities/package.json @@ -0,0 +1,112 @@ +{ + "_args": [ + [ + "stringify-entities@^1.0.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\remark" + ] + ], + "_from": "stringify-entities@>=1.0.0 <2.0.0", + "_id": "stringify-entities@1.0.1", + "_inCache": true, + "_location": "/stringify-entities", + "_nodeVersion": "5.1.0", + "_npmUser": { + "email": "tituswormer@gmail.com", + "name": "wooorm" + }, + "_npmVersion": "3.5.0", + "_phantomChildren": {}, + "_requested": { + "name": "stringify-entities", + "raw": "stringify-entities@^1.0.0", + "rawSpec": "^1.0.0", + "scope": null, + "spec": ">=1.0.0 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/remark" + ], + "_resolved": "https://registry.npmjs.org/stringify-entities/-/stringify-entities-1.0.1.tgz", + "_shasum": "1e134945189bd6b82e6fb7d479ab1af7345c98b6", + "_shrinkwrap": null, + "_spec": "stringify-entities@^1.0.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\remark", + "author": { + "email": "tituswormer@gmail.com", + "name": "Titus Wormer" + }, + "bugs": { + "url": "https://github.com/wooorm/stringify-entities/issues" + }, + "dependencies": { + "character-entities-html4": "^1.0.0" + }, + "description": "Encode HTML character references and character entities", + "devDependencies": { + "browserify": "^12.0.0", + "eslint": "^1.0.0", + "esmangle": "^1.0.0", + "istanbul": "^0.4.0", + "jscs": "^2.0.0", + "jscs-jsdoc": "^1.0.0", + "mdast": "^2.0.0", + "mdast-comment-config": "^1.0.0", + "mdast-github": "^1.0.0", + "mdast-lint": "^1.0.0", + "mdast-slug": "^2.0.0", + "mdast-validate-links": "^1.1.1", + "mdast-yaml-config": "^1.0.0", + "tape": "^4.2.0" + }, + "directories": {}, + "dist": { + "shasum": "1e134945189bd6b82e6fb7d479ab1af7345c98b6", + "tarball": "http://registry.npmjs.org/stringify-entities/-/stringify-entities-1.0.1.tgz" + }, + "files": [ + "LICENSE", + "index.js", + "lib/expression.js" + ], + "gitHead": "fdc1ce3f5ebbe6be02773f2c9c404424f07dd2e6", + "homepage": "https://github.com/wooorm/stringify-entities#readme", + "installable": true, + "keywords": [ + "character", + "encode", + "entities", + "entity", + "escape", + "html", + "reference", + "stringify" + ], + "license": "MIT", + "maintainers": [ + { + "name": "wooorm", + "email": "tituswormer@gmail.com" + } + ], + "name": "stringify-entities", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git+https://github.com/wooorm/stringify-entities.git" + }, + "scripts": { + "build": "npm run build-md && npm run build-expression && npm run build-bundle && npm run build-mangle", + "build-bundle": "browserify index.js --bare -s stringifyEntities > stringify-entities.js", + "build-expression": "node script/generate-expression.js", + "build-mangle": "esmangle stringify-entities.js > stringify-entities.min.js", + "build-md": "mdast . --quiet --frail", + "lint": "npm run lint-api && npm run lint-style", + "lint-api": "eslint .", + "lint-style": "jscs --reporter inline .", + "test": "npm run build && npm run lint && npm run test-coverage", + "test-api": "node test.js", + "test-coverage": "istanbul cover test.js" + }, + "version": "1.0.1" +} diff --git a/tools/node_modules/stringify-entities/readme.md b/tools/node_modules/stringify-entities/readme.md new file mode 100644 index 00000000000000..65ecde9e3e9300 --- /dev/null +++ b/tools/node_modules/stringify-entities/readme.md @@ -0,0 +1,85 @@ +# stringify-entities [![Build Status](https://img.shields.io/travis/wooorm/stringify-entities.svg?style=flat)](https://travis-ci.org/wooorm/stringify-entities) [![Coverage Status](https://img.shields.io/codecov/c/github/wooorm/stringify-entities.svg)](https://codecov.io/github/wooorm/stringify-entities) + +Encode HTML character references and character entities. + +* [x] Very fast; + +* [x] Just the encoding part; + +* [x] Reliable: ``"`"`` characters are escaped to ensure no scripts + execute in IE6-8. Additionally, only named entities recognized by HTML4 + are encoded, meaning the infamous `'` (which people think is a + [virus](http://www.telegraph.co.uk/technology/advice/10516839/Why-do-some-apostrophes-get-replaced-with-andapos.html)) + won’t show up. + +## Installation + +[npm](https://docs.npmjs.com/cli/install): + +```bash +npm install stringify-entities +``` + +**stringify-entities** is also available for [duo](http://duojs.org/#getting-started), +and [bundled](https://github.com/wooorm/stringify-entities/releases) for AMD, +CommonJS, and globals (uncompressed and compressed). + +## Usage + +```js +var stringify = require('stringify-entities'); + +stringify.encode('alpha © bravo ≠ charlie 𝌆 delta'); +``` + +Yields: + +```html +alpha © bravo ≠ charlie 𝌆 delta +``` + +…and with `useNamedReferences: true`. + +```js +stringify.encode('alpha © bravo ≠ charlie 𝌆 delta', { useNamedReferences: true }); +``` + +Yields: + +```html +alpha © bravo ≠ charlie 𝌆 delta +``` + +## API + +### stringifyEntities(value\[, options?]) + +Encode special characters in `value`. + +**Parameters**: + +* `value` (`string`) — Value to encode; + +* `options` (`Object?`, optional) — Configuration: + + * `escapeOnly` (`boolean?`, optional, default: `false`) + — Whether to only escape possibly dangerous characters + (`"`, `'`, `<`, `>` `&`, and `` ` ``); + + * `useNamedReferences` (`boolean?`, optional, default: `false`) + — Whether to use entities where possible. + +**Returns**: `string`, encoded `value`. + +### stringifyEntities.escape(value\[, options?]) + +Escape special characters in `value`. Shortcut for `stringifyEntities` +with `escapeOnly: true` and `useNamedReferences: true`. + +## Support + +See [html.spec.whatwg.org](https://html.spec.whatwg.org/multipage/syntax.html#named-character-references). + +## License + +[MIT](LICENSE) © [Titus Wormer](http://wooorm.com) diff --git a/tools/node_modules/strip-ansi/index.js b/tools/node_modules/strip-ansi/index.js new file mode 100644 index 00000000000000..099480fbfc54cb --- /dev/null +++ b/tools/node_modules/strip-ansi/index.js @@ -0,0 +1,6 @@ +'use strict'; +var ansiRegex = require('ansi-regex')(); + +module.exports = function (str) { + return typeof str === 'string' ? str.replace(ansiRegex, '') : str; +}; diff --git a/tools/node_modules/strip-ansi/license b/tools/node_modules/strip-ansi/license new file mode 100644 index 00000000000000..654d0bfe943437 --- /dev/null +++ b/tools/node_modules/strip-ansi/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tools/node_modules/strip-ansi/package.json b/tools/node_modules/strip-ansi/package.json new file mode 100644 index 00000000000000..21eb2991712bc2 --- /dev/null +++ b/tools/node_modules/strip-ansi/package.json @@ -0,0 +1,110 @@ +{ + "_args": [ + [ + "strip-ansi@^3.0.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\chalk" + ] + ], + "_from": "strip-ansi@>=3.0.0 <4.0.0", + "_id": "strip-ansi@3.0.0", + "_inCache": true, + "_location": "/strip-ansi", + "_nodeVersion": "0.12.5", + "_npmUser": { + "email": "sindresorhus@gmail.com", + "name": "sindresorhus" + }, + "_npmVersion": "2.11.2", + "_phantomChildren": {}, + "_requested": { + "name": "strip-ansi", + "raw": "strip-ansi@^3.0.0", + "rawSpec": "^3.0.0", + "scope": null, + "spec": ">=3.0.0 <4.0.0", + "type": "range" + }, + "_requiredBy": [ + "/chalk", + "/string-width" + ], + "_resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.0.tgz", + "_shasum": "7510b665567ca914ccb5d7e072763ac968be3724", + "_shrinkwrap": null, + "_spec": "strip-ansi@^3.0.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\chalk", + "author": { + "email": "sindresorhus@gmail.com", + "name": "Sindre Sorhus", + "url": "sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/sindresorhus/strip-ansi/issues" + }, + "dependencies": { + "ansi-regex": "^2.0.0" + }, + "description": "Strip ANSI escape codes", + "devDependencies": { + "ava": "0.0.4" + }, + "directories": {}, + "dist": { + "shasum": "7510b665567ca914ccb5d7e072763ac968be3724", + "tarball": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.0.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "3f05b9810e1438f946e2eb84ee854cc00b972e9e", + "homepage": "https://github.com/sindresorhus/strip-ansi", + "installable": true, + "keywords": [ + "256", + "ansi", + "color", + "colors", + "colour", + "command-line", + "console", + "escape", + "formatting", + "log", + "logging", + "remove", + "rgb", + "shell", + "string", + "strip", + "styles", + "terminal", + "text", + "trim", + "tty", + "xterm" + ], + "license": "MIT", + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + }, + { + "name": "jbnicolai", + "email": "jappelman@xebia.com" + } + ], + "name": "strip-ansi", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "https://github.com/sindresorhus/strip-ansi" + }, + "scripts": { + "test": "node test.js" + }, + "version": "3.0.0" +} diff --git a/tools/node_modules/strip-ansi/readme.md b/tools/node_modules/strip-ansi/readme.md new file mode 100644 index 00000000000000..76091512df5e46 --- /dev/null +++ b/tools/node_modules/strip-ansi/readme.md @@ -0,0 +1,33 @@ +# strip-ansi [![Build Status](https://travis-ci.org/sindresorhus/strip-ansi.svg?branch=master)](https://travis-ci.org/sindresorhus/strip-ansi) + +> Strip [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code) + + +## Install + +``` +$ npm install --save strip-ansi +``` + + +## Usage + +```js +var stripAnsi = require('strip-ansi'); + +stripAnsi('\u001b[4mcake\u001b[0m'); +//=> 'cake' +``` + + +## Related + +- [strip-ansi-cli](https://github.com/sindresorhus/strip-ansi-cli) - CLI for this module +- [has-ansi](https://github.com/sindresorhus/has-ansi) - Check if a string has ANSI escape codes +- [ansi-regex](https://github.com/sindresorhus/ansi-regex) - Regular expression for matching ANSI escape codes +- [chalk](https://github.com/sindresorhus/chalk) - Terminal string styling done right + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/tools/node_modules/strip-json-comments/cli.js b/tools/node_modules/strip-json-comments/cli.js new file mode 100644 index 00000000000000..aec5aa20e4a073 --- /dev/null +++ b/tools/node_modules/strip-json-comments/cli.js @@ -0,0 +1,41 @@ +#!/usr/bin/env node +'use strict'; +var fs = require('fs'); +var strip = require('./strip-json-comments'); +var input = process.argv[2]; + + +function getStdin(cb) { + var ret = ''; + + process.stdin.setEncoding('utf8'); + + process.stdin.on('data', function (data) { + ret += data; + }); + + process.stdin.on('end', function () { + cb(ret); + }); +} + +if (process.argv.indexOf('-h') !== -1 || process.argv.indexOf('--help') !== -1) { + console.log('strip-json-comments input-file > output-file'); + console.log('or'); + console.log('strip-json-comments < input-file > output-file'); + return; +} + +if (process.argv.indexOf('-v') !== -1 || process.argv.indexOf('--version') !== -1) { + console.log(require('./package').version); + return; +} + +if (input) { + process.stdout.write(strip(fs.readFileSync(input, 'utf8'))); + return; +} + +getStdin(function (data) { + process.stdout.write(strip(data)); +}); diff --git a/tools/node_modules/strip-json-comments/license b/tools/node_modules/strip-json-comments/license new file mode 100644 index 00000000000000..654d0bfe943437 --- /dev/null +++ b/tools/node_modules/strip-json-comments/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tools/node_modules/strip-json-comments/package.json b/tools/node_modules/strip-json-comments/package.json new file mode 100644 index 00000000000000..08ab0c92596693 --- /dev/null +++ b/tools/node_modules/strip-json-comments/package.json @@ -0,0 +1,103 @@ +{ + "_args": [ + [ + "strip-json-comments@~1.0.4", + "C:\\wamp\\www\\node\\tools\\node_modules\\rc" + ] + ], + "_from": "strip-json-comments@>=1.0.4 <1.1.0", + "_id": "strip-json-comments@1.0.4", + "_inCache": true, + "_location": "/strip-json-comments", + "_nodeVersion": "0.12.5", + "_npmUser": { + "email": "sindresorhus@gmail.com", + "name": "sindresorhus" + }, + "_npmVersion": "2.11.2", + "_phantomChildren": {}, + "_requested": { + "name": "strip-json-comments", + "raw": "strip-json-comments@~1.0.4", + "rawSpec": "~1.0.4", + "scope": null, + "spec": ">=1.0.4 <1.1.0", + "type": "range" + }, + "_requiredBy": [ + "/rc" + ], + "_resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-1.0.4.tgz", + "_shasum": "1e15fbcac97d3ee99bf2d73b4c656b082bbafb91", + "_shrinkwrap": null, + "_spec": "strip-json-comments@~1.0.4", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\rc", + "author": { + "email": "sindresorhus@gmail.com", + "name": "Sindre Sorhus", + "url": "sindresorhus.com" + }, + "bin": { + "strip-json-comments": "cli.js" + }, + "bugs": { + "url": "https://github.com/sindresorhus/strip-json-comments/issues" + }, + "dependencies": {}, + "description": "Strip comments from JSON. Lets you use comments in your JSON files!", + "devDependencies": { + "mocha": "*" + }, + "directories": {}, + "dist": { + "shasum": "1e15fbcac97d3ee99bf2d73b4c656b082bbafb91", + "tarball": "http://registry.npmjs.org/strip-json-comments/-/strip-json-comments-1.0.4.tgz" + }, + "engines": { + "node": ">=0.8.0" + }, + "files": [ + "cli.js", + "strip-json-comments.js" + ], + "gitHead": "f58348696368583cc5bb18525fe31eacc9bd00e1", + "homepage": "https://github.com/sindresorhus/strip-json-comments", + "installable": true, + "keywords": [ + "bin", + "cli", + "comments", + "conf", + "config", + "configuration", + "delete", + "env", + "environment", + "json", + "multiline", + "parse", + "remove", + "settings", + "strip", + "trim", + "util" + ], + "license": "MIT", + "main": "strip-json-comments", + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + } + ], + "name": "strip-json-comments", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "https://github.com/sindresorhus/strip-json-comments" + }, + "scripts": { + "test": "mocha --ui tdd" + }, + "version": "1.0.4" +} diff --git a/tools/node_modules/strip-json-comments/readme.md b/tools/node_modules/strip-json-comments/readme.md new file mode 100644 index 00000000000000..63ce165b23809f --- /dev/null +++ b/tools/node_modules/strip-json-comments/readme.md @@ -0,0 +1,80 @@ +# strip-json-comments [![Build Status](https://travis-ci.org/sindresorhus/strip-json-comments.svg?branch=master)](https://travis-ci.org/sindresorhus/strip-json-comments) + +> Strip comments from JSON. Lets you use comments in your JSON files! + +This is now possible: + +```js +{ + // rainbows + "unicorn": /* ❤ */ "cake" +} +``` + +It will remove single-line comments `//` and multi-line comments `/**/`. + +Also available as a [gulp](https://github.com/sindresorhus/gulp-strip-json-comments)/[grunt](https://github.com/sindresorhus/grunt-strip-json-comments)/[broccoli](https://github.com/sindresorhus/broccoli-strip-json-comments) plugin. + +- + +*There's also [`json-comments`](https://npmjs.org/package/json-comments), but it's only for Node.js, inefficient, bloated as it also minifies, and comes with a `require` hook, which is :(* + + +## Install + +```sh +$ npm install --save strip-json-comments +``` + +```sh +$ bower install --save strip-json-comments +``` + +```sh +$ component install sindresorhus/strip-json-comments +``` + + +## Usage + +```js +var json = '{/*rainbows*/"unicorn":"cake"}'; +JSON.parse(stripJsonComments(json)); +//=> {unicorn: 'cake'} +``` + + +## API + +### stripJsonComments(input) + +#### input + +Type: `string` + +Accepts a string with JSON and returns a string without comments. + + +## CLI + +```sh +$ npm install --global strip-json-comments +``` + +```sh +$ strip-json-comments --help + +strip-json-comments input-file > output-file +# or +strip-json-comments < input-file > output-file +``` + + +## Related + +- [`strip-css-comments`](https://github.com/sindresorhus/strip-css-comments) + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/tools/node_modules/strip-json-comments/strip-json-comments.js b/tools/node_modules/strip-json-comments/strip-json-comments.js new file mode 100644 index 00000000000000..eb77ce7456b8e5 --- /dev/null +++ b/tools/node_modules/strip-json-comments/strip-json-comments.js @@ -0,0 +1,73 @@ +/*! + strip-json-comments + Strip comments from JSON. Lets you use comments in your JSON files! + https://github.com/sindresorhus/strip-json-comments + by Sindre Sorhus + MIT License +*/ +(function () { + 'use strict'; + + var singleComment = 1; + var multiComment = 2; + + function stripJsonComments(str) { + var currentChar; + var nextChar; + var insideString = false; + var insideComment = false; + var ret = ''; + + for (var i = 0; i < str.length; i++) { + currentChar = str[i]; + nextChar = str[i + 1]; + + if (!insideComment && currentChar === '"') { + var escaped = str[i - 1] === '\\' && str[i - 2] !== '\\'; + if (!insideComment && !escaped && currentChar === '"') { + insideString = !insideString; + } + } + + if (insideString) { + ret += currentChar; + continue; + } + + if (!insideComment && currentChar + nextChar === '//') { + insideComment = singleComment; + i++; + } else if (insideComment === singleComment && currentChar + nextChar === '\r\n') { + insideComment = false; + i++; + ret += currentChar; + ret += nextChar; + continue; + } else if (insideComment === singleComment && currentChar === '\n') { + insideComment = false; + } else if (!insideComment && currentChar + nextChar === '/*') { + insideComment = multiComment; + i++; + continue; + } else if (insideComment === multiComment && currentChar + nextChar === '*/') { + insideComment = false; + i++; + continue; + } + + if (insideComment) { + continue; + } + + ret += currentChar; + } + + return ret; + } + + if (typeof module !== 'undefined' && module.exports) { + module.exports = stripJsonComments; + } else { + window.stripJsonComments = stripJsonComments; + } +})(); diff --git a/tools/node_modules/supports-color/index.js b/tools/node_modules/supports-color/index.js new file mode 100644 index 00000000000000..4346e272e1f1cd --- /dev/null +++ b/tools/node_modules/supports-color/index.js @@ -0,0 +1,50 @@ +'use strict'; +var argv = process.argv; + +var terminator = argv.indexOf('--'); +var hasFlag = function (flag) { + flag = '--' + flag; + var pos = argv.indexOf(flag); + return pos !== -1 && (terminator !== -1 ? pos < terminator : true); +}; + +module.exports = (function () { + if ('FORCE_COLOR' in process.env) { + return true; + } + + if (hasFlag('no-color') || + hasFlag('no-colors') || + hasFlag('color=false')) { + return false; + } + + if (hasFlag('color') || + hasFlag('colors') || + hasFlag('color=true') || + hasFlag('color=always')) { + return true; + } + + if (process.stdout && !process.stdout.isTTY) { + return false; + } + + if (process.platform === 'win32') { + return true; + } + + if ('COLORTERM' in process.env) { + return true; + } + + if (process.env.TERM === 'dumb') { + return false; + } + + if (/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(process.env.TERM)) { + return true; + } + + return false; +})(); diff --git a/tools/node_modules/supports-color/license b/tools/node_modules/supports-color/license new file mode 100644 index 00000000000000..654d0bfe943437 --- /dev/null +++ b/tools/node_modules/supports-color/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tools/node_modules/supports-color/package.json b/tools/node_modules/supports-color/package.json new file mode 100644 index 00000000000000..554102e67e7555 --- /dev/null +++ b/tools/node_modules/supports-color/package.json @@ -0,0 +1,104 @@ +{ + "_args": [ + [ + "supports-color@^2.0.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\chalk" + ] + ], + "_from": "supports-color@>=2.0.0 <3.0.0", + "_id": "supports-color@2.0.0", + "_inCache": true, + "_location": "/supports-color", + "_nodeVersion": "0.12.5", + "_npmUser": { + "email": "sindresorhus@gmail.com", + "name": "sindresorhus" + }, + "_npmVersion": "2.11.2", + "_phantomChildren": {}, + "_requested": { + "name": "supports-color", + "raw": "supports-color@^2.0.0", + "rawSpec": "^2.0.0", + "scope": null, + "spec": ">=2.0.0 <3.0.0", + "type": "range" + }, + "_requiredBy": [ + "/chalk" + ], + "_resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "_shasum": "535d045ce6b6363fa40117084629995e9df324c7", + "_shrinkwrap": null, + "_spec": "supports-color@^2.0.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\chalk", + "author": { + "email": "sindresorhus@gmail.com", + "name": "Sindre Sorhus", + "url": "sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/chalk/supports-color/issues" + }, + "dependencies": {}, + "description": "Detect whether a terminal supports color", + "devDependencies": { + "mocha": "*", + "require-uncached": "^1.0.2" + }, + "directories": {}, + "dist": { + "shasum": "535d045ce6b6363fa40117084629995e9df324c7", + "tarball": "http://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz" + }, + "engines": { + "node": ">=0.8.0" + }, + "files": [ + "index.js" + ], + "gitHead": "8400d98ade32b2adffd50902c06d9e725a5c6588", + "homepage": "https://github.com/chalk/supports-color", + "installable": true, + "keywords": [ + "256", + "ansi", + "capability", + "cli", + "color", + "colors", + "colour", + "command-line", + "console", + "detect", + "rgb", + "shell", + "styles", + "support", + "supports", + "terminal", + "tty", + "xterm" + ], + "license": "MIT", + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + }, + { + "name": "jbnicolai", + "email": "jappelman@xebia.com" + } + ], + "name": "supports-color", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "https://github.com/chalk/supports-color" + }, + "scripts": { + "test": "mocha" + }, + "version": "2.0.0" +} diff --git a/tools/node_modules/supports-color/readme.md b/tools/node_modules/supports-color/readme.md new file mode 100644 index 00000000000000..b4761f1ecdeaf0 --- /dev/null +++ b/tools/node_modules/supports-color/readme.md @@ -0,0 +1,36 @@ +# supports-color [![Build Status](https://travis-ci.org/chalk/supports-color.svg?branch=master)](https://travis-ci.org/chalk/supports-color) + +> Detect whether a terminal supports color + + +## Install + +``` +$ npm install --save supports-color +``` + + +## Usage + +```js +var supportsColor = require('supports-color'); + +if (supportsColor) { + console.log('Terminal supports color'); +} +``` + +It obeys the `--color` and `--no-color` CLI flags. + +For situations where using `--color` is not possible, add an environment variable `FORCE_COLOR` with any value to force color. Trumps `--no-color`. + + +## Related + +- [supports-color-cli](https://github.com/chalk/supports-color-cli) - CLI for this module +- [chalk](https://github.com/chalk/chalk) - Terminal string styling done right + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/tools/node_modules/text-table/.travis.yml b/tools/node_modules/text-table/.travis.yml new file mode 100644 index 00000000000000..cc4dba29d959a2 --- /dev/null +++ b/tools/node_modules/text-table/.travis.yml @@ -0,0 +1,4 @@ +language: node_js +node_js: + - "0.8" + - "0.10" diff --git a/tools/node_modules/text-table/LICENSE b/tools/node_modules/text-table/LICENSE new file mode 100644 index 00000000000000..ee27ba4b4412b0 --- /dev/null +++ b/tools/node_modules/text-table/LICENSE @@ -0,0 +1,18 @@ +This software is released under the MIT license: + +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. diff --git a/tools/node_modules/text-table/example/align.js b/tools/node_modules/text-table/example/align.js new file mode 100644 index 00000000000000..9be43098cf87b8 --- /dev/null +++ b/tools/node_modules/text-table/example/align.js @@ -0,0 +1,8 @@ +var table = require('../'); +var t = table([ + [ 'beep', '1024' ], + [ 'boop', '33450' ], + [ 'foo', '1006' ], + [ 'bar', '45' ] +], { align: [ 'l', 'r' ] }); +console.log(t); diff --git a/tools/node_modules/text-table/example/center.js b/tools/node_modules/text-table/example/center.js new file mode 100644 index 00000000000000..52b1c69e012cb1 --- /dev/null +++ b/tools/node_modules/text-table/example/center.js @@ -0,0 +1,8 @@ +var table = require('../'); +var t = table([ + [ 'beep', '1024', 'xyz' ], + [ 'boop', '3388450', 'tuv' ], + [ 'foo', '10106', 'qrstuv' ], + [ 'bar', '45', 'lmno' ] +], { align: [ 'l', 'c', 'l' ] }); +console.log(t); diff --git a/tools/node_modules/text-table/example/dotalign.js b/tools/node_modules/text-table/example/dotalign.js new file mode 100644 index 00000000000000..2cea6299368475 --- /dev/null +++ b/tools/node_modules/text-table/example/dotalign.js @@ -0,0 +1,9 @@ +var table = require('../'); +var t = table([ + [ 'beep', '1024' ], + [ 'boop', '334.212' ], + [ 'foo', '1006' ], + [ 'bar', '45.6' ], + [ 'baz', '123.' ] +], { align: [ 'l', '.' ] }); +console.log(t); diff --git a/tools/node_modules/text-table/example/doubledot.js b/tools/node_modules/text-table/example/doubledot.js new file mode 100644 index 00000000000000..bab983b664cd6d --- /dev/null +++ b/tools/node_modules/text-table/example/doubledot.js @@ -0,0 +1,11 @@ +var table = require('../'); +var t = table([ + [ '0.1.2' ], + [ '11.22.33' ], + [ '5.6.7' ], + [ '1.22222' ], + [ '12345.' ], + [ '5555.' ], + [ '123' ] +], { align: [ '.' ] }); +console.log(t); diff --git a/tools/node_modules/text-table/example/table.js b/tools/node_modules/text-table/example/table.js new file mode 100644 index 00000000000000..903ea4c417ccb0 --- /dev/null +++ b/tools/node_modules/text-table/example/table.js @@ -0,0 +1,6 @@ +var table = require('../'); +var t = table([ + [ 'master', '0123456789abcdef' ], + [ 'staging', 'fedcba9876543210' ] +]); +console.log(t); diff --git a/tools/node_modules/text-table/index.js b/tools/node_modules/text-table/index.js new file mode 100644 index 00000000000000..5c0ba9876a5e0f --- /dev/null +++ b/tools/node_modules/text-table/index.js @@ -0,0 +1,86 @@ +module.exports = function (rows_, opts) { + if (!opts) opts = {}; + var hsep = opts.hsep === undefined ? ' ' : opts.hsep; + var align = opts.align || []; + var stringLength = opts.stringLength + || function (s) { return String(s).length; } + ; + + var dotsizes = reduce(rows_, function (acc, row) { + forEach(row, function (c, ix) { + var n = dotindex(c); + if (!acc[ix] || n > acc[ix]) acc[ix] = n; + }); + return acc; + }, []); + + var rows = map(rows_, function (row) { + return map(row, function (c_, ix) { + var c = String(c_); + if (align[ix] === '.') { + var index = dotindex(c); + var size = dotsizes[ix] + (/\./.test(c) ? 1 : 2) + - (stringLength(c) - index) + ; + return c + Array(size).join(' '); + } + else return c; + }); + }); + + var sizes = reduce(rows, function (acc, row) { + forEach(row, function (c, ix) { + var n = stringLength(c); + if (!acc[ix] || n > acc[ix]) acc[ix] = n; + }); + return acc; + }, []); + + return map(rows, function (row) { + return map(row, function (c, ix) { + var n = (sizes[ix] - stringLength(c)) || 0; + var s = Array(Math.max(n + 1, 1)).join(' '); + if (align[ix] === 'r' || align[ix] === '.') { + return s + c; + } + if (align[ix] === 'c') { + return Array(Math.ceil(n / 2 + 1)).join(' ') + + c + Array(Math.floor(n / 2 + 1)).join(' ') + ; + } + + return c + s; + }).join(hsep).replace(/\s+$/, ''); + }).join('\n'); +}; + +function dotindex (c) { + var m = /\.[^.]*$/.exec(c); + return m ? m.index + 1 : c.length; +} + +function reduce (xs, f, init) { + if (xs.reduce) return xs.reduce(f, init); + var i = 0; + var acc = arguments.length >= 3 ? init : xs[i++]; + for (; i < xs.length; i++) { + f(acc, xs[i], i); + } + return acc; +} + +function forEach (xs, f) { + if (xs.forEach) return xs.forEach(f); + for (var i = 0; i < xs.length; i++) { + f.call(xs, xs[i], i); + } +} + +function map (xs, f) { + if (xs.map) return xs.map(f); + var res = []; + for (var i = 0; i < xs.length; i++) { + res.push(f.call(xs, xs[i], i)); + } + return res; +} diff --git a/tools/node_modules/text-table/package.json b/tools/node_modules/text-table/package.json new file mode 100644 index 00000000000000..061df82a38587a --- /dev/null +++ b/tools/node_modules/text-table/package.json @@ -0,0 +1,96 @@ +{ + "_args": [ + [ + "text-table@^0.2.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\vfile-reporter" + ] + ], + "_from": "text-table@>=0.2.0 <0.3.0", + "_id": "text-table@0.2.0", + "_inCache": true, + "_location": "/text-table", + "_npmUser": { + "email": "mail@substack.net", + "name": "substack" + }, + "_npmVersion": "1.3.7", + "_phantomChildren": {}, + "_requested": { + "name": "text-table", + "raw": "text-table@^0.2.0", + "rawSpec": "^0.2.0", + "scope": null, + "spec": ">=0.2.0 <0.3.0", + "type": "range" + }, + "_requiredBy": [ + "/vfile-reporter" + ], + "_resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "_shasum": "7f5ee823ae805207c00af2df4a84ec3fcfa570b4", + "_shrinkwrap": null, + "_spec": "text-table@^0.2.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\vfile-reporter", + "author": { + "email": "mail@substack.net", + "name": "James Halliday", + "url": "http://substack.net" + }, + "bugs": { + "url": "https://github.com/substack/text-table/issues" + }, + "dependencies": {}, + "description": "borderless text tables with alignment", + "devDependencies": { + "cli-color": "~0.2.3", + "tap": "~0.4.0", + "tape": "~1.0.2" + }, + "directories": {}, + "dist": { + "shasum": "7f5ee823ae805207c00af2df4a84ec3fcfa570b4", + "tarball": "http://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz" + }, + "homepage": "https://github.com/substack/text-table", + "installable": true, + "keywords": [ + "align", + "ascii", + "rows", + "table", + "tabular", + "text" + ], + "license": "MIT", + "main": "index.js", + "maintainers": [ + { + "name": "substack", + "email": "mail@substack.net" + } + ], + "name": "text-table", + "optionalDependencies": {}, + "readme": "# text-table\n\ngenerate borderless text table strings suitable for printing to stdout\n\n[![build status](https://secure.travis-ci.org/substack/text-table.png)](http://travis-ci.org/substack/text-table)\n\n[![browser support](https://ci.testling.com/substack/text-table.png)](http://ci.testling.com/substack/text-table)\n\n# example\n\n## default align\n\n``` js\nvar table = require('text-table');\nvar t = table([\n [ 'master', '0123456789abcdef' ],\n [ 'staging', 'fedcba9876543210' ]\n]);\nconsole.log(t);\n```\n\n```\nmaster 0123456789abcdef\nstaging fedcba9876543210\n```\n\n## left-right align\n\n``` js\nvar table = require('text-table');\nvar t = table([\n [ 'beep', '1024' ],\n [ 'boop', '33450' ],\n [ 'foo', '1006' ],\n [ 'bar', '45' ]\n], { align: [ 'l', 'r' ] });\nconsole.log(t);\n```\n\n```\nbeep 1024\nboop 33450\nfoo 1006\nbar 45\n```\n\n## dotted align\n\n``` js\nvar table = require('text-table');\nvar t = table([\n [ 'beep', '1024' ],\n [ 'boop', '334.212' ],\n [ 'foo', '1006' ],\n [ 'bar', '45.6' ],\n [ 'baz', '123.' ]\n], { align: [ 'l', '.' ] });\nconsole.log(t);\n```\n\n```\nbeep 1024\nboop 334.212\nfoo 1006\nbar 45.6\nbaz 123.\n```\n\n## centered\n\n``` js\nvar table = require('text-table');\nvar t = table([\n [ 'beep', '1024', 'xyz' ],\n [ 'boop', '3388450', 'tuv' ],\n [ 'foo', '10106', 'qrstuv' ],\n [ 'bar', '45', 'lmno' ]\n], { align: [ 'l', 'c', 'l' ] });\nconsole.log(t);\n```\n\n```\nbeep 1024 xyz\nboop 3388450 tuv\nfoo 10106 qrstuv\nbar 45 lmno\n```\n\n# methods\n\n``` js\nvar table = require('text-table')\n```\n\n## var s = table(rows, opts={})\n\nReturn a formatted table string `s` from an array of `rows` and some options\n`opts`.\n\n`rows` should be an array of arrays containing strings, numbers, or other\nprintable values.\n\noptions can be:\n\n* `opts.hsep` - separator to use between columns, default `' '`\n* `opts.align` - array of alignment types for each column, default `['l','l',...]`\n* `opts.stringLength` - callback function to use when calculating the string length\n\nalignment types are:\n\n* `'l'` - left\n* `'r'` - right\n* `'c'` - center\n* `'.'` - decimal\n\n# install\n\nWith [npm](https://npmjs.org) do:\n\n```\nnpm install text-table\n```\n\n# Use with ANSI-colors\n\nSince the string length of ANSI color schemes does not equal the length\nJavaScript sees internally it is necessary to pass the a custom string length\ncalculator during the main function call.\n\nSee the `test/ansi-colors.js` file for an example.\n\n# license\n\nMIT\n", + "readmeFilename": "readme.markdown", + "repository": { + "type": "git", + "url": "git://github.com/substack/text-table.git" + }, + "scripts": { + "test": "tap test/*.js" + }, + "testling": { + "browsers": [ + "chrome/20..latest", + "firefox/10..latest", + "ie/6..latest", + "ipad/6", + "iphone/6", + "opera/11.0..latest", + "safari/latest" + ], + "files": "test/*.js" + }, + "version": "0.2.0" +} diff --git a/tools/node_modules/text-table/readme.markdown b/tools/node_modules/text-table/readme.markdown new file mode 100644 index 00000000000000..18806acd9efbed --- /dev/null +++ b/tools/node_modules/text-table/readme.markdown @@ -0,0 +1,134 @@ +# text-table + +generate borderless text table strings suitable for printing to stdout + +[![build status](https://secure.travis-ci.org/substack/text-table.png)](http://travis-ci.org/substack/text-table) + +[![browser support](https://ci.testling.com/substack/text-table.png)](http://ci.testling.com/substack/text-table) + +# example + +## default align + +``` js +var table = require('text-table'); +var t = table([ + [ 'master', '0123456789abcdef' ], + [ 'staging', 'fedcba9876543210' ] +]); +console.log(t); +``` + +``` +master 0123456789abcdef +staging fedcba9876543210 +``` + +## left-right align + +``` js +var table = require('text-table'); +var t = table([ + [ 'beep', '1024' ], + [ 'boop', '33450' ], + [ 'foo', '1006' ], + [ 'bar', '45' ] +], { align: [ 'l', 'r' ] }); +console.log(t); +``` + +``` +beep 1024 +boop 33450 +foo 1006 +bar 45 +``` + +## dotted align + +``` js +var table = require('text-table'); +var t = table([ + [ 'beep', '1024' ], + [ 'boop', '334.212' ], + [ 'foo', '1006' ], + [ 'bar', '45.6' ], + [ 'baz', '123.' ] +], { align: [ 'l', '.' ] }); +console.log(t); +``` + +``` +beep 1024 +boop 334.212 +foo 1006 +bar 45.6 +baz 123. +``` + +## centered + +``` js +var table = require('text-table'); +var t = table([ + [ 'beep', '1024', 'xyz' ], + [ 'boop', '3388450', 'tuv' ], + [ 'foo', '10106', 'qrstuv' ], + [ 'bar', '45', 'lmno' ] +], { align: [ 'l', 'c', 'l' ] }); +console.log(t); +``` + +``` +beep 1024 xyz +boop 3388450 tuv +foo 10106 qrstuv +bar 45 lmno +``` + +# methods + +``` js +var table = require('text-table') +``` + +## var s = table(rows, opts={}) + +Return a formatted table string `s` from an array of `rows` and some options +`opts`. + +`rows` should be an array of arrays containing strings, numbers, or other +printable values. + +options can be: + +* `opts.hsep` - separator to use between columns, default `' '` +* `opts.align` - array of alignment types for each column, default `['l','l',...]` +* `opts.stringLength` - callback function to use when calculating the string length + +alignment types are: + +* `'l'` - left +* `'r'` - right +* `'c'` - center +* `'.'` - decimal + +# install + +With [npm](https://npmjs.org) do: + +``` +npm install text-table +``` + +# Use with ANSI-colors + +Since the string length of ANSI color schemes does not equal the length +JavaScript sees internally it is necessary to pass the a custom string length +calculator during the main function call. + +See the `test/ansi-colors.js` file for an example. + +# license + +MIT diff --git a/tools/node_modules/text-table/test/align.js b/tools/node_modules/text-table/test/align.js new file mode 100644 index 00000000000000..245357f26a76b9 --- /dev/null +++ b/tools/node_modules/text-table/test/align.js @@ -0,0 +1,18 @@ +var test = require('tape'); +var table = require('../'); + +test('align', function (t) { + t.plan(1); + var s = table([ + [ 'beep', '1024' ], + [ 'boop', '33450' ], + [ 'foo', '1006' ], + [ 'bar', '45' ] + ], { align: [ 'l', 'r' ] }); + t.equal(s, [ + 'beep 1024', + 'boop 33450', + 'foo 1006', + 'bar 45' + ].join('\n')); +}); diff --git a/tools/node_modules/text-table/test/ansi-colors.js b/tools/node_modules/text-table/test/ansi-colors.js new file mode 100644 index 00000000000000..fbc5bb10ad732a --- /dev/null +++ b/tools/node_modules/text-table/test/ansi-colors.js @@ -0,0 +1,32 @@ +var test = require('tape'); +var table = require('../'); +var color = require('cli-color'); +var ansiTrim = require('cli-color/lib/trim'); + +test('center', function (t) { + t.plan(1); + var opts = { + align: [ 'l', 'c', 'l' ], + stringLength: function(s) { return ansiTrim(s).length } + }; + var s = table([ + [ + color.red('Red'), color.green('Green'), color.blue('Blue') + ], + [ + color.bold('Bold'), color.underline('Underline'), + color.italic('Italic') + ], + [ + color.inverse('Inverse'), color.strike('Strike'), + color.blink('Blink') + ], + [ 'bar', '45', 'lmno' ] + ], opts); + t.equal(ansiTrim(s), [ + 'Red Green Blue', + 'Bold Underline Italic', + 'Inverse Strike Blink', + 'bar 45 lmno' + ].join('\n')); +}); diff --git a/tools/node_modules/text-table/test/center.js b/tools/node_modules/text-table/test/center.js new file mode 100644 index 00000000000000..c2c7a62a8f8cca --- /dev/null +++ b/tools/node_modules/text-table/test/center.js @@ -0,0 +1,18 @@ +var test = require('tape'); +var table = require('../'); + +test('center', function (t) { + t.plan(1); + var s = table([ + [ 'beep', '1024', 'xyz' ], + [ 'boop', '3388450', 'tuv' ], + [ 'foo', '10106', 'qrstuv' ], + [ 'bar', '45', 'lmno' ] + ], { align: [ 'l', 'c', 'l' ] }); + t.equal(s, [ + 'beep 1024 xyz', + 'boop 3388450 tuv', + 'foo 10106 qrstuv', + 'bar 45 lmno' + ].join('\n')); +}); diff --git a/tools/node_modules/text-table/test/dotalign.js b/tools/node_modules/text-table/test/dotalign.js new file mode 100644 index 00000000000000..f804f9281ab135 --- /dev/null +++ b/tools/node_modules/text-table/test/dotalign.js @@ -0,0 +1,20 @@ +var test = require('tape'); +var table = require('../'); + +test('dot align', function (t) { + t.plan(1); + var s = table([ + [ 'beep', '1024' ], + [ 'boop', '334.212' ], + [ 'foo', '1006' ], + [ 'bar', '45.6' ], + [ 'baz', '123.' ] + ], { align: [ 'l', '.' ] }); + t.equal(s, [ + 'beep 1024', + 'boop 334.212', + 'foo 1006', + 'bar 45.6', + 'baz 123.' + ].join('\n')); +}); diff --git a/tools/node_modules/text-table/test/doubledot.js b/tools/node_modules/text-table/test/doubledot.js new file mode 100644 index 00000000000000..659b57c9314bca --- /dev/null +++ b/tools/node_modules/text-table/test/doubledot.js @@ -0,0 +1,24 @@ +var test = require('tape'); +var table = require('../'); + +test('dot align', function (t) { + t.plan(1); + var s = table([ + [ '0.1.2' ], + [ '11.22.33' ], + [ '5.6.7' ], + [ '1.22222' ], + [ '12345.' ], + [ '5555.' ], + [ '123' ] + ], { align: [ '.' ] }); + t.equal(s, [ + ' 0.1.2', + '11.22.33', + ' 5.6.7', + ' 1.22222', + '12345.', + ' 5555.', + ' 123' + ].join('\n')); +}); diff --git a/tools/node_modules/text-table/test/table.js b/tools/node_modules/text-table/test/table.js new file mode 100644 index 00000000000000..9c6701464cf66a --- /dev/null +++ b/tools/node_modules/text-table/test/table.js @@ -0,0 +1,14 @@ +var test = require('tape'); +var table = require('../'); + +test('table', function (t) { + t.plan(1); + var s = table([ + [ 'master', '0123456789abcdef' ], + [ 'staging', 'fedcba9876543210' ] + ]); + t.equal(s, [ + 'master 0123456789abcdef', + 'staging fedcba9876543210' + ].join('\n')); +}); diff --git a/tools/node_modules/to-vfile/index.js b/tools/node_modules/to-vfile/index.js new file mode 100644 index 00000000000000..caccafdc6f5e09 --- /dev/null +++ b/tools/node_modules/to-vfile/index.js @@ -0,0 +1,69 @@ +'use strict'; + +/* + * Dependencies. + */ + +var fs = require('fs'); +var toVFile = require('./lib/to-vfile.js'); + +/* + * Methods. + */ + +var read = fs.readFile; +var readSync = fs.readFileSync; + +/** + * Async callback. + * + * @callback toVFile~callback + * @param {Error} err - Error from reading `filePath`. + * @param {VFile} file - Virtual file. + */ + +/** + * Create a virtual file from `filePath` and fill it with + * the actual contents at `filePath`. + * + * @param {string} filePath - Path to file. + * @param {toVFile~callback} callback - Callback. + */ +function async(filePath, callback) { + var file = toVFile(filePath); + + read(filePath, 'utf-8', function (err, res) { + if (err) { + callback(err); + } else { + file.contents = res; + + callback(null, file); + } + }); +} + +/** + * Create a virtual file from `filePath` and fill it with + * the actual contents at `filePath` (synchroneously). + * + * @param {string} filePath - Path to file. + * @throws {Error} err - When reading `filePath` fails. + * @return {VFile} Virtual file. + */ +function sync(filePath) { + var file = toVFile(filePath); + + file.contents = readSync(filePath, 'utf-8'); + + return file; +} + +/* + * Expose. + */ + +toVFile.read = async; +toVFile.readSync = sync; + +module.exports = toVFile; diff --git a/tools/node_modules/to-vfile/lib/to-vfile.js b/tools/node_modules/to-vfile/lib/to-vfile.js new file mode 100644 index 00000000000000..e82e55b27c4ffb --- /dev/null +++ b/tools/node_modules/to-vfile/lib/to-vfile.js @@ -0,0 +1,38 @@ +'use strict'; + +/* + * Dependencies. + */ + +var path = require('path'); +var VFile = require('vfile'); + +/* + * Methods. + */ + +var extname = path.extname; +var basename = path.basename; +var dirname = path.dirname; + +/** + * Create a virtual file from `filePath`. + * + * @param {string} filePath - Path to file. + * @return {VFile} Virtual file. + */ +function toFile(filePath) { + var extension = extname(filePath); + + return new VFile({ + 'directory': dirname(filePath), + 'filename': basename(filePath, extension), + 'extension': extension.slice(1) + }); +} + +/* + * Expose. + */ + +module.exports = toFile; diff --git a/tools/node_modules/to-vfile/package.json b/tools/node_modules/to-vfile/package.json new file mode 100644 index 00000000000000..6616eda507d369 --- /dev/null +++ b/tools/node_modules/to-vfile/package.json @@ -0,0 +1,113 @@ +{ + "_args": [ + [ + "to-vfile@^1.0.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\remark" + ] + ], + "_from": "to-vfile@>=1.0.0 <2.0.0", + "_id": "to-vfile@1.0.0", + "_inCache": true, + "_location": "/to-vfile", + "_npmUser": { + "email": "tituswormer@gmail.com", + "name": "wooorm" + }, + "_npmVersion": "1.4.28", + "_phantomChildren": {}, + "_requested": { + "name": "to-vfile", + "raw": "to-vfile@^1.0.0", + "rawSpec": "^1.0.0", + "scope": null, + "spec": ">=1.0.0 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/remark", + "/vfile-find-down", + "/vfile-find-up" + ], + "_resolved": "https://registry.npmjs.org/to-vfile/-/to-vfile-1.0.0.tgz", + "_shasum": "88defecd43adb2ef598625f0e3d59f7f342941ba", + "_shrinkwrap": null, + "_spec": "to-vfile@^1.0.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\remark", + "author": { + "email": "tituswormer@gmail.com", + "name": "Titus Wormer" + }, + "browser": "lib/to-vfile.js", + "bugs": { + "url": "https://github.com/wooorm/to-vfile/issues" + }, + "dependencies": { + "vfile": "^1.0.0" + }, + "description": "Create a vfile from a file-path", + "devDependencies": { + "browserify": "^11.0.1", + "eslint": "^1.0.0", + "esmangle": "^1.0.1", + "istanbul": "^0.3.0", + "jscs": "^2.0.0", + "jscs-jsdoc": "^1.0.0", + "mdast": "^1.0.0", + "mdast-comment-config": "^0.1.2", + "mdast-github": "^0.3.2", + "mdast-lint": "^0.4.2", + "mdast-slug": "^0.1.1", + "mdast-validate-links": "^0.3.1", + "mocha": "^2.0.0" + }, + "directories": {}, + "dist": { + "shasum": "88defecd43adb2ef598625f0e3d59f7f342941ba", + "tarball": "http://registry.npmjs.org/to-vfile/-/to-vfile-1.0.0.tgz" + }, + "files": [ + "index.js", + "lib" + ], + "gitHead": "421c1019d8f8e20b4924f50248bdebe33a7a7bf8", + "homepage": "https://github.com/wooorm/to-vfile", + "installable": true, + "keywords": [ + "file", + "file", + "file-path", + "path", + "processing", + "text", + "virtual" + ], + "license": "MIT", + "main": "index.js", + "maintainers": [ + { + "name": "wooorm", + "email": "tituswormer@gmail.com" + } + ], + "name": "to-vfile", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "https://github.com/wooorm/to-vfile.git" + }, + "scripts": { + "build": "npm run bundle && npm run build-md", + "build-md": "mdast . --quiet", + "bundle": "browserify lib/to-vfile.js -s toVFile > to-vfile.js", + "lint": "npm run lint-api && npm run lint-style", + "lint-api": "eslint .", + "lint-style": "jscs --reporter inline .", + "make": "npm run lint && npm run test-coverage", + "postbundle": "esmangle to-vfile.js > to-vfile.min.js", + "test": "npm run test-api", + "test-api": "mocha --check-leaks test.js", + "test-coverage": "istanbul cover _mocha -- test.js", + "test-travis": "npm run test-coverage" + }, + "version": "1.0.0" +} diff --git a/tools/node_modules/to-vfile/readme.md b/tools/node_modules/to-vfile/readme.md new file mode 100644 index 00000000000000..b9f3f3dc1e6776 --- /dev/null +++ b/tools/node_modules/to-vfile/readme.md @@ -0,0 +1,132 @@ +# to-vfile [![Build Status](https://img.shields.io/travis/wooorm/to-vfile.svg)](https://travis-ci.org/wooorm/to-vfile) [![Coverage Status](https://img.shields.io/codecov/c/github/wooorm/to-vfile.svg)](https://codecov.io/github/wooorm/to-vfile) + +Create a [vfile](https://github.com/wooorm/vfile) from a file-path. + +## Installation + +[npm](https://docs.npmjs.com/cli/install): + +```bash +npm install to-vfile +``` + +**to-vfile** is also available for [bower](http://bower.io/#install-packages), +[component](https://github.com/componentjs/component), and [duo](http://duojs.org/#getting-started), +and as an AMD, CommonJS, and globals module, [uncompressed](to-vfile.js) and [compressed](to-vfile.min.js). + +> **Note:** browser-builds do not include `read` and `readSync`. + +## Usage + +```js +var toVFile = require('to-vfile'); + +var file = toVFile('./readme.md'); +/* + * { contents: '', + * filename: 'readme', + * directory: '.', + * extension: 'md', + * messages: [], + * __proto__: [VFile] } + */ + +toVFile.read('.git/HEAD', function (err, file) { + if (err) throw err; + + console.log(file); + /* + * { contents: 'ref: refs/heads/master\n', + * filename: 'HEAD', + * directory: '.git', + * extension: '', + * messages: [], + * __proto__: [VFile] } + */ +}); + +var file = toVFile.readSync('.gitignore') +/* + * { contents: '.DS_Store\n*.log\nbower_components/\nbuild/\ncomponents/\nnode_modules/\ncoverage/\nbuild.js\n', + * filename: '.gitignore', + * directory: '.', + * extension: '', + * messages: [], + * __proto__: [VFile] } + */ +``` + +## API + +### toVFile(filePath) + +Create a virtual file from `filePath`. + +**Signatures** + +* `file = toVFile(filePath)`. + +**Parameters** + +* `filePath` (`string`) — Path to a (possibly non-existent) file; + +**Returns** + +[`vfile`](https://github.com/wooorm/vfile) — Instance. + +### toVFile.read(filePath, done) + +Create a virtual file from `filePath` and fill it with the actual contents +at `filePath`. + +**Signatures** + +* `toVFile.read(filePath, callback)`. + +**Parameters** + +* `filePath` (`string`) — Path to a (possibly non-existent) file; +* `callback` — See [`function done(err, vfile)`](#function-doneerr-vfile). + +**Returns** + +[`vfile`](https://github.com/wooorm/vfile) — Instance. + +#### function done(err, vfile) + +Callback. + +**Signatures** + +* `function done(Error, null)`; +* `function done(null, VFile)`. + +**Parameters** + +* `err` (`Error`) — Error from reading `filePath`; +* `vfile` (`VFile`) — Virtual file. + +### toVFile.readSync(filePath) + +Create a virtual file from `filePath` and fill it with the actual contents at +`filePath` (synchroneously). + +**Signatures** + +* `toVFile.read(filePath, callback)`. + +**Parameters** + +* `filePath` (`string`) — Path to a (possibly non-existent) file; + +**Returns** + +[`vfile`](https://github.com/wooorm/vfile) — Instance. + +**Throw** + +`Error` — When reading `filePath` fails. + +## License + +[MIT](LICENSE) © [Titus Wormer](http://wooorm.com) diff --git a/tools/node_modules/trim-trailing-lines/LICENSE b/tools/node_modules/trim-trailing-lines/LICENSE new file mode 100644 index 00000000000000..611b67581bb8e2 --- /dev/null +++ b/tools/node_modules/trim-trailing-lines/LICENSE @@ -0,0 +1,22 @@ +(The MIT License) + +Copyright (c) 2015 Titus Wormer + +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. diff --git a/tools/node_modules/trim-trailing-lines/history.md b/tools/node_modules/trim-trailing-lines/history.md new file mode 100644 index 00000000000000..654a34d89a391f --- /dev/null +++ b/tools/node_modules/trim-trailing-lines/history.md @@ -0,0 +1,9 @@ +--- +mdast: + setext: true +--- + + + +1.0.0 / 2015-07-12 +================== diff --git a/tools/node_modules/trim-trailing-lines/index.js b/tools/node_modules/trim-trailing-lines/index.js new file mode 100644 index 00000000000000..11fe5fb5bad5bd --- /dev/null +++ b/tools/node_modules/trim-trailing-lines/index.js @@ -0,0 +1,36 @@ +'use strict'; + +/* + * Constants. + */ + +var LINE = '\n'; + +/** + * Remove final newline characters from `value`. + * + * @example + * trimTrailingLines('foo\nbar'); // 'foo\nbar' + * trimTrailingLines('foo\nbar\n'); // 'foo\nbar' + * trimTrailingLines('foo\nbar\n\n'); // 'foo\nbar' + * + * @param {string} value - Value with trailing newlines, + * coerced to string. + * @return {string} - Value without trailing newlines. + */ +function trimTrailingLines(value) { + var index; + + value = String(value); + index = value.length; + + while (value.charAt(--index) === LINE) { /* empty */ } + + return value.slice(0, index + 1); +} + +/* + * Expose. + */ + +module.exports = trimTrailingLines; diff --git a/tools/node_modules/trim-trailing-lines/package.json b/tools/node_modules/trim-trailing-lines/package.json new file mode 100644 index 00000000000000..8d8c14dca06fcd --- /dev/null +++ b/tools/node_modules/trim-trailing-lines/package.json @@ -0,0 +1,105 @@ +{ + "_args": [ + [ + "trim-trailing-lines@^1.0.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\remark" + ] + ], + "_from": "trim-trailing-lines@>=1.0.0 <2.0.0", + "_id": "trim-trailing-lines@1.0.0", + "_inCache": true, + "_location": "/trim-trailing-lines", + "_nodeVersion": "2.3.3", + "_npmUser": { + "email": "tituswormer@gmail.com", + "name": "wooorm" + }, + "_npmVersion": "2.11.3", + "_phantomChildren": {}, + "_requested": { + "name": "trim-trailing-lines", + "raw": "trim-trailing-lines@^1.0.0", + "rawSpec": "^1.0.0", + "scope": null, + "spec": ">=1.0.0 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/remark" + ], + "_resolved": "https://registry.npmjs.org/trim-trailing-lines/-/trim-trailing-lines-1.0.0.tgz", + "_shasum": "dbb638247a2232f669121c458fccd48fc2670c8e", + "_shrinkwrap": null, + "_spec": "trim-trailing-lines@^1.0.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\remark", + "author": { + "email": "tituswormer@gmail.com", + "name": "Titus Wormer" + }, + "bugs": { + "url": "https://github.com/wooorm/trim-trailing-lines/issues" + }, + "dependencies": {}, + "description": "Remove final newline characters from a string", + "devDependencies": { + "browserify": "^10.0.0", + "eslint": "^0.24.0", + "esmangle": "^1.0.0", + "istanbul": "^0.3.0", + "jscs": "^1.0.0", + "jscs-jsdoc": "^1.0.0", + "mdast": "^0.26.0", + "mdast-github": "^0.3.1", + "mdast-lint": "^0.4.1", + "mdast-yaml-config": "^0.2.0", + "mocha": "^2.0.0" + }, + "directories": {}, + "dist": { + "shasum": "dbb638247a2232f669121c458fccd48fc2670c8e", + "tarball": "http://registry.npmjs.org/trim-trailing-lines/-/trim-trailing-lines-1.0.0.tgz" + }, + "files": [ + "LICENSE", + "index.js" + ], + "gitHead": "f9104a9d88462fab698e9d1e353a23d0da6103bf", + "homepage": "https://github.com/wooorm/trim-trailing-lines#readme", + "installable": true, + "keywords": [ + "characters", + "final", + "line", + "newline", + "trim" + ], + "license": "MIT", + "maintainers": [ + { + "name": "wooorm", + "email": "tituswormer@gmail.com" + } + ], + "name": "trim-trailing-lines", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git+https://github.com/wooorm/trim-trailing-lines.git" + }, + "scripts": { + "build": "npm run build-md && npm run build-bundle", + "build-bundle": "browserify index.js --bare -s trimTrailingLines > trim-trailing-lines.js", + "build-md": "mdast . LICENSE --output --quiet", + "lint": "npm run lint-api && npm run lint-style", + "lint-api": "eslint .", + "lint-style": "jscs --reporter inline .", + "make": "npm run lint && npm run test-coverage", + "postbuild-bundle": "esmangle trim-trailing-lines.js > trim-trailing-lines.min.js", + "test": "npm run test-api", + "test-api": "mocha --check-leaks test.js", + "test-coverage": "istanbul cover _mocha -- --check-leaks test.js", + "test-coveralls": "istanbul cover _mocha --report lcovonly -- --check-leaks test.js", + "test-travis": "npm run test-coveralls" + }, + "version": "1.0.0" +} diff --git a/tools/node_modules/trim-trailing-lines/readme.md b/tools/node_modules/trim-trailing-lines/readme.md new file mode 100644 index 00000000000000..691ab82e745e5e --- /dev/null +++ b/tools/node_modules/trim-trailing-lines/readme.md @@ -0,0 +1,48 @@ +# trim-trailing-lines [![Build Status](https://img.shields.io/travis/wooorm/trim-trailing-lines.svg?style=flat)](https://travis-ci.org/wooorm/trim-trailing-lines) [![Coverage Status](https://img.shields.io/coveralls/wooorm/trim-trailing-lines.svg?style=flat)](https://coveralls.io/r/wooorm/trim-trailing-lines?branch=master) + +Remove final newline characters from a string. + +## Installation + +[npm](https://docs.npmjs.com/cli/install): + +```bash +npm install trim-trailing-lines +``` + +**trim-trailing-lines** is also available for [bower](http://bower.io/#install-packages), +[component](https://github.com/componentjs/component), [duo](http://duojs.org/#getting-started), +and for AMD, CommonJS, and globals ([uncompressed](trim-trailing-lines.js) and +[compressed](trim-trailing-lines.min.js)). + +## Usage + +Dependencies. + +```javascript +var trimTrailingLines = require('trim-trailing-lines'); +``` + +Trim trailing newline characters: + +```javascript +trimTrailingLines('foo\nbar'); // 'foo\nbar' +trimTrailingLines('foo\nbar\n'); // 'foo\nbar' +trimTrailingLines('foo\nbar\n\n'); // 'foo\nbar' +``` + +## API + +### trimTrailingLines(value) + +Remove final newline characters from `value`. + +Parameters: + +* `value` (`string`) — Value with trailing newlines, coerced to string. + +Returns: `string` — Value without trailing newlines. + +## License + +[MIT](LICENSE) @ [Titus Wormer](http://wooorm.com) diff --git a/tools/node_modules/trim/.npmignore b/tools/node_modules/trim/.npmignore new file mode 100644 index 00000000000000..f1250e584c94b8 --- /dev/null +++ b/tools/node_modules/trim/.npmignore @@ -0,0 +1,4 @@ +support +test +examples +*.sock diff --git a/tools/node_modules/trim/History.md b/tools/node_modules/trim/History.md new file mode 100644 index 00000000000000..c8aa68fa88152d --- /dev/null +++ b/tools/node_modules/trim/History.md @@ -0,0 +1,5 @@ + +0.0.1 / 2010-01-03 +================== + + * Initial release diff --git a/tools/node_modules/trim/Makefile b/tools/node_modules/trim/Makefile new file mode 100644 index 00000000000000..4e9c8d36ebcd2f --- /dev/null +++ b/tools/node_modules/trim/Makefile @@ -0,0 +1,7 @@ + +test: + @./node_modules/.bin/mocha \ + --require should \ + --reporter spec + +.PHONY: test \ No newline at end of file diff --git a/tools/node_modules/trim/Readme.md b/tools/node_modules/trim/Readme.md new file mode 100644 index 00000000000000..3460f523fbe8ac --- /dev/null +++ b/tools/node_modules/trim/Readme.md @@ -0,0 +1,69 @@ + +# trim + + Trims string whitespace. + +## Installation + +``` +$ npm install trim +$ component install component/trim +``` + +## API + + - [trim(str)](#trimstr) + - [.left(str)](#leftstr) + - [.right(str)](#rightstr) + + + +### trim(str) +should trim leading / trailing whitespace. + +```js +trim(' foo bar ').should.equal('foo bar'); +trim('\n\n\nfoo bar\n\r\n\n').should.equal('foo bar'); +``` + + +### .left(str) +should trim leading whitespace. + +```js +trim.left(' foo bar ').should.equal('foo bar '); +``` + + +### .right(str) +should trim trailing whitespace. + +```js +trim.right(' foo bar ').should.equal(' foo bar'); +``` + + +## License + +(The MIT License) + +Copyright (c) 2012 TJ Holowaychuk <tj@vision-media.ca> + +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. \ No newline at end of file diff --git a/tools/node_modules/trim/component.json b/tools/node_modules/trim/component.json new file mode 100644 index 00000000000000..560b25891e5fb6 --- /dev/null +++ b/tools/node_modules/trim/component.json @@ -0,0 +1,7 @@ +{ + "name": "trim", + "version": "0.0.1", + "description": "Trim string whitespace", + "keywords": ["string", "trim"], + "scripts": ["index.js"] +} \ No newline at end of file diff --git a/tools/node_modules/trim/index.js b/tools/node_modules/trim/index.js new file mode 100644 index 00000000000000..640c24cf302e60 --- /dev/null +++ b/tools/node_modules/trim/index.js @@ -0,0 +1,14 @@ + +exports = module.exports = trim; + +function trim(str){ + return str.replace(/^\s*|\s*$/g, ''); +} + +exports.left = function(str){ + return str.replace(/^\s*/, ''); +}; + +exports.right = function(str){ + return str.replace(/\s*$/, ''); +}; diff --git a/tools/node_modules/trim/package.json b/tools/node_modules/trim/package.json new file mode 100644 index 00000000000000..91a83144240803 --- /dev/null +++ b/tools/node_modules/trim/package.json @@ -0,0 +1,71 @@ +{ + "_args": [ + [ + "trim@^0.0.1", + "C:\\wamp\\www\\node\\tools\\node_modules\\remark" + ] + ], + "_from": "trim@>=0.0.1 <0.0.2", + "_id": "trim@0.0.1", + "_inCache": true, + "_location": "/trim", + "_npmUser": { + "email": "tj@vision-media.ca", + "name": "tjholowaychuk" + }, + "_npmVersion": "1.2.2", + "_phantomChildren": {}, + "_requested": { + "name": "trim", + "raw": "trim@^0.0.1", + "rawSpec": "^0.0.1", + "scope": null, + "spec": ">=0.0.1 <0.0.2", + "type": "range" + }, + "_requiredBy": [ + "/remark" + ], + "_resolved": "https://registry.npmjs.org/trim/-/trim-0.0.1.tgz", + "_shasum": "5858547f6b290757ee95cccc666fb50084c460dd", + "_shrinkwrap": null, + "_spec": "trim@^0.0.1", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\remark", + "author": { + "email": "tj@vision-media.ca", + "name": "TJ Holowaychuk" + }, + "component": { + "scripts": { + "trim/index.js": "index.js" + } + }, + "dependencies": {}, + "description": "Trim string whitespace", + "devDependencies": { + "mocha": "*", + "should": "*" + }, + "directories": {}, + "dist": { + "shasum": "5858547f6b290757ee95cccc666fb50084c460dd", + "tarball": "http://registry.npmjs.org/trim/-/trim-0.0.1.tgz" + }, + "installable": true, + "keywords": [ + "string", + "trim" + ], + "main": "index", + "maintainers": [ + { + "name": "tjholowaychuk", + "email": "tj@vision-media.ca" + } + ], + "name": "trim", + "optionalDependencies": {}, + "readme": "\n# trim\n\n Trims string whitespace.\n\n## Installation\n\n```\n$ npm install trim\n$ component install component/trim\n```\n\n## API\n\n - [trim(str)](#trimstr)\n - [.left(str)](#leftstr)\n - [.right(str)](#rightstr)\n\n \n\n### trim(str)\nshould trim leading / trailing whitespace.\n\n```js\ntrim(' foo bar ').should.equal('foo bar');\ntrim('\\n\\n\\nfoo bar\\n\\r\\n\\n').should.equal('foo bar');\n```\n\n\n### .left(str)\nshould trim leading whitespace.\n\n```js\ntrim.left(' foo bar ').should.equal('foo bar ');\n```\n\n\n### .right(str)\nshould trim trailing whitespace.\n\n```js\ntrim.right(' foo bar ').should.equal(' foo bar');\n```\n\n\n## License \n\n(The MIT License)\n\nCopyright (c) 2012 TJ Holowaychuk <tj@vision-media.ca>\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.", + "readmeFilename": "Readme.md", + "version": "0.0.1" +} diff --git a/tools/node_modules/typedarray/.travis.yml b/tools/node_modules/typedarray/.travis.yml new file mode 100644 index 00000000000000..cc4dba29d959a2 --- /dev/null +++ b/tools/node_modules/typedarray/.travis.yml @@ -0,0 +1,4 @@ +language: node_js +node_js: + - "0.8" + - "0.10" diff --git a/tools/node_modules/typedarray/LICENSE b/tools/node_modules/typedarray/LICENSE new file mode 100644 index 00000000000000..11adfaec9e7f95 --- /dev/null +++ b/tools/node_modules/typedarray/LICENSE @@ -0,0 +1,35 @@ +/* + Copyright (c) 2010, Linden Research, Inc. + Copyright (c) 2012, Joshua Bell + + 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. + $/LicenseInfo$ + */ + +// Original can be found at: +// https://bitbucket.org/lindenlab/llsd +// Modifications by Joshua Bell inexorabletash@gmail.com +// https://github.com/inexorabletash/polyfill + +// ES3/ES5 implementation of the Krhonos Typed Array Specification +// Ref: http://www.khronos.org/registry/typedarray/specs/latest/ +// Date: 2011-02-01 +// +// Variations: +// * Allows typed_array.get/set() as alias for subscripts (typed_array[]) diff --git a/tools/node_modules/typedarray/example/tarray.js b/tools/node_modules/typedarray/example/tarray.js new file mode 100644 index 00000000000000..8423d7c9b1c327 --- /dev/null +++ b/tools/node_modules/typedarray/example/tarray.js @@ -0,0 +1,4 @@ +var Uint8Array = require('../').Uint8Array; +var ua = new Uint8Array(5); +ua[1] = 256 + 55; +console.log(ua[1]); diff --git a/tools/node_modules/typedarray/index.js b/tools/node_modules/typedarray/index.js new file mode 100644 index 00000000000000..5e540841f43241 --- /dev/null +++ b/tools/node_modules/typedarray/index.js @@ -0,0 +1,630 @@ +var undefined = (void 0); // Paranoia + +// Beyond this value, index getters/setters (i.e. array[0], array[1]) are so slow to +// create, and consume so much memory, that the browser appears frozen. +var MAX_ARRAY_LENGTH = 1e5; + +// Approximations of internal ECMAScript conversion functions +var ECMAScript = (function() { + // Stash a copy in case other scripts modify these + var opts = Object.prototype.toString, + ophop = Object.prototype.hasOwnProperty; + + return { + // Class returns internal [[Class]] property, used to avoid cross-frame instanceof issues: + Class: function(v) { return opts.call(v).replace(/^\[object *|\]$/g, ''); }, + HasProperty: function(o, p) { return p in o; }, + HasOwnProperty: function(o, p) { return ophop.call(o, p); }, + IsCallable: function(o) { return typeof o === 'function'; }, + ToInt32: function(v) { return v >> 0; }, + ToUint32: function(v) { return v >>> 0; } + }; +}()); + +// Snapshot intrinsics +var LN2 = Math.LN2, + abs = Math.abs, + floor = Math.floor, + log = Math.log, + min = Math.min, + pow = Math.pow, + round = Math.round; + +// ES5: lock down object properties +function configureProperties(obj) { + if (getOwnPropNames && defineProp) { + var props = getOwnPropNames(obj), i; + for (i = 0; i < props.length; i += 1) { + defineProp(obj, props[i], { + value: obj[props[i]], + writable: false, + enumerable: false, + configurable: false + }); + } + } +} + +// emulate ES5 getter/setter API using legacy APIs +// http://blogs.msdn.com/b/ie/archive/2010/09/07/transitioning-existing-code-to-the-es5-getter-setter-apis.aspx +// (second clause tests for Object.defineProperty() in IE<9 that only supports extending DOM prototypes, but +// note that IE<9 does not support __defineGetter__ or __defineSetter__ so it just renders the method harmless) +var defineProp +if (Object.defineProperty && (function() { + try { + Object.defineProperty({}, 'x', {}); + return true; + } catch (e) { + return false; + } + })()) { + defineProp = Object.defineProperty; +} else { + defineProp = function(o, p, desc) { + if (!o === Object(o)) throw new TypeError("Object.defineProperty called on non-object"); + if (ECMAScript.HasProperty(desc, 'get') && Object.prototype.__defineGetter__) { Object.prototype.__defineGetter__.call(o, p, desc.get); } + if (ECMAScript.HasProperty(desc, 'set') && Object.prototype.__defineSetter__) { Object.prototype.__defineSetter__.call(o, p, desc.set); } + if (ECMAScript.HasProperty(desc, 'value')) { o[p] = desc.value; } + return o; + }; +} + +var getOwnPropNames = Object.getOwnPropertyNames || function (o) { + if (o !== Object(o)) throw new TypeError("Object.getOwnPropertyNames called on non-object"); + var props = [], p; + for (p in o) { + if (ECMAScript.HasOwnProperty(o, p)) { + props.push(p); + } + } + return props; +}; + +// ES5: Make obj[index] an alias for obj._getter(index)/obj._setter(index, value) +// for index in 0 ... obj.length +function makeArrayAccessors(obj) { + if (!defineProp) { return; } + + if (obj.length > MAX_ARRAY_LENGTH) throw new RangeError("Array too large for polyfill"); + + function makeArrayAccessor(index) { + defineProp(obj, index, { + 'get': function() { return obj._getter(index); }, + 'set': function(v) { obj._setter(index, v); }, + enumerable: true, + configurable: false + }); + } + + var i; + for (i = 0; i < obj.length; i += 1) { + makeArrayAccessor(i); + } +} + +// Internal conversion functions: +// pack() - take a number (interpreted as Type), output a byte array +// unpack() - take a byte array, output a Type-like number + +function as_signed(value, bits) { var s = 32 - bits; return (value << s) >> s; } +function as_unsigned(value, bits) { var s = 32 - bits; return (value << s) >>> s; } + +function packI8(n) { return [n & 0xff]; } +function unpackI8(bytes) { return as_signed(bytes[0], 8); } + +function packU8(n) { return [n & 0xff]; } +function unpackU8(bytes) { return as_unsigned(bytes[0], 8); } + +function packU8Clamped(n) { n = round(Number(n)); return [n < 0 ? 0 : n > 0xff ? 0xff : n & 0xff]; } + +function packI16(n) { return [(n >> 8) & 0xff, n & 0xff]; } +function unpackI16(bytes) { return as_signed(bytes[0] << 8 | bytes[1], 16); } + +function packU16(n) { return [(n >> 8) & 0xff, n & 0xff]; } +function unpackU16(bytes) { return as_unsigned(bytes[0] << 8 | bytes[1], 16); } + +function packI32(n) { return [(n >> 24) & 0xff, (n >> 16) & 0xff, (n >> 8) & 0xff, n & 0xff]; } +function unpackI32(bytes) { return as_signed(bytes[0] << 24 | bytes[1] << 16 | bytes[2] << 8 | bytes[3], 32); } + +function packU32(n) { return [(n >> 24) & 0xff, (n >> 16) & 0xff, (n >> 8) & 0xff, n & 0xff]; } +function unpackU32(bytes) { return as_unsigned(bytes[0] << 24 | bytes[1] << 16 | bytes[2] << 8 | bytes[3], 32); } + +function packIEEE754(v, ebits, fbits) { + + var bias = (1 << (ebits - 1)) - 1, + s, e, f, ln, + i, bits, str, bytes; + + function roundToEven(n) { + var w = floor(n), f = n - w; + if (f < 0.5) + return w; + if (f > 0.5) + return w + 1; + return w % 2 ? w + 1 : w; + } + + // Compute sign, exponent, fraction + if (v !== v) { + // NaN + // http://dev.w3.org/2006/webapi/WebIDL/#es-type-mapping + e = (1 << ebits) - 1; f = pow(2, fbits - 1); s = 0; + } else if (v === Infinity || v === -Infinity) { + e = (1 << ebits) - 1; f = 0; s = (v < 0) ? 1 : 0; + } else if (v === 0) { + e = 0; f = 0; s = (1 / v === -Infinity) ? 1 : 0; + } else { + s = v < 0; + v = abs(v); + + if (v >= pow(2, 1 - bias)) { + e = min(floor(log(v) / LN2), 1023); + f = roundToEven(v / pow(2, e) * pow(2, fbits)); + if (f / pow(2, fbits) >= 2) { + e = e + 1; + f = 1; + } + if (e > bias) { + // Overflow + e = (1 << ebits) - 1; + f = 0; + } else { + // Normalized + e = e + bias; + f = f - pow(2, fbits); + } + } else { + // Denormalized + e = 0; + f = roundToEven(v / pow(2, 1 - bias - fbits)); + } + } + + // Pack sign, exponent, fraction + bits = []; + for (i = fbits; i; i -= 1) { bits.push(f % 2 ? 1 : 0); f = floor(f / 2); } + for (i = ebits; i; i -= 1) { bits.push(e % 2 ? 1 : 0); e = floor(e / 2); } + bits.push(s ? 1 : 0); + bits.reverse(); + str = bits.join(''); + + // Bits to bytes + bytes = []; + while (str.length) { + bytes.push(parseInt(str.substring(0, 8), 2)); + str = str.substring(8); + } + return bytes; +} + +function unpackIEEE754(bytes, ebits, fbits) { + + // Bytes to bits + var bits = [], i, j, b, str, + bias, s, e, f; + + for (i = bytes.length; i; i -= 1) { + b = bytes[i - 1]; + for (j = 8; j; j -= 1) { + bits.push(b % 2 ? 1 : 0); b = b >> 1; + } + } + bits.reverse(); + str = bits.join(''); + + // Unpack sign, exponent, fraction + bias = (1 << (ebits - 1)) - 1; + s = parseInt(str.substring(0, 1), 2) ? -1 : 1; + e = parseInt(str.substring(1, 1 + ebits), 2); + f = parseInt(str.substring(1 + ebits), 2); + + // Produce number + if (e === (1 << ebits) - 1) { + return f !== 0 ? NaN : s * Infinity; + } else if (e > 0) { + // Normalized + return s * pow(2, e - bias) * (1 + f / pow(2, fbits)); + } else if (f !== 0) { + // Denormalized + return s * pow(2, -(bias - 1)) * (f / pow(2, fbits)); + } else { + return s < 0 ? -0 : 0; + } +} + +function unpackF64(b) { return unpackIEEE754(b, 11, 52); } +function packF64(v) { return packIEEE754(v, 11, 52); } +function unpackF32(b) { return unpackIEEE754(b, 8, 23); } +function packF32(v) { return packIEEE754(v, 8, 23); } + + +// +// 3 The ArrayBuffer Type +// + +(function() { + + /** @constructor */ + var ArrayBuffer = function ArrayBuffer(length) { + length = ECMAScript.ToInt32(length); + if (length < 0) throw new RangeError('ArrayBuffer size is not a small enough positive integer'); + + this.byteLength = length; + this._bytes = []; + this._bytes.length = length; + + var i; + for (i = 0; i < this.byteLength; i += 1) { + this._bytes[i] = 0; + } + + configureProperties(this); + }; + + exports.ArrayBuffer = exports.ArrayBuffer || ArrayBuffer; + + // + // 4 The ArrayBufferView Type + // + + // NOTE: this constructor is not exported + /** @constructor */ + var ArrayBufferView = function ArrayBufferView() { + //this.buffer = null; + //this.byteOffset = 0; + //this.byteLength = 0; + }; + + // + // 5 The Typed Array View Types + // + + function makeConstructor(bytesPerElement, pack, unpack) { + // Each TypedArray type requires a distinct constructor instance with + // identical logic, which this produces. + + var ctor; + ctor = function(buffer, byteOffset, length) { + var array, sequence, i, s; + + if (!arguments.length || typeof arguments[0] === 'number') { + // Constructor(unsigned long length) + this.length = ECMAScript.ToInt32(arguments[0]); + if (length < 0) throw new RangeError('ArrayBufferView size is not a small enough positive integer'); + + this.byteLength = this.length * this.BYTES_PER_ELEMENT; + this.buffer = new ArrayBuffer(this.byteLength); + this.byteOffset = 0; + } else if (typeof arguments[0] === 'object' && arguments[0].constructor === ctor) { + // Constructor(TypedArray array) + array = arguments[0]; + + this.length = array.length; + this.byteLength = this.length * this.BYTES_PER_ELEMENT; + this.buffer = new ArrayBuffer(this.byteLength); + this.byteOffset = 0; + + for (i = 0; i < this.length; i += 1) { + this._setter(i, array._getter(i)); + } + } else if (typeof arguments[0] === 'object' && + !(arguments[0] instanceof ArrayBuffer || ECMAScript.Class(arguments[0]) === 'ArrayBuffer')) { + // Constructor(sequence array) + sequence = arguments[0]; + + this.length = ECMAScript.ToUint32(sequence.length); + this.byteLength = this.length * this.BYTES_PER_ELEMENT; + this.buffer = new ArrayBuffer(this.byteLength); + this.byteOffset = 0; + + for (i = 0; i < this.length; i += 1) { + s = sequence[i]; + this._setter(i, Number(s)); + } + } else if (typeof arguments[0] === 'object' && + (arguments[0] instanceof ArrayBuffer || ECMAScript.Class(arguments[0]) === 'ArrayBuffer')) { + // Constructor(ArrayBuffer buffer, + // optional unsigned long byteOffset, optional unsigned long length) + this.buffer = buffer; + + this.byteOffset = ECMAScript.ToUint32(byteOffset); + if (this.byteOffset > this.buffer.byteLength) { + throw new RangeError("byteOffset out of range"); + } + + if (this.byteOffset % this.BYTES_PER_ELEMENT) { + // The given byteOffset must be a multiple of the element + // size of the specific type, otherwise an exception is raised. + throw new RangeError("ArrayBuffer length minus the byteOffset is not a multiple of the element size."); + } + + if (arguments.length < 3) { + this.byteLength = this.buffer.byteLength - this.byteOffset; + + if (this.byteLength % this.BYTES_PER_ELEMENT) { + throw new RangeError("length of buffer minus byteOffset not a multiple of the element size"); + } + this.length = this.byteLength / this.BYTES_PER_ELEMENT; + } else { + this.length = ECMAScript.ToUint32(length); + this.byteLength = this.length * this.BYTES_PER_ELEMENT; + } + + if ((this.byteOffset + this.byteLength) > this.buffer.byteLength) { + throw new RangeError("byteOffset and length reference an area beyond the end of the buffer"); + } + } else { + throw new TypeError("Unexpected argument type(s)"); + } + + this.constructor = ctor; + + configureProperties(this); + makeArrayAccessors(this); + }; + + ctor.prototype = new ArrayBufferView(); + ctor.prototype.BYTES_PER_ELEMENT = bytesPerElement; + ctor.prototype._pack = pack; + ctor.prototype._unpack = unpack; + ctor.BYTES_PER_ELEMENT = bytesPerElement; + + // getter type (unsigned long index); + ctor.prototype._getter = function(index) { + if (arguments.length < 1) throw new SyntaxError("Not enough arguments"); + + index = ECMAScript.ToUint32(index); + if (index >= this.length) { + return undefined; + } + + var bytes = [], i, o; + for (i = 0, o = this.byteOffset + index * this.BYTES_PER_ELEMENT; + i < this.BYTES_PER_ELEMENT; + i += 1, o += 1) { + bytes.push(this.buffer._bytes[o]); + } + return this._unpack(bytes); + }; + + // NONSTANDARD: convenience alias for getter: type get(unsigned long index); + ctor.prototype.get = ctor.prototype._getter; + + // setter void (unsigned long index, type value); + ctor.prototype._setter = function(index, value) { + if (arguments.length < 2) throw new SyntaxError("Not enough arguments"); + + index = ECMAScript.ToUint32(index); + if (index >= this.length) { + return undefined; + } + + var bytes = this._pack(value), i, o; + for (i = 0, o = this.byteOffset + index * this.BYTES_PER_ELEMENT; + i < this.BYTES_PER_ELEMENT; + i += 1, o += 1) { + this.buffer._bytes[o] = bytes[i]; + } + }; + + // void set(TypedArray array, optional unsigned long offset); + // void set(sequence array, optional unsigned long offset); + ctor.prototype.set = function(index, value) { + if (arguments.length < 1) throw new SyntaxError("Not enough arguments"); + var array, sequence, offset, len, + i, s, d, + byteOffset, byteLength, tmp; + + if (typeof arguments[0] === 'object' && arguments[0].constructor === this.constructor) { + // void set(TypedArray array, optional unsigned long offset); + array = arguments[0]; + offset = ECMAScript.ToUint32(arguments[1]); + + if (offset + array.length > this.length) { + throw new RangeError("Offset plus length of array is out of range"); + } + + byteOffset = this.byteOffset + offset * this.BYTES_PER_ELEMENT; + byteLength = array.length * this.BYTES_PER_ELEMENT; + + if (array.buffer === this.buffer) { + tmp = []; + for (i = 0, s = array.byteOffset; i < byteLength; i += 1, s += 1) { + tmp[i] = array.buffer._bytes[s]; + } + for (i = 0, d = byteOffset; i < byteLength; i += 1, d += 1) { + this.buffer._bytes[d] = tmp[i]; + } + } else { + for (i = 0, s = array.byteOffset, d = byteOffset; + i < byteLength; i += 1, s += 1, d += 1) { + this.buffer._bytes[d] = array.buffer._bytes[s]; + } + } + } else if (typeof arguments[0] === 'object' && typeof arguments[0].length !== 'undefined') { + // void set(sequence array, optional unsigned long offset); + sequence = arguments[0]; + len = ECMAScript.ToUint32(sequence.length); + offset = ECMAScript.ToUint32(arguments[1]); + + if (offset + len > this.length) { + throw new RangeError("Offset plus length of array is out of range"); + } + + for (i = 0; i < len; i += 1) { + s = sequence[i]; + this._setter(offset + i, Number(s)); + } + } else { + throw new TypeError("Unexpected argument type(s)"); + } + }; + + // TypedArray subarray(long begin, optional long end); + ctor.prototype.subarray = function(start, end) { + function clamp(v, min, max) { return v < min ? min : v > max ? max : v; } + + start = ECMAScript.ToInt32(start); + end = ECMAScript.ToInt32(end); + + if (arguments.length < 1) { start = 0; } + if (arguments.length < 2) { end = this.length; } + + if (start < 0) { start = this.length + start; } + if (end < 0) { end = this.length + end; } + + start = clamp(start, 0, this.length); + end = clamp(end, 0, this.length); + + var len = end - start; + if (len < 0) { + len = 0; + } + + return new this.constructor( + this.buffer, this.byteOffset + start * this.BYTES_PER_ELEMENT, len); + }; + + return ctor; + } + + var Int8Array = makeConstructor(1, packI8, unpackI8); + var Uint8Array = makeConstructor(1, packU8, unpackU8); + var Uint8ClampedArray = makeConstructor(1, packU8Clamped, unpackU8); + var Int16Array = makeConstructor(2, packI16, unpackI16); + var Uint16Array = makeConstructor(2, packU16, unpackU16); + var Int32Array = makeConstructor(4, packI32, unpackI32); + var Uint32Array = makeConstructor(4, packU32, unpackU32); + var Float32Array = makeConstructor(4, packF32, unpackF32); + var Float64Array = makeConstructor(8, packF64, unpackF64); + + exports.Int8Array = exports.Int8Array || Int8Array; + exports.Uint8Array = exports.Uint8Array || Uint8Array; + exports.Uint8ClampedArray = exports.Uint8ClampedArray || Uint8ClampedArray; + exports.Int16Array = exports.Int16Array || Int16Array; + exports.Uint16Array = exports.Uint16Array || Uint16Array; + exports.Int32Array = exports.Int32Array || Int32Array; + exports.Uint32Array = exports.Uint32Array || Uint32Array; + exports.Float32Array = exports.Float32Array || Float32Array; + exports.Float64Array = exports.Float64Array || Float64Array; +}()); + +// +// 6 The DataView View Type +// + +(function() { + function r(array, index) { + return ECMAScript.IsCallable(array.get) ? array.get(index) : array[index]; + } + + var IS_BIG_ENDIAN = (function() { + var u16array = new(exports.Uint16Array)([0x1234]), + u8array = new(exports.Uint8Array)(u16array.buffer); + return r(u8array, 0) === 0x12; + }()); + + // Constructor(ArrayBuffer buffer, + // optional unsigned long byteOffset, + // optional unsigned long byteLength) + /** @constructor */ + var DataView = function DataView(buffer, byteOffset, byteLength) { + if (arguments.length === 0) { + buffer = new exports.ArrayBuffer(0); + } else if (!(buffer instanceof exports.ArrayBuffer || ECMAScript.Class(buffer) === 'ArrayBuffer')) { + throw new TypeError("TypeError"); + } + + this.buffer = buffer || new exports.ArrayBuffer(0); + + this.byteOffset = ECMAScript.ToUint32(byteOffset); + if (this.byteOffset > this.buffer.byteLength) { + throw new RangeError("byteOffset out of range"); + } + + if (arguments.length < 3) { + this.byteLength = this.buffer.byteLength - this.byteOffset; + } else { + this.byteLength = ECMAScript.ToUint32(byteLength); + } + + if ((this.byteOffset + this.byteLength) > this.buffer.byteLength) { + throw new RangeError("byteOffset and length reference an area beyond the end of the buffer"); + } + + configureProperties(this); + }; + + function makeGetter(arrayType) { + return function(byteOffset, littleEndian) { + + byteOffset = ECMAScript.ToUint32(byteOffset); + + if (byteOffset + arrayType.BYTES_PER_ELEMENT > this.byteLength) { + throw new RangeError("Array index out of range"); + } + byteOffset += this.byteOffset; + + var uint8Array = new exports.Uint8Array(this.buffer, byteOffset, arrayType.BYTES_PER_ELEMENT), + bytes = [], i; + for (i = 0; i < arrayType.BYTES_PER_ELEMENT; i += 1) { + bytes.push(r(uint8Array, i)); + } + + if (Boolean(littleEndian) === Boolean(IS_BIG_ENDIAN)) { + bytes.reverse(); + } + + return r(new arrayType(new exports.Uint8Array(bytes).buffer), 0); + }; + } + + DataView.prototype.getUint8 = makeGetter(exports.Uint8Array); + DataView.prototype.getInt8 = makeGetter(exports.Int8Array); + DataView.prototype.getUint16 = makeGetter(exports.Uint16Array); + DataView.prototype.getInt16 = makeGetter(exports.Int16Array); + DataView.prototype.getUint32 = makeGetter(exports.Uint32Array); + DataView.prototype.getInt32 = makeGetter(exports.Int32Array); + DataView.prototype.getFloat32 = makeGetter(exports.Float32Array); + DataView.prototype.getFloat64 = makeGetter(exports.Float64Array); + + function makeSetter(arrayType) { + return function(byteOffset, value, littleEndian) { + + byteOffset = ECMAScript.ToUint32(byteOffset); + if (byteOffset + arrayType.BYTES_PER_ELEMENT > this.byteLength) { + throw new RangeError("Array index out of range"); + } + + // Get bytes + var typeArray = new arrayType([value]), + byteArray = new exports.Uint8Array(typeArray.buffer), + bytes = [], i, byteView; + + for (i = 0; i < arrayType.BYTES_PER_ELEMENT; i += 1) { + bytes.push(r(byteArray, i)); + } + + // Flip if necessary + if (Boolean(littleEndian) === Boolean(IS_BIG_ENDIAN)) { + bytes.reverse(); + } + + // Write them + byteView = new exports.Uint8Array(this.buffer, byteOffset, arrayType.BYTES_PER_ELEMENT); + byteView.set(bytes); + }; + } + + DataView.prototype.setUint8 = makeSetter(exports.Uint8Array); + DataView.prototype.setInt8 = makeSetter(exports.Int8Array); + DataView.prototype.setUint16 = makeSetter(exports.Uint16Array); + DataView.prototype.setInt16 = makeSetter(exports.Int16Array); + DataView.prototype.setUint32 = makeSetter(exports.Uint32Array); + DataView.prototype.setInt32 = makeSetter(exports.Int32Array); + DataView.prototype.setFloat32 = makeSetter(exports.Float32Array); + DataView.prototype.setFloat64 = makeSetter(exports.Float64Array); + + exports.DataView = exports.DataView || DataView; + +}()); diff --git a/tools/node_modules/typedarray/package.json b/tools/node_modules/typedarray/package.json new file mode 100644 index 00000000000000..fbef613a6f9674 --- /dev/null +++ b/tools/node_modules/typedarray/package.json @@ -0,0 +1,104 @@ +{ + "_args": [ + [ + "typedarray@~0.0.5", + "C:\\wamp\\www\\node\\tools\\node_modules\\concat-stream" + ] + ], + "_from": "typedarray@>=0.0.5 <0.1.0", + "_id": "typedarray@0.0.6", + "_inCache": true, + "_location": "/typedarray", + "_npmUser": { + "email": "mail@substack.net", + "name": "substack" + }, + "_npmVersion": "1.4.3", + "_phantomChildren": {}, + "_requested": { + "name": "typedarray", + "raw": "typedarray@~0.0.5", + "rawSpec": "~0.0.5", + "scope": null, + "spec": ">=0.0.5 <0.1.0", + "type": "range" + }, + "_requiredBy": [ + "/concat-stream" + ], + "_resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "_shasum": "867ac74e3864187b1d3d47d996a78ec5c8830777", + "_shrinkwrap": null, + "_spec": "typedarray@~0.0.5", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\concat-stream", + "author": { + "email": "mail@substack.net", + "name": "James Halliday", + "url": "http://substack.net" + }, + "bugs": { + "url": "https://github.com/substack/typedarray/issues" + }, + "dependencies": {}, + "description": "TypedArray polyfill for old browsers", + "devDependencies": { + "tape": "~2.3.2" + }, + "directories": {}, + "dist": { + "shasum": "867ac74e3864187b1d3d47d996a78ec5c8830777", + "tarball": "http://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz" + }, + "homepage": "https://github.com/substack/typedarray", + "installable": true, + "keywords": [ + "ArrayBuffer", + "DataView", + "Float32Array", + "Float64Array", + "Int16Array", + "Int32Array", + "Int8Array", + "Uint16Array", + "Uint32Array", + "Uint8Array", + "Uint8ClampedArray", + "array", + "polyfill", + "typed" + ], + "license": "MIT", + "main": "index.js", + "maintainers": [ + { + "name": "substack", + "email": "mail@substack.net" + } + ], + "name": "typedarray", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git://github.com/substack/typedarray.git" + }, + "scripts": { + "test": "tape test/*.js test/server/*.js" + }, + "testling": { + "browsers": [ + "android-browser/4.2..latest", + "chrome/22..latest", + "chrome/canary", + "firefox/16..latest", + "firefox/nightly", + "ie/6..latest", + "ipad/6.0..latest", + "iphone/6.0..latest", + "opera/12..latest", + "opera/next", + "safari/5.1..latest" + ], + "files": "test/*.js" + }, + "version": "0.0.6" +} diff --git a/tools/node_modules/typedarray/readme.markdown b/tools/node_modules/typedarray/readme.markdown new file mode 100644 index 00000000000000..d18f6f7197e6a5 --- /dev/null +++ b/tools/node_modules/typedarray/readme.markdown @@ -0,0 +1,61 @@ +# typedarray + +TypedArray polyfill ripped from [this +module](https://raw.github.com/inexorabletash/polyfill). + +[![build status](https://secure.travis-ci.org/substack/typedarray.png)](http://travis-ci.org/substack/typedarray) + +[![testling badge](https://ci.testling.com/substack/typedarray.png)](https://ci.testling.com/substack/typedarray) + +# example + +``` js +var Uint8Array = require('typedarray').Uint8Array; +var ua = new Uint8Array(5); +ua[1] = 256 + 55; +console.log(ua[1]); +``` + +output: + +``` +55 +``` + +# methods + +``` js +var TA = require('typedarray') +``` + +The `TA` object has the following constructors: + +* TA.ArrayBuffer +* TA.DataView +* TA.Float32Array +* TA.Float64Array +* TA.Int8Array +* TA.Int16Array +* TA.Int32Array +* TA.Uint8Array +* TA.Uint8ClampedArray +* TA.Uint16Array +* TA.Uint32Array + +# install + +With [npm](https://npmjs.org) do: + +``` +npm install typedarray +``` + +To use this module in the browser, compile with +[browserify](http://browserify.org) +or download a UMD build from browserify CDN: + +http://wzrd.in/standalone/typedarray@latest + +# license + +MIT diff --git a/tools/node_modules/typedarray/test/server/undef_globals.js b/tools/node_modules/typedarray/test/server/undef_globals.js new file mode 100644 index 00000000000000..425950f9fc9ed7 --- /dev/null +++ b/tools/node_modules/typedarray/test/server/undef_globals.js @@ -0,0 +1,19 @@ +var test = require('tape'); +var vm = require('vm'); +var fs = require('fs'); +var src = fs.readFileSync(__dirname + '/../../index.js', 'utf8'); + +test('u8a without globals', function (t) { + var c = { + module: { exports: {} }, + }; + c.exports = c.module.exports; + vm.runInNewContext(src, c); + var TA = c.module.exports; + var ua = new(TA.Uint8Array)(5); + + t.equal(ua.length, 5); + ua[1] = 256 + 55; + t.equal(ua[1], 55); + t.end(); +}); diff --git a/tools/node_modules/typedarray/test/tarray.js b/tools/node_modules/typedarray/test/tarray.js new file mode 100644 index 00000000000000..df596a34f23c0e --- /dev/null +++ b/tools/node_modules/typedarray/test/tarray.js @@ -0,0 +1,10 @@ +var TA = require('../'); +var test = require('tape'); + +test('tiny u8a test', function (t) { + var ua = new(TA.Uint8Array)(5); + t.equal(ua.length, 5); + ua[1] = 256 + 55; + t.equal(ua[1], 55); + t.end(); +}); diff --git a/tools/node_modules/unherit/LICENSE b/tools/node_modules/unherit/LICENSE new file mode 100644 index 00000000000000..f3722d94b38121 --- /dev/null +++ b/tools/node_modules/unherit/LICENSE @@ -0,0 +1,21 @@ +(The MIT License) + +Copyright (c) 2015 Titus Wormer + +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. diff --git a/tools/node_modules/unherit/history.md b/tools/node_modules/unherit/history.md new file mode 100644 index 00000000000000..a85d5be3c6938b --- /dev/null +++ b/tools/node_modules/unherit/history.md @@ -0,0 +1,26 @@ + + + + +1.0.4 / 2015-07-28 +================== + +* Fix [d1ab727](https://github.com/wooorm/unherit/commit/d1ab727) ([e11553f](https://github.com/wooorm/unherit/commit/e11553f)) + +1.0.3 / 2015-07-27 +================== + +* Fix missing dependency ([49860a0](https://github.com/wooorm/unherit/commit/49860a0)) + +1.0.2 / 2015-07-27 +================== + +* Fix for `instanceof` checks without `new` in super ([d1ab727](https://github.com/wooorm/unherit/commit/d1ab727)) + +1.0.1 / 2015-07-26 +================== + +* Add support for fooling `instanceof` ([efe9e00](https://github.com/wooorm/unherit/commit/efe9e00)) + +1.0.0 / 2015-07-26 +================== diff --git a/tools/node_modules/unherit/index.js b/tools/node_modules/unherit/index.js new file mode 100644 index 00000000000000..e269f0dc7210bb --- /dev/null +++ b/tools/node_modules/unherit/index.js @@ -0,0 +1,85 @@ +/** + * @author Titus Wormer + * @copyright 2015 Titus Wormer + * @license MIT + * @module unherit + * @fileoverview Create a custom constructor which can be modified + * without affecting the original class. + * @example + * var EventEmitter = require('events').EventEmitter; + * var Emitter = unherit(EventEmitter); + * // Create a private class which acts just like + * // `EventEmitter`. + * + * Emitter.prototype.defaultMaxListeners = 0; + * // Now, all instances of `Emitter` have no maximum + * // listeners, without affecting other `EventEmitter`s. + */ + +'use strict'; + +/* + * Dependencies. + */ + +var clone = require('clone'); +var inherits = require('inherits'); + +/** + * Create a custom constructor which can be modified + * without affecting the original class. + * + * @param {Function} Super - Super-class. + * @return {Function} - Constructor acting like `Super`, + * which can be modified without affecting the original + * class. + */ +function unherit(Super) { + var base = clone(Super.prototype); + var result; + var key; + + /** + * Constructor accepting a single argument, + * which itself is an `arguments` object. + */ + function From(parameters) { + return Super.apply(this, parameters); + } + + /** + * Constructor accepting variadic arguments. + */ + function Of() { + if (!(this instanceof Of)) { + return new From(arguments); + } + + return Super.apply(this, arguments); + } + + inherits(Of, Super); + inherits(From, Of); + + /* + * Both do duplicate work. However, cloning the + * prototype ensures clonable things are cloned + * and thus used. The `inherits` call ensures + * `instanceof` still thinks an instance subclasses + * `Super`. + */ + + result = Of.prototype; + + for (key in base) { + result[key] = base[key]; + } + + return Of; +} + +/* + * Expose. + */ + +module.exports = unherit; diff --git a/tools/node_modules/unherit/package.json b/tools/node_modules/unherit/package.json new file mode 100644 index 00000000000000..f20a05c531e7ce --- /dev/null +++ b/tools/node_modules/unherit/package.json @@ -0,0 +1,110 @@ +{ + "_args": [ + [ + "unherit@^1.0.4", + "C:\\wamp\\www\\node\\tools\\node_modules\\unified" + ] + ], + "_from": "unherit@>=1.0.4 <2.0.0", + "_id": "unherit@1.0.4", + "_inCache": true, + "_location": "/unherit", + "_nodeVersion": "2.3.3", + "_npmUser": { + "email": "tituswormer@gmail.com", + "name": "wooorm" + }, + "_npmVersion": "2.11.3", + "_phantomChildren": {}, + "_requested": { + "name": "unherit", + "raw": "unherit@^1.0.4", + "rawSpec": "^1.0.4", + "scope": null, + "spec": ">=1.0.4 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/attach-ware", + "/unified" + ], + "_resolved": "https://registry.npmjs.org/unherit/-/unherit-1.0.4.tgz", + "_shasum": "b9bcf6487dd04d4782665802dbb4b4f05d618503", + "_shrinkwrap": null, + "_spec": "unherit@^1.0.4", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\unified", + "author": { + "email": "tituswormer@gmail.com", + "name": "Titus Wormer" + }, + "bugs": { + "url": "https://github.com/wooorm/unherit/issues" + }, + "dependencies": { + "clone": "^1.0.1", + "inherits": "^2.0.1" + }, + "description": "Clone a constructor without affecting the super-class", + "devDependencies": { + "browserify": "^11.0.0", + "eslint": "^0.24.0", + "esmangle": "^1.0.0", + "istanbul": "^0.3.0", + "jscs": "^1.0.0", + "jscs-jsdoc": "^1.0.0", + "mdast": "^0.27.1", + "mdast-comment-config": "^0.1.2", + "mdast-github": "^0.3.0", + "mdast-lint": "^0.4.0", + "mdast-man": "^0.4.0", + "mdast-toc": "^0.5.0", + "mdast-validate-links": "^0.3.0", + "mocha": "^2.0.0" + }, + "directories": {}, + "dist": { + "shasum": "b9bcf6487dd04d4782665802dbb4b4f05d618503", + "tarball": "http://registry.npmjs.org/unherit/-/unherit-1.0.4.tgz" + }, + "files": [ + "index.js" + ], + "gitHead": "03c7c3e7ff84f443f7418e39d28fb45f859d660a", + "homepage": "https://github.com/wooorm/unherit#readme", + "installable": true, + "keywords": [ + "class", + "clone", + "constructor", + "super" + ], + "license": "MIT", + "maintainers": [ + { + "name": "wooorm", + "email": "tituswormer@gmail.com" + } + ], + "name": "unherit", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git+https://github.com/wooorm/unherit.git" + }, + "scripts": { + "build": "npm run build-md && npm run build-bundle", + "build-bundle": "browserify index.js --bare -s unherit > unherit.js", + "build-md": "mdast . --quiet", + "lint": "npm run lint-api && npm run lint-style", + "lint-api": "eslint .", + "lint-style": "jscs --reporter inline .", + "make": "npm run lint && npm run test-coverage", + "postbuild-bundle": "esmangle unherit.js > unherit.min.js", + "test": "npm run test-api", + "test-api": "mocha --check-leaks test.js", + "test-coverage": "istanbul cover _mocha -- -- test.js", + "test-coveralls": "istanbul cover _mocha --report lcovonly -- --check-leaks test.js", + "test-travis": "npm run test-coveralls" + }, + "version": "1.0.4" +} diff --git a/tools/node_modules/unherit/readme.md b/tools/node_modules/unherit/readme.md new file mode 100644 index 00000000000000..53ce99a468f6cd --- /dev/null +++ b/tools/node_modules/unherit/readme.md @@ -0,0 +1,54 @@ +# unherit [![Build Status](https://img.shields.io/travis/wooorm/unherit.svg)](https://travis-ci.org/wooorm/unherit) [![Coverage Status](https://img.shields.io/codecov/c/github/wooorm/unherit.svg)](https://codecov.io/github/wooorm/unherit?branch=master) + +Create a custom constructor which can be modified without affecting the +original class. + +## Installation + +[npm](https://docs.npmjs.com/cli/install): + +```bash +npm install unherit +``` + +**unherit** is also available for [bower](http://bower.io/#install-packages), +[component](https://github.com/componentjs/component), and [duo](http://duojs.org/#getting-started), +and as an AMD, CommonJS, and globals module, [uncompressed](unherit.js) and [compressed](unherit.min.js). + +## Usage + +```js +var EventEmitter = require('events').EventEmitter; + +/* Create a private class which acts just like + * `EventEmitter`. */ +var Emitter = unherit(EventEmitter); + +Emitter.prototype.defaultMaxListeners = 0; +/* Now, all instances of `Emitter` have no maximum + * listeners, without affecting other `EventEmitter`s. */ + +assert(new Emitter().defaultMaxListeners === 0); // true +assert(new EventEmitter().defaultMaxListeners === undefined); // true +assert(new Emitter() instanceof EventEmitter); // true +``` + +## API + +### unherit(Super) + +Create a custom constructor which can be modified without affecting the +original class. + +**Parameters** + +* `Super` (`Function`) — Super-class. + +**Returns** + +(`Function`) — Constructor acting like `Super`, which can be modified +without affecting the original class. + +## License + +[MIT](LICENSE) © [Titus Wormer](http://wooorm.com) diff --git a/tools/node_modules/unified/LICENSE b/tools/node_modules/unified/LICENSE new file mode 100644 index 00000000000000..f3722d94b38121 --- /dev/null +++ b/tools/node_modules/unified/LICENSE @@ -0,0 +1,21 @@ +(The MIT License) + +Copyright (c) 2015 Titus Wormer + +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. diff --git a/tools/node_modules/unified/history.md b/tools/node_modules/unified/history.md new file mode 100644 index 00000000000000..cd7c3b883e3207 --- /dev/null +++ b/tools/node_modules/unified/history.md @@ -0,0 +1,41 @@ + + + + +2.1.4 / 2016-01-24 +================== + +2.1.3 / 2016-01-24 +================== + +* Add section on `unified-bridges` ([`1adb6ac`](https://github.com/wooorm/unified/commit/1adb6ac)) +* Add list of processors ([`2670ade`](https://github.com/wooorm/unified/commit/2670ade)) +* Remove support for Component ([`85207f4`](https://github.com/wooorm/unified/commit/85207f4)) +* Remove support for Bower ([`3e09ed6`](https://github.com/wooorm/unified/commit/3e09ed6)) +* Remove distribution files from source ([`7acb775`](https://github.com/wooorm/unified/commit/7acb775)) +* Refactor to replace mocha with tape ([`1533d17`](https://github.com/wooorm/unified/commit/1533d17)) +* Refactor `readme.md` ([`f323dfd`](https://github.com/wooorm/unified/commit/f323dfd)) + +2.1.2 / 2015-10-23 +================== + +* Refactor browserify system ([`c95686d`](https://github.com/wooorm/unified/commit/c95686d)) + +2.1.1 / 2015-10-14 +================== + +* Fix component and duo support ([`3eacf6a`](https://github.com/wooorm/unified/commit/3eacf6a)) + +2.1.0 / 2015-10-10 +================== + +* Add support for processor data ([`e9b9f7e`](https://github.com/wooorm/unified/commit/e9b9f7e)) +* Add references to `hast` ([`d1a1c7e`](https://github.com/wooorm/unified/commit/d1a1c7e)) + +2.0.0 / 2015-09-16 +================== + +* Remove `type` support ([`8748cfe`](https://github.com/wooorm/unified/commit/8748cfe)) + +1.0.0 / 2015-07-31 +================== diff --git a/tools/node_modules/unified/index.js b/tools/node_modules/unified/index.js new file mode 100644 index 00000000000000..1ae212a6d7a620 --- /dev/null +++ b/tools/node_modules/unified/index.js @@ -0,0 +1,293 @@ +/** + * @author Titus Wormer + * @copyright 2015 Titus Wormer + * @license MIT + * @module unified + * @fileoverview Parse / Transform / Compile / Repeat. + */ + +'use strict'; + +/* eslint-env commonjs */ + +/* + * Dependencies. + */ + +var bail = require('bail'); +var ware = require('ware'); +var AttachWare = require('attach-ware')(ware); +var VFile = require('vfile'); +var unherit = require('unherit'); +var extend; + +try { + extend = require('node-extend'); +} catch (e) { + extend = require('extend'); +} + +/* + * Processing pipeline. + */ + +var pipeline = ware() + .use(function (ctx) { + ctx.tree = ctx.context.parse(ctx.file, ctx.settings); + }) + .use(function (ctx, next) { + ctx.context.run(ctx.tree, ctx.file, next); + }) + .use(function (ctx) { + ctx.result = ctx.context.stringify(ctx.tree, ctx.file, ctx.settings); + }); + +/** + * Construct a new Processor class based on the + * given options. + * + * @param {Object} options - Configuration. + * @param {string} options.name - Private storage. + * @param {Function} options.Parser - Class to turn a + * virtual file into a syntax tree. + * @param {Function} options.Compiler - Class to turn a + * syntax tree into a string. + * @return {Processor} - A new constructor. + */ +function unified(options) { + var name = options.name; + var Parser = options.Parser; + var Compiler = options.Compiler; + var data = options.data; + + /** + * Construct a Processor instance. + * + * @constructor + * @class {Processor} + */ + function Processor(processor) { + var self = this; + + if (!(self instanceof Processor)) { + return new Processor(processor); + } + + self.ware = new AttachWare(processor && processor.ware); + self.ware.context = self; + + self.Parser = unherit(Parser); + self.Compiler = unherit(Compiler); + + if (self.data) { + self.data = extend(true, {}, self.data); + } + } + + /** + * Either return `context` if its an instance + * of `Processor` or construct a new `Processor` + * instance. + * + * @private + * @param {Processor?} [context] - Context object. + * @return {Processor} - Either `context` or a new + * Processor instance. + */ + function instance(context) { + return context instanceof Processor ? context : new Processor(); + } + + /** + * Attach a plugin. + * + * @this {Processor?} - Either a Processor instance or + * the Processor constructor. + * @return {Processor} - Either `context` or a new + * Processor instance. + */ + function use() { + var self = instance(this); + + self.ware.use.apply(self.ware, arguments); + + return self; + } + + /** + * Transform. + * + * @this {Processor?} - Either a Processor instance or + * the Processor constructor. + * @param {Node} [node] - Syntax tree. + * @param {VFile?} [file] - Virtual file. + * @param {Function?} [done] - Callback. + * @return {Node} - `node`. + */ + function run(node, file, done) { + var self = this; + var space; + + if (typeof file === 'function') { + done = file; + file = null; + } + + if (!file && node && !node.type) { + file = node; + node = null; + } + + file = new VFile(file); + space = file.namespace(name); + + if (!node) { + node = space.tree || node; + } else if (!space.tree) { + space.tree = node; + } + + if (!node) { + throw new Error('Expected node, got ' + node); + } + + done = typeof done === 'function' ? done : bail; + + /* + * Only run when this is an instance of Processor, + * and when there are transformers. + */ + + if (self.ware && self.ware.fns) { + self.ware.run(node, file, done); + } else { + done(null, node, file); + } + + return node; + } + + /** + * Parse a file. + * + * Patches the parsed node onto the `name` + * namespace on the `type` property. + * + * @this {Processor?} - Either a Processor instance or + * the Processor constructor. + * @param {string|VFile} value - Input to parse. + * @param {Object?} [settings] - Configuration. + * @return {Node} - `node`. + */ + function parse(value, settings) { + var file = new VFile(value); + var CustomParser = (this && this.Parser) || Parser; + var node = new CustomParser(file, settings, instance(this)).parse(); + + file.namespace(name).tree = node; + + return node; + } + + /** + * Compile a file. + * + * Used the parsed node at the `name` + * namespace at `'tree'` when no node was given. + * + * @this {Processor?} - Either a Processor instance or + * the Processor constructor. + * @param {Object} [node] - Syntax tree. + * @param {VFile} [file] - File with syntax tree. + * @param {Object?} [settings] - Configuration. + * @return {string} - Compiled `file`. + */ + function stringify(node, file, settings) { + var CustomCompiler = (this && this.Compiler) || Compiler; + var space; + + if (settings === null || settings === undefined) { + settings = file; + file = null; + } + + if (!file && node && !node.type) { + file = node; + node = null; + } + + file = new VFile(file); + space = file.namespace(name); + + if (!node) { + node = space.tree || node; + } else if (!space.tree) { + space.tree = node; + } + + if (!node) { + throw new Error('Expected node, got ' + node); + } + + return new CustomCompiler(file, settings, instance(this)).compile(); + } + + /** + * Parse / Transform / Compile. + * + * @this {Processor?} - Either a Processor instance or + * the Processor constructor. + * @param {string|VFile} value - Input to process. + * @param {Object?} [settings] - Configuration. + * @param {Function?} [done] - Callback. + * @return {string?} - Parsed document, when + * transformation was async. + */ + function process(value, settings, done) { + var self = instance(this); + var file = new VFile(value); + var result = null; + + if (typeof settings === 'function') { + done = settings; + settings = null; + } + + pipeline.run({ + 'context': self, + 'file': file, + 'settings': settings || {} + }, function (err, res) { + result = res && res.result; + + if (done) { + done(err, file, result); + } else if (err) { + bail(err); + } + }); + + return result; + } + + /* + * Methods / functions. + */ + + var proto = Processor.prototype; + + Processor.use = proto.use = use; + Processor.parse = proto.parse = parse; + Processor.run = proto.run = run; + Processor.stringify = proto.stringify = stringify; + Processor.process = proto.process = process; + Processor.data = proto.data = data || null; + + return Processor; +} + +/* + * Expose. + */ + +module.exports = unified; diff --git a/tools/node_modules/unified/package.json b/tools/node_modules/unified/package.json new file mode 100644 index 00000000000000..8392b54a448c04 --- /dev/null +++ b/tools/node_modules/unified/package.json @@ -0,0 +1,117 @@ +{ + "_args": [ + [ + "unified@^2.0.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\remark" + ] + ], + "_from": "unified@>=2.0.0 <3.0.0", + "_id": "unified@2.1.4", + "_inCache": true, + "_location": "/unified", + "_nodeVersion": "5.1.0", + "_npmUser": { + "email": "tituswormer@gmail.com", + "name": "wooorm" + }, + "_npmVersion": "3.5.0", + "_phantomChildren": {}, + "_requested": { + "name": "unified", + "raw": "unified@^2.0.0", + "rawSpec": "^2.0.0", + "scope": null, + "spec": ">=2.0.0 <3.0.0", + "type": "range" + }, + "_requiredBy": [ + "/remark" + ], + "_resolved": "https://registry.npmjs.org/unified/-/unified-2.1.4.tgz", + "_shasum": "14bc6cd40d98ffff75b405506bad873ecbbac3ba", + "_shrinkwrap": null, + "_spec": "unified@^2.0.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\remark", + "author": { + "email": "tituswormer@gmail.com", + "name": "Titus Wormer" + }, + "browser": { + "node-extend": "extend" + }, + "bugs": { + "url": "https://github.com/wooorm/unified/issues" + }, + "dependencies": { + "attach-ware": "^1.0.0", + "bail": "^1.0.0", + "extend": "^3.0.0", + "unherit": "^1.0.4", + "vfile": "^1.0.0", + "ware": "^1.3.0" + }, + "description": "Text processing framework: Parse / Transform / Compile", + "devDependencies": { + "browserify": "^13.0.0", + "eslint": "^1.0.0", + "esmangle": "^1.0.0", + "istanbul": "^0.4.0", + "jscs": "^2.0.0", + "jscs-jsdoc": "^1.0.0", + "remark": "^3.0.0", + "remark-comment-config": "^2.0.0", + "remark-github": "^4.0.0", + "remark-lint": "^2.0.0", + "remark-man": "^2.0.0", + "remark-toc": "^2.0.0", + "remark-validate-links": "^2.0.0", + "tape": "^4.4.0" + }, + "directories": {}, + "dist": { + "shasum": "14bc6cd40d98ffff75b405506bad873ecbbac3ba", + "tarball": "http://registry.npmjs.org/unified/-/unified-2.1.4.tgz" + }, + "files": [ + "index.js" + ], + "gitHead": "cf783f04890e5e9532982ba3abb37643a78ca66e", + "homepage": "https://github.com/wooorm/unified#readme", + "installable": true, + "keywords": [ + "compile", + "hast", + "parse", + "process", + "remark", + "retext", + "stringify", + "transform" + ], + "license": "MIT", + "maintainers": [ + { + "name": "wooorm", + "email": "tituswormer@gmail.com" + } + ], + "name": "unified", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git+https://github.com/wooorm/unified.git" + }, + "scripts": { + "build": "npm run build-md && npm run build-bundle && npm run build-mangle", + "build-bundle": "browserify index.js -s AttachWare > unified.js", + "build-mangle": "esmangle unified.js > unified.min.js", + "build-md": "remark . --quiet --frail", + "lint": "npm run lint-api && npm run lint-style", + "lint-api": "eslint .", + "lint-style": "jscs --reporter inline .", + "test": "npm run build && npm run lint && npm run test-coverage", + "test-api": "node test.js", + "test-coverage": "istanbul cover test.js" + }, + "version": "2.1.4" +} diff --git a/tools/node_modules/unified/readme.md b/tools/node_modules/unified/readme.md new file mode 100644 index 00000000000000..14a0db0fdad208 --- /dev/null +++ b/tools/node_modules/unified/readme.md @@ -0,0 +1,432 @@ +# unified [![Build Status][travis-badge]][travis] [![Coverage Status][codecov-badge]][codecov] + +Text processing framework: Parse / Transform / Compile. + +This library provides the boilerplate to make parsing and compiling pluggable. +It’s in use by [**remark**][remark], [**retext**][retext], and [**hast**][hast]. + +## Installation + +[npm][npm-install]: + +```bash +npm install unified +``` + +**unified** is also available for [duo][duo-install], and as an AMD, +CommonJS, and globals module, [uncompressed and compressed][releases]. + +## Usage + +From [**remark**][remark-index]: + +```js +var unified = require('unified'); +var Parser = require('./lib/parse.js'); +var Compiler = require('./lib/stringify.js'); + +module.exports = unified({ + 'name': 'mdast', + 'Parser': Parser, + 'Compiler': Compiler +}); +``` + +## Table of Contents + +* [List of Processors](#list-of-processors) + +* [Bridges](#bridges) + +* [API](#api) + + * [unified(options)](#unifiedoptions) + + * [Processor(\[processor\])](#processorprocessor) + + * [processor.Parser](#processorparser) + + * [processor.Compiler](#processorcompiler) + + * [Processor#use(plugin\[, input...\])](#processoruseplugin-input) + + * [Plugin](#plugin) + * [function attacher(processor\[, input...\])](#function-attacherprocessor-input) + * [function transformer(node, file\[, next\])](#function-transformernode-file-next) + + * [Processor#parse(file\[, options\])](#processorparsefile-options) + + * [Processor#run(node\[, file\]\[, done\])](#processorrunnode-file-done) + + * [function done(err, node, file)](#function-doneerr-node-file) + + * [Processor#stringify(node\[, file\]\[, options\])](#processorstringifynode-file-options) + + * [Processor#process(file\[, options\]\[, done\])](#processorprocessfile-options-done) + + * [function done(err, doc, file)](#function-doneerr-doc-file) + + * [Processor#data](#processordata) + +* [License](#license) + +## List of Processors + +* [**remark**][remark] + — Markdown processor powered by plugins. + +* [**retext**][retext] + — Extensible system for analysing and manipulating natural language. + +* [**hast**][hast] + — HTML processor powered by plugins. + +## Bridges + +Bridges are a concept which support two-way transformation between processors. +See [**unified-bridge**][unified-bridge] for more information. + +* [**remark-retext**][remark-retext] + — Transformation from markdown to natural language (currently + it’s not possible to return to markdown); + +## API + +### `unified(options)` + +Create a new `Processor` constructor. + +**Parameters** — `options` (`Object`): + +* `name` (`string`) — Unique namespace, e.g. `'mdast'` or `'retext'`. + +* `data` (`Object`, optional) — `JSON.stringify`able dictionary providing + information to `Parser`, `Compiler`, and plug-ins. + +* `Parser` (`Function`) — Constructor which transforms a virtual file + into a syntax tree. When input is parsed, this function will be + constructed with a `file`, `settings`, and the processor. `Parser` + instances must have a `parse` method which returns a `node` (an object + with a `type` property). + + The string representation of a file can be accessed by executing + `file.toString();`. + +* `Compiler` (`Function`) — Constructor which transforms a node + into a string. When input is compiled, this function will be + constructed with a `file`, `settings`, and the processor. `Compiler` + instances must have a `compile` method which returns a `string`. + + The syntax tree representation of a file can be accessed by executing + `file.namespace(name).tree`. + +**Returns** — `Function` (`Processor` constructor). + +### `Processor([processor])` + +> Note that all methods on the instance are also available as functions on the +> constructor, which, when invoked, create a new instance. +> +> Thus, invoking `new Processor().process()` is the same as +> `Processor.process()`. + +Create a new `Processor` instance. + +**Parameters** + +* `processor` (`Processor`, optional) — Uses all plug-ins available on the + reference processor instance, on the newly constructed processor instance. + +**Returns** + +`Processor`. + +### `processor.Parser` + +### `processor.Compiler` + +The constructors passed to [`unified`][unified-options] at `'Parser'` +and `'Compiler'` are stored on `Processor` instances. The `Parser` +is responsible for parsing a virtual file into a syntax tree, and the +`Compiler` for compiling a syntax tree into something else. + +When a processor is constructed, both are passed to [unherit][], which +ensures that plug-ins can change how the processor instance parses and +compiles without affecting other processors. + +`Parser`s must have a `parse` method, `Compiler`s a `compile` method. + +### `Processor#use(plugin[, input...])` + +Change the way the processor works by using a plugin. + +**Signatures** + +* `unified = unified.use(plugin[, input...])`; +* `unified = unified.use(plugins)`. + +**Parameters** + +* `plugin` (`Function`) — [Plugin][]. +* `plugins` (`Array.`) — List of plugins. +* `input` (`*`) — Passed to plugin. Specified by its documentation. + +**Returns** + +`Processor` — `this` (the context object). + +#### `Plugin` + +A **uniware** plugin changes the way the applied-on processor works. It does +two things: + +* It modifies the instance: such as changing the Parser or the Compiler; +* It transforms a syntax tree representation of a file. + +Both have their own function. The first is called an [“attacher”][attacher]. +The second is named a [“transformer”][transformer]. An “attacher” may return +a “transformer”. + +#### `function attacher(processor[, input...])` + +To modify the processor, create an attacher. An attacher is the thing passed to +[`use`][use]. It can receive plugin specific options, but that’s entirely up to +the third-party developer. + +An **attacher** is invoked when the plugin is [`use`][use]d, and can return +a transformer which will be called on subsequent [`process()`][process]s and +[`run()`][run]s. + +**Signatures** + +* `transformer? = attacher(processor[, input...])`. + +**Parameters** + +* `processor` (`Processor`) — Context on which the plugin was [`use`][use]d; +* `input` (`*`) — Passed by the user of a plug-in. + +**Returns** + +[`transformer`][transformer] (optional). + +#### `function transformer(node, file[, next])` + +To transform a syntax tree, create a transformer. A transformer is a simple +(generator) function which is invoked each time a file is +[`process()`][process]s and [`run()`][run]s. A transformer should change +the syntax tree representation of a file. + +**Signatures** + +* `err? = transformer(node, file)`; +* `transformer(node, file, next)`; +* `Promise. = transformer(node, file)`; +* `transformer*(node, file)`. + +**Parameters** + +* `node` (`Node`) — Syntax tree representation of a file; + +* `file` (`VFile`) — [Virtual file][vfile]; + +* `next` (`function([err])`, optional) — If the signature includes both + `next`, `transformer` **may** finish asynchronous, and **must** + invoke `next()` on completion with an optional error. + +**Returns** — Optionally: + +* `Error` — Exception which will be thrown; + +* `Promise.` — Promise which must be resolved or rejected + on completion. + +### `Processor#parse(file[, options])` + +Parse a document into a syntax tree. + +When given a file, stores the returned node on that file. + +**Signatures** + +* `node = processor.parse(file|value[, options])`. + +**Parameters** + +* `file` (`VFile`) — [Virtual file][vfile]. +* `value` (`string`) — String representation of a file. +* `options` (`Object`) — Configuration given to the parser. + +**Returns** + +`Node` — (`Object`). + +### `Processor#run(node[, file][, done])` + +Transform a syntax tree by applying plug-ins to it. + +Either a node or a file which was previously passed to `processor.parse()`, +must be given. + +**Signatures** + +* `node = processor.run(node[, file|value][, done])`; +* `node = processor.run(file[, done])`. + +**Parameters** + +* `node` (`Object`) — Syntax tree as returned by `parse()`; +* `file` (`VFile`) — [Virtual file][vfile]. +* `value` (`string`) — String representation of a file. +* `done` ([`function done(err, node, file)`][run-done]). + +**Returns** + +`Node` — The given syntax tree node. + +**Throws** + +When no `node` was given and no node was found on the file. + +#### `function done(err, node, file)` + +Invoked when transformation is complete. + +**Signatures** + +* `function done(err)`; +* `function done(null, node, file)`. + +**Parameters** + +* `exception` (`Error`) — Failure; +* `doc` (`string`) — Document generated by the process; +* `file` (`File`) — File object representing the input file; + +### `Processor#stringify(node[, file][, options])` + +Compile a syntax tree into a document. + +Either a node or a file which was previously passed to `processor.parse()`, +must be given. + +**Signatures** + +* `doc = processor.stringify(node[, file|value][, options])`; +* `doc = processor.stringify(file[, options])`. + +**Parameters** + +* `node` (`Object`) — Syntax tree as returned by `parse()`; +* `file` (`VFile`) — [Virtual file][vfile]. +* `value` (`string`) — String representation of a file. +* `options` (`Object`) — Configuration. + +**Returns** + +`doc` (`string`) — Document. + +**Throws** + +When no `node` was given and no node was found on the file. + +### `Processor#process(file[, options][, done])` + +Parse / Transform / Compile. When an async transformer is used, +`null` is returned and `done` must be given to receive the results +upon completion. + +**Signatures** + +* `doc = processor.process(file|value[, options][, done])`. + +**Parameters** + +* `file` (`File`) — [Virtual file][vfile]; +* `value` (`string`) — String representation of a file; +* `options` (`Object`) — Configuration. +* `done` ([`function done(err?, doc?, file?)`][process-done]). + +**Returns** + +`string` — Document generated by the process; + +#### `function done(err, doc, file)` + +Invoked when processing is complete. + +**Signatures** + +* `function done(err)`; +* `function done(null, doc, file)`. + +**Parameters** + +* `exception` (`Error`) — Failure; +* `doc` (`string`) — Document generated by the process; +* `file` (`File`) — File object representing the input file; + +### `Processor#data` + +`JSON.stringify`able dictionary providing information to `Parser`, `Compiler`, +and plug-ins. Cloned when a `Processor` is constructed and to `processor.data`. + +**Type**: `Object`, optional. + +## License + +[MIT][license] © [Titus Wormer][author] + + + +[travis-badge]: https://img.shields.io/travis/wooorm/unified.svg + +[travis]: https://travis-ci.org/wooorm/unified + +[codecov-badge]: https://img.shields.io/codecov/c/github/wooorm/unified.svg + +[codecov]: https://codecov.io/github/wooorm/unified + +[npm-install]: https://docs.npmjs.com/cli/install + +[duo-install]: http://duojs.org/#getting-started + +[releases]: https://github.com/wooorm/unified/releases + +[license]: LICENSE + +[author]: http://wooorm.com + +[remark]: https://github.com/wooorm/remark + +[retext]: https://github.com/wooorm/retext + +[hast]: https://github.com/wooorm/hast + +[unherit]: https://github.com/wooorm/unherit + +[vfile]: https://github.com/wooorm/vfile + +[unified-bridge]: https://github.com/wooorrm/unified-bridge + +[remark-retext]: https://github.com/wooorrm/remark-retext + +[remark-index]: https://github.com/wooorm/remark/blob/master/index.js + +[unified-options]: #unifiedoptions + +[plugin]: #plugin + +[attacher]: #function-attacherprocessor-input + +[transformer]: #function-transformernode-file-next + +[use]: #processoruseplugin-input + +[process]: #processorprocessfile-options-done + +[process-done]: #function-doneerr-doc-file + +[run]: #processorrunnode-file-done + +[run-done]: #function-doneerr-node-file diff --git a/tools/node_modules/untildify/index.js b/tools/node_modules/untildify/index.js new file mode 100644 index 00000000000000..a9153a4588cae0 --- /dev/null +++ b/tools/node_modules/untildify/index.js @@ -0,0 +1,11 @@ +'use strict'; +var osHomedir = require('os-homedir'); +var home = osHomedir(); + +module.exports = function (str) { + if (typeof str !== 'string') { + throw new TypeError('Expected a string'); + } + + return home ? str.replace(/^~($|\/|\\)/, home + '$1') : str; +}; diff --git a/tools/node_modules/untildify/license b/tools/node_modules/untildify/license new file mode 100644 index 00000000000000..654d0bfe943437 --- /dev/null +++ b/tools/node_modules/untildify/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tools/node_modules/untildify/package.json b/tools/node_modules/untildify/package.json new file mode 100644 index 00000000000000..c135d282dfff8b --- /dev/null +++ b/tools/node_modules/untildify/package.json @@ -0,0 +1,105 @@ +{ + "_args": [ + [ + "untildify@^2.1.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\npm-prefix" + ] + ], + "_from": "untildify@>=2.1.0 <3.0.0", + "_id": "untildify@2.1.0", + "_inCache": true, + "_location": "/untildify", + "_nodeVersion": "0.12.4", + "_npmUser": { + "email": "sindresorhus@gmail.com", + "name": "sindresorhus" + }, + "_npmVersion": "2.10.1", + "_phantomChildren": {}, + "_requested": { + "name": "untildify", + "raw": "untildify@^2.1.0", + "rawSpec": "^2.1.0", + "scope": null, + "spec": ">=2.1.0 <3.0.0", + "type": "range" + }, + "_requiredBy": [ + "/npm-prefix" + ], + "_resolved": "https://registry.npmjs.org/untildify/-/untildify-2.1.0.tgz", + "_shasum": "17eb2807987f76952e9c0485fc311d06a826a2e0", + "_shrinkwrap": null, + "_spec": "untildify@^2.1.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\npm-prefix", + "author": { + "email": "sindresorhus@gmail.com", + "name": "Sindre Sorhus", + "url": "sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/sindresorhus/untildify/issues" + }, + "contributors": [ + { + "name": "silverwind", + "email": "me@silverwind.io", + "url": "https://silverwind.io" + } + ], + "dependencies": { + "os-homedir": "^1.0.0" + }, + "description": "Convert a tilde path to an absolute path: ~/dev => /Users/sindresorhus/dev", + "devDependencies": { + "ava": "0.0.4" + }, + "directories": {}, + "dist": { + "shasum": "17eb2807987f76952e9c0485fc311d06a826a2e0", + "tarball": "http://registry.npmjs.org/untildify/-/untildify-2.1.0.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "430eb2e240b60dc2ea60b537a2eea56d64767ecd", + "homepage": "https://github.com/sindresorhus/untildify", + "installable": true, + "keywords": [ + "bash", + "dir", + "directory", + "expand", + "expansion", + "home", + "path", + "shell", + "tilde", + "untildify", + "user" + ], + "license": "MIT", + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + }, + { + "name": "silverwind", + "email": "me@silverwind.io" + } + ], + "name": "untildify", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "https://github.com/sindresorhus/untildify" + }, + "scripts": { + "test": "node test.js" + }, + "version": "2.1.0" +} diff --git a/tools/node_modules/untildify/readme.md b/tools/node_modules/untildify/readme.md new file mode 100644 index 00000000000000..8592f6b00a0f0b --- /dev/null +++ b/tools/node_modules/untildify/readme.md @@ -0,0 +1,30 @@ +# untildify [![Build Status](https://travis-ci.org/sindresorhus/untildify.svg?branch=master)](https://travis-ci.org/sindresorhus/untildify) + +> Convert a tilde path to an absolute path: `~/dev` => `/Users/sindresorhus/dev` + + +## Install + +``` +$ npm install --save untildify +``` + + +## Usage + +```js +var untildify = require('untildify'); + +untildify('~/dev'); +//=> '/Users/sindresorhus/dev' +``` + + +## Related + +See [tildify](https://github.com/sindresorhus/tildify) for the inverse. + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/tools/node_modules/user-home/index.js b/tools/node_modules/user-home/index.js new file mode 100644 index 00000000000000..fdff72164c7603 --- /dev/null +++ b/tools/node_modules/user-home/index.js @@ -0,0 +1,2 @@ +'use strict'; +module.exports = require('os-homedir')(); diff --git a/tools/node_modules/user-home/license b/tools/node_modules/user-home/license new file mode 100644 index 00000000000000..654d0bfe943437 --- /dev/null +++ b/tools/node_modules/user-home/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tools/node_modules/user-home/package.json b/tools/node_modules/user-home/package.json new file mode 100644 index 00000000000000..3c8ca396c449b3 --- /dev/null +++ b/tools/node_modules/user-home/package.json @@ -0,0 +1,97 @@ +{ + "_args": [ + [ + "user-home@^2.0.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\remark" + ] + ], + "_from": "user-home@>=2.0.0 <3.0.0", + "_id": "user-home@2.0.0", + "_inCache": true, + "_location": "/user-home", + "_nodeVersion": "0.12.4", + "_npmUser": { + "email": "sindresorhus@gmail.com", + "name": "sindresorhus" + }, + "_npmVersion": "2.10.1", + "_phantomChildren": {}, + "_requested": { + "name": "user-home", + "raw": "user-home@^2.0.0", + "rawSpec": "^2.0.0", + "scope": null, + "spec": ">=2.0.0 <3.0.0", + "type": "range" + }, + "_requiredBy": [ + "/remark" + ], + "_resolved": "https://registry.npmjs.org/user-home/-/user-home-2.0.0.tgz", + "_shasum": "9c70bfd8169bc1dcbf48604e0f04b8b49cde9e9f", + "_shrinkwrap": null, + "_spec": "user-home@^2.0.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\remark", + "author": { + "email": "sindresorhus@gmail.com", + "name": "Sindre Sorhus", + "url": "sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/sindresorhus/user-home/issues" + }, + "dependencies": { + "os-homedir": "^1.0.0" + }, + "description": "Get the path to the user home directory", + "devDependencies": { + "ava": "0.0.4", + "path-exists": "^1.0.0" + }, + "directories": {}, + "dist": { + "shasum": "9c70bfd8169bc1dcbf48604e0f04b8b49cde9e9f", + "tarball": "http://registry.npmjs.org/user-home/-/user-home-2.0.0.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "23e6d1e2dd553b599c787348f82bd2463225cc80", + "homepage": "https://github.com/sindresorhus/user-home", + "installable": true, + "keywords": [ + "dir", + "directory", + "env", + "environment", + "folder", + "home", + "homedir", + "os-homedir", + "path", + "user", + "userprofile", + "variables", + "vars" + ], + "license": "MIT", + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + } + ], + "name": "user-home", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "https://github.com/sindresorhus/user-home" + }, + "scripts": { + "test": "node test.js" + }, + "version": "2.0.0" +} diff --git a/tools/node_modules/user-home/readme.md b/tools/node_modules/user-home/readme.md new file mode 100644 index 00000000000000..944188c779a27b --- /dev/null +++ b/tools/node_modules/user-home/readme.md @@ -0,0 +1,33 @@ +# user-home [![Build Status](https://travis-ci.org/sindresorhus/user-home.svg?branch=master)](https://travis-ci.org/sindresorhus/user-home) + +> Get the path to the user home directory + + +## Install + +``` +$ npm install --save user-home +``` + + +## Usage + +```js +var userHome = require('user-home'); + +console.log(userHome); +//=> '/Users/sindresorhus' +``` + +Returns `null` in the unlikely scenario that the home directory can't be found. + + +## Related + +- [user-home-cli](https://github.com/sindresorhus/user-home-cli) - CLI for this module +- [home-or-tmp](https://github.com/sindresorhus/home-or-tmp) - Get the user home directory with fallback to the system temp directory + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/tools/node_modules/util-deprecate/History.md b/tools/node_modules/util-deprecate/History.md new file mode 100644 index 00000000000000..acc8675372e980 --- /dev/null +++ b/tools/node_modules/util-deprecate/History.md @@ -0,0 +1,16 @@ + +1.0.2 / 2015-10-07 +================== + + * use try/catch when checking `localStorage` (#3, @kumavis) + +1.0.1 / 2014-11-25 +================== + + * browser: use `console.warn()` for deprecation calls + * browser: more jsdocs + +1.0.0 / 2014-04-30 +================== + + * initial commit diff --git a/tools/node_modules/util-deprecate/LICENSE b/tools/node_modules/util-deprecate/LICENSE new file mode 100644 index 00000000000000..6a60e8c225c9ba --- /dev/null +++ b/tools/node_modules/util-deprecate/LICENSE @@ -0,0 +1,24 @@ +(The MIT License) + +Copyright (c) 2014 Nathan Rajlich + +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. diff --git a/tools/node_modules/util-deprecate/README.md b/tools/node_modules/util-deprecate/README.md new file mode 100644 index 00000000000000..75622fa7c250a6 --- /dev/null +++ b/tools/node_modules/util-deprecate/README.md @@ -0,0 +1,53 @@ +util-deprecate +============== +### The Node.js `util.deprecate()` function with browser support + +In Node.js, this module simply re-exports the `util.deprecate()` function. + +In the web browser (i.e. via browserify), a browser-specific implementation +of the `util.deprecate()` function is used. + + +## API + +A `deprecate()` function is the only thing exposed by this module. + +``` javascript +// setup: +exports.foo = deprecate(foo, 'foo() is deprecated, use bar() instead'); + + +// users see: +foo(); +// foo() is deprecated, use bar() instead +foo(); +foo(); +``` + + +## License + +(The MIT License) + +Copyright (c) 2014 Nathan Rajlich + +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. diff --git a/tools/node_modules/util-deprecate/browser.js b/tools/node_modules/util-deprecate/browser.js new file mode 100644 index 00000000000000..549ae2f065ea5a --- /dev/null +++ b/tools/node_modules/util-deprecate/browser.js @@ -0,0 +1,67 @@ + +/** + * Module exports. + */ + +module.exports = deprecate; + +/** + * Mark that a method should not be used. + * Returns a modified function which warns once by default. + * + * If `localStorage.noDeprecation = true` is set, then it is a no-op. + * + * If `localStorage.throwDeprecation = true` is set, then deprecated functions + * will throw an Error when invoked. + * + * If `localStorage.traceDeprecation = true` is set, then deprecated functions + * will invoke `console.trace()` instead of `console.error()`. + * + * @param {Function} fn - the function to deprecate + * @param {String} msg - the string to print to the console when `fn` is invoked + * @returns {Function} a new "deprecated" version of `fn` + * @api public + */ + +function deprecate (fn, msg) { + if (config('noDeprecation')) { + return fn; + } + + var warned = false; + function deprecated() { + if (!warned) { + if (config('throwDeprecation')) { + throw new Error(msg); + } else if (config('traceDeprecation')) { + console.trace(msg); + } else { + console.warn(msg); + } + warned = true; + } + return fn.apply(this, arguments); + } + + return deprecated; +} + +/** + * Checks `localStorage` for boolean values for the given `name`. + * + * @param {String} name + * @returns {Boolean} + * @api private + */ + +function config (name) { + // accessing global.localStorage can trigger a DOMException in sandboxed iframes + try { + if (!global.localStorage) return false; + } catch (_) { + return false; + } + var val = global.localStorage[name]; + if (null == val) return false; + return String(val).toLowerCase() === 'true'; +} diff --git a/tools/node_modules/util-deprecate/node.js b/tools/node_modules/util-deprecate/node.js new file mode 100644 index 00000000000000..5e6fcff5ddd3fb --- /dev/null +++ b/tools/node_modules/util-deprecate/node.js @@ -0,0 +1,6 @@ + +/** + * For Node.js, simply re-export the core `util.deprecate` function. + */ + +module.exports = require('util').deprecate; diff --git a/tools/node_modules/util-deprecate/package.json b/tools/node_modules/util-deprecate/package.json new file mode 100644 index 00000000000000..0bf47a9c97d13b --- /dev/null +++ b/tools/node_modules/util-deprecate/package.json @@ -0,0 +1,80 @@ +{ + "_args": [ + [ + "util-deprecate@~1.0.1", + "C:\\wamp\\www\\node\\tools\\node_modules\\readable-stream" + ] + ], + "_from": "util-deprecate@>=1.0.1 <1.1.0", + "_id": "util-deprecate@1.0.2", + "_inCache": true, + "_location": "/util-deprecate", + "_nodeVersion": "4.1.2", + "_npmUser": { + "email": "nathan@tootallnate.net", + "name": "tootallnate" + }, + "_npmVersion": "2.14.4", + "_phantomChildren": {}, + "_requested": { + "name": "util-deprecate", + "raw": "util-deprecate@~1.0.1", + "rawSpec": "~1.0.1", + "scope": null, + "spec": ">=1.0.1 <1.1.0", + "type": "range" + }, + "_requiredBy": [ + "/readable-stream" + ], + "_resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "_shasum": "450d4dc9fa70de732762fbd2d4a28981419a0ccf", + "_shrinkwrap": null, + "_spec": "util-deprecate@~1.0.1", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\readable-stream", + "author": { + "email": "nathan@tootallnate.net", + "name": "Nathan Rajlich", + "url": "http://n8.io/" + }, + "browser": "browser.js", + "bugs": { + "url": "https://github.com/TooTallNate/util-deprecate/issues" + }, + "dependencies": {}, + "description": "The Node.js `util.deprecate()` function with browser support", + "devDependencies": {}, + "directories": {}, + "dist": { + "shasum": "450d4dc9fa70de732762fbd2d4a28981419a0ccf", + "tarball": "http://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz" + }, + "gitHead": "475fb6857cd23fafff20c1be846c1350abf8e6d4", + "homepage": "https://github.com/TooTallNate/util-deprecate", + "installable": true, + "keywords": [ + "browser", + "browserify", + "deprecate", + "node", + "util" + ], + "license": "MIT", + "main": "node.js", + "maintainers": [ + { + "name": "tootallnate", + "email": "nathan@tootallnate.net" + } + ], + "name": "util-deprecate", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git://github.com/TooTallNate/util-deprecate.git" + }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "version": "1.0.2" +} diff --git a/tools/node_modules/vfile-find-down/LICENSE b/tools/node_modules/vfile-find-down/LICENSE new file mode 100644 index 00000000000000..32e7a3d93ca5a2 --- /dev/null +++ b/tools/node_modules/vfile-find-down/LICENSE @@ -0,0 +1,22 @@ +(The MIT License) + +Copyright (c) 2015 Titus Wormer + +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. diff --git a/tools/node_modules/vfile-find-down/history.md b/tools/node_modules/vfile-find-down/history.md new file mode 100644 index 00000000000000..be669a3554c489 --- /dev/null +++ b/tools/node_modules/vfile-find-down/history.md @@ -0,0 +1,6 @@ + + + + +1.0.0 / 2015-11-18 +================== diff --git a/tools/node_modules/vfile-find-down/index.js b/tools/node_modules/vfile-find-down/index.js new file mode 100644 index 00000000000000..3ea1ea5f1c558f --- /dev/null +++ b/tools/node_modules/vfile-find-down/index.js @@ -0,0 +1,332 @@ +/** + * @author Titus Wormer + * @copyright 2015 Titus Wormer + * @license MIT + * @module vfile:find-down + * @version 1.0.0 + * @fileoverview Find one or more files by searching the + * file system downwards. + */ + +'use strict'; + +/* eslint-env node */ + +/* + * Dependencies. + */ + +var fs = require('fs'); +var path = require('path'); +var toVFile = require('to-vfile'); + +/* + * Methods. + */ + +var readdir = fs.readdir; +var stat = fs.stat; +var resolve = path.resolve; +var join = path.join; +var has = Object.prototype.hasOwnProperty; + +/* + * Constants. + */ + +var NODE_MODULES = 'node_modules' +var EMPTY = ''; +var DOT = '.'; +var INCLUDE = 1; +var SKIP = 4; +var BREAK = 8; + +/** + * Check a mask. + * + * @param {number} value - Config. + * @param {number} bitmask - Mask. + * @return {boolean} - Whether `mask` matches `config`. + */ +function mask(value, bitmask) { + return (value & bitmask) === bitmask; +} + +/** + * Wrap a string given as a test. + * + * A normal string checks for equality to both the filename + * and extension. A string starting with a `.` checks for + * that equality too, and also to just the extension. + * + * @param {string} filePath - File-name and file-extension + * joined by a `.`, or file-extension. + * @return {Function} + */ +function filePathFactory(filePath) { + var isExtensionLike = filePath.charAt(0) === DOT; + var extension = isExtensionLike && filePath.slice(1); + + /** + * Check whether the given `file` matches the bound + * value. + * + * @param {VFile} file - Virtual file. + * @return {boolean} - Whether or not there is a match. + */ + return function (file) { + var filename = file.filename; + var parts = [filename]; + + if (file.extension) { + parts.push(file.extension); + } + + if ( + filePath === parts.join(DOT) || + (isExtensionLike && extension === file.extension) + ) { + return true; + } + + if ( + filename.charAt(0) === DOT || + filename === NODE_MODULES + ) { + return SKIP; + } + } +} + +/** + * Augment `test` from several supported values to a + * function returning a boolean. + * + * @param {string|Function|Array.} test + * - Augmented test. + * @return {Function} - test + */ +function augment(test) { + var index; + var length; + var tests; + + if (typeof test === 'string') { + return filePathFactory(test); + } + + if (typeof test === 'function') { + return test; + } + + length = test.length; + index = -1; + tests = []; + + while (++index < length) { + tests[index] = augment(test[index]); + } + + return function (file) { + var result; + + index = -1; + + while (++index < length) { + result = tests[index](file); + + if (result) { + return result; + } + } + + return false; + } +} + +/** + * Find files in `filePath`. + * + * @example + * new FindDown({ + * 'extensions': ['md'] + * }).visit('~/foo/bar', console.log); + * + * @param {Object} state - Information. + * @param {string} filePath - Path to file or directory. + * @param {boolean?} one - Whether to search for one or + * more files. + * @param {Function} done - Invoked with a list of zero or + * more files. + */ +function visit(state, filePath, one, done) { + var file; + + /* + * Prevent walking into places multiple times. + */ + + if (has.call(state.checked, filePath)) { + done([]); + return; + } + + state.checked[filePath] = true; + + file = toVFile(filePath); + file.quiet = true; + + stat(resolve(filePath), function (err, stats) { + var real = Boolean(stats); + var results = []; + var result; + + if (state.broken || !real) { + done([]); + } else { + result = state.test(file); + + if (mask(result, INCLUDE)) { + results.push(file); + + if (one) { + state.broken = true; + return done(results); + } + } + + if (mask(result, BREAK)) { + state.broken = true; + } + + if (state.broken || !stats.isDirectory() || mask(result, SKIP)) { + return done(results); + } + + readdir(filePath, function (err, entries) { + visitAll(state, entries, filePath, one, function (files) { + done(results.concat(files)); + }); + }); + } + }); +} + +/** + * Find files in `paths`. Returns a list of + * applicable files. + * + * @example + * visitAll('.md', ['bar'], '~/foo', false, console.log); + * + * @param {Object} state - Information. + * @param {Array.} paths - Path to files and + * directories. + * @param {string?} directory - Path to parent directory, + * if any. + * @param {boolean?} one - Whether to search for one or + * more files. + * @param {Function} done - Invoked with a list of zero or + * more applicable files. + */ +function visitAll(state, paths, directory, one, done) { + var result = []; + var length = paths.length; + var count = -1; + + /** Invoke `done` when complete */ + function next() { + count++; + + if (count === length) { + done(result); + } + } + + paths.forEach(function (filePath) { + visit(state, join(directory || EMPTY, filePath), one, function (files) { + result = result.concat(files); + next(); + }); + }); + + next(); +} + +/** + * Find applicable files. + * + * @example + * find('.md', '~', console.log); + * + * @param {*} test - One or more tests. + * @param {string|Array.} paths - Directories + * to search. + * @param {Function} callback - Invoked with one or more + * files. + * @param {boolean?} one - Whether to search for one or + * more files. + */ +function find(test, paths, callback, one) { + var state = { + 'broken': false, + 'checked': [], + 'test': augment(test) + }; + + if (!callback) { + callback = paths; + paths = [process.cwd()]; + } else if (typeof paths === 'string') { + paths = [paths]; + } + + return visitAll(state, paths, null, one, function (result) { + callback(null, one ? result[0] || null : result); + }); +} + +/** + * Find a file or a directory downwards. + * + * @example + * one('package.json', console.log); + * + * @param {Function} test - Filter function. + * @param {(Array.|string)?} [paths] + * - Directories to search. + * @param {Function} callback - Invoked with a result. + */ +function one(test, paths, callback) { + return find(test, paths, callback, true); +} + +/** + * Find files or directories upwards. + * + * @example + * all('package.json', console.log); + * + * @param {Function} test - Filter function. + * @param {(Array.|string)?} [paths] + * - Directories to search. + * @param {Function} callback - Invoked with results. + */ +function all(test, paths, callback) { + return find(test, paths, callback); +} + +/* + * Expose. + */ + +var findDown = {}; + +findDown.INCLUDE = INCLUDE; +findDown.SKIP = SKIP; +findDown.BREAK = BREAK; + +findDown.all = all; +findDown.one = one; + +module.exports = findDown; diff --git a/tools/node_modules/vfile-find-down/package.json b/tools/node_modules/vfile-find-down/package.json new file mode 100644 index 00000000000000..98bdd3ff223a53 --- /dev/null +++ b/tools/node_modules/vfile-find-down/package.json @@ -0,0 +1,106 @@ +{ + "_args": [ + [ + "vfile-find-down@^1.0.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\remark" + ] + ], + "_from": "vfile-find-down@>=1.0.0 <2.0.0", + "_id": "vfile-find-down@1.0.0", + "_inCache": true, + "_location": "/vfile-find-down", + "_nodeVersion": "5.0.0", + "_npmUser": { + "email": "tituswormer@gmail.com", + "name": "wooorm" + }, + "_npmVersion": "3.3.6", + "_phantomChildren": {}, + "_requested": { + "name": "vfile-find-down", + "raw": "vfile-find-down@^1.0.0", + "rawSpec": "^1.0.0", + "scope": null, + "spec": ">=1.0.0 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/remark" + ], + "_resolved": "https://registry.npmjs.org/vfile-find-down/-/vfile-find-down-1.0.0.tgz", + "_shasum": "84a4d66d03513f6140a84e0776ef0848d4f0ad95", + "_shrinkwrap": null, + "_spec": "vfile-find-down@^1.0.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\remark", + "author": { + "email": "tituswormer@gmail.com", + "name": "Titus Wormer" + }, + "bugs": { + "url": "https://github.com/wooorm/vfile-find-down/issues" + }, + "dependencies": { + "to-vfile": "^1.0.0" + }, + "description": "Find one or more files by searching the file system downwards", + "devDependencies": { + "eslint": "^1.0.0", + "esmangle": "^1.0.0", + "istanbul": "^0.4.0", + "jscs": "^2.0.0", + "jscs-jsdoc": "^1.0.0", + "mdast": "^2.0.0", + "mdast-comment-config": "^1.0.0", + "mdast-github": "^1.0.0", + "mdast-lint": "^1.0.0", + "mdast-slug": "^2.0.0", + "mdast-validate-links": "^1.1.1", + "tape": "^4.2.0" + }, + "directories": {}, + "dist": { + "shasum": "84a4d66d03513f6140a84e0776ef0848d4f0ad95", + "tarball": "http://registry.npmjs.org/vfile-find-down/-/vfile-find-down-1.0.0.tgz" + }, + "files": [ + "index.js" + ], + "gitHead": "814dd210cff202661d3b7c1c0d15f209c2f4fe45", + "homepage": "https://github.com/wooorm/vfile-find-down#readme", + "installable": true, + "keywords": [ + "above", + "down", + "downward", + "downwards", + "find", + "mdast", + "retext", + "vfile", + "walk" + ], + "license": "MIT", + "maintainers": [ + { + "name": "wooorm", + "email": "tituswormer@gmail.com" + } + ], + "name": "vfile-find-down", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git+https://github.com/wooorm/vfile-find-down.git" + }, + "scripts": { + "build": "npm run build-md", + "build-md": "mdast . --quiet --frail", + "lint": "npm run lint-api && npm run lint-style", + "lint-api": "eslint .", + "lint-style": "jscs --reporter inline .", + "test": "npm run build && npm run lint && npm run test-coverage", + "test-api": "node test/index.js", + "test-coverage": "istanbul cover test/index.js" + }, + "version": "1.0.0" +} diff --git a/tools/node_modules/vfile-find-down/readme.md b/tools/node_modules/vfile-find-down/readme.md new file mode 100644 index 00000000000000..b8b338836fdc0f --- /dev/null +++ b/tools/node_modules/vfile-find-down/readme.md @@ -0,0 +1,217 @@ +# vfile-find-down [![Build Status](https://img.shields.io/travis/wooorm/vfile-find-down.svg)](https://travis-ci.org/wooorm/vfile-find-down) [![Coverage Status](https://img.shields.io/codecov/c/github/wooorm/vfile-find-down.svg)](https://codecov.io/github/wooorm/vfile-find-down) + +Find one or more files (exposed as [VFile](https://github.com/wooorm/vfile)s) +by searching the file system downwards. + +## Installation + +[npm](https://docs.npmjs.com/cli/install): + +```bash +npm install vfile-find-down +``` + +## Usage + +Require dependencies: + +```js +var findDown = require('vfile-find-down'); +``` + +Search for files with a `.md` extension from the current working directory +downwards: + +```js +findDown.all('.md', console.log); +/* null [ VFile { + * contents: '', + * messages: [], + * history: [ '/Users/foo/bar/baz/example.md' ], + * directory: '/Users/foo/bar/baz', + * filename: 'example', + * extension: 'md' }, + * VFile { + * contents: '', + * messages: [], + * directory: '/Users/foo/bar/baz', + * filename: 'readme', + * extension: 'md' } ] + */ +``` + +Search for the first file: + +```js +findDown.one('.md', console.log); +/* null VFile { + * contents: '', + * messages: [], + * directory: '/Users/foo/bar/baz', + * filename: 'example', + * extension: 'md' } + */ +``` + +## API + +### findDown.one(test\[, paths\], [callback](#function-callbackerr-file)) + +Find a file or a directory downwards. + +**Example** + +```js +findDown.one('readme.md', console.log); +/* null VFile { + * contents: '', + * messages: [], + * history: [ '/Users/foo/bar/baz/readme.md' ], + * directory: '/Users/foo/bar/baz', + * filename: 'readme', + * extension: 'md' } + */ +``` + +**Signatures** + +* `findDown.one(filePath[, paths], callback)`; +* `findDown.one(extension[, paths], callback)`; +* `findDown.one(test[, paths], callback)`; +* `findDown.one(tests[, paths], callback)`. + +**Parameters** + +* `filePath` (`string`) + — Filename (including extension) to search for; + +* `extension` (`string`) + — File extension to search for (must start with a `.`); + +* `test` ([`Function`](#function-testfile)) + — Function invoked to check whether a virtual file should be included; + +* `tests` (`Array.`) + — List of tests, any of which should match a given file for it to + be included. + +* `paths` (`Array.` or `string`, optional, default: `process.cwd()`) + — Place(s) to start searching from; + +* `callback` ([`Function`](#function-callbackerr-file)); + — Function invoked when a matching file or the top of the volume + is reached. + +**Notes** + +* Virtual Files are not read (their `content` is not populated). + +#### function callback(err, file) + +Invoked when a matching file or the top of the volume is reached. + +**Parameters** + +* `err` (`Error`, optional); +* `file` ([`VFile`](https://github.com/wooorm/vfile), optional). + +**Notes** + +* The `err` parameter is never populated. + +### findDown.all(test\[, paths\], [callback](#function-callbackerr-files)) + +Find files or directories downwards. + +**Example** + +```js +findDown.all('.md', console.log); +/* null [ VFile { + * contents: '', + * messages: [], + * directory: '/Users/foo/bar/baz', + * filename: 'example', + * extension: 'md' }, + * VFile { + * contents: '', + * messages: [], + * directory: '/Users/foo', + * filename: 'readme', + * extension: 'md' } ] + */ +``` + +**Signatures** + +* `findDown.all(filePath[, paths], callback)`; +* `findDown.all(extension[, paths], callback)`; +* `findDown.all(test[, paths], callback)`; +* `findDown.all(tests[, paths], callback)`. + +**Parameters** + +* `filePath` (`string`) + — Filename (including extension) to search for; + +* `extension` (`string`) + — File extension to search for (must start with a `.`); + +* `test` ([`Function`](#function-testfile)) + — Function invoked to check whether a virtual file should be included; + +* `tests` (`Array.`) + — List of tests, any of which should match a given file for it to + be included. + +* `paths` (`Array.` or `string`, optional, default: `process.cwd()`) + — Place(s) to start searching from; + +* `callback` ([`Function`](#function-callbackerr-files)); + — Function invoked when matching files or the top of the volume + is reached. + +**Notes** + +* Virtual Files are not read (their `content` is not populated). + +#### function callback(err, files) + +Invoked when files or the top of the volume is reached. + +**Parameters** + +* `err` (`Error`, optional); +* `files` ([`Array.`](https://github.com/wooorm/vfile), optional). + +**Notes** + +* The `err` parameter is never populated. + +### function test(file) + +Check whether a virtual file should be included. + +**Parameters** + +* `file` ([`VFile`](https://github.com/wooorm/vfile)). + +**Returns**: `boolean`, when truthy, the file is included. + +### findDown.INCLUDE + +Flag used as an alternative to returning `true` from +[`test`](#function-testfile), ensuring the tested file +is included and passed to `callback`. + +### findDown.SKIP + +Flag used to skip searching a directory from [`test`](#function-testfile). + +### findDown.EXIT + +Flag used to stop searching for files from [`test`](#function-testfile). + +## License + +[MIT](LICENSE) © [Titus Wormer](http://wooorm.com) diff --git a/tools/node_modules/vfile-find-up/LICENSE b/tools/node_modules/vfile-find-up/LICENSE new file mode 100644 index 00000000000000..32e7a3d93ca5a2 --- /dev/null +++ b/tools/node_modules/vfile-find-up/LICENSE @@ -0,0 +1,22 @@ +(The MIT License) + +Copyright (c) 2015 Titus Wormer + +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. diff --git a/tools/node_modules/vfile-find-up/history.md b/tools/node_modules/vfile-find-up/history.md new file mode 100644 index 00000000000000..40be23ee3d1bcd --- /dev/null +++ b/tools/node_modules/vfile-find-up/history.md @@ -0,0 +1,6 @@ + + + + +1.0.0 / 2015-11-09 +================== diff --git a/tools/node_modules/vfile-find-up/index.js b/tools/node_modules/vfile-find-up/index.js new file mode 100644 index 00000000000000..d559e346f65121 --- /dev/null +++ b/tools/node_modules/vfile-find-up/index.js @@ -0,0 +1,258 @@ +/** + * @author Titus Wormer + * @copyright 2015 Titus Wormer + * @license MIT + * @module vfile:find-up + * @version 0.0.0 + * @fileoverview Find one or more files by searching the + * file system upwards. + */ + +'use strict'; + +/* eslint-env node */ + +/* + * Dependencies. + */ + +var fs = require('fs'); +var path = require('path'); +var toVFile = require('to-vfile'); + +/* + * Methods. + */ + +var readdir = fs.readdir; +var resolve = path.resolve; +var dirname = path.dirname; +var basename = path.basename; + +/* + * Constants. + */ + +var DOT = '.'; +var INCLUDE = 1; +var BREAK = 4; + +/** + * Check a mask. + * + * @param {number} value - Config. + * @param {number} bitmask - Mask. + * @return {boolean} - Whether `mask` matches `config`. + */ +function mask(value, bitmask) { + return (value & bitmask) === bitmask; +} + +/** + * Wrap a string given as a test. + * + * A normal string checks for equality to both the filename + * and extension. A string starting with a `.` checks for + * that equality too, and also to just the extension. + * + * @param {string} filePath - File-name and file-extension + * joined by a `.`, or file-extension. + * @return {Function} + */ +function filePathFactory(filePath) { + var isExtensionLike = filePath.charAt(0) === DOT; + var extension = isExtensionLike && filePath.slice(1); + + /** + * Check whether the given `file` matches the bound + * value. + * + * @param {VFile} file - Virtual file. + * @return {boolean} - Whether or not there is a match. + */ + return function (file) { + var name = file.filename + (file.extension ? DOT + file.extension : ''); + + return filePath === name || + (isExtensionLike && extension === file.extension); + } +} + +/** + * Augment `test` from several supported values to a + * function returning a boolean. + * + * @param {string|Function|Array.} test + * - Augmented test. + * @return {Function} - test + */ +function augment(test) { + var index; + var length; + var tests; + + if (typeof test === 'string') { + return filePathFactory(test); + } + + if (typeof test === 'function') { + return test; + } + + length = test.length; + index = -1; + tests = []; + + while (++index < length) { + tests[index] = augment(test[index]); + } + + return function (file) { + index = -1; + + while (++index < length) { + if (tests[index](file)) { + return true; + } + } + + return false; + } +} + +/** + * Find files and directories upwards. + * + * @example + * find('package.json', '.', console.log); + * + * @private + * @param {Function} test - Filter function. + * @param {string?} directory - Path to directory to search. + * @param {Function} callback - Invoked with results. + * @param {boolean?} [one] - When `true`, returns the + * first result (`string`), otherwise, returns an array + * of strings. + */ +function find(test, directory, callback, one) { + var results = []; + var currentDirectory; + + test = augment(test); + + if (!callback) { + callback = directory; + directory = null; + } + + currentDirectory = directory ? resolve(directory) : process.cwd(); + + /** + * Test a file-path and check what should be done with + * the resulting file. + * Returns true when iteration should stop. + * + * @param {string} filePath - Path to file. + * @return {boolean} - `true` when `callback` is + * invoked and iteration should stop. + */ + function handle(filePath) { + var file = toVFile(filePath); + var result = test(file); + + if (mask(result, INCLUDE)) { + if (one) { + callback(null, file); + return true; + } + + results.push(file); + } + + if (mask(result, BREAK)) { + callback(null, one ? null : results); + return true; + } + } + + /** TODO */ + function once(childDirectory) { + if (handle(currentDirectory) === true) { + return; + } + + readdir(currentDirectory, function (err, entries) { + var length = entries ? entries.length : 0; + var index = -1; + var entry; + + if (err) { + entries = []; + } + + while (++index < length) { + entry = entries[index]; + + if (entry !== childDirectory) { + if (handle(resolve(currentDirectory, entry)) === true) { + return; + } + } + } + + childDirectory = currentDirectory; + currentDirectory = dirname(currentDirectory); + + if (currentDirectory === childDirectory) { + callback(null, one ? null : results); + return; + } + + once(basename(childDirectory)); + }); + } + + once(); +} + +/** + * Find a file or a directory upwards. + * + * @example + * findOne('package.json', console.log); + * + * @param {Function} test - Filter function. + * @param {string?} [directory] - Path to directory to search. + * @param {Function} callback - Invoked with a result. + */ +function findOne(test, directory, callback) { + return find(test, directory, callback, true); +} + +/** + * Find files or directories upwards. + * + * @example + * findAll('package.json', console.log); + * + * @param {Function} test - Filter function. + * @param {string?} [directory] - Path to directory to search. + * @param {Function} callback - Invoked with results. + */ +function findAll(test, directory, callback) { + return find(test, directory, callback); +} + +/* + * Expose. + */ + +var findUp = {}; + +findUp.INCLUDE = INCLUDE; +findUp.BREAK = BREAK; + +findUp.one = findOne; +findUp.all = findAll; + +module.exports = findUp; diff --git a/tools/node_modules/vfile-find-up/package.json b/tools/node_modules/vfile-find-up/package.json new file mode 100644 index 00000000000000..d124c9c723529c --- /dev/null +++ b/tools/node_modules/vfile-find-up/package.json @@ -0,0 +1,106 @@ +{ + "_args": [ + [ + "vfile-find-up@^1.0.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\remark" + ] + ], + "_from": "vfile-find-up@>=1.0.0 <2.0.0", + "_id": "vfile-find-up@1.0.0", + "_inCache": true, + "_location": "/vfile-find-up", + "_nodeVersion": "4.1.1", + "_npmUser": { + "email": "tituswormer@gmail.com", + "name": "wooorm" + }, + "_npmVersion": "3.3.5", + "_phantomChildren": {}, + "_requested": { + "name": "vfile-find-up", + "raw": "vfile-find-up@^1.0.0", + "rawSpec": "^1.0.0", + "scope": null, + "spec": ">=1.0.0 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/remark" + ], + "_resolved": "https://registry.npmjs.org/vfile-find-up/-/vfile-find-up-1.0.0.tgz", + "_shasum": "5604da6fe453b34350637984eb5fe4909e280390", + "_shrinkwrap": null, + "_spec": "vfile-find-up@^1.0.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\remark", + "author": { + "email": "tituswormer@gmail.com", + "name": "Titus Wormer" + }, + "bugs": { + "url": "https://github.com/wooorm/vfile-find-up/issues" + }, + "dependencies": { + "to-vfile": "^1.0.0" + }, + "description": "Find one or more files by searching the file system upwards", + "devDependencies": { + "eslint": "^1.0.0", + "esmangle": "^1.0.0", + "istanbul": "^0.3.0", + "jscs": "^2.0.0", + "jscs-jsdoc": "^1.0.0", + "mdast": "^1.0.0", + "mdast-comment-config": "^1.0.0", + "mdast-github": "^1.0.0", + "mdast-lint": "^1.0.0", + "mdast-slug": "^2.0.0", + "mdast-validate-links": "^1.1.1", + "tape": "^4.2.0" + }, + "directories": {}, + "dist": { + "shasum": "5604da6fe453b34350637984eb5fe4909e280390", + "tarball": "http://registry.npmjs.org/vfile-find-up/-/vfile-find-up-1.0.0.tgz" + }, + "files": [ + "index.js" + ], + "gitHead": "a16e2a53ad25c9c00ce43e8343a56f460f620387", + "homepage": "https://github.com/wooorm/vfile-find-up#readme", + "installable": true, + "keywords": [ + "above", + "find", + "mdast", + "retext", + "up", + "upward", + "upwards", + "vfile", + "walk" + ], + "license": "MIT", + "maintainers": [ + { + "name": "wooorm", + "email": "tituswormer@gmail.com" + } + ], + "name": "vfile-find-up", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git+https://github.com/wooorm/vfile-find-up.git" + }, + "scripts": { + "build": "npm run build-md", + "build-md": "mdast . --quiet --frail", + "lint": "npm run lint-api && npm run lint-style", + "lint-api": "eslint .", + "lint-style": "jscs --reporter inline .", + "test": "npm run build && npm run lint && npm run test-coverage", + "test-api": "node test/index.js", + "test-coverage": "istanbul cover test/index.js" + }, + "version": "1.0.0" +} diff --git a/tools/node_modules/vfile-find-up/readme.md b/tools/node_modules/vfile-find-up/readme.md new file mode 100644 index 00000000000000..d58a51de4948fa --- /dev/null +++ b/tools/node_modules/vfile-find-up/readme.md @@ -0,0 +1,220 @@ +# vfile-find-up [![Build Status](https://img.shields.io/travis/wooorm/vfile-find-up.svg)](https://travis-ci.org/wooorm/vfile-find-up) [![Coverage Status](https://img.shields.io/codecov/c/github/wooorm/vfile-find-up.svg)](https://codecov.io/github/wooorm/vfile-find-up) + +Find one or more files (exposed as [VFile](https://github.com/wooorm/vfile)s) +by searching the file system upwards. + +## Installation + +[npm](https://docs.npmjs.com/cli/install): + +```bash +npm install vfile-find-up +``` + +## Usage + +Require dependencies: + +```js +var findUp = require('vfile-find-up'); +``` + +Search for files named `package.json` from the current working directory +upwards: + +```js +findUp.all('package.json', console.log); +/* null [ VFile { + * contents: '', + * messages: [], + * history: [ '/Users/foo/bar/baz/package.json' ], + * directory: '/Users/foo/bar/baz', + * filename: 'package', + * extension: 'json' }, + * VFile { + * contents: '', + * messages: [], + * history: [ '/Users/foo/package.json' ], + * directory: '/Users/foo', + * filename: 'package', + * extension: 'json' } ] + */ +``` + +Search for the first file: + +```js +findUp.one('package.json', console.log); +/* null VFile { + * contents: '', + * messages: [], + * history: [ '/Users/foo/bar/baz/package.json' ], + * directory: '/Users/foo/bar/baz', + * filename: 'package', + * extension: 'json' } + */ +``` + +### findUp.one(test\[, directory\], [callback](#function-callbackerr-file)) + +Find a file or a directory upwards. + +**Example** + +```js +findUp.one('package.json', console.log); +/* null VFile { + * contents: '', + * messages: [], + * history: [ '/Users/foo/bar/baz/package.json' ], + * directory: '/Users/foo/bar/baz', + * filename: 'package', + * extension: 'json' } + */ +``` + +**Signatures** + +* `findUp.one(filePath[, directory], callback)`; +* `findUp.one(extension[, directory], callback)`; +* `findUp.one(test[, directory], callback)`; +* `findUp.one(tests[, directory], callback)`. + +**Parameters** + +* `filePath` (`string`) + — Filename (including extension) to search for; + +* `extension` (`string`) + — File extension to search for (must start with a `.`); + +* `test` ([`Function`](#function-testfile)) + — Function invoked to check whether a virtual file should be included; + +* `tests` (`Array.`) + — List of tests, any of which should match a given file for it to + be included. + +* `directory` (`string`, optional, default: `process.cwd()`) + — Place to start searching from; + +* `callback` ([`Function`](#function-callbackerr-file)); + — Function invoked when a matching file or the top of the volume + is reached. + +**Notes** + +* Virtual Files are not read (their `content` is not populated). + +#### function callback(err, file) + +Invoked when a matching file or the top of the volume is reached. + +**Parameters** + +* `err` (`Error`, optional); +* `file` ([`VFile`](https://github.com/wooorm/vfile), optional). + +**Notes** + +* The `err` parameter is never populated. + +### findUp.all(test\[, directory\], [callback](#function-callbackerr-files)) + +Find files or directories upwards. + +**Example** + +```js +findUp.all('package.json', console.log); +/* null [ VFile { + * contents: '', + * messages: [], + * history: [ '/Users/foo/bar/baz/package.json' ], + * directory: '/Users/foo/bar/baz', + * filename: 'package', + * extension: 'json' }, + * VFile { + * contents: '', + * messages: [], + * history: [ '/Users/foo/package.json' ], + * directory: '/Users/foo', + * filename: 'package', + * extension: 'json' } ] + */ +``` + +**Signatures** + +* `findUp.all(filePath[, directory], callback)`; +* `findUp.all(extension[, directory], callback)`; +* `findUp.all(test[, directory], callback)`; +* `findUp.all(tests[, directory], callback)`. + +**Parameters** + +* `filePath` (`string`) + — Filename (including extension) to search for; + +* `extension` (`string`) + — File extension to search for (must start with a `.`); + +* `test` ([`Function`](#function-testfile)) + — Function invoked to check whether a virtual file should be included; + +* `tests` (`Array.`) + — List of tests, any of which should match a given file for it to + be included. + +* `directory` (`string`, optional, default: `process.cwd()`) + — Place to start searching from; + +* `callback` ([`Function`](#function-callbackerr-files)); + — Function invoked when matching files or the top of the volume + is reached. + +**Notes** + +* Virtual Files are not read (their `content` is not populated). + +#### function callback(err, files) + +Invoked when files or the top of the volume is reached. + +**Parameters** + +* `err` (`Error`, optional); +* `files` ([`Array.`](https://github.com/wooorm/vfile), optional). + +**Notes** + +* The `err` parameter is never populated. + +### function test(file) + +Check whether a virtual file should be included. + +**Parameters** + +* `file` ([`VFile`](https://github.com/wooorm/vfile)). + +**Returns**: + +* `boolean` — When truthy, the file is included; + +* `number` — Bitmask ([`findUp.INCLUDE`](#findupinclude) and + [`findUp.EXIT`](#findupexit)) to control searching behavior. + +### findUp.INCLUDE + +Flag used as an alternative to returning `true` from +[`test`](#function-testfile), ensuring the tested file +is included and passed to `callback`. + +### findUp.EXIT + +Flag used to stop searching for files returned to [`test`](#function-testfile). + +## License + +[MIT](LICENSE) © [Titus Wormer](http://wooorm.com) diff --git a/tools/node_modules/vfile-reporter/LICENSE b/tools/node_modules/vfile-reporter/LICENSE new file mode 100644 index 00000000000000..a324254c8d596b --- /dev/null +++ b/tools/node_modules/vfile-reporter/LICENSE @@ -0,0 +1,23 @@ +(The MIT License) + +Copyright (c) 2015 Titus Wormer +Copyright (c) 2013 Nicholas C. Zakas. All rights reserved. + +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. diff --git a/tools/node_modules/vfile-reporter/history.md b/tools/node_modules/vfile-reporter/history.md new file mode 100644 index 00000000000000..9be7f7676bb272 --- /dev/null +++ b/tools/node_modules/vfile-reporter/history.md @@ -0,0 +1,37 @@ + + + + +1.5.0 / 2015-11-21 +================== + +* Remove initial newline before report ([ac6a778](https://github.com/wooorm/vfile-reporter/commit/ac6a778)) + +1.4.1 / 2015-10-23 +================== + +* Fix for changes in vfile ([32c2460](https://github.com/wooorm/vfile-reporter/commit/32c2460)) + +1.4.0 / 2015-09-12 +================== + +* Add support for `note` properties in `verbose` mode ([41a4910](https://github.com/wooorm/vfile-reporter/commit/41a4910)) + +1.3.0 / 2015-08-21 +================== + +* Add output location when applicable to report ([a5b6369](https://github.com/wooorm/vfile-reporter/commit/a5b6369)) + +1.2.0 / 2015-08-20 +================== + +* Refactor summary to only expose non-zero types ([1148621](https://github.com/wooorm/vfile-reporter/commit/1148621)) + +1.1.0 / 2015-08-19 +================== + +* Remove error count, warning count when `0` ([7927078](https://github.com/wooorm/vfile-reporter/commit/7927078)) +* Rename `screen-shot.png` > `screenshot.png` ([f1bb7de](https://github.com/wooorm/vfile-reporter/commit/f1bb7de)) + +1.0.0 / 2015-08-17 +================== diff --git a/tools/node_modules/vfile-reporter/index.js b/tools/node_modules/vfile-reporter/index.js new file mode 100644 index 00000000000000..556b662e41966f --- /dev/null +++ b/tools/node_modules/vfile-reporter/index.js @@ -0,0 +1,287 @@ +/** + * @author Titus Wormer + * @author Sindre Sorhus + * @copyright 2015 Titus Wormer + * @copyright 2013 Nicholas C. Zakas + * @license MIT + * @module vfile:reporter + * @fileoverview Stylish reporter for virtual files. + */ + +'use strict'; + +/* + * Dependencies. + */ + +var pluralize = require('plur'); +var width = require('string-width'); +var symbols = require('log-symbols'); +var chalk = require('chalk'); +var table = require('text-table'); +var repeat = require('repeat-string'); +var sort = require('vfile-sort'); + +/* + * Map of no-warning messages, where `true` refers to + * `compile: true`. + */ + +var SUCCESS = { + 'true': chalk.yellow('written'), + 'false': 'no issues found' +}; + +/* + * List of probabbly lengths of messages. + */ + +var POSITION_LENGTH = '00:0-00:0'.length; +var LABEL_LENGTH = 'message'.length; +var MESSAGE_LENGTH = 'this is an average message'.length; + +/** + * Reject messages without `fatal: true`. + * + * NOTE: Modifies the given files. + * + * @param {Array.} files - List of files. + */ +function removeNonFatalMessages(files) { + files.forEach(function (file) { + file.messages = file.messages.filter(function (message) { + return message.fatal === true; + }) + }); +} + +/** + * Reject files without messages. + * + * @param {Array.} files - List of files. + * @return {Array.} - `files` without non-failed messages. + */ +function removeNonFailedFiles(files) { + return files.filter(function (file) { + return Boolean(file.messages.length); + }); +} + +/** + * Get the length of `value`, ignoring ANSI sequences. + * + * @param {string} value - Value to `pad`. + * @return {number} - Length of `value`. + */ +function realLength(value) { + var index = value.indexOf('\n'); + + if (index !== -1) { + value = value.slice(0, index); + } + + return width(value); +} + +/** + * Pad `value` on the `side` (where truthy means left and + * falsey means right). + * + * @param {string} value - Value to `pad`. + * @param {number} minimum - Pad to `minimum`. + * @param {boolean?} [side] - Side to pad on. + * @return {string} - Right-padded `value`. + */ +function pad(value, minimum, side) { + var padding = repeat(' ', minimum - realLength(value)); + return side ? padding + value : value + padding; +} + +/** + * Pad `value` on the left. + * + * @param {string} value - Value to `pad`. + * @param {number} minimum - Pad to `minimum`. + * @return {string} - Left-padded `value`. + */ +function padLeft(value, minimum) { + return pad(value, minimum, true); +} + +/** + * Pad `value` on the right. + * + * @param {string} value - Value to `pad`. + * @param {number} minimum - Pad to `minimum`. + * @return {string} - Right-padded `value`. + */ +function padRight(value, minimum) { + return pad(value, minimum, false); +} + +/** + * @param {VFile|Array.} files - One or more virtual + * files. + * @param {Object} [options] - Configuration. + * @param {Object} [options.quiet=false] - Do not output + * anything for a file which has no messages. The default + * behaviour is to show a success message. + * @param {Object} [options.silent=false] - Do not output + * messages without `fatal` set to true. Also sets + * `quiet` to `true`. + * @param {Object} [options.verbose=false] - Output notes. + * @return {string} - Formatted files. + */ +function reporter(files, options) { + var total = 0; + var errors = 0; + var warnings = 0; + var result = []; + var listing = false; + var summaryColor; + var summary; + var verbose; + + if (!files) { + return ''; + } + + if (!('length' in files)) { + files = [files]; + } + + if (!options) { + options = {}; + } + + verbose = options.verbose || false; + + if (options.silent) { + removeNonFatalMessages(files); + } + + if (options.silent || options.quiet) { + files = removeNonFailedFiles(files); + } + + files.forEach(function (file, position) { + var destination = file.filePath(); + var filePath = file.history[0] || destination; + var stored = Boolean(file.stored); + var moved = stored && destination !== filePath; + var name = filePath || ''; + var output = ''; + var messages; + var fileColor; + + sort(file); + + messages = file.messages; + + total += messages.length; + + messages = messages.map(function (message) { + var color = 'yellow'; + var location = message.name; + var label; + var reason; + + if (filePath) { + location = location.slice(location.indexOf(':') + 1); + } + + if (message.fatal) { + color = fileColor = summaryColor = 'red'; + label = 'error'; + errors++; + } else if (message.fatal === false) { + label = 'warning'; + warnings++; + + if (!summaryColor) { + summaryColor = color; + } + + if (!fileColor) { + fileColor = color; + } + } else { + label = 'message'; + color = 'gray'; + } + + reason = message.stack || message.message; + + if (verbose && message.note) { + reason += '\n' + message.note; + } + + return [ + '', + padLeft(location, POSITION_LENGTH), + padRight(chalk[color](label), LABEL_LENGTH), + padRight(reason, MESSAGE_LENGTH), + message.ruleId || '' + ]; + }); + + if (listing || (messages.length && position !== 0)) { + output += '\n'; + } + + output += chalk.underline[fileColor || 'green'](name); + + if (moved) { + output += ' > ' + destination; + } + + listing = Boolean(messages.length); + + if (!listing) { + output += ': ' + SUCCESS[stored]; + } else { + output += '\n' + table(messages, { + 'align': ['', 'l', 'l', 'l'], + 'stringLength': realLength + }); + } + + result.push(output); + }); + + if (errors || warnings) { + summary = []; + + if (errors) { + summary.push([ + symbols.error, + errors, + pluralize('error', errors) + ].join(' ')); + } + + if (warnings) { + summary.push([ + symbols.warning, + warnings, + pluralize('warning', warnings) + ].join(' ')); + } + + summary = summary.join(', '); + + if (errors && warnings) { + summary = total + ' messages (' + summary + ')'; + } + + result.push('\n' + summary); + } + + return result.length ? result.join('\n') : ''; +} + +/* + * Expose. + */ + +module.exports = reporter; diff --git a/tools/node_modules/vfile-reporter/package.json b/tools/node_modules/vfile-reporter/package.json new file mode 100644 index 00000000000000..0ca0213010e773 --- /dev/null +++ b/tools/node_modules/vfile-reporter/package.json @@ -0,0 +1,116 @@ +{ + "_args": [ + [ + "vfile-reporter@^1.5.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\remark" + ] + ], + "_from": "vfile-reporter@>=1.5.0 <2.0.0", + "_id": "vfile-reporter@1.5.0", + "_inCache": true, + "_location": "/vfile-reporter", + "_nodeVersion": "5.1.0", + "_npmUser": { + "email": "tituswormer@gmail.com", + "name": "wooorm" + }, + "_npmVersion": "3.5.0", + "_phantomChildren": {}, + "_requested": { + "name": "vfile-reporter", + "raw": "vfile-reporter@^1.5.0", + "rawSpec": "^1.5.0", + "scope": null, + "spec": ">=1.5.0 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/remark" + ], + "_resolved": "https://registry.npmjs.org/vfile-reporter/-/vfile-reporter-1.5.0.tgz", + "_shasum": "21a7009bfe55e24df8ff432aa5bf6f6efa74e418", + "_shrinkwrap": null, + "_spec": "vfile-reporter@^1.5.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\remark", + "author": { + "email": "tituswormer@gmail.com", + "name": "Titus Wormer" + }, + "bugs": { + "url": "https://github.com/wooorm/vfile-reporter/issues" + }, + "dependencies": { + "chalk": "^1.1.0", + "log-symbols": "^1.0.2", + "plur": "^2.0.0", + "repeat-string": "^1.5.0", + "string-width": "^1.0.0", + "text-table": "^0.2.0", + "vfile-sort": "^1.0.0" + }, + "description": "Stylish reporter for virtual files", + "devDependencies": { + "eslint": "^1.0.0", + "esmangle": "^1.0.0", + "istanbul": "^0.3.0", + "jscs": "^2.0.0", + "jscs-jsdoc": "^1.0.0", + "mdast": "^1.0.0", + "mdast-comment-config": "^1.0.0", + "mdast-github": "^1.0.0", + "mdast-lint": "^1.0.0", + "mocha": "^2.0.0", + "to-vfile": "^1.0.0", + "vfile": "^1.0.0" + }, + "directories": {}, + "dist": { + "shasum": "21a7009bfe55e24df8ff432aa5bf6f6efa74e418", + "tarball": "http://registry.npmjs.org/vfile-reporter/-/vfile-reporter-1.5.0.tgz" + }, + "files": [ + "index.js" + ], + "gitHead": "19b36c939e697c37caecda6b05826f32e02e90dd", + "homepage": "https://github.com/wooorm/vfile-reporter#readme", + "installable": true, + "keywords": [ + "error", + "format", + "formatter", + "lint", + "mdast", + "message", + "reporter", + "retext", + "validate", + "vfile", + "warning" + ], + "license": "MIT", + "maintainers": [ + { + "name": "wooorm", + "email": "tituswormer@gmail.com" + } + ], + "name": "vfile-reporter", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git+https://github.com/wooorm/vfile-reporter.git" + }, + "scripts": { + "build": "npm run build-md", + "build-md": "mdast . --quiet", + "lint": "npm run lint-api && npm run lint-style", + "lint-api": "eslint .", + "lint-style": "jscs --reporter inline .", + "make": "npm run lint && npm run test-coverage", + "test": "npm run test-api", + "test-api": "mocha --check-leaks test.js", + "test-coverage": "istanbul cover _mocha -- test.js", + "test-travis": "npm run test-coverage" + }, + "version": "1.5.0" +} diff --git a/tools/node_modules/vfile-reporter/readme.md b/tools/node_modules/vfile-reporter/readme.md new file mode 100644 index 00000000000000..7ecc92a6ba3e93 --- /dev/null +++ b/tools/node_modules/vfile-reporter/readme.md @@ -0,0 +1,95 @@ +# vfile-reporter [![Build Status](https://img.shields.io/travis/wooorm/vfile-reporter.svg)](https://travis-ci.org/wooorm/vfile-reporter) [![Coverage Status](https://img.shields.io/codecov/c/github/wooorm/vfile-reporter.svg)](https://codecov.io/github/wooorm/vfile-reporter) + +Format [**VFile**](https://github.com/wooorm/vfile)s using a stylish reporter. + +Originally forked from ESLint’s stylish reporter, but with some coolness +added. + +![Example screen shot of **vfile-reporter**](./screenshot.png) + +## Features + +* [x] Ranges + — Not just a starting position, such as `3:2`, but `3:2-3:6`. + +* [x] Stack-traces + — When something awful happens, you want to know **where** it occurred, + stack-traces help answer that question. + +* [x] Successful files (configurable) + — Sometimes you want to know if things went okay. + +* [x] And all of [**VFile**](https://github.com/wooorm/vfile)s awesomeness. + +## Installation + +[npm](https://docs.npmjs.com/cli/install): + +```bash +npm install vfile-report +``` + +## Usage + +```js +var toVFile = require('to-vfile'); +var reporter = require('vfile-reporter'); + +var one = toVFile('test/fixture/1.js'); +var two = toVFile('test/fixture/2.js'); + +/* + * See VFile’s docs for more info on how to warn. + */ + +one.warn('Warning!', { + 'line': 2, + 'column': 4 +}); + +console.log(reporter([one, two])); +``` + +Yields: + +```text +test/fixture/1.js + 2:4 warning Warning! + +test/fixture/2.js: no issues found + +⚠ 1 warning +``` + +## API + +### reporter(vfiles\[, options\]) + +Generate a stylish report from the given files. + +**Signatures** + +* `report = reporter(file[, options])` +* `report = reporter(files[, options])` + +**Parameters** + +* `options` (`Object`, optional) + + * `quiet` (`boolean`, default: `false`) + — Do not output anything for a file which has no warnings or errors. + The default behaviour is to show a success message. + + * `silent` (`boolean`, default: `false`) + — Do not output messages without `fatal` set to true. + Also sets `quiet` to `true`. + +**Returns**: `string`, a stylish report. + +## License + +[MIT](LICENSE) © [Titus Wormer](http://wooorm.com) + +Forked from [ESLint](https://github.com/eslint/eslint)’s stylish reporter +(originally created by Sindre Sorhus), which is Copyright (c) 2013 +Nicholas C. Zakas, and licensed under MIT. diff --git a/tools/node_modules/vfile-sort/LICENSE b/tools/node_modules/vfile-sort/LICENSE new file mode 100644 index 00000000000000..32e7a3d93ca5a2 --- /dev/null +++ b/tools/node_modules/vfile-sort/LICENSE @@ -0,0 +1,22 @@ +(The MIT License) + +Copyright (c) 2015 Titus Wormer + +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. diff --git a/tools/node_modules/vfile-sort/history.md b/tools/node_modules/vfile-sort/history.md new file mode 100644 index 00000000000000..4a4fdaa8c3f50f --- /dev/null +++ b/tools/node_modules/vfile-sort/history.md @@ -0,0 +1,15 @@ +--- +mdast: + setext: true +--- + + + +1.0.0 / 2015-08-16 +================== + +* Rename to vfile-sort ([c4b9e7d](https://github.com/wooorm/vfile-sort/commit/c4b9e7d)) +* Update dependencies, dev-dependencies ([899f521](https://github.com/wooorm/vfile-sort/commit/899f521)) + +0.1.0 / 2015-07-04 +================== diff --git a/tools/node_modules/vfile-sort/index.js b/tools/node_modules/vfile-sort/index.js new file mode 100644 index 00000000000000..2624e146305339 --- /dev/null +++ b/tools/node_modules/vfile-sort/index.js @@ -0,0 +1,49 @@ +/** + * @author Titus Wormer + * @copyright 2015 Titus Wormer + * @license MIT + * @module vfile:sort + * @fileoverview Sort VFile messages by line/column. + */ + +'use strict'; + +/** + * Compare a single property. + * + * @param {VFileMessage} a - Original. + * @param {VFileMessage} b - Comparison. + * @param {string} property - Property to compare. + * @return {number} + */ +function check(a, b, property) { + return (a[property] || 0) - (b[property] || 0); +} + +/** + * Comparator. + * + * @param {VFileMessage} a - Original. + * @param {VFileMessage} b - Comparison. + * @return {number} + */ +function comparator(a, b) { + return check(a, b, 'line') || check(a, b, 'column') || -1; +} + +/** + * Sort all `file`s messages by line/column. + * + * @param {VFile} file - Virtual file. + * @return {VFile} - `file`. + */ +function sort(file) { + file.messages.sort(comparator); + return file; +} + +/* + * Expose. + */ + +module.exports = sort; diff --git a/tools/node_modules/vfile-sort/package.json b/tools/node_modules/vfile-sort/package.json new file mode 100644 index 00000000000000..c1f4502bd8385a --- /dev/null +++ b/tools/node_modules/vfile-sort/package.json @@ -0,0 +1,107 @@ +{ + "_args": [ + [ + "vfile-sort@^1.0.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\vfile-reporter" + ] + ], + "_from": "vfile-sort@>=1.0.0 <2.0.0", + "_id": "vfile-sort@1.0.0", + "_inCache": true, + "_location": "/vfile-sort", + "_nodeVersion": "2.5.0", + "_npmUser": { + "email": "tituswormer@gmail.com", + "name": "wooorm" + }, + "_npmVersion": "2.13.2", + "_phantomChildren": {}, + "_requested": { + "name": "vfile-sort", + "raw": "vfile-sort@^1.0.0", + "rawSpec": "^1.0.0", + "scope": null, + "spec": ">=1.0.0 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/vfile-reporter" + ], + "_resolved": "https://registry.npmjs.org/vfile-sort/-/vfile-sort-1.0.0.tgz", + "_shasum": "17ee491ba43e8951bb22913fcff32a7dc4d234d4", + "_shrinkwrap": null, + "_spec": "vfile-sort@^1.0.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\vfile-reporter", + "author": { + "email": "tituswormer@gmail.com", + "name": "Titus Wormer" + }, + "bugs": { + "url": "https://github.com/wooorm/vfile-sort/issues" + }, + "dependencies": {}, + "description": "Sort VFile messages by line/column", + "devDependencies": { + "browserify": "^11.0.0", + "eslint": "^1.0.0", + "esmangle": "^1.0.0", + "istanbul": "^0.3.0", + "jscs": "^2.0.0", + "jscs-jsdoc": "^1.0.0", + "mdast": "^1.0.0", + "mdast-github": "^0.3.0", + "mdast-lint": "^0.4.0", + "mdast-yaml-config": "^1.0.0", + "mocha": "^2.0.0", + "vfile": "^1.0.0" + }, + "directories": {}, + "dist": { + "shasum": "17ee491ba43e8951bb22913fcff32a7dc4d234d4", + "tarball": "http://registry.npmjs.org/vfile-sort/-/vfile-sort-1.0.0.tgz" + }, + "files": [ + "index.js" + ], + "gitHead": "4b4f1530f87e1c3c3298697699765ac1808f2215", + "homepage": "https://github.com/wooorm/vfile-sort#readme", + "installable": true, + "keywords": [ + "error", + "mdast", + "message", + "node", + "retext", + "sort", + "vfile", + "warning" + ], + "license": "MIT", + "maintainers": [ + { + "name": "wooorm", + "email": "tituswormer@gmail.com" + } + ], + "name": "vfile-sort", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git+https://github.com/wooorm/vfile-sort.git" + }, + "scripts": { + "build": "npm run bundle && npm run build-md", + "build-md": "mdast . --quiet", + "bundle": "browserify index.js --no-builtins -s vfileSort > vfile-sort.js", + "lint": "npm run lint-api && npm run lint-style", + "lint-api": "eslint .", + "lint-style": "jscs --reporter inline .", + "make": "npm run lint && npm run test-coverage", + "postbundle": "esmangle vfile-sort.js > vfile-sort.min.js", + "test": "npm run test-api", + "test-api": "mocha --check-leaks test.js", + "test-coverage": "istanbul cover _mocha -- test.js", + "test-travis": "npm run test-coverage" + }, + "version": "1.0.0" +} diff --git a/tools/node_modules/vfile-sort/readme.md b/tools/node_modules/vfile-sort/readme.md new file mode 100644 index 00000000000000..9c1eeed050fb39 --- /dev/null +++ b/tools/node_modules/vfile-sort/readme.md @@ -0,0 +1,57 @@ +# vfile-sort [![Build Status](https://img.shields.io/travis/wooorm/vfile-sort.svg)](https://travis-ci.org/wooorm/vfile-sort) [![Coverage Status](https://img.shields.io/codecov/c/github/wooorm/vfile-sort.svg)](https://codecov.io/github/wooorm/vfile-sort) + +Sorts [`VFile`](https://github.com/wooorm/vfile) [`messages`](https://github.com/wooorm/vfile#vfilemessages). + +## Installation + +[npm](https://docs.npmjs.com/cli/install): + +```bash +npm install vfile-sort +``` + +**vfile-sort** is also available for [bower](http://bower.io/#install-packages), +[component](https://github.com/componentjs/component), and +[duo](http://duojs.org/#getting-started), and as an AMD, CommonJS, and globals +module, [uncompressed](vfile-sort.js) and +[compressed](vfile-sort.min.js). + +## Usage + +```js +var vfile = require('vfile'); +var sort = require('vfile-sort'); + +var file = vfile(); + +file.warn('Error!', { + 'line': 3, + 'column': 1 +}); + +file.warn('Another!', { + 'line': 2, + 'column': 2 +}); + +sort(file); + +console.log(file.messages.map(String)); +/* + * [ + * '2:2: Another!', + * '3:1: Error!' + * ] + */ +``` + +## API + +### sort(vfile) + +Sorts [`messages`](https://github.com/wooorm/vfile#vfilemessages) in the given +[`VFile`](https://github.com/wooorm/vfile). + +## License + +[MIT](LICENSE) © [Titus Wormer](http://wooorm.com) diff --git a/tools/node_modules/vfile/LICENSE b/tools/node_modules/vfile/LICENSE new file mode 100644 index 00000000000000..f3722d94b38121 --- /dev/null +++ b/tools/node_modules/vfile/LICENSE @@ -0,0 +1,21 @@ +(The MIT License) + +Copyright (c) 2015 Titus Wormer + +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. diff --git a/tools/node_modules/vfile/history.md b/tools/node_modules/vfile/history.md new file mode 100644 index 00000000000000..5024343dd46d09 --- /dev/null +++ b/tools/node_modules/vfile/history.md @@ -0,0 +1,51 @@ + + + + +1.3.1 / 2016-01-21 +================== + +1.3.0 / 2016-01-21 +================== + +* Refactor API signatures in `readme.md` ([`d41883c`](https://github.com/wooorm/vfile/commit/d41883c)) +* Add npm deployment to Travis ([`0d236c0`](https://github.com/wooorm/vfile/commit/0d236c0)) +* Update metadata in `package.json` ([`9726eec`](https://github.com/wooorm/vfile/commit/9726eec)) +* Refactor to replace mocha with tape ([`05d29df`](https://github.com/wooorm/vfile/commit/05d29df)) +* Update dev-dependencies ([`6255dd9`](https://github.com/wooorm/vfile/commit/6255dd9)) +* Add new `basename` method ([`07b79af`](https://github.com/wooorm/vfile/commit/07b79af)) + +1.2.0 / 2015-12-27 +================== + +* Update list of related tools ([`69e576f`](https://github.com/wooorm/vfile/commit/69e576f)) +* Remove distribution files from source ([`b45c780`](https://github.com/wooorm/vfile/commit/b45c780)) +* Remove support for bower ([`849c3ad`](https://github.com/wooorm/vfile/commit/849c3ad)) +* Rename mdast to remark ([`b3c8cea`](https://github.com/wooorm/vfile/commit/b3c8cea)) + +1.1.2 / 2015-10-16 +================== + +* Fix missing `Error` properties on `VFileMessage` ([`c896cf9`](https://github.com/wooorm/vfile/commit/c896cf9)) + +1.1.1 / 2015-10-14 +================== + +* Fix Safari 9 ([`bcb7a61`](https://github.com/wooorm/vfile/commit/bcb7a61)) +* Add `convert-vinyl-to-vfile` to related tools ([`1423652`](https://github.com/wooorm/vfile/commit/1423652)) + +1.1.0 / 2015-08-21 +================== + +* Add extensive location information to messages ([`848aef7`](https://github.com/wooorm/vfile/commit/848aef7)) +* Add history tracking ([`67d0112`](https://github.com/wooorm/vfile/commit/67d0112)) + +1.0.1 / 2015-08-17 +================== + +* Add list of related tools to `readme.md` ([`863df04`](https://github.com/wooorm/vfile/commit/863df04)) +* Update dependencies ([`5184aec`](https://github.com/wooorm/vfile/commit/5184aec)) +* Update documentation with difference from vinyl ([`76e1d39`](https://github.com/wooorm/vfile/commit/76e1d39)) + +1.0.0 / 2015-07-26 +================== diff --git a/tools/node_modules/vfile/index.js b/tools/node_modules/vfile/index.js new file mode 100644 index 00000000000000..3ab44289ddc0bc --- /dev/null +++ b/tools/node_modules/vfile/index.js @@ -0,0 +1,624 @@ +/** + * @author Titus Wormer + * @copyright 2015 Titus Wormer + * @license MIT + * @module vfile + * @fileoverview Virtual file format to attach additional + * information related to processed input. Similar to + * `wearefractal/vinyl`. Additionally, `VFile` can be + * passed directly to ESLint formatters to visualise + * warnings and errors relating to a file. + * @example + * var VFile = require('vfile'); + * + * var file = new VFile({ + * 'directory': '~', + * 'filename': 'example', + * 'extension': 'txt', + * 'contents': 'Foo *bar* baz' + * }); + * + * file.toString(); // 'Foo *bar* baz' + * file.filePath(); // '~/example.txt' + * + * file.move({'extension': 'md'}); + * file.filePath(); // '~/example.md' + * + * file.warn('Something went wrong', {'line': 2, 'column': 3}); + * // { [~/example.md:2:3: Something went wrong] + * // name: '~/example.md:2:3', + * // file: '~/example.md', + * // reason: 'Something went wrong', + * // line: 2, + * // column: 3, + * // fatal: false } + */ + +'use strict'; + +/* eslint-env commonjs */ + +var SEPARATOR = '/'; + +try { + SEPARATOR = require('pa' + 'th').sep; +} catch (e) { /* empty */ } + +/** + * Construct a new file message. + * + * Note: We cannot invoke `Error` on the created context, + * as that adds readonly `line` and `column` attributes on + * Safari 9, thus throwing and failing the data. + * + * @example + * var message = new VFileMessage('Whoops!'); + * + * message instanceof Error // true + * + * @constructor + * @class {VFileMessage} + * @param {string} reason - Reason for messaging. + * @property {boolean} [fatal=null] - Whether the message + * is fatal. + * @property {string} [name=''] - File-name and positional + * information. + * @property {string} [file=''] - File-path. + * @property {string} [reason=''] - Reason for messaging. + * @property {number} [line=null] - Start of message. + * @property {number} [column=null] - Start of message. + * @property {Position|Location} [location=null] - Place of + * message. + * @property {string} [stack] - Stack-trace of warning. + */ +function VFileMessage(reason) { + this.message = reason; +} + +/** + * Inherit from `Error#`. + */ +function VFileMessagePrototype() {} + +VFileMessagePrototype.prototype = Error.prototype; + +var proto = new VFileMessagePrototype(); + +VFileMessage.prototype = proto; + +/* + * Expose defaults. + */ + +proto.file = proto.name = proto.reason = proto.message = proto.stack = ''; +proto.fatal = proto.column = proto.line = null; + +/** + * File-related message with location information. + * + * @typedef {Error} VFileMessage + * @property {string} name - (Starting) location of the + * message, preceded by its file-path when available, + * and joined by `:`. Used internally by the native + * `Error#toString()`. + * @property {string} file - File-path. + * @property {string} reason - Reason for message. + * @property {number?} line - Line of message, when + * available. + * @property {number?} column - Column of message, when + * available. + * @property {string?} stack - Stack of message, when + * available. + * @property {boolean?} fatal - Whether the associated file + * is still processable. + */ + +/** + * Stringify a position. + * + * @example + * stringify({'line': 1, 'column': 3}) // '1:3' + * stringify({'line': 1}) // '1:1' + * stringify({'column': 3}) // '1:3' + * stringify() // '1:1' + * + * @private + * @param {Object?} [position] - Single position, like + * those available at `node.position.start`. + * @return {string} - Compiled location. + */ +function stringify(position) { + if (!position) { + position = {}; + } + + return (position.line || 1) + ':' + (position.column || 1); +} + +/** + * ESLint's formatter API expects `filePath` to be a + * string. This hack supports invocation as well as + * implicit coercion. + * + * @example + * var file = new VFile({ + * 'filename': 'example', + * 'extension': 'txt' + * }); + * + * filePath = filePathFactory(file); + * + * String(filePath); // 'example.txt' + * filePath(); // 'example.txt' + * + * @private + * @param {VFile} file - Virtual file. + * @return {Function} - `filePath` getter. + */ +function filePathFactory(file) { + /** + * Get the filename, with extension and directory, if applicable. + * + * @example + * var file = new VFile({ + * 'directory': '~', + * 'filename': 'example', + * 'extension': 'txt' + * }); + * + * String(file.filePath); // ~/example.txt + * file.filePath() // ~/example.txt + * + * @memberof {VFile} + * @property {Function} toString - Itself. ESLint's + * formatter API expects `filePath` to be `string`. + * This hack supports invocation as well as implicit + * coercion. + * @return {string} - If the `vFile` has a `filename`, + * it will be prefixed with the directory (slashed), + * if applicable, and suffixed with the (dotted) + * extension (if applicable). Otherwise, an empty + * string is returned. + */ + function filePath() { + var directory = file.directory; + var separator; + + if (file.filename || file.extension) { + separator = directory.charAt(directory.length - 1); + + if (separator === '/' || separator === '\\') { + directory = directory.slice(0, -1); + } + + if (directory === '.') { + directory = ''; + } + + return (directory ? directory + SEPARATOR : '') + + file.filename + + (file.extension ? '.' + file.extension : ''); + } + + return ''; + } + + filePath.toString = filePath; + + return filePath; +} + +/** +* Get the filename with extantion. +* +* @example +* var file = new VFile({ +* 'directory': '~/foo/bar' +* 'filename': 'example', +* 'extension': 'txt' +* }); +* +* file.basename() // example.txt +* +* @memberof {VFile} +* @return {string} - name of file with extantion. +*/ +function basename() { + var self = this; + var extension = self.extension; + + if (self.filename || extension) { + return self.filename + (extension ? '.' + extension : ''); + } + + return ''; +} + +/** + * Construct a new file. + * + * @example + * var file = new VFile({ + * 'directory': '~', + * 'filename': 'example', + * 'extension': 'txt', + * 'contents': 'Foo *bar* baz' + * }); + * + * file === VFile(file) // true + * file === new VFile(file) // true + * VFile('foo') instanceof VFile // true + * + * @constructor + * @class {VFile} + * @param {Object|VFile|string} [options] - either an + * options object, or the value of `contents` (both + * optional). When a `file` is passed in, it's + * immediately returned. + * @property {string} [contents=''] - Content of file. + * @property {string} [directory=''] - Path to parent + * directory. + * @property {string} [filename=''] - Filename. + * A file-path can still be generated when no filename + * exists. + * @property {string} [extension=''] - Extension. + * A file-path can still be generated when no extension + * exists. + * @property {boolean?} quiet - Whether an error created by + * `VFile#fail()` is returned (when truthy) or thrown + * (when falsey). Ensure all `messages` associated with + * a file are handled properly when setting this to + * `true`. + * @property {Array.} messages - List of associated + * messages. + */ +function VFile(options) { + var self = this; + + /* + * No `new` operator. + */ + + if (!(self instanceof VFile)) { + return new VFile(options); + } + + /* + * Given file. + */ + + if ( + options && + typeof options.message === 'function' && + typeof options.hasFailed === 'function' + ) { + return options; + } + + if (!options) { + options = {}; + } else if (typeof options === 'string') { + options = { + 'contents': options + }; + } + + self.contents = options.contents || ''; + + self.messages = []; + + /* + * Make sure eslint’s formatters stringify `filePath` + * properly. + */ + + self.filePath = filePathFactory(self); + + self.history = []; + + self.move({ + 'filename': options.filename, + 'directory': options.directory, + 'extension': options.extension + }); +} + +/** + * Get the value of the file. + * + * @example + * var vFile = new VFile('Foo'); + * String(vFile); // 'Foo' + * + * @this {VFile} + * @memberof {VFile} + * @return {string} - value at the `contents` property + * in context. + */ +function toString() { + return this.contents; +} + +/** + * Move a file by passing a new directory, filename, + * and extension. When these are not given, the default + * values are kept. + * + * @example + * var file = new VFile({ + * 'directory': '~', + * 'filename': 'example', + * 'extension': 'txt', + * 'contents': 'Foo *bar* baz' + * }); + * + * file.move({'directory': '/var/www'}); + * file.filePath(); // '/var/www/example.txt' + * + * file.move({'extension': 'md'}); + * file.filePath(); // '/var/www/example.md' + * + * @this {VFile} + * @memberof {VFile} + * @param {Object?} [options] - Configuration. + * @return {VFile} - Context object. + */ +function move(options) { + var self = this; + var before = self.filePath(); + var after; + + if (!options) { + options = {}; + } + + self.directory = options.directory || self.directory || ''; + self.filename = options.filename || self.filename || ''; + self.extension = options.extension || self.extension || ''; + + after = self.filePath(); + + if (after && before !== after) { + self.history.push(after); + } + + return self; +} + +/** + * Create a message with `reason` at `position`. + * When an error is passed in as `reason`, copies the + * stack. This does not add a message to `messages`. + * + * @example + * var file = new VFile(); + * + * file.message('Something went wrong'); + * // { [1:1: Something went wrong] + * // name: '1:1', + * // file: '', + * // reason: 'Something went wrong', + * // line: null, + * // column: null } + * + * @this {VFile} + * @memberof {VFile} + * @param {string|Error} reason - Reason for message. + * @param {Node|Location|Position} [position] - Location + * of message in file. + * @return {VFileMessage} - File-related message with + * location information. + */ +function message(reason, position) { + var filePath = this.filePath(); + var range; + var err; + var location = { + 'start': { + 'line': null, + 'column': null + }, + 'end': { + 'line': null, + 'column': null + } + }; + + /* + * Node / location / position. + */ + + if (position && position.position) { + position = position.position; + } + + if (position && position.start) { + range = stringify(position.start) + '-' + stringify(position.end); + location = position; + position = position.start; + } else { + range = stringify(position); + + if (position) { + location.start = position; + location.end.line = null; + location.end.column = null; + } + } + + err = new VFileMessage(reason.message || reason); + + err.name = (filePath ? filePath + ':' : '') + range; + err.file = filePath; + err.reason = reason.message || reason; + err.line = position ? position.line : null; + err.column = position ? position.column : null; + err.location = location; + + if (reason.stack) { + err.stack = reason.stack; + } + + return err; +} + +/** + * Warn. Creates a non-fatal message (see `VFile#message()`), + * and adds it to the file's `messages` list. + * + * @example + * var file = new VFile(); + * + * file.warn('Something went wrong'); + * // { [1:1: Something went wrong] + * // name: '1:1', + * // file: '', + * // reason: 'Something went wrong', + * // line: null, + * // column: null, + * // fatal: false } + * + * @see VFile#message + * @this {VFile} + * @memberof {VFile} + */ +function warn() { + var err = this.message.apply(this, arguments); + + err.fatal = false; + + this.messages.push(err); + + return err; +} + +/** + * Fail. Creates a fatal message (see `VFile#message()`), + * sets `fatal: true`, adds it to the file's + * `messages` list. + * + * If `quiet` is not `true`, throws the error. + * + * @example + * var file = new VFile(); + * + * file.fail('Something went wrong'); + * // 1:1: Something went wrong + * // at VFile.exception (vfile/index.js:296:11) + * // at VFile.fail (vfile/index.js:360:20) + * // at repl:1:6 + * + * file.quiet = true; + * file.fail('Something went wrong'); + * // { [1:1: Something went wrong] + * // name: '1:1', + * // file: '', + * // reason: 'Something went wrong', + * // line: null, + * // column: null, + * // fatal: true } + * + * @this {VFile} + * @memberof {VFile} + * @throws {VFileMessage} - When not `quiet: true`. + * @param {string|Error} reason - Reason for failure. + * @param {Node|Location|Position} [position] - Place + * of failure in file. + * @return {VFileMessage} - Unless thrown, of course. + */ +function fail(reason, position) { + var err = this.message(reason, position); + + err.fatal = true; + + this.messages.push(err); + + if (!this.quiet) { + throw err; + } + + return err; +} + +/** + * Check if a fatal message occurred making the file no + * longer processable. + * + * @example + * var file = new VFile(); + * file.quiet = true; + * + * file.hasFailed(); // false + * + * file.fail('Something went wrong'); + * file.hasFailed(); // true + * + * @this {VFile} + * @memberof {VFile} + * @return {boolean} - `true` if at least one of file's + * `messages` has a `fatal` property set to `true` + */ +function hasFailed() { + var messages = this.messages; + var index = -1; + var length = messages.length; + + while (++index < length) { + if (messages[index].fatal) { + return true; + } + } + + return false; +} + +/** + * Access metadata. + * + * @example + * var file = new VFile('Foo'); + * + * file.namespace('foo').bar = 'baz'; + * + * console.log(file.namespace('foo').bar) // 'baz'; + * + * @this {VFile} + * @memberof {VFile} + * @param {string} key - Namespace key. + * @return {Object} - Private space. + */ +function namespace(key) { + var self = this; + var space = self.data; + + if (!space) { + space = self.data = {}; + } + + if (!space[key]) { + space[key] = {}; + } + + return space[key]; +} + +/* + * Methods. + */ + +var vFilePrototype = VFile.prototype; + +vFilePrototype.basename = basename; +vFilePrototype.move = move; +vFilePrototype.toString = toString; +vFilePrototype.message = message; +vFilePrototype.warn = warn; +vFilePrototype.fail = fail; +vFilePrototype.hasFailed = hasFailed; +vFilePrototype.namespace = namespace; + +/* + * Expose. + */ + +module.exports = VFile; diff --git a/tools/node_modules/vfile/package.json b/tools/node_modules/vfile/package.json new file mode 100644 index 00000000000000..0a7f33e8d24056 --- /dev/null +++ b/tools/node_modules/vfile/package.json @@ -0,0 +1,111 @@ +{ + "_args": [ + [ + "vfile@^1.1.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\remark" + ] + ], + "_from": "vfile@>=1.1.0 <2.0.0", + "_id": "vfile@1.3.1", + "_inCache": true, + "_location": "/vfile", + "_nodeVersion": "5.1.0", + "_npmUser": { + "email": "tituswormer@gmail.com", + "name": "wooorm" + }, + "_npmVersion": "3.5.0", + "_phantomChildren": {}, + "_requested": { + "name": "vfile", + "raw": "vfile@^1.1.0", + "rawSpec": "^1.1.0", + "scope": null, + "spec": ">=1.1.0 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/remark", + "/to-vfile", + "/unified" + ], + "_resolved": "https://registry.npmjs.org/vfile/-/vfile-1.3.1.tgz", + "_shasum": "7d3fff69a8416292fb021cf2089fff5a71ce3c9a", + "_shrinkwrap": null, + "_spec": "vfile@^1.1.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\remark", + "author": { + "email": "tituswormer@gmail.com", + "name": "Titus Wormer" + }, + "bugs": { + "url": "https://github.com/wooorm/vfile/issues" + }, + "dependencies": {}, + "description": "Virtual file format for text processing", + "devDependencies": { + "browserify": "^13.0.0", + "eslint": "^1.0.0", + "esmangle": "^1.0.0", + "istanbul": "^0.4.0", + "jscs": "^2.0.0", + "jscs-jsdoc": "^1.0.0", + "remark": "^3.0.0", + "remark-comment-config": "^2.0.0", + "remark-github": "^3.0.0", + "remark-lint": "^2.0.0", + "remark-man": "^2.0.0", + "remark-toc": "^2.0.0", + "remark-validate-links": "^2.0.0", + "tape": "^4.4.0" + }, + "directories": {}, + "dist": { + "shasum": "7d3fff69a8416292fb021cf2089fff5a71ce3c9a", + "tarball": "http://registry.npmjs.org/vfile/-/vfile-1.3.1.tgz" + }, + "files": [ + "index.js" + ], + "gitHead": "afbbeb77b69b7b54e062f1efed42433dd766a3d0", + "homepage": "https://github.com/wooorm/vfile#readme", + "installable": true, + "keywords": [ + "error", + "file", + "message", + "processing", + "remark", + "retext", + "text", + "virtual", + "warning" + ], + "license": "MIT", + "maintainers": [ + { + "name": "wooorm", + "email": "tituswormer@gmail.com" + } + ], + "name": "vfile", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git+https://github.com/wooorm/vfile.git" + }, + "scripts": { + "build": "npm run build-md && npm run build-bundle && npm run build-mangle", + "build-bundle": "browserify index.js -s VFile > vfile.js", + "build-mangle": "esmangle vfile.js > vfile.min.js", + "build-md": "remark . --quiet --frail", + "lint": "npm run lint-api && npm run lint-style", + "lint-api": "eslint .", + "lint-style": "jscs --reporter inline .", + "test": "npm run build && npm run lint && npm run test-coverage", + "test-api": "node test.js", + "test-coverage": "istanbul cover test.js", + "test-travis": "npm run test-coverage" + }, + "version": "1.3.1" +} diff --git a/tools/node_modules/vfile/readme.md b/tools/node_modules/vfile/readme.md new file mode 100644 index 00000000000000..5c9cc695f4fcbb --- /dev/null +++ b/tools/node_modules/vfile/readme.md @@ -0,0 +1,525 @@ +# ![vfile](https://cdn.rawgit.com/wooorm/vfile/master/logo.svg) + +[![Build Status](https://img.shields.io/travis/wooorm/vfile.svg)](https://travis-ci.org/wooorm/vfile) [![Coverage Status](https://img.shields.io/codecov/c/github/wooorm/vfile.svg)](https://codecov.io/github/wooorm/vfile) + +**VFile** is a virtual file format used by [**retext**](https://github.com/wooorm/retext) +(natural language) and [**remark**](https://github.com/wooorm/remark) +(markdown). Two processors which parse, transform, and compile text. Both need +a virtual representation of files and a place to store metadata and messages. +And, they work in the browser. **VFile** provides these requirements. + +Also, **VFile** exposes a warning mechanism compatible with [**ESLint**](https://github.com/eslint/eslint)s +formatters, making it easy to expose [stylish](https://github.com/eslint/eslint/blob/master/lib/formatters/stylish.js) +warnings, or export [tap](https://github.com/eslint/eslint/blob/master/lib/formatters/tap.js) +compliant messages. + +> **VFile** is different from (the excellent :+1:) [**vinyl**](https://github.com/wearefractal/vinyl) +> in that it does not include file-system or node-only functionality. No +> buffers, streams, or stats. In addition, the focus on +> [metadata](#vfilenamespacekey) and [messages](#vfilemessagereason-position) +> are useful when processing a file through a +> [middleware](https://github.com/segmentio/ware) pipeline. + +## Installation + +[npm](https://docs.npmjs.com/cli/install): + +```bash +npm install vfile +``` + +**VFile** is also available for [duo](http://duojs.org/#getting-started), +and as an AMD, CommonJS, and globals module, [uncompressed and +compressed](https://github.com/wooorm/vfile/releases). + +## Table of Contents + +* [Usage](#usage) + +* [Related Tools](#related-tools) + +* [API](#api) + + * [VFile()](#vfile) + * [VFile#contents](#vfilecontents) + * [VFile#directory](#vfiledirectory) + * [VFile#filename](#vfilefilename) + * [VFile#extension](#vfileextension) + * [VFile#basename()](#vfilebasename) + * [VFile#quiet](#vfilequiet) + * [VFile#messages](#vfilemessages) + * [VFile#history](#vfilehistory) + * [VFile#toString()](#vfiletostring) + * [VFile#filePath()](#vfilefilepath) + * [VFile#move(options)](#vfilemoveoptions) + * [VFile#namespace(key)](#vfilenamespacekey) + * [VFile#message(reason\[, position\])](#vfilemessagereason-position) + * [VFile#warn(reason\[, position\])](#vfilewarnreason-position) + * [VFile#fail(reason\[, position\])](#vfilefailreason-position) + * [VFile#hasFailed()](#vfilehasfailed) + * [VFileMessage](#vfilemessage) + +* [License](#license) + +## Usage + +```js +var VFile = require('vfile'); + +var file = new VFile({ + 'directory': '~', + 'filename': 'example', + 'extension': 'txt', + 'contents': 'Foo *bar* baz' +}); + +file.toString(); // 'Foo *bar* baz' +file.filePath(); // '~/example.txt' + +file.move({'extension': 'md'}); +file.filePath(); // '~/example.md' + +file.warn('Something went wrong', {'line': 1, 'column': 3}); +// { [~/example.md:1:3: Something went wrong] +// name: '~/example.md:1:3', +// file: '~/example.md', +// reason: 'Something went wrong', +// line: 1, +// column: 3, +// fatal: false } +``` + +## Related Tools + +[**VFile**](#api)s are used by both [**retext**](https://github.com/wooorm/retext) +and [**remark**](https://github.com/wooorm/remark). + +In addition, here’s a list of useful tools: + +* [`dustinspecker/convert-vinyl-to-vfile`](https://github.com/dustinspecker/convert-vinyl-to-vfile) + — Convert a [Vinyl](https://github.com/wearefractal/vinyl) file to a VFile; + +* [`shinnn/is-vfile-message`](https://github.com/shinnn/is-vfile-message) + — Check if a value is a `VFileMessage` object; + +* [`wooorm/to-vfile`](https://github.com/wooorm/to-vfile) + — Create a virtual file from a file-path; + +* [`wooorm/vfile-sort`](https://github.com/wooorm/vfile-sort) + — Sort virtual file messages by line/column; + +* [`shinnn/vfile-messages-to-vscode-diagnostics`](https://github.com/shinnn/vfile-messages-to-vscode-diagnostics) + — Convert `VFileMessage`s into an array of VS Code diagnostics; + +* [`wooorm/vfile-reporter`](https://github.com/wooorm/vfile-reporter) + — Stylish reporter for virtual files. + +## API + +### `VFile()` + +**VFile** objects make it easy to move files, to trigger warnings and +errors, and to store supplementary metadata relating to files, all without +accessing the file-system. + +**Example** + +```js +var file = new VFile({ + 'directory': '~', + 'filename': 'example', + 'extension': 'txt', + 'contents': 'Foo *bar* baz' +}); + +file === VFile(file); // true +file === new VFile(file); // true + +VFile('foo') instanceof VFile; // true +``` + +**Signatures** + +* `file = VFile(contents|options|vFile?)`. + +**Parameters** + +* `contents` (`string`) — Contents of the file; + +* `vFile` (`VFile`) — Existing representation, returned without modification; + +* `options` (`Object`): + + * `directory` (`string?`, default: `''`) + — Parent directory; + + * `filename` (`string?`, default: `''`) + — Name, without extension; + + * `extension` (`string?`, default: `''`) + — Extension(s), without initial dot; + + * `contents` (`string?`, default: `''`) + — Raw value. + +**Returns** + +`vFile` — Instance. + +**Notes** + +`VFile` exposes an interface compatible with ESLint’s formatters. For example, +to expose warnings using ESLint’s `compact` formatter, execute the following: + +```javascript +var compact = require('eslint/lib/formatters/compact'); +var VFile = require('vfile'); + +var vFile = new VFile({ + 'directory': '~', + 'filename': 'hello', + 'extension': 'txt' +}); + +vFile.warn('Whoops, something happened!'); + +console.log(compact([vFile])); +``` + +Which would yield the following: + +```text +~/hello.txt: line 0, col 0, Warning - Whoops, something happened! + +1 problem +``` + +### `VFile#contents` + +`string` — Content of file. + +### `VFile#directory` + +`string` — Path to parent directory. + +### `VFile#filename` + +`string` — Filename. A file-path can still be generated when no filename exists. + +### `VFile#extension` + +`string` — Extension. A file-path can still be generated when no extension +exists. + +### `VFile#basename()` + +Get the filename, with extension, if applicable. + +**Example** + +```js +var file = new VFile({ + 'directory': '~', + 'filename': 'example', + 'extension': 'txt' +}); + +file.basename() // example.txt +``` + +**Signatures** + +* `string = vFile.basename()`. + +**Returns** + +`string`— Returns the file path without a directory, if applicable. +Otherwise,an empty string is returned. + +### `VFile#quiet` + +`boolean?` — Whether an error created by [`VFile#fail()`](#vfilefailreason-position) +is returned (when truthy) or thrown (when falsey). + +Ensure all `messages` associated with a file are handled properly when setting +this to `true`. + +### `VFile#messages` + +`Array.` — List of associated messages. + +**Notes** + +`VFile#message()`, and in turn `VFile#warn()` and `VFile#fail()`, return +`Error` objects that adhere to the [`VFileMessage`](#vfilemessage) schema. +Its results can populate `messages`. + +### `VFile#history` + +`Array.` — List of file-paths the file [`move`](#vfilemoveoptions)d +between. + +### `VFile#toString()` + +Get the value of the file. + +**Example** + +```js +var vFile = new VFile('Foo'); +String(vFile); // 'Foo' +``` + +**Signatures** + +* `string = vFile.toString()`. + +**Returns** + +`string` — Contents. + +### `VFile#filePath()` + +Get the filename, with extension and directory, if applicable. + +**Example** + +```js +var file = new VFile({ + 'directory': '~', + 'filename': 'example', + 'extension': 'txt' +}); + +String(file.filePath); // ~/example.txt +file.filePath() // ~/example.txt +``` + +**Signatures** + +* `string = vFile.filePath()`. + +**Returns** + +`string` — If the `vFile` has a `filename`, it will be prefixed with the +directory (slashed), if applicable, and suffixed with the (dotted) extension +(if applicable). Otherwise, an empty string is returned. + +### `VFile#move(options)` + +Move a file by passing a new directory, filename, and extension. When these +are not given, the default values are kept. + +**Example** + +```js +var file = new VFile({ + 'directory': '~', + 'filename': 'example', + 'extension': 'txt', + 'contents': 'Foo *bar* baz' +}); + +file.move({'directory': '/var/www'}); +file.filePath(); // '/var/www/example.txt' + +file.move({'extension': 'md'}); +file.filePath(); // '/var/www/example.md' +``` + +**Signatures** + +* `vFile = vFile.move(options?)`. + +**Parameters** + +* `options` (`Object`): + + * `directory` (`string`, default: `''`) + — Parent directory; + + * `filename` (`string?`, default: `''`) + — Name, without extension; + + * `extension` (`string`, default: `''`) + — Extension(s), without initial dot. + +**Returns** + +`vFile` — Context object (chainable). + +### `VFile#namespace(key)` + +Access metadata. + +**Example** + +```js +var file = new VFile('Foo'); + +file.namespace('foo').bar = 'baz'; + +console.log(file.namespace('foo').bar) // 'baz'; +``` + +**Parameters** + +* `key` (`string`) — Namespace key. + +**Returns** + +`Object` — Private namespace for metadata. + +### `VFile#message(reason[, position])` + +Create a message with `reason` at `position`. When an error is passed in as +`reason`, copies the stack. This does not add a message to `messages`. + +**Example** + +```js +var file = new VFile(); + +file.message('Something went wrong'); +// { [1:1: Something went wrong] +// name: '1:1', +// file: '', +// reason: 'Something went wrong', +// line: null, +// column: null } +``` + +**Signatures** + +* `VFileMessage = vFile.message(err|reason, node|location|position?)`. + +**Parameters** + +* `err` (`Error`) — Original error, whose stack and message are used; + +* `reason` (`string`) — Reason for message; + +* `node` (`Node`) — Syntax tree object; + +* `location` (`Object`) — Syntax tree location (found at `node.position`); + +* `position` (`Object`) — Syntax tree position (found at + `node.position.start` or `node.position.end`). + +**Returns** + +[`VFileMessage`](#vfilemessage) — File-related message with location +information. + +### `VFile#warn(reason[, position])` + +Warn. Creates a non-fatal message (see [`VFile#message()`](#vfilemessagereason-position)), +and adds it to the file's [`messages`](#vfilemessages) list. + +**Example** + +```js +var file = new VFile(); + +file.warn('Something went wrong'); +// { [1:1: Something went wrong] +// name: '1:1', +// file: '', +// reason: 'Something went wrong', +// line: null, +// column: null, +// fatal: false } +``` + +**See** + +* [`VFile#message`](#vfilemessagereason-position) + +### `VFile#fail(reason[, position])` + +Fail. Creates a fatal message (see `VFile#message()`), sets `fatal: true`, +adds it to the file's `messages` list. + +If `quiet` is not `true`, throws the error. + +**Example** + +```js +var file = new VFile(); + +file.fail('Something went wrong'); +// 1:1: Something went wrong +// at VFile.exception (vfile/index.js:296:11) +// at VFile.fail (vfile/index.js:360:20) +// at repl:1:6 + +file.quiet = true; +file.fail('Something went wrong'); +// { [1:1: Something went wrong] +// name: '1:1', +// file: '', +// reason: 'Something went wrong', +// line: null, +// column: null, +// fatal: true } +``` + +**See** + +* [`VFile#message`](#vfilemessagereason-position) + +### `VFile#hasFailed()` + +Check if a fatal message occurred making the file no longer processable. + +**Example** + +```js +var file = new VFile(); +file.quiet = true; + +file.hasFailed(); // false + +file.fail('Something went wrong'); +file.hasFailed(); // true +``` + +**Signatures** + +* `boolean = vFile.hasFailed()`. + +**Returns** + +`boolean` — `true` if at least one of file’s `messages` has a `fatal` +property set to `true`. + +### `VFileMessage` + +`Error` — File-related message with location information. + +**Properties** + +* `name` (`string`) + — (Starting) location of the message, preceded by its file-path when + available, and joined by `':'`. Used by the native + [`Error#toString()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/name); + +* `file` (`string`) — File-path; + +* `reason` (`string`) — Reason for message; + +* `line` (`number?`) — Line of error, when available; + +* `column` (`number?`) — Column of error, when available; + +* `stack` (`string?`) — Stack of message, when available; + +* `fatal` (`boolean?`) — Whether the associated file is still processable. + +* `location` (`object`) — Full range information, when available. Has + `start` and `end` properties, both set to an object with `line` and + `column`, set to `number?`. + +## License + +[MIT](LICENSE) © [Titus Wormer](http://wooorm.com) diff --git a/tools/node_modules/ware/History.md b/tools/node_modules/ware/History.md new file mode 100644 index 00000000000000..df59f0924ec9bc --- /dev/null +++ b/tools/node_modules/ware/History.md @@ -0,0 +1,56 @@ + +1.3.0 - April 30, 2015 +---------------------- +* throw on errors without a `done` callback +* add `files` to `package.json` + +1.2.0 - September 25, 2014 +-------------------------- +* move `co` to `devDependencies` +* add client-side support + +1.1.0 - September 19, 2014 +-------------------------- +* refactor to use `wrap-fn` + +1.0.1 - August 26, 2014 +----------------------- +* add support for passing an array of ware instances + +1.0.0 - August 26, 2014 +----------------------- +* add support for sync middleware +* add support for generators +* remove support for error middleware with arity + +0.3.0 - April 24, 2014 +---------------------- +* let `use` accept arrays +* let `use` accept `Ware` instances +* allow passing `fns` to the constructor + +0.2.2 - March 18, 2013 +---------------------- +* moving to settimeout to fix dom validation issues +* add travis + +0.2.1 - December 12, 2013 +------------------------- +* fix skipping error handlers without error + +0.2.0 - October 18, 2013 +------------------------ +* rewrite: + * handle any amount of input arguments + * allow multiple error handlers + * only call error handlers after the error is `next`'d + * make passing callback optional + * rename `end` to `run` since it can happen multiple times + +0.1.0 - July 29, 2013 +--------------------- +* updating api + +0.0.1 - July 29, 2013 +--------------------- +* first commit diff --git a/tools/node_modules/ware/Readme.md b/tools/node_modules/ware/Readme.md new file mode 100644 index 00000000000000..5d2052eeaedb81 --- /dev/null +++ b/tools/node_modules/ware/Readme.md @@ -0,0 +1,104 @@ + +# ware + + Easily create your own middleware layer. + + [![Build Status](https://travis-ci.org/segmentio/ware.png?branch=master)](https://travis-ci.org/segmentio/ware) + +## Installation + +Node: + +```bash +$ npm install ware +``` + +Component: + +```bash +$ component install segmentio/ware +``` + +Duo: + +```js +var ware = require('segmentio/ware'); +``` + +## Example + +```js +var ware = require('ware'); +var middleware = ware() + .use(function (req, res, next) { + res.x = 'hello'; + next(); + }) + .use(function (req, res, next) { + res.y = 'world'; + next(); + }); + +middleware.run({}, {}, function (err, req, res) { + res.x; // "hello" + res.y; // "world" +}); +``` + + Give it any number of arguments: + +```js +var ware = require('ware'); +var middleware = ware() + .use(function (a, b, c, next) { + console.log(a, b, c); + next(); + }) + +middleware.run(1, 2, 3); // 1, 2, 3 +``` + + Supports generators (on the server): + +```js +var ware = require('ware'); +var middleware = ware() + .use(function (obj) { + obj.url = 'http://google.com'; + }) + .use(function *(obj) { + obj.src = yield http.get(obj.url); + }) + +middleware.run({ url: 'http://facebook.com' }, function(err, obj) { + if (err) throw err; + obj.src // "obj.url" source +}); +``` + +## API + +#### ware() + + Create a new list of middleware. + +#### .use(fn) + + Push a middleware `fn` onto the list. `fn` can be a synchronous, asynchronous, or generator function. + `fn` can also be an array of functions or an instance of `Ware`. + +#### .run(input..., [callback]) + + Runs the middleware functions with `input...` and optionally calls `callback(err, input...)`. + +## License + + (The MIT License) + + Copyright (c) 2013 Segment.io <friends@segment.io> + + 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. diff --git a/tools/node_modules/ware/lib/index.js b/tools/node_modules/ware/lib/index.js new file mode 100644 index 00000000000000..643a74bbcf59b8 --- /dev/null +++ b/tools/node_modules/ware/lib/index.js @@ -0,0 +1,91 @@ +/** + * Module Dependencies + */ + +var slice = [].slice; +var wrap = require('wrap-fn'); + +/** + * Expose `Ware`. + */ + +module.exports = Ware; + +/** + * Throw an error. + * + * @param {Error} error + */ + +function fail (err) { + throw err; +} + +/** + * Initialize a new `Ware` manager, with optional `fns`. + * + * @param {Function or Array or Ware} fn (optional) + */ + +function Ware (fn) { + if (!(this instanceof Ware)) return new Ware(fn); + this.fns = []; + if (fn) this.use(fn); +} + +/** + * Use a middleware `fn`. + * + * @param {Function or Array or Ware} fn + * @return {Ware} + */ + +Ware.prototype.use = function (fn) { + if (fn instanceof Ware) { + return this.use(fn.fns); + } + + if (fn instanceof Array) { + for (var i = 0, f; f = fn[i++];) this.use(f); + return this; + } + + this.fns.push(fn); + return this; +}; + +/** + * Run through the middleware with the given `args` and optional `callback`. + * + * @param {Mixed} args... + * @param {Function} callback (optional) + * @return {Ware} + */ + +Ware.prototype.run = function () { + var fns = this.fns; + var ctx = this; + var i = 0; + var last = arguments[arguments.length - 1]; + var done = 'function' == typeof last && last; + var args = done + ? slice.call(arguments, 0, arguments.length - 1) + : slice.call(arguments); + + // next step + function next (err) { + if (err) return (done || fail)(err); + var fn = fns[i++]; + var arr = slice.call(args); + + if (!fn) { + return done && done.apply(null, [null].concat(args)); + } + + wrap(fn, next).apply(ctx, arr); + } + + next(); + + return this; +}; diff --git a/tools/node_modules/ware/package.json b/tools/node_modules/ware/package.json new file mode 100644 index 00000000000000..636a66b803cca9 --- /dev/null +++ b/tools/node_modules/ware/package.json @@ -0,0 +1,93 @@ +{ + "_args": [ + [ + "ware@^1.3.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\remark" + ] + ], + "_from": "ware@>=1.3.0 <2.0.0", + "_id": "ware@1.3.0", + "_inCache": true, + "_location": "/ware", + "_nodeVersion": "0.12.2", + "_npmUser": { + "email": "ian@ianstormtaylor.com", + "name": "ianstormtaylor" + }, + "_npmVersion": "2.7.4", + "_phantomChildren": {}, + "_requested": { + "name": "ware", + "raw": "ware@^1.3.0", + "rawSpec": "^1.3.0", + "scope": null, + "spec": ">=1.3.0 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/remark", + "/unified" + ], + "_resolved": "https://registry.npmjs.org/ware/-/ware-1.3.0.tgz", + "_shasum": "d1b14f39d2e2cb4ab8c4098f756fe4b164e473d4", + "_shrinkwrap": null, + "_spec": "ware@^1.3.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\remark", + "bugs": { + "url": "https://github.com/segmentio/ware/issues" + }, + "dependencies": { + "wrap-fn": "^0.1.0" + }, + "description": "Easily create your own middleware layer.", + "devDependencies": { + "co": "^3.1.0", + "co-mocha": "^1.0.0", + "gnode": "0.0.8", + "mocha": "^1.21.4" + }, + "directories": {}, + "dist": { + "shasum": "d1b14f39d2e2cb4ab8c4098f756fe4b164e473d4", + "tarball": "http://registry.npmjs.org/ware/-/ware-1.3.0.tgz" + }, + "files": [ + "lib" + ], + "gitHead": "a7e7abf6ad95dbc3a9941d221568eef2dfe2c755", + "homepage": "https://github.com/segmentio/ware", + "installable": true, + "keywords": [ + "compose", + "connect", + "express", + "layer", + "middleware" + ], + "license": "MIT", + "main": "lib/index.js", + "maintainers": [ + { + "name": "segmentio", + "email": "friends@segment.io" + }, + { + "name": "ianstormtaylor", + "email": "ian@ianstormtaylor.com" + }, + { + "name": "segment", + "email": "tj@segment.io" + } + ], + "name": "ware", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "git://github.com/segmentio/ware.git" + }, + "scripts": { + "test": "make test" + }, + "version": "1.3.0" +} diff --git a/tools/node_modules/wrap-fn/Readme.md b/tools/node_modules/wrap-fn/Readme.md new file mode 100644 index 00000000000000..a235369c32dbe9 --- /dev/null +++ b/tools/node_modules/wrap-fn/Readme.md @@ -0,0 +1,77 @@ + +# wrap-fn + + Low-level wrapper to support sync, async, promises, and generator functions. + +## Installation + +Node: + +```bash +$ npm install wrap-fn +``` + +Duo: + +```js +var wrap = require('matthewmueller/wrap-fn'); +``` + +## Example + +```js +function *fn(a, b) { + yield wait(100); + // ... +} + +function next(err) { + // Called after +} + +wrap(fn, next)('a', 'b') +``` + +## API + +### `wrap(fn, [done])([args, ...])` + +Wrap `fn` to support sync, async, promises and generator functions. Call `done` when finished. + +`wrap` returns a function which you can pass arguments to or set the context. + +```js +wrap(fn).call(user, a, b, c, d); +``` + +## Test + +```js +npm install +make test +``` + +## License + +(The MIT License) + +Copyright (c) 2014 Matthew Mueller <mattmuelle@gmail.com> + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tools/node_modules/wrap-fn/index.js b/tools/node_modules/wrap-fn/index.js new file mode 100644 index 00000000000000..b2cf47306fe6a0 --- /dev/null +++ b/tools/node_modules/wrap-fn/index.js @@ -0,0 +1,125 @@ +/** + * Module Dependencies + */ + +var noop = function(){}; +var co = require('co'); + +/** + * Export `wrap-fn` + */ + +module.exports = wrap; + +/** + * Wrap a function to support + * sync, async, and gen functions. + * + * @param {Function} fn + * @param {Function} done + * @return {Function} + * @api public + */ + +function wrap(fn, done) { + done = once(done || noop); + + return function() { + // prevents arguments leakage + // see https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#3-managing-arguments + var i = arguments.length; + var args = new Array(i); + while (i--) args[i] = arguments[i]; + + var ctx = this; + + // done + if (!fn) { + return done.apply(ctx, [null].concat(args)); + } + + // async + if (fn.length > args.length) { + // NOTE: this only handles uncaught synchronous errors + try { + return fn.apply(ctx, args.concat(done)); + } catch (e) { + return done(e); + } + } + + // generator + if (generator(fn)) { + return co(fn).apply(ctx, args.concat(done)); + } + + // sync + return sync(fn, done).apply(ctx, args); + } +} + +/** + * Wrap a synchronous function execution. + * + * @param {Function} fn + * @param {Function} done + * @return {Function} + * @api private + */ + +function sync(fn, done) { + return function () { + var ret; + + try { + ret = fn.apply(this, arguments); + } catch (err) { + return done(err); + } + + if (promise(ret)) { + ret.then(function (value) { done(null, value); }, done); + } else { + ret instanceof Error ? done(ret) : done(null, ret); + } + } +} + +/** + * Is `value` a generator? + * + * @param {Mixed} value + * @return {Boolean} + * @api private + */ + +function generator(value) { + return value + && value.constructor + && 'GeneratorFunction' == value.constructor.name; +} + + +/** + * Is `value` a promise? + * + * @param {Mixed} value + * @return {Boolean} + * @api private + */ + +function promise(value) { + return value && 'function' == typeof value.then; +} + +/** + * Once + */ + +function once(fn) { + return function() { + var ret = fn.apply(this, arguments); + fn = noop; + return ret; + }; +} diff --git a/tools/node_modules/wrap-fn/package.json b/tools/node_modules/wrap-fn/package.json new file mode 100644 index 00000000000000..772d73d31a30fc --- /dev/null +++ b/tools/node_modules/wrap-fn/package.json @@ -0,0 +1,85 @@ +{ + "_args": [ + [ + "wrap-fn@^0.1.0", + "C:\\wamp\\www\\node\\tools\\node_modules\\ware" + ] + ], + "_from": "wrap-fn@>=0.1.0 <0.2.0", + "_id": "wrap-fn@0.1.4", + "_inCache": true, + "_location": "/wrap-fn", + "_npmUser": { + "email": "mattmuelle@gmail.com", + "name": "mattmueller" + }, + "_npmVersion": "2.0.0", + "_phantomChildren": {}, + "_requested": { + "name": "wrap-fn", + "raw": "wrap-fn@^0.1.0", + "rawSpec": "^0.1.0", + "scope": null, + "spec": ">=0.1.0 <0.2.0", + "type": "range" + }, + "_requiredBy": [ + "/ware" + ], + "_resolved": "https://registry.npmjs.org/wrap-fn/-/wrap-fn-0.1.4.tgz", + "_shasum": "03eba5d07ac55c2a93fa2d37a2b01f81c07bddb2", + "_shrinkwrap": null, + "_spec": "wrap-fn@^0.1.0", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\ware", + "author": { + "email": "mattmuelle@gmail.com", + "name": "Matthew Mueller" + }, + "bugs": { + "url": "https://github.com/MatthewMueller/wrap-fn/issues" + }, + "dependencies": { + "co": "3.1.0" + }, + "description": "support sync, async, and generator functions", + "devDependencies": { + "duo": "^0.8.2", + "duo-test": "^0.3.2", + "generator-support": "0.0.1", + "gnode": "0.0.8", + "mocha": "*", + "should": "*" + }, + "directories": {}, + "dist": { + "shasum": "03eba5d07ac55c2a93fa2d37a2b01f81c07bddb2", + "tarball": "http://registry.npmjs.org/wrap-fn/-/wrap-fn-0.1.4.tgz" + }, + "files": [ + "index.js" + ], + "gitHead": "44598c653ad0189ff884152a8b9a3476abbcbce9", + "homepage": "https://github.com/MatthewMueller/wrap-fn", + "installable": true, + "keywords": [ + "browser", + "generator", + "wrap" + ], + "maintainers": [ + { + "name": "mattmueller", + "email": "mattmuelle@gmail.com" + } + ], + "name": "wrap-fn", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "https://github.com/MatthewMueller/wrap-fn" + }, + "scripts": { + "test": "make test" + }, + "version": "0.1.4" +} diff --git a/tools/node_modules/wrappy/LICENSE b/tools/node_modules/wrappy/LICENSE new file mode 100644 index 00000000000000..19129e315fe593 --- /dev/null +++ b/tools/node_modules/wrappy/LICENSE @@ -0,0 +1,15 @@ +The ISC License + +Copyright (c) Isaac Z. Schlueter and Contributors + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR +IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/tools/node_modules/wrappy/README.md b/tools/node_modules/wrappy/README.md new file mode 100644 index 00000000000000..98eab2522b86e5 --- /dev/null +++ b/tools/node_modules/wrappy/README.md @@ -0,0 +1,36 @@ +# wrappy + +Callback wrapping utility + +## USAGE + +```javascript +var wrappy = require("wrappy") + +// var wrapper = wrappy(wrapperFunction) + +// make sure a cb is called only once +// See also: http://npm.im/once for this specific use case +var once = wrappy(function (cb) { + var called = false + return function () { + if (called) return + called = true + return cb.apply(this, arguments) + } +}) + +function printBoo () { + console.log('boo') +} +// has some rando property +printBoo.iAmBooPrinter = true + +var onlyPrintOnce = once(printBoo) + +onlyPrintOnce() // prints 'boo' +onlyPrintOnce() // does nothing + +// random property is retained! +assert.equal(onlyPrintOnce.iAmBooPrinter, true) +``` diff --git a/tools/node_modules/wrappy/package.json b/tools/node_modules/wrappy/package.json new file mode 100644 index 00000000000000..3b70d6e8c2afbb --- /dev/null +++ b/tools/node_modules/wrappy/package.json @@ -0,0 +1,77 @@ +{ + "_args": [ + [ + "wrappy@1", + "C:\\wamp\\www\\node\\tools\\node_modules\\inflight" + ] + ], + "_from": "wrappy@>=1.0.0 <2.0.0", + "_id": "wrappy@1.0.1", + "_inCache": true, + "_location": "/wrappy", + "_nodeVersion": "0.10.31", + "_npmUser": { + "email": "i@izs.me", + "name": "isaacs" + }, + "_npmVersion": "2.0.0", + "_phantomChildren": {}, + "_requested": { + "name": "wrappy", + "raw": "wrappy@1", + "rawSpec": "1", + "scope": null, + "spec": ">=1.0.0 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/inflight", + "/once" + ], + "_resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.1.tgz", + "_shasum": "1e65969965ccbc2db4548c6b84a6f2c5aedd4739", + "_shrinkwrap": null, + "_spec": "wrappy@1", + "_where": "C:\\wamp\\www\\node\\tools\\node_modules\\inflight", + "author": { + "email": "i@izs.me", + "name": "Isaac Z. Schlueter", + "url": "http://blog.izs.me/" + }, + "bugs": { + "url": "https://github.com/npm/wrappy/issues" + }, + "dependencies": {}, + "description": "Callback wrapping utility", + "devDependencies": { + "tap": "^0.4.12" + }, + "directories": { + "test": "test" + }, + "dist": { + "shasum": "1e65969965ccbc2db4548c6b84a6f2c5aedd4739", + "tarball": "http://registry.npmjs.org/wrappy/-/wrappy-1.0.1.tgz" + }, + "gitHead": "006a8cbac6b99988315834c207896eed71fd069a", + "homepage": "https://github.com/npm/wrappy", + "installable": true, + "license": "ISC", + "main": "wrappy.js", + "maintainers": [ + { + "name": "isaacs", + "email": "i@izs.me" + } + ], + "name": "wrappy", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "https://github.com/npm/wrappy" + }, + "scripts": { + "test": "tap test/*.js" + }, + "version": "1.0.1" +} diff --git a/tools/node_modules/wrappy/test/basic.js b/tools/node_modules/wrappy/test/basic.js new file mode 100644 index 00000000000000..5ed0fcdfd9c52e --- /dev/null +++ b/tools/node_modules/wrappy/test/basic.js @@ -0,0 +1,51 @@ +var test = require('tap').test +var wrappy = require('../wrappy.js') + +test('basic', function (t) { + function onceifier (cb) { + var called = false + return function () { + if (called) return + called = true + return cb.apply(this, arguments) + } + } + onceifier.iAmOnce = {} + var once = wrappy(onceifier) + t.equal(once.iAmOnce, onceifier.iAmOnce) + + var called = 0 + function boo () { + t.equal(called, 0) + called++ + } + // has some rando property + boo.iAmBoo = true + + var onlyPrintOnce = once(boo) + + onlyPrintOnce() // prints 'boo' + onlyPrintOnce() // does nothing + t.equal(called, 1) + + // random property is retained! + t.equal(onlyPrintOnce.iAmBoo, true) + + var logs = [] + var logwrap = wrappy(function (msg, cb) { + logs.push(msg + ' wrapping cb') + return function () { + logs.push(msg + ' before cb') + var ret = cb.apply(this, arguments) + logs.push(msg + ' after cb') + } + }) + + var c = logwrap('foo', function () { + t.same(logs, [ 'foo wrapping cb', 'foo before cb' ]) + }) + c() + t.same(logs, [ 'foo wrapping cb', 'foo before cb', 'foo after cb' ]) + + t.end() +}) diff --git a/tools/node_modules/wrappy/wrappy.js b/tools/node_modules/wrappy/wrappy.js new file mode 100644 index 00000000000000..bb7e7d6fcf70fd --- /dev/null +++ b/tools/node_modules/wrappy/wrappy.js @@ -0,0 +1,33 @@ +// Returns a wrapper function that returns a wrapped callback +// The wrapper function should do some stuff, and return a +// presumably different callback function. +// This makes sure that own properties are retained, so that +// decorations and such are not lost along the way. +module.exports = wrappy +function wrappy (fn, cb) { + if (fn && cb) return wrappy(fn)(cb) + + if (typeof fn !== 'function') + throw new TypeError('need wrapper function') + + Object.keys(fn).forEach(function (k) { + wrapper[k] = fn[k] + }) + + return wrapper + + function wrapper() { + var args = new Array(arguments.length) + for (var i = 0; i < args.length; i++) { + args[i] = arguments[i] + } + var ret = fn.apply(this, args) + var cb = args[args.length-1] + if (typeof ret === 'function' && ret !== cb) { + Object.keys(cb).forEach(function (k) { + ret[k] = cb[k] + }) + } + return ret + } +} diff --git a/vcbuild.bat b/vcbuild.bat index 8b2c67b50fe155..b3af9f74a49578 100644 --- a/vcbuild.bat +++ b/vcbuild.bat @@ -25,6 +25,7 @@ set msi= set upload= set licensertf= set jslint= +set jslint_docs= set buildnodeweak= set noetw= set noetw_msi_arg= @@ -54,7 +55,7 @@ if /i "%1"=="nosnapshot" set nosnapshot=1&goto arg-ok if /i "%1"=="noetw" set noetw=1&goto arg-ok if /i "%1"=="noperfctr" set noperfctr=1&goto arg-ok if /i "%1"=="licensertf" set licensertf=1&goto arg-ok -if /i "%1"=="test" set test_args=%test_args% sequential parallel message -J&set jslint=1&goto arg-ok +if /i "%1"=="test" set test_args=%test_args% sequential parallel message -J&set jslint=1&set jslint_docs=1&goto arg-ok if /i "%1"=="test-ci" set test_args=%test_args% %test_ci_args% -p tap --logfile test.tap message sequential parallel&goto arg-ok if /i "%1"=="test-simple" set test_args=%test_args% sequential parallel -J&goto arg-ok if /i "%1"=="test-message" set test_args=%test_args% message&goto arg-ok @@ -63,6 +64,7 @@ if /i "%1"=="test-internet" set test_args=%test_args% internet&goto arg-ok if /i "%1"=="test-pummel" set test_args=%test_args% pummel&goto arg-ok if /i "%1"=="test-all" set test_args=%test_args% sequential parallel message gc internet pummel&set buildnodeweak=1&set jslint=1&goto arg-ok if /i "%1"=="jslint" set jslint=1&goto arg-ok +if /i "%1"=="jslint-docs" set jslint_docs=1&goto arg-ok if /i "%1"=="msi" set msi=1&set licensertf=1&set download_arg="--download=all"&set i18n_arg=small-icu&goto arg-ok if /i "%1"=="build-release" set build_release=1&goto arg-ok if /i "%1"=="upload" set upload=1&goto arg-ok @@ -260,6 +262,12 @@ goto jslint if not defined jslint goto exit echo running jslint %config%\node tools\eslint\bin\eslint.js lib src test tools\doc tools\eslint-rules --rulesdir tools\eslint-rules --quiet +goto jslint-docs + +:jslint-docs +if not defined jslint_docs goto exit +echo running jslint-docs +%config%\node tools\eslint\bin\eslint.js --plugin eslint-plugin-markdown --ext markdown doc\api\ --rulesdir tools\eslint-rules --quiet goto exit :create-msvs-files-failed