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

jsupack

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsupack - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

2

package.json
{
"name": "jsupack",
"version": "1.3.0",
"version": "1.4.0",
"license": "MIT",

@@ -5,0 +5,0 @@ "description": "JavaScript Utilities",

@@ -25,4 +25,6 @@ # jsu

Documentation and examples are available [here](doc).
Version changelog is [here](CHANGELOG.md).
Version changelog is [here](CHANGELOG.md), with each version corresponding to a
[tag](https://github.com/arlogy/jsu/tags).
## Tests

@@ -29,0 +31,0 @@

@@ -68,6 +68,4 @@ /*

return typeof value === 'number' && isFinite(value);
// Number.isFinite() is used instead of !Number.isNaN() for example
// because we want to define a number as a finite value (strings
// excluded); moreover, Number.isNaN(undefined) will return false for
// example
// Number.isFinite() is used because we want to define a number as a
// finite value (strings excluded)
};

@@ -95,2 +93,7 @@

// can be used internally when the value used to override the corresponding
// API.* property is not important; all we want is a check function and the
// initial implementation is sufficient
var _isArray = API.isArray;
// --- Property Accessor/Modifier ---

@@ -214,3 +217,3 @@

function _cloneDeep(value, isArrayFunc, cache) {
function _cloneDeep(value, cache, cloneCustomImpl) {
switch(typeof value) {

@@ -225,4 +228,6 @@ case 'undefined':

case 'symbol':
return cache.get(value) || cache.add(value, Symbol(value.description));
case 'symbol': {
var copy = cache.get(value);
return copy !== undefined ? copy : cache.add(value, Symbol(value.description));
}

@@ -233,3 +238,3 @@ case 'object': {

var copy = cache.get(value);
if(copy) return copy;
if(copy !== undefined) return copy;
if(value instanceof Boolean) return cache.add(value, new Boolean(value.valueOf()));

@@ -241,14 +246,17 @@ if(value instanceof Date) return cache.add(value, new Date(value.valueOf()));

var i = undefined;
if(isArrayFunc(value)) {
if(_isArray(value)) {
copy = [];
cache.add(value, copy); // cache value before the recursive _cloneDeep() call below
cache.add(value, copy); // cache data before the recursive _cloneDeep() calls below
var valueLen = value.length;
for(i = 0; i < valueLen; i++) {
copy.push(_cloneDeep(value[i], isArrayFunc, cache));
copy.push(_cloneDeep(value[i], cache, cloneCustomImpl));
}
}
else if(cloneCustomImpl && ((copy = cloneCustomImpl(value, cache)) !== undefined)) {
// nothing to do because value is already cloned
}
else {
// clone object partially based on Object.keys()
// clone object based on Object.keys()
// i.e. inherited and non-enumerable properties are ignored
// but this is enough for object literals ({...}) only referencing value types handled in this function
// this is enough for object literals ({...})
// e.g. {x:3, y:{}, z:[null, {}, Symbol()]}

@@ -258,3 +266,3 @@ // all the JavaScript built-in objects that one might want to support can be found at

copy = {};
cache.add(value, copy); // cache value before the recursive _cloneDeep() call below
cache.add(value, copy); // cache data before the recursive _cloneDeep() calls below
var valueKeys = Object.keys(value);

@@ -264,3 +272,3 @@ var valueKeysLen = valueKeys.length;

var prop = valueKeys[i];
copy[prop] = _cloneDeep(value[prop], isArrayFunc, cache);
copy[prop] = _cloneDeep(value[prop], cache, cloneCustomImpl);
}

@@ -271,3 +279,3 @@ }

default: // will not be reached but still retained
default: // will not be reached but retained anyway
return value;

@@ -277,17 +285,25 @@ }

API.cloneDeep = function(value) {
return _cloneDeep(value, API.isArray, {
_keys: [],
_vals: [],
get: function(key) {
var idx = this._keys.indexOf(key);
return idx !== -1 ? this._vals[idx] : undefined;
},
add: function(key, val) { // must be called only if get(key) did not find an entry
// this is to prevent the key from being added more than once
this._keys.push(key);
this._vals.push(val);
return val;
},
});
API.cloneDeep = function(value, cache, cloneCustomImpl) {
if(!cache) {
cache = {
_keys: [],
_vals: [],
// returns the value to which key is mapped, or undefined if key is not found
// key can be anything including an object
get: function(key) {
var idx = this._keys.indexOf(key);
return idx !== -1 ? this._vals[idx] : undefined;
},
// maps key to val (which must not be undefined because get() returns undefined if key is not found)
// must be called only if get(key) did not find an entry
// this is to prevent key from being added more than once
// returns val
add: function(key, val) {
this._keys.push(key);
this._vals.push(val);
return val;
},
};
}
return _cloneDeep(value, cache, cloneCustomImpl);
};

@@ -294,0 +310,0 @@

@@ -74,3 +74,3 @@ /*

if(!arr[0].every(function(val) { return arr[1].indexOf(val) === -1 && arr[2].indexOf(val) === -1; }))
throw new RangeError('values cannot be shared between field delimiter, field separators and line separators');
throw new RangeError('Values cannot be shared between field delimiter, field separators and line separators');
});

@@ -77,0 +77,0 @@ }

@@ -268,3 +268,3 @@ /*

str,
latexCommands.map(function(cmd) { return '\\' + cmd; }) // be aware of regex-alternation-note
latexCommands.map(function(cmd) { return '\\' + cmd; })
);

@@ -271,0 +271,0 @@ return str;

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