Socket
Socket
Sign inDemoInstall

immutable-ops

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

immutable-ops - npm Package Compare versions

Comparing version 0.4.1 to 0.4.2

2

lib/index.js

@@ -290,3 +290,3 @@ 'use strict';

if ((0, _lodashIsArrayLike2['default'])(obj)) return immutableArrSet(opts, key, value, obj);
if (canMutate(obj)) return mutableSet(opts, key, obj);
if (canMutate(obj)) return mutableSet(opts, key, value, obj);

@@ -293,0 +293,0 @@ if (obj[key] === value) return obj;

@@ -141,2 +141,23 @@ 'use strict';

it('sets a value', function () {
var obj = (0, _deepFreeze2['default'])({
one: 1,
two: 500,
three: 3
});
var result = undefined;
ops.batched(function () {
result = ops.set('two', 5, obj);
expect((0, _index.canMutate)(result)).to.be['true'];
result = ops.set('two', 2, result);
});
expect(result).to.deep.equal({
one: 1,
two: 2,
three: 3
});
});
it('sets a value in path', function () {

@@ -143,0 +164,0 @@ var obj = (0, _deepFreeze2['default'])({

{
"name": "immutable-ops",
"version": "0.4.1",
"version": "0.4.2",
"description": "A collection of functions to perform immutable operations on plain JavaScript objects",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -266,3 +266,3 @@ import forOwn from 'lodash/forOwn';

if (isArrayLike(obj)) return immutableArrSet(opts, key, value, obj);
if (canMutate(obj)) return mutableSet(opts, key, obj);
if (canMutate(obj)) return mutableSet(opts, key, value, obj);

@@ -269,0 +269,0 @@ if (obj[key] === value) return obj;

@@ -123,2 +123,23 @@ import chai from 'chai';

it('sets a value', () => {
const obj = freeze({
one: 1,
two: 500,
three: 3,
});
let result;
ops.batched(() => {
result = ops.set('two', 5, obj);
expect(canMutate(result)).to.be.true;
result = ops.set('two', 2, result);
});
expect(result).to.deep.equal({
one: 1,
two: 2,
three: 3,
});
});
it('sets a value in path', () => {

@@ -125,0 +146,0 @@ const obj = freeze({

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