feat: initial commit
This commit is contained in:
282
docs/modules.md
Normal file
282
docs/modules.md
Normal file
@@ -0,0 +1,282 @@
|
||||
[@resultium/utils](README.md) / Exports
|
||||
|
||||
# @resultium/utils
|
||||
|
||||
## Table of contents
|
||||
|
||||
### Functions
|
||||
|
||||
- [SplitIntoChunks](modules.md#splitintochunks)
|
||||
- [capitalizeFirstChar](modules.md#capitalizefirstchar)
|
||||
- [classNames](modules.md#classnames)
|
||||
- [conditionalJoin](modules.md#conditionaljoin)
|
||||
- [isDeepWeakEqual](modules.md#isdeepweakequal)
|
||||
- [randomInRange](modules.md#randominrange)
|
||||
- [removeFromArrayByKeyValue](modules.md#removefromarraybykeyvalue)
|
||||
- [removeObjectProperty](modules.md#removeobjectproperty)
|
||||
- [replaceFromArrayByKeyValue](modules.md#replacefromarraybykeyvalue)
|
||||
|
||||
## Functions
|
||||
|
||||
### SplitIntoChunks
|
||||
|
||||
▸ **SplitIntoChunks**\<`T`\>(`array`, `chunkSize`): `T`[][]
|
||||
|
||||
Splits an array into chunks
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `T` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `array` | `T`[] | array which shall be split into chunks |
|
||||
| `chunkSize` | `number` | size of a single chunk |
|
||||
|
||||
#### Returns
|
||||
|
||||
`T`[][]
|
||||
|
||||
array of chunks
|
||||
|
||||
#### Defined in
|
||||
|
||||
functions/splitIntoChuks.ts:8
|
||||
|
||||
___
|
||||
|
||||
### capitalizeFirstChar
|
||||
|
||||
▸ **capitalizeFirstChar**(`string`): `string`
|
||||
|
||||
Capitalizes first character of the given string
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `string` | `string` | string to modify |
|
||||
|
||||
#### Returns
|
||||
|
||||
`string`
|
||||
|
||||
new string
|
||||
|
||||
#### Defined in
|
||||
|
||||
functions/capitalizeFirstChar.ts:7
|
||||
|
||||
___
|
||||
|
||||
### classNames
|
||||
|
||||
▸ **classNames**(`...classes`): `string`
|
||||
|
||||
Conditionally joins given class strings
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `...classes` | `string`[] | class strings to join |
|
||||
|
||||
#### Returns
|
||||
|
||||
`string`
|
||||
|
||||
new string
|
||||
|
||||
#### Defined in
|
||||
|
||||
functions/classNames.ts:7
|
||||
|
||||
___
|
||||
|
||||
### conditionalJoin
|
||||
|
||||
▸ **conditionalJoin**(`array`, `joinChar`): `string`
|
||||
|
||||
Conditionally joins given strings
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `array` | `string`[] | strings to join |
|
||||
| `joinChar` | `string` | character used to join strings |
|
||||
|
||||
#### Returns
|
||||
|
||||
`string`
|
||||
|
||||
new string
|
||||
|
||||
#### Defined in
|
||||
|
||||
functions/conditionalJoin.ts:8
|
||||
|
||||
___
|
||||
|
||||
### isDeepWeakEqual
|
||||
|
||||
▸ **isDeepWeakEqual**(`obj1`, `obj2`): `boolean`
|
||||
|
||||
Weakly compares two objects
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `obj1` | `object` | first object to compare with second |
|
||||
| `obj2` | `object` | second object to compare with first |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
true if equal
|
||||
|
||||
**`Remarks`**
|
||||
|
||||
uses JSON.stringify()
|
||||
|
||||
#### Defined in
|
||||
|
||||
functions/isDeepWeakEqual.ts:10
|
||||
|
||||
___
|
||||
|
||||
### randomInRange
|
||||
|
||||
▸ **randomInRange**(`min`, `max`): `number`
|
||||
|
||||
Returns a pseudo-random number in given range
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `min` | `number` | minimum acceptable value |
|
||||
| `max` | `number` | maximum acceptable value |
|
||||
|
||||
#### Returns
|
||||
|
||||
`number`
|
||||
|
||||
number [min; max]
|
||||
|
||||
**`Remarks`**
|
||||
|
||||
Uses Math.random(), which is not cryptographically secure
|
||||
Returns only integers
|
||||
|
||||
#### Defined in
|
||||
|
||||
functions/randomInRange.ts:12
|
||||
|
||||
___
|
||||
|
||||
### removeFromArrayByKeyValue
|
||||
|
||||
▸ **removeFromArrayByKeyValue**\<`T`\>(`array`, `keyValue`): `T`[]
|
||||
|
||||
Removes an object from an array by key value object.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `T` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `array` | `T`[] | array which shall be manipulated with |
|
||||
| `keyValue` | `Partial`\<\{ [K in string \| number \| symbol]: T[K] }\> | key-value object which defines which object shall be removed from the array |
|
||||
|
||||
#### Returns
|
||||
|
||||
`T`[]
|
||||
|
||||
modified array
|
||||
|
||||
**`Remarks`**
|
||||
|
||||
This method doesn't support deep comparements.
|
||||
|
||||
#### Defined in
|
||||
|
||||
functions/removeFromArrayByKeyValue.ts:11
|
||||
|
||||
___
|
||||
|
||||
### removeObjectProperty
|
||||
|
||||
▸ **removeObjectProperty**\<`T`\>(`object`, `key`): `T`
|
||||
|
||||
Removes an object property by provided key
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `T` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `object` | `T` | object which shall be manipulated |
|
||||
| `key` | keyof `T` | key which should be used to remove a property from object |
|
||||
|
||||
#### Returns
|
||||
|
||||
`T`
|
||||
|
||||
new object
|
||||
|
||||
#### Defined in
|
||||
|
||||
functions/removeObjectProperty.ts:9
|
||||
|
||||
___
|
||||
|
||||
### replaceFromArrayByKeyValue
|
||||
|
||||
▸ **replaceFromArrayByKeyValue**\<`T`\>(`array`, `keyValue`, `newObject`): `T`[]
|
||||
|
||||
Replaces an object from an array with key value object search
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `T` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `array` | `T`[] | array which shall be manipulated with |
|
||||
| `keyValue` | `Partial`\<\{ [K in string \| number \| symbol]: T[K] }\> | key-value object which defines which object shall be removed from the array |
|
||||
| `newObject` | `Partial`\<\{ [K in string \| number \| symbol]: T[K] }\> | object or values to replace within the searched object |
|
||||
|
||||
#### Returns
|
||||
|
||||
`T`[]
|
||||
|
||||
modified array
|
||||
|
||||
**`Remarks`**
|
||||
|
||||
This method doesn't support deep comparements.
|
||||
|
||||
#### Defined in
|
||||
|
||||
functions/replaceFromArrayByKeyValue.ts:12
|
||||
Reference in New Issue
Block a user