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

extendable-immutable

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

extendable-immutable - npm Package Compare versions

Comparing version 1.1.1 to 1.2.0

20

es/util/createExtendable.js

@@ -5,5 +5,3 @@ import _typeof from 'babel-runtime/helpers/typeof';

import invariant from 'invariant';
import searchParentConstructorEntry from './searchParentConstructorEntry';
var emptySymbol = 'empty';
var unwrappedMethods = ['constructor', 'get', 'getIn', 'first', 'last', 'reduce', 'reduceRight', 'find', 'findLast', 'findEntry', 'findLastEntry', 'max', 'maxBy', 'min', 'minBy', 'clear' // Important! We're manually overriding this method

@@ -25,3 +23,7 @@ ];

// A method for wrapping an immutable object, with reference equality for empty objects
// Create a list of keys and values that hold the empty instances
var emptyKeys = [];
var emptyValues = [];
// A method for wrapping an immutable object, with reference equality for empty instances
proto.__wrapImmutable = function __wrapImmutable(val) {

@@ -35,7 +37,13 @@ var forceCreation = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1];

if (!val.size && !val.__ownerID && !forceCreation) {
if (!constructor[emptySymbol] || searchParentConstructorEntry(constructor, emptySymbol, constructor[emptySymbol])) {
return constructor[emptySymbol] = empty(_Object$create(prototype));
var emptyIndex = emptyKeys.indexOf(prototype);
if (emptyIndex > -1) {
return emptyValues[emptyIndex];
}
return constructor[emptySymbol];
// Create empty instance and store it
var emptyInstance = empty(_Object$create(prototype));
emptyValues[emptyKeys.length] = emptyInstance;
emptyKeys.push(prototype);
return emptyInstance;
}

@@ -42,0 +50,0 @@

@@ -25,9 +25,4 @@ 'use strict';

var _searchParentConstructorEntry = require('./searchParentConstructorEntry');
var _searchParentConstructorEntry2 = _interopRequireDefault(_searchParentConstructorEntry);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var emptySymbol = 'empty';
var unwrappedMethods = ['constructor', 'get', 'getIn', 'first', 'last', 'reduce', 'reduceRight', 'find', 'findLast', 'findEntry', 'findLastEntry', 'max', 'maxBy', 'min', 'minBy', 'clear' // Important! We're manually overriding this method

@@ -49,3 +44,7 @@ ];

// A method for wrapping an immutable object, with reference equality for empty objects
// Create a list of keys and values that hold the empty instances
var emptyKeys = [];
var emptyValues = [];
// A method for wrapping an immutable object, with reference equality for empty instances
proto.__wrapImmutable = function __wrapImmutable(val) {

@@ -59,7 +58,13 @@ var forceCreation = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1];

if (!val.size && !val.__ownerID && !forceCreation) {
if (!constructor[emptySymbol] || (0, _searchParentConstructorEntry2.default)(constructor, emptySymbol, constructor[emptySymbol])) {
return constructor[emptySymbol] = empty((0, _create2.default)(prototype));
var emptyIndex = emptyKeys.indexOf(prototype);
if (emptyIndex > -1) {
return emptyValues[emptyIndex];
}
return constructor[emptySymbol];
// Create empty instance and store it
var emptyInstance = empty((0, _create2.default)(prototype));
emptyValues[emptyKeys.length] = emptyInstance;
emptyKeys.push(prototype);
return emptyInstance;
}

@@ -66,0 +71,0 @@

{
"name": "extendable-immutable",
"version": "1.1.1",
"version": "1.2.0",
"main": "lib/index.js",

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

import invariant from 'invariant'
import searchParentConstructorEntry from './searchParentConstructorEntry'
const emptySymbol = 'empty'
const unwrappedMethods = [

@@ -39,3 +37,7 @@ 'constructor',

// A method for wrapping an immutable object, with reference equality for empty objects
// Create a list of keys and values that hold the empty instances
const emptyKeys = []
const emptyValues = []
// A method for wrapping an immutable object, with reference equality for empty instances
proto.__wrapImmutable = function __wrapImmutable(val, forceCreation = false) {

@@ -46,10 +48,13 @@ const prototype = Object.getPrototypeOf(this)

if (!val.size && !val.__ownerID && !forceCreation) {
if (
!constructor[emptySymbol] ||
searchParentConstructorEntry(constructor, emptySymbol, constructor[emptySymbol])
) {
return constructor[emptySymbol] = empty(Object.create(prototype))
const emptyIndex = emptyKeys.indexOf(prototype)
if (emptyIndex > -1) {
return emptyValues[emptyIndex]
}
return constructor[emptySymbol]
// Create empty instance and store it
const emptyInstance = empty(Object.create(prototype))
emptyValues[emptyKeys.length] = emptyInstance
emptyKeys.push(prototype)
return emptyInstance
}

@@ -56,0 +61,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