querier-ts 2.7.1 → 2.8.0

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,18 @@
1
1
  # Changelog
2
2
 
3
+ ## v2.8.0
4
+
5
+ ### Summary
6
+
7
+ - [ ] Bug fixes
8
+ - [ ] Code refactoring
9
+ - [x] New features
10
+ - [ ] Breaking changes
11
+
12
+ ### New features
13
+
14
+ - Added row index as argument to `Query.map()` callback.
15
+
3
16
  ## v2.7.1
4
17
 
5
18
  ### Summary
@@ -10,7 +23,7 @@
10
23
  - [ ] New features
11
24
  - [ ] Breaking changes
12
25
 
13
- ### New features
26
+ ### Documentation updates
14
27
 
15
28
  - Update `README.md` documentation for `orderBy()` method with new overload and examples.
16
29
 
package/README.md CHANGED
@@ -5,7 +5,8 @@ querier-ts
5
5
  A lightweight, type-safe in-memory query engine for JavaScript and TypeScript.
6
6
  <p>
7
7
  <p align="center">
8
- <a href="https://npmx.dev/package/querier-ts"><img src="https://img.shields.io/npm/v/querier-ts?color=729B1B&label=" alt="current querier-ts version badge"></a>
8
+ <a href="https://www.npmjs.com/package/querier-ts"><img src="https://img.shields.io/npm/v/querier-ts.svg" alt="current querier-ts version badge"></a>
9
+ <a href="https://codecov.io/gh/luizfilipezs/querier-ts"><img alt="Codecov" src="https://img.shields.io/codecov/c/github/luizfilipezs/querier-ts.svg?style=flat-square"></a>
9
10
  <p>
10
11
 
11
12
  ## `Query`
@@ -116,6 +117,11 @@ Transforms each row into a new object using a callback function.
116
117
 
117
118
  Like `select()`, this method is intended for data projection, but it is more flexible and better suited for complex transformations:
118
119
 
120
+ Callback arguments:
121
+
122
+ - `row`: The current row.
123
+ - `index`: The index of the current row.
124
+
119
125
 
120
126
  ```ts
121
127
  const authorsWithFirstPostQuery = Query.from(authors)
@@ -295,7 +295,7 @@ var _Query = class _Query {
295
295
  const source = this.#rows;
296
296
  const rows = [];
297
297
  for (let i = 0; i < source.length; i++) {
298
- rows.push(callback(source[i]));
298
+ rows.push(callback(source[i], i));
299
299
  }
300
300
  const query = new _Query(rows);
301
301
  this.cloneStateInto(query);
@@ -110,7 +110,7 @@ declare class Query<T extends object> {
110
110
  * @param callback Function to be called for each row.
111
111
  * @returns New query with the mapped rows.
112
112
  */
113
- map<TReturn extends object>(callback: (obj: T) => TReturn): Query<TReturn>;
113
+ map<TReturn extends object>(callback: (row: T, index: number) => TReturn): Query<TReturn>;
114
114
  /**
115
115
  * Removes duplicate rows based on a key.
116
116
  *
package/dist/esm/index.js CHANGED
@@ -293,7 +293,7 @@ var _Query = class _Query {
293
293
  const source = this.#rows;
294
294
  const rows = [];
295
295
  for (let i = 0; i < source.length; i++) {
296
- rows.push(callback(source[i]));
296
+ rows.push(callback(source[i], i));
297
297
  }
298
298
  const query = new _Query(rows);
299
299
  this.cloneStateInto(query);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "querier-ts",
3
3
  "type": "module",
4
- "version": "2.7.1",
4
+ "version": "2.8.0",
5
5
  "description": "A lightweight, type-safe in-memory query engine for JavaScript and TypeScript",
6
6
  "repository": {
7
7
  "type": "git",