Package Exports
- class-methods
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (class-methods) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
class-methods
Get the methods of a JavaScript class.
☁️ Installation
$ npm i --save class-methods📋 Example
const classMethods = require("class-methods");
class Person {
constructor (name) {
this.setName(name);
}
setName (name) {
this.name = name;
}
getName (name) {
return this.name;
}
}
class Worker extends Person {
constructor (name, job) {
super(name);
this.setJob(job);
}
setJob (job) {
this.job = job;
}
getJob (job) {
return this.job;
}
static randomName () {
// Yes, it's random enough :D
return ["Alice", "Bob"][0];
}
}
console.log(classMethods(Worker));
// [ 'setJob', 'getJob', 'setName', 'getName' ]
console.log(classMethods(Person));
// [ 'setName', 'getName' ]
console.log(classMethods(Worker, {
deep: false
}));
// [ 'setJob', 'getJob' ]
console.log(classMethods(Worker, {
includeStatic: true
}));
// [ 'setJob', 'getJob', 'randomName', 'setName', 'getName' ]📝 Documentation
classMethods(input, options)
Get the methods of a JavaScript class.
Params
- Class
input: The class you want to get the methods of. - Object
options: An object containing the following fields: deep(Boolean): Iffalsethe parent classes will not be iterated.includeStatic(Boolean): Iftrue, the static methods will be included too.
Return
- Array The class methods.
😋 How to contribute
Have an idea? Found a bug? See how to contribute.
💰 Donations
Another way to support the development of my open-source modules is to set up a recurring donation, via Patreon. 🚀
PayPal donations are appreciated too! Each dollar helps.
Thanks! ❤️