UNPKG

icetool

Version:
64 lines (51 loc) 2.3 kB
<div align="center"> <h1>iIceTools</h1> <p> <a href="https://www.npmjs.com/package/icetool"><img src="https://img.shields.io/npm/v/icetool?maxAge=3600" alt="NPM version" /></a> <a href="https://www.npmjs.com/package/icetool"><img src="https://img.shields.io/npm/dt/icetool?maxAge=3600" alt="NPM downloads" /></a> </p> <p> <a href="https://www.npmjs.com/package/icetool"><img src="https://nodei.co/npm/icetool.png?downloads=true&stars=true" alt="NPM Banner"></a> </p> </div> # Table of contents - [Installation](#installation) - [Example Usage](#examples) # Installation ```shContact npm i icetool ``` # Examples ```ts import IceTools from 'icetool'; //Define the icetool module ``` #### Class NumberDateFormat ```ts import { NumberDateFormat } from 'icetool'; const dateFormat = new NumberDateFormat("us-US", {format: "MMMM Do YYYY, hh:mm:ss"}); dateFormat.format(Date.now()); // June 19th 2022, 18:05:01 ``` #### Class NumberFormat ```ts import { NumberFormat } from 'icetool'; const compactNumberShort = new NumberFormat("us-US", {compactDisplay: "short", decimalNumber: 3, style: "none"}); compactNumberShort.format(1234567.891011); // 1.235M const compactNumberLong = new NumberFormat("us-US", {compactDisplay: "long", decimalNumber: 3, style: "none"}); compactNumberLong.format(1234567.891011); // 1,234,567.891 const romanNumber = new NumberFormat("us-US", {style: "roman"}); romanNumber.format("XVII"); // 17 romanNumber.format(2408); // MMCDVIII romanNumber.format(16780); // ↂↁMDCCLXXX ``` #### Class NumberTimeFormat ```ts import { NumberTimeFormat } from 'icetool'; const shortTime = new NumberTimeFormat("us-US", {compactDisplay: "short", format: "End: HMS", separator: ", "}); shortTime.format(3738293); // End: 1h, 2m, 18s const yearsTime = new NumberTimeFormat("us-US", {compactDisplay: "long", format: "Y MM W D H M S MS", separator: " |"}); yearsTime.format(Date.now()); // 52 years | 5 months | 2 weeks | 3 days | 21 hours | 44 minutes | 23 seconds | 528 milliseconds const longTime = new NumberTimeFormat("us-US", {compactDisplay: "long"}); longTime.format("2h and 8m with 20s add 2day ... oh and 80ms"); // 180500080 ``` # Discord Join the [Discord](https://discord.gg/gJycUt946D)