@stamp/arg-over-prop
Advanced tools
Comparing version 1.0.0 to 1.0.1
var ArgOverProp = require('..'); | ||
describe('@stamp/arg-over-prop', function () { | ||
it('can be used as a standalone function', function () { | ||
var argOverProp = ArgOverProp.argOverProp; | ||
var Stamp = argOverProp('override'); | ||
var instance = Stamp({override: 1, dontTouch: 2}); | ||
expect(instance.override).toBe(1); | ||
expect(instance).not.toHaveProperty('dontTouch'); | ||
}); | ||
it('assigns only the requested properties', function () { | ||
@@ -5,0 +14,0 @@ var Stamp = ArgOverProp.argOverProp('override'); |
12
index.js
@@ -28,6 +28,7 @@ var compose = require('@stamp/compose'); | ||
module.exports = compose({ | ||
var ArgOverProp = compose({ | ||
staticProperties: { | ||
argOverProp: function () { | ||
var propNames = [], defaultProps = {}; | ||
'use strict'; | ||
var propNames = [], defaultProps; | ||
for (var i = 0; i < arguments.length; i++) { | ||
@@ -41,3 +42,3 @@ var arg = arguments[i]; | ||
} else if (isObject(arg)) { | ||
assign(defaultProps, arg); | ||
defaultProps = assign(defaultProps || {}, arg); | ||
propNames = propNames.concat(Object.keys(arg)); | ||
@@ -47,3 +48,4 @@ } | ||
return this.compose({ | ||
var Stamp = this && this.compose ? this : ArgOverProp; | ||
return Stamp.compose({ | ||
deepConfiguration: {ArgOverProp: propNames}, | ||
@@ -68,1 +70,3 @@ properties: defaultProps // default property values | ||
}); | ||
module.exports = ArgOverProp; |
{ | ||
"name": "@stamp/arg-over-prop", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Assign properties passed to the stamp factory", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -26,2 +26,9 @@ # @stamp/arg-over-prop | ||
Or if you don't want to import the stamp you can import only the method: | ||
```js | ||
import {argOverProp} from '@stamp/arg-over-prop'; | ||
const StampA = argOverProp({foo: 1}); | ||
``` | ||
Basically, the `arg-over-prop` stamp sets properties in an initializer. | ||
@@ -28,0 +35,0 @@ The code below is what the `StampA` becomes. |
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
6705
126
64