Skip to content

simple-loop is an abstraction for iterating over arrays and objects the same way

License

Unknown, Unknown licenses found

Licenses found

Unknown
LICENSE
Unknown
LICENSE-MINI
Notifications You must be signed in to change notification settings

flams/simple-loop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple loop

Simple loop is an abstraction for iterating over arrays and objects the same way. If an array is given, it will loop over it from the first item to the last one. If an object is given, then the order will be the same as if for ... in were used. Simple loop also loops through an array which length changes while looping.

Installation

npm install simple-loop

How to use

Require simple-loop:

var loop = require("simple-loop");

Use it with an array:

var anArray = ["with", "some", "data"];

loop(anArray, function (value, key, iteratedObject) {
    // this === scope;
    // value is each item
    // key is each index
    // iteratedObject === anArray
}, scope /* optional object */);

Use it with an object:

var anObject = {
  "property1": "with",
  "property2": "some",
  "property3": "data"
};

loop(anObject, function (value, key, iteratedObject) {
    // this === scope;
    // value is each property's value
    // key is property name
    // iteratedObject === anArray
}, scope /* optional object */);

CHANGELOG

0.0.4 - 7 MAY 2015

  • Remove dependency on assert and use custom assert function instead. Saves 17kb in the end after browserification. Thanks to @tomekwi.

LICENSE

MIT

About

simple-loop is an abstraction for iterating over arrays and objects the same way

Resources

License

Unknown, Unknown licenses found

Licenses found

Unknown
LICENSE
Unknown
LICENSE-MINI

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published