New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

math.format

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

math.format

Methods to check values and format numbers.

  • 1.0.4
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
11
decreased by-8.33%
Maintainers
1
Weekly downloads
 
Created
Source

Build Status

Math.format

Method to check values and format numbers.

Usage

Math.format(34.5279, {'round': -2}); // Returns 34.53
Math.format(34.5279, {'round': 0}); // Returns 35
Math.format(34.5279, {'round': 1}); // Returns 30

Math.format(34.5279, {'floor': -2}); // Returns 34.52
Math.format(34.5279, {'floor': 0}); // Returns 34
Math.format(34.5279, {'floor': 1}); // Returns 30

Math.format(34.5279, {'ceil': -2}); // Returns 34.53
Math.format(34.5279, {'ceil': 0}); // Returns 35
Math.format(34.5279, {'ceil': 1}); // Returns 40

Math.format(34.5279, {'min': 40}); // Returns 40
Math.format(34.5279, {'max': 30}); // Returns 30

Math.format('a string', {'ifNaN': 'custom value'}); // Returns 'custom value'
Math.format('', {'ifEmpty': 'custom value'}); // Returns 'custom value'
Math.format(undefined, {'ifEmpty': 'custom value'}); // Returns 'custom value'
Math.format(Infinity, {'ifInfinity': 'custom value'}); // Returns 'custom value'

Math.format(2, {'preProcess': '(x + 2) * 3'}); // Returns 12
Math.format(2, {'postProcess': '(x + 2) * 3'}); // Returns 12
Math.format(2, {'preProcess': '(x + 2) * 3', 'max': 10}); // Returns 10
Math.format(2, {'postProcess': '(x + 2) * 3', 'max': 10}); // Returns 12

Math.format(2, {'prefix': 'hello '}); // Returns 'hello 2'
Math.format(2, {'suffix': ' times'}); // Returns '2 times'
Math.format(2, {'prefix': 'hello ', 'suffix': ' times'}); // Returns 'hello 2 times'

Unit tests

Unit tests are made with Mocha. Just launch npm test to run it.

Contribute

Be careful that I use Git-flow to organize the repository branches, so make your pull requests to the develop branch.

$ npm install
$ npm test
$ npm run watch

Webpack will compile your code in the build directory.

Source

FAQs

Package last updated on 15 Oct 2016

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