@stamp/collision
Advanced tools
Comparing version
@@ -176,5 +176,10 @@ var compose = require('@stamp/compose'); | ||
it('forbid + allow', function () { | ||
expect(function () {Collision.collisionSetup({allow: ['foo'], forbid: ['foo']})}).toThrow(); | ||
expect(function () {Collision.collisionSetup({allow: ['foo'], forbid: ['foo']})}).toThrow(/Collision/); | ||
}); | ||
it('can be used as a standalone function', function () { | ||
var collisionSetup = Collision.collisionSetup; | ||
expect(function () {collisionSetup({allow: ['foo'], forbid: ['foo']})}).toThrow(/Collision/); | ||
}); | ||
it('forbid without conflicts', function () { | ||
@@ -181,0 +186,0 @@ var Forbid = compose({ |
@@ -56,7 +56,10 @@ var compose = require('@stamp/compose'); | ||
module.exports = compose({ | ||
var Collision = compose({ | ||
deepConfiguration: {Collision: {defer: [], forbid: []}}, | ||
staticProperties: { | ||
collisionSetup: function (opts) { | ||
return this.compose({deepConfiguration: {Collision: opts}}); | ||
'use strict'; | ||
var Stamp = this && this.compose ? this : Collision; | ||
return Stamp.compose({deepConfiguration: {Collision: opts}}); | ||
}, | ||
@@ -182,1 +185,3 @@ collisionSettingsReset: function () { | ||
}); | ||
module.exports = Collision; |
{ | ||
"name": "@stamp/collision", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Detect and manipulate method collisions", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -5,10 +5,24 @@ # @stamp/collision | ||
The `defer` collects same named methods and wraps them into a single method. | ||
This stamp (aka behavior) will check if there are any conflicts on every `compose` call. | ||
Throws an `Error` in case of a forbidden collision or ambiguous setup. | ||
This stamp (aka behavior) will check on every `compose` call if there are any conflicts. Throws an `Error` in case of a forbidden collision or ambiguous setup. | ||
## Usage | ||
## Usage | ||
```js | ||
import Collision from '@stamp/collision'; | ||
const ForbidRedrawCollision = Collision.collisionSetup({forbid: ['redraw']}); | ||
``` | ||
Or if you don't want to import the stamp you can import only the method: | ||
```js | ||
import {collisionSetup} from '@stamp/collision'; | ||
const ForbidRedrawCollision = collisionSetup({forbid: ['redraw']}); | ||
``` | ||
The `defer` collects same named methods and wraps them into a single method. | ||
```js | ||
import Collision from '@stamp/collision'; | ||
import {Border, Button, Graph} from './drawable/primitives'; | ||
@@ -15,0 +29,0 @@ |
16648
4.19%395
1.8%110
14.58%