querier-ts 2.5.3 → 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 CHANGED
@@ -1,5 +1,19 @@
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
+
3
17
  ## v2.5.3
4
18
 
5
19
  ### Summary
@@ -263,14 +263,13 @@ var _Query = class _Query {
263
263
  */
264
264
  select(...columns) {
265
265
  const source = this.#rows;
266
- const length = source.length;
267
- const rows = new Array(length);
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[i] = result;
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 length = source.length;
288
- const rows = new Array(length);
289
- for (let i = 0; i < length; i++) {
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);
@@ -448,9 +446,9 @@ var _Query = class _Query {
448
446
  }
449
447
  column = firstColumn;
450
448
  }
451
- const values = new Array(length);
449
+ const values = [];
452
450
  for (let i = 0; i < length; i++) {
453
- values[i] = source[i][column];
451
+ values.push(source[i][column]);
454
452
  }
455
453
  return values;
456
454
  }
@@ -462,10 +460,9 @@ var _Query = class _Query {
462
460
  */
463
461
  values() {
464
462
  const source = this.getLimitedRows();
465
- const length = source.length;
466
- const rows = new Array(length);
467
- for (let i = 0; i < length; i++) {
468
- 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]));
469
466
  }
470
467
  return rows;
471
468
  }
@@ -491,14 +488,14 @@ var _Query = class _Query {
491
488
  if (length === 0) {
492
489
  return null;
493
490
  }
494
- const values = new Array(length);
491
+ const values = [];
495
492
  if (isFunction(arg)) {
496
493
  for (let i = 0; i < length; i++) {
497
- values[i] = arg(source[i]);
494
+ values.push(arg(source[i]));
498
495
  }
499
496
  } else {
500
497
  for (let i = 0; i < length; i++) {
501
- values[i] = source[i][arg];
498
+ values.push(source[i][arg]);
502
499
  }
503
500
  }
504
501
  return Math.min(...values);
@@ -509,14 +506,14 @@ var _Query = class _Query {
509
506
  if (length === 0) {
510
507
  return null;
511
508
  }
512
- const values = new Array(length);
509
+ const values = [];
513
510
  if (isFunction(arg)) {
514
511
  for (let i = 0; i < length; i++) {
515
- values[i] = arg(source[i]);
512
+ values.push(arg(source[i]));
516
513
  }
517
514
  } else {
518
515
  for (let i = 0; i < length; i++) {
519
- values[i] = source[i][arg];
516
+ values.push(source[i][arg]);
520
517
  }
521
518
  }
522
519
  return Math.max(...values);
@@ -527,14 +524,14 @@ var _Query = class _Query {
527
524
  if (length === 0) {
528
525
  return 0;
529
526
  }
530
- const values = new Array(length);
527
+ const values = [];
531
528
  if (isFunction(arg)) {
532
529
  for (let i = 0; i < length; i++) {
533
- values[i] = arg(source[i]);
530
+ values.push(arg(source[i]));
534
531
  }
535
532
  } else {
536
533
  for (let i = 0; i < length; i++) {
537
- values[i] = source[i][arg];
534
+ values.push(source[i][arg]);
538
535
  }
539
536
  }
540
537
  return values.reduce((total, value) => total + value, 0);
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 length = source.length;
265
- const rows = new Array(length);
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[i] = result;
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 length = source.length;
286
- const rows = new Array(length);
287
- for (let i = 0; i < length; i++) {
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);
@@ -446,9 +444,9 @@ var _Query = class _Query {
446
444
  }
447
445
  column = firstColumn;
448
446
  }
449
- const values = new Array(length);
447
+ const values = [];
450
448
  for (let i = 0; i < length; i++) {
451
- values[i] = source[i][column];
449
+ values.push(source[i][column]);
452
450
  }
453
451
  return values;
454
452
  }
@@ -460,10 +458,9 @@ var _Query = class _Query {
460
458
  */
461
459
  values() {
462
460
  const source = this.getLimitedRows();
463
- const length = source.length;
464
- const rows = new Array(length);
465
- for (let i = 0; i < length; i++) {
466
- 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]));
467
464
  }
468
465
  return rows;
469
466
  }
@@ -489,14 +486,14 @@ var _Query = class _Query {
489
486
  if (length === 0) {
490
487
  return null;
491
488
  }
492
- const values = new Array(length);
489
+ const values = [];
493
490
  if (isFunction(arg)) {
494
491
  for (let i = 0; i < length; i++) {
495
- values[i] = arg(source[i]);
492
+ values.push(arg(source[i]));
496
493
  }
497
494
  } else {
498
495
  for (let i = 0; i < length; i++) {
499
- values[i] = source[i][arg];
496
+ values.push(source[i][arg]);
500
497
  }
501
498
  }
502
499
  return Math.min(...values);
@@ -507,14 +504,14 @@ var _Query = class _Query {
507
504
  if (length === 0) {
508
505
  return null;
509
506
  }
510
- const values = new Array(length);
507
+ const values = [];
511
508
  if (isFunction(arg)) {
512
509
  for (let i = 0; i < length; i++) {
513
- values[i] = arg(source[i]);
510
+ values.push(arg(source[i]));
514
511
  }
515
512
  } else {
516
513
  for (let i = 0; i < length; i++) {
517
- values[i] = source[i][arg];
514
+ values.push(source[i][arg]);
518
515
  }
519
516
  }
520
517
  return Math.max(...values);
@@ -525,14 +522,14 @@ var _Query = class _Query {
525
522
  if (length === 0) {
526
523
  return 0;
527
524
  }
528
- const values = new Array(length);
525
+ const values = [];
529
526
  if (isFunction(arg)) {
530
527
  for (let i = 0; i < length; i++) {
531
- values[i] = arg(source[i]);
528
+ values.push(arg(source[i]));
532
529
  }
533
530
  } else {
534
531
  for (let i = 0; i < length; i++) {
535
- values[i] = source[i][arg];
532
+ values.push(source[i][arg]);
536
533
  }
537
534
  }
538
535
  return values.reduce((total, value) => total + value, 0);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "querier-ts",
3
3
  "type": "module",
4
- "version": "2.5.3",
4
+ "version": "2.5.4",
5
5
  "description": "A lightweight, type-safe in-memory query engine for JavaScript and TypeScript",
6
6
  "repository": {
7
7
  "type": "git",