JSPM

typeof-article

0.1.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 362291
  • Score
    100M100P100Q179787F
  • License MIT

Get the native JavaScript type of a value, preceded by the appropriate indefinite article (either `a` or `an`), for use in error messages.

Package Exports

  • typeof-article

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (typeof-article) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

typeof-article NPM version NPM monthly downloads NPM total downloads Linux Build Status

Get the native JavaScript type of a value, preceded by the appropriate indefinite article (either a or an), for use in error messages.

Install

Install with npm:

$ npm install --save typeof-article

Usage

(A few of the types have some extra formatting where it makes sense. For example, instead of a regexp, it returns a regular expression, which IMHO is more readable to users. You can customize mappings if you want)

var type = require('typeof-article');

console.log(type({}));
//=> 'an object'

console.log(type([]));
//=> 'an array'

console.log(type(9));
//=> 'a number'

console.log(type(/abc/));
//=> 'a regular expression'

console.log(type(new WeakMap()));
//=> 'a WeakMap'

Get the object of types-to-articles mappings:

var types = require('typeof-article').types;

Also exposes a typeOf property, for getting the native type only:

var type = require('typeof-article');
type.types.weapmap = 'a WeakMap()';

console.log(type.typeOf(new WeakMap()));
//=> 'weakmap'

Customize

Customize any of the mappings:

var type = require('typeof-article');
type.types.weapmap = 'a WeakMap()';

console.log(type(new WeakMap()));
//=> 'a WeakMap()'

About

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Please read the contributing guide for advice on opening issues, pull requests, and coding standards.

Building docs

(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)

To generate the readme, run the following command:

$ npm install -g verbose/verb#dev verb-generate-readme && verb

Running tests

Install dev dependencies:

$ npm install && npm test

Author

Jon Schlinkert

License

Copyright © 2017, Jon Schlinkert. MIT


This file was generated by verb-generate-readme, v0.4.2, on January 30, 2017.