Socket
Socket
Sign inDemoInstall

simple-loop

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-loop

this a simple loop for iterating over an array or an object


Version published
Weekly downloads
2.4K
increased by48.43%
Maintainers
1
Weekly downloads
 
Created
Source

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

Keywords

FAQs

Package last updated on 08 May 2015

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc