Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "utils/define-read-write-accessor/docs/types/index.d"

Index

Type aliases

Functions

Type aliases

Getter

Getter: () => any

Getter function.

returns

property value

Type declaration

    • (): any
    • Returns any

Setter

Setter: (x: any) => void

Setter function.

param

property value

Type declaration

    • (x: any): void
    • Parameters

      • x: any

      Returns void

Functions

Export assignment setReadWriteAccessor

  • Defines a read-write accessor.

    Notes

    • Read-write accessors are enumerable and non-configurable.

    Parameters

    • obj: any

      object on which to define the property

    • prop: PropertyName

      property name

    • getter: Getter

      get accessor

    • setter: Setter

      set accessor

    Returns void

    Example

    function getter() {
        return name + ' foo';
    }
    
    function setter( v ) {
        name = v;
    }
    
    var name = 'bar';
    var obj = {};
    
    setReadWriteAccessor( obj, 'foo', getter, setter );
    
    var v = obj.foo;
    // returns 'bar foo'
    
    obj.foo = 'beep';
    
    v = obj.foo;
    // returns 'beep foo'