private-proxy
Advanced tools
Comparing version 0.0.1 to 0.0.2
{ | ||
"name": "private-proxy", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "description": "Convert any object into one that supports private properties, using the familiar Object API for getting and setting keys.", |
@@ -5,3 +5,2 @@ ## Features | ||
- Leverages the Proxy object. | ||
- Objects retain original prototype. | ||
- Objects are inspectable, and non-private properties are mutable/inspectable. | ||
@@ -28,3 +27,3 @@ | ||
#### Works with any objects, included classes | ||
#### Works with any objects, including classes | ||
@@ -31,0 +30,0 @@ ``` |
27
test.js
@@ -1,2 +0,2 @@ | ||
const p = require('./index.js'); | ||
const pp = require('./index.js'); | ||
const assert = require('assert'); | ||
@@ -8,3 +8,3 @@ | ||
myObj.name = 'Robert'; | ||
const privateObj = p(myObj); | ||
const privateObj = pp(myObj); | ||
@@ -19,3 +19,3 @@ assert(privateObj.name === 'Robert', 'Public property is accessible directly'); | ||
it('locks an object upon conversion, so that all keys defined thereafter are considered private', () => { | ||
const privateObj = p({}); | ||
const privateObj = pp({}); | ||
privateObj.name = 'Rob'; | ||
@@ -34,3 +34,3 @@ privateObj.name = 'Joey'; | ||
} | ||
const privateAnimal = p(new Animal('Fido')); | ||
const privateAnimal = pp(new Animal('Fido')); | ||
@@ -54,21 +54,6 @@ assert(privateAnimal instanceof Animal, 'Class instance is unchanged'); | ||
}; | ||
const privateObj = p(myObj); | ||
const privateObj = pp(myObj); | ||
privateObj.age = 25; | ||
assert(Object.keys(privateObj).length === 1 && Object.keys(privateObj)[0] === 'name', 'Only public properties are enumerable'); | ||
}); | ||
}) | ||
// console.log(myObj); | ||
// let myObj2 = {}; | ||
// console.log(myObj2); | ||
// myObj.name = 'Rob'; | ||
// console.log(myObj); | ||
// myObj2.name = 'Rob'; | ||
// console.log(myObj2); | ||
// myObj2 = privateProps(myObj2); | ||
// console.log(myObj2, myObj2.name); | ||
// myObj.name = 'Joey'; | ||
// console.log(myObj, myObj.name); | ||
// myObj2.name = 'Joey'; | ||
// console.log(myObj2.name); | ||
// console.log(myObj.name); | ||
}); |
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
4769
59
72