type-of-is
Advanced tools
Comparing version 3.2.1 to 3.3.0
23
index.js
@@ -80,2 +80,13 @@ (function (factory) { | ||
function extension (_Extension, _Base) { | ||
var SuperClass = _Extension; | ||
while (SuperClass.__super__) { | ||
SuperClass = SuperClass.__super__.constructor; | ||
if (SuperClass === _Base) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
function any (obj, tests) { | ||
@@ -106,10 +117,10 @@ if (!is(tests, Array)) { | ||
exports.instance = instance; | ||
exports.string = stringType; | ||
exports.of = of; | ||
exports.is = is; | ||
exports.any = any; | ||
exports.instance = instance; | ||
exports.string = stringType; | ||
exports.of = of; | ||
exports.is = is; | ||
exports.any = any; | ||
exports.extension = extension; | ||
return exports; | ||
})); |
{ | ||
"name": "type-of-is", | ||
"version": "3.2.1", | ||
"version": "3.3.0", | ||
"description": "Determine and test types using constructor or {}.toString", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -43,3 +43,3 @@ # Description | ||
3.2.1 | ||
3.3.0 | ||
@@ -59,3 +59,3 @@ | ||
"dependencies": { | ||
"type-of-is": "3.2.x" | ||
"type-of-is": "~3.3.0" | ||
} | ||
@@ -75,2 +75,3 @@ } | ||
Type.instance(obj, type); // wrapper of "obj instanceof type" | ||
Type.extension(SomeCoffeeScriptClassThatExtendsBarf, SomeCoffeeScriptClassNamedBarf) | ||
@@ -77,0 +78,0 @@ // The top level Type export delegates to Type.of or Type.is based on argument count |
@@ -14,2 +14,4 @@ var Path = require('path'); | ||
var BarfClasses = require('./BarfClasses') | ||
Asserts({ | ||
@@ -144,3 +146,17 @@ "Type, Type.of, and Type.string should properly find types": function () { | ||
}, /should be array/); | ||
}, | ||
"Type.extension(ClassA, ClassB) should properly check CoffeeScript inheritance" : function () { | ||
var Barf = BarfClasses.Barf; | ||
var Hurl = BarfClasses.Hurl; | ||
var Chuck = BarfClasses.Chuck; | ||
var Derp = BarfClasses.Derp; | ||
Assert.equal(Type.extension(Hurl, Barf), true, 'Hurl < Barf'); | ||
Assert.equal(Type.extension(Chuck, Barf), true, 'Chuck < Barf'); | ||
Assert.equal(Type.extension(Chuck, Hurl), true, 'Chuck < Hurl'); | ||
Assert.equal(Type.extension(Barf, Hurl), false, 'Barf < Hurl'); | ||
Assert.equal(Type.extension(Barf, Chuck), false, 'Barf < Chuck'); | ||
Assert.equal(Type.extension(Barf, Derp), false, 'Barf < Derp'); | ||
Assert.equal(Type.extension(Derp, Barf), false, 'Derp < Barf'); | ||
} | ||
}); |
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
24488
12
377
225