Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

listify

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

listify

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

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
127K
decreased by-6.62%
Maintainers
1
Weekly downloads
 
Created

What is listify?

The listify npm package is a utility that converts arrays into human-readable lists. It is particularly useful for formatting lists in a way that is grammatically correct and easy to read.

What are listify's main functionalities?

Basic List Formatting

This feature allows you to convert an array of items into a human-readable list. By default, it uses commas to separate items and adds 'and' before the last item.

const listify = require('listify');
const items = ['apple', 'banana', 'cherry'];
console.log(listify(items)); // Output: 'apple, banana, and cherry'

Custom Separator

This feature allows you to specify a custom separator for the list items. In this example, a semicolon followed by a space is used as the separator.

const listify = require('listify');
const items = ['apple', 'banana', 'cherry'];
console.log(listify(items, { separator: '; ' })); // Output: 'apple; banana; and cherry'

Custom Final Word

This feature allows you to customize the final word used before the last item in the list. In this example, 'or' is used instead of the default 'and'.

const listify = require('listify');
const items = ['apple', 'banana', 'cherry'];
console.log(listify(items, { finalWord: 'or' })); // Output: 'apple, banana, or cherry'

Oxford Comma

This feature allows you to enable or disable the Oxford comma. By setting oxfordComma to false, the comma before the final word is omitted.

const listify = require('listify');
const items = ['apple', 'banana', 'cherry'];
console.log(listify(items, { oxfordComma: false })); // Output: 'apple, banana and cherry'

Other packages similar to listify

Keywords

FAQs

Package last updated on 03 May 2020

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc