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.0 to 0.4.1

5

lib/index.js

@@ -291,4 +291,7 @@ 'use strict';

if (canMutate(obj)) return mutableSet(opts, key, obj);
if (obj[key] === value) return obj;
var newObj = Object.assign({}, obj);
prepareNewObject(newObj);
prepareNewObject(opts, newObj);
newObj[key] = value;

@@ -295,0 +298,0 @@ return newObj;

26

lib/test/testOperations.js

@@ -260,2 +260,25 @@ 'use strict';

it('sets a value', function () {
var obj = (0, _deepFreeze2['default'])({
name: 'Tommi',
age: 25
});
var result = ops.set('age', 26, obj);
expect(result).to.deep.equal({
name: 'Tommi',
age: 26
});
});
it('sets a value and returns the initial value of no changes', function () {
var obj = (0, _deepFreeze2['default'])({
name: 'Tommi',
age: 25
});
var result = ops.set('age', 25, obj);
expect(result).to.equal(obj);
});
it('sets a value in path', function () {

@@ -426,4 +449,3 @@ var obj = (0, _deepFreeze2['default'])({

var setter = ops.set(2, 3);
var result = setter(arr);
var result = ops.set(2, 3, arr);

@@ -430,0 +452,0 @@ expect((0, _index.canMutate)(result)).to.be['false'];

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

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

@@ -267,4 +267,7 @@ import forOwn from 'lodash/forOwn';

if (canMutate(obj)) return mutableSet(opts, key, obj);
if (obj[key] === value) return obj;
const newObj = Object.assign({}, obj);
prepareNewObject(newObj);
prepareNewObject(opts, newObj);
newObj[key] = value;

@@ -271,0 +274,0 @@ return newObj;

@@ -242,2 +242,25 @@ import chai from 'chai';

it('sets a value', () => {
const obj = freeze({
name: 'Tommi',
age: 25,
});
const result = ops.set('age', 26, obj);
expect(result).to.deep.equal({
name: 'Tommi',
age: 26,
});
});
it('sets a value and returns the initial value of no changes', () => {
const obj = freeze({
name: 'Tommi',
age: 25,
});
const result = ops.set('age', 25, obj);
expect(result).to.equal(obj);
});
it('sets a value in path', () => {

@@ -394,4 +417,3 @@ const obj = freeze({

const setter = ops.set(2, 3);
const result = setter(arr);
const result = ops.set(2, 3, arr);

@@ -398,0 +420,0 @@ expect(canMutate(result)).to.be.false;

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