Comparing version 0.19.10 to 0.20.0
@@ -206,2 +206,30 @@ 'use strict'; | ||
/** | ||
* IndexOf method returns the first index at which a given element can be found in the array | ||
* beyond the starting index, or -1 if it is not present. | ||
* | ||
* @param {Array} array | ||
* @param {number} searchElement to be looked for in the array | ||
* @param {number} start index in array to begin searching for search Element | ||
* @returns {number} a integer representing the first index in the array that contains the element | ||
* @example | ||
* const result = arrays.indexOf([1,2,3,4,5,4], 4, 4)); | ||
* console.log(result); | ||
* > 5 | ||
*/ | ||
function indexOf (array, searchElement, start = 0) { | ||
if (array.length === 0) return -1; | ||
if (array[0] === searchElement) return 0; | ||
return array.reduce((res, cur, i) => { | ||
if (i >= start) { | ||
if (i === 1) return cur === searchElement ? 1 : -1; | ||
if (cur === searchElement && res === -1) return i; | ||
return res; | ||
} else { | ||
return -1; | ||
} | ||
}); | ||
} | ||
/** | ||
* Map iterates over an array of values and applies a function to each value | ||
@@ -299,2 +327,3 @@ * | ||
filter: filter, | ||
indexOf: indexOf, | ||
map: map, | ||
@@ -301,0 +330,0 @@ reduceRight: reduceRight, |
@@ -202,2 +202,30 @@ /** | ||
/** | ||
* IndexOf method returns the first index at which a given element can be found in the array | ||
* beyond the starting index, or -1 if it is not present. | ||
* | ||
* @param {Array} array | ||
* @param {number} searchElement to be looked for in the array | ||
* @param {number} start index in array to begin searching for search Element | ||
* @returns {number} a integer representing the first index in the array that contains the element | ||
* @example | ||
* const result = arrays.indexOf([1,2,3,4,5,4], 4, 4)); | ||
* console.log(result); | ||
* > 5 | ||
*/ | ||
function indexOf (array, searchElement, start = 0) { | ||
if (array.length === 0) return -1; | ||
if (array[0] === searchElement) return 0; | ||
return array.reduce((res, cur, i) => { | ||
if (i >= start) { | ||
if (i === 1) return cur === searchElement ? 1 : -1; | ||
if (cur === searchElement && res === -1) return i; | ||
return res; | ||
} else { | ||
return -1; | ||
} | ||
}); | ||
} | ||
/** | ||
* Map iterates over an array of values and applies a function to each value | ||
@@ -295,2 +323,3 @@ * | ||
filter: filter, | ||
indexOf: indexOf, | ||
map: map, | ||
@@ -297,0 +326,0 @@ reduceRight: reduceRight, |
{ | ||
"name": "absurdum", | ||
"version": "0.19.10", | ||
"description": "Reducio Ad Absurdum - The Riduculous Application of Reduce", | ||
"version": "0.20.0", | ||
"description": "Reductio Ad Absurdum - The Ridiculous Application of Reduce", | ||
"keywords": [ | ||
@@ -16,18 +16,22 @@ "functional", | ||
"main": "index.js", | ||
"types": "index.d.ts", | ||
"type": "module", | ||
"scripts": { | ||
"docs": "node --experimental-modules docs.config.js", | ||
"test": "find . -wholename '**/*.spec.js' -not -path './node_modules/*' | xargs -n1 node --experimental-modules", | ||
"test:watch": "npx chokidar-cli -i 'node_modules' 'src/**/*.spec.js' -c 'node --experimental-modules {path}'", | ||
"lint": "semistandard", | ||
"types": "npx tsc -p jsconfig.json", | ||
"typings": "npx tsc -p tsconfig.json", | ||
"build": "npm run clean && npm run build:esm && npm run build:cjs", | ||
"build:esm": "npx rollup --config esm.config.js ", | ||
"build:cjs": "npx rollup --config cjs.config.js", | ||
"clean": "npx rimraf ./dist", | ||
"types": "npx tsc -p .config/jsconfig.json", | ||
"build": "npm run build:esm && npm run build:cjs && npm run build:docs && npm run build:typings", | ||
"build:docs": "node --experimental-modules .config/docs.config.js", | ||
"build:esm": "npx rollup --config .config/esm.config.js ", | ||
"build:cjs": "npx rollup --config .config/cjs.config.js", | ||
"build:typings": "npx tsc -p .config/tsconfig.json", | ||
"clean": "npm run clean:docs && npm run clean:bundles && npm run clean:typings", | ||
"clean:docs": "npx rimraf docs/*.md", | ||
"clean:bundles": "npx rimraf dist/*", | ||
"clean:typings": "npx rimraf src/*.d.ts", | ||
"package": "npx rimraf package && npm pack | tail -n 1 | xargs tar -xf", | ||
"preversion": "npm test && npm run lint && npm run types", | ||
"prepare": "npm run build && git add dist/* && git diff --quiet && git diff --staged --quiet || git commit -am 'Build'", | ||
"postversion": "npm run prepare && git push --follow-tags" | ||
"version": "npm run clean && npm run build && git add dist/* && git diff --quiet && git diff --staged --quiet || git commit -am 'Build'", | ||
"postversion": "git push --follow-tags" | ||
}, | ||
@@ -40,3 +44,3 @@ "dependencies": {}, | ||
"semistandard": "^14.2.0", | ||
"tape": "^4.8.0" | ||
"tape": "^4.11.0" | ||
}, | ||
@@ -43,0 +47,0 @@ "engines": { |
@@ -57,2 +57,3 @@ [![GitHub release](https://img.shields.io/github/release/vanillajs2/absurdum.svg)](https://github.com/vanillajs2/absurdum/releases) | ||
- [filter][arrays.filter] | ||
- [indexOf][arrays.indexOf] | ||
- [map][arrays.map] | ||
@@ -71,2 +72,3 @@ - [reduceRight][arrays.reduceRight] | ||
[arrays.filter]: ./docs/arrays/filter.md | ||
[arrays.indexOf]: ./docs/arrays/indexOf.md | ||
[arrays.map]: ./docs/arrays/map.md | ||
@@ -73,0 +75,0 @@ [arrays.reduceRight]: ./docs/arrays/reduceRight.md |
@@ -1,9 +0,10 @@ | ||
export { chunk } from "./chunk.js"; | ||
export { compact } from "./compact.js"; | ||
export { concat } from "./concat.js"; | ||
export { difference } from "./difference.js"; | ||
export { drop } from "./drop.js"; | ||
export { dropRight } from "./dropRight.js"; | ||
export { fill } from "./fill.js"; | ||
export { chunk } from './chunk.js'; | ||
export { compact } from './compact.js'; | ||
export { concat } from './concat.js'; | ||
export { difference } from './difference.js'; | ||
export { drop } from './drop.js'; | ||
export { dropRight } from './dropRight.js'; | ||
export { fill } from './fill.js'; | ||
export { filter } from './filter.js'; | ||
export { indexOf } from './indexOf.js'; | ||
export { map } from './map.js'; | ||
@@ -10,0 +11,0 @@ export { reduceRight } from './reduceRight.js'; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
65
100
1
66800
1774