Skip to content

Releases: KooiInc/typeofAnything

v2.4

08 Nov 15:23

Choose a tag to compare

More fixes, more tests.

Added

  • The 'special syntax' (see demonstration page) now allows use of additional key notTypes with key (defaultValue).

Fixed

  • Handling of null/undefined for the special syntax.

v2.3

08 Nov 10:18

Choose a tag to compare

The demonstration page now doubles as test page. Testing revealed a few bugs/peculiarities (especially the handling of undefined/null) that are fixed in this new release. Furthermore from this version on typeofAnything can also be used in NodeJS.

v2.2

05 Nov 13:28

Choose a tag to compare

Notes for this version

  1. A number of ES20xx Objects contain the 'well known Symbol' Symbol.toStringTag in their prototype. Such objects use that Symbol for their string representation (toString).
    Such 'types' are not always available as known constructors in the (global) namespace (like for example HTMLElement or
    RegExp are), so one can't always use (for example) IS(new Float32Array(1), Float32Array)).
  2. For the Proxy type check, the global window `namespace disables the library for use in NodeJS.

Added/modified

  • When toStringTag is available IS(input) or [type] reports that as the 'type' of the input between square brackets (e.g. [object Array Iterator]).
  • One can check non-available global constructors using their string representation, e.g. IS(new Float32Array(1), "Float32Array")
  • window is removed from the rewritten Proxy, which enables its use in NodeJS.

See also MDN documentation

v2.1

05 Nov 09:30

Choose a tag to compare

  • the wrapper ($Wrap) encapsulates the input value
  • small fixes (isNothing, NaN reporting)
  • maybe: whenError optional, returns undefined without it

v2.0

30 Oct 14:19

Choose a tag to compare

Based on usage experiences and progressive insight, this library has been overhauled and simplified. The basic functionality (IS) is the same, with some addititions. Some exports are removed because they became obsolete.

The library use

Added functionality:

  • functionality for type checks except one or more type(s)
  • functionality to return a default value if checking input type(s) is unsuccessful
  • functionality to enable/disable reporting Proxy 'type' (enabled by default)

Added exports

  • xProxy: an Object to disable/enable reporting the Proxy 'type'.

Removed exports

  • is/type. After importing the typeofAnything module the symbols exist by default as Symbol.is and Symbol.type.
    This means that variables can be type checked with
    • [some variable][Symbol.is](...types)
    • [some variable][Symbol.type]
  • createWrappedProxy (obsolete)
  • extendObject (obsolete, is now default)
  • typeOf (adds nothing to existing functionality)

Renamed exports

  • $X is now named $Wrap

See the (updated) examples.

v1.0

29 Oct 14:53

Choose a tag to compare

First release