You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
804 B
22 lines
804 B
var types = {
|
|
Array: function (value) { return value !== null && value !== undefined && value.constructor === Array },
|
|
Boolean: function (value) { return typeof value === 'boolean' },
|
|
Function: function (value) { return typeof value === 'function' },
|
|
Nil: function (value) { return value === undefined || value === null },
|
|
Number: function (value) { return typeof value === 'number' },
|
|
Object: function (value) { return typeof value === 'object' },
|
|
String: function (value) { return typeof value === 'string' },
|
|
Buffer: function (value) { return Buffer.isBuffer(value) },
|
|
'': function () { return true }
|
|
}
|
|
|
|
// TODO: deprecate
|
|
types.Null = types.Nil
|
|
|
|
for (var typeName in types) {
|
|
types[typeName].toJSON = function (t) {
|
|
return t
|
|
}.bind(null, typeName)
|
|
}
|
|
|
|
module.exports = types
|
|
|