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

@webgap/format-utils

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@webgap/format-utils

Common formatter utilities to handle numbers, dates, times, etc.

  • 0.2.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

WebGAP Format Utils

Build Status Test Coverage Code Climate Dependency Status

NPM version NPM downloads

README

This is the format utilities module for WebGAP. Contains formatter for Dates, String, Numbers, Bytes and Percentage.

Dependencies

Loads default configuration using @webgap/configuration.
Depends on String for string format.
Depends on Numeral for number format.

Requirements

A configuration file must exist (check @webgap/configuration documentation).

API

Installation
npm install @webgap/format-utils --save
Usage
var format = require('@webgap/format-utils').format();
...
// using default options will output:
format.bytes(256000); // returns 256KB
format.percentage(1); // returns 100.00%
format.number(10); // returns 10.00
format.currentDateTimeUnix(); // returns e.g 1318781876406
format.date(1318781876406); // returns 2011-10-16 +00:00
format.dateTime(1318781876406); // returns 2011-10-16T16:17:56 +00:00
format.dateFromNow(1318781876406); // returns e.g. 4 years ago
format.truncate('This is a long string that should be truncated...lets make it a bit longer...and a bit longer...', 20); // 

Options

var options = {
  dateFormat: "YYYY-MM-DD Z",
  dateTimeFormat: "YYYY-MM-DDTHH:mm:ss Z",
  timeFormat: "HH:mm:ss Z",
  decimalFormat: "0,0.00",
  percentageFormat: "0.00%",
  byteFormat: "0.0b"
};
var format = require('@webgap/format-utils').format(options);
...
format.percentage(1); // 100.00%
...

Check tests for more examples.

License

Apache License, Version 2.0

Keywords

FAQs

Package last updated on 15 Dec 2015

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