Socket
Book a DemoInstallSign in
Socket

@arugaz/formatter

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@arugaz/formatter

Formatter library with tiny size in ~1 Kbytes!

1.0.0-z.2
latest
Source
npmnpm
Version published
Weekly downloads
9
-25%
Maintainers
1
Weekly downloads
 
Created
Source

npm version install size npm downloads

Formatter library with tiny size in ~1 Kbytes!

Table of Contents

Features

  • Simple and Familiar API
  • Unobstrusive and Unopinionated

Install

$ npm install --save @arugaz/formatter
$ yarn add @arugaz/formatter

Usage

import Format from "@arugaz/formatter";

// size formatter
const format = Format.sizeFormatter({
  std: "JEDEC", // 'SI' | 'IEC' | 'JEDEC' (default)
  decimalPlaces: 2,
  keepTrailingZeroes: false,
  render: (literal, symbol) => `${literal} ${symbol}B`,
});

format(1024); //=> '1 KB'

// duration formatter
const span = Date.now() - Date.parse("2019-01-01T09:00:00.000+0200");

const format = Format.durationFormatter({
  // default 'y' | 'mo' | 'w' | 'd' | 'h' | 'm' | 's' | 'ms'
  allowMultiples: ["y", "mo", "d"],
  keepNonLeadingZeroes: false, // E.g. '1y 0mo 0d'
});

format(span); //=> '1y 1mo 19d'
import { sizeFormatter } from "@arugaz/formatter";

// size formatter
const format = sizeFormatter({
  std: "JEDEC", // 'SI' | 'IEC' | 'JEDEC' (default)
  decimalPlaces: 2,
  keepTrailingZeroes: false,
  render: (literal, symbol) => `${literal} ${symbol}B`,
});

format(2048); //=> '2 KB'

License

MIT

Keywords

formatter

FAQs

Package last updated on 14 Jan 2023

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.