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

collection-visit

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

collection-visit

Visit a method over the items in an object, or map visit over the objects in an array.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
10M
decreased by-19.93%
Maintainers
2
Weekly downloads
 
Created

What is collection-visit?

The collection-visit npm package is designed to provide a simple way to visit and apply functions to elements in an object or array. It allows developers to easily manipulate and handle collections of data by iterating over them and invoking a specified method on each element of the collection.

What are collection-visit's main functionalities?

Visiting objects

This feature allows you to visit a specific path within an object and perform operations on it. In the code sample, the `visit` function is used to log the value at the path 'a.b' within the object.

const visit = require('collection-visit');
const obj = { a: { b: { c: 'd' } } };
visit(obj, 'a.b', console.log);  // logs { c: 'd' }

Visiting arrays

This feature enables visiting elements within an array and applying a function to each element. The code sample demonstrates visiting each object in the array and logging the 'name' property.

const visit = require('collection-visit');
const arr = [{ name: 'Alice' }, { name: 'Bob' }];
visit(arr, 'name', console.log);  // logs 'Alice' and 'Bob'

Other packages similar to collection-visit

Keywords

FAQs

Package last updated on 09 Apr 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

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