UNPKG

template-helpers

Version:

Generic JavaScript helpers that can be used with any template engine. Handlebars, Lo-Dash, Underscore, or any engine that supports helper functions.

1,911 lines (1,247 loc) 46.7 kB
# template-helpers [![NPM version](https://img.shields.io/npm/v/template-helpers.svg?style=flat)](https://www.npmjs.com/package/template-helpers) [![NPM monthly downloads](https://img.shields.io/npm/dm/template-helpers.svg?style=flat)](https://npmjs.org/package/template-helpers) [![NPM total downloads](https://img.shields.io/npm/dt/template-helpers.svg?style=flat)](https://npmjs.org/package/template-helpers) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/template-helpers.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/template-helpers) > Generic JavaScript helpers that can be used with any template engine. Handlebars, Lo-Dash, Underscore, or any engine that supports helper functions. Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support. - [Install](#install) - [Usage](#usage) * [Template-engine agnostic](#template-engine-agnostic) * [Namespacing](#namespacing) - [Helpers](#helpers) * [array](#array) * [code](#code) * [collection](#collection) * [conditional](#conditional) * [fs](#fs) * [html](#html) * [index](#index) * [math](#math) * [object](#object) * [path](#path) * [string](#string) - [Coverage](#coverage) - [About](#about) ## Install Install with [npm](https://www.npmjs.com/): ```sh $ npm install --save template-helpers ``` ## Usage To get all helpers: ```js const helpers = require('template-helpers')(); console.log(helpers); ``` **Get a specific helper category** ```js // get only the math helpers const helpers = require('template-helpers')('math'); ``` **Get multiple helper categories** ```js // get only the math helpers const helpers = require('template-helpers')(['math', 'string']); ``` ### Template-engine agnostic **Lo-Dash Example** ```js const helpers = require('template-helpers')('array'); // pass helpers on `imports` const imports = { imports: helpers }; // compile a template const fn = _.template('<%= first(foo) %>', imports); // render fn({ foo: ['a', 'b', 'c'] }); //=> 'a' ``` ### Namespacing Handlebars and Lo-Dash both allow **dot notation** to be used for referencing helpers. I'd be happy to add examples for other engines if someone wants to do a PR. **Example** ```js <%= path.dirname("a/b/c/d.js") %> ``` This can be used as a way of working around potential naming conflicts. ## Helpers _(The following **API Table of Contents** is generated by [verb](https://github.com/verbose/verb). See the [verbfile.js](verbfile.js) for more details.)_ ## Categories Currently **101 helpers** in **10 categories**: * **[array](#array)** ([code](lib/helpers/array.js) | [unit tests](test/array.js)) * **[code](#code)** ([code](lib/helpers/code.js) | [unit tests](test/code.js)) * **[collection](#collection)** ([code](lib/helpers/collection.js) | [unit tests](test/collection.js)) * **[conditional](#conditional)** ([code](lib/helpers/conditional.js) | [unit tests](test/conditional.js)) * **[fs](#fs)** ([code](lib/helpers/fs.js) | [unit tests](test/fs.js)) * **[html](#html)** ([code](lib/helpers/html.js) | [unit tests](test/html.js)) * **[math](#math)** ([code](lib/helpers/math.js) | [unit tests](test/math.js)) * **[object](#object)** ([code](lib/helpers/object.js) | [unit tests](test/object.js)) * **[path](#path)** ([code](lib/helpers/path.js) | [unit tests](test/path.js)) * **[string](#string)** ([code](lib/helpers/string.js) | [unit tests](test/string.js)) ## All helpers ### [array helpers](#array) Visit the: [code](lib/helpers/array.js) | [unit tests](test/array.js) | [issues](https://github.com/jonschlinkert/template-helpers/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+array+helpers)) * **[isArray](#isArray)** ([code](lib/helpers/array.js#L21) | [unit tests](test/array.js#L18)) * **[arrayify](#arrayify)** ([code](lib/helpers/array.js#L42) | [unit tests](test/array.js#L25)) * **[first](#first)** ([code](lib/helpers/array.js#L58) | [unit tests](test/array.js#L32)) * **[last](#last)** ([code](lib/helpers/array.js#L79) | [unit tests](test/array.js#L48)) * **[before](#before)** ([code](lib/helpers/array.js#L102) | [unit tests](test/array.js#L61)) * **[after](#after)** ([code](lib/helpers/array.js#L121) | [unit tests](test/array.js#L71)) * **[each](#each)** ([code](lib/helpers/array.js#L147) | [unit tests](test/array.js#L98)) * **[map](#map)** ([code](lib/helpers/array.js#L188) | [unit tests](test/array.js#L122)) * **[join](#join)** ([code](lib/helpers/array.js#L218) | [unit tests](test/array.js#L82)) * **[sort](#sort)** ([code](lib/helpers/array.js#L241) | [unit tests](test/array.js#L137)) * **[length](#length)** ([code](lib/helpers/array.js#L272) | [unit tests](test/array.js#L162)) * **[compact](#compact)** ([code](lib/helpers/array.js#L289) | [unit tests](test/array.js#L178)) * **[difference](#difference)** ([code](lib/helpers/array.js#L307) | [unit tests](test/array.js#L189)) * **[unique](#unique)** ([code](lib/helpers/array.js#L344) | [unit tests](test/array.js#L205)) * **[union](#union)** ([code](lib/helpers/array.js#L373) | [unit tests](test/array.js#L215)) * **[shuffle](#shuffle)** ([code](lib/helpers/array.js#L389) | [no tests]) ### [code helpers](#code) Visit the: [code](lib/helpers/code.js) | [unit tests](test/code.js) | [issues](https://github.com/jonschlinkert/template-helpers/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+code+helpers)) * **[embed](#embed)** ([code](lib/helpers/code.js#L23) | [unit tests](test/code.js#L33)) * **[jsfiddle](#jsfiddle)** ([code](lib/helpers/code.js#L45) | [unit tests](test/code.js#L24)) ### [collection helpers](#collection) Visit the: [code](lib/helpers/collection.js) | [unit tests](test/collection.js) | [issues](https://github.com/jonschlinkert/template-helpers/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+collection+helpers)) * **[any](#any)** ([code](lib/helpers/collection.js#L17) | [unit tests](test/collection.js#L17)) * **[filter](#filter)** ([code](lib/helpers/collection.js#L32) | [unit tests](test/collection.js#L34)) ### [conditional helpers](#conditional) Visit the: [code](lib/helpers/conditional.js) | [unit tests](test/conditional.js) | [issues](https://github.com/jonschlinkert/template-helpers/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+conditional+helpers)) * **[and](#and)** ([code](lib/helpers/conditional.js#L13) | [no tests]) * **[compare](#compare)** ([code](lib/helpers/conditional.js#L30) | [unit tests](test/conditional.js#L35)) * **[find](#find)** ([code](lib/helpers/conditional.js#L72) | [no tests]) * **[every](#every)** ([code](lib/helpers/conditional.js#L83) | [no tests]) * **[gt](#gt)** ([code](lib/helpers/conditional.js#L98) | [no tests]) * **[gte](#gte)** ([code](lib/helpers/conditional.js#L110) | [no tests]) * **[_if](#_if)** ([code](lib/helpers/conditional.js#L122) | [no tests]) * **[is](#is)** ([code](lib/helpers/conditional.js#L142) | [unit tests](test/conditional.js#L47)) * **[eq](#eq)** ([code](lib/helpers/conditional.js#L157) | [no tests]) * **[isnt](#isnt)** ([code](lib/helpers/conditional.js#L169) | [unit tests](test/conditional.js#L59)) * **[notEq](#notEq)** ([code](lib/helpers/conditional.js#L183) | [no tests]) * **[lt](#lt)** ([code](lib/helpers/conditional.js#L195) | [no tests]) * **[lte](#lte)** ([code](lib/helpers/conditional.js#L207) | [no tests]) * **[or](#or)** ([code](lib/helpers/conditional.js#L219) | [no tests]) * **[some](#some)** ([code](lib/helpers/conditional.js#L230) | [no tests]) ### [fs helpers](#fs) Visit the: [code](lib/helpers/fs.js) | [unit tests](test/fs.js) | [issues](https://github.com/jonschlinkert/template-helpers/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+fs+helpers)) * **[exists](#exists)** ([code](lib/helpers/fs.js#L16) | [unit tests](test/fs.js#L17)) * **[read](#read)** ([code](lib/helpers/fs.js#L29) | [unit tests](test/fs.js#L23)) ### [html helpers](#html) Visit the: [code](lib/helpers/html.js) | [unit tests](test/html.js) | [issues](https://github.com/jonschlinkert/template-helpers/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+html+helpers)) * **[escapeHtml](#escapeHtml)** ([code](lib/helpers/html.js#L18) | [unit tests](test/html.js#L17)) * **[sanitize](#sanitize)** ([code](lib/helpers/html.js#L46) | [unit tests](test/html.js#L27)) ### [math helpers](#math) Visit the: [code](lib/helpers/math.js) | [unit tests](test/math.js) | [issues](https://github.com/jonschlinkert/template-helpers/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+math+helpers)) * **[add](#add)** ([code](lib/helpers/math.js#L17) | [unit tests](test/math.js#L17)) * **[subtract](#subtract)** ([code](lib/helpers/math.js#L31) | [unit tests](test/math.js#L23)) * **[divide](#divide)** ([code](lib/helpers/math.js#L46) | [unit tests](test/math.js#L29)) * **[multiply](#multiply)** ([code](lib/helpers/math.js#L61) | [unit tests](test/math.js#L35)) * **[floor](#floor)** ([code](lib/helpers/math.js#L76) | [unit tests](test/math.js#L41)) * **[ceil](#ceil)** ([code](lib/helpers/math.js#L91) | [unit tests](test/math.js#L47)) * **[round](#round)** ([code](lib/helpers/math.js#L109) | [unit tests](test/math.js#L53)) * **[sum](#sum)** ([code](lib/helpers/math.js#L123) | [unit tests](test/math.js#L60)) ### [object helpers](#object) Visit the: [code](lib/helpers/object.js) | [unit tests](test/object.js) | [issues](https://github.com/jonschlinkert/template-helpers/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+object+helpers)) * **[fallback](#fallback)** ([code](lib/helpers/object.js#L22) | [unit tests](test/object.js#L18)) * **[stringify](#stringify)** ([code](lib/helpers/object.js#L36) | [unit tests](test/object.js#L26)) * **[parse](#parse)** ([code](lib/helpers/object.js#L50) | [unit tests](test/object.js#L33)) * **[get](#get)** ([code](lib/helpers/object.js#L65) | [no tests]) * **[keys](#keys)** ([code](lib/helpers/object.js#L79) | [unit tests](test/object.js#L64)) * **[isObject](#isObject)** ([code](lib/helpers/object.js#L97) | [unit tests](test/object.js#L40)) * **[isPlainObject](#isPlainObject)** ([code](lib/helpers/object.js#L117) | [unit tests](test/object.js#L48)) * **[hasOwn](#hasOwn)** ([code](lib/helpers/object.js#L129) | [unit tests](test/object.js#L57)) * **[omit](#omit)** ([code](lib/helpers/object.js#L144) | [unit tests](test/object.js#L98)) * **[forIn](#forIn)** ([code](lib/helpers/object.js#L163) | [unit tests](test/object.js#L70)) * **[forOwn](#forOwn)** ([code](lib/helpers/object.js#L188) | [unit tests](test/object.js#L84)) * **[extend](#extend)** ([code](lib/helpers/object.js#L205) | [unit tests](test/object.js#L105)) * **[merge](#merge)** ([code](lib/helpers/object.js#L241) | [unit tests](test/object.js#L132)) ### [path helpers](#path) Visit the: [code](lib/helpers/path.js) | [unit tests](test/path.js) | [issues](https://github.com/jonschlinkert/template-helpers/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+path+helpers)) * **[dirname](#dirname)** ([code](lib/helpers/path.js#L19) | [unit tests](test/path.js#L17)) * **[basename](#basename)** ([code](lib/helpers/path.js#L34) | [unit tests](test/path.js#L23)) * **[filename](#filename)** ([code](lib/helpers/path.js#L49) | [unit tests](test/path.js#L29)) * **[stem](#stem)** ([code](lib/helpers/path.js#L65) | [no tests]) * **[extname](#extname)** ([code](lib/helpers/path.js#L80) | [unit tests](test/path.js#L35)) * **[ext](#ext)** ([code](lib/helpers/path.js#L80) | [unit tests](test/path.js#L35)) * **[resolve](#resolve)** ([code](lib/helpers/path.js#L110) | [unit tests](test/path.js#L47)) * **[relative](#relative)** ([code](lib/helpers/path.js#L126) | [unit tests](test/path.js#L53)) * **[segments](#segments)** ([code](lib/helpers/path.js#L162) | [unit tests](test/path.js#L107)) * **[join](#join)** ([code](lib/helpers/path.js#L183) | [unit tests](test/path.js#L100)) * **[isAbsolute](#isAbsolute)** ([code](lib/helpers/path.js#L215) | [unit tests](test/path.js#L81)) * **[isRelative](#isRelative)** ([code](lib/helpers/path.js#L247) | [unit tests](test/path.js#L62)) ### [string helpers](#string) Visit the: [code](lib/helpers/string.js) | [unit tests](test/string.js) | [issues](https://github.com/jonschlinkert/template-helpers/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+string+helpers)) * **[camelcase](#camelcase)** ([code](lib/helpers/string.js#L24) | [unit tests](test/string.js#L98)) * **[centerAlign](#centerAlign)** ([code](lib/helpers/string.js#L46) | [no tests]) * **[chop](#chop)** ([code](lib/helpers/string.js#L69) | [unit tests](test/string.js#L50)) * **[count](#count)** ([code](lib/helpers/string.js#L88) | [unit tests](test/string.js#L277)) * **[dotcase](#dotcase)** ([code](lib/helpers/string.js#L107) | [unit tests](test/string.js#L162)) * **[ellipsis](#ellipsis)** ([code](lib/helpers/string.js#L128) | [unit tests](test/string.js#L368)) * **[isString](#isString)** ([code](lib/helpers/string.js#L147) | [no tests]) * **[lower](#lower)** ([code](lib/helpers/string.js#L161) | [unit tests](test/string.js#L16)) * **[lowercase](#lowercase)** ([code](lib/helpers/string.js#L161) | [unit tests](test/string.js#L16)) * **[pascalcase](#pascalcase)** ([code](lib/helpers/string.js#L177) | [unit tests](test/string.js#L119)) * **[snakecase](#snakecase)** ([code](lib/helpers/string.js#L196) | [unit tests](test/string.js#L141)) * **[split](#split)** ([code](lib/helpers/string.js#L214) | [no tests]) * **[strip](#strip)** ([code](lib/helpers/string.js#L230) | [unit tests](test/string.js#L72)) * **[stripIndent](#stripIndent)** ([code](lib/helpers/string.js#L248) | [unit tests](test/string.js#L86)) * **[trim](#trim)** ([code](lib/helpers/string.js#L275) | [unit tests](test/string.js#L36)) * **[dashcase](#dashcase)** ([code](lib/helpers/string.js#L291) | [unit tests](test/string.js#L183)) * **[pathcase](#pathcase)** ([code](lib/helpers/string.js#L309) | [unit tests](test/string.js#L204)) * **[sentencecase](#sentencecase)** ([code](lib/helpers/string.js#L327) | [unit tests](test/string.js#L225)) * **[hyphenate](#hyphenate)** ([code](lib/helpers/string.js#L345) | [unit tests](test/string.js#L239)) * **[slugify](#slugify)** ([code](lib/helpers/string.js#L363) | [unit tests](test/string.js#L257)) * **[reverse](#reverse)** ([code](lib/helpers/string.js#L377) | [unit tests](test/string.js#L291)) * **[rightAlign](#rightAlign)** ([code](lib/helpers/string.js#L394) | [no tests]) * **[replace](#replace)** ([code](lib/helpers/string.js#L412) | [unit tests](test/string.js#L330)) * **[titleize](#titleize)** ([code](lib/helpers/string.js#Lundefined) | [no tests]) * **[titlecase](#titlecase)** ([code](lib/helpers/string.js#L433) | [unit tests](test/string.js#L348)) * **[truncate](#truncate)** ([code](lib/helpers/string.js#L451) | [unit tests](test/string.js#L358)) * **[upper](#upper)** ([code](lib/helpers/string.js#L467) | [unit tests](test/string.js#L26)) * **[uppercase](#uppercase)** ([code](lib/helpers/string.js#L467) | [unit tests](test/string.js#L26)) * **[wordwrap](#wordwrap)** ([code](lib/helpers/string.js#L484) | [unit tests](test/string.js#L300)) ### array #### [isArray](lib/helpers/array.js#L21) Returns true if `value` is an array. **Params** * `value` **{any}**: The value to test. * `returns` **{Boolean}** **Example** ```js <%= isArray('a, b, c') %> //=> 'false' <%= isArray(['a, b, c']) %> //=> 'true' ``` #### [arrayify](lib/helpers/array.js#L42) Cast `val` to an array. **Params** * `val` **{any}**: The value to arrayify. * `returns` **{Array}**: An array. * `returns` **{Array}** **Example** ```js <%= arrayify('a') %> //=> '["a"]' <%= arrayify({a: 'b'}) %> //=> '[{a: "b"}]' <%= arrayify(['a']) %> //=> '["a"]' ``` #### [first](lib/helpers/array.js#L58) Returns the first item, or first `n` items of an array. **Params** * `array` **{Array}** * `n` **{Number}**: Number of items to return, starting at `0`. * `returns` **{Array}** **Example** ```js <%= first(['a', 'b', 'c', 'd', 'e'], 2) %> //=> '["a", "b"]' ``` #### [last](lib/helpers/array.js#L79) Returns the last item, or last `n` items of an array. **Params** * `array` **{Array}** * `n` **{Number}**: Number of items to return, starting with the last item. * `returns` **{Array}** **Example** ```js <%= last(['a', 'b', 'c', 'd', 'e'], 2) %> //=> '["d", "e"]' ``` #### [before](lib/helpers/array.js#L102) Returns all of the items in an array up to the specified number Opposite of `<%= after() %`. **Params** * `array` **{Array}** * `n` **{Number}** * `returns` **{Array}**: Array excluding items after the given number. **Example** ```js <%= before(['a', 'b', 'c'], 2) %> //=> '["a", "b"]' ``` #### [after](lib/helpers/array.js#L121) Returns all of the items in an arry after the specified index. Opposite of `<%= before() %`. **Params** * `array` **{Array}**: Collection * `n` **{Number}**: Starting index (number of items to exclude) * `returns` **{Array}**: Array exluding `n` items. **Example** ```js <%= after(['a', 'b', 'c'], 1) %> //=> '["c"]' ``` #### [each](lib/helpers/array.js#L147) Calling `fn` on each element of the given `array` with the given `context`. Assuming that `double` has been registered as a helper: **Params** * `array` **{Array}** * `fn` **{String}**: The function to call on each element in the given array. * `returns` **{String}** **Examples** ```js function double(str) { return str + str; } ``` ```js <%= each(['a', 'b', 'c'], double, ctx) %> //=> '["aa", "bb", "cc"]' ``` #### [map](lib/helpers/array.js#L188) Returns a new array, created by calling `function` on each element of the given `array`. Assuming that `double` has been registered as a helper: **Params** * `array` **{Array}** * `fn` **{String}**: The function to call on each element in the given array. * `returns` **{String}** **Examples** ```js function double(str) { return str + str; } ``` ```js <%= map(['a', 'b', 'c'], double) %> //=> '["aa", "bb", "cc"]' ``` #### [join](lib/helpers/array.js#L218) Join all elements of array into a string, optionally using a given separator. **Params** * `array` **{Array}** * `sep` **{String}**: The separator to use. * `returns` **{String}** **Example** ```js <%= join(['a', 'b', 'c']) %> //=> 'a, b, c' <%= join(['a', 'b', 'c'], '-') %> //=> 'a-b-c' ``` #### [sort](lib/helpers/array.js#L241) Sort the given `array`. If an array of objects is passed, you may optionally pass a `key` to sort on as the second argument. You may alternatively pass a sorting function as the second argument. **Params** * `array` **{Array}**: the array to sort. * `key` **{String|Function}**: The object key to sort by, or sorting function. **Example** ```js <%= sort(["b", "a", "c"]) %> //=> 'a,b,c' <%= sort([{a: "zzz"}, {a: "aaa"}], "a") %> //=> '[{"a":"aaa"},{"a":"zzz"}]' ``` #### [length](lib/helpers/array.js#L272) Returns the length of the given array. **Params** * `array` **{Array}** * `returns` **{Number}**: The length of the array. **Example** ```js <%= length(['a', 'b', 'c']) %> //=> 3 ``` #### [compact](lib/helpers/array.js#L289) Returns an array with all falsey values removed. **Params** * `arr` **{Array}** * `returns` **{Array}** **Example** ```js <%= compact([null, a, undefined, 0, false, b, c, '']) %> //=> '["a", "b", "c"]' ``` #### [difference](lib/helpers/array.js#L307) Return the difference between the first array and additional arrays. **Params** * `array` **{Array}**: The array to compare againts. * `arrays` **{Array}**: One or more additional arrays. * `returns` **{Array}** **Example** ```js <%= difference(["a", "c"], ["a", "b"]) %> //=> '["c"]' ``` #### [unique](lib/helpers/array.js#L344) Return an array, free of duplicate values. **Params** * `array` **{Array}**: The array to uniquify * `returns` **{Array}**: Duplicate-free array **Example** ```js <%= unique(['a', 'b', 'c', 'c']) % => '["a", "b", "c"]' ``` #### [union](lib/helpers/array.js#L373) Returns an array of unique values using strict equality for comparisons. **Params** * `arr` **{Array}** * `returns` **{Array}** **Example** ```js <%= union(["a"], ["b"], ["c"]) %> //=> '["a", "b", "c"]' ``` #### [shuffle](lib/helpers/array.js#L389) Shuffle the items in an array. **Params** * `arr` **{Array}** * `returns` **{Array}** **Example** ```js <%= shuffle(["a", "b", "c"]) %> //=> ["c", "a", "b"] ``` ### code #### [embed](lib/helpers/code.js#L23) Embed code from an external file as preformatted text. **Params** * `fp` **{String}**: filepath to the file to embed. * `language` **{String}**: Optionally specify the language to use for syntax highlighting. * `returns` **{String}** **Example** ```js <%= embed('path/to/file.js') %> // specify the language to use <%= embed('path/to/file.hbs', 'html') %> ``` #### [jsfiddle](lib/helpers/code.js#L45) Generate the HTML for a jsFiddle link with the given `params` **Params** * `params` **{Object}** * `returns` **{String}** **Example** ```js <%= jsfiddle({id: '0dfk10ks', {tabs: true}}) %> ``` ### collection #### [any](lib/helpers/collection.js#L17) Returns `true` if `value` exists in the given string, array or object. See [any](https://github.com/jonschlinkert/any) for documentation. **Params** * `value` **{any}** * `target` **{any}** * `options` **{Object}** #### [filter](lib/helpers/collection.js#L32) Filter the given array or object to contain only the matching values. **Params** * `arr` **{Array}** * `returns` **{Array}** **Example** ```js <%= filter(['foo', 'bar', 'baz']) %> //=> '["a", "b", "c"]' ``` ### conditional #### [and](lib/helpers/conditional.js#L13) Returns true when both `valueA` and `valueB` are truthy. **Params** * `valueA` **{any}** * `valueB` **{any}** * `returns` **{Boolean}** #### [compare](lib/helpers/conditional.js#L30) Render a block when a comparison of the first and third arguments returns true. **Params** * `valueA` **{String}** * `operator` **{String}**: The operator to use for the comparison (must be a quoted string). * `valueB` **{String}** * `returns` **{Boolean}** **Example** ```js <%= compare("foo", "!==", "bar") %> ``` #### [find](lib/helpers/conditional.js#L72) Returns the first truthy value. **Params** * `...values` **{...args}** * `returns` **{any}** #### [every](lib/helpers/conditional.js#L83) Returns true when all provided values are truthy. **Params** * `...values` **{...any}** * `returns` **{Boolean}** #### [gt](lib/helpers/conditional.js#L98) Returns true when `valueA` is greater than `valueB`. **Params** * `valueA` **{String}** * `valueB` **{String}** * `returns` **{Boolean}** #### [gte](lib/helpers/conditional.js#L110) Returns true when `valueA` is greater than or equal to `valueB`. **Params** * `valueA` **{String}** * `valueB` **{String}** * `returns` **{Boolean}** #### [_if](lib/helpers/conditional.js#L122) Return true if `key` is an own, enumerable property of the given `obj`. **Params** * `object` **{Object}** * `key` **{String}** * `returns` **{Boolean}** #### [is](lib/helpers/conditional.js#L142) Returns true when `valueA` equals `valueB`. **Params** * `valueA` **{String}** * `valueB` **{String}** * `strict` **{String}** * `returns` **{Boolean}** #### [eq](lib/helpers/conditional.js#L157) Alias for [is](#is). **Params** * `valueA` **{String}** * `valueB` **{String}** * `strict` **{String}** * `returns` **{Boolean}** #### [isnt](lib/helpers/conditional.js#L169) Returns true when `valueA` does not equal `valueB`. **Params** * `valueA` **{String}** * `valueB` **{String}** * `returns` **{Boolean}** #### [notEq](lib/helpers/conditional.js#L183) Alias for [isnt](#isnt). **Params** * `valueA` **{String}** * `valueB` **{String}** * `returns` **{Boolean}** #### [lt](lib/helpers/conditional.js#L195) Returns true when `valueA` is less than `valueB`. **Params** * `valueA` **{String}** * `valueB` **{String}** * `returns` **{Boolean}** #### [lte](lib/helpers/conditional.js#L207) Returns true when `valueA` is less than or equal to `valueB`. **Params** * `valueA` **{String}** * `valueB` **{String}** * `returns` **{Boolean}** #### [or](lib/helpers/conditional.js#L219) Returns `valueA` if thruthy, otherwise `valueB`. **Params** * `valueA` **{any}** * `valueB` **{any}** * `returns` **{any}** #### [some](lib/helpers/conditional.js#L230) Returns true when at least one value is truthy. **Params** * `...values` **{...any}** * `returns` **{Boolean}** ### fs #### [exists](lib/helpers/fs.js#L16) Return true if a file exists **Params** * `filepath` **{String}**: Path of the file to check. * `returns` **{Boolean}**: True if the file exists **Example** ```js <%= exists("foo.js") %> ``` #### [read](lib/helpers/fs.js#L29) Read a file from the file system and inject its content **Params** * `filepath` **{String}**: Path of the file to read. * `returns` **{String}**: Contents of the given file. **Example** ```js <%= read("foo.js") %> ``` ### html #### [escapeHtml](lib/helpers/html.js#L18) Escape HTML characters in a string. **Params** * `str` **{String}**: String of HTML with characters to escape. * `returns` **{String}** **Example** ```js <%= escapeHtml("<span>foo</span>") %> //=> &lt;span&gt;foo&lt;&#x2F;span&gt; ``` #### [sanitize](lib/helpers/html.js#L46) Strip HTML tags from a string, so that only the text nodes are preserved. **Params** * `str` **{String}**: The string of HTML to sanitize. * `returns` **{String}** **Example** ```js <%= sanitize("<span>foo</span>") %> //=> 'foo' ``` ### math #### [add](lib/helpers/math.js#L17) Return the product of `a` plus `b`. **Params** * `a` **{Number}** * `b` **{Number}** **Example** ```js <%= add(1, 2) %> //=> '3' ``` #### [subtract](lib/helpers/math.js#L31) Subtract `b` from `a`. **Params** * `a` **{Number}** * `b` **{Number}** **Example** ```js <%= subtract(5, 2) %> //=> '3' ``` #### [divide](lib/helpers/math.js#L46) Divide `a` (the numerator) by `b` (the divisor). **Params** * `a` **{Number}**: the numerator. * `b` **{Number}**: the divisor. * `returns` **{Number}**: The quotient of `a` divided by `b`. **Example** ```js <%= divide(10, 2) %> //=> '5' ``` #### [multiply](lib/helpers/math.js#L61) Multiply `a` by `b`. **Params** * `a` **{Number}** * `b` **{Number}** * `returns` **{Number}**: The product of `a` times `b`. **Example** ```js <%= divide(10, 2) %> //=> '5' ``` #### [floor](lib/helpers/math.js#L76) Returns the largest integer less than or equal to the given `number`. **Params** * `number` **{Number}** * `returns` **{Number}** **Example** ```js <%= floor(10.6) %> //=> '10' ``` #### [ceil](lib/helpers/math.js#L91) Returns the smallest integer greater than or equal to the given `number`. **Params** * `number` **{Number}** * `returns` **{Number}** **Example** ```js <%= ceil(10.1) %> //=> '11' ``` #### [round](lib/helpers/math.js#L109) Returns the value of the given `number` rounded to the nearest integer. **Params** * `number` **{Number}** * `returns` **{Number}** **Example** ```js <%= round(10.1) %> //=> '10' <%= round(10.5) %> //=> '11' ``` #### [sum](lib/helpers/math.js#L123) Returns the sum of all numbers in the given array. **Params** * `number` **{Number}** * `returns` **{Number}** **Example** ```js <%= sum([1, 2, 3, 4, 5]) %> //=> '15' ``` ### object #### [fallback](lib/helpers/object.js#L22) Specify a fallback value to use when the desired value is undefined. Note that undefined variables that are _not object properties_ with throw an error. **Params** * `a` **{any}**: The desired value. * `b` **{any}**: The fallback ("default") value * `returns` **{any}**: Either `a` or `b` **Example** ```js // when `title` is undefined, use the generic `site.title` <%= fallback(page.title, site.title) %> ``` #### [stringify](lib/helpers/object.js#L36) Stringify an object using `JSON.stringify()`. **Params** * `object` **{Object}** * `returns` **{String}** **Example** ```js <%= stringify({a: "a"}) %> //=> '{"a":"a"}' ``` #### [parse](lib/helpers/object.js#L50) Parse a string into an object using `JSON.parse()`. **Params** * `str` **{String}**: The string to parse. * `returns` **{Object}**: The parsed object. **Example** ```js <%= parse('{"foo":"bar"}')["foo"] %> //=> 'bar' ``` #### [get](lib/helpers/object.js#L65) Use property paths (`a.b.c`) get a nested value from an object. **Params** * `object` **{Object}** * `path` **{String}**: Dot notation for the property to get. * `returns` **{String}** **Example** ```js <%= get({a: {b: 'c'}}, 'a.b') %> //=> 'c' ``` #### [keys](lib/helpers/object.js#L79) Returns an array of keys from the given `object`. **Params** * `object` **{Object}** * `returns` **{Array}**: Keys from `object` **Example** ```js <%= keys({a: 'b', c: 'd'}) %> //=> '["a", "c"]' ``` #### [isObject](lib/helpers/object.js#L97) Return true if the given `value` is an object, and not `null` or an array. **Params** * `value` **{Object}**: The value to check. * `returns` **{Boolean}** **Example** ```js <%= isObject(['a', 'b', 'c']) %> //=> 'false' <%= isObject({a: 'b'}) %> //=> 'true' ``` #### [isPlainObject](lib/helpers/object.js#L117) Return true if the given `value` is a plain object. **Params** * `value` **{Object}**: The value to check. * `returns` **{Boolean}** **Example** ```js <%= isPlainObject(['a', 'b', 'c']) %> //=> 'false' <%= isPlainObject({a: 'b'}) %> //=> 'true' <%= isPlainObject(/foo/g) %> //=> 'false' ``` #### [hasOwn](lib/helpers/object.js#L129) Return true if `key` is an own, enumerable property of the given `obj`. **Params** * `object` **{Object}** * `key` **{String}** * `returns` **{Boolean}** #### [omit](lib/helpers/object.js#L144) Return a copy of `object` exclusing the given `keys`. **Params** * `object` **{Object}**: Object with keys to omit. * `keys` **{String}**: Keys to omit. * `returns` **{Boolean}** **Example** ```js <%= omit({a: 'a', b: 'b', c: 'c'}, ['a', 'c']) %> //=> '{b: "b"}' ``` #### [forIn](lib/helpers/object.js#L163) Iterate over the own and inherited enumerable properties of an object, and return an object with properties that evaluate to true from the callback. Exit early by returning `false`. **Params** * `object` **{Object}**: Object with keys to omit. * `keys` **{String}**: Keys to omit. * `returns` **{Boolean}** **Example** ```js const context = { values: { a: 'b', c: 'd' } }; const str = '<% forIn(values, function(val, key) { %><%= val %><% }) %>'; const fn = _.template(str, { imports: helpers }); assert.equal(fn(context), 'bd'); ``` #### [forOwn](lib/helpers/object.js#L188) Iterate over the own enumerable properties of an object, and return an object with properties that evaluate to true from the callback. Exit early by returning `false` **Params** * `object` **{Object}**: Object with keys to omit. * `keys` **{String}**: Keys to omit. * `returns` **{Boolean}** **Example** ```js const context = { values: { a: 'b', c: 'd' } }; const str = '<% forOwn(values, function(val, key) { %><%= key %><% }) %>'; const fn = _.template(str, { imports: helpers }); console.log(fn(context)) //=> 'ac' ``` #### [extend](lib/helpers/object.js#L205) Extend `o` with properties of other `objects`. **Params** * `o` **{Object}**: The target object. Pass an empty object to shallow clone. * `objects` **{Object}** * `returns` **{Object}** #### [merge](lib/helpers/object.js#L241) Recursively combine the properties of `o` with the properties of other `objects`. **Params** * `o` **{Object}**: The target object. Pass an empty object to shallow clone. * `objects` **{Object}** * `returns` **{Object}** ### path #### [dirname](lib/helpers/path.js#L19) Return the dirname for the given `filepath`. Uses the node.js [path](https://nodejs.org/api/path.html) module. **Params** * `filepath` **{String}** * `returns` **{String}**: Returns the directory part of the file path. **Example** ```js <%= dirname("a/b/c/d") %> //=> 'a/b/c' ``` #### [basename](lib/helpers/path.js#L34) Return the basename for the given `filepath`. Uses the node.js [path](https://nodejs.org/api/path.html) module. **Params** * `filepath` **{String}** * `returns` **{String}**: Returns the basename part of the file path. **Example** ```js <%= basename("a/b/c/d.js") %> //=> 'd.js' ``` #### [filename](lib/helpers/path.js#L49) Returns the filename for the given `filepath`, excluding extension. Aliased as `stem`. **Params** * `filepath` **{String}** * `returns` **{String}**: Returns the file name part of the file path. **Example** ```js <%= filename("a/b/c/d.js") %> //=> 'd' ``` #### [stem](lib/helpers/path.js#L65) Alias for [filename](#filename). **Params** * `filepath` **{String}** * `returns` **{String}**: Returns the file name part of the file path. **Example** ```js <%= stem("a/b/c/d.js") %> //=> 'd' ``` #### [extname](lib/helpers/path.js#L80) Return the file extension for the given `filepath`. Uses the node.js [path](https://nodejs.org/api/path.html) module. **Params** * `filepath` **{String}** * `returns` **{String}**: Returns a file extension **Example** ```js <%= extname("foo.js") %> //=> '.js' ``` #### [ext](lib/helpers/path.js#L95) Return the file extension for the given `filepath`, excluding the `.`. **Params** * `filepath` **{String}** * `returns` **{String}**: Returns a file extension without dot. **Example** ```js <%= ext("foo.js") %> //=> 'js' ``` #### [resolve](lib/helpers/path.js#L110) Resolves the given paths to an absolute path. Uses the node.js [path](https://nodejs.org/api/path.html) module. **Params** * `filepath` **{String}** * `returns` **{String}**: Returns a resolve **Example** ```js <%= resolve('/foo/bar', './baz') %> //=> '/foo/bar/baz' ``` #### [relative](lib/helpers/path.js#L126) Get the relative path from file `a` to file `b`. Typically `a` and `b` would be variables passed on the context. Uses the node.js [path](https://nodejs.org/api/path.html) module. **Params** * `a` **{String}**: The "from" file path. * `b` **{String}**: The "to" file path. * `returns` **{String}**: Returns a relative path. **Example** ```js <%= relative(a, b) %> ``` #### [segments](lib/helpers/path.js#L162) Get specific (joined) segments of a file path by passing a range of array indices. **Params** * `filepath` **{String}**: The file path to split into segments. * `returns` **{String}**: Returns a single, joined file path. **Example** ```js <%= segments("a/b/c/d", "2", "3") %> //=> 'c/d' <%= segments("a/b/c/d", "1", "3") %> //=> 'b/c/d' <%= segments("a/b/c/d", "1", "2") %> //=> 'b/c' ``` #### [join](lib/helpers/path.js#L183) Join all arguments together and normalize the resulting `filepath`. Uses the node.js [path](https://nodejs.org/api/path.html) module. **Note**: there is also a `join()` array helper, dot notation can be used with helpers to differentiate. Example: `<%= path.join() %>`. **Params** * `filepaths` **{String}**: List of file paths. * `returns` **{String}**: Returns a single, joined file path. **Example** ```js <%= join("a", "b") %> //=> 'a/b' ``` #### [isAbsolute](lib/helpers/path.js#L215) Returns true if a file path is an absolute path. An absolute path will always resolve to the same location, regardless of the working directory. Uses the node.js [path](https://nodejs.org/api/path.html) module. **Params** * `filepath` **{String}** * `returns` **{String}**: Returns a resolve **Example** ```js // posix <%= isAbsolute('/foo/bar') %> //=> 'true' <%= isAbsolute('qux/') %> //=> 'false' <%= isAbsolute('.') %> //=> 'false' // Windows <%= isAbsolute('//server') %> //=> 'true' <%= isAbsolute('C:/foo/..') %> //=> 'true' <%= isAbsolute('bar\\baz') %> //=> 'false' <%= isAbsolute('.') %> //=> 'false' ``` #### [isRelative](lib/helpers/path.js#L247) Returns true if a file path is an absolute path. An absolute path will always resolve to the same location, regardless of the working directory. Uses the node.js [path](https://nodejs.org/api/path.html) module. **Params** * `filepath` **{String}** * `returns` **{String}**: Returns a resolve **Example** ```js // posix <%= isRelative('/foo/bar') %> //=> 'false' <%= isRelative('qux/') %> //=> 'true' <%= isRelative('.') %> //=> 'true' // Windows <%= isRelative('//server') %> //=> 'false' <%= isRelative('C:/foo/..') %> //=> 'false' <%= isRelative('bar\\baz') %> //=> 'true' <%= isRelative('.') %> //=> 'true' ``` ### string #### [camelcase](lib/helpers/string.js#L24) camelCase the characters in `string`. **Params** * `string` **{String}**: The string to camelcase. * `returns` **{String}** **Example** ```js <%= camelcase("foo bar baz") %> //=> 'fooBarBaz' ``` #### [centerAlign](lib/helpers/string.js#L46) Center align the characters in a string using non-breaking spaces. **Params** * `str` **{String}**: The string to reverse. * `returns` **{String}**: Centered string. **Example** ```js <%= centerAlign("abc") %> ``` #### [chop](lib/helpers/string.js#L69) Like trim, but removes both extraneous whitespace and non-word characters from the beginning and end of a string. **Params** * `string` **{String}**: The string to chop. * `returns` **{String}** **Example** ```js <%= chop("_ABC_") %> //=> 'ABC' <%= chop("-ABC-") %> //=> 'ABC' <%= chop(" ABC ") %> //=> 'ABC' ``` #### [count](lib/helpers/string.js#L88) Count the number of occurrances of a substring within a string. **Params** * `string` **{String}** * `substring` **{String}** * `returns` **{Number}**: The occurances of `substring` in `string` **Example** ```js <%= count("abcabcabc", "a") %> //=> '3' ``` #### [dotcase](lib/helpers/string.js#L107) dot.case the characters in `string`. **Params** * `string` **{String}** * `returns` **{String}** **Example** ```js <%= dotcase("a-b-c d_e") %> //=> 'a.b.c.d.e' ``` #### [ellipsis](lib/helpers/string.js#L128) Truncate a string to the specified `length`, and append it with an elipsis, `…`. **Params** * `str` **{String}** * `length` **{Number}**: The desired length of the returned string. * `ch` **{String}**: Optionally pass custom characters to append. Default is `…`. * `returns` **{String}**: The truncated string. **Example** ```js <%= ellipsis("<span>foo bar baz</span>", 7) %> //=> 'foo bar…' ``` #### [isString](lib/helpers/string.js#L147) Returns true if the value is a string. **Params** * `val` **{String}** * `returns` **{Boolean}**: True if the value is a string. **Example** ```js <%= isString('abc') %> //=> 'true' <%= isString(null) %> //=> 'false' ``` #### [lowercase](lib/helpers/string.js#L161) Lowercase the characters in the given `string`. **Params** * `string` **{String}**: The string to lowercase. * `returns` **{String}** **Example** ```js <%= lowercase("ABC") %> //=> 'abc' ``` #### [pascalcase](lib/helpers/string.js#L177) PascalCase the characters in `string`. **Params** * `string` **{String}** * `returns` **{String}** **Example** ```js <%= pascalcase("foo bar baz") %> //=> 'FooBarBaz' ``` #### [snakecase](lib/helpers/string.js#L196) snake_case the characters in `string`. **Params** * `string` **{String}** * `returns` **{String}** **Example** ```js <%= snakecase("a-b-c d_e") %> //=> 'a_b_c_d_e' ``` #### [split](lib/helpers/string.js#L214) Split `string` by the given `character`. **Params** * `string` **{String}**: The string to split. * `returns` **{String}** `character`: Default is `,` **Example** ```js <%= split("a,b,c", ",") %> //=> ['a', 'b', 'c'] ``` #### [strip](lib/helpers/string.js#L230) Strip `substring` from the given `string`. **Params** * `substring` **{String|RegExp}**: The string or regex pattern of the substring to remove. * `string` **{String}**: The target string. **Example** ```js <%= strip("foo-bar", "foo-") %> //=> 'bar' ``` #### [stripIndent](lib/helpers/string.js#L248) Strip the indentation from a `string`. **Params** * `string` **{String}**: The string to strip indentation from. * `returns` **{String}** **Example** ```js <%= stripIndent(" _ABC_") %> //=> 'ABC' ``` #### [trim](lib/helpers/string.js#L275) Trim extraneous whitespace from the beginning and end of a string. **Params** * `string` **{String}**: The string to trim. * `returns` **{String}** **Example** ```js <%= trim(" ABC ") %> //=> 'ABC' ``` #### [dashcase](lib/helpers/string.js#L291) dash-case the characters in `string`. This is similar to [slugify](https://github.com/simov/slugify), but [slugify](https://github.com/simov/slugify) makes the string compatible to be used as a URL slug. **Params** * `string` **{String}** * `returns` **{String}** **Example** ```js <%= dashcase("a b.c d_e") %> //=> 'a-b-c-d-e' ``` #### [pathcase](lib/helpers/string.js#L309) path/case the characters in `string`. **Params** * `string` **{String}** * `returns` **{String}** **Example** ```js <%= pathcase("a-b-c d_e") %> //=> 'a/b/c/d/e' ``` #### [sentencecase](lib/helpers/string.js#L327) Sentence-case the characters in `string`. **Params** * `string` **{String}** * `returns` **{String}** **Example** ```js <%= sentencecase("foo bar baz.") %> //=> 'Foo bar baz.' ``` #### [hyphenate](lib/helpers/string.js#L345) Replace spaces in a string with hyphens. This **Params** * `string` **{String}** * `returns` **{String}** **Example** ```js <%= hyphenate("a b c") %> //=> 'a-b-c' ``` #### [reverse](lib/helpers/string.js#L377) Reverse the characters in a string. **Params** * `str` **{String}**: The string to reverse. * `returns` **{String}** **Example** ```js <%= reverse("abc") %> //=> 'cba' ``` #### [rightAlign](lib/helpers/string.js#L394) Right align the characters in a string using non-breaking spaces. **Params** * `str` **{String}**: The string to reverse. * `returns` **{String}**: Right-aligned string. **Example** ```js <%= rightAlign(str) %> ``` #### [replace](lib/helpers/string.js#L412) Replace occurrences of `a` with `b`. **Params** * `str` **{String}** * `a` **{String|RegExp}**: Can be a string or regexp. * `b` **{String}** * `returns` **{String}** **Example** ```js <%= replace("abcabc", /a/, "z") %> //=> 'zbczbc' ``` #### [titlecase](lib/helpers/string.js#L433) Truncate a string by removing all HTML tags and limiting the result to the specified `length`. **Params** * `str` **{String}** * `length` **{Number}**: The desired length of the returned string. * `returns` **{String}**: The truncated string. **Example** ```js <%= titlecase("big deal") %> //=> 'foo bar' ``` #### [truncate](lib/helpers/string.js#L451) Truncate a string by removing all HTML tags and limiting the result to the specified `length`. **Params** * `str` **{String}** * `length` **{Number}**: The desired length of the returned string. * `returns` **{String}**: The truncated string. **Example** ```js <%= truncate("<span>foo bar baz</span>", 7) %> //=> 'foo bar' ``` #### [uppercase](lib/helpers/string.js#L467) Uppercase the characters in a string. **Params** * `string` **{String}**: The string to uppercase. * `returns` **{String}** **Example** ```js <%= uppercase("abc") %> //=> 'ABC' ``` #### [wordwrap](lib/helpers/string.js#L484) Wrap words to a specified width using [word-wrap](https://github.com/jonschlinkert/word-wrap). **Params** * `string` **{String}**: The string with words to wrap. * `object` **{Options}**: Options to pass to [word-wrap](https://github.com/jonschlinkert/word-wrap) * `returns` **{String}**: Formatted string. **Example** ```js <%= wordwrap("a b c d e f", {width: 5, newline: '<br> '}) %> //=> ' a b c <br> d e f' ``` ## Coverage ``` Statements : 94.61% ( 439/464 ) Branches : 88.37% ( 190/215 ) Functions : 96.94% ( 95/98 ) Lines : 94.42% ( 389/412 ) ``` ## About <details> <summary><strong>Contributing</strong></summary> Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new). </details> <details> <summary><strong>Running Tests</strong></summary> Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command: ```sh $ npm install && npm test ``` </details> <details> <summary><strong>Building docs</strong></summary> _(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_ To generate the readme, run the following command: ```sh $ npm install -g verbose/verb#dev verb-generate-readme && verb ``` </details> ### Related projects You might also be interested in the following projects (also visit the [github.com/helpers](https://github.com/helpers), where you can find 60+ additional standalone helpers!): * [assemble](https://www.npmjs.com/package/assemble): Get the rocks out of your socks! Assemble makes you fast at creating web projects… [more](https://github.com/assemble/assemble) | [homepage](https://github.com/assemble/assemble "Get the rocks out of your socks! Assemble makes you fast at creating web projects. Assemble is used by thousands of projects for rapid prototyping, creating themes, scaffolds, boilerplates, e-books, UI components, API documentation, blogs, building websit") * [handlebars-helpers](https://www.npmjs.com/package/handlebars-helpers): More than 130 Handlebars helpers in ~20 categories. Helpers can be used with Assemble, Generate… [more](https://github.com/helpers/handlebars-helpers) | [homepage](https://github.com/helpers/handlebars-helpers "More than 130 Handlebars helpers in ~20 categories. Helpers can be used with Assemble, Generate, Verb, Ghost, gulp-handlebars, grunt-handlebars, consolidate, or any node.js/Handlebars project.") * [templates](https://www.npmjs.com/package/templates): System for creating and managing template collections, and rendering templates with any node.js template engine… [more](https://github.com/jonschlinkert/templates) | [homepage](https://github.com/jonschlinkert/templates "System for creating and managing template collections, and rendering templates with any node.js template engine. Can be used as the basis for creating a static site generator or blog framework.") ### Contributors ### Author **Jon Schlinkert** * [GitHub Profile](https://github.com/jonschlinkert) * [Twitter Profile](https://twitter.com/jonschlinkert) * [LinkedIn Profile](https://linkedin.com/in/jonschlinkert) ### License Copyright © 2018, [Jon Schlinkert](https://github.com/jonschlinkert). Released under the [MIT License](LICENSE). *** _This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on November 24, 2018._