aneka 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGES.md +8 -0
- package/index.js +1 -0
- package/package.json +2 -2
- package/src/filter-index.js +17 -0
- package/src/get-index.js +1 -1
package/CHANGES.md
CHANGED
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Filter array's indexes
|
|
3
|
+
*
|
|
4
|
+
* @param {Array} inputs - Array to filter from
|
|
5
|
+
* @param {Object} matcher - Function to match conditions. If returns ```true```, the running index will be added to the result
|
|
6
|
+
* @returns {Array} Filtered indexes
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
function filterIndex (inputs, matcher) {
|
|
10
|
+
const indexes = inputs.reduce((accumulator, current, index) => {
|
|
11
|
+
if (matcher(current)) accumulator.push(index)
|
|
12
|
+
return accumulator
|
|
13
|
+
}, [])
|
|
14
|
+
return indexes
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default filterIndex
|
package/src/get-index.js
CHANGED