bare-type
Cross-realm type predicates for Bare
Last updated 2 months ago by GitHub Actions .
Apache-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ npm install bare-type 
SYNC missed versions from official npm registry.

bare-type

Cross-realm type predicates for Bare.

npm i bare-type

Usage

const type = require('bare-type')

if (type(123).isNumber()) {
  console.log(123, 'is a number')
}

To test a value against many types at once, switch on type.of() rather than walking the predicates. Every constant carries its base type, so each one matches outright:

const type = require('bare-type')

const { ARRAY, DATE, MAP } = type.constants

switch (type.of(value)) {
  case ARRAY:
    return value.length
  case DATE:
    return value.getTime()
  case MAP:
    return value.size
}

API

See the bare-type reference.

Threat model

bare-type is one of the addons Bare compiles into its binary, so it inherits Bare's threat model. See docs/threat-model.md for where this addon sits in it.

License

Apache-2.0

Current Tags

  • 1.4.0                                ...           latest (2 months ago)

14 Versions

  • 1.4.0                                ...           2 months ago
  • 1.3.0                                ...           2 months ago
  • 1.2.0                                ...           2 months ago
  • 1.1.1                                ...           3 months ago
  • 1.1.0                                ...           a year ago
  • 1.0.8                                ...           a year ago
  • 1.0.7                                ...           a year ago
  • 1.0.6                                ...           2 years ago
  • 1.0.5                                ...           2 years ago
  • 1.0.4                                ...           2 years ago
  • 1.0.3                                ...           2 years ago
  • 1.0.2                                ...           2 years ago
  • 1.0.1                                ...           2 years ago
  • 1.0.0                                ...           3 years ago
Maintainers (1)
Downloads
Total 37
Today 2
This Week 3
This Month 20
Last Day 1
Last Week 16
Last Month 8
Dependencies (0)
None
Dev Dependencies (5)
Dependents (2)

© 2010 - cnpmjs.org x YWFE | Home | YWFE