listify
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/listify package

1.0.3 • Public • Published

listify Version Badge

Build Status dependency status dev dependency status

Turn an array into a list of comma-separated values, appropriate for use in an English sentence.

Example

var listify = require('listify');
 
assert(listify([1, 2]) === '1 and 2');
assert(listify([1, 2, 3]) === '1, 2, and 3');
assert(listify([1, 2, 3, 4]) === '1, 2, 3, and 4');
assert(listify([1, 2, 3], { separator: '… ' }) === '1… 2… and 3');
assert(listify([1, 2, 3], { finalWord: false }) === '1, 2, 3');
assert(listify([1, 2, 3], { separator: '… ', finalWord: 'or' }) === '1… 2… or 3');

Tests

Simply clone the repo, npm install, and run npm test

Dependencies (0)

    Dev Dependencies (7)

    Package Sidebar

    Install

    npm i listify

    Weekly Downloads

    133,807

    Version

    1.0.3

    License

    MIT

    Unpacked Size

    20.2 kB

    Total Files

    11

    Last publish

    Collaborators

    • ljharb