Get all function names of a class up to a specified prototype.
npm install get-class-function-namesGet all function names of a class up to a specified prototype.
``shell`
$ npm i get-class-function-names
Given the class AA extending Array:
`ts
class AA extends Array {
qq() {
}
ww() {
}
}
`
The method names up to Array / Object can be found like below:
`ts
import getClassFunctionNames from "get-class-function-names"
getClassFunctionNames(AA, Array) // ["qq", "ww"]
getClassFunctionNames(AA) // ["qq", "ww", "length", "concat", "copyWithin", "fill", ...]
`
If you wanted to filter out only function names (thus omitting properties like length) you could:
`ts`
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:
`ts``
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
All feedback is appreciated. Create a pull request or write an issue.