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

immutable-state-creator

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

immutable-state-creator

utilities to create immutable state

  • 1.2.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
262
decreased by-16.29%
Maintainers
1
Weekly downloads
 
Created
Source

Create Immutable State Easily travis-ci

An utility to easily create immutable state for Redux

Usage

Primitive types
  1. Define the State
import { createState, StateObject } from 'immutable-state-creator'

const State = createState('User', {
  name: 'my name',
  age: 10,
  languages: ['English'],
  pets: List.of('cat'),
  active: true,
})
  1. Create initial state
const initState = State.create()
  1. Use getter to select value
expect(State.get('age')(initState)).toBe(10)
expect(State.get('name')(initState)).toBe('my name')
  1. Use setter to update a value
const newState = State.set('age', 20)(initState)
expect(State.get('age')(newState)).toBe(20)
Toggle boolean value
const initState = State.create()
expect(initState.active).toBe(true)
const newState = State.toggle('active')(initState)
expect(newState.active).toBe(false)

Keywords

FAQs

Package last updated on 08 Mar 2020

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