Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dustinspecker/array-join-conjunction
Join an array with a conjunction
https://github.com/dustinspecker/array-join-conjunction
Last synced: 2 days ago
JSON representation
Join an array with a conjunction
- Host: GitHub
- URL: https://github.com/dustinspecker/array-join-conjunction
- Owner: dustinspecker
- License: mit
- Created: 2016-01-31T20:00:41.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2019-11-02T04:18:08.000Z (about 5 years ago)
- Last Synced: 2024-08-09T22:35:09.586Z (3 months ago)
- Language: JavaScript
- Size: 13.7 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: license.md
Awesome Lists containing this project
README
# array-join-conjunction
[![NPM version](https://badge.fury.io/js/array-join-conjunction.svg)](http://badge.fury.io/js/array-join-conjunction) [![Build Status](https://travis-ci.org/dustinspecker/array-join-conjunction.svg?branch=master)](https://travis-ci.org/dustinspecker/array-join-conjunction) [![Coverage Status](https://img.shields.io/coveralls/dustinspecker/array-join-conjunction.svg)](https://coveralls.io/r/dustinspecker/array-join-conjunction?branch=master)
[![Code Climate](https://codeclimate.com/github/dustinspecker/array-join-conjunction/badges/gpa.svg)](https://codeclimate.com/github/dustinspecker/array-join-conjunction) [![Dependencies](https://david-dm.org/dustinspecker/array-join-conjunction.svg)](https://david-dm.org/dustinspecker/array-join-conjunction/#info=dependencies&view=table) [![DevDependencies](https://david-dm.org/dustinspecker/array-join-conjunction/dev-status.svg)](https://david-dm.org/dustinspecker/array-join-conjunction/#info=devDependencies&view=table)
> Join an array with a conjunction
## Install
```bash
npm install --save array-join-conjunction
```## Usage
```javascript
import arrayJoinConjunction from 'array-join-conjunction'arrayJoinConjunction([])
// => ''arrayJoinConjunction([1, 2])
// => '1 and 2'arrayJoinConjunction(['blue', 'red', 'green'])
// => 'blue, red, and green'arrayJoinConjunction(['blue', 'red', 'green'], 'or')
// => 'blue, red, or green'
```## API
### arrayJoinConjunction(array, [conjunction])Returns a `string` joined from `array` using an optional `conjunction`.
#### array
type: `array`The array to join into a string. An empty array returns an empty string.
#### conjunction
type: `string`default: `'and'`
A conjunction to join two or more words with. The default is to use `'and'`.
## License
MIT © [Dustin Specker](https://github.com/dustinspecker)