Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@encodable/format

Package Overview
Dependencies
Maintainers
2
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@encodable/format

Utilities for managing time and number formats.

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
14K
decreased by-19.82%
Maintainers
2
Weekly downloads
 
Created
Source

@encodable/format

Version David (path)

Utilities for managing time and number formats. Built on top of D3 formats and support customizing your own formatters.

Install

npm install @encodable/format global-box

Example usage

import {
  getTimeFormat,
  formatTime,
  getNumberFormat,
  formatNumber,
  getNumberFormatterRegistry,
} from '@encodable/format';

// Get number format function
const numFormatFn = getNumberFormat('.2f');
// Get time format function
const timeFormatFn = getTimeFormat('%Y-%m-%d');

// or just format directly

formatNumber('.2f', 200); // 200.00
formatTime('%Y-%m-%d', new Date()); // 2020-08-15

// can customize by adding your own formatters
// or override the d3 ones

getNumberFormatterRegistry().registerValue('my-format', (x) => `haha:${x}`);
formatNumber('my-format', 200); // haha:200

Keywords

FAQs

Package last updated on 20 Aug 2020

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc