Provides functional transformations for JavaScript objects within HotMesh mapping rules. Although inspired by JavaScript, these methods have been adapted to follow a functional approach. Each transformation is a function that expects one or more input parameters from the prior row in the @pipe structure.

Invoked via {@object.<method>} in YAML mapping rules.

Constructors

Methods

  • Merges one or more source objects into a target object. Properties in later sources overwrite earlier ones.

    Parameters

    • target: object

      The target object to merge into

    • Rest...sources: object[]

      One or more source objects to merge from

    Returns object

    The target object with all source properties merged in

    combined_colors:
    "@pipe":
    - ["{@symbol.object}", "{a.output.data.colors}", "{b.output.data.colors}"]
    - ["{@object.assign}"]
  • Creates a new object with specified key-value pairs. Arguments are provided as alternating key-value pairs. If no arguments are provided, an empty object will be created.

    Parameters

    • Rest...args: any[]

      Alternating key-value pairs (key1, value1, key2, value2, ...)

    Returns object

    A new object constructed from the provided key-value pairs

    person:
    "@pipe":
    - ["name", "John", "age", 30, "city", "New York"]
    - ["{@object.create}"]
  • Defines new properties or modifies existing properties on an object and returns the object.

    Parameters

    • obj: object

      The object to define properties on

    • props: PropertyDescriptorMap

      An object whose keys represent property names and whose values are property descriptors

    Returns object

    The object with the defined properties

    person:
    "@pipe":
    - ["{a.person}", {"age": {"value": 30}, "city": {"value": "New York", "writable": false}}]
    - ["{@object.defineProperties}"]
  • Defines a new property or modifies an existing property on an object and returns the object.

    Parameters

    • obj: object

      The object to define the property on

    • prop: string | symbol

      The name of the property to define or modify

    • descriptor: PropertyDescriptor

      The descriptor for the property being defined or modified

    Returns object

    The object with the defined property

    person:
    "@pipe":
    - ["{a.person}", "city", {"value": "New York", "writable": false}]
    - ["{@object.defineProperty}"]
  • Retrieves an array of the object's own enumerable key-value pairs.

    Parameters

    • obj: object

      The object from which to extract the entries

    Returns [string, any][]

    An array of [key, value] pairs

    color_entries:
    "@pipe":
    - ["{a.output.data.colors}"]
    - ["{@object.entries}"]
  • Freezes an object, making it immutable. Prevents new properties from being added, existing properties from being removed, and values of existing properties from being modified.

    Parameters

    • obj: object

      The object to freeze

    Returns object

    The frozen object

    person:
    "@pipe":
    - ["{a.person}"]
    - ["{@object.freeze}"]
  • Transforms an array of key-value pairs into an object.

    Parameters

    • iterable: Iterable<[string, any]>

      An iterable of key-value pairs (e.g., an array of [key, value] arrays)

    Returns object

    A new object constructed from the key-value pairs

    color_object:
    "@pipe":
    - ["{a.output.data.pairs}"]
    - ["{@object.fromEntries}"]
  • Retrieves a property value from an object by its property name.

    Parameters

    • obj: object

      The object from which to retrieve the property value

    • prop: string | symbol

      The name of the property to retrieve

    Returns any

    The value of the specified property, or undefined if the object is nullish

    second_color:
    "@pipe":
    - ["{a.output.data.colors}", "second"]
    - ["{@object.get}"]
  • Returns a property descriptor for an own property of an object.

    Parameters

    • obj: object

      The object to retrieve the property descriptor from

    • prop: string | symbol

      The name of the property

    Returns PropertyDescriptor

    The property descriptor, or undefined if the property does not exist

    ageDescriptor:
    "@pipe":
    - ["{a.person}", "age"]
    - ["{@object.getOwnPropertyDescriptor}"]
  • Returns an array of all property names (including non-enumerable) of an object.

    Parameters

    • obj: object

      The object to retrieve property names from

    Returns string[]

    An array of all own property names

    propertyNames:
    "@pipe":
    - ["{a.person}"]
    - ["{@object.getOwnPropertyNames}"]
  • Returns an array of all symbol properties of an object.

    Parameters

    • obj: object

      The object to retrieve symbol properties from

    Returns symbol[]

    An array of all own symbol properties

    symbolProperties:
    "@pipe":
    - ["{a.person}"]
    - ["{@object.getOwnPropertySymbols}"]
  • Determines if an object has a specified property as its own property (as opposed to inheriting it from the prototype chain).

    Parameters

    • obj: object

      The object to check

    • prop: string | symbol

      The name of the property to test

    Returns boolean

    True if the object has the specified own property, otherwise false

    hasAge:
    "@pipe":
    - ["{a.person}", "age"]
    - ["{@object.hasOwnProperty}"]
  • Determines if an object is extensible (i.e., whether new properties can be added to it).

    Parameters

    • obj: object

      The object to check

    Returns boolean

    True if the object is extensible, otherwise false

    isExtensible:
    "@pipe":
    - ["{a.person}"]
    - ["{@object.isExtensible}"]
  • Determines if an object is frozen.

    Parameters

    • obj: object

      The object to check

    Returns boolean

    True if the object is frozen, otherwise false

    isFrozen:
    "@pipe":
    - ["{a.person}"]
    - ["{@object.isFrozen}"]
  • Determines if an object exists in another object's prototype chain.

    Parameters

    • obj: object

      The object whose prototype chain is to be checked

    • prototypeObj: object

      The prototype object to search for

    Returns boolean

    True if the prototype object is found in the object's prototype chain, otherwise false

    isPersonPrototypeOfEmployee:
    "@pipe":
    - ["{a.person}", "{a.employee}"]
    - ["{@object.isPrototypeOf}"]
  • Determines if an object is sealed.

    Parameters

    • obj: object

      The object to check

    Returns boolean

    True if the object is sealed, otherwise false

    isSealed:
    "@pipe":
    - ["{a.person}"]
    - ["{@object.isSealed}"]
  • Retrieves an array of a given object's own enumerable property names.

    Parameters

    • obj: object

      The object whose property names are to be retrieved

    Returns string[]

    An array of the object's own enumerable property names

    property_names:
    "@pipe":
    - ["{a.output.data}"]
    - ["{@object.keys}"]
  • Prevents new properties from being added to an object. Existing properties can still be modified or deleted.

    Parameters

    • obj: object

      The object to make non-extensible

    Returns object

    The non-extensible object

    person:
    "@pipe":
    - ["{a.person}"]
    - ["{@object.preventExtensions}"]
  • Determines if a specified property on an object is enumerable.

    Parameters

    • obj: object

      The object to check

    • prop: string | symbol

      The name of the property to test

    Returns boolean

    True if the specified property is enumerable, otherwise false

    isAgeEnumerable:
    "@pipe":
    - ["{a.person}", "age"]
    - ["{@object.propertyIsEnumerable}"]
  • Seals an object, preventing new properties from being added and marking all existing properties as non-configurable. Values of existing properties can still be modified.

    Parameters

    • obj: object

      The object to seal

    Returns object

    The sealed object

    person:
    "@pipe":
    - ["{a.person}"]
    - ["{@object.seal}"]
  • Sets a property on an object with a specified value and returns the object. If the input object is undefined or null, a new object will be created.

    Parameters

    • obj: object

      The object to set the property on

    • prop: string | symbol

      The name of the property to set

    • value: any

      The value to assign to the property

    Returns any

    The modified object with the new property value

    output:
    "@pipe":
    - ["{a.output.data.colors}", "third", "blue"]
    - ["{@object.set}"]
  • Retrieves an array of a given object's own enumerable property values.

    Parameters

    • obj: object

      The object from which to extract the values

    Returns any[]

    An array of the object's own enumerable property values

    color_values:
    "@pipe":
    - ["{a.output.data.colors}"]
    - ["{@object.values}"]