• Object.defineProperty where get is cached after first call.

    Type Parameters

    • T

    • R

    Parameters

    • proto: T

      Object on which to add or modify the property.

    • propertyName: PropertyKey

      Key of the property.

    • get: ((it) => R)

      Function to compute the property value.

        • (it): R
        • Parameters

          • it: T

          Returns R

    • enumerable: boolean = false

      Is the property listed in Object.keys. (Optional: default to false)

    Returns void

    Author

    warinternal 20161128

    Example

    defineCachedProperty(Creep.prototype, "bodyParts", (c) => _.countBy(c.body, part => part.type))
    

Generated using TypeDoc