1 |
- {"ast":null,"code":"\"use strict\";\n\n// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.StringUtils = void 0;\n/**\n * String helper functions\n */\nclass StringUtils {\n /**\n * Formats a string by replacing the named {keys} in the string with the values contained in the replacement dictionary.\n * @param format The format string that contains the parts to replace surrounded by {}. For example: \"wss://{region}.cts.speech.microsoft.com\".\n * If your string needs to contain a { or } you can use the {{ and }} escape sequences respectively.\n * @param replacements The dictionary of replacements. If a replacement is not found, it is replaced with an empty string\n * @returns The formatted string. If you pass in a null or undefined format string, an empty string will be returned\n */\n static formatString(format, replacements) {\n if (!format) {\n return \"\";\n }\n if (!replacements) {\n return format;\n }\n let formatted = \"\";\n let key = \"\";\n const appendToFormatted = str => {\n formatted += str;\n };\n const appendToKey = str => {\n key += str;\n };\n let appendFunc = appendToFormatted;\n for (let i = 0; i < format.length; i++) {\n const c = format[i];\n const next = i + 1 < format.length ? format[i + 1] : \"\";\n switch (c) {\n case \"{\":\n if (next === \"{\") {\n appendFunc(\"{\");\n i++;\n } else {\n appendFunc = appendToKey;\n }\n break;\n case \"}\":\n if (next === \"}\") {\n appendFunc(\"}\");\n i++;\n } else {\n if (replacements.hasOwnProperty(key)) {\n formatted += replacements[key];\n }\n appendFunc = appendToFormatted;\n key = \"\";\n }\n break;\n default:\n appendFunc(c);\n break;\n }\n }\n return formatted;\n }\n}\nexports.StringUtils = StringUtils;","map":{"version":3,"names":["Object","defineProperty","exports","value","StringUtils","formatString","format","replacements","formatted","key","appendToFormatted","str","appendToKey","appendFunc","i","length","c","next","hasOwnProperty"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common/StringUtils.js"],"sourcesContent":["\"use strict\";\n// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.StringUtils = void 0;\n/**\n * String helper functions\n */\nclass StringUtils {\n /**\n * Formats a string by replacing the named {keys} in the string with the values contained in the replacement dictionary.\n * @param format The format string that contains the parts to replace surrounded by {}. For example: \"wss://{region}.cts.speech.microsoft.com\".\n * If your string needs to contain a { or } you can use the {{ and }} escape sequences respectively.\n * @param replacements The dictionary of replacements. If a replacement is not found, it is replaced with an empty string\n * @returns The formatted string. If you pass in a null or undefined format string, an empty string will be returned\n */\n static formatString(format, replacements) {\n if (!format) {\n return \"\";\n }\n if (!replacements) {\n return format;\n }\n let formatted = \"\";\n let key = \"\";\n const appendToFormatted = (str) => {\n formatted += str;\n };\n const appendToKey = (str) => {\n key += str;\n };\n let appendFunc = appendToFormatted;\n for (let i = 0; i < format.length; i++) {\n const c = format[i];\n const next = i + 1 < format.length ? format[i + 1] : \"\";\n switch (c) {\n case \"{\":\n if (next === \"{\") {\n appendFunc(\"{\");\n i++;\n }\n else {\n appendFunc = appendToKey;\n }\n break;\n case \"}\":\n if (next === \"}\") {\n appendFunc(\"}\");\n i++;\n }\n else {\n if (replacements.hasOwnProperty(key)) {\n formatted += replacements[key];\n }\n appendFunc = appendToFormatted;\n key = \"\";\n }\n break;\n default:\n appendFunc(c);\n break;\n }\n }\n return formatted;\n }\n}\nexports.StringUtils = StringUtils;\n\n"],"mappings":"AAAA,YAAY;;AACZ;AACA;AACAA,MAAM,CAACC,cAAc,CAACC,OAAO,EAAE,YAAY,EAAE;EAAEC,KAAK,EAAE;AAAK,CAAC,CAAC;AAC7DD,OAAO,CAACE,WAAW,GAAG,KAAK,CAAC;AAC5B;AACA;AACA;AACA,MAAMA,WAAW,CAAC;EACd;AACJ;AACA;AACA;AACA;AACA;AACA;EACI,OAAOC,YAAYA,CAACC,MAAM,EAAEC,YAAY,EAAE;IACtC,IAAI,CAACD,MAAM,EAAE;MACT,OAAO,EAAE;IACb;IACA,IAAI,CAACC,YAAY,EAAE;MACf,OAAOD,MAAM;IACjB;IACA,IAAIE,SAAS,GAAG,EAAE;IAClB,I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