Big news!Introducing Socket AI - ChatGPT-Powered Threat Analysis.Learn more
Socket
Socket

es-to-primitive

Package Overview
Dependencies
3
Maintainers
1
Versions
6
Issues
File Explorer

Advanced tools

es-to-primitive

ECMAScript “ToPrimitive” algorithm. Provides ES5 and ES2015 versions.

    1.2.1latest
    GitHub
    npm

Version published
Maintainers
1
Weekly downloads
25,546,830
increased by4.81%

Weekly downloads

Readme

Source

es-to-primitive Version Badge

Build Status dependency status dev dependency status License Downloads

npm badge

ECMAScript “ToPrimitive” algorithm. Provides ES5 and ES2015 versions. When different versions of the spec conflict, the default export will be the latest version of the abstract operation. Alternative versions will also be available under an es5/es2015 exported property if you require a specific version.

Example

var toPrimitive = require('es-to-primitive'); var assert = require('assert'); assert(toPrimitive(function () {}) === String(function () {})); var date = new Date(); assert(toPrimitive(date) === String(date)); assert(toPrimitive({ valueOf: function () { return 3; } }) === 3); assert(toPrimitive(['a', 'b', 3]) === String(['a', 'b', 3])); var sym = Symbol(); assert(toPrimitive(Object(sym)) === sym);

Tests

Simply clone the repo, npm install, and run npm test

Keywords

FAQs

Last updated on 09 Nov 2019

Did you know?

Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install Socket
Socket
Socket SOC 2 Logo

Product

  • Package Issues
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc