class-extends-array

2.1.0 • Public • Published

I made small function that makes intermediate prototype with methods from parent class between Array class and parent class. Due to babel issue: Errors with extending Array #1424 This function uses __proto__, so, can fail on IE10 and less.

Installation

npm install class-extends-array

Example

import extendWithArray from 'class-extends-array';

// class that should extends Array
class Foo {
    bar() { return this.map(el => `<${el}>`).join('|') }
}

const FooAsArray = extendWithArray(Foo);

const foo = new FooAsArray(1, 2, 3);
foo.push(4);
foo.bar(); // "<1>|<2>|<3>|<4>"

Readme

Keywords

Package Sidebar

Install

npm i class-extends-array

Weekly Downloads

0

Version

2.1.0

License

ISC

Last publish

Collaborators

  • liksu