npm.io
1.0.1 • Published 6 years ago

js-int2str

Licence
GPL-3.0
Version
1.0.1
Deps
0
Size
37 kB
Vulns
0
Weekly
0

JS-Int2Str

A library for converting an integer to a customized string, seems like a free hex converter.

Install

npm install js-int2str --save

or

yarn add js-int2str

API


const { int2str, str2int } = require('js-int2str')

let ticks = new Date().getTime()
let str = int2str(ticks)
console.log(`当前时钟 ${ticks},转成字符串 ${str}`)
// 13位的数字被压缩为7位字符串
// 字符串前面补0依然等效
str = `0${str}`
console.log(`补0后转回数字是 ${str2int(str)}`)

Enjoy it :-)