tr multimethod

Methods

tr(x:Any, pattern:Any, tc:TrContext)
Checks whether x matches the pattern

Returns

Lit(x) or TrNoMatch()
tr(x:Any, a:Arr, tc:TrContext)
Match / transform x using the pattern in a

Returns

Lit or TrCommand
tr(x:Any, h:Hash, tc:TrContext)
Match / transform x using the pattern in h.

Parameters

xHash or HashLike

Returns

Lit or TrCommand
tr(x:Any, a:AnyOf, tc:TrContext)
Match / transform x using the pattern in a. First match shortcuts the evaluation: further items in a are not tried.

Returns

Lit or TrNoMatch
tr(x:Any, pa:PatternAction, tc:TrContext)
Transform x using pa::action of x matches pa::pattern. pa::action will be called with (Any, TrContext). pa::action can either return new data or perform an operation using TrContext. Currently supported operation is skip(TrContext).

Returns

Lit, TrCommand, or TrNoMatch
tr(x:Any, transformation:Any)
Public API of the transformation/tr() experimental facility

Example

cat fhir_questionnaire_01.json | ngs -ppj '_.tr({"url": AnyOf("http://hl7.org/fhir/StructureDefinition/maxValue", "http://hl7.org/fhir/StructureDefinition/minValue")} -> skip(Y)).tr([] -> skip(Y))' >fhir_questionnaire_01.clean.json