The `first-match` package provides a utility function to find the first element in an array that satisfies a given callback test. If no iterator is provided, it returns the first truthy value encountered in the array. This functionality is directly equivalent to what was historically offered by `underscore.find()` and is now standard in modern JavaScript environments via `Array.prototype.find()`. The package is at version 0.0.1, indicating an early development stage, and has effectively been abandoned given the ubiquitous availability of native array methods and the lack of updates over a significant period. Its primary differentiating factor might have been its minimal footprint before native alternatives were widely adopted, but it offers no unique advantages over current standard practices. Its release cadence is effectively zero.
npm install first-matchVerified import paths — ran on the pinned version, not inferred.
Demonstrates `first-match` finding the first truthy value, numbers matching a condition, and utilizing the optional `context` parameter for the iterator function, while also comparing it to modern `Array.prototype.find`.
Replace calls to `first(array, iterator)` with `array.find(iterator)`. For example, `first([1,2,3], n => n > 1)` becomes `[1,2,3].find(n => n > 1)`.
If you absolutely must use this package in an ESM context, consider dynamic import (`import('first-match').then(module => module(...))`) or a CommonJS wrapper if using Node.js, but prefer native `Array.prototype.find()` instead.Migrate to `Array.prototype.find()` or a well-maintained utility library like Lodash's `_.find()`.
Ensure you are using `const first = require('first-match')` in a CommonJS environment. If in an ESM environment, use `Array.prototype.find()` instead.Add `const first = require('first-match');` at the top of your CommonJS file where `first` is used. For ESM, refer to `warnings` and switch to `Array.prototype.find()`.No dependency data recorded yet.