Skip to content

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.

Notifications You must be signed in to change notification settings

jensdpersson/loopjs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)

About

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.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published