const DEBUG = true; function toString(obj) { if (!obj) { return obj } if (typeof obj === 'string') { return obj } return obj + ''; } function debug(...data) { if (DEBUG) { console.debug(...data) } } //helper function to format a string function format(str, args) { var keys = Object.keys(args), i; for (i=0; i