loop-over-object

0.1.3 • Public • Published

loopOverObject

GitHub | NPM | @jelmerdemaat

Small, safe JavaScript function that correctly loops over an object.

  • ES6 ready.
  • Promise based, resolves for each item.
  • Filters array on object.hasOwnProperty to check if the property really exists.

Usage

Add to your dependencies:

  npm install --save loop-over-object
  # or shorter: 
  npm i -S loop-over-object

Use in your JS:

import loopOverObject from 'loop-over-object';
 
const object = {
  name: 'Jelmer',
  color: 'red',
  cape: false
};
 
loopOverObject(object).then((item, key) => {
  console.log(item, key);
  // 👆 Logs:
  //    name Jelmer
  //    color red
  //    cape false
});

Readme

Keywords

Package Sidebar

Install

npm i loop-over-object

Weekly Downloads

0

Version

0.1.3

License

MIT

Unpacked Size

1.88 kB

Total Files

3

Last publish

Collaborators

  • jelmer