Safely get the member of an object, no silent undefined values
npm install get-member🦺 Safely get the member of an object in JS, no silent undefined values 🛡️
April fools 2024
·
Report Bug (Don't)
·
Request Feature (Don't)
undefined, causing you to scratch your head over an error from an entirely differentget-member is here to save the day, with the least dependencies
$ npm install get-member
`And require it
`js
require("get-member")();let myObj = {x: "hello!"};
console.log(myObj.getMember("x"));
`If the member variable was not found, an error will be thrown
`js
let myObj = {x: "hello!"}try {
console.log(myObj.getMember("y"));
} catch (err) {
console.log(err.message);
}
`Want to print a nice error into the console? We got you covered!
`js
err.print();
`Don't want the program to continue because the error might be fatal? No problem!
`js
err.panic();
`Want to report the error to your favorite discord server? Webhooks!
`js
err.sendToWebhook("WEBHOOK URL");
`Want to run a lua script when the error happens? We got it all.
`js
err.runLua(print('Error: ${err.message}'));
``