Socket
Socket
Sign inDemoInstall

parsec

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parsec

A duration parser and formatter to turn random garbage into program usable times.


Version published
Maintainers
1
Created
Source

ParSec

A duration parser and formatter to turn random garbage into program usable times.

Provides a clear, easy to use interface to parse strings into usable timings

Example:

Parsec('aug3 1920').format('{MONTH-NAME} {DAYS}{DAY-SUFFIX} {YEAR}') 
// August 3rd 1920

Documentation Navigation

  • Installation

  • Locales

  • Usage


Installation

NPM

Installing on NPM is simple, just open your terminal and run:

npm install parsec --save

Yarn

to install with Yarn, open your terminal and use:

yarn add parsec

Locales

Supported Locales

All languages supported by this module are translated to the best knowledge of the person submitting the translation, this means we are trying to get native speakers of the language to submit translations of time phrases in their local language,

LanguageNativeSupported SinceTranslator
EnglishEnglish0.0.1Fatalcenturion

Planned Locales

This table contains languages which we are planning to implement into the module, but have not managed to do just yet. If you are a native speaker of any of the languages below and would like to help translate, please get in touch so we can send you a translation package.

LanguageNative
GermanDeutsch
Frenchfrançais
Spanishespañol
Portugueseportuguês

Suggest a Locale

To suggest a Locale for ParSec, please open an issue and use the "Locale" tag informing us of the locale you wish to add

Usage

ParSec

Importing the module:

const ParSec = require('parsec');

Getting started:

This module is a hybrid function-object, this means that the module can be called by running both:

let parsed = ParSec('1 minute, 30 seconds and 145 milliseconds');

And:

let parsed = ParSec.parse('1 minute, 30 seconds and 145 milliseconds');

Note: in both cases here, parsed is an instance of TimeConstruct.
TimeConstruct is a custom class built to provide detailed information about your parsed results.
Read the documentation on TimeConstruct for more information

Values:

self:

Parameters:
inputString: String

Description: Formats the provided string into an instance of TimeConstruct.

Usage:

ParSec(<inputString>)

format:

Parameters
inputString: String

Description:
Formats the provided string using internal values (Internal version of ParSec(string))

parse:

Parameters
inputString: String

Description:
Formats the provided string into an instance of TimeConstruct (Internal version of ParSec(string))


TimeConstruct

Layout:

Values:

locale: String
milliseconds: Number
seconds: Number
minutes: Number
hours: Number
days: Number
weeks: Number
months: Number
years: Number

Methods:

format:

Parameters
inputString: String

Description:
Formats the provided string using internal values (Internal version of ParSec(string))

into:

Parameters
inputString: String

Description:
Formats the provided string, converting all internal values to the largest specified value (Internal version of ParSec(string))

More coming soon....

FAQs

Package last updated on 05 May 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