Compare commits
No commits in common. "development" and "timeToMilliseconds" have entirely different histories.
developmen
...
timeToMill
375
docs/README.md
375
docs/README.md
@ -26,14 +26,10 @@
|
|||||||
- [hasOwn](./docs/modules.md#hasown)
|
- [hasOwn](./docs/modules.md#hasown)
|
||||||
- [hourFloor](./docs/modules.md#hourfloor)
|
- [hourFloor](./docs/modules.md#hourfloor)
|
||||||
- [isEmpty](./docs/modules.md#isempty)
|
- [isEmpty](./docs/modules.md#isempty)
|
||||||
- [kebabCase](./docs/modules.md#kebabcase)
|
|
||||||
- [maybePluralize](./docs/modules.md#maybepluralize)
|
- [maybePluralize](./docs/modules.md#maybepluralize)
|
||||||
- [mergeWithoutNulls](./docs/modules.md#mergewithoutnulls)
|
|
||||||
- [minuteFloor](./docs/modules.md#minutefloor)
|
|
||||||
- [once](./docs/modules.md#once)
|
- [once](./docs/modules.md#once)
|
||||||
- [partOfDay](./docs/modules.md#partofday)
|
- [partOfDay](./docs/modules.md#partofday)
|
||||||
- [throttle](./docs/modules.md#throttle)
|
- [throttle](./docs/modules.md#throttle)
|
||||||
- [timeToMilliseconds](./docs/modules.md#timetomilliseconds)
|
|
||||||
- [toHour](./docs/modules.md#tohour)
|
- [toHour](./docs/modules.md#tohour)
|
||||||
|
|
||||||
## Variables
|
## Variables
|
||||||
@ -54,23 +50,23 @@ LocalStorage.ts:44
|
|||||||
|
|
||||||
Create an array from an Object using specified fields
|
Create an array from an Object using specified fields
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
| Name | Type | Description |
|
|
||||||
| :------ | :------ | :------ |
|
|
||||||
| `jsonObj` | `object` | The Original object |
|
|
||||||
| `wantedFields` | `string`[] | The required fields |
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
`any`[]
|
|
||||||
|
|
||||||
**`Example`**
|
**`Example`**
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
U.arrayFromObj({ a: 1, b: 2 }, ['a', 'b']) // => [1, 2]
|
U.arrayFromObj({ a: 1, b: 2 }, ['a', 'b']) // => [1, 2]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
| Name | Type | Description |
|
||||||
|
| :------ | :------ | :------ |
|
||||||
|
| `jsonObj` | `Object` | The Original object |
|
||||||
|
| `wantedFields` | `string`[] | The required fields |
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`any`[]
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
arrayFromObj.ts:9
|
arrayFromObj.ts:9
|
||||||
@ -83,6 +79,10 @@ ___
|
|||||||
|
|
||||||
Debounce the calling of a function
|
Debounce the calling of a function
|
||||||
|
|
||||||
|
**`Signature`**
|
||||||
|
|
||||||
|
U.debounce(fn, time)
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
@ -94,10 +94,6 @@ Debounce the calling of a function
|
|||||||
|
|
||||||
`Function`
|
`Function`
|
||||||
|
|
||||||
**`Signature`**
|
|
||||||
|
|
||||||
U.debounce(fn, time)
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
debounce.ts:12
|
debounce.ts:12
|
||||||
@ -110,6 +106,16 @@ ___
|
|||||||
|
|
||||||
Calculate the distance between two lat long points
|
Calculate the distance between two lat long points
|
||||||
|
|
||||||
|
**`Signature`**
|
||||||
|
|
||||||
|
U.distance(lat1, long1, lat2, long2)
|
||||||
|
|
||||||
|
**`Example`**
|
||||||
|
|
||||||
|
```ts
|
||||||
|
distance(1, 1, 2, 2) // => 157.22543203805722;
|
||||||
|
```
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type |
|
| Name | Type |
|
||||||
@ -123,16 +129,6 @@ Calculate the distance between two lat long points
|
|||||||
|
|
||||||
`number`
|
`number`
|
||||||
|
|
||||||
**`Signature`**
|
|
||||||
|
|
||||||
U.distance(lat1, long1, lat2, long2)
|
|
||||||
|
|
||||||
**`Example`**
|
|
||||||
|
|
||||||
```ts
|
|
||||||
distance(1, 1, 2, 2) // => 157.22543203805722;
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
distance.ts:16
|
distance.ts:16
|
||||||
@ -141,17 +137,6 @@ distance.ts:16
|
|||||||
|
|
||||||
Calculate the distance between two lat long points
|
Calculate the distance between two lat long points
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
| Name | Type |
|
|
||||||
| :------ | :------ |
|
|
||||||
| `latLong1` | [`LatLong`](./docs/classes/LatLong.md) |
|
|
||||||
| `latLong2` | [`LatLong`](./docs/classes/LatLong.md) |
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
`number`
|
|
||||||
|
|
||||||
**`Signature`**
|
**`Signature`**
|
||||||
|
|
||||||
U.distance(latLong1, latLong2)
|
U.distance(latLong1, latLong2)
|
||||||
@ -164,6 +149,17 @@ const a: U.LatLong = new LatLong(1, 1);
|
|||||||
U.distance(a, b) // => 157.22543203805722
|
U.distance(a, b) // => 157.22543203805722
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
| Name | Type |
|
||||||
|
| :------ | :------ |
|
||||||
|
| `latLong1` | [`LatLong`](./docs/classes/LatLong.md) |
|
||||||
|
| `latLong2` | [`LatLong`](./docs/classes/LatLong.md) |
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`number`
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
distance.ts:33
|
distance.ts:33
|
||||||
@ -172,21 +168,10 @@ ___
|
|||||||
|
|
||||||
### extractFromObj
|
### extractFromObj
|
||||||
|
|
||||||
▸ **extractFromObj**(`jsonObj`, `wantedFields`): `object`
|
▸ **extractFromObj**(`jsonObj`, `wantedFields`): `Object`
|
||||||
|
|
||||||
Extract an object from another object using specific fields
|
Extract an object from another object using specific fields
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
| Name | Type | Description |
|
|
||||||
| :------ | :------ | :------ |
|
|
||||||
| `jsonObj` | `object` | The source object |
|
|
||||||
| `wantedFields` | `string`[] | The required fields |
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
`object`
|
|
||||||
|
|
||||||
**`Signature`**
|
**`Signature`**
|
||||||
|
|
||||||
U.extractFromObj(jsonObj, wantedFields)
|
U.extractFromObj(jsonObj, wantedFields)
|
||||||
@ -197,6 +182,17 @@ U.extractFromObj(jsonObj, wantedFields)
|
|||||||
U.extractFromObj({ a: 1, b: 2 }, ['a']) // => { a: 1 }
|
U.extractFromObj({ a: 1, b: 2 }, ['a']) // => { a: 1 }
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
| Name | Type | Description |
|
||||||
|
| :------ | :------ | :------ |
|
||||||
|
| `jsonObj` | `Object` | The source object |
|
||||||
|
| `wantedFields` | `string`[] | The required fields |
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`Object`
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
extractFromObj.ts:12
|
extractFromObj.ts:12
|
||||||
@ -205,28 +201,28 @@ ___
|
|||||||
|
|
||||||
### get
|
### get
|
||||||
|
|
||||||
▸ **get**(`obj`, `path`, `defaultValue?`): `unknown`
|
▸ **get**(`obj`, `path`, `defaultValue?`): `any`
|
||||||
|
|
||||||
Get the value of an item inside an object
|
Get the value of an item inside an object
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
| Name | Type | Default value | Description |
|
|
||||||
| :------ | :------ | :------ | :------ |
|
|
||||||
| `obj` | `object` | `undefined` | The source object |
|
|
||||||
| `path` | `string` | `undefined` | The path to the object |
|
|
||||||
| `defaultValue` | `unknown` | `undefined` | A default value to be returned |
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
`unknown`
|
|
||||||
|
|
||||||
**`Example`**
|
**`Example`**
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
U.get({ a: 1, b: 2 }, 'b') // => 2
|
U.get({ a: 1, b: 2 }, 'b') // => 2
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
| Name | Type | Default value | Description |
|
||||||
|
| :------ | :------ | :------ | :------ |
|
||||||
|
| `obj` | `Object` | `undefined` | The source object |
|
||||||
|
| `path` | `string` | `undefined` | The path to the object |
|
||||||
|
| `defaultValue` | `any` | `undefined` | A default value to be returned |
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`any`
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
get.ts:10
|
get.ts:10
|
||||||
@ -262,23 +258,23 @@ ___
|
|||||||
|
|
||||||
Check if an object has an property
|
Check if an object has an property
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
| Name | Type | Description |
|
|
||||||
| :------ | :------ | :------ |
|
|
||||||
| `obj` | `object` | The source object |
|
|
||||||
| `prop` | `string` | The required property |
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
`boolean`
|
|
||||||
|
|
||||||
**`Example`**
|
**`Example`**
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
U.hasOwn({bob:'1'}, 'bob') // => true
|
U.hasOwn({bob:'1'}, 'bob') // => true
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
| Name | Type | Description |
|
||||||
|
| :------ | :------ | :------ |
|
||||||
|
| `obj` | `Object` | The source object |
|
||||||
|
| `prop` | `string` | The required property |
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`boolean`
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
hasOwn.ts:12
|
hasOwn.ts:12
|
||||||
@ -291,6 +287,12 @@ ___
|
|||||||
|
|
||||||
Get the hour floor as a Base 32 string
|
Get the hour floor as a Base 32 string
|
||||||
|
|
||||||
|
**`Example`**
|
||||||
|
|
||||||
|
```ts
|
||||||
|
U.hourFloor(1605532173) // => '1fnp540'
|
||||||
|
```
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
@ -301,12 +303,6 @@ Get the hour floor as a Base 32 string
|
|||||||
|
|
||||||
`string`
|
`string`
|
||||||
|
|
||||||
**`Example`**
|
|
||||||
|
|
||||||
```ts
|
|
||||||
U.hourFloor(1605532173) // => '1fnp540'
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
hourFloor.ts:10
|
hourFloor.ts:10
|
||||||
@ -319,16 +315,6 @@ ___
|
|||||||
|
|
||||||
Check if an object is empty
|
Check if an object is empty
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
| Name | Type | Description |
|
|
||||||
| :------ | :------ | :------ |
|
|
||||||
| `obj` | `object` | The object being checked |
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
`boolean`
|
|
||||||
|
|
||||||
**`Example`**
|
**`Example`**
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
@ -336,39 +322,19 @@ U.isEmpty({}) // => true
|
|||||||
U.isEmpty({ bob: true }) // => false
|
U.isEmpty({ bob: true }) // => false
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Defined in
|
|
||||||
|
|
||||||
isEmpty.ts:9
|
|
||||||
|
|
||||||
___
|
|
||||||
|
|
||||||
### kebabCase
|
|
||||||
|
|
||||||
▸ **kebabCase**(`inval`): `string`
|
|
||||||
|
|
||||||
Turn a string into a kebab-case string
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type |
|
| Name | Type | Description |
|
||||||
| :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `inval` | ``null`` \| `string` |
|
| `obj` | `Object` | The object being checked |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`string`
|
`boolean`
|
||||||
|
|
||||||
**`Example`**
|
|
||||||
|
|
||||||
```ts
|
|
||||||
U.kebabCase('test string') // => 'test-string'
|
|
||||||
U.kebabCase('testString') // => 'test-string'
|
|
||||||
U.kebabCase('test_string') // => 'test-string'
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
kebabCase.ts:10
|
isEmpty.ts:9
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@ -378,6 +344,17 @@ ___
|
|||||||
|
|
||||||
Maybe pluralize a count:
|
Maybe pluralize a count:
|
||||||
|
|
||||||
|
**`Signature`**
|
||||||
|
|
||||||
|
U.maybePluralize(number, noun, suffix)
|
||||||
|
|
||||||
|
**`Example`**
|
||||||
|
|
||||||
|
```ts
|
||||||
|
U.maybePluralize(1, 'Bag', 's') // => 1 Bag
|
||||||
|
U.maybePluralize(5, 'Bag', 's') // => 5 Bags
|
||||||
|
```
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Default value | Description |
|
| Name | Type | Default value | Description |
|
||||||
@ -390,90 +367,22 @@ Maybe pluralize a count:
|
|||||||
|
|
||||||
`string`
|
`string`
|
||||||
|
|
||||||
**`Signature`**
|
|
||||||
|
|
||||||
U.maybePluralize(number, noun, suffix)
|
|
||||||
|
|
||||||
**`Example`**
|
|
||||||
|
|
||||||
```ts
|
|
||||||
U.maybePluralize(1, 'Bag', 's') // => 1 Bag
|
|
||||||
U.maybePluralize(5, 'Bag', 's') // => 5 Bags
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
maybePluralize.ts:16
|
maybePluralize.ts:16
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
### mergeWithoutNulls
|
|
||||||
|
|
||||||
▸ **mergeWithoutNulls**(`startingObj`, `newObj`): `object`
|
|
||||||
|
|
||||||
Merge two objects together ignoring null values in the incoming data
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
| Name | Type | Description |
|
|
||||||
| :------ | :------ | :------ |
|
|
||||||
| `startingObj` | `object` | The original source object to be merged into |
|
|
||||||
| `newObj` | `object` | The new incoming data |
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
`object`
|
|
||||||
|
|
||||||
**`Signature`**
|
|
||||||
|
|
||||||
U.mergeWithoutNulls(startingObj, newObj)
|
|
||||||
|
|
||||||
**`Example`**
|
|
||||||
|
|
||||||
```ts
|
|
||||||
U.mergeWithoutNulls({a:1, b:2}, {c:null, d:4}) // => { a:1, b:2, d:4}
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Defined in
|
|
||||||
|
|
||||||
mergeWithoutNulls.ts:11
|
|
||||||
|
|
||||||
___
|
|
||||||
|
|
||||||
### minuteFloor
|
|
||||||
|
|
||||||
▸ **minuteFloor**(`timestamp?`): `string`
|
|
||||||
|
|
||||||
Get the minute floor as a Base 32 string
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
| Name | Type | Description |
|
|
||||||
| :------ | :------ | :------ |
|
|
||||||
| `timestamp?` | ``null`` \| `number` | The timestamp as a number |
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
`string`
|
|
||||||
|
|
||||||
**`Example`**
|
|
||||||
|
|
||||||
```ts
|
|
||||||
U.minuteFloor(1605532173) // => '1fnp540'
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Defined in
|
|
||||||
|
|
||||||
minuteFloor.ts:10
|
|
||||||
|
|
||||||
___
|
|
||||||
|
|
||||||
### once
|
### once
|
||||||
|
|
||||||
▸ **once**(`fn`): `Function`
|
▸ **once**(`fn`): `Function`
|
||||||
|
|
||||||
Trigger a function once and then prevent it from triggering again
|
Trigger a function once and then prevent it from triggering again
|
||||||
|
|
||||||
|
**`Signature`**
|
||||||
|
|
||||||
|
U.once(fn)
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type |
|
| Name | Type |
|
||||||
@ -484,10 +393,6 @@ Trigger a function once and then prevent it from triggering again
|
|||||||
|
|
||||||
`Function`
|
`Function`
|
||||||
|
|
||||||
**`Signature`**
|
|
||||||
|
|
||||||
U.once(fn)
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
once.ts:9
|
once.ts:9
|
||||||
@ -500,6 +405,16 @@ ___
|
|||||||
|
|
||||||
Get a string phrase for the current time of day
|
Get a string phrase for the current time of day
|
||||||
|
|
||||||
|
**`Signature`**
|
||||||
|
|
||||||
|
U.partOfDay(timeString, today)
|
||||||
|
|
||||||
|
**`Example`**
|
||||||
|
|
||||||
|
```ts
|
||||||
|
U.partOfDay('13:00') // => 'Afternoon'
|
||||||
|
```
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Default value |
|
| Name | Type | Default value |
|
||||||
@ -511,16 +426,6 @@ Get a string phrase for the current time of day
|
|||||||
|
|
||||||
`string`
|
`string`
|
||||||
|
|
||||||
**`Signature`**
|
|
||||||
|
|
||||||
U.partOfDay(timeString, today)
|
|
||||||
|
|
||||||
**`Example`**
|
|
||||||
|
|
||||||
```ts
|
|
||||||
U.partOfDay('13:00') // => 'Afternoon'
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
partOfDay.ts:11
|
partOfDay.ts:11
|
||||||
@ -533,6 +438,10 @@ ___
|
|||||||
|
|
||||||
Throttle the calling of a function
|
Throttle the calling of a function
|
||||||
|
|
||||||
|
**`Signature`**
|
||||||
|
|
||||||
|
U.throttle(callback, limit)
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type |
|
| Name | Type |
|
||||||
@ -544,58 +453,28 @@ Throttle the calling of a function
|
|||||||
|
|
||||||
`Function`
|
`Function`
|
||||||
|
|
||||||
**`Signature`**
|
|
||||||
|
|
||||||
U.throttle(callback, limit)
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
throttle.ts:10
|
throttle.ts:10
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
### timeToMilliseconds
|
|
||||||
|
|
||||||
▸ **timeToMilliseconds**(`inTime?`): `number`
|
|
||||||
|
|
||||||
Get milliseconds from a string of time sections
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
| Name | Type | Default value | Description |
|
|
||||||
| :------ | :------ | :------ | :------ |
|
|
||||||
| `inTime` | `string` | `''` | * |
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
`number`
|
|
||||||
|
|
||||||
**`Signature`**
|
|
||||||
|
|
||||||
U.timeToMilliseconds(inTime)
|
|
||||||
|
|
||||||
**`Example`**
|
|
||||||
|
|
||||||
```ts
|
|
||||||
U.timeToMilliseconds('1s') // => 1000
|
|
||||||
U.timeToMilliseconds('1min') // => 60000
|
|
||||||
U.timeToMilliseconds('1 weeks') // => 604800000
|
|
||||||
U.timeToMilliseconds('5y2w30d14h30m10s') // => 161641810000
|
|
||||||
U.timeToMilliseconds('1 hour and 5 seconds') // => 3605000
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Defined in
|
|
||||||
|
|
||||||
timeToMilliseconds.ts:31
|
|
||||||
|
|
||||||
___
|
|
||||||
|
|
||||||
### toHour
|
### toHour
|
||||||
|
|
||||||
▸ **toHour**(`currentTimsestamp`, `extra?`): `number`
|
▸ **toHour**(`currentTimsestamp`, `extra?`): `number`
|
||||||
|
|
||||||
Return the number of Milliseconds to the hour for the supplied timestamp
|
Return the number of Milliseconds to the hour for the supplied timestamp
|
||||||
|
|
||||||
|
**`Signature`**
|
||||||
|
|
||||||
|
U.toHour(currentTimsestamp, extra)
|
||||||
|
|
||||||
|
**`Example`**
|
||||||
|
|
||||||
|
```ts
|
||||||
|
U.toHour('13:00') // => 1605532173
|
||||||
|
```
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Default value |
|
| Name | Type | Default value |
|
||||||
@ -609,16 +488,6 @@ Return the number of Milliseconds to the hour for the supplied timestamp
|
|||||||
|
|
||||||
*
|
*
|
||||||
|
|
||||||
**`Signature`**
|
|
||||||
|
|
||||||
U.toHour(currentTimsestamp, extra)
|
|
||||||
|
|
||||||
**`Example`**
|
|
||||||
|
|
||||||
```ts
|
|
||||||
U.toHour('13:00') // => 1605532173
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
toHour.ts:12
|
toHour.ts:12
|
||||||
|
@ -45,7 +45,7 @@ limitedArray.ts:10
|
|||||||
|
|
||||||
### \_array
|
### \_array
|
||||||
|
|
||||||
• **\_array**: `unknown`[]
|
• **\_array**: `any`[]
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ Bulk add an array to the array
|
|||||||
|
|
||||||
| Name | Type |
|
| Name | Type |
|
||||||
| :------ | :------ |
|
| :------ | :------ |
|
||||||
| `items` | `unknown`[] |
|
| `items` | `any`[] |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
@ -87,13 +87,13 @@ ___
|
|||||||
|
|
||||||
### get
|
### get
|
||||||
|
|
||||||
▸ **get**(): `unknown`[]
|
▸ **get**(): `any`[]
|
||||||
|
|
||||||
Return the items within the array
|
Return the items within the array
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`unknown`[]
|
`any`[]
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
@ -149,7 +149,7 @@ Add items to the end of an array
|
|||||||
|
|
||||||
| Name | Type |
|
| Name | Type |
|
||||||
| :------ | :------ |
|
| :------ | :------ |
|
||||||
| `item` | `unknown` |
|
| `item` | `any` |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
@ -163,13 +163,13 @@ ___
|
|||||||
|
|
||||||
### shift
|
### shift
|
||||||
|
|
||||||
▸ **shift**(): `unknown`
|
▸ **shift**(): `any`
|
||||||
|
|
||||||
Remove an item from the beginning of an array
|
Remove an item from the beginning of an array
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`unknown`
|
`any`
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
|
375
docs/modules.md
375
docs/modules.md
@ -24,14 +24,10 @@
|
|||||||
- [hasOwn](./docs/modules.md#hasown)
|
- [hasOwn](./docs/modules.md#hasown)
|
||||||
- [hourFloor](./docs/modules.md#hourfloor)
|
- [hourFloor](./docs/modules.md#hourfloor)
|
||||||
- [isEmpty](./docs/modules.md#isempty)
|
- [isEmpty](./docs/modules.md#isempty)
|
||||||
- [kebabCase](./docs/modules.md#kebabcase)
|
|
||||||
- [maybePluralize](./docs/modules.md#maybepluralize)
|
- [maybePluralize](./docs/modules.md#maybepluralize)
|
||||||
- [mergeWithoutNulls](./docs/modules.md#mergewithoutnulls)
|
|
||||||
- [minuteFloor](./docs/modules.md#minutefloor)
|
|
||||||
- [once](./docs/modules.md#once)
|
- [once](./docs/modules.md#once)
|
||||||
- [partOfDay](./docs/modules.md#partofday)
|
- [partOfDay](./docs/modules.md#partofday)
|
||||||
- [throttle](./docs/modules.md#throttle)
|
- [throttle](./docs/modules.md#throttle)
|
||||||
- [timeToMilliseconds](./docs/modules.md#timetomilliseconds)
|
|
||||||
- [toHour](./docs/modules.md#tohour)
|
- [toHour](./docs/modules.md#tohour)
|
||||||
|
|
||||||
## Variables
|
## Variables
|
||||||
@ -52,23 +48,23 @@ LocalStorage.ts:44
|
|||||||
|
|
||||||
Create an array from an Object using specified fields
|
Create an array from an Object using specified fields
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
| Name | Type | Description |
|
|
||||||
| :------ | :------ | :------ |
|
|
||||||
| `jsonObj` | `object` | The Original object |
|
|
||||||
| `wantedFields` | `string`[] | The required fields |
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
`any`[]
|
|
||||||
|
|
||||||
**`Example`**
|
**`Example`**
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
U.arrayFromObj({ a: 1, b: 2 }, ['a', 'b']) // => [1, 2]
|
U.arrayFromObj({ a: 1, b: 2 }, ['a', 'b']) // => [1, 2]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
| Name | Type | Description |
|
||||||
|
| :------ | :------ | :------ |
|
||||||
|
| `jsonObj` | `Object` | The Original object |
|
||||||
|
| `wantedFields` | `string`[] | The required fields |
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`any`[]
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
arrayFromObj.ts:9
|
arrayFromObj.ts:9
|
||||||
@ -81,6 +77,10 @@ ___
|
|||||||
|
|
||||||
Debounce the calling of a function
|
Debounce the calling of a function
|
||||||
|
|
||||||
|
**`Signature`**
|
||||||
|
|
||||||
|
U.debounce(fn, time)
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
@ -92,10 +92,6 @@ Debounce the calling of a function
|
|||||||
|
|
||||||
`Function`
|
`Function`
|
||||||
|
|
||||||
**`Signature`**
|
|
||||||
|
|
||||||
U.debounce(fn, time)
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
debounce.ts:12
|
debounce.ts:12
|
||||||
@ -108,6 +104,16 @@ ___
|
|||||||
|
|
||||||
Calculate the distance between two lat long points
|
Calculate the distance between two lat long points
|
||||||
|
|
||||||
|
**`Signature`**
|
||||||
|
|
||||||
|
U.distance(lat1, long1, lat2, long2)
|
||||||
|
|
||||||
|
**`Example`**
|
||||||
|
|
||||||
|
```ts
|
||||||
|
distance(1, 1, 2, 2) // => 157.22543203805722;
|
||||||
|
```
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type |
|
| Name | Type |
|
||||||
@ -121,16 +127,6 @@ Calculate the distance between two lat long points
|
|||||||
|
|
||||||
`number`
|
`number`
|
||||||
|
|
||||||
**`Signature`**
|
|
||||||
|
|
||||||
U.distance(lat1, long1, lat2, long2)
|
|
||||||
|
|
||||||
**`Example`**
|
|
||||||
|
|
||||||
```ts
|
|
||||||
distance(1, 1, 2, 2) // => 157.22543203805722;
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
distance.ts:16
|
distance.ts:16
|
||||||
@ -139,17 +135,6 @@ distance.ts:16
|
|||||||
|
|
||||||
Calculate the distance between two lat long points
|
Calculate the distance between two lat long points
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
| Name | Type |
|
|
||||||
| :------ | :------ |
|
|
||||||
| `latLong1` | [`LatLong`](./docs/classes/LatLong.md) |
|
|
||||||
| `latLong2` | [`LatLong`](./docs/classes/LatLong.md) |
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
`number`
|
|
||||||
|
|
||||||
**`Signature`**
|
**`Signature`**
|
||||||
|
|
||||||
U.distance(latLong1, latLong2)
|
U.distance(latLong1, latLong2)
|
||||||
@ -162,6 +147,17 @@ const a: U.LatLong = new LatLong(1, 1);
|
|||||||
U.distance(a, b) // => 157.22543203805722
|
U.distance(a, b) // => 157.22543203805722
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
| Name | Type |
|
||||||
|
| :------ | :------ |
|
||||||
|
| `latLong1` | [`LatLong`](./docs/classes/LatLong.md) |
|
||||||
|
| `latLong2` | [`LatLong`](./docs/classes/LatLong.md) |
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`number`
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
distance.ts:33
|
distance.ts:33
|
||||||
@ -170,21 +166,10 @@ ___
|
|||||||
|
|
||||||
### extractFromObj
|
### extractFromObj
|
||||||
|
|
||||||
▸ **extractFromObj**(`jsonObj`, `wantedFields`): `object`
|
▸ **extractFromObj**(`jsonObj`, `wantedFields`): `Object`
|
||||||
|
|
||||||
Extract an object from another object using specific fields
|
Extract an object from another object using specific fields
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
| Name | Type | Description |
|
|
||||||
| :------ | :------ | :------ |
|
|
||||||
| `jsonObj` | `object` | The source object |
|
|
||||||
| `wantedFields` | `string`[] | The required fields |
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
`object`
|
|
||||||
|
|
||||||
**`Signature`**
|
**`Signature`**
|
||||||
|
|
||||||
U.extractFromObj(jsonObj, wantedFields)
|
U.extractFromObj(jsonObj, wantedFields)
|
||||||
@ -195,6 +180,17 @@ U.extractFromObj(jsonObj, wantedFields)
|
|||||||
U.extractFromObj({ a: 1, b: 2 }, ['a']) // => { a: 1 }
|
U.extractFromObj({ a: 1, b: 2 }, ['a']) // => { a: 1 }
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
| Name | Type | Description |
|
||||||
|
| :------ | :------ | :------ |
|
||||||
|
| `jsonObj` | `Object` | The source object |
|
||||||
|
| `wantedFields` | `string`[] | The required fields |
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`Object`
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
extractFromObj.ts:12
|
extractFromObj.ts:12
|
||||||
@ -203,28 +199,28 @@ ___
|
|||||||
|
|
||||||
### get
|
### get
|
||||||
|
|
||||||
▸ **get**(`obj`, `path`, `defaultValue?`): `unknown`
|
▸ **get**(`obj`, `path`, `defaultValue?`): `any`
|
||||||
|
|
||||||
Get the value of an item inside an object
|
Get the value of an item inside an object
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
| Name | Type | Default value | Description |
|
|
||||||
| :------ | :------ | :------ | :------ |
|
|
||||||
| `obj` | `object` | `undefined` | The source object |
|
|
||||||
| `path` | `string` | `undefined` | The path to the object |
|
|
||||||
| `defaultValue` | `unknown` | `undefined` | A default value to be returned |
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
`unknown`
|
|
||||||
|
|
||||||
**`Example`**
|
**`Example`**
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
U.get({ a: 1, b: 2 }, 'b') // => 2
|
U.get({ a: 1, b: 2 }, 'b') // => 2
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
| Name | Type | Default value | Description |
|
||||||
|
| :------ | :------ | :------ | :------ |
|
||||||
|
| `obj` | `Object` | `undefined` | The source object |
|
||||||
|
| `path` | `string` | `undefined` | The path to the object |
|
||||||
|
| `defaultValue` | `any` | `undefined` | A default value to be returned |
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`any`
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
get.ts:10
|
get.ts:10
|
||||||
@ -260,23 +256,23 @@ ___
|
|||||||
|
|
||||||
Check if an object has an property
|
Check if an object has an property
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
| Name | Type | Description |
|
|
||||||
| :------ | :------ | :------ |
|
|
||||||
| `obj` | `object` | The source object |
|
|
||||||
| `prop` | `string` | The required property |
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
`boolean`
|
|
||||||
|
|
||||||
**`Example`**
|
**`Example`**
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
U.hasOwn({bob:'1'}, 'bob') // => true
|
U.hasOwn({bob:'1'}, 'bob') // => true
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
| Name | Type | Description |
|
||||||
|
| :------ | :------ | :------ |
|
||||||
|
| `obj` | `Object` | The source object |
|
||||||
|
| `prop` | `string` | The required property |
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`boolean`
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
hasOwn.ts:12
|
hasOwn.ts:12
|
||||||
@ -289,6 +285,12 @@ ___
|
|||||||
|
|
||||||
Get the hour floor as a Base 32 string
|
Get the hour floor as a Base 32 string
|
||||||
|
|
||||||
|
**`Example`**
|
||||||
|
|
||||||
|
```ts
|
||||||
|
U.hourFloor(1605532173) // => '1fnp540'
|
||||||
|
```
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
@ -299,12 +301,6 @@ Get the hour floor as a Base 32 string
|
|||||||
|
|
||||||
`string`
|
`string`
|
||||||
|
|
||||||
**`Example`**
|
|
||||||
|
|
||||||
```ts
|
|
||||||
U.hourFloor(1605532173) // => '1fnp540'
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
hourFloor.ts:10
|
hourFloor.ts:10
|
||||||
@ -317,16 +313,6 @@ ___
|
|||||||
|
|
||||||
Check if an object is empty
|
Check if an object is empty
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
| Name | Type | Description |
|
|
||||||
| :------ | :------ | :------ |
|
|
||||||
| `obj` | `object` | The object being checked |
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
`boolean`
|
|
||||||
|
|
||||||
**`Example`**
|
**`Example`**
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
@ -334,39 +320,19 @@ U.isEmpty({}) // => true
|
|||||||
U.isEmpty({ bob: true }) // => false
|
U.isEmpty({ bob: true }) // => false
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Defined in
|
|
||||||
|
|
||||||
isEmpty.ts:9
|
|
||||||
|
|
||||||
___
|
|
||||||
|
|
||||||
### kebabCase
|
|
||||||
|
|
||||||
▸ **kebabCase**(`inval`): `string`
|
|
||||||
|
|
||||||
Turn a string into a kebab-case string
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type |
|
| Name | Type | Description |
|
||||||
| :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `inval` | ``null`` \| `string` |
|
| `obj` | `Object` | The object being checked |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`string`
|
`boolean`
|
||||||
|
|
||||||
**`Example`**
|
|
||||||
|
|
||||||
```ts
|
|
||||||
U.kebabCase('test string') // => 'test-string'
|
|
||||||
U.kebabCase('testString') // => 'test-string'
|
|
||||||
U.kebabCase('test_string') // => 'test-string'
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
kebabCase.ts:10
|
isEmpty.ts:9
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@ -376,6 +342,17 @@ ___
|
|||||||
|
|
||||||
Maybe pluralize a count:
|
Maybe pluralize a count:
|
||||||
|
|
||||||
|
**`Signature`**
|
||||||
|
|
||||||
|
U.maybePluralize(number, noun, suffix)
|
||||||
|
|
||||||
|
**`Example`**
|
||||||
|
|
||||||
|
```ts
|
||||||
|
U.maybePluralize(1, 'Bag', 's') // => 1 Bag
|
||||||
|
U.maybePluralize(5, 'Bag', 's') // => 5 Bags
|
||||||
|
```
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Default value | Description |
|
| Name | Type | Default value | Description |
|
||||||
@ -388,90 +365,22 @@ Maybe pluralize a count:
|
|||||||
|
|
||||||
`string`
|
`string`
|
||||||
|
|
||||||
**`Signature`**
|
|
||||||
|
|
||||||
U.maybePluralize(number, noun, suffix)
|
|
||||||
|
|
||||||
**`Example`**
|
|
||||||
|
|
||||||
```ts
|
|
||||||
U.maybePluralize(1, 'Bag', 's') // => 1 Bag
|
|
||||||
U.maybePluralize(5, 'Bag', 's') // => 5 Bags
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
maybePluralize.ts:16
|
maybePluralize.ts:16
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
### mergeWithoutNulls
|
|
||||||
|
|
||||||
▸ **mergeWithoutNulls**(`startingObj`, `newObj`): `object`
|
|
||||||
|
|
||||||
Merge two objects together ignoring null values in the incoming data
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
| Name | Type | Description |
|
|
||||||
| :------ | :------ | :------ |
|
|
||||||
| `startingObj` | `object` | The original source object to be merged into |
|
|
||||||
| `newObj` | `object` | The new incoming data |
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
`object`
|
|
||||||
|
|
||||||
**`Signature`**
|
|
||||||
|
|
||||||
U.mergeWithoutNulls(startingObj, newObj)
|
|
||||||
|
|
||||||
**`Example`**
|
|
||||||
|
|
||||||
```ts
|
|
||||||
U.mergeWithoutNulls({a:1, b:2}, {c:null, d:4}) // => { a:1, b:2, d:4}
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Defined in
|
|
||||||
|
|
||||||
mergeWithoutNulls.ts:11
|
|
||||||
|
|
||||||
___
|
|
||||||
|
|
||||||
### minuteFloor
|
|
||||||
|
|
||||||
▸ **minuteFloor**(`timestamp?`): `string`
|
|
||||||
|
|
||||||
Get the minute floor as a Base 32 string
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
| Name | Type | Description |
|
|
||||||
| :------ | :------ | :------ |
|
|
||||||
| `timestamp?` | ``null`` \| `number` | The timestamp as a number |
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
`string`
|
|
||||||
|
|
||||||
**`Example`**
|
|
||||||
|
|
||||||
```ts
|
|
||||||
U.minuteFloor(1605532173) // => '1fnp540'
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Defined in
|
|
||||||
|
|
||||||
minuteFloor.ts:10
|
|
||||||
|
|
||||||
___
|
|
||||||
|
|
||||||
### once
|
### once
|
||||||
|
|
||||||
▸ **once**(`fn`): `Function`
|
▸ **once**(`fn`): `Function`
|
||||||
|
|
||||||
Trigger a function once and then prevent it from triggering again
|
Trigger a function once and then prevent it from triggering again
|
||||||
|
|
||||||
|
**`Signature`**
|
||||||
|
|
||||||
|
U.once(fn)
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type |
|
| Name | Type |
|
||||||
@ -482,10 +391,6 @@ Trigger a function once and then prevent it from triggering again
|
|||||||
|
|
||||||
`Function`
|
`Function`
|
||||||
|
|
||||||
**`Signature`**
|
|
||||||
|
|
||||||
U.once(fn)
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
once.ts:9
|
once.ts:9
|
||||||
@ -498,6 +403,16 @@ ___
|
|||||||
|
|
||||||
Get a string phrase for the current time of day
|
Get a string phrase for the current time of day
|
||||||
|
|
||||||
|
**`Signature`**
|
||||||
|
|
||||||
|
U.partOfDay(timeString, today)
|
||||||
|
|
||||||
|
**`Example`**
|
||||||
|
|
||||||
|
```ts
|
||||||
|
U.partOfDay('13:00') // => 'Afternoon'
|
||||||
|
```
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Default value |
|
| Name | Type | Default value |
|
||||||
@ -509,16 +424,6 @@ Get a string phrase for the current time of day
|
|||||||
|
|
||||||
`string`
|
`string`
|
||||||
|
|
||||||
**`Signature`**
|
|
||||||
|
|
||||||
U.partOfDay(timeString, today)
|
|
||||||
|
|
||||||
**`Example`**
|
|
||||||
|
|
||||||
```ts
|
|
||||||
U.partOfDay('13:00') // => 'Afternoon'
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
partOfDay.ts:11
|
partOfDay.ts:11
|
||||||
@ -531,6 +436,10 @@ ___
|
|||||||
|
|
||||||
Throttle the calling of a function
|
Throttle the calling of a function
|
||||||
|
|
||||||
|
**`Signature`**
|
||||||
|
|
||||||
|
U.throttle(callback, limit)
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type |
|
| Name | Type |
|
||||||
@ -542,58 +451,28 @@ Throttle the calling of a function
|
|||||||
|
|
||||||
`Function`
|
`Function`
|
||||||
|
|
||||||
**`Signature`**
|
|
||||||
|
|
||||||
U.throttle(callback, limit)
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
throttle.ts:10
|
throttle.ts:10
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
### timeToMilliseconds
|
|
||||||
|
|
||||||
▸ **timeToMilliseconds**(`inTime?`): `number`
|
|
||||||
|
|
||||||
Get milliseconds from a string of time sections
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
| Name | Type | Default value | Description |
|
|
||||||
| :------ | :------ | :------ | :------ |
|
|
||||||
| `inTime` | `string` | `''` | * |
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
`number`
|
|
||||||
|
|
||||||
**`Signature`**
|
|
||||||
|
|
||||||
U.timeToMilliseconds(inTime)
|
|
||||||
|
|
||||||
**`Example`**
|
|
||||||
|
|
||||||
```ts
|
|
||||||
U.timeToMilliseconds('1s') // => 1000
|
|
||||||
U.timeToMilliseconds('1min') // => 60000
|
|
||||||
U.timeToMilliseconds('1 weeks') // => 604800000
|
|
||||||
U.timeToMilliseconds('5y2w30d14h30m10s') // => 161641810000
|
|
||||||
U.timeToMilliseconds('1 hour and 5 seconds') // => 3605000
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Defined in
|
|
||||||
|
|
||||||
timeToMilliseconds.ts:31
|
|
||||||
|
|
||||||
___
|
|
||||||
|
|
||||||
### toHour
|
### toHour
|
||||||
|
|
||||||
▸ **toHour**(`currentTimsestamp`, `extra?`): `number`
|
▸ **toHour**(`currentTimsestamp`, `extra?`): `number`
|
||||||
|
|
||||||
Return the number of Milliseconds to the hour for the supplied timestamp
|
Return the number of Milliseconds to the hour for the supplied timestamp
|
||||||
|
|
||||||
|
**`Signature`**
|
||||||
|
|
||||||
|
U.toHour(currentTimsestamp, extra)
|
||||||
|
|
||||||
|
**`Example`**
|
||||||
|
|
||||||
|
```ts
|
||||||
|
U.toHour('13:00') // => 1605532173
|
||||||
|
```
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Default value |
|
| Name | Type | Default value |
|
||||||
@ -607,16 +486,6 @@ Return the number of Milliseconds to the hour for the supplied timestamp
|
|||||||
|
|
||||||
*
|
*
|
||||||
|
|
||||||
**`Signature`**
|
|
||||||
|
|
||||||
U.toHour(currentTimsestamp, extra)
|
|
||||||
|
|
||||||
**`Example`**
|
|
||||||
|
|
||||||
```ts
|
|
||||||
U.toHour('13:00') // => 1605532173
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
toHour.ts:12
|
toHour.ts:12
|
||||||
|
5378
package-lock.json
generated
5378
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
26
package.json
26
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@rakh/utils",
|
"name": "@rakh/utils",
|
||||||
"version": "2.0.22",
|
"version": "2.0.16",
|
||||||
"main": "dist/commonjs/index.js",
|
"main": "dist/commonjs/index.js",
|
||||||
"types": "dist/commonjs/index.d.ts",
|
"types": "dist/commonjs/index.d.ts",
|
||||||
"module": "dist/es/index.js",
|
"module": "dist/es/index.js",
|
||||||
@ -35,22 +35,22 @@
|
|||||||
"author": "Martin Donnelly",
|
"author": "Martin Donnelly",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^29.5.5",
|
"@types/jest": "^29.5.0",
|
||||||
"@types/sinon": "^10.0.18",
|
"@types/sinon": "^10.0.13",
|
||||||
"@typescript-eslint/eslint-plugin": "^6.7.4",
|
"@typescript-eslint/eslint-plugin": "^5.59.1",
|
||||||
"@typescript-eslint/parser": "^6.7.4",
|
"@typescript-eslint/parser": "^5.59.1",
|
||||||
"eslint": "^8.39.0",
|
"eslint": "^8.39.0",
|
||||||
"grunt": "^1.6.1",
|
"grunt": "^1.6.1",
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.5.0",
|
||||||
"marked": "^9.0.3",
|
"marked": "^4.3.0",
|
||||||
"prettier": "^3.0.3",
|
"prettier": "^2.8.7",
|
||||||
"save": "^2.9.0",
|
"save": "^2.9.0",
|
||||||
"sinon": "^16.0.0",
|
"sinon": "^15.0.3",
|
||||||
"ts-jest": "^29.1.1",
|
"ts-jest": "^29.1.0",
|
||||||
"ts-node": "^10.9.1",
|
"ts-node": "^10.9.1",
|
||||||
"typedoc": "^0.25.1",
|
"typedoc": "^0.23.28",
|
||||||
"typedoc-plugin-markdown": "^3.16.0",
|
"typedoc-plugin-markdown": "^3.14.0",
|
||||||
"typescript": "^5.2.2",
|
"typescript": "^5.0.3",
|
||||||
"vik": "^0.4.0"
|
"vik": "^0.4.0"
|
||||||
},
|
},
|
||||||
"description": "",
|
"description": "",
|
||||||
|
375
readme.MD
375
readme.MD
@ -24,14 +24,10 @@
|
|||||||
- [hasOwn](./docs/modules.md#hasown)
|
- [hasOwn](./docs/modules.md#hasown)
|
||||||
- [hourFloor](./docs/modules.md#hourfloor)
|
- [hourFloor](./docs/modules.md#hourfloor)
|
||||||
- [isEmpty](./docs/modules.md#isempty)
|
- [isEmpty](./docs/modules.md#isempty)
|
||||||
- [kebabCase](./docs/modules.md#kebabcase)
|
|
||||||
- [maybePluralize](./docs/modules.md#maybepluralize)
|
- [maybePluralize](./docs/modules.md#maybepluralize)
|
||||||
- [mergeWithoutNulls](./docs/modules.md#mergewithoutnulls)
|
|
||||||
- [minuteFloor](./docs/modules.md#minutefloor)
|
|
||||||
- [once](./docs/modules.md#once)
|
- [once](./docs/modules.md#once)
|
||||||
- [partOfDay](./docs/modules.md#partofday)
|
- [partOfDay](./docs/modules.md#partofday)
|
||||||
- [throttle](./docs/modules.md#throttle)
|
- [throttle](./docs/modules.md#throttle)
|
||||||
- [timeToMilliseconds](./docs/modules.md#timetomilliseconds)
|
|
||||||
- [toHour](./docs/modules.md#tohour)
|
- [toHour](./docs/modules.md#tohour)
|
||||||
|
|
||||||
## Variables
|
## Variables
|
||||||
@ -52,23 +48,23 @@ LocalStorage.ts:44
|
|||||||
|
|
||||||
Create an array from an Object using specified fields
|
Create an array from an Object using specified fields
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
| Name | Type | Description |
|
|
||||||
| :------ | :------ | :------ |
|
|
||||||
| `jsonObj` | `object` | The Original object |
|
|
||||||
| `wantedFields` | `string`[] | The required fields |
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
`any`[]
|
|
||||||
|
|
||||||
**`Example`**
|
**`Example`**
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
U.arrayFromObj({ a: 1, b: 2 }, ['a', 'b']) // => [1, 2]
|
U.arrayFromObj({ a: 1, b: 2 }, ['a', 'b']) // => [1, 2]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
| Name | Type | Description |
|
||||||
|
| :------ | :------ | :------ |
|
||||||
|
| `jsonObj` | `Object` | The Original object |
|
||||||
|
| `wantedFields` | `string`[] | The required fields |
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`any`[]
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
arrayFromObj.ts:9
|
arrayFromObj.ts:9
|
||||||
@ -81,6 +77,10 @@ ___
|
|||||||
|
|
||||||
Debounce the calling of a function
|
Debounce the calling of a function
|
||||||
|
|
||||||
|
**`Signature`**
|
||||||
|
|
||||||
|
U.debounce(fn, time)
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
@ -92,10 +92,6 @@ Debounce the calling of a function
|
|||||||
|
|
||||||
`Function`
|
`Function`
|
||||||
|
|
||||||
**`Signature`**
|
|
||||||
|
|
||||||
U.debounce(fn, time)
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
debounce.ts:12
|
debounce.ts:12
|
||||||
@ -108,6 +104,16 @@ ___
|
|||||||
|
|
||||||
Calculate the distance between two lat long points
|
Calculate the distance between two lat long points
|
||||||
|
|
||||||
|
**`Signature`**
|
||||||
|
|
||||||
|
U.distance(lat1, long1, lat2, long2)
|
||||||
|
|
||||||
|
**`Example`**
|
||||||
|
|
||||||
|
```ts
|
||||||
|
distance(1, 1, 2, 2) // => 157.22543203805722;
|
||||||
|
```
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type |
|
| Name | Type |
|
||||||
@ -121,16 +127,6 @@ Calculate the distance between two lat long points
|
|||||||
|
|
||||||
`number`
|
`number`
|
||||||
|
|
||||||
**`Signature`**
|
|
||||||
|
|
||||||
U.distance(lat1, long1, lat2, long2)
|
|
||||||
|
|
||||||
**`Example`**
|
|
||||||
|
|
||||||
```ts
|
|
||||||
distance(1, 1, 2, 2) // => 157.22543203805722;
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
distance.ts:16
|
distance.ts:16
|
||||||
@ -139,17 +135,6 @@ distance.ts:16
|
|||||||
|
|
||||||
Calculate the distance between two lat long points
|
Calculate the distance between two lat long points
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
| Name | Type |
|
|
||||||
| :------ | :------ |
|
|
||||||
| `latLong1` | [`LatLong`](./docs/classes/LatLong.md) |
|
|
||||||
| `latLong2` | [`LatLong`](./docs/classes/LatLong.md) |
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
`number`
|
|
||||||
|
|
||||||
**`Signature`**
|
**`Signature`**
|
||||||
|
|
||||||
U.distance(latLong1, latLong2)
|
U.distance(latLong1, latLong2)
|
||||||
@ -162,6 +147,17 @@ const a: U.LatLong = new LatLong(1, 1);
|
|||||||
U.distance(a, b) // => 157.22543203805722
|
U.distance(a, b) // => 157.22543203805722
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
| Name | Type |
|
||||||
|
| :------ | :------ |
|
||||||
|
| `latLong1` | [`LatLong`](./docs/classes/LatLong.md) |
|
||||||
|
| `latLong2` | [`LatLong`](./docs/classes/LatLong.md) |
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`number`
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
distance.ts:33
|
distance.ts:33
|
||||||
@ -170,21 +166,10 @@ ___
|
|||||||
|
|
||||||
### extractFromObj
|
### extractFromObj
|
||||||
|
|
||||||
▸ **extractFromObj**(`jsonObj`, `wantedFields`): `object`
|
▸ **extractFromObj**(`jsonObj`, `wantedFields`): `Object`
|
||||||
|
|
||||||
Extract an object from another object using specific fields
|
Extract an object from another object using specific fields
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
| Name | Type | Description |
|
|
||||||
| :------ | :------ | :------ |
|
|
||||||
| `jsonObj` | `object` | The source object |
|
|
||||||
| `wantedFields` | `string`[] | The required fields |
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
`object`
|
|
||||||
|
|
||||||
**`Signature`**
|
**`Signature`**
|
||||||
|
|
||||||
U.extractFromObj(jsonObj, wantedFields)
|
U.extractFromObj(jsonObj, wantedFields)
|
||||||
@ -195,6 +180,17 @@ U.extractFromObj(jsonObj, wantedFields)
|
|||||||
U.extractFromObj({ a: 1, b: 2 }, ['a']) // => { a: 1 }
|
U.extractFromObj({ a: 1, b: 2 }, ['a']) // => { a: 1 }
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
| Name | Type | Description |
|
||||||
|
| :------ | :------ | :------ |
|
||||||
|
| `jsonObj` | `Object` | The source object |
|
||||||
|
| `wantedFields` | `string`[] | The required fields |
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`Object`
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
extractFromObj.ts:12
|
extractFromObj.ts:12
|
||||||
@ -203,28 +199,28 @@ ___
|
|||||||
|
|
||||||
### get
|
### get
|
||||||
|
|
||||||
▸ **get**(`obj`, `path`, `defaultValue?`): `unknown`
|
▸ **get**(`obj`, `path`, `defaultValue?`): `any`
|
||||||
|
|
||||||
Get the value of an item inside an object
|
Get the value of an item inside an object
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
| Name | Type | Default value | Description |
|
|
||||||
| :------ | :------ | :------ | :------ |
|
|
||||||
| `obj` | `object` | `undefined` | The source object |
|
|
||||||
| `path` | `string` | `undefined` | The path to the object |
|
|
||||||
| `defaultValue` | `unknown` | `undefined` | A default value to be returned |
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
`unknown`
|
|
||||||
|
|
||||||
**`Example`**
|
**`Example`**
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
U.get({ a: 1, b: 2 }, 'b') // => 2
|
U.get({ a: 1, b: 2 }, 'b') // => 2
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
| Name | Type | Default value | Description |
|
||||||
|
| :------ | :------ | :------ | :------ |
|
||||||
|
| `obj` | `Object` | `undefined` | The source object |
|
||||||
|
| `path` | `string` | `undefined` | The path to the object |
|
||||||
|
| `defaultValue` | `any` | `undefined` | A default value to be returned |
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`any`
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
get.ts:10
|
get.ts:10
|
||||||
@ -260,23 +256,23 @@ ___
|
|||||||
|
|
||||||
Check if an object has an property
|
Check if an object has an property
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
| Name | Type | Description |
|
|
||||||
| :------ | :------ | :------ |
|
|
||||||
| `obj` | `object` | The source object |
|
|
||||||
| `prop` | `string` | The required property |
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
`boolean`
|
|
||||||
|
|
||||||
**`Example`**
|
**`Example`**
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
U.hasOwn({bob:'1'}, 'bob') // => true
|
U.hasOwn({bob:'1'}, 'bob') // => true
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
| Name | Type | Description |
|
||||||
|
| :------ | :------ | :------ |
|
||||||
|
| `obj` | `Object` | The source object |
|
||||||
|
| `prop` | `string` | The required property |
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`boolean`
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
hasOwn.ts:12
|
hasOwn.ts:12
|
||||||
@ -289,6 +285,12 @@ ___
|
|||||||
|
|
||||||
Get the hour floor as a Base 32 string
|
Get the hour floor as a Base 32 string
|
||||||
|
|
||||||
|
**`Example`**
|
||||||
|
|
||||||
|
```ts
|
||||||
|
U.hourFloor(1605532173) // => '1fnp540'
|
||||||
|
```
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
@ -299,12 +301,6 @@ Get the hour floor as a Base 32 string
|
|||||||
|
|
||||||
`string`
|
`string`
|
||||||
|
|
||||||
**`Example`**
|
|
||||||
|
|
||||||
```ts
|
|
||||||
U.hourFloor(1605532173) // => '1fnp540'
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
hourFloor.ts:10
|
hourFloor.ts:10
|
||||||
@ -317,16 +313,6 @@ ___
|
|||||||
|
|
||||||
Check if an object is empty
|
Check if an object is empty
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
| Name | Type | Description |
|
|
||||||
| :------ | :------ | :------ |
|
|
||||||
| `obj` | `object` | The object being checked |
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
`boolean`
|
|
||||||
|
|
||||||
**`Example`**
|
**`Example`**
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
@ -334,39 +320,19 @@ U.isEmpty({}) // => true
|
|||||||
U.isEmpty({ bob: true }) // => false
|
U.isEmpty({ bob: true }) // => false
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Defined in
|
|
||||||
|
|
||||||
isEmpty.ts:9
|
|
||||||
|
|
||||||
___
|
|
||||||
|
|
||||||
### kebabCase
|
|
||||||
|
|
||||||
▸ **kebabCase**(`inval`): `string`
|
|
||||||
|
|
||||||
Turn a string into a kebab-case string
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type |
|
| Name | Type | Description |
|
||||||
| :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `inval` | ``null`` \| `string` |
|
| `obj` | `Object` | The object being checked |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`string`
|
`boolean`
|
||||||
|
|
||||||
**`Example`**
|
|
||||||
|
|
||||||
```ts
|
|
||||||
U.kebabCase('test string') // => 'test-string'
|
|
||||||
U.kebabCase('testString') // => 'test-string'
|
|
||||||
U.kebabCase('test_string') // => 'test-string'
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
kebabCase.ts:10
|
isEmpty.ts:9
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@ -376,6 +342,17 @@ ___
|
|||||||
|
|
||||||
Maybe pluralize a count:
|
Maybe pluralize a count:
|
||||||
|
|
||||||
|
**`Signature`**
|
||||||
|
|
||||||
|
U.maybePluralize(number, noun, suffix)
|
||||||
|
|
||||||
|
**`Example`**
|
||||||
|
|
||||||
|
```ts
|
||||||
|
U.maybePluralize(1, 'Bag', 's') // => 1 Bag
|
||||||
|
U.maybePluralize(5, 'Bag', 's') // => 5 Bags
|
||||||
|
```
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Default value | Description |
|
| Name | Type | Default value | Description |
|
||||||
@ -388,90 +365,22 @@ Maybe pluralize a count:
|
|||||||
|
|
||||||
`string`
|
`string`
|
||||||
|
|
||||||
**`Signature`**
|
|
||||||
|
|
||||||
U.maybePluralize(number, noun, suffix)
|
|
||||||
|
|
||||||
**`Example`**
|
|
||||||
|
|
||||||
```ts
|
|
||||||
U.maybePluralize(1, 'Bag', 's') // => 1 Bag
|
|
||||||
U.maybePluralize(5, 'Bag', 's') // => 5 Bags
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
maybePluralize.ts:16
|
maybePluralize.ts:16
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
### mergeWithoutNulls
|
|
||||||
|
|
||||||
▸ **mergeWithoutNulls**(`startingObj`, `newObj`): `object`
|
|
||||||
|
|
||||||
Merge two objects together ignoring null values in the incoming data
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
| Name | Type | Description |
|
|
||||||
| :------ | :------ | :------ |
|
|
||||||
| `startingObj` | `object` | The original source object to be merged into |
|
|
||||||
| `newObj` | `object` | The new incoming data |
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
`object`
|
|
||||||
|
|
||||||
**`Signature`**
|
|
||||||
|
|
||||||
U.mergeWithoutNulls(startingObj, newObj)
|
|
||||||
|
|
||||||
**`Example`**
|
|
||||||
|
|
||||||
```ts
|
|
||||||
U.mergeWithoutNulls({a:1, b:2}, {c:null, d:4}) // => { a:1, b:2, d:4}
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Defined in
|
|
||||||
|
|
||||||
mergeWithoutNulls.ts:11
|
|
||||||
|
|
||||||
___
|
|
||||||
|
|
||||||
### minuteFloor
|
|
||||||
|
|
||||||
▸ **minuteFloor**(`timestamp?`): `string`
|
|
||||||
|
|
||||||
Get the minute floor as a Base 32 string
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
| Name | Type | Description |
|
|
||||||
| :------ | :------ | :------ |
|
|
||||||
| `timestamp?` | ``null`` \| `number` | The timestamp as a number |
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
`string`
|
|
||||||
|
|
||||||
**`Example`**
|
|
||||||
|
|
||||||
```ts
|
|
||||||
U.minuteFloor(1605532173) // => '1fnp540'
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Defined in
|
|
||||||
|
|
||||||
minuteFloor.ts:10
|
|
||||||
|
|
||||||
___
|
|
||||||
|
|
||||||
### once
|
### once
|
||||||
|
|
||||||
▸ **once**(`fn`): `Function`
|
▸ **once**(`fn`): `Function`
|
||||||
|
|
||||||
Trigger a function once and then prevent it from triggering again
|
Trigger a function once and then prevent it from triggering again
|
||||||
|
|
||||||
|
**`Signature`**
|
||||||
|
|
||||||
|
U.once(fn)
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type |
|
| Name | Type |
|
||||||
@ -482,10 +391,6 @@ Trigger a function once and then prevent it from triggering again
|
|||||||
|
|
||||||
`Function`
|
`Function`
|
||||||
|
|
||||||
**`Signature`**
|
|
||||||
|
|
||||||
U.once(fn)
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
once.ts:9
|
once.ts:9
|
||||||
@ -498,6 +403,16 @@ ___
|
|||||||
|
|
||||||
Get a string phrase for the current time of day
|
Get a string phrase for the current time of day
|
||||||
|
|
||||||
|
**`Signature`**
|
||||||
|
|
||||||
|
U.partOfDay(timeString, today)
|
||||||
|
|
||||||
|
**`Example`**
|
||||||
|
|
||||||
|
```ts
|
||||||
|
U.partOfDay('13:00') // => 'Afternoon'
|
||||||
|
```
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Default value |
|
| Name | Type | Default value |
|
||||||
@ -509,16 +424,6 @@ Get a string phrase for the current time of day
|
|||||||
|
|
||||||
`string`
|
`string`
|
||||||
|
|
||||||
**`Signature`**
|
|
||||||
|
|
||||||
U.partOfDay(timeString, today)
|
|
||||||
|
|
||||||
**`Example`**
|
|
||||||
|
|
||||||
```ts
|
|
||||||
U.partOfDay('13:00') // => 'Afternoon'
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
partOfDay.ts:11
|
partOfDay.ts:11
|
||||||
@ -531,6 +436,10 @@ ___
|
|||||||
|
|
||||||
Throttle the calling of a function
|
Throttle the calling of a function
|
||||||
|
|
||||||
|
**`Signature`**
|
||||||
|
|
||||||
|
U.throttle(callback, limit)
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type |
|
| Name | Type |
|
||||||
@ -542,58 +451,28 @@ Throttle the calling of a function
|
|||||||
|
|
||||||
`Function`
|
`Function`
|
||||||
|
|
||||||
**`Signature`**
|
|
||||||
|
|
||||||
U.throttle(callback, limit)
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
throttle.ts:10
|
throttle.ts:10
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
### timeToMilliseconds
|
|
||||||
|
|
||||||
▸ **timeToMilliseconds**(`inTime?`): `number`
|
|
||||||
|
|
||||||
Get milliseconds from a string of time sections
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
|
|
||||||
| Name | Type | Default value | Description |
|
|
||||||
| :------ | :------ | :------ | :------ |
|
|
||||||
| `inTime` | `string` | `''` | * |
|
|
||||||
|
|
||||||
#### Returns
|
|
||||||
|
|
||||||
`number`
|
|
||||||
|
|
||||||
**`Signature`**
|
|
||||||
|
|
||||||
U.timeToMilliseconds(inTime)
|
|
||||||
|
|
||||||
**`Example`**
|
|
||||||
|
|
||||||
```ts
|
|
||||||
U.timeToMilliseconds('1s') // => 1000
|
|
||||||
U.timeToMilliseconds('1min') // => 60000
|
|
||||||
U.timeToMilliseconds('1 weeks') // => 604800000
|
|
||||||
U.timeToMilliseconds('5y2w30d14h30m10s') // => 161641810000
|
|
||||||
U.timeToMilliseconds('1 hour and 5 seconds') // => 3605000
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Defined in
|
|
||||||
|
|
||||||
timeToMilliseconds.ts:31
|
|
||||||
|
|
||||||
___
|
|
||||||
|
|
||||||
### toHour
|
### toHour
|
||||||
|
|
||||||
▸ **toHour**(`currentTimsestamp`, `extra?`): `number`
|
▸ **toHour**(`currentTimsestamp`, `extra?`): `number`
|
||||||
|
|
||||||
Return the number of Milliseconds to the hour for the supplied timestamp
|
Return the number of Milliseconds to the hour for the supplied timestamp
|
||||||
|
|
||||||
|
**`Signature`**
|
||||||
|
|
||||||
|
U.toHour(currentTimsestamp, extra)
|
||||||
|
|
||||||
|
**`Example`**
|
||||||
|
|
||||||
|
```ts
|
||||||
|
U.toHour('13:00') // => 1605532173
|
||||||
|
```
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Default value |
|
| Name | Type | Default value |
|
||||||
@ -607,16 +486,6 @@ Return the number of Milliseconds to the hour for the supplied timestamp
|
|||||||
|
|
||||||
*
|
*
|
||||||
|
|
||||||
**`Signature`**
|
|
||||||
|
|
||||||
U.toHour(currentTimsestamp, extra)
|
|
||||||
|
|
||||||
**`Example`**
|
|
||||||
|
|
||||||
```ts
|
|
||||||
U.toHour('13:00') // => 1605532173
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
toHour.ts:12
|
toHour.ts:12
|
||||||
|
@ -8,12 +8,9 @@ export * from './getDays';
|
|||||||
export * from './hasOwn';
|
export * from './hasOwn';
|
||||||
export * from './hourFloor';
|
export * from './hourFloor';
|
||||||
export * from './isEmpty';
|
export * from './isEmpty';
|
||||||
export * from './kebabCase';
|
|
||||||
export * from './latLong';
|
export * from './latLong';
|
||||||
export * from './limitedArray';
|
export * from './limitedArray';
|
||||||
export * from './maybePluralize';
|
export * from './maybePluralize';
|
||||||
export * from './mergeWithoutNulls';
|
|
||||||
export * from './minuteFloor';
|
|
||||||
export * from './once';
|
export * from './once';
|
||||||
export * from './partOfDay';
|
export * from './partOfDay';
|
||||||
export * from './throttle';
|
export * from './throttle';
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
import { kebabCase } from './kebabCase';
|
|
||||||
|
|
||||||
test('Null instead of string', function() {
|
|
||||||
expect(kebabCase(null)).toBe('');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('Empty string', function() {
|
|
||||||
expect(kebabCase('')).toBe('');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('String with spaces', function() {
|
|
||||||
expect(kebabCase('test string')).toBe('test-string');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('String with Capitals', function() {
|
|
||||||
expect(kebabCase('testString')).toBe('test-string');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('String with underscores', function() {
|
|
||||||
expect(kebabCase('test_string')).toBe('test-string');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('String with spaces, underscores and capitals', function() {
|
|
||||||
expect(kebabCase('this is a_complexTest_String')).toBe('this-is-a-complex-test-string');
|
|
||||||
});
|
|
@ -1,23 +0,0 @@
|
|||||||
/**
|
|
||||||
* Turn a string into a kebab-case string
|
|
||||||
* @param inval
|
|
||||||
*
|
|
||||||
* @example
|
|
||||||
* U.kebabCase('test string') // => 'test-string'
|
|
||||||
* U.kebabCase('testString') // => 'test-string'
|
|
||||||
* U.kebabCase('test_string') // => 'test-string'
|
|
||||||
*/
|
|
||||||
export function kebabCase(inval: string | null): string {
|
|
||||||
|
|
||||||
const tempString = (inval) ? inval : '';
|
|
||||||
|
|
||||||
const workArray = tempString.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g);
|
|
||||||
|
|
||||||
let workString: string = '';
|
|
||||||
|
|
||||||
if (workArray && workArray.length > 0) {
|
|
||||||
workString = workArray!.join('-').toLowerCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
return workString;
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
import { mergeWithoutNulls} from "./mergeWithoutNulls";
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
test('It should merge object correctly', function () {
|
|
||||||
|
|
||||||
const a = {a:1,b:2};
|
|
||||||
const b = {c:3,d:4};
|
|
||||||
|
|
||||||
expect(mergeWithoutNulls(a,b)).toEqual(({a:1,b:2, c:3, d:4}));
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
test('It should merge an object with nulls correctly', function () {
|
|
||||||
|
|
||||||
const a = {a:1,b:2};
|
|
||||||
const b = {c:3,d:4, e:null, f:null};
|
|
||||||
|
|
||||||
expect(mergeWithoutNulls(a,b)).toEqual(({a:1,b:2, c:3, d:4}));
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
|||||||
/**
|
|
||||||
* Merge two objects together ignoring null values in the incoming data
|
|
||||||
* @param startingObj The original source object to be merged into
|
|
||||||
* @param newObj The new incoming data
|
|
||||||
* @signature
|
|
||||||
* U.mergeWithoutNulls(startingObj, newObj)
|
|
||||||
*
|
|
||||||
* @example
|
|
||||||
* U.mergeWithoutNulls({a:1, b:2}, {c:null, d:4}) // => { a:1, b:2, d:4}
|
|
||||||
*/
|
|
||||||
export function mergeWithoutNulls(startingObj: object, newObj: object) : object {
|
|
||||||
|
|
||||||
const _cloneObj = Object.assign({}, startingObj);
|
|
||||||
|
|
||||||
for (const key of Object.keys(newObj)) {
|
|
||||||
|
|
||||||
const properties = Object.getOwnPropertyDescriptor(newObj, key);
|
|
||||||
|
|
||||||
if (properties?.value !== null)
|
|
||||||
|
|
||||||
Object.defineProperty(_cloneObj, key, { ...properties });
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return _cloneObj;
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
import { minuteFloor } from './minuteFloor';
|
|
||||||
|
|
||||||
test('Should return the correct Base32 value', () => {
|
|
||||||
expect(minuteFloor(1605532173)).toEqual('1fr3bi0');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('Should return something for a null value', () => {
|
|
||||||
expect(minuteFloor(null)).toBeDefined();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('Should return something for an empty value', () => {
|
|
||||||
expect(minuteFloor()).toBeDefined();
|
|
||||||
});
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
|||||||
/**
|
|
||||||
* Get the minute floor as a Base 32 string
|
|
||||||
* @param timestamp The timestamp as a number
|
|
||||||
* @returns {string}
|
|
||||||
*
|
|
||||||
* @example
|
|
||||||
* U.minuteFloor(1605532173) // => '1fnp540'
|
|
||||||
*/
|
|
||||||
|
|
||||||
export function minuteFloor(timestamp?: number|null): string {
|
|
||||||
|
|
||||||
const _timestamp = (timestamp) ? timestamp : Date.now();
|
|
||||||
|
|
||||||
return (Math.floor(_timestamp / 60000) * 60000).toString(32);
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user