Commit f064c792 authored by Muddsair Sharif's avatar Muddsair Sharif
Browse files

Initial commit

parents
Pipeline #8 canceled with stages
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.
anymatch [![Build Status](https://travis-ci.org/micromatch/anymatch.svg?branch=master)](https://travis-ci.org/micromatch/anymatch) [![Coverage Status](https://img.shields.io/coveralls/micromatch/anymatch.svg?branch=master)](https://coveralls.io/r/micromatch/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.
__Note: This module has Bash-parity, please be aware that Windows-style backslashes are not supported as separators. See https://github.com/micromatch/micromatch#backslashes for more information.__
[![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
// using globs to match directories and their children
anymatch('node_modules', 'node_modules'); // true
anymatch('node_modules', 'node_modules/somelib/index.js'); // false
anymatch('node_modules/**', 'node_modules/somelib/index.js'); // true
anymatch('node_modules/**', '/absolute/path/to/node_modules/somelib/index.js'); // false
anymatch('**/node_modules/**', '/absolute/path/to/node_modules/somelib/index.js'); // true
```
#### 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/micromatch/anymatch/releases)
NOTE: As of v2.0.0, [micromatch](https://github.com/jonschlinkert/micromatch) moves away from minimatch-parity and inline with Bash. This includes handling backslashes differently (see https://github.com/micromatch/micromatch#backslashes for more information).
NOTE: As of v1.2.0, anymatch uses [micromatch](https://github.com/jonschlinkert/micromatch)
for glob pattern matching. 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/micromatch/anymatch/master/LICENSE)
'use strict';
var micromatch = require('micromatch');
var normalize = require('normalize-path');
var path = require('path'); // required for tests.
var arrify = function(a) { return a == null ? [] : (Array.isArray(a) ? a : [a]); };
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, altValue;
var matched = false;
var matchIndex = -1;
function testCriteria(criterion, index) {
var result;
switch (Object.prototype.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);
result = result || altValue && criterion.apply(null, altValue);
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 = normalize(string);
altString = altString === string ? null : altString;
if (altString) altValue = [altString].concat(value.slice(1));
}
matched = crit.slice(startIndex, endIndex).some(testCriteria);
}
return returnIndex === true ? matchIndex : matched;
};
module.exports = anymatch;
{
"_from": "anymatch@^2.0.0",
"_id": "anymatch@2.0.0",
"_inBundle": false,
"_integrity": "sha512-5teOsQWABXHHBFP9y3skS5P3d/WfWXpv3FUpy+LorMrNYaT9pI4oLMQX7jzQ2KklNpGpWHzdCXTDT2Y3XGlZBw==",
"_location": "/anymatch",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "anymatch@^2.0.0",
"name": "anymatch",
"escapedName": "anymatch",
"rawSpec": "^2.0.0",
"saveSpec": null,
"fetchSpec": "^2.0.0"
},
"_requiredBy": [
"/chokidar"
],
"_resolved": "https://registry.npmjs.org/anymatch/-/anymatch-2.0.0.tgz",
"_shasum": "bcb24b4f37934d9aa7ac17b4adaf89e7c76ef2eb",
"_spec": "anymatch@^2.0.0",
"_where": "/Users/Chorthip/Documents/GitKraken/nasaproject/node_modules/chokidar",
"author": {
"name": "Elan Shanker",
"url": "http://github.com/es128"
},
"bugs": {
"url": "https://github.com/micromatch/anymatch/issues"
},
"bundleDependencies": false,
"dependencies": {
"micromatch": "^3.1.4",
"normalize-path": "^2.1.1"
},
"deprecated": false,
"description": "Matches strings against configurable strings, globs, regular expressions, and/or functions",
"devDependencies": {
"coveralls": "^2.7.0",
"istanbul": "^0.4.5",
"mocha": "^3.0.0"
},
"files": [
"index.js"
],
"homepage": "https://github.com/micromatch/anymatch",
"keywords": [
"match",
"any",
"string",
"file",
"fs",
"list",
"glob",
"regex",
"regexp",
"regular",
"expression",
"function"
],
"license": "ISC",
"name": "anymatch",
"repository": {
"type": "git",
"url": "git+https://github.com/micromatch/anymatch.git"
},
"scripts": {
"test": "istanbul cover _mocha && cat ./coverage/lcov.info | coveralls"
},
"version": "2.0.0"
}
ap
==
`Function.prototype.bind` sets `this` which is super annoying if you just want
to do currying over arguments while passing `this` through.
Instead you can do:
``` js
var ap = require('ap');
var z = ap([3], function (x, y) {
return this.z * (x * 2 + y);
}).call({ z : 10 }, 4);
console.log(z);
```
***
```
100
```
methods
=======
``` js
var ap = require('ap')
```
## ap(args, fn)
Fill in the arguments `args` at the beginning of `fn`'s arguments list.
## ap.pa(args, fn)
Fill in the arguments `args` at the end of `fn`'s arguments list.
## ap.apa(left, right, fn)
Fill in `left` arguments starting from the beginning of `fn`'s argument list and
`right` arguments starting from the end.
## ap.partial(fn, args...)
Fill in `fn`'s arguments with `args...` from the beginning of `fn`'s arguments
list.
## ap.partialRight(fn, args...)
Fill in `fn`'s arguments with `args...` starting from the end of `fn`'s
arguments list.
## ap.curry(fn, args...)
Curry `fn`, returning a new function with `args...` partially applied from the
beginning of `fn`'s arguments list.
## ap.curryRight(fn, args...)
Curry `fn` returning a new function with `args...` partially applied from the
end of `fn`'s arguments list.
var ap = require('../');
var z = ap([3], function (x, y) {
return this.z * (x * 2 + y);
}).call({ z : 10 }, 4);
console.log(z);
exports = module.exports = ap;
function ap (args, fn) {
return function () {
var rest = [].slice.call(arguments)
, first = args.slice()
first.push.apply(first, rest)
return fn.apply(this, first);
};
}
exports.pa = pa;
function pa (args, fn) {
return function () {
var rest = [].slice.call(arguments)
rest.push.apply(rest, args)
return fn.apply(this, rest);
};
}
exports.apa = apa;
function apa (left, right, fn) {
return function () {
return fn.apply(this,
left.concat.apply(left, arguments).concat(right)
);
};
}
exports.partial = partial;
function partial (fn) {
var args = [].slice.call(arguments, 1);
return ap(args, fn);
}
exports.partialRight = partialRight;
function partialRight (fn) {
var args = [].slice.call(arguments, 1);
return pa(args, fn);
}
exports.curry = curry;
function curry (fn) {
return partial(partial, fn);
}
exports.curryRight = function curryRight (fn) {
return partial(partialRight, fn);
}
{
"_args": [
[
{
"raw": "ap@~0.2.0",
"scope": null,
"escapedName": "ap",
"name": "ap",
"rawSpec": "~0.2.0",
"spec": ">=0.2.0 <0.3.0",
"type": "range"
},
"C:\\Users\\Giuliano\\Desktop\\nasaproject\\node_modules\\pg-types"
]
],
"_from": "ap@>=0.2.0 <0.3.0",
"_id": "ap@0.2.0",
"_inCache": true,
"_location": "/ap",
"_npmUser": {
"name": "substack",
"email": "mail@substack.net"
},
"_npmVersion": "1.1.59",
"_phantomChildren": {},
"_requested": {
"raw": "ap@~0.2.0",
"scope": null,
"escapedName": "ap",
"name": "ap",
"rawSpec": "~0.2.0",
"spec": ">=0.2.0 <0.3.0",
"type": "range"
},
"_requiredBy": [
"/pg-types"
],
"_resolved": "https://registry.npmjs.org/ap/-/ap-0.2.0.tgz",
"_shasum": "ae0942600b29912f0d2b14ec60c45e8f330b6110",
"_shrinkwrap": null,
"_spec": "ap@~0.2.0",
"_where": "C:\\Users\\Giuliano\\Desktop\\nasaproject\\node_modules\\pg-types",
"author": {
"name": "James Halliday",
"email": "mail@substack.net",
"url": "http://substack.net"
},
"bugs": {
"url": "https://github.com/substack/node-ap/issues"
},
"dependencies": {},
"description": "Currying in javascript. Like .bind() without also setting `this`.",
"devDependencies": {
"tap": "0.2.5"
},
"directories": {
"example": "./examples"
},
"dist": {
"shasum": "ae0942600b29912f0d2b14ec60c45e8f330b6110",
"tarball": "https://registry.npmjs.org/ap/-/ap-0.2.0.tgz"
},
"engine": {
"node": ">=0.4.0"
},
"homepage": "https://github.com/substack/node-ap#readme",
"keywords": [
"curry",
"apply",
"ap",
"bind",
"function",
"functional"
],
"license": "MIT/X11",
"main": "./index.js",
"maintainers": [
{
"name": "substack",
"email": "mail@substack.net"
}
],
"name": "ap",
"optionalDependencies": {},
"readme": "ap\n==\n\n`Function.prototype.bind` sets `this` which is super annoying if you just want\nto do currying over arguments while passing `this` through.\n\nInstead you can do:\n\n``` js\nvar ap = require('ap');\nvar z = ap([3], function (x, y) {\n return this.z * (x * 2 + y);\n}).call({ z : 10 }, 4);\nconsole.log(z);\n```\n\n***\n\n```\n100\n```\n\nmethods\n=======\n\n``` js\nvar ap = require('ap')\n```\n\n## ap(args, fn)\n\nFill in the arguments `args` at the beginning of `fn`'s arguments list.\n\n## ap.pa(args, fn)\n\nFill in the arguments `args` at the end of `fn`'s arguments list.\n\n## ap.apa(left, right, fn)\n\nFill in `left` arguments starting from the beginning of `fn`'s argument list and\n`right` arguments starting from the end.\n\n## ap.partial(fn, args...)\n\nFill in `fn`'s arguments with `args...` from the beginning of `fn`'s arguments\nlist.\n\n## ap.partialRight(fn, args...)\n\nFill in `fn`'s arguments with `args...` starting from the end of `fn`'s\narguments list.\n\n## ap.curry(fn, args...)\n\nCurry `fn`, returning a new function with `args...` partially applied from the\nbeginning of `fn`'s arguments list.\n\n## ap.curryRight(fn, args...)\n\nCurry `fn` returning a new function with `args...` partially applied from the\nend of `fn`'s arguments list.\n",
"readmeFilename": "README.markdown",
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/substack/node-ap.git"
},
"scripts": {
"test": "tap ./test"
},
"version": "0.2.0"
}
var test = require("tap").test;
var ap = require('../');
var pa = ap.pa;
var apa = ap.apa;
var partial = ap.partial;
var partialRight = ap.partialRight;
var curry = ap.curry;
var curryRight = ap.curryRight;
function one(x, y) {
return x * 2 + y
}
function two(x, y, z, w) {
return x * 2 + (y + z) * w
}
function three(x, y) {
return this.z * (x * 2 + y)
}
var z = {
z: 10
};
test("ap function", function (t) {
var apOne = ap([3], one);
t.equal(apOne(4),
3 * 2 + 4);
var apTwo = ap([3,4], two);
t.equal(apTwo(5, 6),
3 * 2 + (4 + 5) * 6);
var apThree = ap([3], three);
t.equal(apThree.call(z, 4),
10 * (3 * 2 + 4));
t.end();
});
test("pa function", function (t) {
var paOne = pa([3], one);
t.equal(paOne(4),
4 * 2 + 3);
var paTwo = pa([3,4], two);
t.equal(paTwo(5, 6),
5 * 2 + (6 + 3) * 4);
var paThree = pa([3], three);
t.equal(paThree.call(z, 4),
10 * (4 * 2 + 3));
t.end();
});
test("apa function", function (t) {
var apaOne = apa([3], [4], one);
t.equal(apaOne(),
3 * 2 + 4);
var apaTwo = apa([3], [4], two);
t.equal(apaTwo(5, 6),
3 * 2 + (5 + 6) * 4);
var apaThree = apa([3], [4], three);
t.equal(apaThree.call(z),
10 * (3 * 2 + 4));
t.end();
});
test("partial function", function (t) {
var apOne = partial(one, 3);
t.equal(apOne(4),
3 * 2 + 4);
var apTwo = partial(two, 3, 4);
t.equal(apTwo(5, 6),
3 * 2 + (4 + 5) * 6);
var apThree = partial(three, 3);
t.equal(apThree.call(z, 4),
10 * (3 * 2 + 4));
t.end();
});
test("partialRight function", function (t) {
var paOne = partialRight(one, 3);
t.equal(paOne(4),
4 * 2 + 3);
var paTwo = partialRight(two, 3, 4);
t.equal(paTwo(5, 6),
5 * 2 + (6 + 3) * 4);
var paThree = partialRight(three, 3);
t.equal(paThree.call(z, 4),
10 * (4 * 2 + 3));
t.end();
});
test("curry function", function (t) {
var apOne = curry(one)(3);
t.equal(apOne(4),
3 * 2 + 4, "curry one");
var apTwo = curry(two)(3, 4);
t.equal(apTwo(5, 6),
3 * 2 + (4 + 5) * 6, "curry two");
var apThree = curry(three)(3);
t.equal(apThree.call(z, 4),
10 * (3 * 2 + 4), "curry three");
t.end();
});
test("curryRight function", function (t) {
var paOne = curryRight(one)(3);
t.equal(paOne(4),
4 * 2 + 3);
var paTwo = curryRight(two)(3, 4);
t.equal(paTwo(5, 6),
5 * 2 + (6 + 3) * 4);
var paThree = curryRight(three)(3);
t.equal(paThree.call(z, 4),
10 * (4 * 2 + 3));
t.end();
});
The MIT License (MIT)
Copyright (c) 2014-2017, Jon Schlinkert
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
# arr-diff [![NPM version](https://img.shields.io/npm/v/arr-diff.svg?style=flat)](https://www.npmjs.com/package/arr-diff) [![NPM monthly downloads](https://img.shields.io/npm/dm/arr-diff.svg?style=flat)](https://npmjs.org/package/arr-diff) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/arr-diff.svg?style=flat&label=Travis)](https://travis-ci.org/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.
## Install
Install with [npm](https://www.npmjs.com/):
```sh
$ npm install --save arr-diff
```
Install with [yarn](https://yarnpkg.com):
```sh
$ yarn add arr-diff
```
Install with [bower](https://bower.io/)
```sh
$ bower install arr-diff --save
```
## Usage
Returns the difference between the first array and additional arrays.
```js
var diff = require('arr-diff');
var a = ['a', 'b', 'c', 'd'];
var b = ['b', 'c'];
console.log(diff(a, b))
//=> ['a', 'd']
```
## Benchmarks
This library versus [array-differ](https://github.com/sindresorhus/array-differ), on April 14, 2017:
```
Benchmarking: (4 of 4)
· long-dupes
· long
· med
· short
# benchmark/fixtures/long-dupes.js (100804 bytes)
arr-diff-3.0.0 x 822 ops/sec ±0.67% (86 runs sampled)
arr-diff-4.0.0 x 2,141 ops/sec ±0.42% (89 runs sampled)
array-differ x 708 ops/sec ±0.70% (89 runs sampled)
fastest is arr-diff-4.0.0
# benchmark/fixtures/long.js (94529 bytes)
arr-diff-3.0.0 x 882 ops/sec ±0.60% (87 runs sampled)
arr-diff-4.0.0 x 2,329 ops/sec ±0.97% (83 runs sampled)
array-differ x 769 ops/sec ±0.61% (90 runs sampled)
fastest is arr-diff-4.0.0
# benchmark/fixtures/med.js (708 bytes)
arr-diff-3.0.0 x 856,150 ops/sec ±0.42% (89 runs sampled)
arr-diff-4.0.0 x 4,665,249 ops/sec ±1.06% (89 runs sampled)
array-differ x 653,888 ops/sec ±1.02% (86 runs sampled)
fastest is arr-diff-4.0.0
# benchmark/fixtures/short.js (60 bytes)
arr-diff-3.0.0 x 3,078,467 ops/sec ±0.77% (93 runs sampled)
arr-diff-4.0.0 x 9,213,296 ops/sec ±0.65% (89 runs sampled)
array-differ x 1,337,051 ops/sec ±0.91% (92 runs sampled)
fastest is arr-diff-4.0.0
```
## About
### 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 "Recursively flatten an array or arrays. This is the fastest implementation of array flatten.")
* [array-filter](https://www.npmjs.com/package/array-filter): Array#filter for older browsers. | [homepage](https://github.com/juliangruber/array-filter "Array#filter for older browsers.")
* [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://github.com/jonschlinkert/array-intersection) | [homepage](https://github.com/jonschlinkert/array-intersection "Return an array with the unique values present in _all_ given arrays using strict equality for comparisons.")
### Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
### Contributors
| **Commits** | **Contributor** |
| --- | --- |
| 33 | [jonschlinkert](https://github.com/jonschlinkert) |
| 2 | [paulmillr](https://github.com/paulmillr) |
### Building docs
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
To generate the readme, run the following command:
```sh
$ npm install -g verbose/verb#dev verb-generate-readme && verb
```
### Running tests
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
```sh
$ npm install && npm test
```
### Author
**Jon Schlinkert**
* [github/jonschlinkert](https://github.com/jonschlinkert)
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
### License
Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT License](LICENSE).
***
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.5.0, on April 14, 2017._
\ No newline at end of file
/*!
* arr-diff <https://github.com/jonschlinkert/arr-diff>
*
* Copyright (c) 2014-2017, Jon Schlinkert.
* Released under the MIT License.
*/
'use strict';
module.exports = function diff(arr/*, arrays*/) {
var len = arguments.length;
var idx = 0;
while (++idx < len) {
arr = diffArray(arr, arguments[idx]);
}
return arr;
};
function diffArray(one, two) {
if (!Array.isArray(two)) {
return one.slice();
}
var tlen = two.length
var olen = one.length;
var idx = -1;
var arr = [];
while (++idx < olen) {
var ele = one[idx];
var hasEle = false;
for (var i = 0; i < tlen; i++) {
var val = two[i];
if (ele === val) {
hasEle = true;
break;
}
}
if (hasEle === false) {
arr.push(ele);
}
}
return arr;
}
{
"_from": "arr-diff@^4.0.0",
"_id": "arr-diff@4.0.0",
"_inBundle": false,
"_integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=",
"_location": "/arr-diff",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "arr-diff@^4.0.0",
"name": "arr-diff",
"escapedName": "arr-diff",
"rawSpec": "^4.0.0",
"saveSpec": null,
"fetchSpec": "^4.0.0"
},
"_requiredBy": [
"/micromatch",
"/nanomatch"
],
"_resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz",
"_shasum": "d6461074febfec71e7e15235761a329a5dc7c520",
"_spec": "arr-diff@^4.0.0",
"_where": "/Users/Chorthip/Documents/GitKraken/nasaproject/node_modules/micromatch",
"author": {
"name": "Jon Schlinkert",
"url": "https://github.com/jonschlinkert"
},
"bugs": {
"url": "https://github.com/jonschlinkert/arr-diff/issues"
},
"bundleDependencies": false,
"contributors": [
{
"name": "Jon Schlinkert",
"email": "jon.schlinkert@sellside.com",
"url": "http://twitter.com/jonschlinkert"
},
{
"name": "Paul Miller",
"email": "paul+gh@paulmillr.com",
"url": "paulmillr.com"
}
],
"dependencies": {},
"deprecated": false,
"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": {
"ansi-bold": "^0.1.1",
"arr-flatten": "^1.0.1",
"array-differ": "^1.0.0",
"benchmarked": "^0.2.4",
"gulp-format-md": "^0.1.9",
"minimist": "^1.2.0",
"mocha": "^2.4.5"
},
"engines": {
"node": ">=0.10.0"
},
"files": [
"index.js"
],
"homepage": "https://github.com/jonschlinkert/arr-diff",
"keywords": [
"arr",
"array",
"array differ",
"array-differ",
"diff",
"differ",
"difference"
],
"license": "MIT",
"main": "index.js",
"name": "arr-diff",
"repository": {
"type": "git",
"url": "git+https://github.com/jonschlinkert/arr-diff.git"
},
"scripts": {
"test": "mocha"
},
"verb": {
"toc": false,
"layout": "default",
"tasks": [
"readme"
],
"plugins": [
"gulp-format-md"
],
"related": {
"list": [
"arr-flatten",
"array-filter",
"array-intersection"
]
},
"reflinks": [
"array-differ",
"verb"
],
"lint": {
"reflinks": true
}
},
"version": "4.0.0"
}
The MIT License (MIT)
Copyright (c) 2014-2017, Jon Schlinkert.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
# arr-flatten [![NPM version](https://img.shields.io/npm/v/arr-flatten.svg?style=flat)](https://www.npmjs.com/package/arr-flatten) [![NPM monthly downloads](https://img.shields.io/npm/dm/arr-flatten.svg?style=flat)](https://npmjs.org/package/arr-flatten) [![NPM total downloads](https://img.shields.io/npm/dt/arr-flatten.svg?style=flat)](https://npmjs.org/package/arr-flatten) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/arr-flatten.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/arr-flatten) [![Windows Build Status](https://img.shields.io/appveyor/ci/jonschlinkert/arr-flatten.svg?style=flat&label=AppVeyor)](https://ci.appveyor.com/project/jonschlinkert/arr-flatten)
> Recursively flatten an array or arrays.
## Install
Install with [npm](https://www.npmjs.com/):
```sh
$ npm install --save arr-flatten
```
## Install
Install with [bower](https://bower.io/)
```sh
$ bower install arr-flatten --save
```
## Usage
```js
var flatten = require('arr-flatten');
flatten(['a', ['b', ['c']], 'd', ['e']]);
//=> ['a', 'b', 'c', 'd', 'e']
```
## 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%.
## About
### Related projects
* [arr-filter](https://www.npmjs.com/package/arr-filter): Faster alternative to javascript's native filter method. | [homepage](https://github.com/jonschlinkert/arr-filter "Faster alternative to javascript's native filter method.")
* [arr-union](https://www.npmjs.com/package/arr-union): Combines a list of arrays, returning a single array with unique values, using strict equality… [more](https://github.com/jonschlinkert/arr-union) | [homepage](https://github.com/jonschlinkert/arr-union "Combines a list of arrays, returning a single array with unique values, using strict equality for comparisons.")
* [array-each](https://www.npmjs.com/package/array-each): Loop over each item in an array and call the given function on every element. | [homepage](https://github.com/jonschlinkert/array-each "Loop over each item in an array and call the given function on every element.")
* [array-unique](https://www.npmjs.com/package/array-unique): Remove duplicate values from an array. Fastest ES5 implementation. | [homepage](https://github.com/jonschlinkert/array-unique "Remove duplicate values from an array. Fastest ES5 implementation.")
### Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
### Contributors
| **Commits** | **Contributor** |
| --- | --- |
| 20 | [jonschlinkert](https://github.com/jonschlinkert) |
| 1 | [lukeed](https://github.com/lukeed) |
### Building docs
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
To generate the readme, run the following command:
```sh
$ npm install -g verbose/verb#dev verb-generate-readme && verb
```
### Running tests
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
```sh
$ npm install && npm test
```
### Author
**Jon Schlinkert**
* [github/jonschlinkert](https://github.com/jonschlinkert)
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
### License
Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT License](LICENSE).
***
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on July 05, 2017._
\ No newline at end of file
/*!
* arr-flatten <https://github.com/jonschlinkert/arr-flatten>
*
* Copyright (c) 2014-2017, Jon Schlinkert.
* Released under the MIT License.
*/
'use strict';
module.exports = function (arr) {
return flat(arr, []);
};
function flat(arr, res) {
var i = 0, cur;
var len = arr.length;
for (; i < len; i++) {
cur = arr[i];
Array.isArray(cur) ? flat(cur, res) : res.push(cur);
}
return res;
}
{
"_from": "arr-flatten@^1.1.0",
"_id": "arr-flatten@1.1.0",
"_inBundle": false,
"_integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==",
"_location": "/arr-flatten",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "arr-flatten@^1.1.0",
"name": "arr-flatten",
"escapedName": "arr-flatten",
"rawSpec": "^1.1.0",
"saveSpec": null,
"fetchSpec": "^1.1.0"
},
"_requiredBy": [
"/braces"
],
"_resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz",
"_shasum": "36048bbff4e7b47e136644316c99669ea5ae91f1",
"_spec": "arr-flatten@^1.1.0",
"_where": "/Users/Chorthip/Documents/GitKraken/nasaproject/node_modules/braces",
"author": {
"name": "Jon Schlinkert",
"url": "https://github.com/jonschlinkert"
},
"bugs": {
"url": "https://github.com/jonschlinkert/arr-flatten/issues"
},
"bundleDependencies": false,
"contributors": [
{
"name": "Jon Schlinkert",
"url": "http://twitter.com/jonschlinkert"
},
{
"name": "Luke Edwards",
"url": "https://lukeed.com"
}
],
"deprecated": false,
"description": "Recursively flatten an array or arrays.",
"devDependencies": {
"ansi-bold": "^0.1.1",
"array-flatten": "^2.1.1",
"array-slice": "^1.0.0",
"benchmarked": "^1.0.0",
"compute-flatten": "^1.0.0",
"flatit": "^1.1.1",
"flatten": "^1.0.2",
"flatten-array": "^1.0.0",
"glob": "^7.1.1",
"gulp-format-md": "^0.1.12",
"just-flatten-it": "^1.1.23",
"lodash.flattendeep": "^4.4.0",
"m_flattened": "^1.0.1",
"mocha": "^3.2.0",
"utils-flatten": "^1.0.0",
"write": "^0.3.3"
},
"engines": {
"node": ">=0.10.0"
},
"files": [
"index.js"
],
"homepage": "https://github.com/jonschlinkert/arr-flatten",
"keywords": [
"arr",
"array",
"elements",
"flat",
"flatten",
"nested",
"recurse",
"recursive",
"recursively"
],
"license": "MIT",
"main": "index.js",
"name": "arr-flatten",
"repository": {
"type": "git",
"url": "git+https://github.com/jonschlinkert/arr-flatten.git"
},
"scripts": {
"test": "mocha"
},
"verb": {
"toc": false,
"layout": "default",
"tasks": [
"readme"
],
"plugins": [
"gulp-format-md"
],
"related": {
"list": [
"arr-filter",
"arr-union",
"array-each",
"array-unique"
]
},
"lint": {
"reflinks": true
}
},
"version": "1.1.0"
}
The MIT License (MIT)
Copyright (c) 2014-2016, Jon Schlinkert.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
# arr-union [![NPM version](https://img.shields.io/npm/v/arr-union.svg)](https://www.npmjs.com/package/arr-union) [![Build Status](https://img.shields.io/travis/jonschlinkert/arr-union.svg)](https://travis-ci.org/jonschlinkert/arr-union)
> Combines a list of arrays, returning a single array with unique values, using strict equality for comparisons.
## Install
Install with [npm](https://www.npmjs.com/):
```sh
$ npm i arr-union --save
```
## Benchmarks
This library is **10-20 times faster** and more performant than [array-union](https://github.com/sindresorhus/array-union).
See the [benchmarks](./benchmark).
```sh
#1: five-arrays
array-union x 511,121 ops/sec ±0.80% (96 runs sampled)
arr-union x 5,716,039 ops/sec ±0.86% (93 runs sampled)
#2: ten-arrays
array-union x 245,196 ops/sec ±0.69% (94 runs sampled)
arr-union x 1,850,786 ops/sec ±0.84% (97 runs sampled)
#3: two-arrays
array-union x 563,869 ops/sec ±0.97% (94 runs sampled)
arr-union x 9,602,852 ops/sec ±0.87% (92 runs sampled)
```
## Usage
```js
var union = require('arr-union');
union(['a'], ['b', 'c'], ['d', 'e', 'f']);
//=> ['a', 'b', 'c', 'd', 'e', 'f']
```
Returns only unique elements:
```js
union(['a', 'a'], ['b', 'c']);
//=> ['a', 'b', 'c']
```
## Related projects
* [arr-diff](https://www.npmjs.com/package/arr-diff): Returns an array with only the unique values from the first array, by excluding all… [more](https://www.npmjs.com/package/arr-diff) | [homepage](https://github.com/jonschlinkert/arr-diff)
* [arr-filter](https://www.npmjs.com/package/arr-filter): Faster alternative to javascript's native filter method. | [homepage](https://github.com/jonschlinkert/arr-filter)
* [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)
* [arr-map](https://www.npmjs.com/package/arr-map): Faster, node.js focused alternative to JavaScript's native array map. | [homepage](https://github.com/jonschlinkert/arr-map)
* [arr-pluck](https://www.npmjs.com/package/arr-pluck): Retrieves the value of a specified property from all elements in the collection. | [homepage](https://github.com/jonschlinkert/arr-pluck)
* [arr-reduce](https://www.npmjs.com/package/arr-reduce): Fast array reduce that also loops over sparse elements. | [homepage](https://github.com/jonschlinkert/arr-reduce)
* [array-unique](https://www.npmjs.com/package/array-unique): Return an array free of duplicate values. Fastest ES5 implementation. | [homepage](https://github.com/jonschlinkert/array-unique)
## Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/arr-union/issues/new).
## Building docs
Generate readme and API documentation with [verb](https://github.com/verbose/verb):
```sh
$ npm i verb && npm run docs
```
Or, if [verb](https://github.com/verbose/verb) is installed globally:
```sh
$ verb
```
## Running tests
Install dev dependencies:
```sh
$ npm i -d && npm test
```
## Author
**Jon Schlinkert**
* [github/jonschlinkert](https://github.com/jonschlinkert)
* [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
## License
Copyright © 2016 [Jon Schlinkert](https://github.com/jonschlinkert)
Released under the [MIT license](https://github.com/jonschlinkert/arr-union/blob/master/LICENSE).
***
_This file was generated by [verb](https://github.com/verbose/verb), v0.9.0, on February 23, 2016._
\ No newline at end of file
'use strict';
module.exports = function union(init) {
if (!Array.isArray(init)) {
throw new TypeError('arr-union expects the first argument to be an array.');
}
var len = arguments.length;
var i = 0;
while (++i < len) {
var arg = arguments[i];
if (!arg) continue;
if (!Array.isArray(arg)) {
arg = [arg];
}
for (var j = 0; j < arg.length; j++) {
var ele = arg[j];
if (init.indexOf(ele) >= 0) {
continue;
}
init.push(ele);
}
}
return init;
};
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment