@aws-lambda-powertools/jmespath 2.26.1 → 2.28.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.
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/cjs/ast.js CHANGED
@@ -6,9 +6,9 @@ exports.valueProjection = exports.subexpression = exports.slice = exports.projec
6
6
  *
7
7
  * A comparator expression is a binary expression that compares two values.
8
8
  *
9
- * @param name The name of the comparator
10
- * @param first The left-hand side of the comparator
11
- * @param second The right-hand side of the comparator
9
+ * @param name - The name of the comparator
10
+ * @param first - The left-hand side of the comparator
11
+ * @param second - The right-hand side of the comparator
12
12
  */
13
13
  const comparator = (name, first, second) => ({
14
14
  type: 'comparator',
@@ -33,7 +33,7 @@ exports.currentNode = currentNode;
33
33
  * An expression reference is a reference to another expression.
34
34
  * In JMESPath, an expression reference is represented by the `&` symbol.
35
35
  *
36
- * @param expression The expression to reference
36
+ * @param expression - The expression to reference
37
37
  */
38
38
  const expref = (expression) => ({
39
39
  type: 'expref',
@@ -49,8 +49,8 @@ exports.expref = expref;
49
49
  *
50
50
  * Custom functions can be added by extending the `Functions` class.
51
51
  *
52
- * @param name The name of the function
53
- * @param args The arguments to the function
52
+ * @param name - The name of the function
53
+ * @param args - The arguments to the function
54
54
  */
55
55
  const functionExpression = (name, args) => ({
56
56
  type: 'function_expression',
@@ -62,6 +62,8 @@ exports.functionExpression = functionExpression;
62
62
  * AST node representing a field reference.
63
63
  *
64
64
  * A field reference is a reference to a field in an object.
65
+ *
66
+ * @param name - The name of the field
65
67
  */
66
68
  const field = (name) => ({
67
69
  type: 'field',
@@ -79,9 +81,9 @@ exports.field = field;
79
81
  * For example, `people[?age > 18]` filters the `people` array based on the
80
82
  * `age` field.
81
83
  *
82
- * @param left The left-hand side of the filter projection
83
- * @param right The right-hand side of the filter projection
84
- * @param comparator The comparator to use for the filter
84
+ * @param left - The left-hand side of the filter projection
85
+ * @param right - The right-hand side of the filter projection
86
+ * @param comparator - The comparator to use for the filter
85
87
  */
86
88
  const filterProjection = (left, right, comparator) => ({
87
89
  type: 'filter_projection',
@@ -98,7 +100,7 @@ exports.filterProjection = filterProjection;
98
100
  * For example, `people[].name` flattens the `people` array and returns the
99
101
  * `name` field of each object in the array.
100
102
  *
101
- * @param node The node to flatten
103
+ * @param node - The node to flatten
102
104
  */
103
105
  const flatten = (node) => ({
104
106
  type: 'flatten',
@@ -116,7 +118,7 @@ exports.identity = identity;
116
118
  * An index reference is a reference to an index in an array.
117
119
  * For example, `people[0]` references the first element in the `people` array.
118
120
  *
119
- * @param index The index to reference
121
+ * @param index - The index to reference
120
122
  */
121
123
  const index = (index) => ({
122
124
  type: 'index',
@@ -129,7 +131,7 @@ exports.index = index;
129
131
  *
130
132
  * An index expression holds the index and the children of the expression.
131
133
  *
132
- * @param children The children of the index expression
134
+ * @param children - The children of the index expression
133
135
  */
134
136
  const indexExpression = (children) => ({
135
137
  type: 'index_expression',
@@ -139,8 +141,8 @@ exports.indexExpression = indexExpression;
139
141
  /**
140
142
  * AST node representing a key-value pair.
141
143
  *
142
- * @param keyName The name of the key
143
- * @param node The value of the key
144
+ * @param keyName - The name of the key
145
+ * @param node - The value of the key
144
146
  */
145
147
  const keyValPair = (keyName, node) => ({
146
148
  type: 'key_val_pair',
@@ -153,7 +155,7 @@ exports.keyValPair = keyValPair;
153
155
  *
154
156
  * A literal value is a value that is not a reference to another node.
155
157
  *
156
- * @param literalValue The value of the literal
158
+ * @param literalValue - The value of the literal
157
159
  */
158
160
  const literal = (literalValue) => ({
159
161
  type: 'literal',
@@ -166,7 +168,7 @@ exports.literal = literal;
166
168
  *
167
169
  * A multi-select object is a reference to multiple nodes in an object.
168
170
  *
169
- * @param nodes
171
+ * @param nodes - The nodes to select
170
172
  */
171
173
  const multiSelectObject = (nodes) => ({
172
174
  type: 'multi_select_object',
@@ -176,7 +178,7 @@ exports.multiSelectObject = multiSelectObject;
176
178
  /**
177
179
  * AST node representing a multi-select list.
178
180
  *
179
- * @param nodes
181
+ * @param nodes - The nodes to select
180
182
  */
181
183
  const multiSelectList = (nodes) => ({
182
184
  type: 'multi_select_list',
@@ -186,8 +188,8 @@ exports.multiSelectList = multiSelectList;
186
188
  /**
187
189
  * AST node representing an or expression.
188
190
  *
189
- * @param left The left-hand side of the or expression
190
- * @param right The right-hand side of the or expression
191
+ * @param left - The left-hand side of the or expression
192
+ * @param right - The right-hand side of the or expression
191
193
  */
192
194
  const orExpression = (left, right) => ({
193
195
  type: 'or_expression',
@@ -197,8 +199,8 @@ exports.orExpression = orExpression;
197
199
  /**
198
200
  * AST node representing an and expression.
199
201
  *
200
- * @param left The left-hand side of the and expression
201
- * @param right The right-hand side of the and expression
202
+ * @param left - The left-hand side of the and expression
203
+ * @param right - The right-hand side of the and expression
202
204
  */
203
205
  const andExpression = (left, right) => ({
204
206
  type: 'and_expression',
@@ -208,8 +210,8 @@ exports.andExpression = andExpression;
208
210
  /**
209
211
  * AST node representing a not expression.
210
212
  *
211
- * @param left The left-hand side of the not expression
212
- * @param right The right-hand side of the not expression
213
+ * @param left - The left-hand side of the not expression
214
+ * @param right - The right-hand side of the not expression
213
215
  */
214
216
  const notExpression = (expr) => ({
215
217
  type: 'not_expression',
@@ -219,8 +221,8 @@ exports.notExpression = notExpression;
219
221
  /**
220
222
  * AST node representing a pipe expression.
221
223
  *
222
- * @param left The left-hand side of the pipe expression
223
- * @param right The right-hand side of the pipe expression
224
+ * @param left - The left-hand side of the pipe expression
225
+ * @param right - The right-hand side of the pipe expression
224
226
  */
225
227
  const pipe = (left, right) => ({
226
228
  type: 'pipe',
@@ -230,8 +232,8 @@ exports.pipe = pipe;
230
232
  /**
231
233
  * AST node representing a projection.
232
234
  *
233
- * @param left The left-hand side of the projection
234
- * @param right The right-hand side of the projection
235
+ * @param left - The left-hand side of the projection
236
+ * @param right - The right-hand side of the projection
235
237
  */
236
238
  const projection = (left, right) => ({
237
239
  type: 'projection',
@@ -241,7 +243,7 @@ exports.projection = projection;
241
243
  /**
242
244
  * AST node representing a subexpression.
243
245
  *
244
- * @param children The children of the subexpression
246
+ * @param children - The children of the subexpression
245
247
  */
246
248
  const subexpression = (children) => ({
247
249
  type: 'subexpression',
@@ -253,9 +255,9 @@ exports.subexpression = subexpression;
253
255
  *
254
256
  * A slice is a reference to a range of values in an array.
255
257
  *
256
- * @param start The start of the slice
257
- * @param end The end of the slice
258
- * @param step The step of the slice
258
+ * @param start - The start of the slice
259
+ * @param end - The end of the slice
260
+ * @param step - The step of the slice
259
261
  */
260
262
  const slice = (start, end, step) => ({
261
263
  type: 'slice',
@@ -265,8 +267,8 @@ exports.slice = slice;
265
267
  /**
266
268
  * AST node representing a value projection.
267
269
  *
268
- * @param left The left-hand side of the value projection
269
- * @param right The right-hand side of the value projection
270
+ * @param left - The left-hand side of the value projection
271
+ * @param right - The right-hand side of the value projection
270
272
  */
271
273
  const valueProjection = (left, right) => ({
272
274
  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)";
@@ -51,9 +51,9 @@ const search_js_1 = require("./search.js");
51
51
  * };
52
52
  * ```
53
53
  *
54
- * @param data The JSON object to search
55
- * @param envelope The JMESPath expression to use
56
- * @param options The parsing options to use
54
+ * @param data - The JSON object to search
55
+ * @param envelope - The JMESPath expression to use
56
+ * @param options - The parsing options to use
57
57
  */
58
58
  const extractDataFromEnvelope = (data, envelope, options) => {
59
59
  return (0, search_js_1.search)(envelope, data, options || { customFunctions: new PowertoolsFunctions_js_1.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 serializeExpect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}
package/lib/cjs/errors.js CHANGED
@@ -22,7 +22,7 @@ class JMESPathError extends Error {
22
22
  * thrown. In some instances the expression is not known until after the
23
23
  * error is thrown (i.e. the error is thrown down the call stack).
24
24
  *
25
- * @param expression The expression that was being parsed when the error occurred.
25
+ * @param expression - The expression that was being parsed when the error occurred.
26
26
  */
27
27
  setExpression(expression) {
28
28
  this.expression = expression;
@@ -147,7 +147,7 @@ class FunctionError extends JMESPathError {
147
147
  * alias. To avoid passing the function name down the call stack, we set it
148
148
  * after the error is thrown.
149
149
  *
150
- * @param functionName The function that was being validated or executed when the error occurred.
150
+ * @param functionName - The function that was being validated or executed when the error occurred.
151
151
  */
152
152
  setEvaluatedFunctionName(functionName) {
153
153
  this.message = this.message.replace('for function undefined', `for function ${functionName}()`);
@@ -173,6 +173,12 @@ class ArityError extends FunctionError {
173
173
  // Set the message to include the error info.
174
174
  this.message = `Expected ${arityParticle} ${this.expectedArity} ${this.pluralize('argument', this.expectedArity)} for function ${this.functionName}, received ${this.actualArity}`;
175
175
  }
176
+ /**
177
+ * Pluralizes a word based on the count.
178
+ *
179
+ * @param word - The word to pluralize
180
+ * @param count - The count to determine if the word should be pluralized
181
+ */
176
182
  pluralize(word, count) {
177
183
  return count === 1 ? word : `${word}s`;
178
184
  }
@@ -218,6 +224,9 @@ class JMESPathTypeError extends FunctionError {
218
224
  // Set the message to include the error info.
219
225
  this.message = `Invalid argument type for function ${this.functionName}, expected ${this.serializeExpectedTypes()} but found "${this.actualType}"`;
220
226
  }
227
+ /**
228
+ * Serialize the expected types for the error message.
229
+ */
221
230
  serializeExpectedTypes() {
222
231
  const types = [];
223
232
  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/cjs/search.js CHANGED
@@ -45,9 +45,9 @@ const parser = new Parser_js_1.Parser();
45
45
  * console.log(result); // { foo: 'bar' }
46
46
  * ```
47
47
  *
48
- * @param expression The JMESPath expression to use
49
- * @param data The JSON object to search
50
- * @param options The parsing options to use
48
+ * @param expression - The JMESPath expression to use
49
+ * @param data - The JSON object to search
50
+ * @param options - The parsing options to use
51
51
  */
52
52
  const search = (expression, data, options) => {
53
53
  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/cjs/utils.js CHANGED
@@ -12,7 +12,7 @@ const errors_js_1 = require("./errors.js");
12
12
  * this reason we wrap the original isTruthy function from the commons package
13
13
  * and add a check for numbers.
14
14
  *
15
- * @param value The value to check
15
+ * @param value - The value to check
16
16
  */
17
17
  const isTruthy = (value) => {
18
18
  if ((0, typeutils_1.isNumber)(value)) {
@@ -26,9 +26,9 @@ exports.isTruthy = isTruthy;
26
26
  * Cap a slice range value to the length of an array, taking into account
27
27
  * negative values and whether the step is negative.
28
28
  *
29
- * @param arrayLength The length of the array
30
- * @param value The value to cap
31
- * @param isStepNegative Whether the step is negative
29
+ * @param arrayLength - The length of the array
30
+ * @param value - The value to cap
31
+ * @param isStepNegative - Whether the step is negative
32
32
  */
33
33
  const capSliceRange = (arrayLength, value, isStepNegative) => {
34
34
  let capValue = value;
@@ -45,24 +45,24 @@ const capSliceRange = (arrayLength, value, isStepNegative) => {
45
45
  };
46
46
  /**
47
47
  * Given a start, stop, and step value, the sub elements in an array are extracted as follows:
48
- * * The first element in the extracted array is the index denoted by start.
49
- * * The last element in the extracted array is the index denoted by end - 1.
50
- * * 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.
48
+ * - The first element in the extracted array is the index denoted by start.
49
+ * - The last element in the extracted array is the index denoted by end - 1.
50
+ * - 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.
51
51
  *
52
52
  * Slice expressions adhere to the following rules:
53
- * * If a negative start position is given, it is calculated as the total length of the array plus the given start position.
54
- * * 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.
55
- * * If a negative stop position is given, it is calculated as the total length of the array plus the given stop position.
56
- * * 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.
57
- * * If the given step is omitted, it it assumed to be 1.
58
- * * If the given step is 0, an invalid-value error MUST be raised (thrown before calling the function)
59
- * * If the element being sliced is not an array, the result is null (returned before calling the function)
60
- * * If the element being sliced is an array and yields no results, the result MUST be an empty array.
53
+ * - If a negative start position is given, it is calculated as the total length of the array plus the given start position.
54
+ * - 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.
55
+ * - If a negative stop position is given, it is calculated as the total length of the array plus the given stop position.
56
+ * - 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.
57
+ * - If the given step is omitted, it it assumed to be 1.
58
+ * - If the given step is 0, an invalid-value error MUST be raised (thrown before calling the function)
59
+ * - If the element being sliced is not an array, the result is null (returned before calling the function)
60
+ * - If the element being sliced is an array and yields no results, the result MUST be an empty array.
61
61
  *
62
- * @param array The array to slice
63
- * @param start The start index
64
- * @param end The end index
65
- * @param step The step value
62
+ * @param array - The array to slice
63
+ * @param start - The start index
64
+ * @param end - The end index
65
+ * @param step - The step value
66
66
  */
67
67
  const sliceArray = ({ array, start, end, step, }) => {
68
68
  const isStepNegative = step < 0;
@@ -97,10 +97,10 @@ exports.sliceArray = sliceArray;
97
97
  * greater than or equal to the expected arity. If the number of arguments passed to the function
98
98
  * is less than the expected arity, a `VariadicArityError` is thrown.
99
99
  *
100
- * @param args The arguments passed to the function
101
- * @param argumentsSpecs The expected types for each argument
102
- * @param decoratedFuncName The name of the function being called
103
- * @param variadic Whether the function is variadic
100
+ * @param args - The arguments passed to the function
101
+ * @param argumentsSpecs - The expected types for each argument
102
+ * @param decoratedFuncName - The name of the function being called
103
+ * @param variadic - Whether the function is variadic
104
104
  */
105
105
  const arityCheck = (args, argumentsSpecs, variadic) => {
106
106
  if (variadic) {
@@ -135,8 +135,8 @@ exports.arityCheck = arityCheck;
135
135
  * passes. If the argument does not match any of the types, then
136
136
  * a JMESPathTypeError is thrown.
137
137
  *
138
- * @param args The arguments passed to the function
139
- * @param argumentsSpecs The expected types for each argument
138
+ * @param args - The arguments passed to the function
139
+ * @param argumentsSpecs - The expected types for each argument
140
140
  */
141
141
  const typeCheck = (args, argumentsSpecs) => {
142
142
  for (const [index, argumentSpec] of argumentsSpecs.entries()) {
@@ -155,25 +155,25 @@ exports.typeCheck = typeCheck;
155
155
  * passes. If the argument does not match any of the types, then
156
156
  * a JMESPathTypeError is thrown.
157
157
  *
158
- * @param arg
159
- * @param argumentSpec
158
+ * @param arg - The argument to check
159
+ * @param argumentSpec - The expected types for the argument
160
160
  */
161
161
  const typeCheckArgument = (arg, argumentSpec) => {
162
162
  let valid = false;
163
- argumentSpec.forEach((type, index) => {
163
+ for (const [index, type] of argumentSpec.entries()) {
164
164
  if (valid)
165
165
  return;
166
166
  valid = checkIfArgumentTypeIsValid(arg, type, index, argumentSpec);
167
- });
167
+ }
168
168
  };
169
169
  exports.typeCheckArgument = typeCheckArgument;
170
170
  /**
171
171
  * Check if the argument is of the expected type.
172
172
  *
173
- * @param arg The argument to check
174
- * @param type The expected type
175
- * @param index The index of the type we are checking
176
- * @param argumentSpec The list of types to check against
173
+ * @param arg - The argument to check
174
+ * @param type - The expected type
175
+ * @param index - The index of the type we are checking
176
+ * @param argumentSpec - The list of types to check against
177
177
  */
178
178
  const checkIfArgumentTypeIsValid = (arg, type, index, argumentSpec) => {
179
179
  const hasMoreTypesToCheck = index < argumentSpec.length - 1;
@@ -209,10 +209,10 @@ const checkIfArgumentTypeIsValid = (arg, type, index, argumentSpec) => {
209
209
  /**
210
210
  * Check if the argument is of the expected type.
211
211
  *
212
- * @param arg The argument to check
213
- * @param type The type to check against
214
- * @param argumentSpec The list of types to check against
215
- * @param hasMoreTypesToCheck Whether there are more types to check
212
+ * @param arg - The argument to check
213
+ * @param type - The type to check against
214
+ * @param argumentSpec - The list of types to check against
215
+ * @param hasMoreTypesToCheck - Whether there are more types to check
216
216
  */
217
217
  const typeCheckType = (arg, type, argumentSpec, hasMoreTypesToCheck) => {
218
218
  if (typeof arg !== type && !hasMoreTypesToCheck) {
@@ -226,9 +226,9 @@ const typeCheckType = (arg, type, argumentSpec, hasMoreTypesToCheck) => {
226
226
  /**
227
227
  * Check if the argument is an array of complex types.
228
228
  *
229
- * @param arg The argument to check
230
- * @param type The type to check against
231
- * @param hasMoreTypesToCheck Whether there are more types to check
229
+ * @param arg - The argument to check
230
+ * @param type - The type to check against
231
+ * @param hasMoreTypesToCheck - Whether there are more types to check
232
232
  */
233
233
  const checkComplexArrayType = (arg, type, hasMoreTypesToCheck) => {
234
234
  if (!type.includes('-'))
@@ -250,9 +250,9 @@ const checkComplexArrayType = (arg, type, hasMoreTypesToCheck) => {
250
250
  /**
251
251
  * Check if the argument is an expression.
252
252
  *
253
- * @param arg The argument to check
254
- * @param type The type to check against
255
- * @param hasMoreTypesToCheck Whether there are more types to check
253
+ * @param arg - The argument to check
254
+ * @param type - The type to check against
255
+ * @param hasMoreTypesToCheck - Whether there are more types to check
256
256
  */
257
257
  const checkExpressionType = (arg, type, hasMoreTypesToCheck) => {
258
258
  if (!(arg instanceof Expression_js_1.Expression) && !hasMoreTypesToCheck) {
@@ -266,9 +266,9 @@ const checkExpressionType = (arg, type, hasMoreTypesToCheck) => {
266
266
  /**
267
267
  * Check if the argument is an object.
268
268
  *
269
- * @param arg The argument to check
270
- * @param type The type to check against
271
- * @param hasMoreTypesToCheck Whether there are more types to check
269
+ * @param arg - The argument to check
270
+ * @param type - The type to check against
271
+ * @param hasMoreTypesToCheck - Whether there are more types to check
272
272
  */
273
273
  const checkObjectType = (arg, type, hasMoreTypesToCheck) => {
274
274
  if (!(0, typeutils_1.isRecord)(arg) && !hasMoreTypesToCheck) {
@@ -9,9 +9,8 @@ declare class Expression {
9
9
  /**
10
10
  * Evaluate the expression against a JSON value.
11
11
  *
12
- * @param value The JSON value to apply the expression to.
13
- * @param node The node to visit.
14
- * @returns The result of applying the expression to the value.
12
+ * @param value - The JSON value to apply the expression to.
13
+ * @param node - The node to visit.
15
14
  */
16
15
  visit(value: JSONObject, node?: Node): JSONObject;
17
16
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Expression.d.ts","sourceRoot":"","sources":["../../src/Expression.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEnD;;GAEG;AACH,cAAM,UAAU;;gBAIK,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,eAAe;IAKjE;;;;;;OAMG;IACI,KAAK,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG,UAAU;CAGzD;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
1
+ {"version":3,"file":"Expression.d.ts","sourceRoot":"","sources":["../../src/Expression.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEnD;;GAEG;AACH,cAAM,UAAU;;gBAIK,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,eAAe;IAKjE;;;;;OAKG;IACI,KAAK,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG,UAAU;CAGzD;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}