0.0.2 • Published 5 years ago

@mmgj/triks v0.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

@mmgj/triks

  npm i @mmgj/triks
  yarn add @mmgj/triks

Usage

humanList / thingCommaThingAndThing / tctat

Takes an array of strings and an optional config object and returns a human-readable string.

  import { humanList } from '@mmgj/triks';

...or, if you prefer:

  import { thingCommaThingAndThing } from '@mmgj/triks';

Usage

  const betterList = humanList(array, { config });

Arguments:

array (Array) : an array of strings. config (Object) : an optional config object. (see below)

Must be declared in the form of a config object. I.e. { oxford: true, andThen: '!' }.

PropTypeDefaultDescription
oxfordbooleanfalseUse Oxford comma? (I.e 'thingCommaThingCommaAndThing')
andstring'and'What's going in the 'and' place?
andThenstring''What goes after the string? (A period or exclamation mark for example)

Returns

(String) : a string more resembling what a human might write.

Examples

humanList(['Tom', 'Dick', 'Harry']); // Tom, Dick and Harry
humanList(['Tom', 'Dick', 'Harry']); { oxford: true }); // Tom, Dick, and Harry
humanList(['Luke', 'Leia']); // Luke and Leia
humanList(['Luke', 'Leia'], { andThen: '!!!' }); // Luke and Leia!!!
humanList(['Pompel', 'Pilt'], { and: 'og' }); // Pompel og Pilt
humanList(['Stone', 'Scissors', 'Paper', 'Lizard', 'Spock'], { oxford: true, and: '', andThen: '!!!!'};
 // Stone, Scissors, Paper, Lizard, Spock!!!!