inibase 1.1.9 → 1.1.11
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/README.md +3 -1
- package/dist/index.d.ts +12 -11
- package/dist/index.js +69 -29
- package/dist/utils.js +3 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -97,6 +97,7 @@ interface {
|
|
|
97
97
|
compression: boolean;
|
|
98
98
|
cache: boolean;
|
|
99
99
|
prepend: boolean;
|
|
100
|
+
decodeID: boolean;
|
|
100
101
|
}
|
|
101
102
|
```
|
|
102
103
|
|
|
@@ -236,7 +237,8 @@ const db = new Inibase("/databaseName");
|
|
|
236
237
|
const userTableConfig = {
|
|
237
238
|
compression: true,
|
|
238
239
|
cache: true,
|
|
239
|
-
prepend: false
|
|
240
|
+
prepend: false,
|
|
241
|
+
decodeID: false
|
|
240
242
|
}
|
|
241
243
|
|
|
242
244
|
const userTableSchema = [
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "dotenv/config";
|
|
2
2
|
export interface Data {
|
|
3
|
-
id?: string;
|
|
3
|
+
id?: string | number;
|
|
4
4
|
[key: string]: any;
|
|
5
5
|
createdAt?: number;
|
|
6
6
|
updatedAt?: number;
|
|
@@ -27,6 +27,7 @@ export interface Config {
|
|
|
27
27
|
compression?: boolean;
|
|
28
28
|
cache?: boolean;
|
|
29
29
|
prepend?: boolean;
|
|
30
|
+
decodeID?: boolean;
|
|
30
31
|
}
|
|
31
32
|
export interface TableObject {
|
|
32
33
|
schema?: Schema;
|
|
@@ -134,11 +135,11 @@ export default class Inibase {
|
|
|
134
135
|
* @param {boolean} [onlyLinesNumbers]
|
|
135
136
|
* @return {*} {(Promise<Data | number | (Data | number)[] | null>)}
|
|
136
137
|
*/
|
|
137
|
-
get<TData extends Record<string, any> & Partial<Data>>(tableName: string, where: string | number | (string | number)[] | Criteria | undefined, options: Options | undefined, onlyOne: true, onlyLinesNumbers?: false): Promise<(Data & TData) | null>;
|
|
138
|
-
get<TData extends Record<string, any> & Partial<Data>>(tableName: string, where: string | number, options?: Options, onlyOne?: boolean, onlyLinesNumbers?: false): Promise<(Data & TData) | null>;
|
|
139
|
-
get<TData extends Record<string, any> & Partial<Data>>(tableName: string, where?: string | number | (string | number)[] | Criteria, options?: Options, onlyOne?: boolean, onlyLinesNumbers?: false): Promise<(Data & TData)[] | null>;
|
|
140
|
-
get<TData extends Record<string, any> & Partial<Data>>(tableName: string, where: string | number | (string | number)[] | Criteria | undefined, options: Options | undefined, onlyOne: false | undefined, onlyLinesNumbers: true): Promise<number[] | null>;
|
|
141
|
-
get<TData extends Record<string, any> & Partial<Data>>(tableName: string, where: string | number | (string | number)[] | Criteria | undefined, options: Options | undefined, onlyOne: true, onlyLinesNumbers: true): Promise<number | null>;
|
|
138
|
+
get<TData extends Record<string, any> & Partial<Data>>(tableName: string, where: string | number | (string | number)[] | Criteria | undefined, options: Options | undefined, onlyOne: true, onlyLinesNumbers?: false, _whereIsLinesNumbers?: boolean): Promise<(Data & TData) | null>;
|
|
139
|
+
get<TData extends Record<string, any> & Partial<Data>>(tableName: string, where: string | number, options?: Options, onlyOne?: boolean, onlyLinesNumbers?: false, _whereIsLinesNumbers?: boolean): Promise<(Data & TData) | null>;
|
|
140
|
+
get<TData extends Record<string, any> & Partial<Data>>(tableName: string, where?: string | number | (string | number)[] | Criteria, options?: Options, onlyOne?: boolean, onlyLinesNumbers?: false, _whereIsLinesNumbers?: boolean): Promise<(Data & TData)[] | null>;
|
|
141
|
+
get<TData extends Record<string, any> & Partial<Data>>(tableName: string, where: string | number | (string | number)[] | Criteria | undefined, options: Options | undefined, onlyOne: false | undefined, onlyLinesNumbers: true, _whereIsLinesNumbers?: boolean): Promise<number[] | null>;
|
|
142
|
+
get<TData extends Record<string, any> & Partial<Data>>(tableName: string, where: string | number | (string | number)[] | Criteria | undefined, options: Options | undefined, onlyOne: true, onlyLinesNumbers: true, _whereIsLinesNumbers?: boolean): Promise<number | null>;
|
|
142
143
|
/**
|
|
143
144
|
* Create new item(s) in a table
|
|
144
145
|
*
|
|
@@ -161,10 +162,10 @@ export default class Inibase {
|
|
|
161
162
|
* @param {boolean} [returnUpdatedData]
|
|
162
163
|
* @return {*} {Promise<Data | Data[] | null | undefined | void>}
|
|
163
164
|
*/
|
|
164
|
-
put<TData extends Record<string, any> & Partial<Data>>(tableName: string, data?: (Data & TData) | (Data & TData)[], where?: number | string | (number | string)[] | Criteria | undefined, options?: Options | undefined, returnUpdatedData?: false): Promise<void>;
|
|
165
|
-
put<TData extends Record<string, any> & Partial<Data>>(tableName: string, data: Data & TData, where: number | string | (number | string)[] | Criteria | undefined, options: Options | undefined, returnUpdatedData: true | boolean): Promise<(Data & TData) | null>;
|
|
166
|
-
put<TData extends Record<string, any> & Partial<Data>>(tableName: string, data: (Data & TData)[], where: number | string | (number | string)[] | Criteria | undefined, options: Options | undefined, returnUpdatedData: true | boolean): Promise<(Data & TData)[] | null>;
|
|
167
|
-
put<TData extends Record<string, any> & Partial<Data>>(tableName: string, data: (Data & TData) | (Data & TData)[], where: number | string | (number | string)[] | Criteria | undefined, options: Options | undefined, returnUpdatedData: true | boolean): Promise<(Data & TData) | (Data & TData)[] | null>;
|
|
165
|
+
put<TData extends Record<string, any> & Partial<Data>>(tableName: string, data?: (Data & TData) | (Data & TData)[], where?: number | string | (number | string)[] | Criteria | undefined, options?: Options | undefined, returnUpdatedData?: false, _whereIsLinesNumbers?: boolean): Promise<void>;
|
|
166
|
+
put<TData extends Record<string, any> & Partial<Data>>(tableName: string, data: Data & TData, where: number | string | (number | string)[] | Criteria | undefined, options: Options | undefined, returnUpdatedData: true | boolean, _whereIsLinesNumbers?: boolean): Promise<(Data & TData) | null>;
|
|
167
|
+
put<TData extends Record<string, any> & Partial<Data>>(tableName: string, data: (Data & TData)[], where: number | string | (number | string)[] | Criteria | undefined, options: Options | undefined, returnUpdatedData: true | boolean, _whereIsLinesNumbers?: boolean): Promise<(Data & TData)[] | null>;
|
|
168
|
+
put<TData extends Record<string, any> & Partial<Data>>(tableName: string, data: (Data & TData) | (Data & TData)[], where: number | string | (number | string)[] | Criteria | undefined, options: Options | undefined, returnUpdatedData: true | boolean, _whereIsLinesNumbers?: boolean): Promise<(Data & TData) | (Data & TData)[] | null>;
|
|
168
169
|
/**
|
|
169
170
|
* Delete item(s) in a table
|
|
170
171
|
*
|
|
@@ -172,7 +173,7 @@ export default class Inibase {
|
|
|
172
173
|
* @param {(number | string | (number | string)[] | Criteria)} [where]
|
|
173
174
|
* @return {boolean | null} {(Promise<boolean | null>)}
|
|
174
175
|
*/
|
|
175
|
-
delete(tableName: string, where?: number | string | (number | string)[] | Criteria,
|
|
176
|
+
delete(tableName: string, where?: number | string | (number | string)[] | Criteria, _whereIsLinesNumbers?: boolean): Promise<boolean | null>;
|
|
176
177
|
/**
|
|
177
178
|
* Generate sum of column(s) in a table
|
|
178
179
|
*
|
package/dist/index.js
CHANGED
|
@@ -158,6 +158,7 @@ export default class Inibase {
|
|
|
158
158
|
compression: process.env.INIBASE_COMPRESSION == "true",
|
|
159
159
|
cache: process.env.INIBASE_CACHE === "true",
|
|
160
160
|
prepend: process.env.INIBASE_PREPEND === "true",
|
|
161
|
+
decodeID: process.env.INIBASE_ENCODEID === "true",
|
|
161
162
|
};
|
|
162
163
|
if (config) {
|
|
163
164
|
if (config.compression)
|
|
@@ -251,6 +252,13 @@ export default class Inibase {
|
|
|
251
252
|
await unlink(join(tablePath, ".cache.config"));
|
|
252
253
|
}
|
|
253
254
|
}
|
|
255
|
+
if (config.decodeID !== undefined &&
|
|
256
|
+
config.decodeID !== table.config.decodeID) {
|
|
257
|
+
if (config.decodeID)
|
|
258
|
+
await writeFile(join(tablePath, ".decodeID.config"), "");
|
|
259
|
+
else
|
|
260
|
+
await unlink(join(tablePath, ".decodeID.config"));
|
|
261
|
+
}
|
|
254
262
|
if (config.prepend !== undefined &&
|
|
255
263
|
config.prepend !== table.config.prepend) {
|
|
256
264
|
await UtilsServer.execFile("find", [
|
|
@@ -302,6 +310,7 @@ export default class Inibase {
|
|
|
302
310
|
compression: await File.isExists(join(tablePath, ".compression.config")),
|
|
303
311
|
cache: await File.isExists(join(tablePath, ".cache.config")),
|
|
304
312
|
prepend: await File.isExists(join(tablePath, ".prepend.config")),
|
|
313
|
+
decodeID: await File.isExists(join(tablePath, ".decodeID.config")),
|
|
305
314
|
},
|
|
306
315
|
});
|
|
307
316
|
return this.tablesMap.get(tableName);
|
|
@@ -476,7 +485,11 @@ export default class Inibase {
|
|
|
476
485
|
? value
|
|
477
486
|
: UtilsServer.hashPassword(String(value));
|
|
478
487
|
case "number":
|
|
479
|
-
return Utils.isNumber(value)
|
|
488
|
+
return Utils.isNumber(value)
|
|
489
|
+
? typeof value === "number"
|
|
490
|
+
? value
|
|
491
|
+
: Number(value.trim())
|
|
492
|
+
: 0;
|
|
480
493
|
case "id":
|
|
481
494
|
return Utils.isNumber(value)
|
|
482
495
|
? value
|
|
@@ -713,7 +726,9 @@ export default class Inibase {
|
|
|
713
726
|
async processSimpleField(tableName, field, linesNumber, RETURN, _options, prefix) {
|
|
714
727
|
const fieldPath = join(this.databasePath, tableName, `${prefix ?? ""}${field.key}${this.getFileExtension(tableName)}`);
|
|
715
728
|
if (await File.isExists(fieldPath)) {
|
|
716
|
-
const items = await File.get(fieldPath, linesNumber, field.
|
|
729
|
+
const items = await File.get(fieldPath, linesNumber, field.key === "id" && this.tablesMap.get(tableName).config.decodeID
|
|
730
|
+
? "number"
|
|
731
|
+
: field.type, field.children, this.salt);
|
|
717
732
|
if (items) {
|
|
718
733
|
for (const [index, item] of Object.entries(items)) {
|
|
719
734
|
if (typeof item === "undefined")
|
|
@@ -840,7 +855,7 @@ export default class Inibase {
|
|
|
840
855
|
if (!RETURN[index])
|
|
841
856
|
RETURN[index] = {};
|
|
842
857
|
if (Utils.isObject(item)) {
|
|
843
|
-
if (!Object.values(item).every((i) => i === null))
|
|
858
|
+
if (!Object.values(item).every((i) => i === null || i === 0))
|
|
844
859
|
RETURN[index][field.key] = item;
|
|
845
860
|
}
|
|
846
861
|
}
|
|
@@ -1058,7 +1073,7 @@ export default class Inibase {
|
|
|
1058
1073
|
async get(tableName, where, options = {
|
|
1059
1074
|
page: 1,
|
|
1060
1075
|
perPage: 15,
|
|
1061
|
-
}, onlyOne, onlyLinesNumbers) {
|
|
1076
|
+
}, onlyOne, onlyLinesNumbers, _whereIsLinesNumbers) {
|
|
1062
1077
|
const tablePath = join(this.databasePath, tableName);
|
|
1063
1078
|
// Ensure options.columns is an array
|
|
1064
1079
|
if (options.columns) {
|
|
@@ -1189,8 +1204,9 @@ export default class Inibase {
|
|
|
1189
1204
|
if (!this.totalItems.has(`${tableName}-*`))
|
|
1190
1205
|
this.totalItems.set(`${tableName}-*`, pagination[1]);
|
|
1191
1206
|
}
|
|
1192
|
-
else if ((Array.isArray(where) && where.every(Utils.isNumber)) ||
|
|
1193
|
-
Utils.isNumber(where))
|
|
1207
|
+
else if (((Array.isArray(where) && where.every(Utils.isNumber)) ||
|
|
1208
|
+
Utils.isNumber(where)) &&
|
|
1209
|
+
(_whereIsLinesNumbers || !this.tablesMap.get(tableName).config.decodeID)) {
|
|
1194
1210
|
// "where" in this case, is the line(s) number(s) and not id(s)
|
|
1195
1211
|
let lineNumbers = where;
|
|
1196
1212
|
if (!Array.isArray(lineNumbers))
|
|
@@ -1204,7 +1220,11 @@ export default class Inibase {
|
|
|
1204
1220
|
if (RETURN?.length && !Array.isArray(where))
|
|
1205
1221
|
RETURN = RETURN[0];
|
|
1206
1222
|
}
|
|
1207
|
-
else if ((
|
|
1223
|
+
else if ((!_whereIsLinesNumbers &&
|
|
1224
|
+
this.tablesMap.get(tableName).config.decodeID &&
|
|
1225
|
+
((Array.isArray(where) && where.every(Utils.isNumber)) ||
|
|
1226
|
+
Utils.isNumber(where))) ||
|
|
1227
|
+
(Array.isArray(where) && where.every(Utils.isValidID)) ||
|
|
1208
1228
|
Utils.isValidID(where)) {
|
|
1209
1229
|
let Ids = where;
|
|
1210
1230
|
if (!Array.isArray(Ids))
|
|
@@ -1241,7 +1261,7 @@ export default class Inibase {
|
|
|
1241
1261
|
return onlyOne ? Number(cachedItems[0]) : cachedItems.map(Number);
|
|
1242
1262
|
return this.get(tableName, cachedItems
|
|
1243
1263
|
.slice((options.page - 1) * options.perPage, options.page * options.perPage)
|
|
1244
|
-
.map(Number), options, onlyOne);
|
|
1264
|
+
.map(Number), options, onlyOne, undefined, true);
|
|
1245
1265
|
}
|
|
1246
1266
|
const [LineNumberDataMap, linesNumbers] = await this.applyCriteria(tableName, options, where);
|
|
1247
1267
|
if (LineNumberDataMap && linesNumbers?.size) {
|
|
@@ -1275,6 +1295,15 @@ export default class Inibase {
|
|
|
1275
1295
|
totalPages: Math.ceil(greatestTotalItems / options.perPage),
|
|
1276
1296
|
total: greatestTotalItems,
|
|
1277
1297
|
};
|
|
1298
|
+
// if (this.tablesMap.get(tableName).config.decodeID) {
|
|
1299
|
+
// if (Array.isArray(RETURN)) {
|
|
1300
|
+
// for (let index = 0; index < RETURN.length; index++)
|
|
1301
|
+
// RETURN[index].id = UtilsServer.decodeID(
|
|
1302
|
+
// RETURN[index].id as string,
|
|
1303
|
+
// this.salt,
|
|
1304
|
+
// );
|
|
1305
|
+
// } else RETURN.id = UtilsServer.decodeID(RETURN.id as string, this.salt);
|
|
1306
|
+
// }
|
|
1278
1307
|
return onlyOne && Array.isArray(RETURN) ? RETURN[0] : RETURN;
|
|
1279
1308
|
}
|
|
1280
1309
|
async post(tableName, data, options, returnPostedData) {
|
|
@@ -1340,7 +1369,8 @@ export default class Inibase {
|
|
|
1340
1369
|
? clonedData
|
|
1341
1370
|
.map((_, index) => this.totalItems.get(`${tableName}-*`) - index)
|
|
1342
1371
|
.toReversed()
|
|
1343
|
-
: this.totalItems.get(`${tableName}-*`), options, !Utils.isArrayOfObjects(clonedData)
|
|
1372
|
+
: this.totalItems.get(`${tableName}-*`), options, !Utils.isArrayOfObjects(clonedData), // return only one item if data is not array of objects
|
|
1373
|
+
undefined, true);
|
|
1344
1374
|
}
|
|
1345
1375
|
finally {
|
|
1346
1376
|
if (renameList.length)
|
|
@@ -1351,7 +1381,7 @@ export default class Inibase {
|
|
|
1351
1381
|
async put(tableName, data, where, options = {
|
|
1352
1382
|
page: 1,
|
|
1353
1383
|
perPage: 15,
|
|
1354
|
-
}, returnUpdatedData) {
|
|
1384
|
+
}, returnUpdatedData, _whereIsLinesNumbers) {
|
|
1355
1385
|
const renameList = [];
|
|
1356
1386
|
const tablePath = join(this.databasePath, tableName);
|
|
1357
1387
|
await this.throwErrorIfTableEmpty(tableName);
|
|
@@ -1394,13 +1424,9 @@ export default class Inibase {
|
|
|
1394
1424
|
await File.unlock(join(tablePath, ".tmp"));
|
|
1395
1425
|
}
|
|
1396
1426
|
}
|
|
1397
|
-
else if ((Array.isArray(where) && where.every(Utils.
|
|
1398
|
-
Utils.
|
|
1399
|
-
|
|
1400
|
-
return this.put(tableName, clonedData, lineNumbers, options, false);
|
|
1401
|
-
}
|
|
1402
|
-
else if ((Array.isArray(where) && where.every(Utils.isNumber)) ||
|
|
1403
|
-
Utils.isNumber(where)) {
|
|
1427
|
+
else if (((Array.isArray(where) && where.every(Utils.isNumber)) ||
|
|
1428
|
+
Utils.isNumber(where)) &&
|
|
1429
|
+
(_whereIsLinesNumbers || !this.tablesMap.get(tableName).config.decodeID)) {
|
|
1404
1430
|
// "where" in this case, is the line(s) number(s) and not id(s)
|
|
1405
1431
|
await this.validateData(tableName, clonedData, true);
|
|
1406
1432
|
clonedData = this.formatData(clonedData, this.tablesMap.get(tableName).schema, true);
|
|
@@ -1428,7 +1454,7 @@ export default class Inibase {
|
|
|
1428
1454
|
if (this.tablesMap.get(tableName).config.cache)
|
|
1429
1455
|
await this.clearCache(tableName);
|
|
1430
1456
|
if (returnUpdatedData)
|
|
1431
|
-
return this.get(tableName, where, options, !Array.isArray(where));
|
|
1457
|
+
return this.get(tableName, where, options, !Array.isArray(where), undefined, true);
|
|
1432
1458
|
}
|
|
1433
1459
|
finally {
|
|
1434
1460
|
if (renameList.length)
|
|
@@ -1436,10 +1462,19 @@ export default class Inibase {
|
|
|
1436
1462
|
await File.unlock(join(tablePath, ".tmp"), keys);
|
|
1437
1463
|
}
|
|
1438
1464
|
}
|
|
1465
|
+
else if ((!_whereIsLinesNumbers &&
|
|
1466
|
+
this.tablesMap.get(tableName).config.decodeID &&
|
|
1467
|
+
((Array.isArray(where) && where.every(Utils.isNumber)) ||
|
|
1468
|
+
Utils.isNumber(where))) ||
|
|
1469
|
+
(Array.isArray(where) && where.every(Utils.isValidID)) ||
|
|
1470
|
+
Utils.isValidID(where)) {
|
|
1471
|
+
const lineNumbers = await this.get(tableName, where, undefined, undefined, true);
|
|
1472
|
+
return this.put(tableName, clonedData, lineNumbers, options, false, true);
|
|
1473
|
+
}
|
|
1439
1474
|
else if (Utils.isObject(where)) {
|
|
1440
1475
|
const lineNumbers = await this.get(tableName, where, undefined, undefined, true);
|
|
1441
1476
|
if (lineNumbers)
|
|
1442
|
-
return this.put(tableName, clonedData, lineNumbers, options, returnUpdatedData);
|
|
1477
|
+
return this.put(tableName, clonedData, lineNumbers, options, returnUpdatedData, true);
|
|
1443
1478
|
}
|
|
1444
1479
|
else
|
|
1445
1480
|
throw this.createError("INVALID_PARAMETERS");
|
|
@@ -1451,7 +1486,7 @@ export default class Inibase {
|
|
|
1451
1486
|
* @param {(number | string | (number | string)[] | Criteria)} [where]
|
|
1452
1487
|
* @return {boolean | null} {(Promise<boolean | null>)}
|
|
1453
1488
|
*/
|
|
1454
|
-
async delete(tableName, where,
|
|
1489
|
+
async delete(tableName, where, _whereIsLinesNumbers) {
|
|
1455
1490
|
const tablePath = join(this.databasePath, tableName);
|
|
1456
1491
|
await this.throwErrorIfTableEmpty(tableName);
|
|
1457
1492
|
if (!where) {
|
|
@@ -1479,13 +1514,9 @@ export default class Inibase {
|
|
|
1479
1514
|
await File.unlock(join(tablePath, ".tmp"));
|
|
1480
1515
|
}
|
|
1481
1516
|
}
|
|
1482
|
-
if ((Array.isArray(where) && where.every(Utils.
|
|
1483
|
-
Utils.
|
|
1484
|
-
|
|
1485
|
-
return this.delete(tableName, lineNumbers, where);
|
|
1486
|
-
}
|
|
1487
|
-
if ((Array.isArray(where) && where.every(Utils.isNumber)) ||
|
|
1488
|
-
Utils.isNumber(where)) {
|
|
1517
|
+
if (((Array.isArray(where) && where.every(Utils.isNumber)) ||
|
|
1518
|
+
Utils.isNumber(where)) &&
|
|
1519
|
+
(_whereIsLinesNumbers || !this.tablesMap.get(tableName).config.decodeID)) {
|
|
1489
1520
|
// "where" in this case, is the line(s) number(s) and not id(s)
|
|
1490
1521
|
const files = (await readdir(tablePath))?.filter((fileName) => fileName.endsWith(this.getFileExtension(tableName)));
|
|
1491
1522
|
if (files.length) {
|
|
@@ -1525,10 +1556,19 @@ export default class Inibase {
|
|
|
1525
1556
|
}
|
|
1526
1557
|
}
|
|
1527
1558
|
}
|
|
1528
|
-
|
|
1559
|
+
if ((!_whereIsLinesNumbers &&
|
|
1560
|
+
this.tablesMap.get(tableName).config.decodeID &&
|
|
1561
|
+
((Array.isArray(where) && where.every(Utils.isNumber)) ||
|
|
1562
|
+
Utils.isNumber(where))) ||
|
|
1563
|
+
(Array.isArray(where) && where.every(Utils.isValidID)) ||
|
|
1564
|
+
Utils.isValidID(where)) {
|
|
1565
|
+
const lineNumbers = await this.get(tableName, where, undefined, undefined, true);
|
|
1566
|
+
return this.delete(tableName, lineNumbers, true);
|
|
1567
|
+
}
|
|
1568
|
+
if (Utils.isObject(where)) {
|
|
1529
1569
|
const lineNumbers = await this.get(tableName, where, undefined, undefined, true);
|
|
1530
1570
|
if (lineNumbers)
|
|
1531
|
-
return this.delete(tableName, lineNumbers);
|
|
1571
|
+
return this.delete(tableName, lineNumbers, true);
|
|
1532
1572
|
}
|
|
1533
1573
|
else
|
|
1534
1574
|
throw this.createError("INVALID_PARAMETERS");
|
package/dist/utils.js
CHANGED
|
@@ -25,7 +25,9 @@ export const isArrayOfArrays = (input) => Array.isArray(input) && input.length >
|
|
|
25
25
|
* Note: Recursively checks each element, allowing for nested arrays of nulls.
|
|
26
26
|
*/
|
|
27
27
|
export const isArrayOfNulls = (input) => Array.isArray(input) &&
|
|
28
|
-
input.every((_input) => Array.isArray(_input)
|
|
28
|
+
input.every((_input) => Array.isArray(_input)
|
|
29
|
+
? isArrayOfNulls(_input)
|
|
30
|
+
: _input === null || _input === 0 || _input === undefined);
|
|
29
31
|
/**
|
|
30
32
|
* Type guard function to check if the input is an object.
|
|
31
33
|
*
|