microsoft-cognitiveservices-speech-sdk
Version:
Microsoft Cognitive Services Speech SDK for JavaScript
1 lines • 4.61 kB
Source Map (JSON)
{"version":3,"sources":["src/sdk/PropertyCollection.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;;GAGG;AACH,qBAAa,kBAAkB;IAC3B,OAAO,CAAC,QAAQ,CAA4B;IAC5C,OAAO,CAAC,UAAU,CAA4B;IAE9C;;;;;;;;;;;OAWG;IACI,WAAW,CAAC,GAAG,EAAE,UAAU,GAAG,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM;IAsBrF;;;;;;;OAOG;IACI,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAoBjE;;;;;;OAMG;IACI,KAAK,IAAI,kBAAkB;IAWlC;;;;;;OAMG;IACI,OAAO,CAAC,qBAAqB,EAAE,kBAAkB,GAAG,IAAI;IAS/D;;;;;;OAMG;IACH,IAAW,IAAI,IAAI,MAAM,EAAE,CAE1B;CACJ","file":"PropertyCollection.d.ts","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { PropertyId } from \"./Exports.js\";\r\n\r\n/**\r\n * Represents collection of properties and their values.\r\n * @class PropertyCollection\r\n */\r\nexport class PropertyCollection {\r\n private privKeys: string[] = [] as string[];\r\n private privValues: string[] = [] as string[];\r\n\r\n /**\r\n * Returns the property value in type String.\r\n * Currently only String, int and bool are allowed.\r\n * If the name is not available, the specified defaultValue is returned.\r\n * @member PropertyCollection.prototype.getProperty\r\n * @function\r\n * @public\r\n * @param {string} key - The parameter name.\r\n * @param {string | number | boolean} def - The default value which is returned if the parameter\r\n * is not available in the collection.\r\n * @returns {string} value of the parameter.\r\n */\r\n public getProperty(key: PropertyId | string, def?: string | number | boolean): string {\r\n let keyToUse: string;\r\n\r\n if (typeof key === \"string\") {\r\n keyToUse = key;\r\n } else {\r\n keyToUse = PropertyId[key];\r\n }\r\n\r\n for (let n = 0; n < this.privKeys.length; n++) {\r\n if (this.privKeys[n] === keyToUse) {\r\n return this.privValues[n];\r\n }\r\n }\r\n\r\n if (def === undefined) {\r\n return undefined;\r\n }\r\n\r\n return String(def);\r\n }\r\n\r\n /**\r\n * Sets the String value of the parameter specified by name.\r\n * @member PropertyCollection.prototype.setProperty\r\n * @function\r\n * @public\r\n * @param {string} key - The parameter name.\r\n * @param {string} value - The value of the parameter.\r\n */\r\n public setProperty(key: string | PropertyId, value: string): void {\r\n let keyToUse: string;\r\n\r\n if (typeof key === \"string\") {\r\n keyToUse = key;\r\n } else {\r\n keyToUse = PropertyId[key];\r\n }\r\n\r\n for (let n = 0; n < this.privKeys.length; n++) {\r\n if (this.privKeys[n] === keyToUse) {\r\n this.privValues[n] = value;\r\n return;\r\n }\r\n }\r\n\r\n this.privKeys.push(keyToUse);\r\n this.privValues.push(value);\r\n }\r\n\r\n /**\r\n * Clones the collection.\r\n * @member PropertyCollection.prototype.clone\r\n * @function\r\n * @public\r\n * @returns {PropertyCollection} A copy of the collection.\r\n */\r\n public clone(): PropertyCollection {\r\n const clonedMap = new PropertyCollection();\r\n\r\n for (let n = 0; n < this.privKeys.length; n++) {\r\n clonedMap.privKeys.push(this.privKeys[n]);\r\n clonedMap.privValues.push(this.privValues[n]);\r\n }\r\n\r\n return clonedMap;\r\n }\r\n\r\n /**\r\n * Merges this set of properties into another, no overwrites.\r\n * @member PropertyCollection.prototype.mergeTo\r\n * @function\r\n * @public\r\n * @param {PropertyCollection} destinationCollection - The collection to merge into.\r\n */\r\n public mergeTo(destinationCollection: PropertyCollection): void {\r\n this.privKeys.forEach((key: string | PropertyId): void => {\r\n if (destinationCollection.getProperty(key, undefined) === undefined) {\r\n const value = this.getProperty(key);\r\n destinationCollection.setProperty(key, value);\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Get the keys in Property Collection.\r\n * @member PropertyCollection.prototype.keys\r\n * @function\r\n * @public\r\n * @returns {string []} Keys in the collection.\r\n */\r\n public get keys(): string[] {\r\n return this.privKeys;\r\n }\r\n}\r\n"]}