@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.
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TreeInterpreter = void 0;
4
4
  const typeutils_1 = require("@aws-lambda-powertools/commons/typeutils");
5
- const errors_js_1 = require("./errors.js");
6
5
  const Expression_js_1 = require("./Expression.js");
7
6
  const Functions_js_1 = require("./Functions.js");
7
+ const errors_js_1 = require("./errors.js");
8
8
  const utils_js_1 = require("./utils.js");
9
9
  /**
10
10
  *
@@ -67,9 +67,7 @@ class TreeInterpreter {
67
67
  if (visitMethod) {
68
68
  return visitMethod.call(this, node, value);
69
69
  }
70
- else {
71
- throw new errors_js_1.JMESPathError(`Not Implemented: Invalid node type: ${node.type}`);
72
- }
70
+ throw new errors_js_1.JMESPathError(`Not Implemented: Invalid node type: ${node.type}`);
73
71
  }
74
72
  /**
75
73
  * Visit a subexpression, index expression, or pipe node.
@@ -103,9 +101,7 @@ class TreeInterpreter {
103
101
  node.value in value) {
104
102
  return value[node.value];
105
103
  }
106
- else {
107
- return null;
108
- }
104
+ return null;
109
105
  }
110
106
  /**
111
107
  * Visit a comparator node.
@@ -123,24 +119,22 @@ class TreeInterpreter {
123
119
  if (comparator === 'eq') {
124
120
  return (0, typeutils_1.isStrictEqual)(left, right);
125
121
  }
126
- else if (comparator === 'ne') {
122
+ if (comparator === 'ne') {
127
123
  return !(0, typeutils_1.isStrictEqual)(left, right);
128
124
  }
129
- else if (typeof left === 'number' && typeof right === 'number') {
125
+ if (typeof left === 'number' && typeof right === 'number') {
130
126
  // Ordering operators only work on numbers. Evaluating them on other
131
127
  // types will return null.
132
128
  if (comparator === 'lt') {
133
129
  return left < right;
134
130
  }
135
- else if (comparator === 'lte') {
131
+ if (comparator === 'lte') {
136
132
  return left <= right;
137
133
  }
138
- else if (comparator === 'gt') {
134
+ if (comparator === 'gt') {
139
135
  return left > right;
140
136
  }
141
- else {
142
- return left >= right;
143
- }
137
+ return left >= right;
144
138
  }
145
139
  }
146
140
  else {
@@ -193,7 +187,6 @@ class TreeInterpreter {
193
187
  // doesn't know that, so we have to use @ts-ignore to tell it that it's
194
188
  // okay. We could use a type assertion like `as keyof Functions`, but
195
189
  // we also want to keep the args generic, so for now we'll just ignore it.
196
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
197
190
  // @ts-ignore-next-line
198
191
  return this.#functions[funcName](args);
199
192
  }
@@ -60,12 +60,12 @@ const DIGITS = '0123456789';
60
60
  /**
61
61
  * The set of ASCII letters and digits allowed in JMESPath identifiers.
62
62
  */
63
- const START_IDENTIFIER = new Set(ASCII_LETTERS + '_');
63
+ const START_IDENTIFIER = new Set(`${ASCII_LETTERS}_`);
64
64
  exports.START_IDENTIFIER = START_IDENTIFIER;
65
65
  /**
66
66
  * The set of ASCII letters and digits allowed in JMESPath identifiers.
67
67
  */
68
- const VALID_IDENTIFIER = new Set(ASCII_LETTERS + DIGITS + '_');
68
+ const VALID_IDENTIFIER = new Set(`${ASCII_LETTERS}${DIGITS}_`);
69
69
  exports.VALID_IDENTIFIER = VALID_IDENTIFIER;
70
70
  /**
71
71
  * The set of ASCII digits allowed in JMESPath identifiers.
@@ -1 +1 @@
1
- {"version":3,"file":"envelopes.d.ts","sourceRoot":"","sources":["../../src/envelopes.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAErE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,QAAA,MAAM,uBAAuB,YACrB,UAAU,YACN,MAAM,YACN,sBAAsB,KAC/B,CAMF,CAAC;AAEF,QAAA,MAAM,gBAAgB,0BAA0B,CAAC;AACjD,QAAA,MAAM,gBAAgB,0BAA0B,CAAC;AACjD,QAAA,MAAM,GAAG,qCAAqC,CAAC;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E,QAAA,MAAM,UAAU,yEACwD,CAAC;AACzE,QAAA,MAAM,MAAM,gDAAgD,CAAC;AAC7D,QAAA,MAAM,uBAAuB,4FAC8D,CAAC;AAC5F,QAAA,MAAM,mBAAmB,mEACyC,CAAC;AACnE,QAAA,MAAM,kBAAkB,4CAA4C,CAAC;AAErE,OAAO,EACL,uBAAuB,EACvB,gBAAgB,EAChB,gBAAgB,EAChB,GAAG,EACH,GAAG,EACH,WAAW,EACX,2BAA2B,EAC3B,mBAAmB,EACnB,eAAe,EACf,UAAU,EACV,MAAM,EACN,uBAAuB,EACvB,mBAAmB,EACnB,kBAAkB,GACnB,CAAC"}
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.S3_EVENTBRIDGE_SQS = exports.S3_KINESIS_FIREHOSE = exports.S3_SNS_KINESIS_FIREHOSE = exports.S3_SQS = exports.S3_SNS_SQS = exports.CLOUDWATCH_LOGS = exports.KINESIS_DATA_STREAM = exports.CLOUDWATCH_EVENTS_SCHEDULED = exports.EVENTBRIDGE = exports.SNS = exports.SQS = exports.API_GATEWAY_HTTP = exports.API_GATEWAY_REST = exports.extractDataFromEnvelope = void 0;
4
- const search_js_1 = require("./search.js");
5
4
  const PowertoolsFunctions_js_1 = require("./PowertoolsFunctions.js");
5
+ const search_js_1 = require("./search.js");
6
6
  /**
7
7
  * Searches and extracts data using JMESPath
8
8
  *
@@ -56,10 +56,7 @@ const PowertoolsFunctions_js_1 = require("./PowertoolsFunctions.js");
56
56
  * @param options The parsing options to use
57
57
  */
58
58
  const extractDataFromEnvelope = (data, envelope, options) => {
59
- if (!options) {
60
- options = { customFunctions: new PowertoolsFunctions_js_1.PowertoolsFunctions() };
61
- }
62
- return (0, search_js_1.search)(envelope, data, options);
59
+ return (0, search_js_1.search)(envelope, data, options || { customFunctions: new PowertoolsFunctions_js_1.PowertoolsFunctions() });
63
60
  };
64
61
  exports.extractDataFromEnvelope = extractDataFromEnvelope;
65
62
  const API_GATEWAY_REST = 'powertools_json(body)';
@@ -1,6 +1,6 @@
1
- import type { JSONValue, JSONArray } from '@aws-lambda-powertools/commons/types';
1
+ import type { JSONArray, JSONValue } from '@aws-lambda-powertools/commons/types';
2
2
  import type { Functions } from './Functions.js';
3
- import { BINDING_POWER } from './constants.js';
3
+ import type { BINDING_POWER } from './constants.js';
4
4
  /**
5
5
  * A token in the JMESPath AST.
6
6
  */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,SAAS,EACV,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C;;GAEG;AACH,KAAK,KAAK,GAAG;IACX,IAAI,EAAE,MAAM,OAAO,aAAa,CAAC;IACjC,KAAK,EAAE,SAAS,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF;;GAEG;AACH,KAAK,IAAI,GAAG;IACV,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,IAAI,EAAE,CAAC;IACjB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,KAAK,sBAAsB,GAAG;IAC5B;;;;;OAKG;IACH,eAAe,CAAC,EAAE,SAAS,CAAC;CAC7B,CAAC;AAEF;;GAEG;AACH,KAAK,0BAA0B,GAAG,CAChC,MAAM,EAAE,SAAS,GAAG,OAAO,SAAS,EACpC,WAAW,EAAE,MAAM,GAAG,MAAM,EAC5B,UAAU,EAAE,kBAAkB,KAC3B,IAAI,CAAC;AAEV;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,KAAK,wBAAwB,GAAG;IAC9B,cAAc,EAAE,KAAK,C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C,MAAM,CAAC,CAAC,CAAC;IACrC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF;;GAEG;AACH,KAAK,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,CAAC;AAEjD,YAAY,EACV,0BAA0B,EAC1B,wBAAwB,EACxB,IAAI,EACJ,sBAAsB,EACtB,KAAK,EACL,UAAU,GACX,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAUA;;;;;;;;;GASG;AACH,QAAA,MAAM,QAAQ,UAAW,OAAO,KAAG,OAMlC,CAAC;AA4BF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,QAAA,MAAM,UAAU,oCAKb;IACD,KAAK,EAAE,CAAC,EAAE,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,KAAG,CAAC,EAAE,GAAG,IA0BT,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,QAAA,MAAM,UAAU,SACR,OAAO,EAAE,kBACC,MAAM,MAAM,MAAM,CAAC,CAAC,aACzB,OAAO,KACjB,IAcF,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,QAAA,MAAM,SAAS,SACP,OAAO,EAAE,kBACC,MAAM,MAAM,MAAM,CAAC,CAAC,KACnC,IAKF,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,iBAAiB,QAAS,OAAO,gBAAgB,MAAM,MAAM,CAAC,KAAG,IAMtE,CAAC;AA4IF,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,iBAAiB,EAAE,CAAC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAUA;;;;;;;;;GASG;AACH,QAAA,MAAM,QAAQ,UAAW,OAAO,KAAG,OAKlC,CAAC;AA6BF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,QAAA,MAAM,UAAU,GAAI,CAAC,gCAKlB;IACD,KAAK,EAAE,CAAC,EAAE,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,KAAG,CAAC,EAAE,GAAG,IA0BT,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,QAAA,MAAM,UAAU,SACR,OAAO,EAAE,kBACC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,aACzB,OAAO,KACjB,IAcF,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,QAAA,MAAM,SAAS,SACP,OAAO,EAAE,kBACC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,KACnC,IAKF,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,iBAAiB,QAAS,OAAO,gBAAgB,KAAK,CAAC,MAAM,CAAC,KAAG,IAMtE,CAAC;AA+IF,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,iBAAiB,EAAE,CAAC"}
package/lib/cjs/utils.js CHANGED
@@ -18,9 +18,7 @@ const isTruthy = (value) => {
18
18
  if ((0, typeutils_1.isNumber)(value)) {
19
19
  return true;
20
20
  }
21
- else {
22
- return (0, typeutils_1.isTruthy)(value);
23
- }
21
+ return (0, typeutils_1.isTruthy)(value);
24
22
  };
25
23
  exports.isTruthy = isTruthy;
26
24
  /**
@@ -33,16 +31,17 @@ exports.isTruthy = isTruthy;
33
31
  * @param isStepNegative Whether the step is negative
34
32
  */
35
33
  const capSliceRange = (arrayLength, value, isStepNegative) => {
36
- if (value < 0) {
37
- value += arrayLength;
38
- if (value < 0) {
39
- value = isStepNegative ? -1 : 0;
34
+ let capValue = value;
35
+ if (capValue < 0) {
36
+ capValue += arrayLength;
37
+ if (capValue < 0) {
38
+ capValue = isStepNegative ? -1 : 0;
40
39
  }
41
40
  }
42
- else if (value >= arrayLength) {
43
- value = isStepNegative ? arrayLength - 1 : arrayLength;
41
+ else if (capValue >= arrayLength) {
42
+ capValue = isStepNegative ? arrayLength - 1 : arrayLength;
44
43
  }
45
- return value;
44
+ return capValue;
46
45
  };
47
46
  /**
48
47
  * Given a start, stop, and step value, the sub elements in an array are extracted as follows:
@@ -196,8 +195,9 @@ const checkIfArgumentTypeIsValid = (arg, type, index, argumentSpec) => {
196
195
  checkExpressionType(arg, argumentSpec, hasMoreTypesToCheck);
197
196
  return true;
198
197
  }
199
- else if (['string', 'number', 'boolean'].includes(type)) {
198
+ if (['string', 'number', 'boolean'].includes(type)) {
200
199
  typeCheckType(arg, type, argumentSpec, hasMoreTypesToCheck);
200
+ // biome-ignore lint/suspicious/useValidTypeof: we know that `type` is one of 'string', 'number', or 'boolean' because we checked for that above
201
201
  if (typeof arg === type)
202
202
  return true;
203
203
  }
@@ -216,6 +216,7 @@ const checkIfArgumentTypeIsValid = (arg, type, index, argumentSpec) => {
216
216
  * @param hasMoreTypesToCheck Whether there are more types to check
217
217
  */
218
218
  const typeCheckType = (arg, type, argumentSpec, hasMoreTypesToCheck) => {
219
+ // biome-ignore lint/suspicious/useValidTypeof: we know that `type` is one of 'string', 'number', or 'boolean' because we checked before calling this function
219
220
  if (typeof arg !== type && !hasMoreTypesToCheck) {
220
221
  throw new errors_js_1.JMESPathTypeError({
221
222
  currentValue: arg,
@@ -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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zE;;;;OAIG;IAII,QAAQ,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"}
@@ -118,9 +118,7 @@ class Functions {
118
118
  if (isRecord(arg)) {
119
119
  return Object.keys(arg).length;
120
120
  }
121
- else {
122
- return arg.length;
123
- }
121
+ return arg.length;
124
122
  }
125
123
  /**
126
124
  * Map the provided function over the provided array.
@@ -143,13 +141,11 @@ class Functions {
143
141
  return null;
144
142
  // The signature decorator already enforces that all elements are of the same type
145
143
  }
146
- else if (isNumber(arg[0])) {
144
+ if (isNumber(arg[0])) {
147
145
  return Math.max(...arg);
148
146
  }
149
- else {
150
- // local compare function to handle string comparison
151
- return arg.reduce((a, b) => (a > b ? a : b));
152
- }
147
+ // local compare function to handle string comparison
148
+ return arg.reduce((a, b) => (a > b ? a : b));
153
149
  }
154
150
  /**
155
151
  * Get the item in the provided array that has the maximum value when the provided expression is evaluated.
@@ -177,14 +173,12 @@ class Functions {
177
173
  if (max.visited === current.visited) {
178
174
  return max;
179
175
  }
180
- else {
181
- // We can safely cast visited to number | string here because we've already
182
- // checked the type at runtime above and we know that it's either a number or a string
183
- return max.visited >
184
- current.visited
185
- ? max
186
- : current;
187
- }
176
+ // We can safely cast visited to number | string here because we've already
177
+ // checked the type at runtime above and we know that it's either a number or a string
178
+ return max.visited >
179
+ current.visited
180
+ ? max
181
+ : current;
188
182
  }, visitedArgs[0]);
189
183
  return max.arg;
190
184
  }
@@ -196,6 +190,7 @@ class Functions {
196
190
  * @param args The objects to merge
197
191
  */
198
192
  funcMerge(...args) {
193
+ // biome-ignore lint/performance/noAccumulatingSpread: This is a shallow merge so the tradeoff is acceptable
199
194
  return args.reduce((a, b) => ({ ...a, ...b }), {});
200
195
  }
201
196
  /**
@@ -208,12 +203,10 @@ class Functions {
208
203
  return null;
209
204
  // The signature decorator already enforces that all elements are of the same type
210
205
  }
211
- else if (isNumber(arg[0])) {
206
+ if (isNumber(arg[0])) {
212
207
  return Math.min(...arg);
213
208
  }
214
- else {
215
- return arg.reduce((a, b) => (a < b ? a : b));
216
- }
209
+ return arg.reduce((a, b) => (a < b ? a : b));
217
210
  }
218
211
  /**
219
212
  * Get the item in the provided array that has the minimum value when the provided expression is evaluated.
@@ -241,14 +234,12 @@ class Functions {
241
234
  if (min.visited === current.visited) {
242
235
  return min;
243
236
  }
244
- else {
245
- // We can safely cast visited to number | string here because we've already
246
- // checked the type at runtime above and we know that it's either a number or a string
247
- return min.visited <
248
- current.visited
249
- ? min
250
- : current;
251
- }
237
+ // We can safely cast visited to number | string here because we've already
238
+ // checked the type at runtime above and we know that it's either a number or a string
239
+ return min.visited <
240
+ current.visited
241
+ ? min
242
+ : current;
252
243
  }, visitedArgs[0]);
253
244
  return min.arg;
254
245
  }
@@ -317,13 +308,11 @@ class Functions {
317
308
  if (a.visited === b.visited) {
318
309
  return a.index - b.index; // Make the sort stable
319
310
  }
320
- else {
321
- // We can safely cast visited to number | string here because we've already
322
- // checked the type at runtime above and we know that it's either a number or a string
323
- return a.visited > b.visited
324
- ? 1
325
- : -1;
326
- }
311
+ // We can safely cast visited to number | string here because we've already
312
+ // checked the type at runtime above and we know that it's either a number or a string
313
+ return a.visited > b.visited
314
+ ? 1
315
+ : -1;
327
316
  })
328
317
  .map(({ value }) => value); // Extract the original values
329
318
  }
@@ -369,13 +358,11 @@ class Functions {
369
358
  if (typeof arg === 'number') {
370
359
  return arg;
371
360
  }
372
- else if (typeof arg === 'string') {
361
+ if (typeof arg === 'string') {
373
362
  const num = Number(arg);
374
363
  return Number.isNaN(num) ? null : num;
375
364
  }
376
- else {
377
- return null;
378
- }
365
+ return null;
379
366
  }
380
367
  /**
381
368
  * 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/esm/Lexer.js CHANGED
@@ -23,9 +23,7 @@ class Lexer {
23
23
  while (this.#current !== '' && this.#current !== undefined) {
24
24
  if (SIMPLE_TOKENS.has(this.#current)) {
25
25
  yield {
26
- // We know that SIMPLE_TOKENS has this.#current as a key because
27
- // we checked for that above.
28
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
26
+ // biome-ignore lint/style/noNonNullAssertion: We know that SIMPLE_TOKENS has this.#current as a key because we checked for that above.
29
27
  type: SIMPLE_TOKENS.get(this.#current),
30
28
  value: this.#current,
31
29
  start: this.#position,
@@ -53,7 +51,7 @@ class Lexer {
53
51
  const buff = this.#consumeNumber();
54
52
  yield {
55
53
  type: 'number',
56
- value: parseInt(buff),
54
+ value: Number.parseInt(buff),
57
55
  start: start,
58
56
  end: start + buff.length,
59
57
  };
@@ -113,9 +111,7 @@ class Lexer {
113
111
  end: this.#position,
114
112
  };
115
113
  }
116
- else {
117
- throw new LexerError(this.#position - 1, '=');
118
- }
114
+ throw new LexerError(this.#position - 1, '=');
119
115
  }
120
116
  /**
121
117
  * Consume an unquoted identifier.
@@ -149,15 +145,13 @@ class Lexer {
149
145
  if (buff.length > 1) {
150
146
  return {
151
147
  type: 'number',
152
- value: parseInt(buff),
148
+ value: Number.parseInt(buff),
153
149
  start: start,
154
150
  end: start + buff.length,
155
151
  };
156
152
  }
157
- else {
158
- // If the negative sign is not followed by a number, it is an error.
159
- throw new LexerError(start, 'Unknown token after "-"');
160
- }
153
+ // If the negative sign is not followed by a number, it is an error.
154
+ throw new LexerError(start, 'Unknown token after "-"');
161
155
  }
162
156
  /**
163
157
  * Consume a raw string that is a number.
@@ -183,17 +177,15 @@ class Lexer {
183
177
  #consumeSquareBracket() {
184
178
  const start = this.#position;
185
179
  const nextChar = this.#next();
186
- if (nextChar == ']') {
180
+ if (nextChar === ']') {
187
181
  this.#next();
188
182
  return { type: 'flatten', value: '[]', start: start, end: start + 2 };
189
183
  }
190
- else if (nextChar == '?') {
184
+ if (nextChar === '?') {
191
185
  this.#next();
192
186
  return { type: 'filter', value: '[?', start: start, end: start + 2 };
193
187
  }
194
- else {
195
- return { type: 'lbracket', value: '[', start: start, end: start + 1 };
196
- }
188
+ return { type: 'lbracket', value: '[', start: start, end: start + 1 };
197
189
  }
198
190
  /**
199
191
  * Initializes the lexer for the given expression.
@@ -283,7 +275,7 @@ class Lexer {
283
275
  */
284
276
  #consumeQuotedIdentifier() {
285
277
  const start = this.#position;
286
- const lexeme = '"' + this.#consumeUntil('"') + '"';
278
+ const lexeme = `"${this.#consumeUntil('"')}"`;
287
279
  const tokenLen = this.#position - start;
288
280
  return {
289
281
  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"}