Isn't it already solvable by:

const SizedArray = (size) => class SizedArray extends Array
 {

  constructor(...args) {
    if(args.length > size) throw new SyntaxError('Argument size is too big.')
    super(...args)
  }
  push(i) {
    if(this.length + 1 > size) throw new SyntaxError('Cannot push
items anymore, array too big.')
    super.push(i)
  }

}

const arr = new (SizedArray(5))?



On Tue, Jan 15, 2019 at 8:01 PM IdkGoodName Vilius <
[email protected]> wrote:

> See:
> https://github.com/CreatorVilius/ecmascript-proposals/blob/master/proposal-class-templates.md
>
>
>
> I think having Class Templates in JavaScript would be awesome thing and
> should be implemented. But that’s just my opinion.
> _______________________________________________
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to