
Security News
libxml2 Maintainer Ends Embargoed Vulnerability Reports, Citing Unsustainable Burden
Libxml2’s solo maintainer drops embargoed security fixes, highlighting the burden on unpaid volunteers who keep critical open source software secure.
Vanilla JavaScript array iterators with control-flow capability. That's all.
ECMAScript 5.1 native Array.prototype
iterators implemention with control-flow capatibility. Same functional fun, same imperative control flow.
Behavior are strictly maintained with the native implementation.
Rational note: I thought about this actually a long time ago, and was suprised that there nothing already outside (or maybe it's really hard to find), so I've decided to do this crazy idea by my own.
var ArrayFlow = require('arrayflow')
var nativeArr = [1,2,3,4,5,6,7,8]
var awesomeArr = ArrayFlow.wrap(nativeArr)
awesomeArr
.filter(function (value, key, _, stop) {
return value < 6
})
.forEach(function (value, key, _, stop) {
console.log('Read number:', value)
if (number > 3) {
stop()
console.log('Oh, stop iteration...')
}
})
Alternative, if you are evil, you infect
the Array.prototype to enable control flow capabilities to any Array
object:
ArrayFlow.infect() // yeah, I'm evil!
var a = [1,2,3,4]
// Now using a ArrayFlow iterators
a.forEach(function (value, key, arr, stop) {
// mad science here ...
// ... but now stops when you want!
})
Via npm:
npm install arrayflow
Via bower:
bower install arrayflow
Loading the script via CDN:
<script src="//cdn.rawgit.com/h2non/arrayflow/master/arrayflow.js"></script>
Create a new ArrayFlow based array. Inherits from Array, so you're actually using a vanilla Array just with some methods overwritten.
Runs a callback for each element in the array.
Map elements in an array.
Filter elements in array.
Reduce an array.
Wrap a native Array
instance with ArrayFlow iterations.
Self-described, but anyway, this method does evil things mutating the native Array.prototype
with the ArrayFlow iterators, therefore you can use control-flow features in any array initialized, for instance, with literator notation = []
ArrayFlow.infect()
var a = [1,2,3,4]
// Now using a ArrayFlow iterators
a.forEach(function (value, key, arr, stop) {
// mad science ...
})
=>
function(iterator)Get an ArrayFlow method and returns its iterator.
MIT - Tomas Aparicio
FAQs
Vanilla JavaScript array iterators with control-flow capability. That's all.
The npm package arrayflow receives a total of 1 weekly downloads. As such, arrayflow popularity was classified as not popular.
We found that arrayflow 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
Libxml2’s solo maintainer drops embargoed security fixes, highlighting the burden on unpaid volunteers who keep critical open source software secure.
Research
Security News
Socket investigates hidden protestware in npm packages that blocks user interaction and plays the Ukrainian anthem for Russian-language visitors.
Research
Security News
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.