35 lines
508 B
JavaScript
35 lines
508 B
JavaScript
class RequestError
|
|
{
|
|
constructor(code, text)
|
|
{
|
|
this.code = code;
|
|
this.message = text;
|
|
}
|
|
}
|
|
|
|
function de64(k)
|
|
{
|
|
if (k == null) // null or undefined
|
|
return k;
|
|
return Buffer.from(k, 'base64').toString();
|
|
}
|
|
|
|
function runCallbacks(obj, key, new_value)
|
|
{
|
|
const cbs = obj[key];
|
|
obj[key] = new_value;
|
|
if (cbs)
|
|
{
|
|
for (const cb of cbs)
|
|
{
|
|
cb();
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
RequestError,
|
|
de64,
|
|
runCallbacks,
|
|
};
|