0.1.5 • Published 7 years ago

typ3of v0.1.5

Weekly downloads
3
License
ISC
Repository
github
Last release
7 years ago

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

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago