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.2.3 to 0.2.4

2

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

@@ -5,0 +5,0 @@ "main": "./dst/Private.js",

@@ -10,55 +10,3 @@ ### Install

```javascript
import Clone from "js.clone";
class Private {
constructor( props ){
this._key_ = `_${ Math.random().toString( 36 ).substr( 2, 7 ) }_`;
this._props_ = this.prepare( props );
}
prepare( props ){
for( let attr in props )
if( props.hasOwnProperty( attr ) && typeof props[ attr ] === `function` )
props[ attr ] = this.bind( this._key_, props[ attr ] );
return props;
}
bind( key, method ){
return function(){
return method.apply( this[ key ], arguments );
};
}
get( context ){
return context[ this._key_ ] || this.set( context );
}
set( context ){
let props = Object.create( this._props_, this.descriptor( this._key_, context ) );
for( let attr in this._props_ )
if( this._props_.hasOwnProperty( attr ) && typeof this._props_[ attr ] === `object` )
props[ attr ] = Clone( this._props_[ attr ] );
return Object.defineProperties( context, this.descriptor( this._key_, props ) )[ this._key_ ];
}
descriptor( name, value, configurable = false, writable = false, enumerable = false ){
return { [ name ]: { value, configurable, writable, enumerable } };
}
}
export default function( props ){
let instance = new Private( props );
return function( context ){
return instance.get( context );
};
}
import Private from "js.private";

@@ -65,0 +13,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