New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

immutable-validator

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

immutable-validator

Simple tool to deep validate that your immutable-js object is fully immutable

latest
npmnpm
Version
0.2.1
Version published
Maintainers
1
Created
Source

Immutable validator

Deep validates an Object/Array/Map/List

Simple tool to validate that your immutable-js object is fully immutable. Deep validates and logs paths if there are any leafs that are not an instance from immutable-js. Primitive values are ignored.

What do I use it for?

  • If you got a large nested state and expect everything (non-primitives) to be an instance of immutable-js
  • Validate that your redux store is fully immutable

Installation

npm install immutable-validator --save

Usage example

import { Map, List } from 'immutable'
import ImmutableValidator from 'immutable-validator'

const obj = Map({
    a: 1,
    b: 2,
    c: {},
    d: [],
    e: List([
        1,
        2,
        Map({
            aa: 1,
            bb: {}
        })
    ])
})

ImmutableValidator(obj /**, options **/)

/** LOGS:
 * root.c
 * root.d
 * root.e.2.bb
 * /

Redux example

Usage with Redux

import { createStore } from 'redux'
import rootReducer from '../rootReducer'
import ImmutableValidator from 'immutable-validator'

const Store = createStore(rootReducer)

Store.subscribe(() => ImmutableValidator(Store.getState()))

Options

Object passed as second argument

CommanddefaultDescription
logToConsoletrueLog result to console
collapsedtrueCollapse the result in console

Changes

  • 0.2.0: Dependency updates (babel 7, immutable 4)
  • 0.1.0: First version

FAQs

Package last updated on 18 Dec 2018

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