šŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →
Socket
Sign inDemoInstall
Socket

object-visit

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

object-visit

Call a specified method on each value in the given object.

1.0.1
latest
Source
npm
Version published
Weekly downloads
12M
9.07%
Maintainers
1
Weekly downloads
Ā 
Created

What is object-visit?

The object-visit npm package is designed to simplify the process of visiting and invoking methods on an object. It allows you to call a specified method on each property of an object, which can be particularly useful for tasks like data transformation, validation, or applying a series of operations to an object's properties.

What are object-visit's main functionalities?

Invoke a method on each property of an object

This feature allows you to invoke a specified method on each property of an object. In this example, the 'greet' method is called on each property of the object, transforming the 'greet' property to its return value.

const visit = require('object-visit');

const obj = {
  name: 'John',
  age: 30,
  greet: function() { return `Hello, my name is ${this.name}`; }
};

visit(obj, 'greet');
// Output: { name: 'John', age: 30, greet: 'Hello, my name is John' }

Invoke a method with arguments on each property of an object

This feature allows you to invoke a specified method with arguments on each property of an object. In this example, the 'greet' method is called with the argument 'Hi' on each property of the object, transforming the 'greet' property to its return value.

const visit = require('object-visit');

const obj = {
  name: 'John',
  age: 30,
  greet: function(greeting) { return `${greeting}, my name is ${this.name}`; }
};

visit(obj, 'greet', 'Hi');
// Output: { name: 'John', age: 30, greet: 'Hi, my name is John' }

Other packages similar to object-visit

Keywords

context

FAQs

Package last updated on 30 May 2017

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