functionality
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -60,2 +60,3 @@ var _ = require('lodash'); | ||
var mask = state.mask; | ||
var value = state.value; | ||
if(!mask.match(state)) | ||
@@ -85,9 +86,6 @@ return false; | ||
for(var i = 0; i < Masquerade.types.length; i++) | ||
if(mask === Masquerade.types[i][0]) return Masquerade.types[i][1]; | ||
if(Array.isArray(mask) && mask.length === 1) return new Masquerade("[" + mask[0].name + "]", function(value) { | ||
if(!Array.isArray(value)) return false; | ||
if(!(mask[0] instanceof Masquerade)) mask = Masquerade.type(mask[0]); | ||
return Masquerade.match([mask], value, true); | ||
var actualMask = Masquerade.type(mask[0]); | ||
return Masquerade.match([actualMask], value, true); | ||
}); | ||
@@ -100,2 +98,5 @@ | ||
for(var i = 0; i < Masquerade.types.length; i++) | ||
if(mask === Masquerade.types[i][0]) return Masquerade.types[i][1]; | ||
return new Masquerade("InstanceOf", function(value) { | ||
@@ -102,0 +103,0 @@ // Masquerade => new Masquerade() |
{ | ||
"name": "functionality", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Simple function overloading for JavaScript", | ||
@@ -5,0 +5,0 @@ "author": "Sierra Softworks", |
@@ -20,2 +20,26 @@ var fn = require('../'); | ||
}); | ||
describe('Object masking Array', function() { | ||
it('should not mask an [Object] (or similar) option if Object is also an option', function() { | ||
var f = fn.on(Object, fn.gobble(), function(obj) { | ||
return false; | ||
}).on([Object], fn.opt(Function), function(objs, cb) { | ||
return true; | ||
}).compile(); | ||
f({ a: 1 }).should.be.false; | ||
f([{ a: 1 }]).should.be.true; | ||
}); | ||
it('should not mask an [Object] (or similar) option if Object is also an option and retry() is used', function() { | ||
var f = fn.on(Object, fn.gobble(), function(obj) { | ||
return this.retry([obj]); | ||
}).on([Object], fn.opt(Function), function(objs, cb) { | ||
return true; | ||
}).compile(); | ||
f({ a: 1 }).should.be.true; | ||
f([{ a: 1 }]).should.be.true; | ||
}); | ||
}); | ||
}); |
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
30867
565