From 4e90484e3dd043696e904248a407bb35f35c5cfb Mon Sep 17 00:00:00 2001 From: Lloyd Brookes Date: Sat, 24 Nov 2018 11:11:05 +0000 Subject: [PATCH] Added Load Anywhere section to readme --- README.hbs | 28 ++++++++++++++++++++++++++++ README.md | 42 +++++++++++++++++++++++++++++++++++------- dist/index.js | 25 +++++++++++++------------ dist/test.js | 26 +++++++++++++------------- index.mjs | 14 +++++++------- 5 files changed, 96 insertions(+), 39 deletions(-) diff --git a/README.hbs b/README.hbs index d15cf0b..bca42e6 100644 --- a/README.hbs +++ b/README.hbs @@ -7,6 +7,34 @@ {{>main}} +### Load anywhere + +This library can be loaded anywhere, natively without transpilation. + +Node.js: + +```js +const arrayify = require('array-back') +``` + +Within Node.js with ECMAScript Module support enabled: + +```js +import arrayify from 'array-back' +``` + +Within an modern browser ECMAScript Module: + +```js +import arrayify from './node_modules/array-back/index.mjs' +``` + +Old browser (adds `window.arrayBack`): + +```html + +``` + * * * © 2015-18 Lloyd Brookes \<75pound@gmail.com\>. Documented by [jsdoc-to-markdown](https://github.com/75lb/jsdoc-to-markdown). \ No newline at end of file diff --git a/README.md b/README.md index 22e7caf..2de5301 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,13 @@ ## array-back +Takes any input and guarantees an array back. + +- converts array-like objects (e.g. `arguments`) to a real array +- converts `undefined` to an empty array +- converts any another other, singular value (including `null`) into an array containing that value +- ignores input which is already an array + **Example** ```js > const arrayify = require('array-back') @@ -31,13 +38,6 @@ ### arrayify(input) ⇒ Array ⏏ -Takes any input and guarantees an array back. - -- converts array-like objects (e.g. `arguments`) to a real array -- converts `undefined` to an empty array -- converts any another other, singular value (including `null`) into an array containing that value -- ignores input which is already an array - **Kind**: Exported function | Param | Type | Description | @@ -45,6 +45,34 @@ Takes any input and guarantees an array back. | input | \* | the input value to convert to an array | +### Load anywhere + +This library can be loaded anywhere, natively without transpilation. + +Node.js: + +```js +const arrayify = require('array-back') +``` + +Within Node.js with ECMAScript Module support enabled: + +```js +import arrayify from 'array-back' +``` + +Within an modern browser ECMAScript Module: + +```js +import arrayify from './node_modules/array-back/index.mjs' +``` + +Old browser (adds `window.arrayBack`): + +```html + +``` + * * * © 2015-18 Lloyd Brookes \<75pound@gmail.com\>. Documented by [jsdoc-to-markdown](https://github.com/75lb/jsdoc-to-markdown). \ No newline at end of file diff --git a/dist/index.js b/dist/index.js index 6385d55..70b201d 100644 --- a/dist/index.js +++ b/dist/index.js @@ -5,22 +5,30 @@ }(this, (function () { 'use strict'; /** + * Takes any input and guarantees an array back. + * + * - converts array-like objects (e.g. `arguments`) to a real array + * - converts `undefined` to an empty array + * - converts any another other, singular value (including `null`) into an array containing that value + * - ignores input which is already an array + * * @module array-back * @example * > const arrayify = require('array-back') - * > a.arrayify(undefined) + * + * > arrayify(undefined) * [] * - * > a.arrayify(null) + * > arrayify(null) * [ null ] * - * > a.arrayify(0) + * > arrayify(0) * [ 0 ] * - * > a.arrayify([ 1, 2 ]) + * > arrayify([ 1, 2 ]) * [ 1, 2 ] * - * > function f(){ return a.arrayify(arguments); } + * > function f(){ return arrayify(arguments); } * > f(1,2,3) * [ 1, 2, 3 ] */ @@ -34,13 +42,6 @@ } /** - * Takes any input and guarantees an array back. - * - * - converts array-like objects (e.g. `arguments`) to a real array - * - converts `undefined` to an empty array - * - converts any another other, singular value (including `null`) into an array containing that value - * - ignores input which is already an array - * * @param {*} - the input value to convert to an array * @returns {Array} * @alias module:array-back diff --git a/dist/test.js b/dist/test.js index 20edbea..9661c0e 100644 --- a/dist/test.js +++ b/dist/test.js @@ -6,23 +6,30 @@ var TestRunner = _interopDefault(require('test-runner')); var a = _interopDefault(require('assert')); /** + * Takes any input and guarantees an array back. + * + * - converts array-like objects (e.g. `arguments`) to a real array + * - converts `undefined` to an empty array + * - converts any another other, singular value (including `null`) into an array containing that value + * - ignores input which is already an array + * * @module array-back * @example * > const arrayify = require('array-back') - * - * > a.arrayify(undefined) + * + * > arrayify(undefined) * [] * - * > a.arrayify(null) + * > arrayify(null) * [ null ] * - * > a.arrayify(0) + * > arrayify(0) * [ 0 ] * - * > a.arrayify([ 1, 2 ]) + * > arrayify([ 1, 2 ]) * [ 1, 2 ] * - * > function f(){ return a.arrayify(arguments); } + * > function f(){ return arrayify(arguments); } * > f(1,2,3) * [ 1, 2, 3 ] */ @@ -36,13 +43,6 @@ function isArrayLike (input) { } /** - * Takes any input and guarantees an array back. - * - * - converts array-like objects (e.g. `arguments`) to a real array - * - converts `undefined` to an empty array - * - converts any another other, singular value (including `null`) into an array containing that value - * - ignores input which is already an array - * * @param {*} - the input value to convert to an array * @returns {Array} * @alias module:array-back diff --git a/index.mjs b/index.mjs index b58969c..cff1090 100644 --- a/index.mjs +++ b/index.mjs @@ -1,4 +1,11 @@ /** + * Takes any input and guarantees an array back. + * + * - converts array-like objects (e.g. `arguments`) to a real array + * - converts `undefined` to an empty array + * - converts any another other, singular value (including `null`) into an array containing that value + * - ignores input which is already an array + * * @module array-back * @example * > const arrayify = require('array-back') @@ -29,13 +36,6 @@ function isArrayLike (input) { } /** - * Takes any input and guarantees an array back. - * - * - converts array-like objects (e.g. `arguments`) to a real array - * - converts `undefined` to an empty array - * - converts any another other, singular value (including `null`) into an array containing that value - * - ignores input which is already an array - * * @param {*} - the input value to convert to an array * @returns {Array} * @alias module:array-back