chore: update to version 14.0.11 and align website URLs

This commit is contained in:
2026-01-11 11:34:13 +03:00
parent ef74383349
commit 19c8d69bd8
1499 changed files with 53633 additions and 89 deletions
+15
View File
@@ -0,0 +1,15 @@
/**
* @name arrayChunk
* @summary Split T[] into T[][] based on the defind size
* @description
* Returns a set ao arrays based on the chunksize
* @example
* <BR>
*
* ```javascript
* import { arrayChunk } from '@pezkuwi/util';
*
* arrayChunk([1, 2, 3, 4, 5]); // [[1, 2], [3, 4], [5]]
* ```
*/
export declare function arrayChunk<T>(array: T[], chunkSize: number): T[][];
+27
View File
@@ -0,0 +1,27 @@
/**
* @name arrayChunk
* @summary Split T[] into T[][] based on the defind size
* @description
* Returns a set ao arrays based on the chunksize
* @example
* <BR>
*
* ```javascript
* import { arrayChunk } from '@pezkuwi/util';
*
* arrayChunk([1, 2, 3, 4, 5]); // [[1, 2], [3, 4], [5]]
* ```
*/
export function arrayChunk(array, chunkSize) {
const outputSize = Math.ceil(array.length / chunkSize);
// shortcut for the single-split case
if (outputSize === 1) {
return [array];
}
const output = Array(outputSize);
for (let i = 0; i < outputSize; i++) {
const offset = i * chunkSize;
output[i] = array.slice(offset, offset + chunkSize);
}
return output;
}
+16
View File
@@ -0,0 +1,16 @@
/**
* @name arrayFilter
* @summary Filters undefined and (optionally) null values from an array
* @description
* Returns a new array with all `undefined` values removed. Optionally, when `allowNulls = false`, it removes the `null` values as well
* @example
* <BR>
*
* ```javascript
* import { arrayFilter } from '@pezkuwi/util';
*
* arrayFilter([0, void 0, true, null, false, '']); // [0, true, null, false, '']
* arrayFilter([0, void 0, true, null, false, ''], false); // [0, true, false, '']
* ```
*/
export declare function arrayFilter<T = unknown>(array: readonly (T | null | undefined)[], allowNulls?: boolean): T[];
+19
View File
@@ -0,0 +1,19 @@
/**
* @name arrayFilter
* @summary Filters undefined and (optionally) null values from an array
* @description
* Returns a new array with all `undefined` values removed. Optionally, when `allowNulls = false`, it removes the `null` values as well
* @example
* <BR>
*
* ```javascript
* import { arrayFilter } from '@pezkuwi/util';
*
* arrayFilter([0, void 0, true, null, false, '']); // [0, true, null, false, '']
* arrayFilter([0, void 0, true, null, false, ''], false); // [0, true, false, '']
* ```
*/
export function arrayFilter(array, allowNulls = true) {
return array.filter((v) => v !== undefined &&
(allowNulls || v !== null));
}
+15
View File
@@ -0,0 +1,15 @@
/**
* @name arrayFlatten
* @summary Merge T[][] into T[]
* @description
* Returns a new array with all arrays merged into one
* @example
* <BR>
*
* ```javascript
* import { arrayFlatten } from '@pezkuwi/util';
*
* arrayFlatten([[1, 2], [3, 4], [5]]); // [1, 2, 3, 4, 5]
* ```
*/
export declare function arrayFlatten<T>(arrays: readonly T[][]): T[];
+39
View File
@@ -0,0 +1,39 @@
/**
* @name arrayFlatten
* @summary Merge T[][] into T[]
* @description
* Returns a new array with all arrays merged into one
* @example
* <BR>
*
* ```javascript
* import { arrayFlatten } from '@pezkuwi/util';
*
* arrayFlatten([[1, 2], [3, 4], [5]]); // [1, 2, 3, 4, 5]
* ```
*/
export function arrayFlatten(arrays) {
const num = arrays.length;
// shortcuts for the empty & single-entry case
if (num === 0) {
return [];
}
else if (num === 1) {
return arrays[0];
}
// pre-allocate based on the combined size
let size = 0;
for (let i = 0; i < num; i++) {
size += arrays[i].length;
}
const output = new Array(size);
let i = -1;
for (let j = 0; j < num; j++) {
const a = arrays[j];
// instead of pushing, we just set the entries
for (let e = 0, count = a.length; e < count; e++) {
output[++i] = a[e];
}
}
return output;
}
+10
View File
@@ -0,0 +1,10 @@
/**
* @summary Utility methods that operates on arrays
*/
export { arrayChunk } from './chunk.js';
export { arrayFilter } from './filter.js';
export { arrayFlatten } from './flatten.js';
export { arrayRange } from './range.js';
export { arrayShuffle } from './shuffle.js';
export { arrayUnzip } from './unzip.js';
export { arrayZip } from './zip.js';
+10
View File
@@ -0,0 +1,10 @@
/**
* @summary Utility methods that operates on arrays
*/
export { arrayChunk } from './chunk.js';
export { arrayFilter } from './filter.js';
export { arrayFlatten } from './flatten.js';
export { arrayRange } from './range.js';
export { arrayShuffle } from './shuffle.js';
export { arrayUnzip } from './unzip.js';
export { arrayZip } from './zip.js';
+16
View File
@@ -0,0 +1,16 @@
/**
* @name arrayRange
* @summary Returns a range of numbers ith the size and the specified offset
* @description
* Returns a new array of numbers with the specific size. Optionally, when `startAt`, is provided, it generates the range to start at a specific value.
* @example
* <BR>
*
* ```javascript
* import { arrayRange } from '@pezkuwi/util';
*
* arrayRange(5); // [0, 1, 2, 3, 4]
* arrayRange(3, 5); // [5, 6, 7]
* ```
*/
export declare function arrayRange(size: number, startAt?: number): number[];
+25
View File
@@ -0,0 +1,25 @@
/**
* @name arrayRange
* @summary Returns a range of numbers ith the size and the specified offset
* @description
* Returns a new array of numbers with the specific size. Optionally, when `startAt`, is provided, it generates the range to start at a specific value.
* @example
* <BR>
*
* ```javascript
* import { arrayRange } from '@pezkuwi/util';
*
* arrayRange(5); // [0, 1, 2, 3, 4]
* arrayRange(3, 5); // [5, 6, 7]
* ```
*/
export function arrayRange(size, startAt = 0) {
if (size <= 0) {
throw new Error('Expected non-zero, positive number as a range size');
}
const result = new Array(size);
for (let i = 0; i < size; i++) {
result[i] = i + startAt;
}
return result;
}
+5
View File
@@ -0,0 +1,5 @@
/**
* @name arrayShuffle
* @description Shuffles the input array (unlike sort, this is not done in-place)
*/
export declare function arrayShuffle<T>(input: readonly T[]): T[];
+19
View File
@@ -0,0 +1,19 @@
/**
* @name arrayShuffle
* @description Shuffles the input array (unlike sort, this is not done in-place)
*/
export function arrayShuffle(input) {
const result = input.slice();
let curr = result.length;
// noop for the single entry
if (curr === 1) {
return result;
}
while (curr !== 0) {
// ~~ is more performant than Math.floor
const rand = ~~(Math.random() * curr);
curr--;
[result[curr], result[rand]] = [result[rand], result[curr]];
}
return result;
}
+5
View File
@@ -0,0 +1,5 @@
/**
* @name arrayUnzip
* @description Splits a single [K, V][] into [K[], V[]]
*/
export declare function arrayUnzip<K, V>(entries: readonly [K, V][]): [K[], V[]];
+13
View File
@@ -0,0 +1,13 @@
/**
* @name arrayUnzip
* @description Splits a single [K, V][] into [K[], V[]]
*/
export function arrayUnzip(entries) {
const count = entries.length;
const keys = new Array(count);
const values = new Array(count);
for (let i = 0; i < count; i++) {
[keys[i], values[i]] = entries[i];
}
return [keys, values];
}
+5
View File
@@ -0,0 +1,5 @@
/**
* @name arrayZip
* @description Combines 2 distinct key/value arrays into a single [K, V] array
*/
export declare function arrayZip<K, V>(keys: readonly K[], values: readonly V[]): [K, V][];
+12
View File
@@ -0,0 +1,12 @@
/**
* @name arrayZip
* @description Combines 2 distinct key/value arrays into a single [K, V] array
*/
export function arrayZip(keys, values) {
const count = keys.length;
const result = new Array(count);
for (let i = 0; i < count; i++) {
result[i] = [keys[i], values[i]];
}
return result;
}