New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@stridekick/formatters

Package Overview
Dependencies
Maintainers
5
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stridekick/formatters

A collection of formatter functions

latest
Source
npmnpm
Version
2.1.2
Version published
Maintainers
5
Created
Source

@stridekick/formatters

A collection of formatter functions

Table of Contents

  • Installation
  • Usage
  • Formatters
  • Publishing

Installation

npm install --save-dev @stridekick/formatters

Usage

Import the formatters needed

All formatters have chainable operations (denoted by chainable)

import {DateFormatter, NumberFormatter, StringFormatter} from '@stridekick/formatters'

const dateFormatter   = new DateFormatter(new Date())
const numberFormatter = new NumberFormatter(10000)
const stringFormatter = new StringFormatter('https://stridekick.com')

const stringFormatter = new StringFormatter('https://stridekick.com')
  .chompLeft('https://')
  .chompRight('.com')
  .toString() // stridekick

Formatters

NumberFormatter

Numbers can be formatted to look like currency, percentages, times, or even plain old numbers with decimal places, thousands, and abbreviations.

const numberFormatter = new NumberFormatter(10000)

toString

Returns the result of the chained operations

API {numberFormatter}.toString([format])

numberFormatter (required)

  • Description: an instance of NumberFormatter
  • Type: NumberFormatter
  • Default: undefined

format (optional)

  • Description: format to be applied to number
  • Type: string
  • Default: NumberFormatter.formats.DEFAULT === 0,0
  • Supported options:

Example

import {NumberFormatter} from '@stridekick/formatters'

new NumberFormatter(100).toString() // 100
new NumberFormatter(1000).toString() // 1,000
new NumberFormatter(10000).toString() // 10,000
new NumberFormatter(10000.00).toString() // 10,000
new NumberFormatter(10000.10).toString() // 10,000
new NumberFormatter(10000.10).toString(NumberFormatter.formats.TWO_DECIMAL_PLACES) // 10,000.10

formats

Named formats

  • DEFAULT === 0,0
  • TWO_DECIMAL_PLACES === 0,0.00

string

chompLeft

Removes prefix from start of string

API chompLeft(string, prefix)

string (required)

  • Description: original string
  • Type: string
  • Default: undefined

prefix (required)

  • Description: string to be chomped
  • Type: string
  • Default: undefined

Example

import {string} from '@stridekick/formatters'

string.chompLeft(`http://url.com`, `http://`) // url.com

Publishing

To publish updates to the npm repository:

  • Push all code changes to the code repository

  • npm install

  • Perform one of the following:

  • npm run publish:patch - {major}.{minor}.{patch +1}
  • npm run publish:minor - {major}.{minor + 1}.0
  • npm run publish:major - {major + 1}.0.0

FAQs

Package last updated on 11 Oct 2016

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