Metreeca Gear
    Preparing search index...

    Function jpath

    Creates a JSON path selector.

    • Creates a JSON path selector task.

      The generated task converts a feed of values into a feed of JPath selectors, one selector per value, so that a consumer selects what a value holds by path rather than walking it.

      Note

      • Incremental: each selector is emitted as soon as its value is drawn, so the feed produced runs dry as the feed drawn from does and an endless source is read as long as it is consumed.
      • Streaming: values are drawn one at a time and none retained, so the length of the feed weighs on memory no more than a single value does; a selector keeps the value it targets for as long as a consumer holds it.
      • Stateless: every value is targeted on its own, so the outcome is unaffected by 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, whatever the source reports while producing values

    • Creates a JSON path mapping task.

      The generated task converts a feed of values into a feed of mapped results, one result per value, so that a consumer works on the shape it is after rather than on the one the source states.

      Note

      • Incremental: each result is emitted as soon as its value is drawn, so the feed produced runs dry as the feed drawn from does and an endless source is read as long as it is consumed.
      • Streaming: values are drawn one at a time and released as soon as their result is assembled, so the length of the feed weighs on memory no more than a single value does.
      • Stateless: every value is mapped on its own, so the outcome is unaffected by how the feed is split across nested feeds or runs.

      Type Parameters

      • V

        The type of the result mapped from each incoming value

      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, whatever the source reports while producing values, or whatever mapper reports while mapping a value, 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, so that a consumer selecting from a value it holds does so exactly as one selecting from a value drawn from a source.

      Important

      A call with no value, spreading an empty list included, creates a task over a feed of values rather than a selector with an empty target set.

      Parameters

      • ...values: readonly Value[]

        The target values, in the order they are to be selected from

      Returns JPath

      An immutable selector targeting values