Skip to content

Commit 00ce163

Browse files
committed
See:
- updated .gitignore to push docs - updated cicd to generate docs - updated scripts in package.json - added badge to README.md skip-checks: true
1 parent 4a8e709 commit 00ce163

14 files changed

+475
-6
lines changed

.github/workflows/cicd.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ jobs:
4141

4242
- run: npm run test
4343

44+
- run: npm run build:docs
45+
4446
- run: |
4547
SSH="${{ runner.temp }}/ssh"
4648
mkdir -p $SSH

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ build/Release
9393
coverage
9494
dist/
9595
dist/**/*
96-
docs/
9796
ehthumbs.db
9897
ehthumbs_vista.db
9998
jspm_packages/

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
> JavaScript standard library extensions
44
55
[![cicd](https://github.com/KamaranL/js-stdlib-extensions/actions/workflows/cicd.yml/badge.svg?branch=dev)](https://github.com/KamaranL/js-stdlib-extensions/actions/workflows/cicd.yml)
6+
[![view on npmjs](https://badgen.net/npm/v/js-stdlib-extensions)](https://www.npmjs.com/package/js-stdlib-extensions)
67

78
## Installation and Usage
89

VERSION.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.0-alpha.1
1+
0.1.0-alpha.3

docs/README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
js-stdlib-extensions / [Exports](/docs/modules.md)
2+
3+
# js-stdlib-extensions
4+
5+
> JavaScript standard library extensions
6+
7+
[![cicd](https://github.com/KamaranL/js-stdlib-extensions/actions/workflows/cicd.yml/badge.svg?branch=dev)](https://github.com/KamaranL/js-stdlib-extensions/actions/workflows/cicd.yml)
8+
[![view on npmjs](https://badgen.net/npm/v/js-stdlib-extensions)](https://www.npmjs.com/package/js-stdlib-extensions)
9+
10+
## Installation and Usage
11+
12+
### Prerequisites
13+
14+
- [Node.js](https://nodejs.org/) `>=20.10.0`
15+
16+
### Install
17+
18+
```bash
19+
npm i js-stdlib-extensions
20+
```
21+
22+
### Usage
23+
24+
#### Import into package
25+
26+
```javascript
27+
// javascript
28+
require('js-stdlib-extensions')
29+
30+
// typescript
31+
import 'js-stdlib-extensions'
32+
```
33+
34+
### [Docs](/docs/modules.md)
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
[js-stdlib-extensions](/docs/README.md) / [Exports](/docs/modules.md) / [ArrayExtensions](/docs/modules/ArrayExtensions.md) / Array
2+
3+
# Interface: Array\<T\>
4+
5+
[ArrayExtensions](/docs/modules/ArrayExtensions.md).Array
6+
7+
Array
8+
9+
## Type parameters
10+
11+
| Name |
12+
| :------ |
13+
| `T` |
14+
15+
## Table of contents
16+
17+
### Methods
18+
19+
- [isEmpty](/docs/interfaces/ArrayExtensions.Array.md#isempty)
20+
21+
## Methods
22+
23+
### isEmpty
24+
25+
**isEmpty**(): `boolean`
26+
27+
Returns true if the length of the array is 0.
28+
29+
#### Returns
30+
31+
`boolean`
32+
33+
**`Example`**
34+
35+
```ts
36+
// returns true
37+
[].isEmpty()
38+
```
39+
40+
#### Defined in
41+
42+
[array.ts:17](https://github.com/KamaranL/js-stdlib-extensions/blob/c125d3e/src/ext/array.ts#L17)
Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
[js-stdlib-extensions](/docs/README.md) / [Exports](/docs/modules.md) / [ObjectExtensions](/docs/modules/ObjectExtensions.md) / ObjectConstructor
2+
3+
# Interface: ObjectConstructor
4+
5+
[ObjectExtensions](/docs/modules/ObjectExtensions.md).ObjectConstructor
6+
7+
ObjectConstructor
8+
9+
## Table of contents
10+
11+
### Methods
12+
13+
- [flatMap](/docs/interfaces/ObjectExtensions.ObjectConstructor.md#flatmap)
14+
- [isEmpty](/docs/interfaces/ObjectExtensions.ObjectConstructor.md#isempty)
15+
- [sort](/docs/interfaces/ObjectExtensions.ObjectConstructor.md#sort)
16+
17+
## Methods
18+
19+
### flatMap
20+
21+
**flatMap**\<`T`\>(`o`, `options?`): \{ `[key: string]`: `string` \| [value: string, type: string]; }[]
22+
23+
Returns a flat map of a multi-dimensional object with, or without, type
24+
definitions of the value.
25+
26+
#### Type parameters
27+
28+
| Name |
29+
| :------ |
30+
| `T` |
31+
32+
#### Parameters
33+
34+
| Name | Type | Description |
35+
| :------ | :------ | :------ |
36+
| `o` | `T` | Object. |
37+
| `options?` | `Object` | - |
38+
| `options.types?` | `boolean` | If false, will return only the value with each object key, instead of an array that contains the value with the type definition of the value. |
39+
40+
#### Returns
41+
42+
\{ `[key: string]`: `string` \| [value: string, type: string]; }[]
43+
44+
**`Example`**
45+
46+
```ts
47+
// returns [
48+
// { name: [ 'John', 'string' ] },
49+
// { age: [ 42, 'number' ] },
50+
// { 'children.0.name': [ 'Mary', 'string' ] },
51+
// { 'children.0.age': [ 18, 'number' ] },
52+
// { 'children.1.name': [ 'Nicholas', 'string' ] },
53+
// { 'children.1.age': [ 11, 'number' ] },
54+
// { 'children.2.name': [ 'Adam', 'string' ] },
55+
// { 'children.2.age': [ 21, 'number' ] },
56+
// { 'letters.0': [ 'a', 'string' ] },
57+
// { 'letters.1': [ 'd', 'string' ] },
58+
// { 'letters.2': [ 'z', 'string' ] },
59+
// { 'letters.3': [ 'c', 'string' ] },
60+
// { 'numbers.0': [ 9, 'number' ] },
61+
// { 'numbers.1': [ 1, 'number' ] },
62+
// { 'numbers.3': [ 4, 'number' ] }
63+
// ]
64+
Object.flatMap({
65+
name: 'John',
66+
age: 42,
67+
single: false,
68+
children: [
69+
{ name: 'Mary', age: 18 },
70+
{ name: 'Nicholas', age: 11 },
71+
{ name: 'Adam', age: 21 }
72+
],
73+
letters: [ 'a', 'd', 'z', 'c' ],
74+
numbers: [ 9, 1, 0, 4 ]
75+
})
76+
```
77+
78+
**`Example`**
79+
80+
```ts
81+
// returns [
82+
// { name: 'John' },
83+
// { age: 42 },
84+
// { 'children.0.name': 'Mary' },
85+
// { 'children.0.age': 18 },
86+
// { 'children.1.name': 'Nicholas' },
87+
// { 'children.1.age': 11 },
88+
// { 'children.2.name': 'Adam' },
89+
// { 'children.2.age': 21 },
90+
// { 'letters.0': 'a' },
91+
// { 'letters.1': 'd' },
92+
// { 'letters.2': 'z' },
93+
// { 'letters.3': 'c' },
94+
// { 'numbers.0': 9 },
95+
// { 'numbers.1': 1 },
96+
// { 'numbers.3': 4 }
97+
// ]
98+
Object.flatMap({
99+
name: 'John',
100+
age: 42,
101+
single: false,
102+
children: [
103+
{ name: 'Mary', age: 18 },
104+
{ name: 'Nicholas', age: 11 },
105+
{ name: 'Adam', age: 21 }
106+
],
107+
letters: [ 'a', 'd', 'z', 'c' ],
108+
numbers: [ 9, 1, 0, 4 ]
109+
}, {types: false})
110+
```
111+
112+
#### Defined in
113+
114+
[object.ts:82](https://github.com/KamaranL/js-stdlib-extensions/blob/c125d3e/src/ext/object.ts#L82)
115+
116+
___
117+
118+
### isEmpty
119+
120+
**isEmpty**\<`T`\>(`o`): `boolean`
121+
122+
Return true if the length of Object.keys() is 0.
123+
124+
#### Type parameters
125+
126+
| Name |
127+
| :------ |
128+
| `T` |
129+
130+
#### Parameters
131+
132+
| Name | Type | Description |
133+
| :------ | :------ | :------ |
134+
| `o` | `T` | Object. |
135+
136+
#### Returns
137+
138+
`boolean`
139+
140+
**`Example`**
141+
142+
```ts
143+
// returns true
144+
Object.isEmpty({})
145+
```
146+
147+
#### Defined in
148+
149+
[object.ts:99](https://github.com/KamaranL/js-stdlib-extensions/blob/c125d3e/src/ext/object.ts#L99)
150+
151+
___
152+
153+
### sort
154+
155+
**sort**\<`T`\>(`o`, `options?`): `T`
156+
157+
Returns an object with sorted keys.
158+
159+
#### Type parameters
160+
161+
| Name |
162+
| :------ |
163+
| `T` |
164+
165+
#### Parameters
166+
167+
| Name | Type | Description |
168+
| :------ | :------ | :------ |
169+
| `o` | `T` | Object. |
170+
| `options?` | `Object` | - |
171+
| `options.descending?` | `boolean` | If true, will sort object keys in descending order. |
172+
| `options.property?` | `string` | If provided, will sort arrays of objects by the specified property. |
173+
| `options.recursive?` | `boolean` | If true, will recursively sort any nested objects/arrays. |
174+
175+
#### Returns
176+
177+
`T`
178+
179+
**`Example`**
180+
181+
```ts
182+
// returns {
183+
// age: 42,
184+
// children: [
185+
// { name: 'Mary', age: 18 },
186+
// { name: 'Nicholas', age: 11 },
187+
// { name: 'Adam', age: 21 }
188+
// ],
189+
// letters: [ 'a', 'd', 'z', 'c' ],
190+
// name: 'John',
191+
// numbers: [ 9, 1, 0, 4 ],
192+
// single: false
193+
// }
194+
Object.sort({
195+
name: 'John',
196+
age: 42,
197+
single: false,
198+
children: [
199+
{ name: 'Mary', age: 18 },
200+
{ name: 'Nicholas', age: 11 },
201+
{ name: 'Adam', age: 21 }
202+
],
203+
letters: [ 'a', 'd', 'z', 'c' ],
204+
numbers: [ 9, 1, 0, 4 ]
205+
})
206+
```
207+
208+
**`Example`**
209+
210+
```ts
211+
// returns {
212+
// age: 42,
213+
// children: [
214+
// { age: 11, name: 'Nicholas' },
215+
// { age: 18, name: 'Mary' },
216+
// { age: 21, name: 'Adam' }
217+
// ],
218+
// letters: [ 'a', 'c', 'd', 'z' ],
219+
// name: 'John',
220+
// numbers: [ 0, 1, 4, 9 ],
221+
// single: false
222+
// }
223+
Object.sort({
224+
name: 'John',
225+
age: 42,
226+
single: false,
227+
children: [
228+
{ name: 'Mary', age: 18 },
229+
{ name: 'Nicholas', age: 11 },
230+
{ name: 'Adam', age: 21 }
231+
],
232+
letters: [ 'a', 'd', 'z', 'c' ],
233+
numbers: [ 9, 1, 0, 4 ]
234+
}, {recursive: true, property: 'age'})
235+
```
236+
237+
#### Defined in
238+
239+
[object.ts:168](https://github.com/KamaranL/js-stdlib-extensions/blob/c125d3e/src/ext/object.ts#L168)

0 commit comments

Comments
 (0)