blueconfig-format-with-moment

6.2.2 • Public • Published

Blueconfig-format-with-moment

NPM version

Format 'duration' and 'timestamp' for blueconfig with momentjs.

Install

npm install blueconfig-format-with-moment

Usage

An example config.js file:

const blueconfig = require('blueconfig');
 
blueconfig.addFormat(require('blueconfig-format-with-moment').duration);
blueconfig.addFormat(require('blueconfig-format-with-moment').timestamp);
 
// Define a schema
var config = blueconfig({
  format: {
    format: 'duration'
  },
  format: {
    format: 'timestamp'
  }
});

Validation

This package uses moment.js to validate:

  • duration - milliseconds or a human readable string (e.g. 3000, "5 days")
  • timestamp - Unix timestamps or date strings recognized by moment.js

Coercion

Blueconfig will automatically coerce strings variables to their proper types when importing them. duration and timestamp are also parse and converted into numbers, though they utilize moment.js for date parsing.

Package Sidebar

Install

npm i blueconfig-format-with-moment

Weekly Downloads

0

Version

6.2.2

License

Apache-2.0

Unpacked Size

3.95 kB

Total Files

4

Last publish

Collaborators

  • a-312