motion-master-client 0.0.338 → 0.0.340

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/src/lib/util.d.ts CHANGED
@@ -1,72 +1,120 @@
1
- import { OperatorFunction } from 'rxjs';
2
1
  import { SystemLogLine } from './system-log-line';
3
2
  import { IMotionMasterMessage, MotionMasterMessage, Ipv4 } from './types';
4
3
  /**
5
- * Parses a single line of system log into a structured `SystemLogLine` object.
4
+ * Parses a single line of a system log into a structured `SystemLogLine` object.
6
5
  *
7
- * This function uses a regular expression to extract key parts of a log line: the timestamp, uptime, ID,
8
- * file, log level, and message. If the line matches the expected format, it returns an object with these
9
- * extracted properties. If the line doesn't match the format, it returns `undefined`.
6
+ * The function expects the log line to follow the format:
7
+ * ```
8
+ * YYYY-MM-DD HH:MM:SS.sss (uptime) [id]file:linelevel|message
9
+ * ```
10
+ * where the `id` part is optional.
10
11
  *
11
- * **Note:** The regular expression uses the `s` flag (dot-all mode), which may not be supported in all browsers.
12
- * This is suppressed with `@ts-ignore`.
12
+ * @param line - A single system log line as a string.
13
+ * @returns A `SystemLogLine` object with parsed fields, or `undefined` if the line cannot be parsed.
13
14
  *
14
- * @param {string} line - A single log line to parse.
15
- * @returns {SystemLogLine | undefined} A `SystemLogLine` object with the parsed data, or `undefined` if the line doesn't match the expected format.
15
+ * @example
16
+ * const line = '2025-12-05 10:01:23.123 (12:34:56) [device1]main.ts:123INFO|Started';
17
+ * const parsed = parseSystemLogLine(line);
18
+ * console.log(parsed?.date); // → Date object for '2025-12-05 10:01:23.123'
19
+ * console.log(parsed?.uptime); // → '12:34:56'
20
+ * console.log(parsed?.id); // → 'device1'
21
+ * console.log(parsed?.message); // → 'Started'
22
+ *
23
+ * @remarks
24
+ * - Uses a regular expression with the `s` (dotAll) flag; this may not be supported in all browsers.
25
+ * - If parsing fails, the function returns `undefined`.
26
+ * - The returned object includes the original line for reference.
16
27
  */
17
28
  export declare function parseSystemLogLine(line: string): SystemLogLine | undefined;
18
29
  /**
19
- * Parses the content of a system log into an array of `SystemLogLine` objects.
30
+ * Parses a system log string into an array of structured `SystemLogLine` objects.
31
+ *
32
+ * Each log entry is expected to start with a timestamp in the format `YYYY-MM-DD HH:MM:SS.sss`.
33
+ * The function uses a regular expression to split the content into individual log entries,
34
+ * then parses each entry into a `SystemLogLine` using `parseSystemLogLine`.
20
35
  *
21
- * This function uses a regular expression to split the log content into individual log lines. It then parses
22
- * each log line into a structured `SystemLogLine` object. The function also filters out any empty lines
23
- * and ensures only valid `SystemLogLine` objects are returned.
36
+ * @param content - The full system log content as a string.
37
+ * @returns An array of `SystemLogLine` objects representing each parsed log entry.
24
38
  *
25
- * **Note:** The regular expression uses the `s` flag, which may not be supported in all browsers. This is suppressed
26
- * with `@ts-ignore` to allow the use of dot-all mode in the regex.
39
+ * @example
40
+ * const logContent = '2025-12-05 10:01:23.123 Info: started\n2025-12-05 10:01:24.456 Error: failed';
41
+ * const lines = parseSystemLogContent(logContent);
42
+ * console.log(lines[0].timestamp); // → Date object for '2025-12-05 10:01:23.123'
27
43
  *
28
- * @param {string} content - The raw system log content to parse.
29
- * @returns {SystemLogLine[]} An array of `SystemLogLine` objects parsed from the log content.
44
+ * @remarks
45
+ * - Entries that cannot be parsed by `parseSystemLogLine` are ignored.
46
+ * - The regular expression uses the `s` (dotAll) flag, which may not be supported in all browsers;
47
+ * a `@ts-ignore` is used to suppress TypeScript warnings.
30
48
  */
31
49
  export declare function parseSystemLogContent(content: string): SystemLogLine[];
32
50
  /**
33
- * Differs two system log contents and returns the new content after the last matching line.
51
+ * Computes the difference between two system log contents by returning only the new lines
52
+ * added after the last known line from the old content.
53
+ *
54
+ * @param oldContent - The previous log content.
55
+ * @param newContent - The current log content.
56
+ * @param lineSeparator - Optional string used to split lines (default: `'\n'`).
57
+ * @param lastLineIndex - Optional index of the line in `oldContent` to use as the reference point
58
+ * (default: `-2`, i.e., the second-to-last line).
59
+ * @returns A string containing only the new lines from `newContent` that come after the reference
60
+ * line from `oldContent`. If the reference line is not found, returns the entire `newContent`.
34
61
  *
35
- * This function compares two log contents, `oldContent` and `newContent`, and returns the portion of
36
- * the `newContent` that appears after the last matching line in the `oldContent`. It splits the content
37
- * based on the provided `lineSeparator` and uses the `lastLineIndex` to find the line to compare.
62
+ * @example
63
+ * const oldLog = 'line1\nline2\nline3';
64
+ * const newLog = 'line1\nline2\nline3\nline4\nline5';
65
+ * const diff = diffSystemLogContents(oldLog, newLog);
66
+ * console.log(diff); // → 'line4\nline5'
38
67
  *
39
- * @param {string} oldContent - The original system log content to compare against.
40
- * @param {string} newContent - The new system log content to find the difference from the old content.
41
- * @param {string} [lineSeparator='\n'] - The character(s) used to separate lines in the content (default is newline).
42
- * @param {number} [lastLineIndex=-2] - The index of the last line to compare, negative index can be used (default is -2, the second-to-last line).
43
- * @returns {string} The portion of `newContent` after the last matching line in `oldContent`. If no match is found, returns the entire `newContent`.
68
+ * @remarks
69
+ * - Useful for incremental log processing where only newly appended lines need to be handled.
70
+ * - Handles negative indexing for selecting the reference line from the end of `oldContent`.
44
71
  */
45
72
  export declare function diffSystemLogContents(oldContent: string, newContent: string, lineSeparator?: string, lastLineIndex?: number): string;
46
73
  /**
47
- * Converts a `MotionMasterMessage` to a plain JavaScript object with specific field handling options.
74
+ * Converts a `MotionMasterMessage` instance into a plain JavaScript object with full defaults
75
+ * and JSON-compatible values.
48
76
  *
49
- * This function utilizes the `MotionMasterMessage.toObject()` method to create a plain object
50
- * from the provided `MotionMasterMessage`. It includes various options for how fields are processed,
51
- * such as handling arrays, default values, and JSON compatibility.
77
+ * The conversion uses `MotionMasterMessage.toObject` with options that:
78
+ * - Convert bytes fields to standard arrays.
79
+ * - Include default values for missing fields.
80
+ * - Initialize empty arrays for repeated fields and empty objects for map fields.
81
+ * - Include virtual `oneof` properties indicating which field is set.
82
+ * - Apply JSON-compatible conversions (e.g., NaN and Infinity to strings).
52
83
  *
53
- * **Note:** The function includes a fix for the error `TypeError: Cannot freeze array buffer views with elements in NgRx`.
84
+ * @param motionMasterMessage - The `MotionMasterMessage` instance to convert.
85
+ * @returns A plain object representation of the message with all fields populated and JSON-safe.
54
86
  *
55
- * @param {MotionMasterMessage} motionMasterMessage - The `MotionMasterMessage` instance to convert.
56
- * @returns {object} A plain JavaScript object representing the message with the specified options applied.
87
+ * @example
88
+ * const plainObject = createPlainObjectFromMotionMasterMessage(message);
89
+ * console.log(plainObject.status); // → fully populated status object
90
+ *
91
+ * @remarks
92
+ * - Useful for logging, serialization, or transferring messages over standard JSON APIs.
93
+ * - Ensures that all optional, repeated, and map fields are represented in the resulting object.
57
94
  */
58
95
  export declare function createPlainObjectFromMotionMasterMessage(motionMasterMessage: MotionMasterMessage): IMotionMasterMessage;
59
96
  /**
60
- * Converts a `motionMasterMessage` into a logger context object.
97
+ * Converts a `IMotionMasterMessage` into a structured context object suitable for logging.
98
+ *
99
+ * The resulting object includes:
100
+ * - `namespace`: a string identifying the logging context (default: `'reqResMessage'`),
101
+ * - `motionMasterMessage`: the original message,
102
+ * - `type`: either `'request'` or `'status'` depending on the message content,
103
+ * - `name`: a comma-separated string of the keys in the request or status object.
61
104
  *
62
- * This function extracts relevant details from the provided `motionMasterMessage` and
63
- * constructs an object to be used as context in logging. It determines whether the message
64
- * is a request or status type and stores the associated keys from the respective properties.
105
+ * @param motionMasterMessage - The Motion Master message to convert.
106
+ * @param namespace - Optional namespace for the logging context (default is `'reqResMessage'`).
107
+ * @returns An object containing the logging context with type, name, namespace, and original message.
108
+ *
109
+ * @example
110
+ * const context = convertMotionMasterMessageToLoggerContext(message, 'motion');
111
+ * console.log(context.namespace); // → 'motion'
112
+ * console.log(context.type); // → 'request' or 'status'
113
+ * console.log(context.name); // → comma-separated keys of the message content
65
114
  *
66
- * @param {IMotionMasterMessage} motionMasterMessage - The message to convert into a logger context.
67
- * @param {string} [namespace='reqResMessage'] - The namespace to associate with the context (default is 'reqResMessage').
68
- * @returns {object} An object containing the `namespace`, the original `motionMasterMessage`, the `type` of message
69
- * (either 'request' or 'status'), and the `name` (a string of keys from the request or status).
115
+ * @remarks
116
+ * - Determines type by checking the presence of `request` or `status` in the message.
117
+ * - Useful for structured logging or telemetry where message metadata is required.
70
118
  */
71
119
  export declare function convertMotionMasterMessageToLoggerContext(motionMasterMessage: IMotionMasterMessage, namespace?: string): {
72
120
  namespace: string;
@@ -75,153 +123,242 @@ export declare function convertMotionMasterMessageToLoggerContext(motionMasterMe
75
123
  name: string;
76
124
  };
77
125
  /**
78
- * Decodes a `Uint8Array` of text content into a string.
126
+ * Decodes a `Uint8Array` of bytes into a string using UTF-8 encoding.
79
127
  *
80
- * This function uses the `TextDecoder` API to decode the given `Uint8Array` (representing
81
- * text encoded in a specific encoding, such as UTF-8) into a readable string.
128
+ * @param content - The byte array to decode.
129
+ * @returns The decoded string representation of the input bytes.
82
130
  *
83
- * @param {Uint8Array} content - The `Uint8Array` containing the encoded text.
84
- * @returns {string} The decoded string.
131
+ * @example
132
+ * const bytes = new Uint8Array([72, 101, 108, 108, 111]);
133
+ * const text = decodeTextContent(bytes); // → "Hello"
134
+ *
135
+ * @remarks
136
+ * - Uses the standard `TextDecoder` API with UTF-8 encoding.
137
+ * - Creates a copy of the input array before decoding, so the original `Uint8Array` is not modified.
85
138
  */
86
139
  export declare function decodeTextContent(content: Uint8Array): string;
87
140
  /**
88
- * Resolves a promise after a specified delay.
141
+ * Returns a promise that resolves with the specified value after a given delay.
142
+ *
143
+ * @typeParam T - The type of the value to resolve.
144
+ * @param ms - The delay in milliseconds before the promise resolves.
145
+ * @param value - Optional value to resolve the promise with (defaults to `undefined` if not provided).
146
+ * @returns A `Promise` that resolves to `value` after `ms` milliseconds.
89
147
  *
90
- * This function returns a promise that resolves after the given number of milliseconds (`ms`),
91
- * optionally resolving with a provided value.
148
+ * @example
149
+ * await resolveAfter(1000, 'hello'); // resolves with 'hello' after 1 second
150
+ * await resolveAfter(500); // resolves with undefined after 0.5 seconds
92
151
  *
93
- * @param {number} ms - The number of milliseconds to wait before resolving the promise.
94
- * @param {unknown} [value] - The value to resolve with once the delay has passed. Default is `undefined`.
95
- * @returns {Promise<unknown>} A promise that resolves with the specified value after the delay.
152
+ * @remarks
153
+ * - Useful for simulating delays or asynchronous timing in tests or animations.
154
+ * - The function does not reject; it always resolves after the specified timeout.
96
155
  */
97
156
  export declare function resolveAfter<T>(ms: number, value?: T): Promise<T | undefined>;
98
157
  /**
99
- * Converts a 24-bit RGB color value to a format used by LED controllers.
158
+ * Converts a standard 24-bit RGB color value into a format suitable for certain LED controllers.
159
+ *
160
+ * The conversion swaps the red and green channels, producing a new 24-bit integer where:
161
+ * - Original green becomes the most significant byte,
162
+ * - Original red becomes the middle byte,
163
+ * - Original blue remains the least significant byte.
100
164
  *
101
- * This function takes an RGB color value (represented as a single 24-bit number)
102
- * and rearranges the color channels to match a typical LED color format, which may
103
- * require swapping the red and green channels.
165
+ * @param value - A 24-bit RGB color represented as a number (0xRRGGBB).
166
+ * @returns The converted 24-bit LED color value with swapped red and green channels.
167
+ *
168
+ * @example
169
+ * const rgb = 0x112233;
170
+ * const ledColor = convertRgbToLedColor(rgb); // → 0x221133
104
171
  *
105
- * @param {number} value - A 24-bit integer representing the RGB color value (0xRRGGBB).
106
- * @returns {number} A new integer representing the color in the LED format (0xGRB).
172
+ * @remarks
173
+ * - Useful when interfacing with LED hardware that expects a different channel ordering.
174
+ * - Input and output are standard JavaScript numbers representing 24-bit colors.
107
175
  */
108
176
  export declare function convertRgbToLedColor(value: number): number;
109
177
  /**
110
- * Generates a random hex color code with a specified brightness.
178
+ * Generates a random hexadecimal color string with a specified minimum brightness.
111
179
  *
112
- * This function creates a random color by generating random values for the red, green, and blue
113
- * color channels. The brightness parameter ensures the generated color is not too dark by
114
- * limiting the possible range for each channel.
180
+ * @param brightness - Minimum value for each RGB channel (0–255). Higher values produce lighter colors.
181
+ * @returns A random color string in `#RRGGBB` format.
115
182
  *
116
- * @param {number} brightness - The minimum brightness of the generated color. Should be between 0 and 255.
117
- * @returns {string} A random hex color code, in the form of `#RRGGBB`.
183
+ * @example
184
+ * createRandomColor(100); // '#c48f7a' (example output)
185
+ * createRandomColor(200); // → '#e5f0ff' (example output)
118
186
  *
119
- * @throws {Error} Throws an error if the brightness is not between 0 and 255.
187
+ * @remarks
188
+ * - Each color channel (red, green, blue) is independently randomized between `brightness` and 255.
189
+ * - Ensures that no channel is darker than the specified brightness.
190
+ * - Useful for generating visually distinct colors while avoiding very dark shades.
120
191
  */
121
192
  export declare function createRandomColor(brightness: number): string;
122
193
  /**
123
- * Retrieves the first key from a `Map` that matches a given value.
194
+ * Finds the first key in a `Map` that corresponds to the specified value.
195
+ *
196
+ * @typeParam K - The type of keys in the map.
197
+ * @typeParam V - The type of values in the map.
198
+ * @param map - The map to search.
199
+ * @param searchValue - The value to find the corresponding key for.
200
+ * @returns The first key whose value strictly equals (`===`) the searchValue, or `undefined` if no match is found.
124
201
  *
125
- * This function iterates over the entries of the map and returns the first key
126
- * whose corresponding value strictly equals (`===`) the provided `searchValue`.
127
- * If no matching value is found, it returns `undefined`.
202
+ * @example
203
+ * const myMap = new Map<string, number>([['a', 1], ['b', 2], ['c', 1]]);
204
+ * getMapKeyByValue(myMap, 1); // 'a'
205
+ * getMapKeyByValue(myMap, 3); // → undefined
128
206
  *
129
- * @template K - The type of the map's keys.
130
- * @template V - The type of the map's values.
131
- * @param {Map<K, V>} map - The map to search through.
132
- * @param {V} searchValue - The value to find the corresponding key for.
133
- * @returns {K | undefined} The key associated with the given value, or `undefined` if not found.
207
+ * @remarks
208
+ * - Only the first matching key is returned; subsequent keys with the same value are ignored.
209
+ * - Comparison uses strict equality (`===`).
134
210
  */
135
211
  export declare function getMapKeyByValue<K, V>(map: Map<K, V>, searchValue: V): K | undefined;
136
212
  /**
137
- * Finds and returns the duplicate elements in an array.
213
+ * Identifies duplicate elements in an array and returns them as a new array.
138
214
  *
139
- * This function iterates through the array and identifies elements that appear more than once.
140
- * It preserves only one instance of each duplicate in the output.
215
+ * @typeParam T - The type of elements in the array.
216
+ * @param arr - The array to check for duplicate values.
217
+ * @returns An array containing all elements that appear more than once in the input array.
218
+ * Each duplicate element appears only once in the returned array, regardless of how many times it occurs.
141
219
  *
142
- * @template T - The type of elements in the array.
143
- * @param {T[]} arr - The input array to search for duplicates.
144
- * @returns {T[]} An array of the duplicate elements, without repetition.
220
+ * @example
221
+ * findDuplicates([1, 2, 3, 2, 4, 3, 5]); // [2, 3]
222
+ * findDuplicates(['a', 'b', 'a', 'c']); // ['a']
223
+ *
224
+ * @remarks
225
+ * - Uses `Set` internally for efficient duplicate detection.
226
+ * - Preserves the insertion order of first detected duplicates.
145
227
  */
146
228
  export declare function findDuplicates<T>(arr: T[]): T[];
147
229
  /**
148
- * Converts a camelCase string into a space-separated lowercase string.
230
+ * Converts a camelCase or PascalCase string into a space-separated, lowercase string.
231
+ *
232
+ * @param str - The input string in camelCase or PascalCase format.
233
+ * @returns A new string where each uppercase letter is preceded by a space and all letters are lowercase.
149
234
  *
150
- * This function inserts spaces before each uppercase letter in the string (except the first one)
151
- * and converts the entire string to lowercase.
235
+ * @example
236
+ * camelCaseToWords('camelCaseString'); // 'camel case string'
237
+ * camelCaseToWords('PascalCase'); // → 'pascal case'
152
238
  *
153
- * @param {string} str - The camelCase string to convert.
154
- * @returns {string} A space-separated, lowercase version of the input string.
239
+ * @remarks
240
+ * - Useful for converting identifiers into human-readable words.
241
+ * - Leading spaces are preserved if the string starts with an uppercase letter.
155
242
  */
156
243
  export declare function camelCaseToWords(str: string): string;
157
244
  /**
158
- * Sets the specified bit in the given number to 0.
245
+ * Clears (sets to 0) the bit at the specified position in a number.
246
+ *
247
+ * @param value - The original number whose bit is to be cleared.
248
+ * @param position - Zero-based bit position to clear (0 = least-significant bit).
249
+ * @returns A new number with the bit at the specified position cleared to 0.
159
250
  *
160
- * @param {number} value - The original number whose bit will be modified.
161
- * @param {number} position - The position of the bit to set to 0 (0-based index).
162
- * @returns {number} The modified number with the specified bit set to 0.
251
+ * @example
252
+ * setBitLow(0b1011, 1); // 0b1001 (clears bit 1)
253
+ * setBitLow(0b1111, 3); // 0b0111 (clears bit 3)
254
+ *
255
+ * @remarks
256
+ * - Only the bit at the given position is affected; all other bits remain unchanged.
257
+ * - Works with any 32-bit integer representable in JavaScript.
163
258
  */
164
259
  export declare function setBitLow(value: number, position: number): number;
165
260
  /**
166
- * Sets the specified bit in the given number to 1.
261
+ * Sets (changes to 1) the bit at the specified position in a number.
262
+ *
263
+ * @param value - The original number whose bit is to be set.
264
+ * @param position - Zero-based bit position to set (0 = least-significant bit).
265
+ * @returns A new number with the bit at the specified position set to 1.
167
266
  *
168
- * @param {number} value - The original number whose bit will be modified.
169
- * @param {number} position - The position of the bit to set to 1 (0-based index).
170
- * @returns {number} The modified number with the specified bit set to 1.
267
+ * @example
268
+ * setBitHigh(0b1001, 1); // 0b1011 (sets bit 1)
269
+ * setBitHigh(0b0111, 3); // 0b1111 (sets bit 3)
270
+ *
271
+ * @remarks
272
+ * - Only the bit at the given position is affected; all other bits remain unchanged.
273
+ * - Works with any 32-bit integer representable in JavaScript.
171
274
  */
172
275
  export declare function setBitHigh(value: number, position: number): number;
173
276
  /**
174
- * Returns the bit at the specified position in a number.
277
+ * Retrieves the value of the bit at the specified position in a number.
175
278
  *
176
- * This function performs a bitwise AND operation to isolate the bit at the `k`th position.
177
- * If the bit is 0, it returns `0`; otherwise, it returns `1`.
279
+ * @param n - The number from which to retrieve the bit.
280
+ * @param k - Zero-based bit position to retrieve (0 = least-significant bit).
281
+ * @returns `1` if the bit at position `k` is set, otherwise `0`.
282
+ *
283
+ * @example
284
+ * getBit(0b1010, 1); // → 1 (bit 1 is set)
285
+ * getBit(0b1010, 0); // → 0 (bit 0 is clear)
178
286
  *
179
- * @param {number} n - The number whose bit will be retrieved.
180
- * @param {number} k - The position of the bit to retrieve (0-indexed).
181
- * @returns {number} The bit at position `k` (either 0 or 1).
287
+ * @remarks
288
+ * - Works with any 32-bit integer representable in JavaScript.
289
+ * - Does not modify the original number.
182
290
  */
183
291
  export declare function getBit(n: number, k: number): number;
184
292
  /**
185
- * Checks if the bit at the specified position is on (1).
293
+ * Checks whether the bit at the specified position in a number is set (1).
186
294
  *
187
- * This function performs a bitwise AND operation to check if the bit at the `k`th position is set to `1`.
188
- * It returns `true` if the bit is set, otherwise `false`.
295
+ * @param n - The number to check.
296
+ * @param k - Zero-based bit position to check (0 = least-significant bit).
297
+ * @returns `true` if the bit at position `k` is 1, otherwise `false`.
189
298
  *
190
- * @param {number} n - The number to check.
191
- * @param {number} k - The position of the bit to check (0-indexed).
192
- * @returns {boolean} `true` if the bit is on (1), otherwise `false`.
299
+ * @example
300
+ * isBitOn(0b1010, 1); // true (bit 1 is set)
301
+ * isBitOn(0b1010, 0); // false (bit 0 is clear)
302
+ *
303
+ * @remarks
304
+ * - Works with any 32-bit integer representable in JavaScript.
305
+ * - Does not modify the original number.
193
306
  */
194
307
  export declare function isBitOn(n: number, k: number): boolean;
195
308
  /**
196
- * Sets the bit at the specified position to 1.
309
+ * Sets (changes to 1) the bit at the specified position in a number.
197
310
  *
198
- * This function performs a bitwise OR operation to ensure that the bit at the `k`th position is set to `1`.
311
+ * The original number is not mutated; a new number is returned with the bit set.
199
312
  *
200
- * @param {number} n - The number in which the bit will be set.
201
- * @param {number} k - The position of the bit to set (0-indexed).
202
- * @returns {number} The new number with the bit at position `k` set to 1.
313
+ * @param n - The original number whose bit is to be set.
314
+ * @param k - Zero-based bit position to set (0 = least-significant bit).
315
+ * @returns A new number equal to `n` with bit `k` set.
316
+ *
317
+ * @example
318
+ * setBit(0b1001, 1); // → 0b1011 (sets bit 1)
319
+ * setBit(0b0111, 3); // → 0b1111 (sets bit 3)
320
+ *
321
+ * @remarks
322
+ * - Only the bit at position `k` is affected; all other bits remain unchanged.
323
+ * - Works with any 32-bit integer representable in JavaScript.
203
324
  */
204
325
  export declare function setBit(n: number, k: number): number;
205
326
  /**
206
- * Clears the bit at the specified position (sets it to 0).
327
+ * Clears (sets to 0) the bit at the specified position in a number.
328
+ *
329
+ * The original number is not mutated; a new number is returned with the bit cleared.
207
330
  *
208
- * This function performs a bitwise AND operation with a mask to ensure that the bit at the `k`th position is set to `0`.
331
+ * @param n - The original number whose bit is to be cleared.
332
+ * @param k - Zero-based bit position to clear (0 = least-significant bit).
333
+ * @returns A new number equal to `n` with bit `k` cleared.
334
+ *
335
+ * @example
336
+ * clearBit(0b1011, 1); // → 0b1001 (clears bit 1)
337
+ * clearBit(0b1111, 3); // → 0b0111 (clears bit 3)
209
338
  *
210
- * @param {number} n - The number in which the bit will be cleared.
211
- * @param {number} k - The position of the bit to clear (0-indexed).
212
- * @returns {number} The new number with the bit at position `k` cleared (set to 0).
339
+ * @remarks
340
+ * - Only the bit at position `k` is affected; all other bits remain unchanged.
341
+ * - Works with any 32-bit integer representable in JavaScript.
213
342
  */
214
343
  export declare function clearBit(n: number, k: number): number;
215
344
  /**
216
- * Updates the bit at the specified position with the given value.
345
+ * Updates the bit at position `k` in the given number `n` to the specified value.
217
346
  *
218
- * This function updates the bit at the `k`th position to either `1` or `0` depending on the provided value.
219
- * If the value is a boolean, it will be normalized to `1` (true) or `0` (false).
347
+ * The original number is not mutated; instead, a new number is returned with the bit updated.
348
+ *
349
+ * @param n - The original number whose bit is being modified.
350
+ * @param k - Zero-based bit position to update (0 = least-significant bit).
351
+ * @param value - Boolean or numeric value indicating whether the bit should be set (`true` / `1`)
352
+ * or cleared (`false` / `0`).
353
+ * @returns A new number equal to `n` with bit `k` updated.
354
+ *
355
+ * @example
356
+ * updateBit(0b1010, 1, true); // → 0b1011 (set bit 1)
357
+ * updateBit(0b1011, 3, false); // → 0b0011 (clear bit 3)
220
358
  *
221
- * @param {number} n - The number in which the bit will be updated.
222
- * @param {number} k - The position of the bit to update (0-indexed).
223
- * @param {number | boolean} value - The value to set the bit to (1 or 0, or `true`/`false`).
224
- * @returns {number} The new number with the bit at position `k` updated.
359
+ * @remarks
360
+ * - Values other than `0` or `false` result in bit being set to `1`.
361
+ * - Works with any 32-bit integer representable in JavaScript.
225
362
  */
226
363
  export declare function updateBit(n: number, k: number, value: number | boolean): number;
227
364
  /**
@@ -234,15 +371,20 @@ export declare function updateBit(n: number, k: number, value: number | boolean)
234
371
  */
235
372
  export declare function toFixedFormat(x: number | string, n?: number, rightTrimZero?: boolean): string;
236
373
  /**
237
- * Converts a `Blob` into a Base64-encoded string.
374
+ * Converts a `Blob` object into a Base64-encoded string.
238
375
  *
239
- * This function reads the provided `Blob` using `FileReader` and extracts the Base64 content
240
- * from the resulting data URL.
376
+ * @param blob - The `Blob` to convert.
377
+ * @returns A `Promise` that resolves to the Base64 string representation of the blob.
241
378
  *
242
- * @param {Blob} blob - The `Blob` to convert into a Base64 string.
243
- * @returns {Promise<string>} A promise that resolves with the Base64 string representation of the blob.
379
+ * @example
380
+ * const blob = new Blob(['Hello, world!'], { type: 'text/plain' });
381
+ * const base64 = await convertBlobToBase64(blob);
382
+ * console.log(base64); // → 'SGVsbG8sIHdvcmxkIQ=='
244
383
  *
245
- * @throws {string} If the blob cannot be read (e.g., due to an error), the promise rejects with an error message.
384
+ * @remarks
385
+ * - Internally uses `FileReader.readAsDataURL` to serialize the blob.
386
+ * - The returned Base64 string excludes the data URL prefix (e.g., `data:text/plain;base64,`).
387
+ * - The promise is rejected if the blob cannot be read.
246
388
  */
247
389
  export declare function convertBlobToBase64(blob: Blob): Promise<string>;
248
390
  /**
@@ -277,12 +419,17 @@ export declare function isElectronContext(): boolean;
277
419
  *
278
420
  * The function uses bitwise operations to isolate each byte from the 32-bit integer.
279
421
  *
280
- * @param {number} value - The 32-bit integer to be parsed.
281
- * @returns {Object} An object containing the extracted components:
422
+ * @param value - The 32-bit integer to be parsed.
423
+ * @returns An object containing the extracted components:
282
424
  * - `prefix`: The extracted prefix byte (8 bits).
283
425
  * - `numerator`: The extracted numerator byte (8 bits).
284
426
  * - `denominator`: The extracted denominator byte (8 bits).
285
427
  * - `reserved`: The extracted reserved byte (8 bits).
428
+ *
429
+ * @example
430
+ * const parsed = parseUnitValue(0x12345678);
431
+ * console.log(parsed);
432
+ * // → { prefix: 0x12, numerator: 0x34, denominator: 0x56, reserved: 0x78 }
286
433
  */
287
434
  export declare function parseUnitValue(value: number): {
288
435
  prefix: number;
@@ -293,21 +440,34 @@ export declare function parseUnitValue(value: number): {
293
440
  /**
294
441
  * Merges multiple `Uint8Array` instances into a single `Uint8Array`.
295
442
  *
296
- * This function concatenates all provided `Uint8Array` instances in the order they are given,
297
- * producing a new array containing all their bytes sequentially.
443
+ * @param ary - One or more `Uint8Array` instances to merge.
444
+ * @returns A new `Uint8Array` containing all elements from the input arrays in order.
445
+ *
446
+ * @example
447
+ * const a = new Uint8Array([1, 2]);
448
+ * const b = new Uint8Array([3, 4]);
449
+ * const merged = mergeUint8Arrays(a, b); // → Uint8Array [1, 2, 3, 4]
298
450
  *
299
- * @param {...Uint8Array[]} ary - An array of `Uint8Array` instances to merge.
300
- * @returns {Uint8Array} A new `Uint8Array` containing the concatenated bytes from all input arrays.
451
+ * @remarks
452
+ * - Preserves the order of elements from each input array.
453
+ * - Efficiently concatenates arrays without creating intermediate arrays for each element.
454
+ * - Returns a new `Uint8Array`; the input arrays are not modified.
301
455
  */
302
456
  export declare function mergeUint8Arrays(...ary: Uint8Array[]): Uint8Array;
303
457
  /**
304
- * Returns an array of unique items by removing duplicates from the given array.
458
+ * Returns a new array containing only the unique elements from the input array, preserving their order.
459
+ *
460
+ * @typeParam T - The type of elements in the array.
461
+ * @param items - The array from which to remove duplicates.
462
+ * @returns A new array with duplicate elements removed.
305
463
  *
306
- * This function utilizes the `Set` object to remove duplicate values, ensuring that only unique items
307
- * remain in the returned array. The order of items in the resulting array is preserved as in the input.
464
+ * @example
465
+ * uniqueItems([1, 2, 2, 3, 1]); // [1, 2, 3]
466
+ * uniqueItems(['a', 'b', 'a']); // → ['a', 'b']
308
467
  *
309
- * @param {Array<T>} items - The array from which duplicates will be removed.
310
- * @returns {Array<T>} A new array containing only the unique items from the input array.
468
+ * @remarks
469
+ * - Uses a `Set` internally for efficient duplicate removal.
470
+ * - Original array is not modified.
311
471
  */
312
472
  export declare function uniqueItems<T>(items: Array<T>): Array<T>;
313
473
  /**
@@ -450,27 +610,6 @@ export interface NotificationEntry {
450
610
  message: string;
451
611
  timeDifference: number;
452
612
  }
453
- /**
454
- * Custom RxJS operator that accumulates notifications with their
455
- * elapsed time relative to a provided start time.
456
- *
457
- * Each emitted notification string is converted into a `NotificationEntry`
458
- * object, and the operator maintains an array of all previous entries.
459
- *
460
- * @param startTime - The timestamp (in milliseconds) to use as the reference
461
- * point for calculating elapsed time. Typically obtained via `performance.now()`.
462
- * @returns An OperatorFunction that transforms an Observable of strings into
463
- * an Observable of `NotificationEntry[]`.
464
- *
465
- * @example
466
- * ```ts
467
- * const startTime = performance.now();
468
- * notifications$.pipe(withTimeDifference(startTime)).subscribe(entries => {
469
- * console.log(entries); // Array of NotificationEntry objects with elapsed time
470
- * });
471
- * ```
472
- */
473
- export declare function withTimeDifference(startTime: number): OperatorFunction<string, NotificationEntry[]>;
474
613
  /**
475
614
  * Analyzes an array of measured time durations and returns useful statistics
476
615
  * both for the full dataset and for outlier-filtered data.