alexzhang1030 / fmt-it

Format string tool.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

fmt-it

A format string tool.

Types

export type AllowingInput = string | Readonly<string>
export type FmtFn = (input: AllowingInput, ...args: any[]) => string

Utilities

1. camelCase

function camelCase(input: AllowingInput): string

2. pluralize

function pluralize(input: AllowingInput, count?: number): string

3. singularize

function singularize(input: AllowingInput): string

4. addSpace

function addSpace(input: AllowingInput): string

5. pascalCase

function pascalCase(input: AllowingInput): string

helper

1. pipeFmt

function pipeFmt(value: AllowingInput): {
  then: (fn: FmtFn) => pipeFmt
  get: () => string
}

example

function camelCaseAndPluralize(input: AllowingInput, count: number) {
  return pipe(input)
    .then(input => camelCase(input))
    .then(res => pluralize(res, count))
}

camelCaseAndPluralize(input, 2).get() // => 'twoApples'

About

Format string tool.

License:MIT License


Languages

Language:TypeScript 100.0%