Skip to content

Commit

Permalink
Added Load Anywhere section to readme
Browse files Browse the repository at this point in the history
  • Loading branch information
75lb committed Nov 24, 2018
1 parent c9d3e0b commit 4e90484
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 39 deletions.
28 changes: 28 additions & 0 deletions README.hbs
Expand Up @@ -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
<script nomodule src="./node_modules/array-back/dist/index.js"></script>
```

* * *

&copy; 2015-18 Lloyd Brookes \<75pound@gmail.com\>. Documented by [jsdoc-to-markdown](https://github.com/75lb/jsdoc-to-markdown).
42 changes: 35 additions & 7 deletions README.md
Expand Up @@ -8,6 +8,13 @@
<a name="module_array-back"></a>

## 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')
Expand All @@ -31,20 +38,41 @@
<a name="exp_module_array-back--arrayify"></a>

### arrayify(input) ⇒ <code>Array</code> ⏏
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 |
| --- | --- | --- |
| input | <code>\*</code> | 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
<script nomodule src="./node_modules/array-back/dist/index.js"></script>
```

* * *

&copy; 2015-18 Lloyd Brookes \<75pound@gmail.com\>. Documented by [jsdoc-to-markdown](https://github.com/75lb/jsdoc-to-markdown).
25 changes: 13 additions & 12 deletions dist/index.js
Expand Up @@ -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 ]
*/
Expand All @@ -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
Expand Down
26 changes: 13 additions & 13 deletions dist/test.js
Expand Up @@ -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 ]
*/
Expand All @@ -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
Expand Down
14 changes: 7 additions & 7 deletions 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')
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4e90484

Please sign in to comment.