pubo-utils 1.0.95 → 1.0.98

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.
@@ -7,5 +7,11 @@ type ProductsObject<T, F> = {
7
7
  type Factory<C> = (config: C, key: string) => any;
8
8
  export type CreateFactory<C, F> = <T>(apis: OptionsObject<T, C>) => ProductsObject<T, F>;
9
9
  export type SuperFactory = <C, F>(factory: Factory<C>) => CreateFactory<C, F>;
10
+ /**
11
+ * Creates a factory function that takes another factory function and returns a new function that creates a product object based on the options passed in.
12
+ *
13
+ * @param {SuperFactory} factory - the factory function to be used in creating the product object
14
+ * @return {(options: any) => any} the new factory function that creates the product object
15
+ */
10
16
  export declare const superFactory: SuperFactory;
11
17
  export {};
@@ -14,6 +14,12 @@ var __values = this && this.__values || function (o) {
14
14
  };
15
15
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
16
16
  };
17
+ /**
18
+ * Creates a factory function that takes another factory function and returns a new function that creates a product object based on the options passed in.
19
+ *
20
+ * @param {SuperFactory} factory - the factory function to be used in creating the product object
21
+ * @return {(options: any) => any} the new factory function that creates the product object
22
+ */
17
23
  export var superFactory = function superFactory(factory) {
18
24
  return function (options) {
19
25
  var e_1, _a;
@@ -15,8 +15,19 @@ export declare class SensorDataFilter {
15
15
  });
16
16
  filter(n: number): number;
17
17
  private calc;
18
+ /**
19
+ * A function to calculate the most frequent element in the 'tmp' array and its frequency.
20
+ *
21
+ * @return {object} An object containing the most frequent element and its frequency.
22
+ */
18
23
  private getMostNumberOfTmp;
19
24
  }
25
+ /**
26
+ * Splits the input string using the specified split symbol and returns an array of substrings.
27
+ *
28
+ * @param {string} str - the input string to be split
29
+ * @return {string[]} an array of substrings
30
+ */
20
31
  export declare class StringSplit {
21
32
  private readonly _splitSymbol;
22
33
  private _cache;
@@ -80,6 +80,11 @@ var SensorDataFilter = /** @class */function () {
80
80
  }
81
81
  return res;
82
82
  };
83
+ /**
84
+ * A function to calculate the most frequent element in the 'tmp' array and its frequency.
85
+ *
86
+ * @return {object} An object containing the most frequent element and its frequency.
87
+ */
83
88
  SensorDataFilter.prototype.getMostNumberOfTmp = function () {
84
89
  var e_1, _a;
85
90
  var a = {};
@@ -117,6 +122,12 @@ var SensorDataFilter = /** @class */function () {
117
122
  return SensorDataFilter;
118
123
  }();
119
124
  export { SensorDataFilter };
125
+ /**
126
+ * Splits the input string using the specified split symbol and returns an array of substrings.
127
+ *
128
+ * @param {string} str - the input string to be split
129
+ * @return {string[]} an array of substrings
130
+ */
120
131
  var StringSplit = /** @class */function () {
121
132
  function StringSplit(splitSymbol) {
122
133
  this._cache = '';
@@ -1,5 +1,21 @@
1
+ /**
2
+ * Executes the given callback function in a loop with the specified time interval.
3
+ *
4
+ * @param {Function} cb - The callback function to be executed in the loop. It takes a stop function as a parameter.
5
+ * @param {number} time - The time interval in milliseconds for the loop.
6
+ * @return {Function} The stop function that can be used to stop the loop.
7
+ */
1
8
  export declare const loop: (cb: (stop: () => void) => Promise<void>, time: number) => () => void;
2
9
  type WaitForBool = () => boolean | Promise<boolean>;
10
+ /**
11
+ * Waits for a boolean condition to be true, with optional timeouts for the check and the overall wait.
12
+ *
13
+ * @param {WaitForBool} bool - the boolean condition to wait for
14
+ * @param {Object} options - optional parameters for checkTime and timeout
15
+ * @param {number} options.checkTime - the time interval for checking the boolean condition (default is 100)
16
+ * @param {number} options.timeout - the maximum time to wait for the boolean condition to be true
17
+ * @return {Promise<any>} a promise that resolves when the boolean condition is true or rejects with 'timeout' if the timeout is reached
18
+ */
3
19
  export declare const waitFor: (bool: WaitForBool, { checkTime, timeout }?: {
4
20
  checkTime?: number | undefined;
5
21
  timeout?: number | undefined;
package/es/loop/index.js CHANGED
@@ -114,6 +114,13 @@ var __generator = this && this.__generator || function (thisArg, body) {
114
114
  }
115
115
  };
116
116
  import { sleep } from '../sleep';
117
+ /**
118
+ * Executes the given callback function in a loop with the specified time interval.
119
+ *
120
+ * @param {Function} cb - The callback function to be executed in the loop. It takes a stop function as a parameter.
121
+ * @param {number} time - The time interval in milliseconds for the loop.
122
+ * @return {Function} The stop function that can be used to stop the loop.
123
+ */
117
124
  export var loop = function loop(cb, time) {
118
125
  var onOff = true;
119
126
  var stop = function stop() {
@@ -144,6 +151,15 @@ export var loop = function loop(cb, time) {
144
151
  _fn();
145
152
  return stop;
146
153
  };
154
+ /**
155
+ * Waits for a boolean condition to be true, with optional timeouts for the check and the overall wait.
156
+ *
157
+ * @param {WaitForBool} bool - the boolean condition to wait for
158
+ * @param {Object} options - optional parameters for checkTime and timeout
159
+ * @param {number} options.checkTime - the time interval for checking the boolean condition (default is 100)
160
+ * @param {number} options.timeout - the maximum time to wait for the boolean condition to be true
161
+ * @return {Promise<any>} a promise that resolves when the boolean condition is true or rejects with 'timeout' if the timeout is reached
162
+ */
147
163
  export var waitFor = function waitFor(bool, _a) {
148
164
  var _b = _a === void 0 ? {} : _a,
149
165
  checkTime = _b.checkTime,
@@ -1,2 +1,14 @@
1
+ /**
2
+ * Generates a random string of specified length.
3
+ *
4
+ * @param {number} n - The length of the random string to generate
5
+ * @return {string} The randomly generated string
6
+ */
1
7
  export declare const random: (n?: number) => string;
8
+ /**
9
+ * Generates a random number within the specified range.
10
+ *
11
+ * @param {number[]} range - The range within which to generate the random number.
12
+ * @return {number} The randomly generated number within the specified range.
13
+ */
2
14
  export declare const randomRangeNum: (range: any) => number;
@@ -1,3 +1,9 @@
1
+ /**
2
+ * Generates a random string of specified length.
3
+ *
4
+ * @param {number} n - The length of the random string to generate
5
+ * @return {string} The randomly generated string
6
+ */
1
7
  var __read = this && this.__read || function (o, n) {
2
8
  var m = typeof Symbol === "function" && o[Symbol.iterator];
3
9
  if (!m) return o;
@@ -49,6 +55,12 @@ export var random = function random(n) {
49
55
  }
50
56
  return res;
51
57
  };
58
+ /**
59
+ * Generates a random number within the specified range.
60
+ *
61
+ * @param {number[]} range - The range within which to generate the random number.
62
+ * @return {number} The randomly generated number within the specified range.
63
+ */
52
64
  export var randomRangeNum = function randomRangeNum(range) {
53
65
  var size = Math.abs(range[1] - range[0]);
54
66
  return Math.random() * size + Math.min.apply(Math, __spreadArray([], __read(range), false));
@@ -1 +1,7 @@
1
+ /**
2
+ * Asynchronous function to sleep for a specified amount of time.
3
+ *
4
+ * @param {number} time - The duration in milliseconds to sleep
5
+ * @return {Promise<void>} A promise that resolves after the specified time
6
+ */
1
7
  export declare const sleep: (time: number) => Promise<void>;
package/es/sleep/index.js CHANGED
@@ -1,3 +1,9 @@
1
+ /**
2
+ * Asynchronous function to sleep for a specified amount of time.
3
+ *
4
+ * @param {number} time - The duration in milliseconds to sleep
5
+ * @return {Promise<void>} A promise that resolves after the specified time
6
+ */
1
7
  var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
2
8
  function adopt(value) {
3
9
  return value instanceof P ? value : new P(function (resolve) {
@@ -7,5 +7,11 @@ type ProductsObject<T, F> = {
7
7
  type Factory<C> = (config: C, key: string) => any;
8
8
  export type CreateFactory<C, F> = <T>(apis: OptionsObject<T, C>) => ProductsObject<T, F>;
9
9
  export type SuperFactory = <C, F>(factory: Factory<C>) => CreateFactory<C, F>;
10
+ /**
11
+ * Creates a factory function that takes another factory function and returns a new function that creates a product object based on the options passed in.
12
+ *
13
+ * @param {SuperFactory} factory - the factory function to be used in creating the product object
14
+ * @return {(options: any) => any} the new factory function that creates the product object
15
+ */
10
16
  export declare const superFactory: SuperFactory;
11
17
  export {};
@@ -20,6 +20,12 @@ Object.defineProperty(exports, "__esModule", {
20
20
  value: true
21
21
  });
22
22
  exports.superFactory = void 0;
23
+ /**
24
+ * Creates a factory function that takes another factory function and returns a new function that creates a product object based on the options passed in.
25
+ *
26
+ * @param {SuperFactory} factory - the factory function to be used in creating the product object
27
+ * @return {(options: any) => any} the new factory function that creates the product object
28
+ */
23
29
  var superFactory = function superFactory(factory) {
24
30
  return function (options) {
25
31
  var e_1, _a;
@@ -15,8 +15,19 @@ export declare class SensorDataFilter {
15
15
  });
16
16
  filter(n: number): number;
17
17
  private calc;
18
+ /**
19
+ * A function to calculate the most frequent element in the 'tmp' array and its frequency.
20
+ *
21
+ * @return {object} An object containing the most frequent element and its frequency.
22
+ */
18
23
  private getMostNumberOfTmp;
19
24
  }
25
+ /**
26
+ * Splits the input string using the specified split symbol and returns an array of substrings.
27
+ *
28
+ * @param {string} str - the input string to be split
29
+ * @return {string[]} an array of substrings
30
+ */
20
31
  export declare class StringSplit {
21
32
  private readonly _splitSymbol;
22
33
  private _cache;
@@ -86,6 +86,11 @@ var SensorDataFilter = /** @class */function () {
86
86
  }
87
87
  return res;
88
88
  };
89
+ /**
90
+ * A function to calculate the most frequent element in the 'tmp' array and its frequency.
91
+ *
92
+ * @return {object} An object containing the most frequent element and its frequency.
93
+ */
89
94
  SensorDataFilter.prototype.getMostNumberOfTmp = function () {
90
95
  var e_1, _a;
91
96
  var a = {};
@@ -123,6 +128,12 @@ var SensorDataFilter = /** @class */function () {
123
128
  return SensorDataFilter;
124
129
  }();
125
130
  exports.SensorDataFilter = SensorDataFilter;
131
+ /**
132
+ * Splits the input string using the specified split symbol and returns an array of substrings.
133
+ *
134
+ * @param {string} str - the input string to be split
135
+ * @return {string[]} an array of substrings
136
+ */
126
137
  var StringSplit = /** @class */function () {
127
138
  function StringSplit(splitSymbol) {
128
139
  this._cache = '';
@@ -1,5 +1,21 @@
1
+ /**
2
+ * Executes the given callback function in a loop with the specified time interval.
3
+ *
4
+ * @param {Function} cb - The callback function to be executed in the loop. It takes a stop function as a parameter.
5
+ * @param {number} time - The time interval in milliseconds for the loop.
6
+ * @return {Function} The stop function that can be used to stop the loop.
7
+ */
1
8
  export declare const loop: (cb: (stop: () => void) => Promise<void>, time: number) => () => void;
2
9
  type WaitForBool = () => boolean | Promise<boolean>;
10
+ /**
11
+ * Waits for a boolean condition to be true, with optional timeouts for the check and the overall wait.
12
+ *
13
+ * @param {WaitForBool} bool - the boolean condition to wait for
14
+ * @param {Object} options - optional parameters for checkTime and timeout
15
+ * @param {number} options.checkTime - the time interval for checking the boolean condition (default is 100)
16
+ * @param {number} options.timeout - the maximum time to wait for the boolean condition to be true
17
+ * @return {Promise<any>} a promise that resolves when the boolean condition is true or rejects with 'timeout' if the timeout is reached
18
+ */
3
19
  export declare const waitFor: (bool: WaitForBool, { checkTime, timeout }?: {
4
20
  checkTime?: number | undefined;
5
21
  timeout?: number | undefined;
package/lib/loop/index.js CHANGED
@@ -120,6 +120,13 @@ Object.defineProperty(exports, "__esModule", {
120
120
  });
121
121
  exports.waitFor = exports.loop = void 0;
122
122
  var sleep_1 = require("../sleep");
123
+ /**
124
+ * Executes the given callback function in a loop with the specified time interval.
125
+ *
126
+ * @param {Function} cb - The callback function to be executed in the loop. It takes a stop function as a parameter.
127
+ * @param {number} time - The time interval in milliseconds for the loop.
128
+ * @return {Function} The stop function that can be used to stop the loop.
129
+ */
123
130
  var loop = function loop(cb, time) {
124
131
  var onOff = true;
125
132
  var stop = function stop() {
@@ -151,6 +158,15 @@ var loop = function loop(cb, time) {
151
158
  return stop;
152
159
  };
153
160
  exports.loop = loop;
161
+ /**
162
+ * Waits for a boolean condition to be true, with optional timeouts for the check and the overall wait.
163
+ *
164
+ * @param {WaitForBool} bool - the boolean condition to wait for
165
+ * @param {Object} options - optional parameters for checkTime and timeout
166
+ * @param {number} options.checkTime - the time interval for checking the boolean condition (default is 100)
167
+ * @param {number} options.timeout - the maximum time to wait for the boolean condition to be true
168
+ * @return {Promise<any>} a promise that resolves when the boolean condition is true or rejects with 'timeout' if the timeout is reached
169
+ */
154
170
  var waitFor = function waitFor(bool, _a) {
155
171
  var _b = _a === void 0 ? {} : _a,
156
172
  checkTime = _b.checkTime,
@@ -1,2 +1,14 @@
1
+ /**
2
+ * Generates a random string of specified length.
3
+ *
4
+ * @param {number} n - The length of the random string to generate
5
+ * @return {string} The randomly generated string
6
+ */
1
7
  export declare const random: (n?: number) => string;
8
+ /**
9
+ * Generates a random number within the specified range.
10
+ *
11
+ * @param {number[]} range - The range within which to generate the random number.
12
+ * @return {number} The randomly generated number within the specified range.
13
+ */
2
14
  export declare const randomRangeNum: (range: any) => number;
@@ -1,5 +1,11 @@
1
1
  "use strict";
2
2
 
3
+ /**
4
+ * Generates a random string of specified length.
5
+ *
6
+ * @param {number} n - The length of the random string to generate
7
+ * @return {string} The randomly generated string
8
+ */
3
9
  var __read = this && this.__read || function (o, n) {
4
10
  var m = typeof Symbol === "function" && o[Symbol.iterator];
5
11
  if (!m) return o;
@@ -56,6 +62,12 @@ var random = function random(n) {
56
62
  return res;
57
63
  };
58
64
  exports.random = random;
65
+ /**
66
+ * Generates a random number within the specified range.
67
+ *
68
+ * @param {number[]} range - The range within which to generate the random number.
69
+ * @return {number} The randomly generated number within the specified range.
70
+ */
59
71
  var randomRangeNum = function randomRangeNum(range) {
60
72
  var size = Math.abs(range[1] - range[0]);
61
73
  return Math.random() * size + Math.min.apply(Math, __spreadArray([], __read(range), false));
@@ -1 +1,7 @@
1
+ /**
2
+ * Asynchronous function to sleep for a specified amount of time.
3
+ *
4
+ * @param {number} time - The duration in milliseconds to sleep
5
+ * @return {Promise<void>} A promise that resolves after the specified time
6
+ */
1
7
  export declare const sleep: (time: number) => Promise<void>;
@@ -1,5 +1,11 @@
1
1
  "use strict";
2
2
 
3
+ /**
4
+ * Asynchronous function to sleep for a specified amount of time.
5
+ *
6
+ * @param {number} time - The duration in milliseconds to sleep
7
+ * @return {Promise<void>} A promise that resolves after the specified time
8
+ */
3
9
  var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
4
10
  function adopt(value) {
5
11
  return value instanceof P ? value : new P(function (resolve) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pubo-utils",
3
- "version": "1.0.95",
3
+ "version": "1.0.98",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -18,5 +18,5 @@
18
18
  "engines": {
19
19
  "node": ">=8.0.0"
20
20
  },
21
- "gitHead": "d626fb18ee0b20c0377396a0f2c3aa983ebb3e59"
21
+ "gitHead": "4f1b1c6ff194adccef99ba0cead655b0ce82a406"
22
22
  }