one
Version:
One is a React framework for web, iOS, and Android apps.
69 lines (66 loc) • 2.64 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all) __defProp(target, name, {
get: all[name],
enumerable: true
});
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
get: () => from[key],
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
});
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var validate_exports = {};
__export(validate_exports, {
assertSpeakOptions: () => assertSpeakOptions,
assertSpeakText: () => assertSpeakText
});
module.exports = __toCommonJS(validate_exports);
function assertSpeakText(text) {
if (typeof text !== "string" || text.length === 0) {
throw new Error("SpeechSynthesis.speak: text must be a non-empty string");
}
}
function assertSpeakOptions(options) {
if (options === void 0) return;
if (typeof options !== "object" || options === null || Array.isArray(options)) {
throw new Error("SpeechSynthesis.speak: options must be an object");
}
var { language, pitch, rate, voice, volume, onStart, onDone, onStopped, onError } = options;
if (language !== void 0 && typeof language !== "string") {
throw new Error("SpeechSynthesis.speak: language must be a BCP-47 string");
}
if (pitch !== void 0 && (typeof pitch !== "number" || !Number.isFinite(pitch))) {
throw new Error("SpeechSynthesis.speak: pitch must be a finite number");
}
if (rate !== void 0 && (typeof rate !== "number" || !Number.isFinite(rate))) {
throw new Error("SpeechSynthesis.speak: rate must be a finite number");
}
if (voice !== void 0 && typeof voice !== "string") {
throw new Error("SpeechSynthesis.speak: voice must be a string");
}
if (volume !== void 0 && (typeof volume !== "number" || !Number.isFinite(volume) || volume < 0 || volume > 1)) {
throw new Error("SpeechSynthesis.speak: volume must be a number between 0 and 1");
}
for (var _i = 0, _iter = [
["onStart", onStart],
["onDone", onDone],
["onStopped", onStopped],
["onError", onError]
]; _i < _iter.length; _i++) {
var [name, callback] = _iter[_i];
if (callback !== void 0 && typeof callback !== "function") {
throw new Error(`SpeechSynthesis.speak: ${name} must be a function`);
}
}
}
//# sourceMappingURL=validate.native.js.map