Function objUpdatePropertyDescriptors

  • Updates the property descriptors of the specified properties on the given object.

    Type Parameters

    • V

    Parameters

    • object: Record<ObjectKey, V>

      The object whose property descriptors are to be updated.

    • properties: string[]

      An array of property names for which the descriptors are to be updated.

    • update: (<T>(descriptor, property) => T)

      A function that takes a property descriptor and a property name, and returns a new property descriptor.

        • <T>(descriptor, property): T
        • Type Parameters

          • T extends PropertyDescriptor

          Parameters

          • descriptor: T
          • property: string

          Returns T

    Returns void

    Throws

    Will throw an error if any of the specified properties do not exist on the object.

    Example

    const obj = { a: 1, b: 2 };
    objUpdatePropertyDescriptors(obj, ['a', 'b'], (descriptor, property) => {
    descriptor.writable = true;
    return obj;
    });

Generated using TypeDoc