microsoft-cognitiveservices-speech-sdk
Version:
Microsoft Cognitive Services Speech SDK for JavaScript
1 lines • 3.36 kB
Source Map (JSON)
{"version":3,"sources":["src/sdk/Contracts.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,qBAAa,SAAS;WACJ,sBAAsB,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;WAMtD,WAAW,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;WAM3C,uBAAuB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;WAQ1D,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;WAQ1E,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;WAQ3E,eAAe,CAAC,UAAU,EAAE,OAAO,GAAG,IAAI;WAM1C,6BAA6B,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;WAYlE,uBAAuB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;WAM1D,mBAAmB,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;CAKpE","file":"Contracts.d.ts","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\n/**\r\n * @class Contracts\r\n * @private\r\n */\r\nexport class Contracts {\r\n public static throwIfNullOrUndefined(param: any, name: string): void {\r\n if (param === undefined || param === null) {\r\n throw new Error(\"throwIfNullOrUndefined:\" + name);\r\n }\r\n }\r\n\r\n public static throwIfNull(param: any, name: string): void {\r\n if (param === null) {\r\n throw new Error(\"throwIfNull:\" + name);\r\n }\r\n }\r\n\r\n public static throwIfNullOrWhitespace(param: string, name: string): void {\r\n Contracts.throwIfNullOrUndefined(param, name);\r\n\r\n if ((\"\" + param).trim().length < 1) {\r\n throw new Error(\"throwIfNullOrWhitespace:\" + name);\r\n }\r\n }\r\n\r\n public static throwIfNullOrTooLong(param: string, name: string, maxLength: number): void {\r\n Contracts.throwIfNullOrUndefined(param, name);\r\n\r\n if ((\"\" + param).length > maxLength) {\r\n throw new Error(\"throwIfNullOrTooLong:\" + name + \" (more than \" + maxLength.toString() + \" characters)\");\r\n }\r\n }\r\n\r\n public static throwIfNullOrTooShort(param: string, name: string, minLength: number): void {\r\n Contracts.throwIfNullOrUndefined(param, name);\r\n\r\n if ((\"\" + param).length < minLength) {\r\n throw new Error(\"throwIfNullOrTooShort:\" + name + \" (less than \" + minLength.toString() + \" characters)\");\r\n }\r\n }\r\n\r\n public static throwIfDisposed(isDisposed: boolean): void {\r\n if (isDisposed) {\r\n throw new Error(\"the object is already disposed\");\r\n }\r\n }\r\n\r\n public static throwIfArrayEmptyOrWhitespace(array: string[], name: string): void {\r\n Contracts.throwIfNullOrUndefined(array, name);\r\n\r\n if (array.length === 0) {\r\n throw new Error(\"throwIfArrayEmptyOrWhitespace:\" + name);\r\n }\r\n\r\n for (const item of array) {\r\n Contracts.throwIfNullOrWhitespace(item, name);\r\n }\r\n }\r\n\r\n public static throwIfFileDoesNotExist(param: string, name: string): void {\r\n Contracts.throwIfNullOrWhitespace(param, name);\r\n\r\n // TODO check for file existence.\r\n }\r\n\r\n public static throwIfNotUndefined(param: any, name: string): void {\r\n if (param !== undefined) {\r\n throw new Error(\"throwIfNotUndefined:\" + name);\r\n }\r\n }\r\n}\r\n"]}