Skip to content

Commit 5854016

Browse files
committed
docs
1 parent 3d66f0c commit 5854016

6 files changed

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

3335
function isObject (input) {
3436
return typeof input === 'object' && input !== null
@@ -38,12 +40,28 @@ function isArrayLike (input) {
3840
return isObject(input) && typeof input.length === 'number'
3941
}
4042

41-
/**
42-
* @param {*} - The input value to convert to an array
43-
* @returns {Array}
44-
* @alias module:array-back
45-
*/
46-
function arrayify (input) {
43+
/*☭
44+
### arrayBack
45+
46+
Description.
47+
48+
- **Type:** `function`
49+
- **Returns:** `Array`
50+
51+
¬
52+
Param
53+
Type
54+
Description
55+
¬
56+
input
57+
`any`
58+
The input value to convert to an array
59+
¬
60+
61+
62+
id: Something
63+
*/
64+
function arrayBack (input) {
4765
if (Array.isArray(input)) {
4866
return input
4967
} else if (input === undefined) {
@@ -55,4 +73,4 @@ function arrayify (input) {
5573
}
5674
}
5775

58-
export default arrayify
76+
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
}
File renamed without changes.

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)