10000 GitHub - etc-tiago/list-to-phase
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

etc-tiago/list-to-phase

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

list-to-sentence

Easily convert an array of strings into a natural language sentence with customizable conjunctions and separators.

Installation

npm install list-to-sentence
// yarn add list-to-sentence
// pnpm add list-to-sentence
// bun add list-to-sentence

Usage

import listToSentence from 'list-to-sentence';

listToSentence(['a', 'b', 'c']);
//=> 'a, b e c'

listToSentence(['a', 'b', 'c'], { conjunction: ' y ', separator: ' y ' });
//=> 'a y b y c'

TypeScript support

import listToSentence from 'list-to-sentence';

const fruits = ['Apple', 'Banana', 'Cherry'];
const sentence = listToSentence(fruits, { conjunction: ' and ', separator: ', ' });
console.log(sentence); // "Apple, Banana and Cherry"

API

listToSentence(list: string[], options?: { conjunction?: string, separator?: string }) => string

Parameters:

  • list (string[]) – The array of strings to be converted into a sentence.
  • options (optional) – An object to customize output.
    • conjunction (string, default: " e ") – The word used before the last item.
    • separator (string, default: ", ") – The separator between items.

Returns:

A formatted string with proper punctuation and conjunction.

Related Project:

UserTimeline – Track and visualize a user’s journey through your SaaS and websites.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0