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

immutability-helper-x

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

immutability-helper-x - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

__tests__/chain_api.spec.js

31

package.json
{
"name": "immutability-helper-x",
"version": "1.0.0",
"version": "1.0.1",
"description": "expand the immutability-helper, to support update by path string, like the get/set in lodash",

@@ -11,2 +11,4 @@ "main": "lib/index.js",

"scripts": {
"test": "jest --coverage",
"coveralls": "cat ./coverage/lcov.info | coveralls",
"clean": "rimraf lib dist",

@@ -21,2 +23,3 @@ "build": "npm run build:commonjs",

"babel-core": "^6.24.1",
"babel-jest": "^20.0.3",
"babel-loader": "^7.0.0",

@@ -27,3 +30,5 @@ "babel-plugin-transform-es2015-modules-commonjs": "^6.24.1",

"babel-preset-stage-0": "^6.24.1",
"coveralls": "^2.13.1",
"cross-env": "^5.0.0",
"jest": "^20.0.4",
"rimraf": "^2.6.1",

@@ -33,4 +38,26 @@ "webpack": "^2.5.1"

"dependencies": {
"immutability-helper": "^2.2.0"
"immutability-helper": "^2.2.2"
},
"jest": {
"testRegex": "(/__tests__/.*\\.(test|spec))\\.(ts|tsx|js)$",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"json"
],
"collectCoverage": true,
"collectCoverageFrom": [
"src/*.{js,jsx}",
"!**/node_modules/**",
"!**/vendor/**"
],
"moduleDirectories": [
"node_modules",
"src"
],
"transform": {
"^.+\\.js?$": "babel-jest"
}
}
}

20

README.md
# immutability-helper-x
-------------
this lib extends the [kolodny/immutability-helper](https://github.com/kolodny/immutability-helper) to support update by path string, like the get/set in lodash
> The library extends the [kolodny/immutability-helper](https://github.com/kolodny/immutability-helper) to support update by path string, like the get/set in lodash.
[![Build Status](https://travis-ci.org/ProtoTeam/immutability-helper-x.svg?branch=master)](https://travis-ci.org/ProtoTeam/immutability-helper-x) [![Coverage Status](https://coveralls.io/repos/github/ProtoTeam/immutability-helper-x/badge.svg?branch=master)](https://coveralls.io/github/ProtoTeam/immutability-helper-x?branch=master) [![npm](https://img.shields.io/npm/v/immutability-helper-x.svg)](https://www.npmjs.com/package/immutability-helper-x)
## install

@@ -12,10 +15,14 @@

## example
```
## usage
```js
import update, { updateChain } from 'immutability-helper-x';
update.$set(data, 'a.b', newValue);
// same as
update.$set(data, ['a', 'b'], newValue);
// for the array methods like $push/$unshift, you can update it with two forms
update.$push(data, 'arr', ['car', 'bus']);
update.$push(data, 'arr', 'car', 'bus');

@@ -51,1 +58,4 @@ update.$apply(data, 'a.b', value => ++value);

```

@@ -7,3 +7,2 @@ /**

* update.$push(object, 'arr', ['car', 'bus']);
* update.$push(object, 'arr', 'car', 'bus');
* update.$apply(object, 'a.b', value => ++value);

@@ -16,3 +15,3 @@ * **********************************

* });
* // step 2
* // step 2
* update.$addtax(object, 'price', 0.8);

@@ -55,3 +54,3 @@ * // or

// [n] => .n
realPath = realPath.replace(/(\[\d+\])/g, s => `.${s.sslice(1, -1)}`);
realPath = realPath.replace(/(\[\d+\])/g, s => `.${s.slice(1, -1)}`);
realPath = realPath.split('.');

@@ -68,11 +67,7 @@ }

});
update[methodName] = (object, path, ...value) => {
if ((!isUndefined(path) && value.length === 0) || isUndefined(object)) {
update[methodName] = (object, path, value) => {
if ((!isUndefined(path) && isUndefined(value)) || isUndefined(object)) {
throw new Error('update: params are not valid');
}
let realValue = value;
if (value.length === 1) {
realValue = value[0];
}
const updatable = createUpdatable(methodName, path, realValue);
const updatable = createUpdatable(methodName, path, value);
return update(object, updatable);

@@ -79,0 +74,0 @@ };

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