@autots/fn
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Table of Contents

formatNumber

省略第二个参数,则默认按 '万'(level = 10000, unit = '万‘) 转换,保留 1(precision = 1) 位小数

Parameters

  • n number
  • config (optional, default {level:10000,precision:1,unit:'万'})

Examples

formatNumber(9999) -> 9999
formatNumber(10001) -> '1万'
formatNumber(14999) -> '1.5万'

Returns (number | string)

limitMaxNumber

限制展示的最大数字

Parameters

  • n number 被转换的数字
  • max 触发转换规则的【阀值】,默认为 99 (optional, default 99)
  • suffix 转换后添加的【后缀符号】,默认为 '+' (optional, default '+')

Returns (number | string) 转换结果

formatUrl

后端返回的地址有时是 http 的,浏览器会提醒站点安全问题或一些业务无关的展示 Bug

Parameters

Returns string

addPre0

省略第二个参数,则数字最长 = 2

Parameters

Examples

addPre0(1) => '01'

Returns string

formatDuration

格式化【秒】 => 时:分:秒

Parameters

Returns String 格式化为[:]:

isServer

判断是否是 Server 端

Returns boolean

importScript

动态引入脚本

Parameters

Returns Promise<HTMLScriptElement> 创建的 script 元素

/@autots/fn/

    Package Sidebar

    Install

    npm i @autots/fn

    Weekly Downloads

    1

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    13.5 kB

    Total Files

    6

    Last publish

    Collaborators

    • atser
    • sharklegs
    • liihom
    • magnnus
    • jeff_yang
    • wukong16
    • elenino_m
    • hylurk