Gathering detailed insights and metrics for array-iterate
Gathering detailed insights and metrics for array-iterate
Gathering detailed insights and metrics for array-iterate
Gathering detailed insights and metrics for array-iterate
`Array#forEach()` but it’s possible to define where to move to next
npm install array-iterate
99.2
Supply Chain
99.4
Quality
75.6
Maintenance
100
Vulnerability
100
License
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
7 Stars
78 Commits
3 Forks
4 Watching
1 Branches
3 Contributors
Updated on 02 Apr 2024
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-2%
86,901
Compared to previous day
Last week
2.2%
527,858
Compared to previous week
Last month
9.9%
2,137,295
Compared to previous month
Last year
46.6%
20,827,519
Compared to previous year
Array#forEach()
but it’s possible to define where to move to next.
A tiny package that works just like forEach
, with one small difference.
You can use this if for some weird reason—like I did—you have to sometimes skip a few places ahead or backwards when moving through an array.
This package is ESM only. In Node.js (version 14.14+, 16.0+), install with npm:
1npm install array-iterate
In Deno with esm.sh
:
1import {arrayIterate} from 'https://esm.sh/array-iterate@2'
In browsers with esm.sh
:
1<script type="module"> 2 import {arrayIterate} from 'https://esm.sh/array-iterate@2?bundle' 3</script>
1import {arrayIterate} from 'array-iterate' 2 3let first = true 4 5arrayIterate( 6 [1, 2, 3, 4], 7 function (value, index, values){ 8 console.log(this, value, index, values) 9 10 // Repeat once. 11 if (first && index + 1 === values.length) { 12 first = false 13 return 0 14 } 15 }, 16 {hello: 'world'} 17)
Yields:
1{hello: 'world'}, 1, 0, [1, 2, 3, 4] 2{hello: 'world'}, 2, 1, [1, 2, 3, 4] 3{hello: 'world'}, 3, 2, [1, 2, 3, 4] 4{hello: 'world'}, 4, 3, [1, 2, 3, 4] 5{hello: 'world'}, 1, 0, [1, 2, 3, 4] 6{hello: 'world'}, 2, 1, [1, 2, 3, 4] 7{hello: 'world'}, 3, 2, [1, 2, 3, 4] 8{hello: 'world'}, 4, 3, [1, 2, 3, 4]
This package exports the identifier arrayIterate
.
There is no default export.
arrayIterate(values, callbackFn[, thisArg])
Perform the specified action for each element in an array (just like
Array#forEach()
).
When callbackFn
returns a number
, moves to the element at that index
next.
values
(Array<*>
)
— values to iterate overcallbackFn
(Function
)
— function called for each element, can return the index
to move to nextthisArg
(*
, optional)
— optional object passed as this
in callbackFn
undefined
.
function callbackFn(value, index, values)
Callback given to iterate
.
this
(*
)
— context object when given as thisArg
to arrayIterate
or undefined
value
(*
)
— element in arrayindex
(number
)
— index of value
in values
values
(Array.<*>
)
— listThe optional index
to move to next (number
or undefined
)
This package is fully typed with TypeScript.
It exports the additional type CallbackFn
.
This package is at least compatible with all maintained versions of Node.js. As of now, that is Node.js 14.14+ and 16.0+. It also works in Deno and modern browsers.
This package is safe, assuming that you don’t create an infinite loop by keeping on repeating.
Yes please! See How to Contribute to Open Source.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 1/30 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
Project has not signed or included provenance with any releases.
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More