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

core-extensions

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

core-extensions - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

75

index.js

@@ -7,2 +7,32 @@ "use strict";

Object.defineProperty( Object.prototype, "clone", {
enumerable: false,
value: function () {
var target = null;
var type = typeof this;
if ( this === undefined ) {
target = undefined;
}
else if ( this === null ) {
target = null;
}
else if ( type == 'string' || type == 'number' || type == 'boolean' ) {
target = this;
}
else if ( this instanceof Date ) {
target = new Date( this.toISOString() );
}
else if ( Object.isObject( this ) || Array.isArray( this ) ) {
target = JSON.parse( JSON.stringify( this ) ); // probably a slightly more efficient way to do this, but this is ok for now
}
else { // functions, etc. not clonable yet
target = undefined;
}
return target;
}
} );
Object.defineProperty( Object.prototype, "mixin", {

@@ -47,5 +77,14 @@ enumerable: false,

// ...replace target array with a new array containing existing values and new values
child[ name ] = target.concat( source );
// ...merge source array into target array
for ( var j = 0; j < source.length; j++ ) {
if ( typeof child[ name ][j] === 'object' ) {
child[ name ][j] = child[ name ][j].mixin( source[j] );
}
else {
child[ name ][j] = source[j];
}
}
}

@@ -63,3 +102,3 @@

child[ name ] = source;
child[ name ] = source.clone();

@@ -76,34 +115,4 @@ }

Object.defineProperty( Object.prototype, "clone", {
enumerable: false,
value: function () {
var target = null;
var type = typeof this;
if ( this === undefined ) {
target = undefined;
}
else if ( this === null ) {
target = null;
}
else if ( type == 'string' || type == 'number' || type == 'boolean' ) {
target = this;
}
else if ( this instanceof Date ) {
target = new Date( this.toISOString() );
}
else if ( Object.isObject( this ) || Array.isArray( this ) ) {
target = JSON.parse( JSON.stringify( this ) ); // probably a slightly more efficient way to do this, but this is ok for now
}
else { // functions, regex, etc. not clonable yet
throw "Cannot clone " + typeof this;
}
return target;
}
} );

@@ -5,3 +5,3 @@ {

"author": "Anthony Hildoer <anthony@bluerival.com>",
"version": "0.0.2",
"version": "0.0.3",
"repository": {

@@ -8,0 +8,0 @@ "type": "git",

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