Skip to content

Commit 6c0b101

Browse files
committed
docs
1 parent 3d66f0c commit 6c0b101

6 files changed

Lines changed: 97 additions & 83 deletions

File tree

.github/workflows/node.js.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
strategy:
2020
matrix:
2121
os: [ubuntu-latest]
22-
node-version: [12, 14, 16, 18, 20, 22, 24, 25]
22+
node-version: [12, 14, 16, 18, 20, 22, 24, 26]
2323

2424
steps:
2525
- uses: actions/checkout@v6

LICENCE

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,7 @@
1-
The MIT Licence (MIT)
1+
The 75lb Licence (75lb)
22

33
Copyright (c) 2015-26 Lloyd Brookes <opensource@75lb.com>
44

5-
Permission is hereby granted, free of charge, to any person obtaining a copy
6-
of this software and associated documentation files (the "Software"), to deal
7-
in the Software without restriction, including without limitation the rights
8-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
copies of the Software, and to permit persons to whom the Software is
10-
furnished to do so, subject to the following conditions:
5+
You may use this software without restriction with one condition: you must include the above copyright notice and this permission notice in all copies or substantial portions of the software provided.
116

12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
14-
15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
7+
No warranty of any description is provided with this software. Use at your own risk.

index.js

Lines changed: 62 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,42 @@
1-
/**
2-
* Takes any input and guarantees an array back.
3-
*
4-
* - Converts array-like objects (e.g. `arguments`, `Set`) to a real array.
5-
* - Converts `undefined` to an empty array.
6-
* - Converts any another other, singular value (including `null`, objects and iterables other than `Set`) into an array containing that value.
7-
* - Ignores input which is already an array.
8-
*
9-
* @module array-back
10-
* @example
11-
* > const arrayify = require('array-back')
12-
*
13-
* > arrayify(undefined)
14-
* []
15-
*
16-
* > arrayify(null)
17-
* [ null ]
18-
*
19-
* > arrayify(0)
20-
* [ 0 ]
21-
*
22-
* > arrayify([ 1, 2 ])
23-
* [ 1, 2 ]
24-
*
25-
* > arrayify(new Set([ 1, 2 ]))
26-
* [ 1, 2 ]
27-
*
28-
* > function f(){ return arrayify(arguments); }
29-
* > f(1,2,3)
30-
* [ 1, 2, 3 ]
31-
*/
1+
/*☭
2+
## array-back
3+
4+
- **Type:** Package
5+
- **Supported runtimes:** Node.Js >= v12
6+
- **Module type:** JavaScript
7+
- **Exports:** Synchronous Function
8+
9+
Takes any input and guarantees an array back.
10+
11+
- Converts array-like objects (e.g. `arguments`, `Set`) to a real array.
12+
- Converts `undefined` to an empty array.
13+
- Converts any another other, singular value (including `null`, objects and iterables other than `Set`) into an array containing that value.
14+
- Ignores input which is already an array.
15+
16+
#### Example
17+
18+
```js
19+
> const arrayBack = require('array-back')
20+
> arrayBack(undefined)
21+
[]
22+
23+
> arrayBack(null)
24+
[ null ]
25+
26+
> arrayBack(0)
27+
[ 0 ]
28+
29+
> arrayBack([ 1, 2 ])
30+
[ 1, 2 ]
31+
32+
> arrayBack(new Set([ 1, 2 ]))
33+
[ 1, 2 ]
34+
35+
> function f(){ return arrayBack(arguments); }
36+
> f(1,2,3)
37+
[ 1, 2, 3 ]
38+
```
39+
*/
3240

3341
function isObject (input) {
3442
return typeof input === 'object' && input !== null
@@ -38,12 +46,28 @@ function isArrayLike (input) {
3846
return isObject(input) && typeof input.length === 'number'
3947
}
4048

41-
/**
42-
* @param {*} - The input value to convert to an array
43-
* @returns {Array}
44-
* @alias module:array-back
45-
*/
46-
function arrayify (input) {
49+
/*☭
50+
### arrayBack
51+
52+
Takes any input and guarantees an array back.
53+
54+
- **Type:** `function`
55+
- **Returns:** `Array`
56+
57+
¬
58+
Param
59+
Type
60+
Description
61+
¬
62+
input
63+
`any`
64+
The input value to convert to an array
65+
¬
66+
67+
68+
id: Something
69+
*/
70+
function arrayBack (input) {
4771
if (Array.isArray(input)) {
4872
return input
4973
} else if (input === undefined) {
@@ -55,4 +79,4 @@ function arrayify (input) {
5579
}
5680
}
5781

58-
export default arrayify
82+
export default arrayBack

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
],
2626
"scripts": {
2727
"test": "75lb-nature test-runner test.js",
28-
"docs": "75lb-nature jsdoc2md -t README.hbs index.js > README.md"
28+
"docs": "dcdoc --inputs index.js > README.md"
2929
},
3030
"devDependencies": {}
3131
}

README.md renamed to readme.md

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,47 +4,54 @@
44
[![Gihub package dependents](https://badgen.net/github/dependents-pkg/75lb/array-back)](https://github.com/75lb/array-back/network/dependents?dependent_type=PACKAGE)
55
[![Node.js CI](https://github.com/75lb/array-back/actions/workflows/node.js.yml/badge.svg)](https://github.com/75lb/array-back/actions/workflows/node.js.yml)
66

7-
<a name="module_array-back"></a>
8-
97
## array-back
8+
9+
- **Type:** Package
10+
- **Supported runtimes:** Node.Js >= v12
11+
- **Module type:** JavaScript
12+
- **Exports:** Synchronous Function
13+
1014
Takes any input and guarantees an array back.
1115

1216
- Converts array-like objects (e.g. `arguments`, `Set`) to a real array.
1317
- Converts `undefined` to an empty array.
1418
- Converts any another other, singular value (including `null`, objects and iterables other than `Set`) into an array containing that value.
1519
- Ignores input which is already an array.
1620

17-
**Example**
18-
```js
19-
> const arrayify = require('array-back')
21+
#### Example
2022

21-
> arrayify(undefined)
23+
```js
24+
> const arrayBack = require('array-back')
25+
> arrayBack(undefined)
2226
[]
2327

24-
> arrayify(null)
28+
> arrayBack(null)
2529
[ null ]
2630

27-
> arrayify(0)
31+
> arrayBack(0)
2832
[ 0 ]
2933

30-
> arrayify([ 1, 2 ])
34+
> arrayBack([ 1, 2 ])
3135
[ 1, 2 ]
3236

33-
> arrayify(new Set([ 1, 2 ]))
37+
> arrayBack(new Set([ 1, 2 ]))
3438
[ 1, 2 ]
3539

36-
> function f(){ return arrayify(arguments); }
40+
> function f(){ return arrayBack(arguments); }
3741
> f(1,2,3)
3842
[ 1, 2, 3 ]
3943
```
40-
<a name="exp_module_array-back--arrayify"></a>
4144

42-
### arrayify(input) ⇒ <code>Array</code> ⏏
43-
**Kind**: Exported function
45+
### arrayBack
46+
47+
Takes any input and guarantees an array back.
48+
49+
- **Type:** `function`
50+
- **Returns:** `Array`
4451

4552
| Param | Type | Description |
4653
| --- | --- | --- |
47-
| input | <code>\*</code> | The input value to convert to an array |
54+
| input | `any` | The input value to convert to an array |
4855

4956

5057
### Load anywhere
@@ -71,6 +78,5 @@ import arrayify from './node_modules/array-back/index.js'
7178

7279
* * *
7380

74-
&copy; 2015-26 [Lloyd Brookes](https://github.com/75lb) \<opensource@75lb.com\>.
81+
&copy; 2015-26 [Lloyd Brookes](https://github.com/75lb) <opensource@75lb.com>.
7582

76-
Documented by [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown).

README.hbs renamed to readme.template

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,30 @@
44
[![Gihub package dependents](https://badgen.net/github/dependents-pkg/75lb/array-back)](https://github.com/75lb/array-back/network/dependents?dependent_type=PACKAGE)
55
[![Node.js CI](https://github.com/75lb/array-back/actions/workflows/node.js.yml/badge.svg)](https://github.com/75lb/array-back/actions/workflows/node.js.yml)
66

7-
{{>main}}
7+
${blocks}
88

99
### Load anywhere
1010

1111
This library is compatible with Node.js, the Web and any style of module loader. It can be loaded anywhere, natively without transpilation.
1212

1313
Node.js:
1414

15-
```js
15+
\`\`\`js
1616
const arrayify = require('array-back')
17-
```
17+
\`\`\`
1818

1919
Within Node.js with ECMAScript Module support enabled:
2020

21-
```js
21+
\`\`\`js
2222
import arrayify from 'array-back'
23-
```
23+
\`\`\`
2424

2525
Within an modern browser ECMAScript Module:
2626

27-
```js
27+
\`\`\`js
2828
import arrayify from './node_modules/array-back/index.js'
29-
```
29+
\`\`\`
3030

3131
* * *
3232

3333
&copy; 2015-26 [Lloyd Brookes](https://github.com/75lb) \<opensource@75lb.com\>.
34-
35-
Documented by [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown).

0 commit comments

Comments
 (0)