Comparing version 0.2.2 to 0.2.3
@@ -18,3 +18,5 @@ var canSymbol = require("can-symbol"); | ||
function isNaN(assert, result) { | ||
assert.ok(Number.isNaN(result), "Is NaN value"); | ||
// result !== result is used because Number.isNaN doesn’t exist in IE11 | ||
// result !== result works because NaN is the only value not equal to itself in JS | ||
assert.ok(result !== result, "Is NaN value"); | ||
} | ||
@@ -145,3 +147,5 @@ | ||
QUnit.test("type.late(fn) takes a function to define the type later", function(assert) { | ||
var theType = type.late(() => type.convert(Number)); | ||
var theType = type.late(function() { | ||
return type.convert(Number); | ||
}); | ||
var result = canReflect.convert("45", theType); | ||
@@ -152,3 +156,5 @@ assert.equal(result, 45, "Defined late but then converted"); | ||
dev.devOnlyTest("type.late(fn) where the underlying type value is a builtin becomes a strict type", function(assert) { | ||
var typeType = type.late(() => Number); | ||
var typeType = type.late(function() { | ||
return Number; | ||
}); | ||
var result = canReflect.convert(45, typeType); | ||
@@ -155,0 +161,0 @@ assert.equal(result, 45, "works with numbers"); |
@@ -10,4 +10,7 @@ var canReflect = require("can-reflect"); | ||
var primitives = new Map(); | ||
[Number, String, Boolean].forEach(function(Type) { | ||
var typeString = Type.name.toLowerCase(); | ||
canReflect.each({ | ||
"boolean": Boolean, | ||
"number": Number, | ||
"string": String | ||
}, function(Type, typeString) { | ||
primitives.set(Type, { | ||
@@ -112,3 +115,3 @@ isMember: function(val) { | ||
function check(Type, val) { | ||
throw new Error(`Type value ${typeof val === "string" ? '"' + val + '"' : val} is not of type ${canReflect.getName(Type)}.`); | ||
throw new Error('Type value ' + typeof val === "string" ? '"' + val + '"' : val + ' is not of type ' + canReflect.getName(Type) + '.' ); | ||
} | ||
@@ -115,0 +118,0 @@ |
{ | ||
"name": "can-type", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"description": "Type definitions", | ||
@@ -15,3 +15,5 @@ "homepage": "https://canjs.com/doc/can-type.html", | ||
}, | ||
"browserslist": "ie 11", | ||
"scripts": { | ||
"ci": "npm run test && node test-saucelabs.js", | ||
"preversion": "npm test", | ||
@@ -21,2 +23,3 @@ "postpublish": "git push --tags && git push", | ||
"test": "npm run jshint && npm run testee", | ||
"http-server": "http-server -p 3000 --silent", | ||
"jshint": "jshint ./*.js --config", | ||
@@ -38,2 +41,3 @@ "release:patch": "npm version patch && npm publish", | ||
"can-test-helpers": "^1.1.4", | ||
"http-server": "^0.11.1", | ||
"jshint": "^2.9.1", | ||
@@ -43,2 +47,3 @@ "steal": "^2.1.6", | ||
"steal-tools": "^2.0.9", | ||
"test-saucelabs": "0.0.6", | ||
"testee": "^0.9.1" | ||
@@ -45,0 +50,0 @@ }, |
Sorry, the diff of this file is not supported yet
33353
23
393
8