0.1.5 • Published 7 years ago
typ3of v0.1.5
typ3of
A better typeof, all results are 3 characters long.
Usage
from test/usage.js:
var typ3of = require('typ3of'), same = require('assert').deepStrictEqual,
hi = 'hello';
function eql(values, types) { same(values.map(typ3of), types); }
// trivial values
eql([undefined, null, true, 42, 'foo', eql, {} ],
['und', 'nul', 'boo', 'num', 'str', 'fun', 'obj']);
// what's a number?
eql([0, -2, 3, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY, +hi],
repeat('num', 5).concat('NaN'));
// objects
eql([hi.split(), [], /RegExp/g, new Date()],
['arr', 'arr', 'rgx', 'dat' ]);
if (checkSupported(function () { return Buffer.from; })) {
eql([ Buffer.from(hi) ],
[ 'buf' ]);
}
Known issues
- needs more/better tests and docs
License
ISC