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

immutable-assign

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

immutable-assign - npm Package Compare versions

Comparing version 2.1.1 to 2.1.2

.prettierrc.js

10

deploy/iassign.js

@@ -94,5 +94,5 @@ 'use strict';

if (!propPaths) {
// Check if getProp() is valid
var value = getProp(obj, context);
if (option.ignoreIfNoChange) {
// Check if getProp() is valid
var value = getProp(obj, context);
newValue = setProp(value);

@@ -114,5 +114,5 @@ if (newValue === value) {

else {
// Check if getProp() is valid
var value = getPropByPaths(obj, propPaths);
if (option.ignoreIfNoChange) {
// Check if getProp() is valid
var value = getPropByPaths(obj, propPaths);
newValue = setProp(value);

@@ -158,3 +158,3 @@ if (newValue === value) {

isNaN(token.propName)) {
throw new Error("Cannot handle " + token.propName + " when the property it point to is undefined, which require unsafe feature of e v a l.");
throw new Error("Cannot handle " + token.propName + " when the property it point to is undefined.");
}

@@ -161,0 +161,0 @@ }

{
"name": "immutable-assign",
"version": "2.1.1",
"version": "2.1.2",
"description": "Lightweight immutable helper that allows you to continue working with Plain JavaScript Objects",

@@ -47,11 +47,10 @@ "main": "deploy/iassign.js",

"edge-launcher": "^1.2.2",
"expect": "^23.5.0",
"expect": "^24.1.0",
"gulp": "^3.9.1",
"gulp-less": "^4.0.1",
"gulp-typescript": "^5.0.0-alpha.3",
"immer": "^1.5.0",
"immer": "^2.0.0",
"immutable": "^3.8.2",
"istanbul": "^0.4.5",
"jasmine": "^3.2.0",
"karma": "^3.0.0",
"karma": "^4.0.0",
"karma-chrome-launcher": "^2.2.0",

@@ -61,3 +60,3 @@ "karma-edge-launcher": "^0.4.2",

"karma-ie-launcher": "^1.0.0",
"karma-jasmine": "^1.1.2",
"karma-jasmine": "^2.0.1",
"karma-phantomjs-launcher": "^1.0.4",

@@ -64,0 +63,0 @@ "karma-safari-launcher": "^1.0.0",

@@ -18,3 +18,3 @@ # immutable-assign (iassign.js)

* Most immutable JavaScript libraries try to encapsulate the data and provide proprietary APIs to work with the data. They are more verbose than normal JavaScript syntax. E.g., map1.get('b') vs map1.b, nested2.getIn(['a', 'b', 'd']) vs nested2.a.b.d, etc.
* Most immutable JavaScript libraries try to encapsulate the data and provide proprietary APIs to work with the data. They are more verbose than normal JavaScript syntax. E.g., `map1.get('b')` vs `map1.b`, `nested2.getIn(['a', 'b', 'd'])` vs `nested2.a.b.d`, etc.
* Encapsulated data is no more POJO, therefore cannot be easily used with other libraries, e.g., lodash, underscore, etc.

@@ -24,3 +24,3 @@ * Most immutable libraries leak themselves throughout your entire application (including view components), however, they should have been encapsulated at the place where updates happen (e.g., Redux reducers). This is also a pain when you need to change to another immutable library that has its own APIs.

* [Immutability Helpers](https://facebook.github.io/react/docs/update.html) allows us to work with POJO, but it has still introduced some magic keywords, such as $set, $push, etc.
* In addition, we lost TypeScript type checking. E.g., when calling nested2.getIn(["a", "b", "c"]), TypeScript won't be able to warn me if I changed property "c" to "d".
* In addition, we lost TypeScript type checking. E.g., when calling `nested2.getIn(["a", "b", "c"])`, TypeScript won't be able to warn me if I changed property "c" to "d".

@@ -37,3 +37,3 @@ This library is an alternative to [Immutable.js](https://facebook.github.io/immutable-js/), it has only one method **iassign()**, which accept a POJO object and return you a new POJO object with specific property updated. However, since it works with other libraries such as lodash (refer to [example 4](#example-4-work-with-3rd-party-libraries-eg-lodash)), it provides all the functionalities you need plus immutability.

Performance of this library should be comparable to [Immutable.js](https://facebook.github.io/immutable-js/), because read operations will always occur more than write operations. When using this library, all your react components can read object properties directly. E.g., you can use <TextBox value={this.state.userinfo.fullName} /> in your components, instead of <TextBox value={this.state.getIn(["userinfo", "fullName"])} />. In addition, shouldComponentUpdate() can compare POJO objects without knowing about the immutable libraries, e.g., return this.props.userInfo.orders !== nextProps.userInfos.orders. I.e., the more read operations you have, the more it will outperform [Immutable.js](https://facebook.github.io/immutable-js/). Following are the benchmarks for multiple immutable libraries (assuming the read to write ratio is 5 to 1):
Performance of this library should be comparable to [Immutable.js](https://facebook.github.io/immutable-js/), because read operations will always occur more than write operations. When using this library, all your react components can read object properties directly. E.g., you can use `<TextBox value={this.state.userinfo.fullName}>` in your components, instead of `<TextBox value={this.state.getIn(["userinfo", "fullName"])}>`. In addition, `shouldComponentUpdate()` can compare POJO objects without knowing about the immutable libraries, e.g., `return this.props.userInfo.orders !== nextProps.userInfos.orders`. I.e., the more read operations you have, the more it will outperform [Immutable.js](https://facebook.github.io/immutable-js/). Following are the benchmarks for multiple immutable libraries (assuming the read to write ratio is 5 to 1):

@@ -62,3 +62,3 @@ ```

Full performance test results can be found at <a href="https://github.com/engineforce/ImmutableAssign/tree/master/debug" target="_blank">benchmarks</a>.
Full performance test results and test script can be found at <a href="https://github.com/engineforce/ImmutableAssign/tree/master/debug" target="_blank">benchmarks</a>.

@@ -75,3 +75,3 @@ ## Install with npm

### Example 1: Update 1st level object properties
### Example 1: Update 1st level object properties, it has skipped the getProp parameter

@@ -99,3 +99,3 @@ ```javascript

### Example 2: Update 1st level list/array elements
### Example 2: Update 1st level list/array elements, it has skipped the getProp parameter

@@ -102,0 +102,0 @@ ```javascript

Sorry, the diff of this file is not supported yet

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