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.32.2 to 0.33.0

docs/arrays/findIndex.md

29

dist/absurdum.cjs.js

@@ -264,2 +264,30 @@ 'use strict';

/**
* FindIndex method returns the value of First element at which a provided function is true,
* or -1 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.findIndex([5, 12, 8, 130, 44], (x) => x < 10);
* console.log(result);
* > 0
* @example
* const result = arrays.findIndex([5, 174, 8, 130, 44], function(x) { return x > this }, 100);
* console.log(result);
* > 1
*/
function findIndex (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'); }
return array.reduce((res, cur, i) => {
if (res < 0 && predicate.call(thisArg, cur)) return i;
return res;
}, -1);
}
/**
* FindLastIndex method returns the value of Last element at which a provided function is true,

@@ -550,2 +578,3 @@ * or undefined if no elements in the array satisfy the function.

find: find,
findIndex: findIndex,
findLastIndex: findLastIndex,

@@ -552,0 +581,0 @@ flat: flat,

@@ -260,2 +260,30 @@ /**

/**
* FindIndex method returns the value of First element at which a provided function is true,
* or -1 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.findIndex([5, 12, 8, 130, 44], (x) => x < 10);
* console.log(result);
* > 0
* @example
* const result = arrays.findIndex([5, 174, 8, 130, 44], function(x) { return x > this }, 100);
* console.log(result);
* > 1
*/
function findIndex (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'); }
return array.reduce((res, cur, i) => {
if (res < 0 && predicate.call(thisArg, cur)) return i;
return res;
}, -1);
}
/**
* FindLastIndex method returns the value of Last element at which a provided function is true,

@@ -546,2 +574,3 @@ * or undefined if no elements in the array satisfy the function.

find: find,
findIndex: findIndex,
findLastIndex: findLastIndex,

@@ -548,0 +577,0 @@ flat: flat,

2

package.json
{
"name": "absurdum",
"version": "0.32.2",
"version": "0.33.0",
"description": "Reductio Ad Absurdum - The Ridiculous Application of Reduce",

@@ -5,0 +5,0 @@ "keywords": [

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

- [find][arrays.find]
- [findIndex][arrays.findIndex]
- [findLastIndex][arrays.findLastIndex]

@@ -82,2 +83,3 @@ - [flat][arrays.flat]

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

@@ -84,0 +86,0 @@ [arrays.flat]: ./docs/arrays/flat.md

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

export { find } from "./find.js";
export { findIndex } from "./findIndex.js";
export { findLastIndex } from "./findLastIndex.js";

@@ -13,0 +14,0 @@ export { flat } from "./flat.js";

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

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

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

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