@stamp/privatize
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -7,3 +7,3 @@ var compose = require('@stamp/compose'); | ||
var accessFoo, accessBar; | ||
var orig = compose({ | ||
var Orig = compose({ | ||
properties: {foo: 1}, | ||
@@ -18,3 +18,3 @@ methods: { | ||
}); | ||
var Stamp = orig.compose(Privatize).privatizeMethods('bar'); | ||
var Stamp = Orig.compose(Privatize).privatizeMethods('bar'); | ||
var instance = Stamp(); | ||
@@ -26,3 +26,3 @@ | ||
expect(accessFoo).toBe(1); | ||
expect(accessBar).toBe(orig.compose.methods.bar); | ||
expect(accessBar).toBe(Orig.compose.methods.bar); | ||
}); | ||
@@ -54,3 +54,3 @@ | ||
var Stamp = compose(Privatize, { | ||
properties: { bar: 'foo' }, | ||
properties: { bar: 'foo' } | ||
}); | ||
@@ -60,3 +60,26 @@ var instance = Stamp(); | ||
expect(instance.bar).toBeUndefined(); | ||
}); | ||
it('can be used as a standalone function', function () { | ||
var privatizeMethods = Privatize.privatizeMethods; | ||
var accessFoo, accessBar; | ||
var Orig = compose({ | ||
properties: {foo: 1}, | ||
methods: { | ||
bar: function () {}, | ||
checkAccess: function () { | ||
accessFoo = this.foo; | ||
accessBar = this.bar; | ||
} | ||
} | ||
}); | ||
var Stamp = privatizeMethods('bar').compose(Orig); | ||
var instance = Stamp(); | ||
expect(instance.foo).toBeUndefined(); | ||
expect(instance.bar).toBeUndefined(); | ||
instance.checkAccess(); | ||
expect(accessFoo).toBe(1); | ||
expect(accessBar).toBe(Orig.compose.methods.bar); | ||
}) | ||
}); |
@@ -41,3 +41,3 @@ var compose = require('@stamp/compose'); | ||
module.exports = compose({ | ||
var Privatize = compose({ | ||
initializers: [initializer], | ||
@@ -47,2 +47,3 @@ deepConfiguration: {Privatize: {methods: []}}, | ||
privatizeMethods: function () { | ||
'use strict'; | ||
var methodNames = []; | ||
@@ -55,3 +56,4 @@ for (var i = 0; i < arguments.length; i++) { | ||
} | ||
return this.compose({ | ||
var Stamp = this && this.compose ? this : Privatize; | ||
return Stamp.compose({ | ||
deepConfiguration: { | ||
@@ -72,1 +74,3 @@ Privatize: { | ||
}); | ||
module.exports = Privatize; |
{ | ||
"name": "@stamp/privatize", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Protect private properties", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -22,2 +22,8 @@ # @stamp/privatize | ||
Or if you don't want to import the stamp you can import only the method: | ||
```js | ||
import {privatizeMethods} from '@stamp/privatize'; | ||
const AuthWithPrivatePropertiesAndMethod = Auth.compose(privatizeMethods('setPassword')); | ||
``` | ||
## Warning! | ||
@@ -24,0 +30,0 @@ Every property you assign in the initializers will be private. |
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
7767
133
100