Giter Site home page Giter Site logo

fero-ms's Introduction

Installation

npm: npm install fero-ms

yarn: yarn add fero-ms

Importing

TypeScript: import { ms } from "fero-ms"

JavaScript: const { ms } = require("fero-ms");

Usage

Works very similar to ms, however there are more units, options, and you can even use more than one unit at once!

const { ms } = require("fero-ms");

console.log(ms("1d4h")); // Expected Output: 100800000
console.log(ms("1 day 4 hours")); // Expected Output: 100800000
console.log(ms(100800000)); // Expected Output: "1d 4h"
console.log(ms(100800000, { long: true })); // Expected Output: "1 day 4 hours"

Options

console.log(ms("1d4h", {
    disabledUnits: ["millisecond"], // The units not to parse/output; Default: []
    returnDate: true // Whether or not to return a Date (now + result) when using the string -> number conversion; Default: true
})); // Expected Output: 2021-09-06T01:45:51.403Z (as of time of writing);
console.log(ms(100800000, {
    long: true, // Whether or not to use longer aliases; Default: false
    spacedOut: true, // Whether ot not to make the output spaced out; Default: value for long
    unitTrailingSpace: true, // Whether or not to add a space at the end of each unit in the output; Default: true
    disabledUnits: ["millisecond"], // The units to not parse/output; Default: []
})); // Expected Output: 1 day 4 hours

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.