Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

iterate-object

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

iterate-object

A convenient way to iterate objects.

  • 1.3.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
232K
decreased by-5.61%
Maintainers
1
Weekly downloads
 
Created

What is iterate-object?

The iterate-object npm package provides a simple utility to iterate over the properties of an object. It allows you to perform operations on each key-value pair in the object.

What are iterate-object's main functionalities?

Basic Iteration

This feature allows you to iterate over each key-value pair in an object and perform operations on them. In this example, it logs each key and value to the console.

const iterateObject = require('iterate-object');
const obj = { a: 1, b: 2, c: 3 };
iterateObject(obj, (value, key) => {
  console.log(key, value);
});

Modify Object Values

This feature allows you to modify the values of the object during iteration. In this example, it multiplies each value by 2.

const iterateObject = require('iterate-object');
const obj = { a: 1, b: 2, c: 3 };
iterateObject(obj, (value, key) => {
  obj[key] = value * 2;
});
console.log(obj);

Filter Object Properties

This feature allows you to filter the properties of an object based on a condition. In this example, it creates a new object with properties that have values greater than 1.

const iterateObject = require('iterate-object');
const obj = { a: 1, b: 2, c: 3 };
const filteredObj = {};
iterateObject(obj, (value, key) => {
  if (value > 1) {
    filteredObj[key] = value;
  }
});
console.log(filteredObj);

Other packages similar to iterate-object

Keywords

FAQs

Package last updated on 09 Aug 2020

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