@inrixia/helpers 1.23.4 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/conv.d.ts +28 -0
- package/conv.d.ts.map +1 -0
- package/conv.js +42 -0
- package/conv.js.map +1 -0
- package/{elastic/index.d.ts → elastic.d.ts} +15 -14
- package/elastic.d.ts.map +1 -0
- package/{elastic/index.js → elastic.js} +24 -31
- package/elastic.js.map +1 -0
- package/{geo/index.d.ts → geo.d.ts} +5 -6
- package/geo.d.ts.map +1 -0
- package/geo.js +32 -0
- package/geo.js.map +1 -0
- package/index.d.ts +9 -7
- package/index.d.ts.map +1 -1
- package/index.js +9 -33
- package/index.js.map +1 -1
- package/{logic/index.d.ts → logic.d.ts} +2 -2
- package/logic.d.ts.map +1 -0
- package/{logic/index.js → logic.js} +16 -18
- package/logic.js.map +1 -0
- package/{math/index.d.ts → math.d.ts} +2 -2
- package/math.d.ts.map +1 -0
- package/{math/index.js → math.js} +6 -13
- package/math.js.map +1 -0
- package/{object/index.d.ts → object.d.ts} +42 -44
- package/object.d.ts.map +1 -0
- package/{object/index.js → object.js} +77 -111
- package/object.js.map +1 -0
- package/package.json +9 -4
- package/{react/index.d.ts → react.d.ts} +1 -1
- package/react.d.ts.map +1 -0
- package/{react/index.js → react.js} +2 -6
- package/react.js.map +1 -0
- package/test/matchers.d.ts +15 -0
- package/test/matchers.d.ts.map +1 -0
- package/test/matchers.js +66 -0
- package/test/matchers.js.map +1 -0
- package/test.d.ts +15 -0
- package/test.d.ts.map +1 -0
- package/test.js +5 -0
- package/test.js.map +1 -0
- package/ts/math.js +1 -2
- package/ts/numRange.d.ts.map +1 -1
- package/ts/numRange.js +1 -2
- package/{ts/index.d.ts → ts.d.ts} +7 -3
- package/ts.d.ts.map +1 -0
- package/ts.js +6 -0
- package/ts.js.map +1 -0
- package/conv/index.d.ts +0 -28
- package/conv/index.d.ts.map +0 -1
- package/conv/index.js +0 -48
- package/conv/index.js.map +0 -1
- package/elastic/index.d.ts.map +0 -1
- package/elastic/index.js.map +0 -1
- package/geo/index.d.ts.map +0 -1
- package/geo/index.js +0 -39
- package/geo/index.js.map +0 -1
- package/jest/index.d.ts +0 -24
- package/jest/index.d.ts.map +0 -1
- package/jest/index.js +0 -47
- package/jest/index.js.map +0 -1
- package/logic/index.d.ts.map +0 -1
- package/logic/index.js.map +0 -1
- package/math/index.d.ts.map +0 -1
- package/math/index.js.map +0 -1
- package/object/index.d.ts.map +0 -1
- package/object/index.js.map +0 -1
- package/react/index.d.ts.map +0 -1
- package/react/index.js.map +0 -1
- package/ts/index.d.ts.map +0 -1
- package/ts/index.js +0 -11
- package/ts/index.js.map +0 -1
package/conv.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get `dryBulbTemp` from `dewBulbTemp` and `relativeHumidity`
|
|
3
|
+
* @param dewPointTemp Dew point temperature in degrees celsius
|
|
4
|
+
* @param relativeHumidity Relative humidity in whole number percent 0-100
|
|
5
|
+
* @returns `dryBulbTemp` - Dry bulb temperature in degrees celsius
|
|
6
|
+
*
|
|
7
|
+
* @url https://bmcnoldy.rsmas.miami.edu/humidity_conversions.pdf
|
|
8
|
+
*/
|
|
9
|
+
export declare const dryBulbTemp: (dewPointTemp: number, relativeHumidity: number) => number;
|
|
10
|
+
/**
|
|
11
|
+
* Get `dewPointTemp` from `dryBulbTemp` and `relativeHumidity`
|
|
12
|
+
* @param dryBulbTemp Dry bulb temperature in degrees celsius
|
|
13
|
+
* @param relativeHumidity Relative humidity in whole number percent 0-100
|
|
14
|
+
* @returns `dewPointTemp` - Dew point temperature in degrees celsius
|
|
15
|
+
*
|
|
16
|
+
* @url https://bmcnoldy.rsmas.miami.edu/humidity_conversions.pdf
|
|
17
|
+
*/
|
|
18
|
+
export declare const dewPointTemp: (dryBulbTemp: number, relativeHumidity: number) => number;
|
|
19
|
+
/**
|
|
20
|
+
* Get `relativeHumidity` from `dryBulbTemp` and `dewPointTemp`
|
|
21
|
+
* @param dryBulbTemp Dry bulb temperature in degrees celsius
|
|
22
|
+
* @param dewPointTemp Dew point temperature in degrees celsius
|
|
23
|
+
* @returns `dryBulbTemp` - Relative humidity in whole number percent 0-100
|
|
24
|
+
*
|
|
25
|
+
* @url https://bmcnoldy.rsmas.miami.edu/humidity_conversions.pdf
|
|
26
|
+
*/
|
|
27
|
+
export declare const relativeHumidity: (dryBulbTemp: number, dewPointTemp: number) => number;
|
|
28
|
+
//# sourceMappingURL=conv.d.ts.map
|
package/conv.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conv.d.ts","sourceRoot":"","sources":["../src/conv.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,iBAAkB,MAAM,oBAAoB,MAAM,KAAG,MAI5E,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,gBAAiB,MAAM,oBAAoB,MAAM,KAAG,MAI5E,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,gBAAiB,MAAM,gBAAgB,MAAM,KAAG,MAI5E,CAAC"}
|
package/conv.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const a = 17.625;
|
|
2
|
+
const b = 243.04;
|
|
3
|
+
/**
|
|
4
|
+
* Get `dryBulbTemp` from `dewBulbTemp` and `relativeHumidity`
|
|
5
|
+
* @param dewPointTemp Dew point temperature in degrees celsius
|
|
6
|
+
* @param relativeHumidity Relative humidity in whole number percent 0-100
|
|
7
|
+
* @returns `dryBulbTemp` - Dry bulb temperature in degrees celsius
|
|
8
|
+
*
|
|
9
|
+
* @url https://bmcnoldy.rsmas.miami.edu/humidity_conversions.pdf
|
|
10
|
+
*/
|
|
11
|
+
export const dryBulbTemp = (dewPointTemp, relativeHumidity) => {
|
|
12
|
+
const lnRH = Math.log(relativeHumidity / 100);
|
|
13
|
+
const aTdbTd = (a * dewPointTemp) / (b + dewPointTemp);
|
|
14
|
+
return (b * (aTdbTd - lnRH)) / (a + lnRH - aTdbTd);
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Get `dewPointTemp` from `dryBulbTemp` and `relativeHumidity`
|
|
18
|
+
* @param dryBulbTemp Dry bulb temperature in degrees celsius
|
|
19
|
+
* @param relativeHumidity Relative humidity in whole number percent 0-100
|
|
20
|
+
* @returns `dewPointTemp` - Dew point temperature in degrees celsius
|
|
21
|
+
*
|
|
22
|
+
* @url https://bmcnoldy.rsmas.miami.edu/humidity_conversions.pdf
|
|
23
|
+
*/
|
|
24
|
+
export const dewPointTemp = (dryBulbTemp, relativeHumidity) => {
|
|
25
|
+
const lnRH = Math.log(relativeHumidity / 100);
|
|
26
|
+
const aTbT = (a * dryBulbTemp) / (b + dryBulbTemp);
|
|
27
|
+
return (b * (lnRH + aTbT)) / (a - lnRH - aTbT);
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Get `relativeHumidity` from `dryBulbTemp` and `dewPointTemp`
|
|
31
|
+
* @param dryBulbTemp Dry bulb temperature in degrees celsius
|
|
32
|
+
* @param dewPointTemp Dew point temperature in degrees celsius
|
|
33
|
+
* @returns `dryBulbTemp` - Relative humidity in whole number percent 0-100
|
|
34
|
+
*
|
|
35
|
+
* @url https://bmcnoldy.rsmas.miami.edu/humidity_conversions.pdf
|
|
36
|
+
*/
|
|
37
|
+
export const relativeHumidity = (dryBulbTemp, dewPointTemp) => {
|
|
38
|
+
const aTdbTd = (a * dewPointTemp) / (b + dewPointTemp);
|
|
39
|
+
const aTbT = (a * dryBulbTemp) / (b + dryBulbTemp);
|
|
40
|
+
return 100 * (Math.exp(aTdbTd) / Math.exp(aTbT));
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=conv.js.map
|
package/conv.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conv.js","sourceRoot":"","sources":["../src/conv.ts"],"names":[],"mappings":"A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,CAAC,MAAM,CAAC,GAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;AAC9C,CAAC,CAAC"}
|
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
import type { Client, SearchParams, SearchResponse, IndicesCreateParams } from "elasticsearch";
|
|
2
|
+
import type { UnknownRecord } from "./ts.js";
|
|
2
3
|
import { EventEmitter } from "events";
|
|
3
4
|
/**
|
|
4
5
|
* Indexes a large amount of entities in a single query
|
|
5
|
-
* @param
|
|
6
|
-
* @param
|
|
6
|
+
* @param entities Array containing entities to index
|
|
7
|
+
* @param indexName Name of index to index entities.
|
|
7
8
|
*
|
|
8
|
-
* @returns
|
|
9
|
+
* @returns Promise that resolves time taken to index entities in ms.
|
|
9
10
|
*/
|
|
10
|
-
export declare const bulkIndex: (elastic: Client, entities:
|
|
11
|
+
export declare const bulkIndex: (elastic: Client, entities: UnknownRecord[], indexName: string, refresh?: boolean) => Promise<number>;
|
|
11
12
|
/**
|
|
12
13
|
* Queries elastic using `params`.
|
|
13
|
-
* @param
|
|
14
|
+
* @param params Query object.
|
|
14
15
|
*
|
|
15
16
|
* @returns Iterator that yeilds a result until query exhausted.
|
|
16
17
|
*/
|
|
17
18
|
export declare function scrollSearch(elastic: Client, params: SearchParams): AsyncGenerator<SearchResponse<unknown>>;
|
|
18
19
|
/**
|
|
19
20
|
* Function to recreate a elasticsearch index.
|
|
20
|
-
* @param
|
|
21
|
-
* @param
|
|
22
|
-
* @param
|
|
21
|
+
* @param elastic Elasticsearch client
|
|
22
|
+
* @param createParams Elastic parameters for creation of index
|
|
23
|
+
* @param options Options for creation
|
|
23
24
|
*/
|
|
24
25
|
export declare const createIndex: (elastic: Client, createParams: IndicesCreateParams, options: {
|
|
25
26
|
logProgress?: boolean;
|
|
@@ -27,11 +28,11 @@ export declare const createIndex: (elastic: Client, createParams: IndicesCreateP
|
|
|
27
28
|
}) => Promise<void>;
|
|
28
29
|
/**
|
|
29
30
|
* Returns scrollsearch results in simulated time based on when result timestamp.
|
|
30
|
-
* @param
|
|
31
|
-
* @param
|
|
32
|
-
* @param
|
|
33
|
-
* @param
|
|
34
|
-
* @returns
|
|
31
|
+
* @param elastic Elasticsearch client to use
|
|
32
|
+
* @param query Query object to use for scroll search
|
|
33
|
+
* @param timestampKey Key to use for fetching timestamp from objects
|
|
34
|
+
* @param options.timescale Rate at which "time" progreesses
|
|
35
|
+
* @returns EventEmitter which emits 'entity' events containing resulting hits
|
|
35
36
|
* @example
|
|
36
37
|
* const elasticClient = new ElasticClient({ node: 'http://127.0.0.1:9200' })
|
|
37
38
|
* const timestamp = "reportedTime"
|
|
@@ -50,4 +51,4 @@ export declare const stream: (elastic: Client, query: SearchParams, timestampKey
|
|
|
50
51
|
timescale: number;
|
|
51
52
|
logProgress: boolean;
|
|
52
53
|
}) => EventEmitter;
|
|
53
|
-
//# sourceMappingURL=
|
|
54
|
+
//# sourceMappingURL=elastic.d.ts.map
|
package/elastic.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elastic.d.ts","sourceRoot":"","sources":["../src/elastic.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAC/F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAGtC;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,YAAmB,MAAM,YAAY,aAAa,EAAE,aAAa,MAAM,wBAAoB,QAAQ,MAAM,CAI5H,CAAC;AAEJ;;;;;GAKG;AACH,wBAAuB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,GAAG,cAAc,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAelH;AAED;;;;;GAKG;AACH,eAAO,MAAM,WAAW,YACd,MAAM,gBACD,mBAAmB,WACxB;IAAE,WAAW,CAAC,EAAE,OAAO,CAAC;IAAC,eAAe,EAAE,OAAO,CAAA;CAAE,KAC1D,QAAQ,IAAI,CAoCd,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,MAAM,YACT,MAAM,SACR,YAAY,gBACL,MAAM,YACX;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,OAAO,CAAA;CAAE,KAClD,YA0BF,CAAC"}
|
|
@@ -1,26 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.stream = exports.createIndex = exports.scrollSearch = exports.bulkIndex = void 0;
|
|
4
|
-
const events_1 = require("events");
|
|
1
|
+
import { EventEmitter } from "events";
|
|
5
2
|
/**
|
|
6
3
|
* Indexes a large amount of entities in a single query
|
|
7
|
-
* @param
|
|
8
|
-
* @param
|
|
4
|
+
* @param entities Array containing entities to index
|
|
5
|
+
* @param indexName Name of index to index entities.
|
|
9
6
|
*
|
|
10
|
-
* @returns
|
|
7
|
+
* @returns Promise that resolves time taken to index entities in ms.
|
|
11
8
|
*/
|
|
12
|
-
const bulkIndex = async (elastic, entities, indexName, refresh = false) => elastic.bulk({
|
|
9
|
+
export const bulkIndex = async (elastic, entities, indexName, refresh = false) => elastic.bulk({
|
|
13
10
|
refresh: refresh,
|
|
14
11
|
body: entities.flatMap((entity) => [{ index: { _index: indexName } }, entity]),
|
|
15
12
|
});
|
|
16
|
-
exports.bulkIndex = bulkIndex;
|
|
17
13
|
/**
|
|
18
14
|
* Queries elastic using `params`.
|
|
19
|
-
* @param
|
|
15
|
+
* @param params Query object.
|
|
20
16
|
*
|
|
21
17
|
* @returns Iterator that yeilds a result until query exhausted.
|
|
22
18
|
*/
|
|
23
|
-
async function* scrollSearch(elastic, params) {
|
|
19
|
+
export async function* scrollSearch(elastic, params) {
|
|
24
20
|
if (params.scroll === undefined)
|
|
25
21
|
throw new Error("params.scroll is required!");
|
|
26
22
|
let response = await elastic.search(params);
|
|
@@ -39,14 +35,13 @@ async function* scrollSearch(elastic, params) {
|
|
|
39
35
|
response = await nextResponse;
|
|
40
36
|
}
|
|
41
37
|
}
|
|
42
|
-
exports.scrollSearch = scrollSearch;
|
|
43
38
|
/**
|
|
44
39
|
* Function to recreate a elasticsearch index.
|
|
45
|
-
* @param
|
|
46
|
-
* @param
|
|
47
|
-
* @param
|
|
40
|
+
* @param elastic Elasticsearch client
|
|
41
|
+
* @param createParams Elastic parameters for creation of index
|
|
42
|
+
* @param options Options for creation
|
|
48
43
|
*/
|
|
49
|
-
const createIndex = async (elastic, createParams, options) => {
|
|
44
|
+
export const createIndex = async (elastic, createParams, options) => {
|
|
50
45
|
if (!options)
|
|
51
46
|
throw new Error("Options required!");
|
|
52
47
|
if (!createParams)
|
|
@@ -100,14 +95,13 @@ const createIndex = async (elastic, createParams, options) => {
|
|
|
100
95
|
process.stdout.write(" Created!\n");
|
|
101
96
|
}
|
|
102
97
|
};
|
|
103
|
-
exports.createIndex = createIndex;
|
|
104
98
|
/**
|
|
105
99
|
* Returns scrollsearch results in simulated time based on when result timestamp.
|
|
106
|
-
* @param
|
|
107
|
-
* @param
|
|
108
|
-
* @param
|
|
109
|
-
* @param
|
|
110
|
-
* @returns
|
|
100
|
+
* @param elastic Elasticsearch client to use
|
|
101
|
+
* @param query Query object to use for scroll search
|
|
102
|
+
* @param timestampKey Key to use for fetching timestamp from objects
|
|
103
|
+
* @param options.timescale Rate at which "time" progreesses
|
|
104
|
+
* @returns EventEmitter which emits 'entity' events containing resulting hits
|
|
111
105
|
* @example
|
|
112
106
|
* const elasticClient = new ElasticClient({ node: 'http://127.0.0.1:9200' })
|
|
113
107
|
* const timestamp = "reportedTime"
|
|
@@ -122,8 +116,8 @@ exports.createIndex = createIndex;
|
|
|
122
116
|
* }
|
|
123
117
|
* stream(elasticClient, query, timestamp, 2).on('entity', console.log) // <- Emitted results based on time moving at 2x normal speed
|
|
124
118
|
*/
|
|
125
|
-
const stream = (elastic, query, timestampKey, options = { timescale: 1, logProgress: false }) => {
|
|
126
|
-
const entityReceiver = new
|
|
119
|
+
export const stream = (elastic, query, timestampKey, options = { timescale: 1, logProgress: false }) => {
|
|
120
|
+
const entityReceiver = new EventEmitter();
|
|
127
121
|
(async () => {
|
|
128
122
|
if (options.timescale === undefined)
|
|
129
123
|
options.timescale = 1;
|
|
@@ -132,26 +126,25 @@ const stream = (elastic, query, timestampKey, options = { timescale: 1, logProgr
|
|
|
132
126
|
if (timestampKey === undefined)
|
|
133
127
|
throw new Error("timestampKey is undefined!");
|
|
134
128
|
let timeOffset;
|
|
135
|
-
let startDate;
|
|
129
|
+
let startDate = Date.now();
|
|
136
130
|
if (options.logProgress)
|
|
137
131
|
console.log("Beginning elastic scroll for entity streaming...");
|
|
138
132
|
for await (const result of scrollSearch(elastic, query)) {
|
|
139
133
|
if (options.logProgress)
|
|
140
134
|
console.log(`Query iteration finished, streaming ${result.hits.hits.length} entities.`);
|
|
141
135
|
if (timeOffset === undefined) {
|
|
142
|
-
timeOffset =
|
|
136
|
+
timeOffset = Date.now() - new Date(result.hits.hits[0]._source[timestampKey]).getTime();
|
|
143
137
|
startDate = Date.now();
|
|
144
138
|
}
|
|
145
139
|
for (const entity of result.hits.hits) {
|
|
146
140
|
const offsetEntityTime = new Date(entity._source[timestampKey]).getTime() + timeOffset;
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
141
|
+
while (Date.now() + (Date.now() - startDate) * options.timescale < offsetEntityTime) {
|
|
142
|
+
// Spin while waiting to emit next entity
|
|
143
|
+
}
|
|
150
144
|
entityReceiver.emit("entity", entity._source);
|
|
151
145
|
}
|
|
152
146
|
}
|
|
153
147
|
})();
|
|
154
148
|
return entityReceiver;
|
|
155
149
|
};
|
|
156
|
-
|
|
157
|
-
//# sourceMappingURL=index.js.map
|
|
150
|
+
//# sourceMappingURL=elastic.js.map
|
package/elastic.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
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|
|
4
4
|
*
|
|
5
|
-
* @returns
|
|
5
|
+
* @returns Coordinate in degrees, minutes & seconds
|
|
6
6
|
*/
|
|
7
7
|
export declare const toDMS: (coord: number) => {
|
|
8
8
|
degrees: number;
|
|
@@ -12,9 +12,8 @@ export declare const toDMS: (coord: number) => {
|
|
|
12
12
|
export declare const toRad: (val: number) => number;
|
|
13
13
|
/**
|
|
14
14
|
* Returns the distance between two LatLong's in kilometers
|
|
15
|
-
* @param
|
|
16
|
-
* @param
|
|
17
|
-
* @returns {number}
|
|
15
|
+
* @param pos1 [lat, long] coordinates
|
|
16
|
+
* @param pos2 [lat, long] coordinates
|
|
18
17
|
*/
|
|
19
18
|
export declare const getDistance: (pos1: [number, number], pos2: [number, number]) => number;
|
|
20
|
-
//# sourceMappingURL=
|
|
19
|
+
//# sourceMappingURL=geo.d.ts.map
|
package/geo.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geo.d.ts","sourceRoot":"","sources":["../src/geo.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,KAAK,UAAW,MAAM;aAAc,MAAM;aAAW,MAAM;aAAW,MAAM;CAOxF,CAAC;AAGF,eAAO,MAAM,KAAK,QAAS,MAAM,KAAG,MAA6B,CAAC;AAElE;;;;GAIG;AACH,eAAO,MAAM,WAAW,SAAU,CAAC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,KAAG,MAS5E,CAAC"}
|
package/geo.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts latitude or longitude to degrees, minutes & seconds.
|
|
3
|
+
* @param coord Latitude or longitude coordinate
|
|
4
|
+
*
|
|
5
|
+
* @returns Coordinate in degrees, minutes & seconds
|
|
6
|
+
*/
|
|
7
|
+
export const toDMS = (coord) => {
|
|
8
|
+
const absolute = Math.abs(coord);
|
|
9
|
+
const degrees = Math.floor(absolute);
|
|
10
|
+
const minutesNotTruncated = (absolute - degrees) * 60;
|
|
11
|
+
const minutes = Math.floor(minutesNotTruncated);
|
|
12
|
+
const seconds = Math.floor((minutesNotTruncated - minutes) * 60);
|
|
13
|
+
return { degrees, minutes, seconds };
|
|
14
|
+
};
|
|
15
|
+
// Converts numeric degrees to radians
|
|
16
|
+
export const toRad = (val) => val * Math.PI / 180;
|
|
17
|
+
/**
|
|
18
|
+
* Returns the distance between two LatLong's in kilometers
|
|
19
|
+
* @param pos1 [lat, long] coordinates
|
|
20
|
+
* @param pos2 [lat, long] coordinates
|
|
21
|
+
*/
|
|
22
|
+
export const getDistance = (pos1, pos2) => {
|
|
23
|
+
const [lat1, lon1] = pos1;
|
|
24
|
+
const [lat2, lon2] = pos2;
|
|
25
|
+
const R = 6371; // km
|
|
26
|
+
const dLat = toRad(lat2 - lat1);
|
|
27
|
+
const dLon = toRad(lon2 - lon1);
|
|
28
|
+
const a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.sin(dLon / 2) * Math.sin(dLon / 2) * Math.cos(toRad(lat1)) * Math.cos(toRad(lat2));
|
|
29
|
+
const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
|
30
|
+
return R * c;
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=geo.js.map
|
package/geo.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geo.js","sourceRoot":"","sources":["../src/geo.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,KAAa,EAAyD,EAAE;IAC7F,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACjC,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IACrC,MAAM,mBAAmB,GAAG,CAAC,QAAQ,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IACtD,MAAM,OAAO,GAAG,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AAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACzD,OAAO,CAAC,GAAG,CAAC,CAAC;AACd,CAAC,CAAC"}
|
package/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
export *
|
|
2
|
-
export *
|
|
3
|
-
export *
|
|
4
|
-
export *
|
|
5
|
-
export *
|
|
6
|
-
export *
|
|
7
|
-
export *
|
|
1
|
+
export * from "./conv.js";
|
|
2
|
+
export * from "./elastic.js";
|
|
3
|
+
export * from "./geo.js";
|
|
4
|
+
export * from "./logic.js";
|
|
5
|
+
export * from "./math.js";
|
|
6
|
+
export * from "./object.js";
|
|
7
|
+
export * from "./react.js";
|
|
8
|
+
export * from "./test.js";
|
|
9
|
+
export * from "./ts.js";
|
|
8
10
|
//# sourceMappingURL=index.d.ts.map
|
package/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC"}
|
package/index.js
CHANGED
|
@@ -1,34 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.logic = exports.conv = exports.object = exports.math = exports.jest = exports.geo = exports.elastic = void 0;
|
|
27
|
-
exports.elastic = __importStar(require("./elastic"));
|
|
28
|
-
exports.geo = __importStar(require("./geo"));
|
|
29
|
-
exports.jest = __importStar(require("./jest"));
|
|
30
|
-
exports.math = __importStar(require("./math"));
|
|
31
|
-
exports.object = __importStar(require("./object"));
|
|
32
|
-
exports.conv = __importStar(require("./conv"));
|
|
33
|
-
exports.logic = __importStar(require("./logic"));
|
|
1
|
+
export * from "./conv.js";
|
|
2
|
+
export * from "./elastic.js";
|
|
3
|
+
export * from "./geo.js";
|
|
4
|
+
export * from "./logic.js";
|
|
5
|
+
export * from "./math.js";
|
|
6
|
+
export * from "./object.js";
|
|
7
|
+
export * from "./react.js";
|
|
8
|
+
export * from "./test.js";
|
|
9
|
+
export * from "./ts.js";
|
|
34
10
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
export declare const sleep: typeof import("timers/promises").setTimeout;
|
|
3
3
|
export declare class Promize<T> {
|
|
4
4
|
p: Promise<T>;
|
|
@@ -20,4 +20,4 @@ export declare const retry: <T>(func: () => T | Promise<T>, options?: {
|
|
|
20
20
|
timeoutMultiplier?: number | undefined;
|
|
21
21
|
maxRetries?: number | undefined;
|
|
22
22
|
} | undefined) => () => Promise<T>;
|
|
23
|
-
//# sourceMappingURL=
|
|
23
|
+
//# sourceMappingURL=logic.d.ts.map
|
package/logic.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logic.d.ts","sourceRoot":"","sources":["../src/logic.ts"],"names":[],"mappings":";AACA,eAAO,MAAM,KAAK,6CAAwB,CAAC;AAE3C,qBAAa,OAAO,CAAC,CAAC;IACd,CAAC,EAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IACtB,GAAG,EAAG,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IACzB,GAAG,EAAG,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IAE7B;;;OAGG;gBACS,QAAQ,CAAC,EAAE,CAAC;IAIxB;;;OAGG;IACH,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,GAAG,IAAI;CAOvB;AAED,eAAO,MAAM,KAAK;qBAEW,OAAO,cAAc,MAAM,KAAK,IAAI;;;kCAoBhE,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { promisify } from "util";
|
|
2
|
+
export const sleep = promisify(setTimeout);
|
|
3
|
+
export class Promize {
|
|
4
|
+
p;
|
|
5
|
+
res;
|
|
6
|
+
rej;
|
|
7
7
|
/**
|
|
8
8
|
* Returns a new instance of a `Promize`, a externally resolvable Promise.
|
|
9
9
|
* @param resValue If not undefined, resolves the internal promise with given value on creation.
|
|
@@ -24,23 +24,22 @@ class Promize {
|
|
|
24
24
|
this.res(resValue);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
|
|
28
|
-
const retry = (func, options) => {
|
|
27
|
+
export const retry = (func, options) => {
|
|
29
28
|
let retryCount = 0;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
const maxRetries = options?.maxRetries ?? 10;
|
|
30
|
+
const timeoutMultiplier = options?.timeoutMultiplier ?? 1000;
|
|
31
|
+
const onErr = options?.onErr;
|
|
33
32
|
const tryAgain = async () => {
|
|
34
33
|
try {
|
|
35
34
|
return await func();
|
|
36
35
|
}
|
|
37
36
|
catch (e) {
|
|
38
|
-
if (
|
|
39
|
-
|
|
40
|
-
if (retryCount <
|
|
37
|
+
if (onErr !== undefined)
|
|
38
|
+
onErr(e, retryCount);
|
|
39
|
+
if (retryCount < maxRetries) {
|
|
41
40
|
retryCount++;
|
|
42
|
-
if (
|
|
43
|
-
await
|
|
41
|
+
if (timeoutMultiplier > 0)
|
|
42
|
+
await sleep(Math.random() * timeoutMultiplier);
|
|
44
43
|
return tryAgain();
|
|
45
44
|
}
|
|
46
45
|
throw e;
|
|
@@ -48,5 +47,4 @@ const retry = (func, options) => {
|
|
|
48
47
|
};
|
|
49
48
|
return tryAgain;
|
|
50
49
|
};
|
|
51
|
-
|
|
52
|
-
//# sourceMappingURL=index.js.map
|
|
50
|
+
//# sourceMappingURL=logic.js.map
|
package/logic.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logic.js","sourceRoot":"","sources":["../src/logic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM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gBAC1E,OAAO,QAAQ,EAAE,CAAC;aAClB;YACD,MAAM,CAAC,CAAC;SACR;IACF,CAAC,CAAC;IACF,OAAO,QAAQ,CAAC;AACjB,CAAC,CAAC"}
|
|
@@ -24,7 +24,7 @@ export declare const qRnd: (num: number, digits?: number) => number;
|
|
|
24
24
|
* @param num Number to pad.
|
|
25
25
|
* @param zeros Number of digits returned number should have.
|
|
26
26
|
*
|
|
27
|
-
* @returns
|
|
27
|
+
* @returns Padded number
|
|
28
28
|
* @example
|
|
29
29
|
* let paddedNumber = nPad(5)
|
|
30
30
|
* // paddedNumber = "05"
|
|
@@ -32,4 +32,4 @@ export declare const qRnd: (num: number, digits?: number) => number;
|
|
|
32
32
|
* // triplePaddedNumber = "006"
|
|
33
33
|
*/
|
|
34
34
|
export declare const nPad: (num: number | string, zeros?: number) => string;
|
|
35
|
-
//# sourceMappingURL=
|
|
35
|
+
//# sourceMappingURL=math.d.ts.map
|
package/math.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"math.d.ts","sourceRoot":"","sources":["../src/math.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,WAAY,MAAM,UAAU,MAAM,uBAAkB,MAO/E,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,KAAK,UAAW,MAAM,KAAG,MAGrC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,IAAI,QAAS,MAAM,sBAAe,MAG9C,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,IAAI,QAAS,MAAM,GAAG,MAAM,qBAAc,MAItD,CAAC"}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.nPad = exports.qRnd = exports.to360 = exports.angleDifference = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Calculates the difference between two angles (0°-360°), `angle1` & `angle2` returned result is in decimal degrees and is signed.
|
|
6
3
|
* @param angle1 First angle to compare
|
|
@@ -8,7 +5,7 @@ exports.nPad = exports.qRnd = exports.to360 = exports.angleDifference = void 0;
|
|
|
8
5
|
* @param signed If the result is signed or absolute
|
|
9
6
|
* @returns The difference in degrees
|
|
10
7
|
*/
|
|
11
|
-
const angleDifference = (angle1, angle2, signed = true) => {
|
|
8
|
+
export const angleDifference = (angle1, angle2, signed = true) => {
|
|
12
9
|
let difference = Math.abs(angle1 - angle2) % 360;
|
|
13
10
|
difference = difference > 180 ? 360 - difference : difference;
|
|
14
11
|
// Calculate sign
|
|
@@ -16,45 +13,41 @@ const angleDifference = (angle1, angle2, signed = true) => {
|
|
|
16
13
|
return (angle1 - angle2 >= 0 && angle1 - angle2 <= 180) || (angle1 - angle2 <= -180 && angle1 - angle2 >= -360) ? difference : difference * -1;
|
|
17
14
|
return difference;
|
|
18
15
|
};
|
|
19
|
-
exports.angleDifference = angleDifference;
|
|
20
16
|
/**
|
|
21
17
|
* Converts `angle` to 0°-360°
|
|
22
18
|
* @param angle
|
|
23
19
|
* @returns `angle` in 0-360°
|
|
24
20
|
*/
|
|
25
|
-
const to360 = (angle) => {
|
|
21
|
+
export const to360 = (angle) => {
|
|
26
22
|
angle = angle % 360;
|
|
27
23
|
return angle < 0 ? angle + 360 : angle;
|
|
28
24
|
};
|
|
29
|
-
exports.to360 = to360;
|
|
30
25
|
/**
|
|
31
26
|
* Rounds a number to `digits` decimal places.
|
|
32
27
|
* @param num Number to round
|
|
33
28
|
* @param digits Decimal places to round to
|
|
34
29
|
* @returns Rounded number
|
|
35
30
|
*/
|
|
36
|
-
const qRnd = (num, digits = 0) => {
|
|
31
|
+
export const qRnd = (num, digits = 0) => {
|
|
37
32
|
digits = 10 ** digits;
|
|
38
33
|
return ~~(num * digits) / digits;
|
|
39
34
|
};
|
|
40
|
-
exports.qRnd = qRnd;
|
|
41
35
|
/**
|
|
42
36
|
* Pad a number with 0's
|
|
43
37
|
* @param num Number to pad.
|
|
44
38
|
* @param zeros Number of digits returned number should have.
|
|
45
39
|
*
|
|
46
|
-
* @returns
|
|
40
|
+
* @returns Padded number
|
|
47
41
|
* @example
|
|
48
42
|
* let paddedNumber = nPad(5)
|
|
49
43
|
* // paddedNumber = "05"
|
|
50
44
|
* let triplePaddedNumber = nPad(6, 3)
|
|
51
45
|
* // triplePaddedNumber = "006"
|
|
52
46
|
*/
|
|
53
|
-
const nPad = (num, zeros = 2) => {
|
|
47
|
+
export const nPad = (num, zeros = 2) => {
|
|
54
48
|
num = num.toString();
|
|
55
49
|
while (num.length < zeros)
|
|
56
50
|
num = "0" + num;
|
|
57
51
|
return num;
|
|
58
52
|
};
|
|
59
|
-
|
|
60
|
-
//# sourceMappingURL=index.js.map
|
|
53
|
+
//# sourceMappingURL=math.js.map
|
package/math.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"math.js","sourceRoot":"","sources":["../src/math.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,MAAc,EAAE,MAAc,EAAE,MAAM,GAAG,IAAI,EAAU,EAAE;IACxF,IAAI,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,GAAG,CAAC;IACjD,UAAU,GAAG,UAAU,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC;IAE9D,iBAAiB;IACjB,IAAI,MAAM;QAAE,OAAO,CAAC,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,MAAM,GAAG,MAAM,IAAI,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,IAAI,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC;IAC3J,OAAO,UAAU,CAAC;AACnB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