New: Introducing PHP and Composer Support.Read the Announcement
Socket
Book a DemoInstallSign in
Socket

maskr

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

maskr

> A tiny (337B) reusable date formatter. Extremely fast!

Source
npmnpm
Version
0.0.0
Version published
Maintainers
1
Created
Source

maskr Build Status

A tiny (337B) reusable date formatter. Extremely fast!

Demo

Inspired by tinytime, this module returns a "render" function that efficiently re-render your deconstructed template. This allows for incredibly performant results!

However, please notice that this only provides a limited subset of Date methods. If you need more, tinytime or date-fns are great alternatives!

Install

$ npm install --save maskr

Usage

const maskr = require('maskr');
const fooDate = new Date('5/1/2017, 4:30:09 PM');

const stamp = maskr('Current time: [{HH}:{mm}:{ss}]');

stamp(fooDate);
//=> Current time: [16:30:09]

stamp();
//=> Current time: [17:09:34]

API

maskr(pattern)(date)

pattern

Type: string

The template pattern to be parsed.

date

Type: Date
Default: new Date()

The date from which to retrieve values. Defaults to current datetime.

Patterns

  • {YYYY}: full year; eg: 2017
  • {YY}: short year; eg: 17
  • {MM}: month; eg: 04
  • {DD}: day; eg: 01
  • {HH}: hours; eg: 06 (24h)
  • {mm}: minutes; eg: 59
  • {ss}: seconds; eg: 09

Benchmarks

maskr
  --> 72,236,210 ops/sec ±0.89% (91 runs sampled)
tinytime
  --> 27,530,608 ops/sec ±0.92% (93 runs sampled)
time-stamp
  --> 569,692 ops/sec ±0.80% (90 runs sampled)

License

MIT © Luke Edwards

FAQs

Package last updated on 30 May 2017

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