Comparing version 0.6.0 to 0.6.1
@@ -48,2 +48,5 @@ // Copyright 2012 The Obvious Corporation. | ||
/** extended type name */ | ||
var NULLISH = "null or undefined"; | ||
/** type name */ | ||
@@ -215,3 +218,3 @@ var NUMBER = "number"; | ||
(Object.getPrototypeOf(x) === DATE_PROTOTYPE) && | ||
(baseToString(x) === '[object Date]'); | ||
(baseToString(x) === '[object Date]'); | ||
} | ||
@@ -278,2 +281,10 @@ | ||
function isNull(x) { | ||
return (x === null); | ||
} | ||
function isNullish(x) { | ||
return (x === null) || isUndefined(x); | ||
} | ||
function isNumber(x) { | ||
@@ -362,2 +373,14 @@ return (typeof x) === NUMBER; | ||
function assertNull(x) { | ||
if (!isNull(x)) { | ||
failType(x, NULL); | ||
} | ||
} | ||
function assertNullish(x) { | ||
if (!isNullish(x)) { | ||
failType(x, NULLISH); | ||
} | ||
} | ||
function assertNumber(x) { | ||
@@ -426,2 +449,4 @@ if (!isNumber(x)) { | ||
assertMap: assertMap, | ||
assertNull: assertNull, | ||
assertNullish: assertNullish, | ||
assertNumber: assertNumber, | ||
@@ -446,2 +471,4 @@ assertObject: assertObject, | ||
isMap: isMap, | ||
isNull: isNull, | ||
isNullish: isNullish, | ||
isNumber: isNumber, | ||
@@ -448,0 +475,0 @@ isObject: isObject, |
{ | ||
"name": "typ", | ||
"version": "0.6.0", | ||
"version": "0.6.1", | ||
"keywords": | ||
@@ -5,0 +5,0 @@ ["type", "assert", "predicate"], |
@@ -177,2 +177,11 @@ typ: Type predicates and assertions for Node | ||
### null: isNull(value), assertNull(value) | ||
The only value that is null is `null` per se. | ||
### nullish: isNullish(value), assertNullish(value) | ||
The only two values that are considered to be "nullish" are `null` | ||
and `undefined`. | ||
### number: isNumber(value), assertNumber(value) | ||
@@ -179,0 +188,0 @@ |
@@ -38,2 +38,4 @@ // Copyright 2012 The Obvious Corporation. | ||
{ assert: typ.assertMap, predicate: typ.isMap }, | ||
{ assert: typ.assertNull, predicate: typ.isNull }, | ||
{ assert: typ.assertNullish, predicate: typ.isNullish }, | ||
{ assert: typ.assertNumber, predicate: typ.isNumber }, | ||
@@ -101,4 +103,4 @@ { assert: typ.assertObject, predicate: typ.isObject }, | ||
// other | ||
{ v: null, p: [typ.isDefined] }, | ||
{ v: undefined, p: [typ.isUndefined] } | ||
{ v: null, p: [typ.isNull, typ.isNullish, typ.isDefined] }, | ||
{ v: undefined, p: [typ.isNullish, typ.isUndefined] } | ||
]; | ||
@@ -105,0 +107,0 @@ |
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
34422
558
290