js.private
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -22,6 +22,4 @@ "use strict"; | ||
this.props = props; | ||
this.owners = []; | ||
this.values = []; | ||
this.key = Math.random().toString(36).replace(/^.{2}/, "_private_"); | ||
this.get = this.get.bind(this); | ||
this.get.destroy = this.destroy.bind(this); | ||
} | ||
@@ -32,5 +30,3 @@ | ||
value: function get(context) { | ||
var key = this.owners.indexOf(context); | ||
if (key < 0) key = this.set(context); | ||
return this.values[key]; | ||
return context[this.key] || this.set(context); | ||
} | ||
@@ -43,11 +39,4 @@ }, { | ||
if (clone.hasOwnProperty(attr) && clone[attr] instanceof Function) clone[attr] = clone[attr].bind(context); | ||
}this.owners.push(context); | ||
return this.values.push(clone) - 1; | ||
}return context[this.key] = clone; | ||
} | ||
}, { | ||
key: "destroy", | ||
value: function destroy(context) { | ||
var key = this.owners.indexOf(context); | ||
return delete this.owners[key] && delete this.values[key]; | ||
} | ||
}]); | ||
@@ -54,0 +43,0 @@ |
{ | ||
"name": "js.private", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Private properties for objects", | ||
@@ -5,0 +5,0 @@ "main": "./dst/Private.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3928
65