🚀 DAY 5 OF LAUNCH WEEK:Introducing Webhook Events for Alert Changes.Learn more →
Socket
Book a DemoInstallSign in
Socket

fmat

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fmat

A barebones yet feature-rich string formatter.

Source
npmnpm
Version
1.0.2
Version published
Weekly downloads
60
42.86%
Maintainers
1
Weekly downloads
 
Created
Source

code style: prettier

fmat

A barebones but feature-rich string formatter

Usage

Installation

$ npm install fmat

Usage

Import fmat into your project.

import fmat from 'fmat';

Use it by calling the function with an input value and options, this will always return a string.

const formattedString = fmat('hello', {}); // -> 'hello'

Options

execution: 'loop' | 'hang' | 'exec'

Determines the behaviour when the string is longer than the available format indexes.

  • loop - loops the format until the end of the input string.
  • hang - loops the last format value until the end of the input string.
  • exec - runs just the format and quits after.

Default: 'exec'

Usage

const formattedString = fmat('hello', { format: [1], execution: 'loop' }); // -> 'h e l l o'
const formattedString = fmat('hello', { format: [2, 1], execution: 'hang' }); // -> 'he l l o'
const formattedString = fmat('hello', { format: [2, 1], execution: 'exec' }); // -> 'h ello'

format: number[]

Add an array of numbers which represent text index to add a delimiter to.

Default: []

Usage

const formattedString = fmat('hello', { format: [1] }); // -> 'h ello'

delimiter: string

Specify the delimiter to insert at every format value index within the input string.

Default: " "

Usage

const formattedString = fmat('hello', { format: [1], delimiter: '!' }); // -> 'h!ello'

Contributing

Want to contribute? Great! Please branch out from the master version from using a branchname such as feature/{insert-descriptive-feature-name} and create a pull request when ready.

Use npm run build to build the project.

Keywords

formatting

FAQs

Package last updated on 22 Mar 2019

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