<commit_before># immutable-path-resolver

`immutable-path-resolver` can be used to dynamically resolve paths through [ImmutableJS](https://facebook.github.io/immutable-js/) data structures.

Suppose you have a tree of immutable objects like this:

    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.

## 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.
- There is currently no support for a function as the first item in the path specification. Hopefully there will be soon.
- This utility has only been tested with the `Map`, `List`, and `Record` data types.<commit_msg>Add CI badge to readme<commit_after># immutable-path-resolver

`immutable-path-resolver` can be used to dynamically resolve paths through [ImmutableJS](https://facebook.github.io/immutable-js/) data structures.

Suppose you have a tree of immutable objects like this:

    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](https://travis-ci.org/bhritchie/immutable-path-resolver.svg?branch=master)](https://travis-ci.org/bhritchie/immutable-path-resolver)

## 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.
- There is currently no support for a function as the first item in the path specification. Hopefully there will be soon.
- This utility has only been tested with the `Map`, `List`, and `Record` data types.
{'fraction_non_alphanumeric': 0.10953058321479374, 'fraction_numerical': 0.0035561877667140826, 'mean_word_length': 3.3612403100775192, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2157401', 'n_tokens_mistral': 839, 'n_tokens_neox': 807, 'n_words': 329}