JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 8
  • Score
    100M100P100Q47023F
  • License ISC

Package Exports

  • y2fixed
  • y2fixed/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (y2fixed) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

About

Similar to .toFixed(), but can be ceil, floor or round (default)

const y2fixed = require('y2fixed')
let v = 1.234
t = y2fixed(v, 2, "floor") // t: 1.23
t = y2fixed(v, 2, "ceil") // t: 1.24
t = y2fixed(v, 2) // t: 1.23 (round)

parameters

y2fixed(v, decimals, op)
  • v: number|string
  • decimals: 0-100 integer
  • op (options): string or object
    • string: ceil|floor|undefined(round)
    • object: {type, string}
      • type: ceil|floor|undefined(round)
      • string|str|s: 0|1, return as string, default: 0 (return as number)
      • ceil: 0|1 // default 0; shorthand for type:'ceil'
      • floor: 0|1 // default 0; shorthand for type:'floor'
  • return: number(default)|string(op:{str:1})

eg2 (options)

let v = 1.2345
t = y2fixed(v, 2, {type:'floor', s:1}) // string|str|st|s: 0|1, return as string, default 0: number
t = y2fixed(v, 2, "ceil") // t: 1.24
t = y2fixed(v, 2) // t: 1.23, same as v.toFixed(2)
t = y2fixed(v, 3, {floor:1}) // t:1.234

notes

  • default return is number instead of string