jtlt 0.2.0 → 0.3.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 (50) hide show
  1. package/CHANGES.md +18 -0
  2. package/README.md +16 -87
  3. package/demo/calltemplate-params-demo.js +138 -0
  4. package/demo/index.html +31 -0
  5. package/demo/index.js +30 -0
  6. package/demo/xpath2-placeholder.js +1 -0
  7. package/dist/AbstractJoiningTransformer.d.ts +83 -9
  8. package/dist/AbstractJoiningTransformer.d.ts.map +1 -1
  9. package/dist/DOMJoiningTransformer.d.ts +85 -25
  10. package/dist/DOMJoiningTransformer.d.ts.map +1 -1
  11. package/dist/JSONJoiningTransformer.d.ts +159 -51
  12. package/dist/JSONJoiningTransformer.d.ts.map +1 -1
  13. package/dist/JSONPathTransformer.d.ts +37 -38
  14. package/dist/JSONPathTransformer.d.ts.map +1 -1
  15. package/dist/JSONPathTransformerContext.d.ts +247 -121
  16. package/dist/JSONPathTransformerContext.d.ts.map +1 -1
  17. package/dist/StringJoiningTransformer.d.ts +132 -41
  18. package/dist/StringJoiningTransformer.d.ts.map +1 -1
  19. package/dist/XPathTransformer.d.ts +35 -20
  20. package/dist/XPathTransformer.d.ts.map +1 -1
  21. package/dist/XPathTransformerContext.d.ts +191 -99
  22. package/dist/XPathTransformerContext.d.ts.map +1 -1
  23. package/dist/index-browser.d.ts +4 -0
  24. package/dist/index-browser.d.ts.map +1 -0
  25. package/dist/index-node.d.ts +4 -0
  26. package/dist/index-node.d.ts.map +1 -0
  27. package/dist/index.d.ts +330 -57
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/types.d.ts +204 -0
  30. package/dist/types.d.ts.map +1 -0
  31. package/docs/API.expanded.md +167 -2
  32. package/docs/API.md +91 -1
  33. package/docs/TO-DO.md +144 -0
  34. package/docs/calltemplate-params.md +251 -0
  35. package/eslint.config.js +9 -5
  36. package/package.json +13 -7
  37. package/pnpm-workspace.yaml +1 -0
  38. package/src/AbstractJoiningTransformer.js +54 -15
  39. package/src/DOMJoiningTransformer.js +275 -28
  40. package/src/JSONJoiningTransformer.js +351 -70
  41. package/src/JSONPathTransformer.js +48 -30
  42. package/src/JSONPathTransformerContext.js +308 -104
  43. package/src/StringJoiningTransformer.js +311 -57
  44. package/src/XPathTransformer.js +27 -12
  45. package/src/XPathTransformerContext.js +467 -89
  46. package/src/index-browser.js +5 -0
  47. package/src/index-node.js +7 -0
  48. package/src/index.js +498 -97
  49. package/typings/xpath2-js.d.ts +40 -1
  50. package/src/types/xpath2-js.d.ts +0 -2
@@ -1,4 +1,88 @@
1
1
  export default JSONPathTransformerContext;
2
+ /**
3
+ * Sort spec types used by applyTemplates() and forEach().
4
+ */
5
+ export type SortObject = {
6
+ select?: string;
7
+ order?: "ascending" | "descending";
8
+ type?: "text" | "number";
9
+ locale?: string;
10
+ localeOptions?: unknown;
11
+ };
12
+ /**
13
+ * Sort spec types used by applyTemplates() and forEach().
14
+ */
15
+ export type SortComparator = (a: unknown, b: unknown, ctx: JSONPathTransformerContext) => number;
16
+ /**
17
+ * Sort spec types used by applyTemplates() and forEach().
18
+ */
19
+ export type SortSpec = string | SortObject | SortComparator | Array<string | SortObject>;
20
+ export type JSONPathTransformerContextConfig<T = "json"> = {
21
+ /**
22
+ * - Data to transform
23
+ */
24
+ data: null | boolean | number | string | object;
25
+ /**
26
+ * - Parent object
27
+ */
28
+ parent?: object | undefined;
29
+ /**
30
+ * - Parent property name
31
+ */
32
+ parentProperty?: string | undefined;
33
+ /**
34
+ * - Whether to error on
35
+ * equal priority
36
+ */
37
+ errorOnEqualPriority?: boolean | undefined;
38
+ /**
39
+ * - Joining transformer
40
+ */
41
+ joiningTransformer: T extends "json" ? import("./JSONJoiningTransformer.js").default : T extends "string" ? import("./StringJoiningTransformer.js").default : import("./DOMJoiningTransformer.js").default;
42
+ /**
43
+ * - Whether to prevent eval in
44
+ * JSONPath
45
+ */
46
+ preventEval?: boolean | undefined;
47
+ /**
48
+ * Priority resolver function
49
+ */
50
+ specificityPriorityResolver?: ((path: string) => number) | undefined;
51
+ templates: import("./index.js").JSONPathTemplateObject<T>[];
52
+ };
53
+ /**
54
+ * Sort spec types used by applyTemplates() and forEach().
55
+ * @typedef {{
56
+ * select?: string,
57
+ * order?: 'ascending' | 'descending',
58
+ * type?: 'text'|'number',
59
+ * locale?: string,
60
+ * localeOptions?: unknown
61
+ * }} SortObject
62
+ * @typedef {(a: unknown, b: unknown,
63
+ * ctx: JSONPathTransformerContext
64
+ * ) => number} SortComparator
65
+ * @typedef {string | SortObject | SortComparator |
66
+ * Array<string|SortObject>} SortSpec
67
+ */
68
+ /**
69
+ * @template [T = "json"]
70
+ * @typedef {object} JSONPathTransformerContextConfig
71
+ * @property {null|boolean|number|string|object} data - Data to transform
72
+ * @property {object} [parent] - Parent object
73
+ * @property {string} [parentProperty] - Parent property name
74
+ * @property {boolean} [errorOnEqualPriority] - Whether to error on
75
+ * equal priority
76
+ * @property {T extends "json" ? import('./JSONJoiningTransformer.js').
77
+ * default : T extends "string" ? import('./StringJoiningTransformer.js').
78
+ * default : import('./DOMJoiningTransformer.js').
79
+ * default} joiningTransformer - Joining transformer
80
+ * @property {boolean} [preventEval] - Whether to prevent eval in
81
+ * JSONPath
82
+ * @property {(path: string) => number} [specificityPriorityResolver]
83
+ * Priority resolver function
84
+ * @property {import('./index.js').JSONPathTemplateObject<T>[]} templates
85
+ */
2
86
  /**
3
87
  * Execution context for JSONPath-driven template application.
4
88
  *
@@ -6,69 +90,36 @@ export default JSONPathTransformerContext;
6
90
  * running templates. Exposes helper methods that mirror the underlying
7
91
  * joining transformer (e.g., string(), object(), array()) so templates can
8
92
  * emit results without referencing the joiner directly.
93
+ * @template [T = "json"]
9
94
  */
10
- declare class JSONPathTransformerContext {
11
- /**
12
- * @param {object} config - Configuration object
13
- * @param {object} config.data - Data to transform
14
- * @param {object} [config.parent] - Parent object
15
- * @param {string} [config.parentProperty] - Parent property name
16
- * @param {boolean} [config.errorOnEqualPriority] - Whether to error on
17
- * equal priority
18
- * @param {{append: Function, get: Function, string: Function,
19
- * object: Function, array: Function}} config.joiningTransformer -
20
- * Joining transformer
21
- * @param {boolean} [config.preventEval] - Whether to prevent eval in
22
- * JSONPath
23
- * @param {Function} [config.specificityPriorityResolver] - Function to
24
- * resolve priority
25
- * @param {any[]} templates - Array of template objects
26
- */
27
- constructor(config: {
28
- data: object;
29
- parent?: object | undefined;
30
- parentProperty?: string | undefined;
31
- errorOnEqualPriority?: boolean | undefined;
32
- joiningTransformer: {
33
- append: Function;
34
- get: Function;
35
- string: Function;
36
- object: Function;
37
- array: Function;
38
- };
39
- preventEval?: boolean | undefined;
40
- specificityPriorityResolver?: Function | undefined;
41
- }, templates: any[]);
42
- _config: {
43
- data: object;
44
- parent?: object | undefined;
45
- parentProperty?: string | undefined;
46
- errorOnEqualPriority?: boolean | undefined;
47
- joiningTransformer: {
48
- append: Function;
49
- get: Function;
50
- string: Function;
51
- object: Function;
52
- array: Function;
53
- };
54
- preventEval?: boolean | undefined;
55
- specificityPriorityResolver?: Function | undefined;
56
- };
57
- _templates: any[];
58
- _contextObj: object;
59
- _origObj: object;
95
+ declare class JSONPathTransformerContext<T = "json"> {
96
+ /**
97
+ * @param {JSONPathTransformerContextConfig<T>} config
98
+ * @param {import('./index.js').JSONPathTemplateObject<T>[]} templates - Array
99
+ * of template objects
100
+ */
101
+ constructor(config: JSONPathTransformerContextConfig<T>, templates: import("./index.js").JSONPathTemplateObject<T>[]);
102
+ _config: JSONPathTransformerContextConfig<T>;
103
+ _templates: import("./index.js").JSONPathTemplateObject<T>[];
104
+ _contextObj: string | number | boolean | object | null;
105
+ _origObj: string | number | boolean | object | null;
60
106
  _parent: object;
61
107
  _parentProperty: string;
62
- /** @type {Record<string, any>} */
63
- vars: Record<string, any>;
64
- /** @type {Record<string, any>} */
65
- propertySets: Record<string, any>;
66
- /** @type {Record<string, any>} */
67
- keys: Record<string, any>;
108
+ /** @type {Record<string, unknown>} */
109
+ vars: Record<string, unknown>;
110
+ /** @type {Record<string, Record<string, unknown>>} */
111
+ propertySets: Record<string, Record<string, unknown>>;
112
+ /** @type {Record<string, {match: string, use: string}>} */
113
+ keys: Record<string, {
114
+ match: string;
115
+ use: string;
116
+ }>;
68
117
  /** @type {boolean | undefined} */
69
118
  _initialized: boolean | undefined;
70
119
  /** @type {string | undefined} */
71
120
  _currPath: string | undefined;
121
+ /** @type {Record<string, any> | undefined} */
122
+ _params: Record<string, any> | undefined;
72
123
  /**
73
124
  * Triggers an error if equal priority templates are found.
74
125
  * @returns {void}
@@ -76,17 +127,20 @@ declare class JSONPathTransformerContext {
76
127
  _triggerEqualPriorityError(): void;
77
128
  /**
78
129
  * Gets the joining transformer from config.
79
- * @returns {any} The joining transformer
130
+ * @returns {T extends "json" ? import('./JSONJoiningTransformer.js').
131
+ * default : T extends "string" ? import('./StringJoiningTransformer.js').
132
+ * default : import('./DOMJoiningTransformer.js').
133
+ * default} The joining transformer
80
134
  */
81
- _getJoiningTransformer(): any;
135
+ _getJoiningTransformer(): T extends "json" ? import("./JSONJoiningTransformer.js").default : T extends "string" ? import("./StringJoiningTransformer.js").default : import("./DOMJoiningTransformer.js").default;
82
136
  /**
83
- * @param {*} item - Item to append to output
84
- * @returns {JSONPathTransformerContext}
137
+ * @param {string | Node} item - Item to append to output
138
+ * @returns {this}
85
139
  */
86
- appendOutput(item: any): JSONPathTransformerContext;
140
+ appendOutput(item: string | Node): this;
87
141
  /**
88
142
  * Gets the current output.
89
- * @returns {*} The output from the joining transformer
143
+ * @returns {any} The output from the joining transformer
90
144
  */
91
145
  getOutput(): any;
92
146
  /**
@@ -95,14 +149,14 @@ declare class JSONPathTransformerContext {
95
149
  * to the result tree instead).
96
150
  * @param {string} select - JSONPath selector
97
151
  * @param {boolean} wrap - Whether to wrap results
98
- * @returns {*} The selected value(s)
152
+ * @returns {any} The selected value(s)
99
153
  */
100
154
  get(select: string, wrap: boolean): any;
101
155
  /**
102
- * @param {*} v - Value to set
103
- * @returns {JSONPathTransformerContext}
156
+ * @param {any} v - Value to set
157
+ * @returns {this}
104
158
  */
105
- set(v: any): JSONPathTransformerContext;
159
+ set(v: any): this;
106
160
  /**
107
161
  * Apply matching templates to nodes selected by JSONPath, optionally sorted.
108
162
  *
@@ -113,151 +167,223 @@ declare class JSONPathTransformerContext {
113
167
  * locale, localeOptions }
114
168
  * - array: multiple key objects/strings in priority order.
115
169
  *
116
- * @param {string|object} select - JSONPath selector or options object
170
+ * @param {string|null|
171
+ * {mode?: string, select?: string}
172
+ * } [select] - JSONPath selector or options object
117
173
  * @param {string} [mode] - Mode to apply
118
- * @param {string|Function|object|Array<string|object>} [sort] - Sort spec
119
- * @returns {JSONPathTransformerContext}
174
+ * @param {SortSpec} [sort] - Sort spec
175
+ * @returns {this}
120
176
  */
121
- applyTemplates(select: string | object, mode?: string, sort?: string | Function | object | Array<string | object>): JSONPathTransformerContext;
177
+ applyTemplates(select?: string | null | {
178
+ mode?: string;
179
+ select?: string;
180
+ }, mode?: string, sort?: SortSpec): this;
122
181
  /**
123
- * @param {string|object} name - Template name or options object
182
+ * @param {string|
183
+ * {name: string, withParam?: any[]}} name - Template name or
184
+ * options object
124
185
  * @param {any[]} [withParams] - Parameters to pass to template
125
- * @returns {JSONPathTransformerContext}
186
+ * @returns {this}
126
187
  */
127
- callTemplate(name: string | object, withParams?: any[]): JSONPathTransformerContext;
188
+ callTemplate(name: string | {
189
+ name: string;
190
+ withParam?: any[];
191
+ }, withParams?: any[]): this;
128
192
  /**
129
193
  * Iterate over values selected by JSONPath, optionally sorted.
130
194
  *
131
195
  * Sort parameter forms are the same as applyTemplates().
132
196
  * @param {string} select - JSONPath selector
133
- * @param {Function} cb - Callback function
134
- * @param {string|Function|object|Array<string|object>} [sort] - Sort spec
135
- * @returns {JSONPathTransformerContext}
197
+ * @param {(this: JSONPathTransformerContext<T>,
198
+ * value: any
199
+ * ) => void} cb - Callback function
200
+ * @param {SortSpec} [sort] - Sort spec
201
+ * @returns {this}
136
202
  */
137
- forEach(select: string, cb: Function, sort?: string | Function | object | Array<string | object>): JSONPathTransformerContext;
203
+ forEach(select: string, cb: (this: JSONPathTransformerContext<T>, value: any) => void, sort?: SortSpec): this;
138
204
  /**
139
205
  * @param {string|object} [select] - JSONPath selector
140
- * @returns {JSONPathTransformerContext}
206
+ * @returns {this}
141
207
  */
142
- valueOf(select?: string | object): JSONPathTransformerContext;
208
+ valueOf(select?: string | object): this;
143
209
  /**
144
210
  * Deep copy selection or current context when omitted.
145
211
  * @param {string} [select] - JSONPath selector
146
- * @returns {JSONPathTransformerContext}
212
+ * @returns {this}
147
213
  */
148
- copyOf(select?: string): JSONPathTransformerContext;
214
+ copyOf(select?: string): this;
149
215
  /**
150
216
  * Shallow copy current context; optionally merge property set names.
151
217
  * @param {string[]} [propertySets] - Property sets to merge
152
- * @returns {JSONPathTransformerContext}
218
+ * @returns {this}
153
219
  */
154
- copy(propertySets?: string[]): JSONPathTransformerContext;
220
+ copy(propertySets?: string[]): this;
155
221
  /**
156
222
  * @param {string} name - Variable name
157
223
  * @param {string} select - JSONPath selector
158
- * @returns {JSONPathTransformerContext}
224
+ * @returns {this}
159
225
  */
160
- variable(name: string, select: string): JSONPathTransformerContext;
226
+ variable(name: string, select: string): this;
161
227
  /**
162
- * @param {*} json - JSON data to log
228
+ * @param {unknown} json - JSON data to log
163
229
  * @returns {void}
164
230
  */
165
- message(json: any): void;
231
+ message(json: unknown): void;
166
232
  /**
167
233
  * @param {string} str - String value
168
- * @param {Function} cb - Callback function
169
- * @returns {JSONPathTransformerContext}
234
+ * @param {import('./JSONJoiningTransformer.js').
235
+ * SimpleCallback<T>} [cb] - Optional callback to build nested
236
+ * string content
237
+ * @returns {this}
170
238
  */
171
- string(str: string, cb: Function): JSONPathTransformerContext;
239
+ string(str: string, cb?: import("./JSONJoiningTransformer.js").SimpleCallback<T>): this;
172
240
  /**
173
241
  * Append a number to JSON output. Mirrors the joining transformer API so
174
242
  * templates can call `this.number()`.
175
243
  * @param {number} num - Number value to append
176
- * @returns {JSONPathTransformerContext}
244
+ * @returns {this}
177
245
  */
178
- number(num: number): JSONPathTransformerContext;
246
+ number(num: number): this;
179
247
  /**
180
248
  * Append plain text directly to the output without escaping or JSON
181
249
  * stringification. Mirrors the joining transformer API so templates can
182
250
  * call `this.plainText()`.
183
251
  * @param {string} str - Plain text to append
184
- * @returns {JSONPathTransformerContext}
252
+ * @returns {this}
185
253
  */
186
- plainText(str: string): JSONPathTransformerContext;
254
+ plainText(str: string): this;
187
255
  /**
188
256
  * Set a property value on the current object (JSON joiner). Mirrors the
189
257
  * joining transformer API so templates can call `this.propValue()`.
190
258
  * @param {string} prop - Property name
191
- * @param {*} val - Property value
192
- * @returns {JSONPathTransformerContext}
259
+ * @param {any} val - Property value
260
+ * @returns {this}
193
261
  */
194
- propValue(prop: string, val: any): JSONPathTransformerContext;
262
+ propValue(prop: string, val: any): this;
195
263
  /**
196
264
  * Build an object. Mirrors the joining transformer API. All joiners now
197
265
  * support both signatures: (obj, cb, usePropertySets, propSets) with seed
198
266
  * object or (cb, usePropertySets, propSets) without.
199
267
  * @param {...any} args - Arguments to pass to joiner
200
- * @returns {JSONPathTransformerContext}
268
+ * @returns {this}
201
269
  */
202
- object(...args: any[]): JSONPathTransformerContext;
270
+ object(...args: any[]): this;
203
271
  /**
204
272
  * Build an array. Mirrors the joining transformer API. All joiners now
205
273
  * support both signatures: (arr, cb) with seed array or (cb) without.
206
274
  * @param {...any} args - Arguments to pass to joiner
207
- * @returns {JSONPathTransformerContext}
275
+ * @returns {this}
276
+ */
277
+ array(...args: any[]): this;
278
+ /**
279
+ * Set document-level configuration.
280
+ * @param {import('./StringJoiningTransformer.js').OutputConfig} cfg Text
281
+ * @returns {this}
208
282
  */
209
- array(...args: any[]): JSONPathTransformerContext;
283
+ output(cfg: import("./StringJoiningTransformer.js").OutputConfig): this;
210
284
  /**
211
285
  * Create an element. Mirrors the joining transformer API so templates can
212
286
  * call `this.element()`.
213
287
  * @param {string} name - Element name
214
- * @param {object} [atts] - Attributes object
288
+ * @param {Record<string, string>} [atts] - Attributes object
215
289
  * @param {any[]} [children] - Child nodes
216
- * @param {Function} [cb] - Callback function
217
- * @returns {JSONPathTransformerContext}
290
+ * @param {import('./JSONJoiningTransformer.js').
291
+ * SimpleCallback<T>} [cb] - Callback function
292
+ * @returns {this}
218
293
  */
219
- element(name: string, atts?: object, children?: any[], cb?: Function): JSONPathTransformerContext;
294
+ element(name: string, atts?: Record<string, string>, children?: any[], cb?: import("./JSONJoiningTransformer.js").SimpleCallback<T>): this;
220
295
  /**
221
296
  * Add an attribute to the most recently opened element. Mirrors the joining
222
297
  * transformer API so templates can call `this.attribute()`.
223
298
  * @param {string} name - Attribute name
224
- * @param {string|object} val - Attribute value
225
- * @param {boolean} [avoidAttEscape] - Whether to avoid escaping
226
- * @returns {JSONPathTransformerContext}
299
+ * @param {string|Record<string, unknown>} val - Attribute value
300
+ * @returns {this}
227
301
  */
228
- attribute(name: string, val: string | object, avoidAttEscape?: boolean): JSONPathTransformerContext;
302
+ attribute(name: string, val: string | Record<string, unknown>): this;
229
303
  /**
230
304
  * Append text content. Mirrors the joining transformer API so templates can
231
305
  * call `this.text()`.
232
306
  * @param {string} txt - Text content
233
- * @returns {JSONPathTransformerContext}
307
+ * @returns {this}
308
+ */
309
+ text(txt: string): this;
310
+ /**
311
+ * Add a comment to the most recently opened element. Mirrors the joining
312
+ * transformer API so templates can call `this.comment()`.
313
+ * @param {string} text - Comment text
314
+ * @returns {this}
234
315
  */
235
- text(txt: string): JSONPathTransformerContext;
316
+ comment(text: string): this;
317
+ /**
318
+ * Add a processing instruction to the most recently opened element.
319
+ * Mirrors the joining transformer API so templates can call
320
+ * `this.processingInstruction()`.
321
+ * @param {string} target - Processing instruction target
322
+ * @param {string} data - Processing instruction data
323
+ * @returns {this}
324
+ */
325
+ processingInstruction(target: string, data: string): this;
236
326
  /**
237
327
  * @param {string} name - Property set name
238
- * @param {object} propertySetObj - Property set object
328
+ * @param {Record<string, unknown>} propertySetObj - Property set object
239
329
  * @param {any[]} [usePropertySets] - Property sets to use
240
- * @returns {JSONPathTransformerContext}
330
+ * @returns {this}
241
331
  */
242
- propertySet(name: string, propertySetObj: object, usePropertySets?: any[]): JSONPathTransformerContext;
332
+ propertySet(name: string, propertySetObj: Record<string, unknown>, usePropertySets?: any[]): this;
243
333
  /**
244
- * @param {object} obj - Object to assign properties to
334
+ * @param {Record<string, unknown>} obj - Object to assign properties to
245
335
  * @param {string} name - Property set name
246
- * @returns {object}
336
+ * @returns {Record<string, unknown>}
247
337
  */
248
- _usePropertySets(obj: object, name: string): object;
338
+ _usePropertySets(obj: Record<string, unknown>, name: string): Record<string, unknown>;
249
339
  /**
250
340
  * @param {string} name - Key name
251
- * @param {*} value - Value to match
252
- * @returns {*}
341
+ * @param {any} value - Value to match
342
+ * @returns {any}
253
343
  */
254
344
  getKey(name: string, value: any): any;
255
345
  /**
256
346
  * @param {string} name - Key name
257
347
  * @param {string} match - Match expression
258
348
  * @param {string} use - Use expression
259
- * @returns {JSONPathTransformerContext}
349
+ * @returns {this}
350
+ */
351
+ key(name: string, match: string, use: string): this;
352
+ /**
353
+ * Conditionally execute a callback when a JSONPath selector evaluates
354
+ * to a truthy scalar or a non-empty result set (node set analogue).
355
+ * Mirrors XSLT's xsl:if semantics where a non-empty node set is truthy.
356
+ *
357
+ * Truthiness rules:
358
+ * - If the selection (with wrap) yields an array with length > 0, the
359
+ * condition passes.
360
+ * - Otherwise the (non-wrapped) scalar value is coerced with Boolean();
361
+ * e.g., 0, '', null, undefined => false; others => true.
362
+ *
363
+ * @param {string} select - JSONPath selector expression
364
+ * @param {(this: JSONPathTransformerContext<T>)
365
+ * => void} cb - Callback to invoke if condition is met
366
+ * @returns {this}
367
+ */
368
+ if(select: string, cb: (this: JSONPathTransformerContext<T>) => void): this;
369
+ /**
370
+ * Internal helper: determine if `select` passes truthiness test.
371
+ * Non-empty wrapped results => true; single item: objects truthy,
372
+ * primitives coerced via Boolean().
373
+ * @param {string} select
374
+ * @returns {boolean}
375
+ */
376
+ _passesIf(select: string): boolean;
377
+ /**
378
+ * Like `if()`, but also supports an optional fallback callback executed
379
+ * when the test does not pass (similar to xsl:choose/xsl:otherwise).
380
+ * @param {string} select JSONPath selector
381
+ * @param {(this: JSONPathTransformerContext<T>)
382
+ * => void} whenCb Callback when condition passes
383
+ * @param {(this: JSONPathTransformerContext<T>)
384
+ * => void} [otherwiseCb] Callback when condition fails
385
+ * @returns {this}
260
386
  */
261
- key(name: string, match: string, use: string): JSONPathTransformerContext;
387
+ choose(select: string, whenCb: (this: JSONPathTransformerContext<T>) => void, otherwiseCb?: (this: JSONPathTransformerContext<T>) => void): this;
262
388
  }
263
389
  //# sourceMappingURL=JSONPathTransformerContext.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"JSONPathTransformerContext.d.ts","sourceRoot":"","sources":["../src/JSONPathTransformerContext.js"],"names":[],"mappings":";AAGA;;;;;;;GAOG;AACH;IACE;;;;;;;;;;;;;;;OAeG;IACH,oBAdG;QAAuB,IAAI,EAAnB,MAAM;QACU,MAAM;QACN,cAAc;QACb,oBAAoB;QAGA,kBAAkB,EADvD;YAAC,MAAM,WAAW;YAAC,GAAG,WAAW;YAAC,MAAM,WAAW;YACzD,MAAM,WAAW;YAAC,KAAK,WAAU;SAAC;QAEX,WAAW;QAEV,2BAA2B;KAErD,aAAQ,GAAG,EAAE,EAkBf;IAfC;cAfS,MAAM;;;;4BAKN;YAAC,MAAM,WAAW;YAAC,GAAG,WAAW;YAAC,MAAM,WAAW;YACzD,MAAM,WAAW;YAAC,KAAK,WAAU;SAAC;;;MAShB;IACrB,kBAA2B;IAC3B,oBAA8C;IAA3B,iBAA2B;IAC9C,gBAA4C;IAC5C,wBAAsD;IACtD,kCAAkC;IAClC,MADW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAChB;IACd,kCAAkC;IAClC,cADW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CACR;IACtB,kCAAkC;I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0BAA0B,CAKtC;IAED;;;;;;OAMG;IACH,gBAJW,MAAM,OACN,GAAC,GACC,0BAA0B,CAKtC;IAED;;;;;;OAMG;IACH,gBAHc,GAAG,EAAA,GACJ,0BAA0B,CAKtC;IAED;;;;;OAKG;IACH,eAHc,GAAG,EAAA,GACJ,0BAA0B,CAKtC;IAED;;;;;;;;OAQG;IACH,cANW,MAAM,SACN,MAAM,aACN,GAAG,EAAE,kBAEH,0BAA0B,CAOtC;IAED;;;;;;;OAOG;IACH,gBALW,MAAM,OACN,MAAM,GAAC,MAAM,mBACb,OAAO,GACL,0BAA0B,CAOtC;IAED;;;;;OAKG;IACH,UAHW,MAAM,GACJ,0BAA0B,CAKtC;IAED;;;;;OAKG;IACH,kBALW,MAAM,kBACN,MAAM,oBACN,GAAG,EAAE,GACH,0BAA0B,CActC;IAED;;;;OAIG;IACH,sBAJW,MAAM,QACN,MAAM,GACJ,MAAM,CAIlB;IAED;;;;OAIG;IACH,aAJW,MAAM,SACN,GAAC,GACC,GAAC,CAYb;IAED;;;;;OAKG;IACH,UALW,MAAM,SACN,MAAM,OACN,MAAM,GACJ,0BAA0B,CAKtC;CACF"}
1
+ {"version":3,"file":"JSONPathTransformerContext.d.ts","sourceRoot":"","sources":["../src/JSONPathTransformerContext.js"],"names":[],"mappings":";;;;yBAKa;IACR,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,WAAW,GAAG,YAAY,CAAC;IACnC,IAAI,CAAC,EAAE,MAAM,GAAC,QAAQ,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB;;;;6BACS,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAC/B,GAAG,EAAE,0BAA0B,KAC5B,MAAM;;;;uBACD,MAAM,GAAG,UAAU,GAAG,cAAc,GAC5C,KAAK,CAAC,MAAM,GAAC,UAAU,CAAC;6CAIf,CAAC;;;;UAED,I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