EntriesMixin

EntriesMixin

Methods

(inner) at(key, pickLensopt)

Build a lens through a specific key

Source:

There are several ways to call this method, with different argument patterns:

  1. datumLens.at(key)
  2. datumLens.ad(key, propvalSlotPicker)
  3. datumLens.ad(key, porpvalSlotLens)

Pattern 1 creates a lens to the key property value of the Object targeted by this lens.

Pattern 2 creates an optic (a lens where possible) targeting a slot within the key property of the Object targeted by this lens, where the slot within the item is selected by the result of propvalSlotPicker. propvalSlotPicker is called with the "other property" datum plan for the target of this lens if one is specified within the datum plan.

Pattern 3 is similar to pattern 2, just directly passing a lens (or lens-like object) rather than a function that returns one.

Parameters:
Name Type Attributes Description
key string

Key (i.e. property name) of the targeted Object on which to focus

pickLens function | Lens <optional>

A lens to a slot within the selected value or a Function returning such a lens given the value plan

Returns:

A lens (or at least some optic) to the value or a slot within the value

(inner) mapAllInside(subject, …manipulator)

Clone the subject with the target of this lens altered by mapping property values

Source:

There are several ways to call this method, with different types of manipulators:

  1. datumLens.mapAllInside(subject, propvalXform)
  2. datumLens.mapAllInside(subject, propvalSlotPicker, propvalSlotXform)
  3. datumLens.mapAllInside(subject, propvalSlotLens, propvalSlotXform)

All of these patterns iterate only over all own-properties of the Object targeted within subject by this lens.

Pattern 1 applies a transformation function (propvalXform) to each own-property of the Object selected by this lens.

Pattern 2 is for applying a change within each own-property value of the Object targeted by this lens as a clone is made, selecting the slot within each item by returning a lens from propvalSlotPicker. propvalSlotPicker is called with the "other property" datum plan for the targeted Object if one exists in the datum plan.

Pattern 3 is similar to pattern 2, just directly passing a lens (or something that knows how to xformInClone) rather than a function that returns one.

The propvalXform function in pattern 1 is called with the property value, the property name and, if specified, the "other property" datum plan for the target Object of this lens. The "other property" datum plan is passed in even for explicitly specified properties of the target object that might have conflicting datum plans.

The propvalSlotXform function in patterns 2 and 3 is called with the slot value within the property value and the name of the property within the Object target of this lens.

Parameters:
Name Type Attributes Description
subject

The input structured data

manipulator * <repeatable>

See description

Returns:

A minimally changed clone of the subject with the transformed value in this slot

(inner) mapInside(subject, …manipulator)

Clone the subject with the target of this lens altered by mapping property values

Source:

There are several ways to call this method, with different types of manipulators:

  1. datumLens.mapInside(subject, propvalXform)
  2. datumLens.mapInside(subject, propvalSlotPicker, propvalSlotXform)
  3. datumLens.mapInside(subject, propvalSlotLens, propvalSlotXform)

All of these patterns iterate only over the non-explicit own-properties of the Object targeted within subject by this lens. Explicit properties are those whose names are given within the datum plan in the position corresponding to this lens.

Pattern 1 applies a transformation function (propvalXform) to each own-property of the Object selected by this lens not explicitly specified in the datum plan as the clone of subject is made.

Pattern 2 is for applying a change within each non-explicit own-property value of the Object targeted by this lens as a clone is made, selecting the slot within each item by returning a lens from propvalSlotPicker. propvalSlotPicker is called with the "other property" datum plan for the targeted Object if one exists in the datum plan.

Pattern 3 is similar to pattern 2, just directly passing a lens (or something that knows how to xformInClone) rather than a function that returns one.

The propvalXform function in pattern 1 is called with the property value, the property name and, if specified, the "other property" datum plan for the target Object of this lens.

The propvalSlotXform function in patterns 2 and 3 is called with the slot value within the property value and the name of the property within the Object target of this lens.

Parameters:
Name Type Attributes Description
subject

The input structured data

manipulator * <repeatable>

See description

Returns:

A minimally changed clone of the subject with the transformed value in this slot