🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

humanize-list

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

humanize-list

Comma delimit an array for human readability, the Oxford comma is optional.

1.0.1
latest
Source
npm
Version published
Weekly downloads
244K
0.65%
Maintainers
1
Weekly downloads
 
Created

What is humanize-list?

The humanize-list npm package is designed to convert arrays into human-readable strings. It is particularly useful for creating natural language lists from array data, making it easier to display lists in a user-friendly format.

What are humanize-list's main functionalities?

Basic List Humanization

This feature converts an array of items into a human-readable string, using commas and the word 'and' before the last item.

const humanizeList = require('humanize-list');
const items = ['apples', 'oranges', 'bananas'];
const humanized = humanizeList(items);
console.log(humanized); // Output: 'apples, oranges, and bananas'

Custom Conjunction

This feature allows you to customize the conjunction used in the list. In this example, the word 'or' is used instead of 'and'.

const humanizeList = require('humanize-list');
const items = ['apples', 'oranges', 'bananas'];
const humanized = humanizeList(items, { conjunction: 'or' });
console.log(humanized); // Output: 'apples, oranges, or bananas'

Serial Comma

This feature allows you to control the use of the serial comma (Oxford comma). Setting `serialComma` to false omits the comma before the conjunction.

const humanizeList = require('humanize-list');
const items = ['apples', 'oranges', 'bananas'];
const humanized = humanizeList(items, { serialComma: false });
console.log(humanized); // Output: 'apples, oranges and bananas'

Other packages similar to humanize-list

Keywords

humanize

FAQs

Package last updated on 18 Dec 2015

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