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

stereotype

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

stereotype

Cast a string (where possible) to a primitive type.

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8.6K
decreased by-8%
Maintainers
1
Weekly downloads
 
Created
Source

Stereotype.js npm Version Build Status Coverage Status

Cast a string (where possible) to a primitive type.

Usage

stereotype('undefined'); //=> undefined
stereotype('null');      //=> null
stereotype('NaN');       //=> NaN
stereotype('Infinity');  //=> Infinity
stereotype('true');      //=> true
stereotype('3.14');      //=> 3.14
stereotype('0xFF');      //=> 255

stereotype({});          //=> {}
stereotype('foo');       //=> 'foo'

More usage examples are in the tests.

API

stereotype(obj)

Returns, where possible, obj cast to a primitive type. Otherwise returns obj if obj is not a string, or if obj cannot be cast to a primitive.

Installation

Install via npm:

$ npm i --save stereotype

License

MIT license

Keywords

FAQs

Package last updated on 23 Aug 2014

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