{"version":3,"sources":["../src/string.ts"],"sourcesContent":["\n\nexport function stringTruncate (str: string, length: number, ellipsis : string = '...') : string\n{\n   if (str.length > length) \n   {\n      return str.substring(0, length) + ellipsis;\n   }\n   return str;\n}\n\nexport function stringToBool (str: string) : boolean\n{\n\tswitch(str?.toLowerCase()?.trim()){\n        case \"true\": \n        case \"yes\": \n        case \"1\": \n          return true;\n\n        case \"false\": \n        case \"no\": \n        case \"0\": \n        case null: \n        case undefined:\n          return false;\n\n        default: \n          return JSON.parse(str);\n    }\n}\n\n/**\n  * Returns the width of the given text of given font in pixels.\n  * \n  * @param {String} text The text to be rendered.\n  * @param {String} font The css font descriptor that text is to be rendered with (e.g. \"bold 14px verdana\").\n  * \n  * @see https://stackoverflow.com/questions/118241/calculate-text-width-with-javascript/21015393#21015393\n  */\nexport function stringWidth(text: string, font: string): number\n{\n    const canvas = (stringWidth as any).canvas || ((stringWidth as any).canvas = document.createElement(\"canvas\"));\n    const context = canvas.getContext(\"2d\");\n    context.font = font;\n    const metrics = context.measureText(text);\n    return metrics.width;\n}"],"mappings":";AAEO,SAAS,eAAgB,KAAa,QAAgB,WAAoB,OACjF;AACG,MAAI,IAAI,SAAS,QACjB;AACG,WAAO,IAAI,UAAU,GAAG,MAAM,IAAI;AAAA,EACrC;AACA,SAAO;AACV;AAEO,SAAS,aAAc,KAC9B;AACC,UAAO,KAAK,YAAY,GAAG,KAAK,GAAE;AAAA,IAC3B,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,IAET,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,IAET;AACE,aAAO,KAAK,MAAM,GAAG;AAAA,EAC3B;AACJ;AAUO,SAAS,YAAY,MAAc,MAC1C;AACI,QAAM,SAAU,YAAoB,WAAY,YAAoB,SAAS,SAAS,cAAc,QAAQ;AAC5G,QAAM,UAAU,OAAO,WAAW,IAAI;AACtC,UAAQ,OAAO;AACf,QAAM,UAAU,QAAQ,YAAY,IAAI;AACxC,SAAO,QAAQ;AACnB;","names":[]}