1.2.0 • Published 9 months ago

get-class-function-names v1.2.0

Weekly downloads
40
License
ISC
Repository
github
Last release
9 months ago

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.

1.2.0

9 months ago

1.1.5

11 months ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

3 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago

0.0.1

4 years ago