{"version":3,"file":"stringUtils.js","names":["codeBackslash","codeSlash","codeAsterisk","codeOpeningBrace","codeClosingBrace","codeOpeningBracket","codeClosingBracket","codeOpenParenthesis","codeCloseParenthesis","codeSpace","codeNewline","codeTab","codeReturn","codeBackspace","codeFormFeed","codeDoubleQuote","codePlus","codeMinus","codeQuote","codeZero","codeNine","codeComma","codeDot","codeColon","codeSemicolon","codeUppercaseA","codeLowercaseA","codeUppercaseE","codeLowercaseE","codeUppercaseF","codeLowercaseF","codeNonBreakingSpace","codeEnQuad","codeHairSpace","codeNarrowNoBreakSpace","codeMediumMathematicalSpace","codeIdeographicSpace","codeDoubleQuoteLeft","codeDoubleQuoteRight","codeQuoteLeft","codeQuoteRight","codeGraveAccent","codeAcuteAccent","isHex","code","isDigit","isValidStringCharacter","isDelimiter","char","regexDelimiter","test","isDelimiterExceptSlash","isStartOfValue","regexStartOfValue","isQuote","charCodeAt","isControlCharacter","isWhitespace","isSpecialWhitespace","isDoubleQuoteLike","isSingleQuoteLike","isDoubleQuote","isSingleQuote","stripLastOccurrence","text","textToStrip","stripRemainingText","arguments","length","undefined","index","lastIndexOf","substring","insertBeforeLastWhitespace","textToInsert","removeAtIndex","start","count","endsWithCommaOrNewline","isFunctionName"],"sources":["../../../src/utils/stringUtils.ts"],"sourcesContent":["export const codeBackslash = 0x5c // \"\\\"\nexport const codeSlash = 0x2f // \"/\"\nexport const codeAsterisk = 0x2a // \"*\"\nexport const codeOpeningBrace = 0x7b // \"{\"\nexport const codeClosingBrace = 0x7d // \"}\"\nexport const codeOpeningBracket = 0x5b // \"[\"\nexport const codeClosingBracket = 0x5d // \"]\"\nexport const codeOpenParenthesis = 0x28 // \"(\"\nexport const codeCloseParenthesis = 0x29 // \")\"\nexport const codeSpace = 0x20 // \" \"\nexport const codeNewline = 0xa // \"\\n\"\nexport const codeTab = 0x9 // \"\\t\"\nexport const codeReturn = 0xd // \"\\r\"\nexport const codeBackspace = 0x08 // \"\\b\"\nexport const codeFormFeed = 0x0c // \"\\f\"\nexport const codeDoubleQuote = 0x0022 // \"\nexport const codePlus = 0x2b // \"+\"\nexport const codeMinus = 0x2d // \"-\"\nexport const codeQuote = 0x27 // \"'\"\nexport const codeZero = 0x30 // \"0\"\nexport const codeNine = 0x39 // \"9\"\nexport const codeComma = 0x2c // \",\"\nexport const codeDot = 0x2e // \".\" (dot, period)\nexport const codeColon = 0x3a // \":\"\nexport const codeSemicolon = 0x3b // \";\"\nexport const codeUppercaseA = 0x41 // \"A\"\nexport const codeLowercaseA = 0x61 // \"a\"\nexport const codeUppercaseE = 0x45 // \"E\"\nexport const codeLowercaseE = 0x65 // \"e\"\nexport const codeUppercaseF = 0x46 // \"F\"\nexport const codeLowercaseF = 0x66 // \"f\"\nconst codeNonBreakingSpace = 0xa0\nconst codeEnQuad = 0x2000\nconst codeHairSpace = 0x200a\nconst codeNarrowNoBreakSpace = 0x202f\nconst codeMediumMathematicalSpace = 0x205f\nconst codeIdeographicSpace = 0x3000\nconst codeDoubleQuoteLeft = 0x201c // “\nconst codeDoubleQuoteRight = 0x201d // ”\nconst codeQuoteLeft = 0x2018 // ‘\nconst codeQuoteRight = 0x2019 // ’\nconst codeGraveAccent = 0x0060 // `\nconst codeAcuteAccent = 0x00b4 // ´\n\nexport function isHex(code: number): boolean {\n return (\n (code >= codeZero && code <= codeNine) ||\n (code >= codeUppercaseA && code <= codeUppercaseF) ||\n (code >= codeLowercaseA && code <= codeLowercaseF)\n )\n}\n\nexport function isDigit(code: number): boolean {\n return code >= codeZero && code <= codeNine\n}\n\nexport function isValidStringCharacter(code: number): boolean {\n return code >= 0x20 && code <= 0x10ffff\n}\n\nexport function isDelimiter(char: string): boolean {\n return regexDelimiter.test(char)\n}\n\nconst regexDelimiter = /^[,:[\\]/{}()\\n+]$/\n\nexport function isDelimiterExceptSlash(char: string): boolean {\n return isDelimiter(char) && char !== '/'\n}\n\nexport function isStartOfValue(char: string): boolean {\n return regexStartOfValue.test(char) || (char && isQuote(char.charCodeAt(0)))\n}\n\n// alpha, number, minus, or opening bracket or brace\nconst regexStartOfValue = /^[[{\\w-]$/\n\nexport function isControlCharacter(code: number) {\n return (\n code === codeNewline ||\n code === codeReturn ||\n code === codeTab ||\n code === codeBackspace ||\n code === codeFormFeed\n )\n}\n\n/**\n * Check if the given character is a whitespace character like space, tab, or\n * newline\n */\nexport function isWhitespace(code: number): boolean {\n return code === codeSpace || code === codeNewline || code === codeTab || code === codeReturn\n}\n\n/**\n * Check if the given character is a special whitespace character, some\n * unicode variant\n */\nexport function isSpecialWhitespace(code: number): boolean {\n return (\n code === codeNonBreakingSpace ||\n (code >= codeEnQuad && code <= codeHairSpace) ||\n code === codeNarrowNoBreakSpace ||\n code === codeMediumMathematicalSpace ||\n code === codeIdeographicSpace\n )\n}\n\n/**\n * Test whether the given character is a quote or double quote character.\n * Also tests for special variants of quotes.\n */\nexport function isQuote(code: number): boolean {\n // the first check double quotes, since that occurs most often\n return isDoubleQuoteLike(code) || isSingleQuoteLike(code)\n}\n\n/**\n * Test whether the given character is a double quote character.\n * Also tests for special variants of double quotes.\n */\nexport function isDoubleQuoteLike(code: number): boolean {\n // the first check double quotes, since that occurs most often\n return code === codeDoubleQuote || code === codeDoubleQuoteLeft || code === codeDoubleQuoteRight\n}\n\n/**\n * Test whether the given character is a double quote character.\n * Does NOT test for special variants of double quotes.\n */\nexport function isDoubleQuote(code: number): boolean {\n return code === codeDoubleQuote\n}\n\n/**\n * Test whether the given character is a single quote character.\n * Also tests for special variants of single quotes.\n */\nexport function isSingleQuoteLike(code: number): boolean {\n return (\n code === codeQuote ||\n code === codeQuoteLeft ||\n code === codeQuoteRight ||\n code === codeGraveAccent ||\n code === codeAcuteAccent\n )\n}\n\n/**\n * Test whether the given character is a single quote character.\n * Does NOT test for special variants of single quotes.\n */\nexport function isSingleQuote(code: number): boolean {\n return code === codeQuote\n}\n\n/**\n * Strip last occurrence of textToStrip from text\n */\nexport function stripLastOccurrence(\n text: string,\n textToStrip: string,\n stripRemainingText = false\n): string {\n const index = text.lastIndexOf(textToStrip)\n return index !== -1\n ? text.substring(0, index) + (stripRemainingText ? '' : text.substring(index + 1))\n : text\n}\n\nexport function insertBeforeLastWhitespace(text: string, textToInsert: string): string {\n let index = text.length\n\n if (!isWhitespace(text.charCodeAt(index - 1))) {\n // no trailing whitespaces\n return text + textToInsert\n }\n\n while (isWhitespace(text.charCodeAt(index - 1))) {\n index--\n }\n\n return text.substring(0, index) + textToInsert + text.substring(index)\n}\n\nexport function removeAtIndex(text: string, start: number, count: number) {\n return text.substring(0, start) + text.substring(start + count)\n}\n\n/**\n * Test whether a string ends with a newline or comma character and optional whitespace\n */\nexport function endsWithCommaOrNewline(text: string): boolean {\n return /[,\\n][ \\t\\r]*$/.test(text)\n}\n\nexport function isFunctionName(text: string): boolean {\n return /^\\w+$/.test(text)\n}\n"],"mappings":"AAAA,OAAO,MAAMA,aAAa,GAAG,IAAI,EAAC;AAClC,OAAO,MAAMC,SAAS,GAAG,IAAI,EAAC;AAC9B,OAAO,MAAMC,YAAY,GAAG,IAAI,EAAC;AACjC,OAAO,MAAMC,gBAAgB,GAAG,IAAI,EAAC;AACrC,OAAO,MAAMC,gBAAgB,GAAG,IAAI,EAAC;AACrC,OAAO,MAAMC,kBAAkB,GAAG,IAAI,EAAC;AACvC,OAAO,MAAMC,kBAAkB,GAAG,IAAI,EAAC;AACvC,OAAO,MAAMC,mBAAmB,GAAG,IAAI,EAAC;AACxC,OAAO,MAAMC,oBAAoB,GAAG,IAAI,EAAC;AACzC,OAAO,MAAMC,SAAS,GAAG,IAAI,EAAC;AAC9B,OAAO,MAAMC,WAAW,GAAG,GAAG,EAAC;AAC/B,OAAO,MAAMC,OAAO,GAAG,GAAG,EAAC;AAC3B,OAAO,MAAMC,UAAU,GAAG,GAAG,EAAC;AAC9B,OAAO,MAAMC,aAAa,GAAG,IAAI,EAAC;AAClC,OAAO,MAAMC,YAAY,GAAG,IAAI,EAAC;AACjC,OAAO,MAAMC,eAAe,GAAG,MAAM,EAA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