Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

absurdum

Package Overview
Dependencies
Maintainers
1
Versions
177
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

absurdum - npm Package Compare versions

Comparing version 0.26.0 to 0.27.0

docs/arrays/findLastIndex.md

47

dist/absurdum.cjs.js

@@ -242,3 +242,3 @@ 'use strict';

* @param {Function} predicate to be run against each element of the array
* @param {*} thisArg of this
* @param {*} [thisArg=undefined] of this
* @returns {*} value of element that satisfied function.

@@ -269,2 +269,33 @@ * @example

/**
* FindLastIndex method returns the value of Last element at which a provided function is true,
* or undefined if no elements in the array satisfy the function.
*
* @param {Array} array input array
* @param {Function} predicate to be run against each element of the array
* @param {*} [thisArg=undefined]
* @returns {*} value of element that satisfied function.
* @example
* const result = arrays.findLastIndex([5, 12, 8, 130, 44], (x) => x < 10);
* console.log(result);
* > 2
* @example
* const result = arrays.findLastIndex([5, 174, 8, 130, 44], function(x) { return x > this }, 100);
* console.log(result);
* > 3
*/
function findLastIndex (array, predicate, thisArg = undefined) {
if (array.length === 0) return -1;
if (this == null) { throw TypeError('"this" is null or not defined'); }
if (typeof predicate !== 'function') { throw TypeError('predicate must be a function'); }
if (predicate.call(thisArg, array[array.length - 1])) return array.length - 1;
if (array.length === 1) return -1;
return array.reduceRight((res, cur, i) => {
if (i === array.length - 2) return predicate.call(thisArg, cur) ? i : -1;
if (res < 0 && predicate.call(thisArg, cur)) return i;
return res;
});
}
/**
* Flattens an array of nested arrays

@@ -298,3 +329,3 @@ *

* @param {number} searchElement to be looked for in the array
* @param {number} start index in array to begin searching for search Element
* @param {number} [start=0] index in array to begin searching for search Element
* @returns {number} a integer representing the first index in the array that contains the element

@@ -405,4 +436,7 @@ * @example

return array.reduce((res, cur, i, arr) => {
if (res === true) { return true; }
return array.slice(0).reduce((res, cur, i, arr) => {
if (res === true) {
arr.splice(0);
return true;
}
if (i === 1) return predicate.call(thisArg, cur);

@@ -441,3 +475,3 @@ if (predicate.call(thisArg, cur)) return true;

* @param {Array} array2 input array
* @param {Function} predicate optional to be applied to corresponding values
* @param {Function} [predicate=(a, b)=>[a, b]] to be applied to corresponding values
* @returns {Array} input array filled value pairs after the function has been applied

@@ -485,2 +519,3 @@ *

find: find,
findLastIndex: findLastIndex,
flat: flat,

@@ -678,3 +713,3 @@ indexOf: indexOf,

* @param {string} substr substring to test
* @returns {string} does the input start with the substring?
* @returns {boolean} does the input start with the substring?
*

@@ -681,0 +716,0 @@ * @example

@@ -238,3 +238,3 @@ /**

* @param {Function} predicate to be run against each element of the array
* @param {*} thisArg of this
* @param {*} [thisArg=undefined] of this
* @returns {*} value of element that satisfied function.

@@ -265,2 +265,33 @@ * @example

/**
* FindLastIndex method returns the value of Last element at which a provided function is true,
* or undefined if no elements in the array satisfy the function.
*
* @param {Array} array input array
* @param {Function} predicate to be run against each element of the array
* @param {*} [thisArg=undefined]
* @returns {*} value of element that satisfied function.
* @example
* const result = arrays.findLastIndex([5, 12, 8, 130, 44], (x) => x < 10);
* console.log(result);
* > 2
* @example
* const result = arrays.findLastIndex([5, 174, 8, 130, 44], function(x) { return x > this }, 100);
* console.log(result);
* > 3
*/
function findLastIndex (array, predicate, thisArg = undefined) {
if (array.length === 0) return -1;
if (this == null) { throw TypeError('"this" is null or not defined'); }
if (typeof predicate !== 'function') { throw TypeError('predicate must be a function'); }
if (predicate.call(thisArg, array[array.length - 1])) return array.length - 1;
if (array.length === 1) return -1;
return array.reduceRight((res, cur, i) => {
if (i === array.length - 2) return predicate.call(thisArg, cur) ? i : -1;
if (res < 0 && predicate.call(thisArg, cur)) return i;
return res;
});
}
/**
* Flattens an array of nested arrays

@@ -294,3 +325,3 @@ *

* @param {number} searchElement to be looked for in the array
* @param {number} start index in array to begin searching for search Element
* @param {number} [start=0] index in array to begin searching for search Element
* @returns {number} a integer representing the first index in the array that contains the element

@@ -401,4 +432,7 @@ * @example

return array.reduce((res, cur, i, arr) => {
if (res === true) { return true; }
return array.slice(0).reduce((res, cur, i, arr) => {
if (res === true) {
arr.splice(0);
return true;
}
if (i === 1) return predicate.call(thisArg, cur);

@@ -437,3 +471,3 @@ if (predicate.call(thisArg, cur)) return true;

* @param {Array} array2 input array
* @param {Function} predicate optional to be applied to corresponding values
* @param {Function} [predicate=(a, b)=>[a, b]] to be applied to corresponding values
* @returns {Array} input array filled value pairs after the function has been applied

@@ -481,2 +515,3 @@ *

find: find,
findLastIndex: findLastIndex,
flat: flat,

@@ -674,3 +709,3 @@ indexOf: indexOf,

* @param {string} substr substring to test
* @returns {string} does the input start with the substring?
* @returns {boolean} does the input start with the substring?
*

@@ -677,0 +712,0 @@ * @example

4

docs/arrays/find.md

@@ -10,3 +10,3 @@ # arrays.find

<h3 id="findarray-predicate-thisarg"><code>find(array, predicate, thisArg)</code></h3>
<h3 id="findarray-predicate-thisargundefined"><code>find(array, predicate, [thisArg=undefined])</code></h3>

@@ -19,3 +19,3 @@ Find method returns the value of first element at which a provided function is true,

2. `predicate` *(Function)*: to be run against each element of the array
3. `thisArg` *(&#42;)*: of this
3. `[thisArg=undefined]` *(&#42;)*: of this

@@ -22,0 +22,0 @@ #### Returns

@@ -10,3 +10,3 @@ # arrays.indexOf

<h3 id="indexofarray-searchelement-start"><code>indexOf(array, searchElement, start)</code></h3>
<h3 id="indexofarray-searchelement-start0"><code>indexOf(array, searchElement, [start=0])</code></h3>

@@ -19,3 +19,3 @@ IndexOf method returns the first index at which a given element can be found in the array

2. `searchElement` *(number)*: to be looked for in the array
3. `start` *(number)*: index in array to begin searching for search Element
3. `[start=0]` *(number)*: index in array to begin searching for search Element

@@ -22,0 +22,0 @@ #### Returns

@@ -10,3 +10,3 @@ # arrays.zip

<h3 id="ziparray1-array2-predicate"><code>zip(array1, array2, predicate)</code></h3>
<h3 id="ziparray1-array2-predicatea-b"><code>zip(array1, array2, [predicate=(a,b)])</code></h3>

@@ -19,3 +19,3 @@ Zip applies a specified function to the corresponding elements of two sequences,

2. `array2` *(Array)*: input array
3. `predicate` *(Function)*: optional to be applied to corresponding values
3. `[predicate=(a,b)]` *(Function)*: to be applied to corresponding values

@@ -22,0 +22,0 @@ #### Returns

@@ -19,3 +19,3 @@ # strings.startsWith

#### Returns
*(string)*: does the input start with the substring?
*(boolean)*: does the input start with the substring?

@@ -22,0 +22,0 @@ #### Example

{
"name": "absurdum",
"version": "0.26.0",
"version": "0.27.0",
"description": "Reductio Ad Absurdum - The Ridiculous Application of Reduce",

@@ -35,3 +35,3 @@ "keywords": [

"preversion": "npm test && npm run lint && npm run types",
"version": "npm run build && git add dist/* && git diff --quiet && git diff --staged --quiet || git commit -am 'Build'",
"version": "npm run build && git add dist/* && git diff --quiet && git diff --staged --quiet || git commit -am 'Bump'",
"postversion": "git push --follow-tags"

@@ -38,0 +38,0 @@ },

@@ -59,2 +59,3 @@ [![GitHub release](https://img.shields.io/github/release/vanillaes/absurdum.svg)](https://github.com/vanillaes/absurdum/releases)

- [find][arrays.find]
- [findLastIndex][arrays.findLastIndex]
- [flat][arrays.flat]

@@ -79,2 +80,3 @@ - [indexOf][arrays.indexOf]

[arrays.find]: ./docs/arrays/find.md
[arrays.findLastIndex]: ./docs/arrays/findLastIndex.md
[arrays.flat]: ./docs/arrays/flat.md

@@ -81,0 +83,0 @@ [arrays.indexOf]: ./docs/arrays/indexOf.md

@@ -7,3 +7,3 @@ /**

* @param {Function} predicate to be run against each element of the array
* @param {*} thisArg of this
* @param {*} [thisArg=undefined] of this
* @returns {*} value of element that satisfied function.

@@ -10,0 +10,0 @@ * @example

@@ -7,6 +7,8 @@ export { chunk } from "./chunk.js";

export { dropRight } from "./dropRight.js";
export { every } from './every.js';
export { every } from "./every.js";
export { fill } from "./fill.js";
export { filter } from "./filter.js";
export { find } from './find.js';
export { find } from "./find.js";
export { findLastIndex } from "./findLastIndex.js";
export { flat } from "./flat.js";
export { indexOf } from "./indexOf.js";

@@ -13,0 +15,0 @@ export { map } from "./map.js";

@@ -11,2 +11,3 @@ export { chunk } from './chunk.js';

export { find } from './find.js';
export { findLastIndex } from './findLastIndex.js';
export { flat } from './flat.js';

@@ -13,0 +14,0 @@ export { indexOf } from './indexOf.js';

@@ -7,3 +7,3 @@ /**

* @param {number} searchElement to be looked for in the array
* @param {number} start index in array to begin searching for search Element
* @param {number} [start=0] index in array to begin searching for search Element
* @returns {number} a integer representing the first index in the array that contains the element

@@ -10,0 +10,0 @@ * @example

@@ -25,4 +25,7 @@ /**

return array.reduce((res, cur, i, arr) => {
if (res === true) { return true; }
return array.slice(0).reduce((res, cur, i, arr) => {
if (res === true) {
arr.splice(0);
return true;
}
if (i === 1) return predicate.call(thisArg, cur);

@@ -29,0 +32,0 @@ if (predicate.call(thisArg, cur)) return true;

@@ -7,3 +7,3 @@ /**

* @param {Array} array2 input array
* @param {Function} predicate optional to be applied to corresponding values
* @param {Function} [predicate=(a, b)=>[a, b]] to be applied to corresponding values
* @returns {Array} input array filled value pairs after the function has been applied

@@ -10,0 +10,0 @@ *

@@ -6,3 +6,3 @@ /**

* @param {string} substr substring to test
* @returns {string} does the input start with the substring?
* @returns {boolean} does the input start with the substring?
*

@@ -9,0 +9,0 @@ * @example

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc