@aws-lambda-powertools/jmespath 2.27.0 → 2.28.1

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.
Files changed (60) hide show
  1. package/README.md +4 -4
  2. package/lib/cjs/Expression.d.ts +2 -3
  3. package/lib/cjs/Expression.d.ts.map +1 -1
  4. package/lib/cjs/Expression.js +2 -3
  5. package/lib/cjs/Functions.d.ts +36 -36
  6. package/lib/cjs/Functions.js +36 -36
  7. package/lib/cjs/Lexer.js +2 -2
  8. package/lib/cjs/ParsedResult.d.ts +2 -2
  9. package/lib/cjs/ParsedResult.js +2 -2
  10. package/lib/cjs/Parser.d.ts +1 -2
  11. package/lib/cjs/Parser.d.ts.map +1 -1
  12. package/lib/cjs/Parser.js +42 -23
  13. package/lib/cjs/PowertoolsFunctions.d.ts +3 -5
  14. package/lib/cjs/PowertoolsFunctions.d.ts.map +1 -1
  15. package/lib/cjs/PowertoolsFunctions.js +4 -6
  16. package/lib/cjs/TreeInterpreter.js +2 -2
  17. package/lib/cjs/ast.d.ts +35 -33
  18. package/lib/cjs/ast.d.ts.map +1 -1
  19. package/lib/cjs/ast.js +35 -33
  20. package/lib/cjs/constants.d.ts.map +1 -1
  21. package/lib/cjs/envelopes.d.ts +3 -3
  22. package/lib/cjs/envelopes.js +3 -3
  23. package/lib/cjs/errors.d.ts +11 -2
  24. package/lib/cjs/errors.d.ts.map +1 -1
  25. package/lib/cjs/errors.js +11 -2
  26. package/lib/cjs/search.d.ts +3 -3
  27. package/lib/cjs/search.js +3 -3
  28. package/lib/cjs/types.d.ts +2 -2
  29. package/lib/cjs/utils.d.ts +24 -24
  30. package/lib/cjs/utils.js +46 -46
  31. package/lib/esm/Expression.d.ts +2 -3
  32. package/lib/esm/Expression.d.ts.map +1 -1
  33. package/lib/esm/Expression.js +2 -3
  34. package/lib/esm/Functions.d.ts +36 -36
  35. package/lib/esm/Functions.js +36 -36
  36. package/lib/esm/Lexer.js +2 -2
  37. package/lib/esm/ParsedResult.d.ts +2 -2
  38. package/lib/esm/ParsedResult.js +2 -2
  39. package/lib/esm/Parser.d.ts +1 -2
  40. package/lib/esm/Parser.d.ts.map +1 -1
  41. package/lib/esm/Parser.js +42 -23
  42. package/lib/esm/PowertoolsFunctions.d.ts +3 -5
  43. package/lib/esm/PowertoolsFunctions.d.ts.map +1 -1
  44. package/lib/esm/PowertoolsFunctions.js +3 -5
  45. package/lib/esm/TreeInterpreter.js +2 -2
  46. package/lib/esm/ast.d.ts +35 -33
  47. package/lib/esm/ast.d.ts.map +1 -1
  48. package/lib/esm/ast.js +35 -33
  49. package/lib/esm/constants.d.ts.map +1 -1
  50. package/lib/esm/envelopes.d.ts +3 -3
  51. package/lib/esm/envelopes.js +3 -3
  52. package/lib/esm/errors.d.ts +11 -2
  53. package/lib/esm/errors.d.ts.map +1 -1
  54. package/lib/esm/errors.js +11 -2
  55. package/lib/esm/search.d.ts +3 -3
  56. package/lib/esm/search.js +3 -3
  57. package/lib/esm/types.d.ts +2 -2
  58. package/lib/esm/utils.d.ts +24 -24
  59. package/lib/esm/utils.js +46 -46
  60. package/package.json +2 -2
package/lib/esm/ast.js CHANGED
@@ -3,9 +3,9 @@
3
3
  *
4
4
  * A comparator expression is a binary expression that compares two values.
5
5
  *
6
- * @param name The name of the comparator
7
- * @param first The left-hand side of the comparator
8
- * @param second The right-hand side of the comparator
6
+ * @param name - The name of the comparator
7
+ * @param first - The left-hand side of the comparator
8
+ * @param second - The right-hand side of the comparator
9
9
  */
10
10
  const comparator = (name, first, second) => ({
11
11
  type: 'comparator',
@@ -28,7 +28,7 @@ const currentNode = () => ({
28
28
  * An expression reference is a reference to another expression.
29
29
  * In JMESPath, an expression reference is represented by the `&` symbol.
30
30
  *
31
- * @param expression The expression to reference
31
+ * @param expression - The expression to reference
32
32
  */
33
33
  const expref = (expression) => ({
34
34
  type: 'expref',
@@ -43,8 +43,8 @@ const expref = (expression) => ({
43
43
  *
44
44
  * Custom functions can be added by extending the `Functions` class.
45
45
  *
46
- * @param name The name of the function
47
- * @param args The arguments to the function
46
+ * @param name - The name of the function
47
+ * @param args - The arguments to the function
48
48
  */
49
49
  const functionExpression = (name, args) => ({
50
50
  type: 'function_expression',
@@ -55,6 +55,8 @@ const functionExpression = (name, args) => ({
55
55
  * AST node representing a field reference.
56
56
  *
57
57
  * A field reference is a reference to a field in an object.
58
+ *
59
+ * @param name - The name of the field
58
60
  */
59
61
  const field = (name) => ({
60
62
  type: 'field',
@@ -71,9 +73,9 @@ const field = (name) => ({
71
73
  * For example, `people[?age > 18]` filters the `people` array based on the
72
74
  * `age` field.
73
75
  *
74
- * @param left The left-hand side of the filter projection
75
- * @param right The right-hand side of the filter projection
76
- * @param comparator The comparator to use for the filter
76
+ * @param left - The left-hand side of the filter projection
77
+ * @param right - The right-hand side of the filter projection
78
+ * @param comparator - The comparator to use for the filter
77
79
  */
78
80
  const filterProjection = (left, right, comparator) => ({
79
81
  type: 'filter_projection',
@@ -89,7 +91,7 @@ const filterProjection = (left, right, comparator) => ({
89
91
  * For example, `people[].name` flattens the `people` array and returns the
90
92
  * `name` field of each object in the array.
91
93
  *
92
- * @param node The node to flatten
94
+ * @param node - The node to flatten
93
95
  */
94
96
  const flatten = (node) => ({
95
97
  type: 'flatten',
@@ -105,7 +107,7 @@ const identity = () => ({ type: 'identity', children: [] });
105
107
  * An index reference is a reference to an index in an array.
106
108
  * For example, `people[0]` references the first element in the `people` array.
107
109
  *
108
- * @param index The index to reference
110
+ * @param index - The index to reference
109
111
  */
110
112
  const index = (index) => ({
111
113
  type: 'index',
@@ -117,7 +119,7 @@ const index = (index) => ({
117
119
  *
118
120
  * An index expression holds the index and the children of the expression.
119
121
  *
120
- * @param children The children of the index expression
122
+ * @param children - The children of the index expression
121
123
  */
122
124
  const indexExpression = (children) => ({
123
125
  type: 'index_expression',
@@ -126,8 +128,8 @@ const indexExpression = (children) => ({
126
128
  /**
127
129
  * AST node representing a key-value pair.
128
130
  *
129
- * @param keyName The name of the key
130
- * @param node The value of the key
131
+ * @param keyName - The name of the key
132
+ * @param node - The value of the key
131
133
  */
132
134
  const keyValPair = (keyName, node) => ({
133
135
  type: 'key_val_pair',
@@ -139,7 +141,7 @@ const keyValPair = (keyName, node) => ({
139
141
  *
140
142
  * A literal value is a value that is not a reference to another node.
141
143
  *
142
- * @param literalValue The value of the literal
144
+ * @param literalValue - The value of the literal
143
145
  */
144
146
  const literal = (literalValue) => ({
145
147
  type: 'literal',
@@ -151,7 +153,7 @@ const literal = (literalValue) => ({
151
153
  *
152
154
  * A multi-select object is a reference to multiple nodes in an object.
153
155
  *
154
- * @param nodes
156
+ * @param nodes - The nodes to select
155
157
  */
156
158
  const multiSelectObject = (nodes) => ({
157
159
  type: 'multi_select_object',
@@ -160,7 +162,7 @@ const multiSelectObject = (nodes) => ({
160
162
  /**
161
163
  * AST node representing a multi-select list.
162
164
  *
163
- * @param nodes
165
+ * @param nodes - The nodes to select
164
166
  */
165
167
  const multiSelectList = (nodes) => ({
166
168
  type: 'multi_select_list',
@@ -169,8 +171,8 @@ const multiSelectList = (nodes) => ({
169
171
  /**
170
172
  * AST node representing an or expression.
171
173
  *
172
- * @param left The left-hand side of the or expression
173
- * @param right The right-hand side of the or expression
174
+ * @param left - The left-hand side of the or expression
175
+ * @param right - The right-hand side of the or expression
174
176
  */
175
177
  const orExpression = (left, right) => ({
176
178
  type: 'or_expression',
@@ -179,8 +181,8 @@ const orExpression = (left, right) => ({
179
181
  /**
180
182
  * AST node representing an and expression.
181
183
  *
182
- * @param left The left-hand side of the and expression
183
- * @param right The right-hand side of the and expression
184
+ * @param left - The left-hand side of the and expression
185
+ * @param right - The right-hand side of the and expression
184
186
  */
185
187
  const andExpression = (left, right) => ({
186
188
  type: 'and_expression',
@@ -189,8 +191,8 @@ const andExpression = (left, right) => ({
189
191
  /**
190
192
  * AST node representing a not expression.
191
193
  *
192
- * @param left The left-hand side of the not expression
193
- * @param right The right-hand side of the not expression
194
+ * @param left - The left-hand side of the not expression
195
+ * @param right - The right-hand side of the not expression
194
196
  */
195
197
  const notExpression = (expr) => ({
196
198
  type: 'not_expression',
@@ -199,8 +201,8 @@ const notExpression = (expr) => ({
199
201
  /**
200
202
  * AST node representing a pipe expression.
201
203
  *
202
- * @param left The left-hand side of the pipe expression
203
- * @param right The right-hand side of the pipe expression
204
+ * @param left - The left-hand side of the pipe expression
205
+ * @param right - The right-hand side of the pipe expression
204
206
  */
205
207
  const pipe = (left, right) => ({
206
208
  type: 'pipe',
@@ -209,8 +211,8 @@ const pipe = (left, right) => ({
209
211
  /**
210
212
  * AST node representing a projection.
211
213
  *
212
- * @param left The left-hand side of the projection
213
- * @param right The right-hand side of the projection
214
+ * @param left - The left-hand side of the projection
215
+ * @param right - The right-hand side of the projection
214
216
  */
215
217
  const projection = (left, right) => ({
216
218
  type: 'projection',
@@ -219,7 +221,7 @@ const projection = (left, right) => ({
219
221
  /**
220
222
  * AST node representing a subexpression.
221
223
  *
222
- * @param children The children of the subexpression
224
+ * @param children - The children of the subexpression
223
225
  */
224
226
  const subexpression = (children) => ({
225
227
  type: 'subexpression',
@@ -230,9 +232,9 @@ const subexpression = (children) => ({
230
232
  *
231
233
  * A slice is a reference to a range of values in an array.
232
234
  *
233
- * @param start The start of the slice
234
- * @param end The end of the slice
235
- * @param step The step of the slice
235
+ * @param start - The start of the slice
236
+ * @param end - The end of the slice
237
+ * @param step - The step of the slice
236
238
  */
237
239
  const slice = (start, end, step) => ({
238
240
  type: 'slice',
@@ -241,8 +243,8 @@ const slice = (start, end, step) => ({
241
243
  /**
242
244
  * AST node representing a value projection.
243
245
  *
244
- * @param left The left-hand side of the value projection
245
- * @param right The right-hand side of the value projection
246
+ * @param left - The left-hand side of the value projection
247
+ * @param right - The right-hand side of the value projection
246
248
  */
247
249
  const valueProjection = (left, right) => ({
248
250
  type: 'value_projection',
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+BT,CAAC;AAkBX;;GAEG;AACH,QAAA,MAAM,gBAAgB,aAA+B,CAAC;AACtD;;GAEG;AACH,QAAA,MAAM,gBAAgB,aAAwC,CAAC;AAC/D;;GAEG;AACH,QAAA,MAAM,YAAY,aAAkB,CAAC;AACrC;;GAEG;AACH,QAAA,MAAM,UAAU,aAAqB,CAAC;AACtC;;GAEG;AACH,QAAA,MAAM,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,OAAO,aAAa,CAYzD,CAAC;AAEH,OAAO,EACL,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,UAAU,GACX,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+BT,CAAC;AAsBX;;GAEG;AACH,QAAA,MAAM,gBAAgB,aAA+B,CAAC;AAEtD;;GAEG;AACH,QAAA,MAAM,gBAAgB,aAAwC,CAAC;AAE/D;;GAEG;AACH,QAAA,MAAM,YAAY,aAAkB,CAAC;AACrC;;GAEG;AACH,QAAA,MAAM,UAAU,aAAqB,CAAC;AAEtC;;GAEG;AACH,QAAA,MAAM,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,OAAO,aAAa,CAYzD,CAAC;AAEH,OAAO,EACL,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,UAAU,GACX,CAAC"}
@@ -47,9 +47,9 @@ import type { JMESPathParsingOptions, JSONObject } from './types.js';
47
47
  * };
48
48
  * ```
49
49
  *
50
- * @param data The JSON object to search
51
- * @param envelope The JMESPath expression to use
52
- * @param options The parsing options to use
50
+ * @param data - The JSON object to search
51
+ * @param envelope - The JMESPath expression to use
52
+ * @param options - The parsing options to use
53
53
  */
54
54
  declare const extractDataFromEnvelope: <T>(data: JSONObject, envelope: string, options?: JMESPathParsingOptions) => T;
55
55
  declare const API_GATEWAY_REST = "powertools_json(body)";
@@ -48,9 +48,9 @@ import { search } from './search.js';
48
48
  * };
49
49
  * ```
50
50
  *
51
- * @param data The JSON object to search
52
- * @param envelope The JMESPath expression to use
53
- * @param options The parsing options to use
51
+ * @param data - The JSON object to search
52
+ * @param envelope - The JMESPath expression to use
53
+ * @param options - The parsing options to use
54
54
  */
55
55
  const extractDataFromEnvelope = (data, envelope, options) => {
56
56
  return search(envelope, data, options || { customFunctions: new PowertoolsFunctions() });
@@ -16,7 +16,7 @@ declare class JMESPathError extends Error {
16
16
  * thrown. In some instances the expression is not known until after the
17
17
  * error is thrown (i.e. the error is thrown down the call stack).
18
18
  *
19
- * @param expression The expression that was being parsed when the error occurred.
19
+ * @param expression - The expression that was being parsed when the error occurred.
20
20
  */
21
21
  setExpression(expression: string): void;
22
22
  }
@@ -107,7 +107,7 @@ declare class FunctionError extends JMESPathError {
107
107
  * alias. To avoid passing the function name down the call stack, we set it
108
108
  * after the error is thrown.
109
109
  *
110
- * @param functionName The function that was being validated or executed when the error occurred.
110
+ * @param functionName - The function that was being validated or executed when the error occurred.
111
111
  */
112
112
  setEvaluatedFunctionName(functionName: string): void;
113
113
  }
@@ -126,6 +126,12 @@ declare class ArityError extends FunctionError {
126
126
  expectedArity: number;
127
127
  actualArity: number;
128
128
  });
129
+ /**
130
+ * Pluralizes a word based on the count.
131
+ *
132
+ * @param word - The word to pluralize
133
+ * @param count - The count to determine if the word should be pluralized
134
+ */
129
135
  protected pluralize(word: string, count: number): string;
130
136
  }
131
137
  /**
@@ -161,6 +167,9 @@ declare class JMESPathTypeError extends FunctionError {
161
167
  actualType: string;
162
168
  expectedTypes: string[];
163
169
  });
170
+ /**
171
+ * Serialize the expected types for the error message.
172
+ */
164
173
  protected serializeExpectedTypes(): string;
165
174
  }
166
175
  /**
@@ -1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19,7 @@ class JMESPathError extends Error {
19
19
  * thrown. In some instances the expression is not known until after the
20
20
  * error is thrown (i.e. the error is thrown down the call stack).
21
21
  *
22
- * @param expression The expression that was being parsed when the error occurred.
22
+ * @param expression - The expression that was being parsed when the error occurred.
23
23
  */
24
24
  setExpression(expression) {
25
25
  this.expression = expression;
@@ -139,7 +139,7 @@ class FunctionError extends JMESPathError {
139
139
  * alias. To avoid passing the function name down the call stack, we set it
140
140
  * after the error is thrown.
141
141
  *
142
- * @param functionName The function that was being validated or executed when the error occurred.
142
+ * @param functionName - The function that was being validated or executed when the error occurred.
143
143
  */
144
144
  setEvaluatedFunctionName(functionName) {
145
145
  this.message = this.message.replace('for function undefined', `for function ${functionName}()`);
@@ -165,6 +165,12 @@ class ArityError extends FunctionError {
165
165
  // Set the message to include the error info.
166
166
  this.message = `Expected ${arityParticle} ${this.expectedArity} ${this.pluralize('argument', this.expectedArity)} for function ${this.functionName}, received ${this.actualArity}`;
167
167
  }
168
+ /**
169
+ * Pluralizes a word based on the count.
170
+ *
171
+ * @param word - The word to pluralize
172
+ * @param count - The count to determine if the word should be pluralized
173
+ */
168
174
  pluralize(word, count) {
169
175
  return count === 1 ? word : `${word}s`;
170
176
  }
@@ -208,6 +214,9 @@ class JMESPathTypeError extends FunctionError {
208
214
  // Set the message to include the error info.
209
215
  this.message = `Invalid argument type for function ${this.functionName}, expected ${this.serializeExpectedTypes()} but found "${this.actualType}"`;
210
216
  }
217
+ /**
218
+ * Serialize the expected types for the error message.
219
+ */
211
220
  serializeExpectedTypes() {
212
221
  const types = [];
213
222
  for (const type of this.expectedTypes) {
@@ -41,9 +41,9 @@ import type { JMESPathParsingOptions, JSONObject } from './types.js';
41
41
  * console.log(result); // { foo: 'bar' }
42
42
  * ```
43
43
  *
44
- * @param expression The JMESPath expression to use
45
- * @param data The JSON object to search
46
- * @param options The parsing options to use
44
+ * @param expression - The JMESPath expression to use
45
+ * @param data - The JSON object to search
46
+ * @param options - The parsing options to use
47
47
  */
48
48
  declare const search: (expression: string, data: JSONObject, options?: JMESPathParsingOptions) => unknown;
49
49
  export { search };
package/lib/esm/search.js CHANGED
@@ -42,9 +42,9 @@ const parser = new Parser();
42
42
  * console.log(result); // { foo: 'bar' }
43
43
  * ```
44
44
  *
45
- * @param expression The JMESPath expression to use
46
- * @param data The JSON object to search
47
- * @param options The parsing options to use
45
+ * @param expression - The JMESPath expression to use
46
+ * @param data - The JSON object to search
47
+ * @param options - The parsing options to use
48
48
  */
49
49
  const search = (expression, data, options) => {
50
50
  return parser.parse(expression).search(data, options);
@@ -69,8 +69,8 @@ type FunctionSignatureDecorator = (target: Functions | typeof Functions, propert
69
69
  * }
70
70
  * ```
71
71
  *
72
- * @param argumentsSpecs The expected arguments for the function.
73
- * @param variadic Whether the function is variadic.
72
+ * @param argumentsSpecs - The expected arguments for the function.
73
+ * @param variadic - Whether the function is variadic.
74
74
  */
75
75
  type FunctionSignatureOptions = {
76
76
  argumentsSpecs: Array<Array<string>>;
@@ -6,29 +6,29 @@
6
6
  * this reason we wrap the original isTruthy function from the commons package
7
7
  * and add a check for numbers.
8
8
  *
9
- * @param value The value to check
9
+ * @param value - The value to check
10
10
  */
11
11
  declare const isTruthy: (value: unknown) => boolean;
12
12
  /**
13
13
  * Given a start, stop, and step value, the sub elements in an array are extracted as follows:
14
- * * The first element in the extracted array is the index denoted by start.
15
- * * The last element in the extracted array is the index denoted by end - 1.
16
- * * The step value determines how many indices to skip after each element is selected from the array. An array of 1 (the default step) will not skip any indices. A step value of 2 will skip every other index while extracting elements from an array. A step value of -1 will extract values in reverse order from the array.
14
+ * - The first element in the extracted array is the index denoted by start.
15
+ * - The last element in the extracted array is the index denoted by end - 1.
16
+ * - The step value determines how many indices to skip after each element is selected from the array. An array of 1 (the default step) will not skip any indices. A step value of 2 will skip every other index while extracting elements from an array. A step value of -1 will extract values in reverse order from the array.
17
17
  *
18
18
  * Slice expressions adhere to the following rules:
19
- * * If a negative start position is given, it is calculated as the total length of the array plus the given start position.
20
- * * If no start position is given, it is assumed to be 0 if the given step is greater than 0 or the end of the array if the given step is less than 0.
21
- * * If a negative stop position is given, it is calculated as the total length of the array plus the given stop position.
22
- * * If no stop position is given, it is assumed to be the length of the array if the given step is greater than 0 or 0 if the given step is less than 0.
23
- * * If the given step is omitted, it it assumed to be 1.
24
- * * If the given step is 0, an invalid-value error MUST be raised (thrown before calling the function)
25
- * * If the element being sliced is not an array, the result is null (returned before calling the function)
26
- * * If the element being sliced is an array and yields no results, the result MUST be an empty array.
19
+ * - If a negative start position is given, it is calculated as the total length of the array plus the given start position.
20
+ * - If no start position is given, it is assumed to be 0 if the given step is greater than 0 or the end of the array if the given step is less than 0.
21
+ * - If a negative stop position is given, it is calculated as the total length of the array plus the given stop position.
22
+ * - If no stop position is given, it is assumed to be the length of the array if the given step is greater than 0 or 0 if the given step is less than 0.
23
+ * - If the given step is omitted, it it assumed to be 1.
24
+ * - If the given step is 0, an invalid-value error MUST be raised (thrown before calling the function)
25
+ * - If the element being sliced is not an array, the result is null (returned before calling the function)
26
+ * - If the element being sliced is an array and yields no results, the result MUST be an empty array.
27
27
  *
28
- * @param array The array to slice
29
- * @param start The start index
30
- * @param end The end index
31
- * @param step The step value
28
+ * @param array - The array to slice
29
+ * @param start - The start index
30
+ * @param end - The end index
31
+ * @param step - The step value
32
32
  */
33
33
  declare const sliceArray: <T>({ array, start, end, step, }: {
34
34
  array: T[];
@@ -44,10 +44,10 @@ declare const sliceArray: <T>({ array, start, end, step, }: {
44
44
  * greater than or equal to the expected arity. If the number of arguments passed to the function
45
45
  * is less than the expected arity, a `VariadicArityError` is thrown.
46
46
  *
47
- * @param args The arguments passed to the function
48
- * @param argumentsSpecs The expected types for each argument
49
- * @param decoratedFuncName The name of the function being called
50
- * @param variadic Whether the function is variadic
47
+ * @param args - The arguments passed to the function
48
+ * @param argumentsSpecs - The expected types for each argument
49
+ * @param decoratedFuncName - The name of the function being called
50
+ * @param variadic - Whether the function is variadic
51
51
  */
52
52
  declare const arityCheck: (args: unknown[], argumentsSpecs: Array<Array<string>>, variadic?: boolean) => void;
53
53
  /**
@@ -66,8 +66,8 @@ declare const arityCheck: (args: unknown[], argumentsSpecs: Array<Array<string>>
66
66
  * passes. If the argument does not match any of the types, then
67
67
  * a JMESPathTypeError is thrown.
68
68
  *
69
- * @param args The arguments passed to the function
70
- * @param argumentsSpecs The expected types for each argument
69
+ * @param args - The arguments passed to the function
70
+ * @param argumentsSpecs - The expected types for each argument
71
71
  */
72
72
  declare const typeCheck: (args: unknown[], argumentsSpecs: Array<Array<string>>) => void;
73
73
  /**
@@ -79,8 +79,8 @@ declare const typeCheck: (args: unknown[], argumentsSpecs: Array<Array<string>>)
79
79
  * passes. If the argument does not match any of the types, then
80
80
  * a JMESPathTypeError is thrown.
81
81
  *
82
- * @param arg
83
- * @param argumentSpec
82
+ * @param arg - The argument to check
83
+ * @param argumentSpec - The expected types for the argument
84
84
  */
85
85
  declare const typeCheckArgument: (arg: unknown, argumentSpec: Array<string>) => void;
86
86
  export { isTruthy, arityCheck, sliceArray, typeCheck, typeCheckArgument };
package/lib/esm/utils.js CHANGED
@@ -9,7 +9,7 @@ import { ArityError, JMESPathTypeError, VariadicArityError } from './errors.js';
9
9
  * this reason we wrap the original isTruthy function from the commons package
10
10
  * and add a check for numbers.
11
11
  *
12
- * @param value The value to check
12
+ * @param value - The value to check
13
13
  */
14
14
  const isTruthy = (value) => {
15
15
  if (isNumber(value)) {
@@ -22,9 +22,9 @@ const isTruthy = (value) => {
22
22
  * Cap a slice range value to the length of an array, taking into account
23
23
  * negative values and whether the step is negative.
24
24
  *
25
- * @param arrayLength The length of the array
26
- * @param value The value to cap
27
- * @param isStepNegative Whether the step is negative
25
+ * @param arrayLength - The length of the array
26
+ * @param value - The value to cap
27
+ * @param isStepNegative - Whether the step is negative
28
28
  */
29
29
  const capSliceRange = (arrayLength, value, isStepNegative) => {
30
30
  let capValue = value;
@@ -41,24 +41,24 @@ const capSliceRange = (arrayLength, value, isStepNegative) => {
41
41
  };
42
42
  /**
43
43
  * Given a start, stop, and step value, the sub elements in an array are extracted as follows:
44
- * * The first element in the extracted array is the index denoted by start.
45
- * * The last element in the extracted array is the index denoted by end - 1.
46
- * * The step value determines how many indices to skip after each element is selected from the array. An array of 1 (the default step) will not skip any indices. A step value of 2 will skip every other index while extracting elements from an array. A step value of -1 will extract values in reverse order from the array.
44
+ * - The first element in the extracted array is the index denoted by start.
45
+ * - The last element in the extracted array is the index denoted by end - 1.
46
+ * - The step value determines how many indices to skip after each element is selected from the array. An array of 1 (the default step) will not skip any indices. A step value of 2 will skip every other index while extracting elements from an array. A step value of -1 will extract values in reverse order from the array.
47
47
  *
48
48
  * Slice expressions adhere to the following rules:
49
- * * If a negative start position is given, it is calculated as the total length of the array plus the given start position.
50
- * * If no start position is given, it is assumed to be 0 if the given step is greater than 0 or the end of the array if the given step is less than 0.
51
- * * If a negative stop position is given, it is calculated as the total length of the array plus the given stop position.
52
- * * If no stop position is given, it is assumed to be the length of the array if the given step is greater than 0 or 0 if the given step is less than 0.
53
- * * If the given step is omitted, it it assumed to be 1.
54
- * * If the given step is 0, an invalid-value error MUST be raised (thrown before calling the function)
55
- * * If the element being sliced is not an array, the result is null (returned before calling the function)
56
- * * If the element being sliced is an array and yields no results, the result MUST be an empty array.
49
+ * - If a negative start position is given, it is calculated as the total length of the array plus the given start position.
50
+ * - If no start position is given, it is assumed to be 0 if the given step is greater than 0 or the end of the array if the given step is less than 0.
51
+ * - If a negative stop position is given, it is calculated as the total length of the array plus the given stop position.
52
+ * - If no stop position is given, it is assumed to be the length of the array if the given step is greater than 0 or 0 if the given step is less than 0.
53
+ * - If the given step is omitted, it it assumed to be 1.
54
+ * - If the given step is 0, an invalid-value error MUST be raised (thrown before calling the function)
55
+ * - If the element being sliced is not an array, the result is null (returned before calling the function)
56
+ * - If the element being sliced is an array and yields no results, the result MUST be an empty array.
57
57
  *
58
- * @param array The array to slice
59
- * @param start The start index
60
- * @param end The end index
61
- * @param step The step value
58
+ * @param array - The array to slice
59
+ * @param start - The start index
60
+ * @param end - The end index
61
+ * @param step - The step value
62
62
  */
63
63
  const sliceArray = ({ array, start, end, step, }) => {
64
64
  const isStepNegative = step < 0;
@@ -92,10 +92,10 @@ const sliceArray = ({ array, start, end, step, }) => {
92
92
  * greater than or equal to the expected arity. If the number of arguments passed to the function
93
93
  * is less than the expected arity, a `VariadicArityError` is thrown.
94
94
  *
95
- * @param args The arguments passed to the function
96
- * @param argumentsSpecs The expected types for each argument
97
- * @param decoratedFuncName The name of the function being called
98
- * @param variadic Whether the function is variadic
95
+ * @param args - The arguments passed to the function
96
+ * @param argumentsSpecs - The expected types for each argument
97
+ * @param decoratedFuncName - The name of the function being called
98
+ * @param variadic - Whether the function is variadic
99
99
  */
100
100
  const arityCheck = (args, argumentsSpecs, variadic) => {
101
101
  if (variadic) {
@@ -129,8 +129,8 @@ const arityCheck = (args, argumentsSpecs, variadic) => {
129
129
  * passes. If the argument does not match any of the types, then
130
130
  * a JMESPathTypeError is thrown.
131
131
  *
132
- * @param args The arguments passed to the function
133
- * @param argumentsSpecs The expected types for each argument
132
+ * @param args - The arguments passed to the function
133
+ * @param argumentsSpecs - The expected types for each argument
134
134
  */
135
135
  const typeCheck = (args, argumentsSpecs) => {
136
136
  for (const [index, argumentSpec] of argumentsSpecs.entries()) {
@@ -148,24 +148,24 @@ const typeCheck = (args, argumentsSpecs) => {
148
148
  * passes. If the argument does not match any of the types, then
149
149
  * a JMESPathTypeError is thrown.
150
150
  *
151
- * @param arg
152
- * @param argumentSpec
151
+ * @param arg - The argument to check
152
+ * @param argumentSpec - The expected types for the argument
153
153
  */
154
154
  const typeCheckArgument = (arg, argumentSpec) => {
155
155
  let valid = false;
156
- argumentSpec.forEach((type, index) => {
156
+ for (const [index, type] of argumentSpec.entries()) {
157
157
  if (valid)
158
158
  return;
159
159
  valid = checkIfArgumentTypeIsValid(arg, type, index, argumentSpec);
160
- });
160
+ }
161
161
  };
162
162
  /**
163
163
  * Check if the argument is of the expected type.
164
164
  *
165
- * @param arg The argument to check
166
- * @param type The expected type
167
- * @param index The index of the type we are checking
168
- * @param argumentSpec The list of types to check against
165
+ * @param arg - The argument to check
166
+ * @param type - The expected type
167
+ * @param index - The index of the type we are checking
168
+ * @param argumentSpec - The list of types to check against
169
169
  */
170
170
  const checkIfArgumentTypeIsValid = (arg, type, index, argumentSpec) => {
171
171
  const hasMoreTypesToCheck = index < argumentSpec.length - 1;
@@ -201,10 +201,10 @@ const checkIfArgumentTypeIsValid = (arg, type, index, argumentSpec) => {
201
201
  /**
202
202
  * Check if the argument is of the expected type.
203
203
  *
204
- * @param arg The argument to check
205
- * @param type The type to check against
206
- * @param argumentSpec The list of types to check against
207
- * @param hasMoreTypesToCheck Whether there are more types to check
204
+ * @param arg - The argument to check
205
+ * @param type - The type to check against
206
+ * @param argumentSpec - The list of types to check against
207
+ * @param hasMoreTypesToCheck - Whether there are more types to check
208
208
  */
209
209
  const typeCheckType = (arg, type, argumentSpec, hasMoreTypesToCheck) => {
210
210
  if (typeof arg !== type && !hasMoreTypesToCheck) {
@@ -218,9 +218,9 @@ const typeCheckType = (arg, type, argumentSpec, hasMoreTypesToCheck) => {
218
218
  /**
219
219
  * Check if the argument is an array of complex types.
220
220
  *
221
- * @param arg The argument to check
222
- * @param type The type to check against
223
- * @param hasMoreTypesToCheck Whether there are more types to check
221
+ * @param arg - The argument to check
222
+ * @param type - The type to check against
223
+ * @param hasMoreTypesToCheck - Whether there are more types to check
224
224
  */
225
225
  const checkComplexArrayType = (arg, type, hasMoreTypesToCheck) => {
226
226
  if (!type.includes('-'))
@@ -242,9 +242,9 @@ const checkComplexArrayType = (arg, type, hasMoreTypesToCheck) => {
242
242
  /**
243
243
  * Check if the argument is an expression.
244
244
  *
245
- * @param arg The argument to check
246
- * @param type The type to check against
247
- * @param hasMoreTypesToCheck Whether there are more types to check
245
+ * @param arg - The argument to check
246
+ * @param type - The type to check against
247
+ * @param hasMoreTypesToCheck - Whether there are more types to check
248
248
  */
249
249
  const checkExpressionType = (arg, type, hasMoreTypesToCheck) => {
250
250
  if (!(arg instanceof Expression) && !hasMoreTypesToCheck) {
@@ -258,9 +258,9 @@ const checkExpressionType = (arg, type, hasMoreTypesToCheck) => {
258
258
  /**
259
259
  * Check if the argument is an object.
260
260
  *
261
- * @param arg The argument to check
262
- * @param type The type to check against
263
- * @param hasMoreTypesToCheck Whether there are more types to check
261
+ * @param arg - The argument to check
262
+ * @param type - The type to check against
263
+ * @param hasMoreTypesToCheck - Whether there are more types to check
264
264
  */
265
265
  const checkObjectType = (arg, type, hasMoreTypesToCheck) => {
266
266
  if (!isRecord(arg) && !hasMoreTypesToCheck) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-lambda-powertools/jmespath",
3
- "version": "2.27.0",
3
+ "version": "2.28.1",
4
4
  "description": "A type safe and modern jmespath module to parse and extract data from JSON documents using JMESPath",
5
5
  "author": {
6
6
  "name": "Amazon Web Services",
@@ -25,7 +25,7 @@
25
25
  "nodejs"
26
26
  ],
27
27
  "dependencies": {
28
- "@aws-lambda-powertools/commons": "2.27.0"
28
+ "@aws-lambda-powertools/commons": "2.28.1"
29
29
  },
30
30
  "main": "./lib/cjs/index.js",
31
31
  "types": "./lib/cjs/index.d.ts",