Comparing version 0.19.2 to 0.19.3
@@ -1,2 +0,3 @@ | ||
export * as arrays from './src/arrays/index.js'; | ||
export * as strings from './src/strings/index.js'; | ||
import * as arrays from './src/arrays/index.js'; | ||
import * as strings from './src/strings/index.js'; | ||
export { arrays, strings }; |
{ | ||
"name": "absurdum", | ||
"version": "0.19.2", | ||
"version": "0.19.3", | ||
"description": "Reducio Ad Absurdum - The Riduculous Application of Reduce", | ||
@@ -22,4 +22,5 @@ "keywords": [ | ||
"lint": "semistandard", | ||
"types": "npx tsc --checkJs", | ||
"package": "npx rimraf package && npm pack | tail -n 1 | xargs tar -xf", | ||
"preversion": "npm test && npm run lint", | ||
"preversion": "npm test && npm run lint && npm run types", | ||
"postversion": "git push --follow-tags" | ||
@@ -29,2 +30,3 @@ }, | ||
"devDependencies": { | ||
"@types/tape": "^4.2.33", | ||
"docdown": "github:evanplaice/docdown", | ||
@@ -31,0 +33,0 @@ "glob": "^7.1.4", |
@@ -14,6 +14,6 @@ /** | ||
function difference (array, values) { | ||
values = new Set(values); | ||
const uniqueValues = new Set(values); | ||
return array.reduce((acc, curr) => { | ||
if (!values.has(curr)) { | ||
if (!uniqueValues.has(curr)) { | ||
acc.push(curr); | ||
@@ -20,0 +20,0 @@ } |
@@ -7,3 +7,3 @@ /** | ||
* @param {number} [start=0] | ||
* @param {number} end | ||
* @param {number} [end] | ||
* @returns {Array} The filled array | ||
@@ -16,4 +16,4 @@ * | ||
*/ | ||
function fill (array, value, start = 0, end) { | ||
if (!end) { | ||
function fill (array, value, start = 0, end = null) { | ||
if (end === null) { | ||
end = array.length - 1; | ||
@@ -20,0 +20,0 @@ } |
@@ -19,3 +19,11 @@ /** | ||
function endsWith (string, substr = '') { | ||
return string.split('').reduce((acc, curr, idx, arr) => { | ||
/** | ||
* @private | ||
* @param {*} acc output accumulator | ||
* @param {*} curr the value of the current iteration | ||
* @param {number} [idx] the index of the current iteration | ||
* @param {*[]} [arr] reference to the input array | ||
* @returns | ||
*/ | ||
const reducer = (acc, curr, idx, arr) => { | ||
// exit early on mismatch | ||
@@ -32,5 +40,7 @@ if (arr[arr.length - idx - 1] !== substr[substr.length - idx - 1]) { | ||
return acc; | ||
}, null); | ||
}; | ||
return string.split('').reduce(reducer, null); | ||
} | ||
export { endsWith }; |
@@ -31,5 +31,5 @@ /** | ||
let substrIdx = 0; | ||
string = [...string, ...Array(padLen)]; | ||
const stringArr = [...string, ...Array(padLen)]; | ||
return string.reduce((acc, curr, idx, arr) => { | ||
const reducer = (acc, curr, idx, arr) => { | ||
if (strLen !== 0) { | ||
@@ -43,5 +43,7 @@ acc.push(curr); | ||
return acc; | ||
}, []).join(''); | ||
}; | ||
return stringArr.reduce(reducer, []).join(''); | ||
} | ||
export { padEnd }; |
@@ -30,5 +30,5 @@ /** | ||
let substrIdx = 0; | ||
string = [...Array(padLen), ...string]; | ||
const stringArr = [...Array(padLen), ...string]; | ||
return string.reduce((acc, curr, idx, arr) => { | ||
const reducer = (acc, curr, idx, arr) => { | ||
if (padLen !== 0) { | ||
@@ -42,5 +42,7 @@ acc.push(substr[substrIdx]); | ||
return acc; | ||
}, []).join(''); | ||
}; | ||
return stringArr.reduce(reducer, []).join(''); | ||
} | ||
export { padStart }; |
@@ -20,3 +20,4 @@ /** | ||
let chars = string.split(''); | ||
return chars.reduce((acc, curr, idx, arr) => { | ||
const reducer = (acc, curr, idx, arr) => { | ||
// exit early on mismatch | ||
@@ -33,5 +34,7 @@ if (curr !== substr[idx]) { | ||
return acc; | ||
}, null); | ||
}; | ||
return chars.reduce(reducer, null); | ||
} | ||
export { startsWith }; |
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
40048
51
936
5