2.0.2 • Published 5 years ago

redefine-statics-js v2.0.2

Weekly downloads
25
License
MIT
Repository
-
Last release
5 years ago

redefine-statics-js

Utility function that copies-over all static methods of a child object to the parent object.

The problem

This utility solves: The problem is that when we have a class and we wrap it inside a higher-order-function, the static methods of the wrapped class should be copied to the higher-order-class (the class returned by the higher-order-function).

Usage

npm i -s redefine-statics-js.

Then on your wrapper:

import redefineStatics from 'redefine-statics-js';

function MyWrapper(WrappedClass) {
  class MyWrapperClass {
    // some methods here.
  }

  redefineStatics(MyWrapperClass, WrappedClass);

  return MyWrapperClass;
}

Then on the wrapped class:

class WrappedObject {
  static myStaticMethod() {}
}

export default MyWrapper(WrappedObject);

Now the export of the wrapped class would have myStaticMethod in it.

2.0.2

5 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago