querier-ts 2.5.2 → 2.5.4
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/CHANGELOG.md +28 -0
- package/dist/cjs/index.cjs +26 -23
- package/dist/esm/index.d.ts +9 -4
- package/dist/esm/index.js +26 -23
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## v2.5.4
|
|
4
|
+
|
|
5
|
+
### Summary
|
|
6
|
+
|
|
7
|
+
- [ ] Bug fixes
|
|
8
|
+
- [x] Code refactoring
|
|
9
|
+
- [ ] New features
|
|
10
|
+
- [ ] Build and packaging updates
|
|
11
|
+
- [ ] Breaking changes
|
|
12
|
+
|
|
13
|
+
### Build and packaging updates
|
|
14
|
+
|
|
15
|
+
- Replaced pre-allocated arrays by static arrays for improved performance.
|
|
16
|
+
|
|
17
|
+
## v2.5.3
|
|
18
|
+
|
|
19
|
+
### Summary
|
|
20
|
+
|
|
21
|
+
- [ ] Bug fixes
|
|
22
|
+
- [x] Code refactoring
|
|
23
|
+
- [ ] New features
|
|
24
|
+
- [ ] Build and packaging updates
|
|
25
|
+
- [ ] Breaking changes
|
|
26
|
+
|
|
27
|
+
### Build and packaging updates
|
|
28
|
+
|
|
29
|
+
- Improved JSDoc for `column()` method.
|
|
30
|
+
|
|
3
31
|
## v2.5.2
|
|
4
32
|
|
|
5
33
|
### Summary
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -263,14 +263,13 @@ var _Query = class _Query {
|
|
|
263
263
|
*/
|
|
264
264
|
select(...columns) {
|
|
265
265
|
const source = this.#rows;
|
|
266
|
-
const
|
|
267
|
-
|
|
268
|
-
for (let i = 0; i < length; i++) {
|
|
266
|
+
const rows = [];
|
|
267
|
+
for (let i = 0; i < source.length; i++) {
|
|
269
268
|
const result = {};
|
|
270
269
|
for (const column of columns) {
|
|
271
270
|
result[column] = source[i][column];
|
|
272
271
|
}
|
|
273
|
-
rows
|
|
272
|
+
rows.push(result);
|
|
274
273
|
}
|
|
275
274
|
const query = new _Query(rows);
|
|
276
275
|
this.cloneStateInto(query);
|
|
@@ -284,10 +283,9 @@ var _Query = class _Query {
|
|
|
284
283
|
*/
|
|
285
284
|
map(callback) {
|
|
286
285
|
const source = this.#rows;
|
|
287
|
-
const
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
rows[i] = callback(source[i]);
|
|
286
|
+
const rows = [];
|
|
287
|
+
for (let i = 0; i < source.length; i++) {
|
|
288
|
+
rows.push(callback(source[i]));
|
|
291
289
|
}
|
|
292
290
|
const query = new _Query(rows);
|
|
293
291
|
this.cloneStateInto(query);
|
|
@@ -429,6 +427,12 @@ var _Query = class _Query {
|
|
|
429
427
|
const firstColumn = this.getFirstColumn();
|
|
430
428
|
return firstObject && firstColumn ? firstObject[firstColumn] : false;
|
|
431
429
|
}
|
|
430
|
+
/**
|
|
431
|
+
* Internal implementation for retrieving column values.
|
|
432
|
+
*
|
|
433
|
+
* If no column is provided, the first available column is used.
|
|
434
|
+
* Returns an empty array if there are no rows or no columns.
|
|
435
|
+
*/
|
|
432
436
|
column(column) {
|
|
433
437
|
const source = this.getLimitedRows();
|
|
434
438
|
const length = source.length;
|
|
@@ -442,9 +446,9 @@ var _Query = class _Query {
|
|
|
442
446
|
}
|
|
443
447
|
column = firstColumn;
|
|
444
448
|
}
|
|
445
|
-
const values =
|
|
449
|
+
const values = [];
|
|
446
450
|
for (let i = 0; i < length; i++) {
|
|
447
|
-
values
|
|
451
|
+
values.push(source[i][column]);
|
|
448
452
|
}
|
|
449
453
|
return values;
|
|
450
454
|
}
|
|
@@ -456,10 +460,9 @@ var _Query = class _Query {
|
|
|
456
460
|
*/
|
|
457
461
|
values() {
|
|
458
462
|
const source = this.getLimitedRows();
|
|
459
|
-
const
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
rows[i] = Object.values(source[i]);
|
|
463
|
+
const rows = [];
|
|
464
|
+
for (let i = 0; i < source.length; i++) {
|
|
465
|
+
rows.push(Object.values(source[i]));
|
|
463
466
|
}
|
|
464
467
|
return rows;
|
|
465
468
|
}
|
|
@@ -485,14 +488,14 @@ var _Query = class _Query {
|
|
|
485
488
|
if (length === 0) {
|
|
486
489
|
return null;
|
|
487
490
|
}
|
|
488
|
-
const values =
|
|
491
|
+
const values = [];
|
|
489
492
|
if (isFunction(arg)) {
|
|
490
493
|
for (let i = 0; i < length; i++) {
|
|
491
|
-
values
|
|
494
|
+
values.push(arg(source[i]));
|
|
492
495
|
}
|
|
493
496
|
} else {
|
|
494
497
|
for (let i = 0; i < length; i++) {
|
|
495
|
-
values
|
|
498
|
+
values.push(source[i][arg]);
|
|
496
499
|
}
|
|
497
500
|
}
|
|
498
501
|
return Math.min(...values);
|
|
@@ -503,14 +506,14 @@ var _Query = class _Query {
|
|
|
503
506
|
if (length === 0) {
|
|
504
507
|
return null;
|
|
505
508
|
}
|
|
506
|
-
const values =
|
|
509
|
+
const values = [];
|
|
507
510
|
if (isFunction(arg)) {
|
|
508
511
|
for (let i = 0; i < length; i++) {
|
|
509
|
-
values
|
|
512
|
+
values.push(arg(source[i]));
|
|
510
513
|
}
|
|
511
514
|
} else {
|
|
512
515
|
for (let i = 0; i < length; i++) {
|
|
513
|
-
values
|
|
516
|
+
values.push(source[i][arg]);
|
|
514
517
|
}
|
|
515
518
|
}
|
|
516
519
|
return Math.max(...values);
|
|
@@ -521,14 +524,14 @@ var _Query = class _Query {
|
|
|
521
524
|
if (length === 0) {
|
|
522
525
|
return 0;
|
|
523
526
|
}
|
|
524
|
-
const values =
|
|
527
|
+
const values = [];
|
|
525
528
|
if (isFunction(arg)) {
|
|
526
529
|
for (let i = 0; i < length; i++) {
|
|
527
|
-
values
|
|
530
|
+
values.push(arg(source[i]));
|
|
528
531
|
}
|
|
529
532
|
} else {
|
|
530
533
|
for (let i = 0; i < length; i++) {
|
|
531
|
-
values
|
|
534
|
+
values.push(source[i][arg]);
|
|
532
535
|
}
|
|
533
536
|
}
|
|
534
537
|
return values.reduce((total, value) => total + value, 0);
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -234,13 +234,18 @@ declare class Query<T extends object> {
|
|
|
234
234
|
*/
|
|
235
235
|
scalar(): T[PropOf<T>] | false;
|
|
236
236
|
/**
|
|
237
|
-
* Returns the values
|
|
237
|
+
* Returns the values from the first column for all rows.
|
|
238
238
|
*
|
|
239
|
-
* @
|
|
240
|
-
*
|
|
241
|
-
* @returns Values from the first (selected) column.
|
|
239
|
+
* @returns An array containing the values of the first column for each row.
|
|
242
240
|
*/
|
|
243
241
|
column(): T[PropOf<T>][];
|
|
242
|
+
/**
|
|
243
|
+
* Returns the values from a specific column for all rows.
|
|
244
|
+
*
|
|
245
|
+
* @param column The column whose values should be retrieved.
|
|
246
|
+
*
|
|
247
|
+
* @returns An array containing the values of the specified column for each row.
|
|
248
|
+
*/
|
|
244
249
|
column<TColumn extends PropOf<T>>(column: TColumn): T[TColumn][];
|
|
245
250
|
/**
|
|
246
251
|
* Returns the values of the rows. If there are selected columns, only their
|
package/dist/esm/index.js
CHANGED
|
@@ -261,14 +261,13 @@ var _Query = class _Query {
|
|
|
261
261
|
*/
|
|
262
262
|
select(...columns) {
|
|
263
263
|
const source = this.#rows;
|
|
264
|
-
const
|
|
265
|
-
|
|
266
|
-
for (let i = 0; i < length; i++) {
|
|
264
|
+
const rows = [];
|
|
265
|
+
for (let i = 0; i < source.length; i++) {
|
|
267
266
|
const result = {};
|
|
268
267
|
for (const column of columns) {
|
|
269
268
|
result[column] = source[i][column];
|
|
270
269
|
}
|
|
271
|
-
rows
|
|
270
|
+
rows.push(result);
|
|
272
271
|
}
|
|
273
272
|
const query = new _Query(rows);
|
|
274
273
|
this.cloneStateInto(query);
|
|
@@ -282,10 +281,9 @@ var _Query = class _Query {
|
|
|
282
281
|
*/
|
|
283
282
|
map(callback) {
|
|
284
283
|
const source = this.#rows;
|
|
285
|
-
const
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
rows[i] = callback(source[i]);
|
|
284
|
+
const rows = [];
|
|
285
|
+
for (let i = 0; i < source.length; i++) {
|
|
286
|
+
rows.push(callback(source[i]));
|
|
289
287
|
}
|
|
290
288
|
const query = new _Query(rows);
|
|
291
289
|
this.cloneStateInto(query);
|
|
@@ -427,6 +425,12 @@ var _Query = class _Query {
|
|
|
427
425
|
const firstColumn = this.getFirstColumn();
|
|
428
426
|
return firstObject && firstColumn ? firstObject[firstColumn] : false;
|
|
429
427
|
}
|
|
428
|
+
/**
|
|
429
|
+
* Internal implementation for retrieving column values.
|
|
430
|
+
*
|
|
431
|
+
* If no column is provided, the first available column is used.
|
|
432
|
+
* Returns an empty array if there are no rows or no columns.
|
|
433
|
+
*/
|
|
430
434
|
column(column) {
|
|
431
435
|
const source = this.getLimitedRows();
|
|
432
436
|
const length = source.length;
|
|
@@ -440,9 +444,9 @@ var _Query = class _Query {
|
|
|
440
444
|
}
|
|
441
445
|
column = firstColumn;
|
|
442
446
|
}
|
|
443
|
-
const values =
|
|
447
|
+
const values = [];
|
|
444
448
|
for (let i = 0; i < length; i++) {
|
|
445
|
-
values
|
|
449
|
+
values.push(source[i][column]);
|
|
446
450
|
}
|
|
447
451
|
return values;
|
|
448
452
|
}
|
|
@@ -454,10 +458,9 @@ var _Query = class _Query {
|
|
|
454
458
|
*/
|
|
455
459
|
values() {
|
|
456
460
|
const source = this.getLimitedRows();
|
|
457
|
-
const
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
rows[i] = Object.values(source[i]);
|
|
461
|
+
const rows = [];
|
|
462
|
+
for (let i = 0; i < source.length; i++) {
|
|
463
|
+
rows.push(Object.values(source[i]));
|
|
461
464
|
}
|
|
462
465
|
return rows;
|
|
463
466
|
}
|
|
@@ -483,14 +486,14 @@ var _Query = class _Query {
|
|
|
483
486
|
if (length === 0) {
|
|
484
487
|
return null;
|
|
485
488
|
}
|
|
486
|
-
const values =
|
|
489
|
+
const values = [];
|
|
487
490
|
if (isFunction(arg)) {
|
|
488
491
|
for (let i = 0; i < length; i++) {
|
|
489
|
-
values
|
|
492
|
+
values.push(arg(source[i]));
|
|
490
493
|
}
|
|
491
494
|
} else {
|
|
492
495
|
for (let i = 0; i < length; i++) {
|
|
493
|
-
values
|
|
496
|
+
values.push(source[i][arg]);
|
|
494
497
|
}
|
|
495
498
|
}
|
|
496
499
|
return Math.min(...values);
|
|
@@ -501,14 +504,14 @@ var _Query = class _Query {
|
|
|
501
504
|
if (length === 0) {
|
|
502
505
|
return null;
|
|
503
506
|
}
|
|
504
|
-
const values =
|
|
507
|
+
const values = [];
|
|
505
508
|
if (isFunction(arg)) {
|
|
506
509
|
for (let i = 0; i < length; i++) {
|
|
507
|
-
values
|
|
510
|
+
values.push(arg(source[i]));
|
|
508
511
|
}
|
|
509
512
|
} else {
|
|
510
513
|
for (let i = 0; i < length; i++) {
|
|
511
|
-
values
|
|
514
|
+
values.push(source[i][arg]);
|
|
512
515
|
}
|
|
513
516
|
}
|
|
514
517
|
return Math.max(...values);
|
|
@@ -519,14 +522,14 @@ var _Query = class _Query {
|
|
|
519
522
|
if (length === 0) {
|
|
520
523
|
return 0;
|
|
521
524
|
}
|
|
522
|
-
const values =
|
|
525
|
+
const values = [];
|
|
523
526
|
if (isFunction(arg)) {
|
|
524
527
|
for (let i = 0; i < length; i++) {
|
|
525
|
-
values
|
|
528
|
+
values.push(arg(source[i]));
|
|
526
529
|
}
|
|
527
530
|
} else {
|
|
528
531
|
for (let i = 0; i < length; i++) {
|
|
529
|
-
values
|
|
532
|
+
values.push(source[i][arg]);
|
|
530
533
|
}
|
|
531
534
|
}
|
|
532
535
|
return values.reduce((total, value) => total + value, 0);
|