New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

immutable-path-resolver

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

immutable-path-resolver

Dynamically resolve paths through ImmutableJS data structures

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

immutable-path-resolver

immutable-path-resolver can be used to dynamically resolve paths through ImmutableJS data structures.

Suppose you have a tree of immutable objects like this:

const {Map, List, Record} = require('immutable');

class Todo extends Record({id: null, label: ''}) {};

const state = new Map({
    todos: new List([
        new Todo({id: 1, label: 'utility'}),
        new Todo({id: 2, label: 'tests'})
    ]),
});

immutable-path-resolver allows you to resolve the actual path for the label of the to-do with id: 1 by providing a path specification like this:

const resolvePath = require('immutable-path-resolver');

const path = resolvePath(state, [
    'todos',
    (todos => todos.findIndex(todo => todo.id === 1)),
    'label'
]);

//=> ['todos', 0, 'label']

Then you can use that path with ImmutableJS methods such as getIn, setIn, etc.

Build Status npm

Installation

npm install immutable-path-resolver

Usage Notes

  • When you provide a function at some point in your path specification, that function will be invoked with the value of the preceding item in the tree, or the initial object when the function is in the first position.
  • This utility has only been tested with the Map, List, and Record data types.

Keywords

FAQs

Package last updated on 17 Aug 2016

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