Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

typeof-article

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typeof-article

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

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
300K
increased by2.84%
Maintainers
1
Weekly downloads
 
Created
Source

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.

Keywords

FAQs

Package last updated on 30 Jan 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc