@mnrendra/util-readable-list
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

@mnrendra/util-readable-list

A utility to convert an array into readable text.

Install

npm i @mnrendra/util-readable-list

Usage

import { readableList } from '@mnrendra/util-readable-list'

console.log(readableList(['a'])) // Will print: a
console.log(readableList(['a'], { quote: '"' })) // Will print: "a"
console.log(readableList(['a', 'b'])) // Will print: a and b
console.log(readableList(['a', 'b'], { conj: 'or' })) // Will print: a or b
console.log(readableList(['a', 'b'], { quote: '`' })) // Will print: `a` and `b`
console.log(readableList(['a', 'b'], { quote: '\'', conj: 'or' })) // Will print: 'a' or 'b'
console.log(readableList(['a', 'b', 'c'], { quote: '"', conj: 'or' })) // Will print: "a", "b", or "c"
console.log(readableList(['a', 'b', 'c'], { quote: '"', conj: 'or', comma: ';' })) // Will print: "a"; "b"; or "c"
console.log(readableList(['a', 'b', 'c']. { comma: ';' })) // Will print: a; b; and c

Types

import type {
  Options
} from '@mnrendra/util-readable-list'

License

MIT

Author

@mnrendra

/@mnrendra/util-readable-list/

    Package Sidebar

    Install

    npm i @mnrendra/util-readable-list

    Weekly Downloads

    1

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    8.35 kB

    Total Files

    9

    Last publish

    Collaborators

    • mnrendra