diff options
Diffstat (limited to 'school/node_modules/@arr')
-rw-r--r-- | school/node_modules/@arr/every/index.js | 11 | ||||
-rw-r--r-- | school/node_modules/@arr/every/module.d.ts | 1 | ||||
-rw-r--r-- | school/node_modules/@arr/every/module.js | 11 | ||||
-rw-r--r-- | school/node_modules/@arr/every/package.json | 30 | ||||
-rw-r--r-- | school/node_modules/@arr/every/readme.md | 45 |
5 files changed, 98 insertions, 0 deletions
diff --git a/school/node_modules/@arr/every/index.js b/school/node_modules/@arr/every/index.js new file mode 100644 index 0000000..170cc49 --- /dev/null +++ b/school/node_modules/@arr/every/index.js @@ -0,0 +1,11 @@ +module.exports = function (arr, cb) { + var i=0, len=arr.length; + + for (; i < len; i++) { + if (!cb(arr[i], i, arr)) { + return false; + } + } + + return true; +} diff --git a/school/node_modules/@arr/every/module.d.ts b/school/node_modules/@arr/every/module.d.ts new file mode 100644 index 0000000..f2935dc --- /dev/null +++ b/school/node_modules/@arr/every/module.d.ts @@ -0,0 +1 @@ +export default function<T>(arr: T[], callback: (val: T, idx: number, arr: T[]) => unknown): boolean; diff --git a/school/node_modules/@arr/every/module.js b/school/node_modules/@arr/every/module.js new file mode 100644 index 0000000..18a4208 --- /dev/null +++ b/school/node_modules/@arr/every/module.js @@ -0,0 +1,11 @@ +export default function (arr, cb) { + var i=0, len=arr.length; + + for (; i < len; i++) { + if (!cb(arr[i], i, arr)) { + return false; + } + } + + return true; +} diff --git a/school/node_modules/@arr/every/package.json b/school/node_modules/@arr/every/package.json new file mode 100644 index 0000000..b82e2cc --- /dev/null +++ b/school/node_modules/@arr/every/package.json @@ -0,0 +1,30 @@ +{ + "name": "@arr/every", + "version": "1.0.1", + "repository": "lukeed/arr", + "description": "A tiny, faster alternative to native Array.prototype.every", + "types": "module.d.ts", + "module": "module.js", + "main": "index.js", + "license": "MIT", + "author": { + "name": "Luke Edwards", + "email": "luke.edwards05@gmail.com", + "url": "https://lukeed.com" + }, + "engines": { + "node": ">=4" + }, + "keywords": [ + "arr", + "array", + "Array.every", + "Array.prototype.every", + "performance", + "native", + "every" + ], + "publishConfig": { + "access": "public" + } +} diff --git a/school/node_modules/@arr/every/readme.md b/school/node_modules/@arr/every/readme.md new file mode 100644 index 0000000..31cad87 --- /dev/null +++ b/school/node_modules/@arr/every/readme.md @@ -0,0 +1,45 @@ +# @arr/every + +> A tiny, faster alternative to native `Array.prototype.every` + +:warning: Unlike native, `@arr/every` does _not_ support the optional `thisArg` parameter! + +## Install + +``` +$ npm install --save @arr/every +``` + +## Usage + +```js +import every from '@arr/every'; + +const isBigEnough = val => val >= 10; + +every([12, 5, 8, 130, 44], isBigEnough); +//=> false +every([12, 54, 18, 130, 44], isBigEnough); +//=> true +``` + +## API + +### every(arr, callback) + +#### arr +Type: `Array`<br> +The array to iterate upon. + +#### callback(value[, index, array]) +Type: `Function`<br> +Function to test for each element, taking three arguments: + +* **value** (required) -- The current element being processed in the array. +* **index** (optional) -- The index of the current element being processed in the array. +* **array** (optional) -- The array `every` was called upon. + + +## License + +MIT © [Luke Edwards](http://lukeed.com) |