Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
indexed-filter
Advanced tools
Array#filter()
with also appending indexes of filtered values to the result
const arr = [1, 'foo', 2, 'bar'];
arr.filter(v => typeof v === 'string');
//=> ['foo', 'bar']
indexedFilter(arr, v => typeof v === 'string');
//=> [{index: 1, value: 'foo'}, {index: 3, value: 'bar'}]
npm install indexed-filter
import indexedFilter from 'indexed-filter';
array: Array
filterFn: Function
thisObject: (any value)
Return: Array
The API is very similar to Array.prototype.filter()
. There are only two differences:
.filter()
method on the array instance.index
(array index integer) and value
(array element).indexedFilter([0, [1], [2], '3', [5]], function(val, index, arr) {
return this.isArray(val) && index % 2 === 0 && index < arr.length * 0.5;
}, Array);
//=> [{index: 2, value: [2]}]
ISC License © 2018 Shinnosuke Watanabe
FAQs
Array#filter() with also detecting indexes of filtered values
We found that indexed-filter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.