ClassWrapSpec

Spec that provides configuration for wrapping classes (both class style and traditional function style).

Constructor

new ClassWrapSpec(params)

Parameters:
NameTypeDescription
paramsClassWrapSpecParams

Members

es6 :boolean

When true, the class being wrapped is class style. Our es5 wrapper depends on calling the constructor without new, so we have to differentiate.

Type:
  • boolean

post :ConstructorHookFunction|null

As with ClassWrapSpec.pre, this function will be applied subsequent to invoking the wrapped class's constructor.

See
  • pre

pre :ConstructorHookFunction|null

When wrapping a class based object, the pre function will be invoked with the class's constructor arguments before the class constructor is invoked. The this reference will be bound to null.

Example
class Foo {
  constructor(a, b, c) {
    // do stuff
  }
}
const spec = new ClassWrapSpec({
  pre: function (...args) {
    // args = [a, b, c]
  }
})
const wrappedClass = class Wrapper extends Foo {
  constructor() {
    spec.pre.apply(null, [...arguments])
  }
}