@aws-lambda-powertools/jmespath 2.5.0 → 2.7.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/README.md CHANGED
@@ -6,16 +6,16 @@ You can use the package in both TypeScript and JavaScript code bases.
6
6
 
7
7
  - [Intro](#intro)
8
8
  - [Usage](#usage)
9
- - [Basic usage](#basic-usage)
10
- - [Extract data from envelopes](#extract-data-from-envelopes)
11
- - [JMESPath custom functions](#jmespath-custom-functions)
9
+ - [Basic usage](#basic-usage)
10
+ - [Extract data from envelopes](#extract-data-from-envelopes)
11
+ - [JMESPath custom functions](#jmespath-custom-functions)
12
12
  - [Contribute](#contribute)
13
13
  - [Roadmap](#roadmap)
14
14
  - [Connect](#connect)
15
15
  - [How to support Powertools for AWS Lambda (TypeScript)?](#how-to-support-powertools-for-aws-lambda-typescript)
16
- - [Becoming a reference customer](#becoming-a-reference-customer)
17
- - [Sharing your work](#sharing-your-work)
18
- - [Using Lambda Layer](#using-lambda-layer)
16
+ - [Becoming a reference customer](#becoming-a-reference-customer)
17
+ - [Sharing your work](#sharing-your-work)
18
+ - [Using Lambda Layer](#using-lambda-layer)
19
19
  - [License](#license)
20
20
 
21
21
  ## Intro
@@ -182,8 +182,8 @@ Help us prioritize upcoming functionalities or utilities by [upvoting existing R
182
182
 
183
183
  ## Connect
184
184
 
185
- * **Powertools for AWS Lambda on Discord**: `#typescript` - **[Invite link](https://discord.gg/B8zZKbbyET)**
186
- * **Email**: aws-lambda-powertools-feedback@amazon.com
185
+ - **Powertools for AWS Lambda on Discord**: `#typescript` - **[Invite link](https://discord.gg/B8zZKbbyET)**
186
+ - **Email**: <aws-lambda-powertools-feedback@amazon.com>
187
187
 
188
188
  ## How to support Powertools for AWS Lambda (TypeScript)?
189
189
 
@@ -193,17 +193,21 @@ Knowing which companies are using this library is important to help prioritize t
193
193
 
194
194
  The following companies, among others, use Powertools:
195
195
 
196
- * [Hashnode](https://hashnode.com/)
197
- * [Trek10](https://www.trek10.com/)
198
- * [Elva](https://elva-group.com)
199
- * [globaldatanet](https://globaldatanet.com/)
200
- * [Bailey Nelson](https://www.baileynelson.com.au)
201
- * [Perfect Post](https://www.perfectpost.fr)
202
- * [Sennder](https://sennder.com/)
203
- * [Certible](https://www.certible.com/)
204
- * [tecRacer GmbH & Co. KG](https://www.tecracer.com/)
205
- * [AppYourself](https://appyourself.net)
206
- * [Alma Media](https://www.almamedia.fi)
196
+ - [Alma Media](https://www.almamedia.fi)
197
+ - [AppYourself](https://appyourself.net)
198
+ - [Bailey Nelson](https://www.baileynelson.com.au)
199
+ - [Banxware](https://www.banxware.com)
200
+ - [Caylent](https://caylent.com/)
201
+ - [Certible](https://www.certible.com/)
202
+ - [Elva](https://elva-group.com)
203
+ - [globaldatanet](https://globaldatanet.com/)
204
+ - [Hashnode](https://hashnode.com/)
205
+ - [LocalStack](https://localstack.cloud/)
206
+ - [Perfect Post](https://www.perfectpost.fr)
207
+ - [Sennder](https://sennder.com/)
208
+ - [tecRacer GmbH & Co. KG](https://www.tecracer.com/)
209
+ - [Trek10](https://www.trek10.com/)
210
+ - [WeSchool](https://www.weschool.com)
207
211
 
208
212
  ### Sharing your work
209
213
 
@@ -215,4 +219,4 @@ This helps us understand who uses Powertools for AWS Lambda (TypeScript) in a no
215
219
 
216
220
  ## License
217
221
 
218
- This library is licensed under the MIT-0 License. See the LICENSE file.
222
+ This library is licensed under the MIT-0 License. See the LICENSE file.
@@ -1 +1 @@
1
- {"version":3,"file":"Functions.d.ts","sourceRoot":"","sources":["../../src/Functions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EACV,SAAS,EACV,MAAM,sCAAsC,CAAC;AAM9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,KAAK,EACV,0BAA0B,EAC1B,wBAAwB,EAEzB,MAAM,YAAY,CAAC;AAGpB;;;;;;;;;;;;;;;;;;;;;;;;;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,CAAC,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC;IAenE;;;;;OAKG;IAII,UAAU,CACf,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC,EACtB,UAAU,EAAE,UAAU,GACrB,KAAK,CAAC,OAAO,CAAC;IAgCjB;;;;;OAKG;IAII,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO;IAI3D;;;;OAIG;IAII,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM;IAI3C;;;;;;;OAOG;IAII,WAAW,CAChB,GAAG,EAAE,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC,GAChC,KAAK,CAAC,SAAS,CAAC,GAAG,SAAS;IAI/B;;;;;;;;;OASG;IAII,YAAY,CAAC,GAAG,EAAE,SAAS,GAAG,MAAM,GAAG,IAAI;IAYlD;;;;;;;OAOG;IAII,YAAY,CAAC,GAAG,EAAE,SAAS,GAAG,MAAM;IAI3C;;;;OAIG;IAII,QAAQ,CAAC,GAAG,EAAE,SAAS,GAAG,MAAM;IAIvC;;;;OAIG;IAII,UAAU,CAAC,GAAG,EAAE,UAAU,GAAG,SAAS,EAAE;IAI/C;;;;;;;;;;;;;;;;OAgBG;IACI,iBAAiB,CAAC,KAAK,CAAC,EAAE,SAAS,GAAG,GAAG,CAAC,MAAM,CAAC;IA8BxD;;;;;;;;;;;;;;;;;;;;;;;OAuBG;WACW,SAAS,CACrB,OAAO,EAAE,wBAAwB,GAChC,0BAA0B;CAiB9B;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
@@ -121,9 +121,7 @@ class Functions {
121
121
  if ((0, typeutils_1.isRecord)(arg)) {
122
122
  return Object.keys(arg).length;
123
123
  }
124
- else {
125
- return arg.length;
126
- }
124
+ return arg.length;
127
125
  }
128
126
  /**
129
127
  * Map the provided function over the provided array.
@@ -146,13 +144,11 @@ class Functions {
146
144
  return null;
147
145
  // The signature decorator already enforces that all elements are of the same type
148
146
  }
149
- else if ((0, typeutils_1.isNumber)(arg[0])) {
147
+ if ((0, typeutils_1.isNumber)(arg[0])) {
150
148
  return Math.max(...arg);
151
149
  }
152
- else {
153
- // local compare function to handle string comparison
154
- return arg.reduce((a, b) => (a > b ? a : b));
155
- }
150
+ // local compare function to handle string comparison
151
+ return arg.reduce((a, b) => (a > b ? a : b));
156
152
  }
157
153
  /**
158
154
  * Get the item in the provided array that has the maximum value when the provided expression is evaluated.
@@ -180,14 +176,12 @@ class Functions {
180
176
  if (max.visited === current.visited) {
181
177
  return max;
182
178
  }
183
- else {
184
- // We can safely cast visited to number | string here because we've already
185
- // checked the type at runtime above and we know that it's either a number or a string
186
- return max.visited >
187
- current.visited
188
- ? max
189
- : current;
190
- }
179
+ // We can safely cast visited to number | string here because we've already
180
+ // checked the type at runtime above and we know that it's either a number or a string
181
+ return max.visited >
182
+ current.visited
183
+ ? max
184
+ : current;
191
185
  }, visitedArgs[0]);
192
186
  return max.arg;
193
187
  }
@@ -199,6 +193,7 @@ class Functions {
199
193
  * @param args The objects to merge
200
194
  */
201
195
  funcMerge(...args) {
196
+ // biome-ignore lint/performance/noAccumulatingSpread: This is a shallow merge so the tradeoff is acceptable
202
197
  return args.reduce((a, b) => ({ ...a, ...b }), {});
203
198
  }
204
199
  /**
@@ -211,12 +206,10 @@ class Functions {
211
206
  return null;
212
207
  // The signature decorator already enforces that all elements are of the same type
213
208
  }
214
- else if ((0, typeutils_1.isNumber)(arg[0])) {
209
+ if ((0, typeutils_1.isNumber)(arg[0])) {
215
210
  return Math.min(...arg);
216
211
  }
217
- else {
218
- return arg.reduce((a, b) => (a < b ? a : b));
219
- }
212
+ return arg.reduce((a, b) => (a < b ? a : b));
220
213
  }
221
214
  /**
222
215
  * Get the item in the provided array that has the minimum value when the provided expression is evaluated.
@@ -244,14 +237,12 @@ class Functions {
244
237
  if (min.visited === current.visited) {
245
238
  return min;
246
239
  }
247
- else {
248
- // We can safely cast visited to number | string here because we've already
249
- // checked the type at runtime above and we know that it's either a number or a string
250
- return min.visited <
251
- current.visited
252
- ? min
253
- : current;
254
- }
240
+ // We can safely cast visited to number | string here because we've already
241
+ // checked the type at runtime above and we know that it's either a number or a string
242
+ return min.visited <
243
+ current.visited
244
+ ? min
245
+ : current;
255
246
  }, visitedArgs[0]);
256
247
  return min.arg;
257
248
  }
@@ -320,13 +311,11 @@ class Functions {
320
311
  if (a.visited === b.visited) {
321
312
  return a.index - b.index; // Make the sort stable
322
313
  }
323
- else {
324
- // We can safely cast visited to number | string here because we've already
325
- // checked the type at runtime above and we know that it's either a number or a string
326
- return a.visited > b.visited
327
- ? 1
328
- : -1;
329
- }
314
+ // We can safely cast visited to number | string here because we've already
315
+ // checked the type at runtime above and we know that it's either a number or a string
316
+ return a.visited > b.visited
317
+ ? 1
318
+ : -1;
330
319
  })
331
320
  .map(({ value }) => value); // Extract the original values
332
321
  }
@@ -372,13 +361,11 @@ class Functions {
372
361
  if (typeof arg === 'number') {
373
362
  return arg;
374
363
  }
375
- else if (typeof arg === 'string') {
364
+ if (typeof arg === 'string') {
376
365
  const num = Number(arg);
377
366
  return Number.isNaN(num) ? null : num;
378
367
  }
379
- else {
380
- return null;
381
- }
368
+ return null;
382
369
  }
383
370
  /**
384
371
  * Convert the provided value to a string.
@@ -1 +1 @@
1
- {"version":3,"file":"Lexer.d.ts","sourceRoot":"","sources":["../../src/Lexer.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC;;;;GAIG;AACH,cAAM,KAAK;;IAOT;;;;;;OAMG;IACK,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC;CAgVvD;AAED,OAAO,EAAE,KAAK,EAAE,CAAC"}
1
+ {"version":3,"file":"Lexer.d.ts","sourceRoot":"","sources":["../../src/Lexer.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC;;;;GAIG;AACH,cAAM,KAAK;;IAOT;;;;;;OAMG;IACK,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC;CA4UvD;AAED,OAAO,EAAE,KAAK,EAAE,CAAC"}
package/lib/cjs/Lexer.js CHANGED
@@ -26,9 +26,7 @@ class Lexer {
26
26
  while (this.#current !== '' && this.#current !== undefined) {
27
27
  if (constants_js_1.SIMPLE_TOKENS.has(this.#current)) {
28
28
  yield {
29
- // We know that SIMPLE_TOKENS has this.#current as a key because
30
- // we checked for that above.
31
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
29
+ // biome-ignore lint/style/noNonNullAssertion: We know that SIMPLE_TOKENS has this.#current as a key because we checked for that above.
32
30
  type: constants_js_1.SIMPLE_TOKENS.get(this.#current),
33
31
  value: this.#current,
34
32
  start: this.#position,
@@ -56,7 +54,7 @@ class Lexer {
56
54
  const buff = this.#consumeNumber();
57
55
  yield {
58
56
  type: 'number',
59
- value: parseInt(buff),
57
+ value: Number.parseInt(buff),
60
58
  start: start,
61
59
  end: start + buff.length,
62
60
  };
@@ -116,9 +114,7 @@ class Lexer {
116
114
  end: this.#position,
117
115
  };
118
116
  }
119
- else {
120
- throw new errors_js_1.LexerError(this.#position - 1, '=');
121
- }
117
+ throw new errors_js_1.LexerError(this.#position - 1, '=');
122
118
  }
123
119
  /**
124
120
  * Consume an unquoted identifier.
@@ -152,15 +148,13 @@ class Lexer {
152
148
  if (buff.length > 1) {
153
149
  return {
154
150
  type: 'number',
155
- value: parseInt(buff),
151
+ value: Number.parseInt(buff),
156
152
  start: start,
157
153
  end: start + buff.length,
158
154
  };
159
155
  }
160
- else {
161
- // If the negative sign is not followed by a number, it is an error.
162
- throw new errors_js_1.LexerError(start, 'Unknown token after "-"');
163
- }
156
+ // If the negative sign is not followed by a number, it is an error.
157
+ throw new errors_js_1.LexerError(start, 'Unknown token after "-"');
164
158
  }
165
159
  /**
166
160
  * Consume a raw string that is a number.
@@ -186,17 +180,15 @@ class Lexer {
186
180
  #consumeSquareBracket() {
187
181
  const start = this.#position;
188
182
  const nextChar = this.#next();
189
- if (nextChar == ']') {
183
+ if (nextChar === ']') {
190
184
  this.#next();
191
185
  return { type: 'flatten', value: '[]', start: start, end: start + 2 };
192
186
  }
193
- else if (nextChar == '?') {
187
+ if (nextChar === '?') {
194
188
  this.#next();
195
189
  return { type: 'filter', value: '[?', start: start, end: start + 2 };
196
190
  }
197
- else {
198
- return { type: 'lbracket', value: '[', start: start, end: start + 1 };
199
- }
191
+ return { type: 'lbracket', value: '[', start: start, end: start + 1 };
200
192
  }
201
193
  /**
202
194
  * Initializes the lexer for the given expression.
@@ -286,7 +278,7 @@ class Lexer {
286
278
  */
287
279
  #consumeQuotedIdentifier() {
288
280
  const start = this.#position;
289
- const lexeme = '"' + this.#consumeUntil('"') + '"';
281
+ const lexeme = `"${this.#consumeUntil('"')}"`;
290
282
  const tokenLen = this.#position - start;
291
283
  return {
292
284
  type: 'quoted_identifier',
@@ -1,4 +1,4 @@
1
- import type { Node, JMESPathParsingOptions, JSONObject } from './types.js';
1
+ import type { JMESPathParsingOptions, JSONObject, Node } from './types.js';
2
2
  declare class ParsedResult {
3
3
  expression: string;
4
4
  parsed: Node;
@@ -1 +1 @@
1
- {"version":3,"file":"ParsedResult.d.ts","sourceRoot":"","sources":["../../src/ParsedResult.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,IAAI,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE3E,cAAM,YAAY;IACT,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,IAAI,CAAC;gBAED,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI;IAKnD;;;;;OAKG;IACI,MAAM,CAAC,KAAK,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,sBAAsB,GAAG,OAAO;CAiB5E;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
1
+ {"version":3,"file":"ParsedResult.d.ts","sourceRoot":"","sources":["../../src/ParsedResult.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,sBAAsB,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAE3E,cAAM,YAAY;IACT,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,IAAI,CAAC;gBAED,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI;IAKnD;;;;;OAKG;IACI,MAAM,CAAC,KAAK,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,sBAAsB,GAAG,OAAO;CAiB5E;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Parser.d.ts","sourceRoot":"","sources":["../../src/Parser.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AA6BjD;;;;;;;;;;;;;GAaG;AACH,cAAM,MAAM;;gBAkBS,SAAS,SAAI;IAIhC;;;;;;;;OAQG;IACI,KAAK,CAAC,UAAU,EAAE,MAAM,GAAG,YAAY;IAc9C;;OAEG;IACI,UAAU,IAAI,IAAI;CAkuB1B;AAED,OAAO,EAAE,MAAM,EAAE,CAAC"}
1
+ {"version":3,"file":"Parser.d.ts","sourceRoot":"","sources":["../../src/Parser.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AA6BjD;;;;;;;;;;;;;GAaG;AACH,cAAM,MAAM;;gBAkBS,SAAS,SAAI;IAIhC;;;;;;;;OAQG;IACI,KAAK,CAAC,UAAU,EAAE,MAAM,GAAG,YAAY;IAc9C;;OAEG;IACI,UAAU,IAAI,IAAI;CAutB1B;AAED,OAAO,EAAE,MAAM,EAAE,CAAC"}
package/lib/cjs/Parser.js CHANGED
@@ -141,13 +141,13 @@ class Parser {
141
141
  case 'flatten':
142
142
  return this.#processFlattenTokenNud();
143
143
  case 'not':
144
- return (0, ast_js_1.notExpression)(this.#expression(constants_js_1.BINDING_POWER['not']));
144
+ return (0, ast_js_1.notExpression)(this.#expression(constants_js_1.BINDING_POWER.not));
145
145
  case 'lbracket':
146
146
  return this.#processLBracketTokenNud();
147
147
  case 'current':
148
148
  return (0, ast_js_1.currentNode)();
149
149
  case 'expref':
150
- return (0, ast_js_1.expref)(this.#expression(constants_js_1.BINDING_POWER['expref']));
150
+ return (0, ast_js_1.expref)(this.#expression(constants_js_1.BINDING_POWER.expref));
151
151
  default:
152
152
  return this.#processDefaultToken(token);
153
153
  }
@@ -186,7 +186,7 @@ class Parser {
186
186
  right = (0, ast_js_1.identity)();
187
187
  }
188
188
  else {
189
- right = this.#parseProjectionRhs(constants_js_1.BINDING_POWER['star']);
189
+ right = this.#parseProjectionRhs(constants_js_1.BINDING_POWER.star);
190
190
  }
191
191
  return (0, ast_js_1.valueProjection)(left, right);
192
192
  }
@@ -213,7 +213,7 @@ class Parser {
213
213
  */
214
214
  #processFlattenTokenNud() {
215
215
  const left = (0, ast_js_1.flatten)((0, ast_js_1.identity)());
216
- const right = this.#parseProjectionRhs(constants_js_1.BINDING_POWER['flatten']);
216
+ const right = this.#parseProjectionRhs(constants_js_1.BINDING_POWER.flatten);
217
217
  return (0, ast_js_1.projection)(left, right);
218
218
  }
219
219
  /**
@@ -229,16 +229,13 @@ class Parser {
229
229
  const right = this.#parseIndexExpression();
230
230
  return this.#projectIfSlice((0, ast_js_1.identity)(), right);
231
231
  }
232
- else if (this.#currentToken() === 'star' &&
233
- this.#lookahead(1) === 'rbracket') {
232
+ if (this.#currentToken() === 'star' && this.#lookahead(1) === 'rbracket') {
234
233
  this.#advance();
235
234
  this.#advance();
236
- const right = this.#parseProjectionRhs(constants_js_1.BINDING_POWER['star']);
235
+ const right = this.#parseProjectionRhs(constants_js_1.BINDING_POWER.star);
237
236
  return (0, ast_js_1.projection)((0, ast_js_1.identity)(), right);
238
237
  }
239
- else {
240
- return this.#parseMultiSelectList();
241
- }
238
+ return this.#parseMultiSelectList();
242
239
  }
243
240
  /**
244
241
  * Process a default token.
@@ -310,21 +307,17 @@ class Parser {
310
307
  */
311
308
  #processDotToken(leftNode) {
312
309
  if (this.#currentToken() !== 'star') {
313
- const right = this.#parseDotRhs(constants_js_1.BINDING_POWER['dot']);
310
+ const right = this.#parseDotRhs(constants_js_1.BINDING_POWER.dot);
314
311
  if (leftNode.type === 'subexpression') {
315
312
  leftNode.children.push(right);
316
313
  return leftNode;
317
314
  }
318
- else {
319
- return (0, ast_js_1.subexpression)([leftNode, right]);
320
- }
321
- }
322
- else {
323
- // We are creating a value projection
324
- this.#advance();
325
- const right = this.#parseProjectionRhs(constants_js_1.BINDING_POWER['dot']);
326
- return (0, ast_js_1.valueProjection)(leftNode, right);
315
+ return (0, ast_js_1.subexpression)([leftNode, right]);
327
316
  }
317
+ // We are creating a value projection
318
+ this.#advance();
319
+ const right = this.#parseProjectionRhs(constants_js_1.BINDING_POWER.dot);
320
+ return (0, ast_js_1.valueProjection)(leftNode, right);
328
321
  }
329
322
  /**
330
323
  * Process a pipe token.
@@ -337,7 +330,7 @@ class Parser {
337
330
  * @param leftNode The left hand side of the expression.
338
331
  */
339
332
  #processPipeToken(leftNode) {
340
- const right = this.#expression(constants_js_1.BINDING_POWER['pipe']);
333
+ const right = this.#expression(constants_js_1.BINDING_POWER.pipe);
341
334
  return (0, ast_js_1.pipe)(leftNode, right);
342
335
  }
343
336
  /**
@@ -351,7 +344,7 @@ class Parser {
351
344
  * @param leftNode The left hand side of the expression.
352
345
  */
353
346
  #processOrToken(leftNode) {
354
- const right = this.#expression(constants_js_1.BINDING_POWER['or']);
347
+ const right = this.#expression(constants_js_1.BINDING_POWER.or);
355
348
  return (0, ast_js_1.orExpression)(leftNode, right);
356
349
  }
357
350
  /**
@@ -365,7 +358,7 @@ class Parser {
365
358
  * @param leftNode The left hand side of the expression.
366
359
  */
367
360
  #processAndToken(leftNode) {
368
- const right = this.#expression(constants_js_1.BINDING_POWER['and']);
361
+ const right = this.#expression(constants_js_1.BINDING_POWER.and);
369
362
  return (0, ast_js_1.andExpression)(leftNode, right);
370
363
  }
371
364
  #processLParenToken(leftNode) {
@@ -390,13 +383,13 @@ class Parser {
390
383
  right = (0, ast_js_1.identity)();
391
384
  }
392
385
  else {
393
- right = this.#parseProjectionRhs(constants_js_1.BINDING_POWER['flatten']);
386
+ right = this.#parseProjectionRhs(constants_js_1.BINDING_POWER.flatten);
394
387
  }
395
388
  return (0, ast_js_1.filterProjection)(leftNode, right, condition);
396
389
  }
397
390
  #processFlattenToken(leftNode) {
398
391
  const left = (0, ast_js_1.flatten)(leftNode);
399
- const right = this.#parseProjectionRhs(constants_js_1.BINDING_POWER['flatten']);
392
+ const right = this.#parseProjectionRhs(constants_js_1.BINDING_POWER.flatten);
400
393
  return (0, ast_js_1.projection)(left, right);
401
394
  }
402
395
  #processLBracketToken(leftNode) {
@@ -410,17 +403,13 @@ class Parser {
410
403
  leftNode.children.push(right);
411
404
  return leftNode;
412
405
  }
413
- else {
414
- return this.#projectIfSlice(leftNode, right);
415
- }
416
- }
417
- else {
418
- // We have a projection
419
- this.#match('star');
420
- this.#match('rbracket');
421
- const right = this.#parseProjectionRhs(constants_js_1.BINDING_POWER['star']);
422
- return (0, ast_js_1.projection)(leftNode, right);
406
+ return this.#projectIfSlice(leftNode, right);
423
407
  }
408
+ // We have a projection
409
+ this.#match('star');
410
+ this.#match('rbracket');
411
+ const right = this.#parseProjectionRhs(constants_js_1.BINDING_POWER.star);
412
+ return (0, ast_js_1.projection)(leftNode, right);
424
413
  }
425
414
  /**
426
415
  * Throw a parse error.
@@ -458,13 +447,11 @@ class Parser {
458
447
  if (this.#lookahead(0) === 'colon' || this.#lookahead(1) === 'colon') {
459
448
  return this.#parseSliceExpression();
460
449
  }
461
- else {
462
- // Parse the syntax [number]
463
- const node = (0, ast_js_1.index)(this.#lookaheadToken(0).value);
464
- this.#advance();
465
- this.#match('rbracket');
466
- return node;
467
- }
450
+ // Parse the syntax [number]
451
+ const node = (0, ast_js_1.index)(this.#lookaheadToken(0).value);
452
+ this.#advance();
453
+ this.#match('rbracket');
454
+ return node;
468
455
  }
469
456
  /**
470
457
  * Process a slice expression.
@@ -522,11 +509,9 @@ class Parser {
522
509
  #projectIfSlice(left, right) {
523
510
  const idxExpression = (0, ast_js_1.indexExpression)([left, right]);
524
511
  if (right.type === 'slice') {
525
- return (0, ast_js_1.projection)(idxExpression, this.#parseProjectionRhs(constants_js_1.BINDING_POWER['star']));
526
- }
527
- else {
528
- return idxExpression;
512
+ return (0, ast_js_1.projection)(idxExpression, this.#parseProjectionRhs(constants_js_1.BINDING_POWER.star));
529
513
  }
514
+ return idxExpression;
530
515
  }
531
516
  /**
532
517
  * Process a comparator.
@@ -556,9 +541,7 @@ class Parser {
556
541
  if (this.#currentToken() === 'rbracket') {
557
542
  break;
558
543
  }
559
- else {
560
- this.#match('comma');
561
- }
544
+ this.#match('comma');
562
545
  }
563
546
  this.#match('rbracket');
564
547
  return (0, ast_js_1.multiSelectList)(expressions);
@@ -578,15 +561,15 @@ class Parser {
578
561
  // Before getting the token value, verify it's
579
562
  // an identifier.
580
563
  this.#matchMultipleTokens(['quoted_identifier', 'unquoted_identifier']); // token types
581
- const keyName = keyToken['value'];
564
+ const keyName = keyToken.value;
582
565
  this.#match('colon');
583
566
  const value = this.#expression(0);
584
567
  const node = (0, ast_js_1.keyValPair)(keyName, value);
585
568
  pairs.push(node);
586
- if (this.#currentToken() == 'comma') {
569
+ if (this.#currentToken() === 'comma') {
587
570
  this.#match('comma');
588
571
  }
589
- else if (this.#currentToken() == 'rbrace') {
572
+ else if (this.#currentToken() === 'rbrace') {
590
573
  this.#match('rbrace');
591
574
  break;
592
575
  }
@@ -605,13 +588,13 @@ class Parser {
605
588
  // BP of 10 are all the tokens that stop a projection.
606
589
  right = (0, ast_js_1.identity)();
607
590
  }
608
- else if (this.#currentToken() == 'lbracket') {
591
+ else if (this.#currentToken() === 'lbracket') {
609
592
  right = this.#expression(bindingPower);
610
593
  }
611
- else if (this.#currentToken() == 'filter') {
594
+ else if (this.#currentToken() === 'filter') {
612
595
  right = this.#expression(bindingPower);
613
596
  }
614
- else if (this.#currentToken() == 'dot') {
597
+ else if (this.#currentToken() === 'dot') {
615
598
  this.#match('dot');
616
599
  right = this.#parseDotRhs(bindingPower);
617
600
  }
@@ -639,17 +622,15 @@ class Parser {
639
622
  if (['quoted_identifier', 'unquoted_identifier', 'star'].includes(lookahead)) {
640
623
  return this.#expression(bindingPower);
641
624
  }
642
- else if (lookahead == 'lbracket') {
625
+ if (lookahead === 'lbracket') {
643
626
  this.#match('lbracket');
644
627
  return this.#parseMultiSelectList();
645
628
  }
646
- else if (lookahead == 'lbrace') {
629
+ if (lookahead === 'lbrace') {
647
630
  this.#match('lbrace');
648
631
  return this.#parseMultiSelectHash();
649
632
  }
650
- else {
651
- this.#throwParseError();
652
- }
633
+ this.#throwParseError();
653
634
  }
654
635
  /**
655
636
  * Process a token and throw an error if it doesn't match the expected token.
@@ -670,13 +651,11 @@ class Parser {
670
651
  tokenType: token.type,
671
652
  });
672
653
  }
673
- else {
674
- throw new errors_js_1.ParseError({
675
- lexPosition: token.start,
676
- tokenValue: token.value,
677
- tokenType: token.type,
678
- });
679
- }
654
+ throw new errors_js_1.ParseError({
655
+ lexPosition: token.start,
656
+ tokenValue: token.value,
657
+ tokenType: token.type,
658
+ });
680
659
  }
681
660
  }
682
661
  /**
@@ -695,13 +674,11 @@ class Parser {
695
674
  tokenType: token.type,
696
675
  });
697
676
  }
698
- else {
699
- throw new errors_js_1.ParseError({
700
- lexPosition: token.start,
701
- tokenValue: token.value,
702
- tokenType: token.type,
703
- });
704
- }
677
+ throw new errors_js_1.ParseError({
678
+ lexPosition: token.start,
679
+ tokenValue: token.value,
680
+ tokenType: token.type,
681
+ });
705
682
  }
706
683
  this.#advance();
707
684
  }
@@ -1,4 +1,4 @@
1
- import type { Node, JMESPathParsingOptions, JSONObject } from './types.js';
1
+ import type { JMESPathParsingOptions, JSONObject, Node } from './types.js';
2
2
  /**
3
3
  *
4
4
  * A tree interpreter for JMESPath ASTs.
@@ -1 +1 @@
1
- {"version":3,"file":"TreeInterpreter.d.ts","sourceRoot":"","sources":["../../src/TreeInterpreter.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,IAAI,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAG3E;;;;;;;;GAQG;AACH,cAAM,eAAe;;IAGnB;;OAEG;gBACgB,OAAO,CAAC,EAAE,sBAAsB;IASnD;;;;;;;OAOG;IACI,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,GAAG,UAAU,GAAG,IAAI;CA4b/D;AAED,OAAO,EAAE,eAAe,EAAE,CAAC"}
1
+ {"version":3,"file":"TreeInterpreter.d.ts","sourceRoot":"","sources":["../../src/TreeInterpreter.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,sBAAsB,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAG3E;;;;;;;;GAQG;AACH,cAAM,eAAe;;IAGnB;;OAEG;gBACgB,OAAO,CAAC,EAAE,sBAAsB;IASnD;;;;;;;OAOG;IACI,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,GAAG,UAAU,GAAG,IAAI;CA0b/D;AAED,OAAO,EAAE,eAAe,EAAE,CAAC"}