Metreeca MIME
    Preparing search index...

    Function jpath

    Creates a JSON path selector.

    • Creates a JSON path selector task.

      The task converts a feed of values into a feed of JPath selectors, one selector per value, so that downstream tasks select nested values by path rather than walking the structure.

      Note

      • Incremental: each selector is emitted as soon as its value is drawn, so endless sources are processed for as long as the feed is consumed.
      • Streaming: values are processed one at a time and none is retained, so memory use doesn't grow with the length of the feed; each selector keeps its target value alive for as long as it is referenced.
      • Stateless: each value is processed independently, so the result doesn't depend on how the feed is split across nested feeds or runs.

      Returns Task<Value, JPath>

      A task converting a feed of values into a feed of path selectors

      Error While the feed is consumed, if the source feed fails

    • Creates a JSON path mapping task.

      The task converts a feed of values into a feed of mapped results, one result per value, so that downstream tasks work on the shape they need rather than on the one stated by the source.

      Note

      • Incremental: each result is emitted as soon as its value is drawn, so endless sources are processed for as long as the feed is consumed.
      • Streaming: values are processed one at a time and released once mapped, so memory use doesn't grow with the length of the feed.
      • Stateless: each value is mapped independently, so the result doesn't depend on how the feed is split across nested feeds or runs.

      Type Parameters

      • V

        The type of the results mapped from incoming values

      Parameters

      • mapper: (path: JPath) => V

        The mapping function, applied to a JPath selector targeting the value being processed

      Returns Task<Value, V>

      A task converting a feed of values into a feed of mapped results

      Error While the feed is consumed, if the source feed fails or mapper throws, including a SyntaxError for a malformed path

      const events = jpath(path => ({

      id: path("$.id"),
      tags: path("$.tags[*]")

      }));
    • Creates a JSON path selector over given values.

      Targets values already at hand, outside a feed, with the same selection semantics as the selectors emitted by the feed tasks.

      Important

      A call without values, including one spreading an empty list, creates a selector task over a feed rather than a selector with an empty target set.

      Parameters

      • ...values: readonly Value[]

        The target values, in selection order

      Returns JPath

      An immutable selector targeting values