Socket
Book a DemoInstallSign in
Socket

number.prototype.toexponential

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

number.prototype.toexponential

An ES-spec-compliant Number.prototype.toExponential shim/polyfill/replacement that works as far down as ES3

latest
Source
npmnpm
Version
1.0.6
Version published
Maintainers
1
Created
Source

Number.prototype.toExponential Version Badge

github actions coverage dependency status dev dependency status License Downloads

npm badge

An ES-spec-compliant Number.prototype.toExponential shim/polyfill/replacement that works as far down as ES3

This package implements the es-shim API interface. It works in an ES3-supported environment and complies with the spec.

Where this is needed

In particular:

  • Edge 15-17, and the equivalent versions of ChakraCore, have a rounding bug
  • IE <= 11, and Edge <= 14, have a different rounding bug
  • IE 6-8 do not properly throw on ±Infinity as fractionalDigits
  • FF 3.6-86 have a rounding bug
  • Safari < 11 and FF < 50 incorrectly throw on edge cases

If you are not concerned with supporting these engines, there is no need to use this package.

Note: ES2018 increased the maximum range from 20 to 100. This package does not attempt to patch this difference.

Getting started

npm install --save number.prototype.exponential

Usage/Examples

console.log((-3).toExponential()); // "-3e+0"
console.log(0x10.toExponential(2)); // "1.60e+1"
console.log(1.23456.toExponential(5)); // "1.23456e+0"
console.log((-6.9e-11).toExponential(4)); // "-6.9000e-11"

Tests

Clone the repo, npm install, and run npm test

Keywords

ecmascript

FAQs

Package last updated on 19 Dec 2024

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