csv-stringify
Version:
CSV stringifier implementing the Node.js `stream.Transform` API
23 lines (21 loc) • 598 B
JavaScript
class CsvError extends Error {
constructor(code, message, ...contexts) {
if (Array.isArray(message)) message = message.join(" ");
super(message);
if (Error.captureStackTrace !== undefined) {
Error.captureStackTrace(this, CsvError);
}
this.code = code;
for (const context of contexts) {
for (const key in context) {
const value = context[key];
this[key] = Buffer.isBuffer(value)
? value.toString()
: value == null
? value
: JSON.parse(JSON.stringify(value));
}
}
}
}
export { CsvError };