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

js.private

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js.private - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

4

package.json
{
"name": "js.private",
"version": "0.0.2",
"version": "0.0.3",
"description": "Private properties for objects",

@@ -16,4 +16,4 @@ "main": "./dst/Private.js",

"dependencies": {
"js.clone": "^0.0.1"
"js.clone": ">0.0.1"
}
}

@@ -25,7 +25,2 @@ ### Install

remove(){
$.destroy( this ); // destroy private props to free memory
console.log( "i removed" );
}
}

@@ -49,4 +44,3 @@

man.generateInfo // > undefined
man.remove() // > "I removed"
```

@@ -7,13 +7,9 @@ import Clone from "js.clone";

constructor( props ){
this.props = props;
this.owners = [];
this.values = [];
this.get = this.get.bind( this );
this.get.destroy = this.destroy.bind( this );
this.props = props;
this.key = Math.random().toString( 36 ).replace( /^.{2}/, "_private_" );
this.get = this.get.bind( this );
}
get( context ){
let key = this.owners.indexOf( context );
if( key < 0 ) key = this.set( context );
return this.values[ key ];
return context[ this.key ] || this.set( context );
}

@@ -26,11 +22,5 @@

clone[ attr ] = clone[ attr ].bind( context );
this.owners.push( context );
return this.values.push( clone ) - 1;
return context[ this.key ] = clone;
}
destroy( context ){
let key = this.owners.indexOf( context );
return delete this.owners[ key ] && delete this.values[ key ];
}
}

@@ -37,0 +27,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