Package detail

acorn-private-methods

acornjs832.2kMIT1.0.0

Support for private methods in acorn

readme

Private methods and getter/setters support for Acorn

NPM version

This is a plugin for Acorn - a tiny, fast JavaScript parser, written completely in JavaScript.

It implements support for private methods, getters and setters as defined in the stage 3 proposal Private methods and getter/setters for JavaScript classes. The emitted AST follows the ESTree experimental Class Features design.

Usage

This module provides a plugin that can be used to extend the Acorn Parser class:

const {Parser} = require('acorn');
const privateMethods = require('acorn-private-methods');
Parser.extend(privateMethods).parse('class X { #a() {} }');

or as an ECMAScript Module:

import {Parser} from 'acorn';
import privateMethods from 'acorn-private-methods';
Parser.extend(privateMethods).parse('class X { #a() {} }');

License

This plugin is released under an MIT License.

changelog

1.0.0 (2021-02-08)

  • Update AST node names to match ESTree

0.3.3 (2020-08-13)

  • Migrate to ESM
  • Mark as compatible with acorn@8

0.3.2 (2020-06-11)

  • Don't break acorn's optional chaining support

0.3.1 (2020-04-22)

  • Don't parse static private methods
  • Don't allow private method access on super
  • Use injected acorn instance if available
  • Uses Object.getPrototypeOf if available instead of __proto__
  • Mark as compatible with acorn v7

0.3.0 (2019-02-09)

  • Require acorn >= 6.1.0

0.2.3 (2019-02-09)

  • Forbid binding await in async arrow function's parameter list

0.2.2 (2019-01-30)

  • Fix parsing of chained subscripts

0.2.1 (2018-11-06)

  • Adapt to changes in acorn 6.0.3

0.2.0 (2018-09-14)

  • Update to new acorn 6 interface
  • Change license to MIT
  • Don't allow direct super() calls in private methods

0.1.1 (2018-02-09)

  • Don't accept whitespace between hash and private name

0.1.0 (2018-01-13)

Initial release