arrayloop

0.1.1 • Public • Published

loopjs

Loop.js is a very small, but powerful, utility for looping over array-like objects. It enables the classical functional patterns like map, filter, fold and find with a single simple operation and features the ability to break out of the loop early.

var result = loop(arrayLike, defaultResult, function(lo){ 
    var theCurrentItem = lo.item; 
    var theCurrentIndex = lo.index();
    
    //Starts with the value of the defaultResult parameter, returned at end of iteration
    var theResultSoFar = lo.result;   
    var isLastItemInTheArray = lo.isLast(); 
    lo.stop(); //break out of loop 
});

Full readme
Test suite (run in your browser)

Package Sidebar

Install

npm i arrayloop

Weekly Downloads

0

Version

0.1.1

License

ISC

Last publish

Collaborators

  • jensdpersson