Updated packages and added documention builder

This commit is contained in:
Martin Donnelly 2023-04-06 00:11:07 +01:00
parent 163ef078d4
commit a95f78d933
9 changed files with 2683 additions and 5671 deletions

1
docs/.nojekyll Normal file
View File

@ -0,0 +1 @@
TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false.

493
docs/README.md Normal file
View File

@ -0,0 +1,493 @@
@rakh/utils / [Exports](./docs/modules.md)
[@rakh/utils](./docs/README.md) / Exports
# @rakh/utils
## Table of contents
### Classes
- [LatLong](./docs/classes/LatLong.md)
- [limitedArray](./docs/classes/limitedArray.md)
### Variables
- [LocalStorage](./docs/modules.md#localstorage)
### Functions
- [arrayFromObj](./docs/modules.md#arrayfromobj)
- [debounce](./docs/modules.md#debounce)
- [distance](./docs/modules.md#distance)
- [extractFromObj](./docs/modules.md#extractfromobj)
- [get](./docs/modules.md#get)
- [getDays](./docs/modules.md#getdays)
- [hasOwn](./docs/modules.md#hasown)
- [hourFloor](./docs/modules.md#hourfloor)
- [isEmpty](./docs/modules.md#isempty)
- [maybePluralize](./docs/modules.md#maybepluralize)
- [once](./docs/modules.md#once)
- [partOfDay](./docs/modules.md#partofday)
- [throttle](./docs/modules.md#throttle)
- [toHour](./docs/modules.md#tohour)
## Variables
### LocalStorage
**LocalStorage**: `Object` = `_LocalStorage`
#### Defined in
LocalStorage.ts:44
## Functions
### arrayFromObj
**arrayFromObj**(`jsonObj`, `wantedFields`): `any`[]
Create an array from an Object using specified fields
**`Example`**
```ts
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
arrayFromObj.ts:9
___
### debounce
**debounce**(`fn`, `time`): `Function`
Debounce the calling of a function
**`Signature`**
U.debounce(fn, time)
#### Parameters
| Name | Type | Description |
| :------ | :------ | :------ |
| `fn` | `Function` | The function to be debounced |
| `time` | `number` | How long to wait |
#### Returns
`Function`
#### Defined in
debounce.ts:12
___
### distance
**distance**(`lat1`, `lon1`, `lat2`, `lon2`): `number`
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
| Name | Type |
| :------ | :------ |
| `lat1` | `number` |
| `lon1` | `number` |
| `lat2` | `number` |
| `lon2` | `number` |
#### Returns
`number`
#### Defined in
distance.ts:16
**distance**(`latLong1`, `latLong2`): `number`
Calculate the distance between two lat long points
**`Signature`**
U.distance(latLong1, latLong2)
**`Example`**
```ts
const a: U.LatLong = new LatLong(1, 1);
const b: U.LatLong = new LatLong(2, 2);
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
distance.ts:33
___
### extractFromObj
**extractFromObj**(`jsonObj`, `wantedFields`): `Object`
Extract an object from another object using specific fields
**`Signature`**
U.extractFromObj(jsonObj, wantedFields)
**`Example`**
```ts
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
extractFromObj.ts:12
___
### get
**get**(`obj`, `path`, `defaultValue?`): `any`
Get the value of an item inside an object
**`Example`**
```ts
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
get.ts:10
___
### getDays
**getDays**(`startdate`, `enddate`): `number`
Get number of days between two Date objects
#### Parameters
| Name | Type |
| :------ | :------ |
| `startdate` | `Date` |
| `enddate` | `Date` |
#### Returns
`number`
#### Defined in
getDays.ts:7
___
### hasOwn
**hasOwn**(`obj`, `prop`): `boolean`
Check if an object has an property
**`Example`**
```ts
U.hasOwn({bob:'1'}, 'bob') // => true
```
#### Parameters
| Name | Type | Description |
| :------ | :------ | :------ |
| `obj` | `Object` | The source object |
| `prop` | `string` | The required property |
#### Returns
`boolean`
#### Defined in
hasOwn.ts:12
___
### hourFloor
**hourFloor**(`timestamp`): `string`
Get the hour floor as a Base 32 string
**`Example`**
```ts
U.hourFloor(1605532173) // => '1fnp540'
```
#### Parameters
| Name | Type | Description |
| :------ | :------ | :------ |
| `timestamp` | `number` | The timestamp as a number |
#### Returns
`string`
#### Defined in
hourFloor.ts:10
___
### isEmpty
**isEmpty**(`obj`): `boolean`
Check if an object is empty
**`Example`**
```ts
U.isEmpty({}) // => true
U.isEmpty({ bob: true }) // => false
```
#### Parameters
| Name | Type | Description |
| :------ | :------ | :------ |
| `obj` | `Object` | The object being checked |
#### Returns
`boolean`
#### Defined in
isEmpty.ts:9
___
### maybePluralize
**maybePluralize**(`count`, `noun`, `suffix?`): `string`
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
| Name | Type | Default value | Description |
| :------ | :------ | :------ | :------ |
| `count` | `number` | `undefined` | the value counting |
| `noun` | `string` | `undefined` | the name of the value |
| `suffix` | `string` | `'s'` | the suffix |
#### Returns
`string`
#### Defined in
maybePluralize.ts:16
___
### once
**once**(`fn`): `Function`
Trigger a function once and then prevent it from triggering again
**`Signature`**
U.once(fn)
#### Parameters
| Name | Type |
| :------ | :------ |
| `fn` | `Function` |
#### Returns
`Function`
#### Defined in
once.ts:9
___
### partOfDay
**partOfDay**(`timeString`, `today?`): `string`
Get a string phrase for the current time of day
**`Signature`**
U.partOfDay(timeString, today)
**`Example`**
```ts
U.partOfDay('13:00') // => 'Afternoon'
```
#### Parameters
| Name | Type | Default value |
| :------ | :------ | :------ |
| `timeString` | `string` | `undefined` |
| `today` | `boolean` | `false` |
#### Returns
`string`
#### Defined in
partOfDay.ts:11
___
### throttle
**throttle**(`callback`, `limit`): `Function`
Throttle the calling of a function
**`Signature`**
U.throttle(callback, limit)
#### Parameters
| Name | Type |
| :------ | :------ |
| `callback` | `Function` |
| `limit` | `number` |
#### Returns
`Function`
#### Defined in
throttle.ts:10
___
### toHour
**toHour**(`currentTimsestamp`, `extra?`): `number`
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
| Name | Type | Default value |
| :------ | :------ | :------ |
| `currentTimsestamp` | `number` | `undefined` |
| `extra` | `number` | `0` |
#### Returns
`number`
*
#### Defined in
toHour.ts:12

61
docs/classes/LatLong.md Normal file
View File

@ -0,0 +1,61 @@
[@rakh/utils](./docs/README.md) / [Exports](./docs/modules.md) / LatLong
# Class: LatLong
Calculate the distance between two latLongs
**`Param`**
**`Param`**
**`Param`**
**`Param`**
## Table of contents
### Constructors
- [constructor](./docs/classes/LatLong.md#constructor)
### Properties
- [lat](./docs/classes/LatLong.md#lat)
- [long](./docs/classes/LatLong.md#long)
## Constructors
### constructor
**new LatLong**(`lat`, `long`)
#### Parameters
| Name | Type |
| :------ | :------ |
| `lat` | `number` |
| `long` | `number` |
#### Defined in
latLong.ts:12
## Properties
### lat
**lat**: `number`
#### Defined in
latLong.ts:10
___
### long
**long**: `number`
#### Defined in
latLong.ts:11

View File

@ -0,0 +1,176 @@
[@rakh/utils](./docs/README.md) / [Exports](./docs/modules.md) / limitedArray
# Class: limitedArray
## Table of contents
### Constructors
- [constructor](./docs/classes/limitedArray.md#constructor)
### Properties
- [\_array](./docs/classes/limitedArray.md#_array)
- [\_limit](./docs/classes/limitedArray.md#_limit)
### Methods
- [add](./docs/classes/limitedArray.md#add)
- [get](./docs/classes/limitedArray.md#get)
- [length](./docs/classes/limitedArray.md#length)
- [limit](./docs/classes/limitedArray.md#limit)
- [push](./docs/classes/limitedArray.md#push)
- [shift](./docs/classes/limitedArray.md#shift)
## Constructors
### constructor
**new limitedArray**(`size?`)
Used to construct the LimitedArray
Defaults to 100 when no size is passed in
#### Parameters
| Name | Type | Default value |
| :------ | :------ | :------ |
| `size` | `number` | `100` |
#### Defined in
limitedArray.ts:10
## Properties
### \_array
**\_array**: `any`[]
#### Defined in
limitedArray.ts:2
___
### \_limit
**\_limit**: `number`
#### Defined in
limitedArray.ts:3
## Methods
### add
**add**(`items`): `void`
Bulk add an array to the array
#### Parameters
| Name | Type |
| :------ | :------ |
| `items` | `any`[] |
#### Returns
`void`
#### Defined in
limitedArray.ts:54
___
### get
**get**(): `any`[]
Return the items within the array
#### Returns
`any`[]
#### Defined in
limitedArray.ts:29
___
### length
**length**(): `number`
Returns the length of the array
#### Returns
`number`
#### Defined in
limitedArray.ts:46
___
### limit
**limit**(`size`): `void`
Limits the size of the array
#### Parameters
| Name | Type |
| :------ | :------ |
| `size` | `number` |
#### Returns
`void`
#### Defined in
limitedArray.ts:37
___
### push
**push**(`item`): `void`
Add items to the end of an array
#### Parameters
| Name | Type |
| :------ | :------ |
| `item` | `any` |
#### Returns
`void`
#### Defined in
limitedArray.ts:20
___
### shift
**shift**(): `any`
Remove an item from the beginning of an array
#### Returns
`any`
#### Defined in
limitedArray.ts:64

491
docs/modules.md Normal file
View File

@ -0,0 +1,491 @@
[@rakh/utils](./docs/README.md) / Exports
# @rakh/utils
## Table of contents
### Classes
- [LatLong](./docs/classes/LatLong.md)
- [limitedArray](./docs/classes/limitedArray.md)
### Variables
- [LocalStorage](./docs/modules.md#localstorage)
### Functions
- [arrayFromObj](./docs/modules.md#arrayfromobj)
- [debounce](./docs/modules.md#debounce)
- [distance](./docs/modules.md#distance)
- [extractFromObj](./docs/modules.md#extractfromobj)
- [get](./docs/modules.md#get)
- [getDays](./docs/modules.md#getdays)
- [hasOwn](./docs/modules.md#hasown)
- [hourFloor](./docs/modules.md#hourfloor)
- [isEmpty](./docs/modules.md#isempty)
- [maybePluralize](./docs/modules.md#maybepluralize)
- [once](./docs/modules.md#once)
- [partOfDay](./docs/modules.md#partofday)
- [throttle](./docs/modules.md#throttle)
- [toHour](./docs/modules.md#tohour)
## Variables
### LocalStorage
**LocalStorage**: `Object` = `_LocalStorage`
#### Defined in
LocalStorage.ts:44
## Functions
### arrayFromObj
**arrayFromObj**(`jsonObj`, `wantedFields`): `any`[]
Create an array from an Object using specified fields
**`Example`**
```ts
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
arrayFromObj.ts:9
___
### debounce
**debounce**(`fn`, `time`): `Function`
Debounce the calling of a function
**`Signature`**
U.debounce(fn, time)
#### Parameters
| Name | Type | Description |
| :------ | :------ | :------ |
| `fn` | `Function` | The function to be debounced |
| `time` | `number` | How long to wait |
#### Returns
`Function`
#### Defined in
debounce.ts:12
___
### distance
**distance**(`lat1`, `lon1`, `lat2`, `lon2`): `number`
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
| Name | Type |
| :------ | :------ |
| `lat1` | `number` |
| `lon1` | `number` |
| `lat2` | `number` |
| `lon2` | `number` |
#### Returns
`number`
#### Defined in
distance.ts:16
**distance**(`latLong1`, `latLong2`): `number`
Calculate the distance between two lat long points
**`Signature`**
U.distance(latLong1, latLong2)
**`Example`**
```ts
const a: U.LatLong = new LatLong(1, 1);
const b: U.LatLong = new LatLong(2, 2);
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
distance.ts:33
___
### extractFromObj
**extractFromObj**(`jsonObj`, `wantedFields`): `Object`
Extract an object from another object using specific fields
**`Signature`**
U.extractFromObj(jsonObj, wantedFields)
**`Example`**
```ts
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
extractFromObj.ts:12
___
### get
**get**(`obj`, `path`, `defaultValue?`): `any`
Get the value of an item inside an object
**`Example`**
```ts
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
get.ts:10
___
### getDays
**getDays**(`startdate`, `enddate`): `number`
Get number of days between two Date objects
#### Parameters
| Name | Type |
| :------ | :------ |
| `startdate` | `Date` |
| `enddate` | `Date` |
#### Returns
`number`
#### Defined in
getDays.ts:7
___
### hasOwn
**hasOwn**(`obj`, `prop`): `boolean`
Check if an object has an property
**`Example`**
```ts
U.hasOwn({bob:'1'}, 'bob') // => true
```
#### Parameters
| Name | Type | Description |
| :------ | :------ | :------ |
| `obj` | `Object` | The source object |
| `prop` | `string` | The required property |
#### Returns
`boolean`
#### Defined in
hasOwn.ts:12
___
### hourFloor
**hourFloor**(`timestamp`): `string`
Get the hour floor as a Base 32 string
**`Example`**
```ts
U.hourFloor(1605532173) // => '1fnp540'
```
#### Parameters
| Name | Type | Description |
| :------ | :------ | :------ |
| `timestamp` | `number` | The timestamp as a number |
#### Returns
`string`
#### Defined in
hourFloor.ts:10
___
### isEmpty
**isEmpty**(`obj`): `boolean`
Check if an object is empty
**`Example`**
```ts
U.isEmpty({}) // => true
U.isEmpty({ bob: true }) // => false
```
#### Parameters
| Name | Type | Description |
| :------ | :------ | :------ |
| `obj` | `Object` | The object being checked |
#### Returns
`boolean`
#### Defined in
isEmpty.ts:9
___
### maybePluralize
**maybePluralize**(`count`, `noun`, `suffix?`): `string`
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
| Name | Type | Default value | Description |
| :------ | :------ | :------ | :------ |
| `count` | `number` | `undefined` | the value counting |
| `noun` | `string` | `undefined` | the name of the value |
| `suffix` | `string` | `'s'` | the suffix |
#### Returns
`string`
#### Defined in
maybePluralize.ts:16
___
### once
**once**(`fn`): `Function`
Trigger a function once and then prevent it from triggering again
**`Signature`**
U.once(fn)
#### Parameters
| Name | Type |
| :------ | :------ |
| `fn` | `Function` |
#### Returns
`Function`
#### Defined in
once.ts:9
___
### partOfDay
**partOfDay**(`timeString`, `today?`): `string`
Get a string phrase for the current time of day
**`Signature`**
U.partOfDay(timeString, today)
**`Example`**
```ts
U.partOfDay('13:00') // => 'Afternoon'
```
#### Parameters
| Name | Type | Default value |
| :------ | :------ | :------ |
| `timeString` | `string` | `undefined` |
| `today` | `boolean` | `false` |
#### Returns
`string`
#### Defined in
partOfDay.ts:11
___
### throttle
**throttle**(`callback`, `limit`): `Function`
Throttle the calling of a function
**`Signature`**
U.throttle(callback, limit)
#### Parameters
| Name | Type |
| :------ | :------ |
| `callback` | `Function` |
| `limit` | `number` |
#### Returns
`Function`
#### Defined in
throttle.ts:10
___
### toHour
**toHour**(`currentTimsestamp`, `extra?`): `number`
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
| Name | Type | Default value |
| :------ | :------ | :------ |
| `currentTimsestamp` | `number` | `undefined` |
| `extra` | `number` | `0` |
#### Returns
`number`
*
#### Defined in
toHour.ts:12

6589
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,27 @@
{
"name": "@rakh/utils",
"version": "2.0.5",
"version": "2.0.14",
"main": "dist/commonjs/index.js",
"types": "dist/commonjs/index.d.ts",
"module": "dist/es/index.js",
"jsnext:main": "dist/es/index.js",
"files": [
"dist/**/*",
"docs/**/*",
"readme.MD"
],
"exports": {
".": {
"import": {
"types": "./dist/es/index.d.ts",
"default": "./dist/es/index.js"
},
"require": {
"types": "./dist/commonjs/index.d.ts",
"default": "./dist/commonjs/index.js"
}
}
},
"scripts": {
"release": "node ./scripts/create-index.js && vik patch -t",
"clean": "rm -rf dist",
@ -11,25 +29,25 @@
"test": "jest --coverage && npm run compile",
"compile:es": "tsc --declaration true --declarationMap true --module esnext --outDir './dist/es'",
"compile:commonjs": "tsc --declaration true --declarationMap true --module commonjs --outDir './dist/commonjs'",
"compile": "npm run clean && npm run compile:es && npm run compile:commonjs"
"compile": "npm run clean && npm run compile:es && npm run compile:commonjs && npm run document",
"document": "./node_modules/.bin/typedoc --plugin typedoc-plugin-markdown --publicPath ./docs/ --out docs ./ts-src && cp ./docs/modules.md ./readme.MD"
},
"author": "Martin Donnelly",
"license": "ISC",
"dependencies": {
"save": "^2.4.0",
"typedoc": "^0.23.15"
},
"devDependencies": {
"@types/jest": "^29.0.3",
"@types/sinon": "^10.0.0",
"grunt": "^1.3.0",
"jest": "^29.0.3",
"marked": "^4.1.0",
"prettier": "^2.3.0",
"sinon": "^14.0.0",
"ts-jest": "^29.0.2",
"@types/jest": "^29.5.0",
"@types/sinon": "^10.0.13",
"grunt": "^1.6.1",
"jest": "^29.5.0",
"marked": "^4.3.0",
"prettier": "^2.8.7",
"save": "^2.9.0",
"sinon": "^15.0.3",
"ts-jest": "^29.1.0",
"ts-node": "^10.9.1",
"typescript": "^4.2.4",
"typedoc": "^0.23.28",
"typedoc-plugin-markdown": "^3.14.0",
"typescript": "^5.0.3",
"vik": "^0.4.0"
},
"description": "",

491
readme.MD
View File

@ -1,4 +1,491 @@
# Rakh/utils
[@rakh/utils](./docs/README.md) / Exports
![Build status](https://travis-ci.org/martind2000/utils.svg?branch=main)
# @rakh/utils
## Table of contents
### Classes
- [LatLong](./docs/classes/LatLong.md)
- [limitedArray](./docs/classes/limitedArray.md)
### Variables
- [LocalStorage](./docs/modules.md#localstorage)
### Functions
- [arrayFromObj](./docs/modules.md#arrayfromobj)
- [debounce](./docs/modules.md#debounce)
- [distance](./docs/modules.md#distance)
- [extractFromObj](./docs/modules.md#extractfromobj)
- [get](./docs/modules.md#get)
- [getDays](./docs/modules.md#getdays)
- [hasOwn](./docs/modules.md#hasown)
- [hourFloor](./docs/modules.md#hourfloor)
- [isEmpty](./docs/modules.md#isempty)
- [maybePluralize](./docs/modules.md#maybepluralize)
- [once](./docs/modules.md#once)
- [partOfDay](./docs/modules.md#partofday)
- [throttle](./docs/modules.md#throttle)
- [toHour](./docs/modules.md#tohour)
## Variables
### LocalStorage
• **LocalStorage**: `Object` = `_LocalStorage`
#### Defined in
LocalStorage.ts:44
## Functions
### arrayFromObj
▸ **arrayFromObj**(`jsonObj`, `wantedFields`): `any`[]
Create an array from an Object using specified fields
**`Example`**
```ts
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
arrayFromObj.ts:9
___
### debounce
▸ **debounce**(`fn`, `time`): `Function`
Debounce the calling of a function
**`Signature`**
U.debounce(fn, time)
#### Parameters
| Name | Type | Description |
| :------ | :------ | :------ |
| `fn` | `Function` | The function to be debounced |
| `time` | `number` | How long to wait |
#### Returns
`Function`
#### Defined in
debounce.ts:12
___
### distance
▸ **distance**(`lat1`, `lon1`, `lat2`, `lon2`): `number`
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
| Name | Type |
| :------ | :------ |
| `lat1` | `number` |
| `lon1` | `number` |
| `lat2` | `number` |
| `lon2` | `number` |
#### Returns
`number`
#### Defined in
distance.ts:16
▸ **distance**(`latLong1`, `latLong2`): `number`
Calculate the distance between two lat long points
**`Signature`**
U.distance(latLong1, latLong2)
**`Example`**
```ts
const a: U.LatLong = new LatLong(1, 1);
const b: U.LatLong = new LatLong(2, 2);
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
distance.ts:33
___
### extractFromObj
▸ **extractFromObj**(`jsonObj`, `wantedFields`): `Object`
Extract an object from another object using specific fields
**`Signature`**
U.extractFromObj(jsonObj, wantedFields)
**`Example`**
```ts
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
extractFromObj.ts:12
___
### get
▸ **get**(`obj`, `path`, `defaultValue?`): `any`
Get the value of an item inside an object
**`Example`**
```ts
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
get.ts:10
___
### getDays
▸ **getDays**(`startdate`, `enddate`): `number`
Get number of days between two Date objects
#### Parameters
| Name | Type |
| :------ | :------ |
| `startdate` | `Date` |
| `enddate` | `Date` |
#### Returns
`number`
#### Defined in
getDays.ts:7
___
### hasOwn
▸ **hasOwn**(`obj`, `prop`): `boolean`
Check if an object has an property
**`Example`**
```ts
U.hasOwn({bob:'1'}, 'bob') // => true
```
#### Parameters
| Name | Type | Description |
| :------ | :------ | :------ |
| `obj` | `Object` | The source object |
| `prop` | `string` | The required property |
#### Returns
`boolean`
#### Defined in
hasOwn.ts:12
___
### hourFloor
▸ **hourFloor**(`timestamp`): `string`
Get the hour floor as a Base 32 string
**`Example`**
```ts
U.hourFloor(1605532173) // => '1fnp540'
```
#### Parameters
| Name | Type | Description |
| :------ | :------ | :------ |
| `timestamp` | `number` | The timestamp as a number |
#### Returns
`string`
#### Defined in
hourFloor.ts:10
___
### isEmpty
▸ **isEmpty**(`obj`): `boolean`
Check if an object is empty
**`Example`**
```ts
U.isEmpty({}) // => true
U.isEmpty({ bob: true }) // => false
```
#### Parameters
| Name | Type | Description |
| :------ | :------ | :------ |
| `obj` | `Object` | The object being checked |
#### Returns
`boolean`
#### Defined in
isEmpty.ts:9
___
### maybePluralize
▸ **maybePluralize**(`count`, `noun`, `suffix?`): `string`
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
| Name | Type | Default value | Description |
| :------ | :------ | :------ | :------ |
| `count` | `number` | `undefined` | the value counting |
| `noun` | `string` | `undefined` | the name of the value |
| `suffix` | `string` | `'s'` | the suffix |
#### Returns
`string`
#### Defined in
maybePluralize.ts:16
___
### once
▸ **once**(`fn`): `Function`
Trigger a function once and then prevent it from triggering again
**`Signature`**
U.once(fn)
#### Parameters
| Name | Type |
| :------ | :------ |
| `fn` | `Function` |
#### Returns
`Function`
#### Defined in
once.ts:9
___
### partOfDay
▸ **partOfDay**(`timeString`, `today?`): `string`
Get a string phrase for the current time of day
**`Signature`**
U.partOfDay(timeString, today)
**`Example`**
```ts
U.partOfDay('13:00') // => 'Afternoon'
```
#### Parameters
| Name | Type | Default value |
| :------ | :------ | :------ |
| `timeString` | `string` | `undefined` |
| `today` | `boolean` | `false` |
#### Returns
`string`
#### Defined in
partOfDay.ts:11
___
### throttle
▸ **throttle**(`callback`, `limit`): `Function`
Throttle the calling of a function
**`Signature`**
U.throttle(callback, limit)
#### Parameters
| Name | Type |
| :------ | :------ |
| `callback` | `Function` |
| `limit` | `number` |
#### Returns
`Function`
#### Defined in
throttle.ts:10
___
### toHour
▸ **toHour**(`currentTimsestamp`, `extra?`): `number`
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
| Name | Type | Default value |
| :------ | :------ | :------ |
| `currentTimsestamp` | `number` | `undefined` |
| `extra` | `number` | `0` |
#### Returns
`number`
*
#### Defined in
toHour.ts:12

View File

@ -66,5 +66,5 @@
"skipLibCheck": true
},
"include": ["ts-src"],
"exclude": ["node_modules"]
"exclude": ["node_modules", "**/*.test.ts"]
}