get-class-function-names
TypeScript icon, indicating that this package has built-in type declarations

1.2.0 • Public • Published

Get class function names

Get all function names of a class up to a specified prototype.

Installation

 $ npm i get-class-function-names

Usage

Given the class AA extending Array:

class AA extends Array {
  qq() {

  }
  ww() {

  }
}

The method names up to Array / Object can be found like below:

import getClassFunctionNames from "get-class-function-names"

getClassFunctionNames(AA, Array)   // ["qq", "ww"]
getClassFunctionNames(AA)          // ["qq", "ww", "length", "concat", "copyWithin", "fill", ...]

Filter

If you wanted to filter out only function names (thus omitting properties like length) you could:

getClassFunctionNames(AA, {includeInstanceOf: Function})   // ["qq", "ww", "concat", "copyWithin", "fill", ...]
getClassFunctionNames(AA, {excludeInstanceOf: "number"})   // ["qq", "ww", "concat", "copyWithin", "fill", ...]

Note: that the constructor is always omitted

If you want to white / blacklist additional names do:

getClassFunctionNames(AA, {excludeInstanceOf: "number"})   // ["qq", "ww", "concat", "copyWithin", "fill", ...]s
getClassFunctionNames(AA, {includeInstanceOf: Function})   // ["qq", "ww", "concat", "copyWithin", "fill", ...]s

Note: that length is missing in the above example

Contribute

All feedback is appreciated. Create a pull request or write an issue.

Dependencies (0)

    Dev Dependencies (13)

    Package Sidebar

    Install

    npm i get-class-function-names

    Weekly Downloads

    7

    Version

    1.2.0

    License

    ISC

    Unpacked Size

    19.7 kB

    Total Files

    18

    Last publish

    Collaborators

    • zzrv