123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308 |
- define(['exports', './when-e6985d2a'], function (exports, when) { 'use strict';
-
- function DeveloperError(message) {
-
- this.name = "DeveloperError";
-
- this.message = message;
-
- var stack;
- try {
- throw new Error();
- } catch (e) {
- stack = e.stack;
- }
-
- this.stack = stack;
- }
- if (when.defined(Object.create)) {
- DeveloperError.prototype = Object.create(Error.prototype);
- DeveloperError.prototype.constructor = DeveloperError;
- }
- DeveloperError.prototype.toString = function () {
- var str = this.name + ": " + this.message;
- if (when.defined(this.stack)) {
- str += "\n" + this.stack.toString();
- }
- return str;
- };
-
- DeveloperError.throwInstantiationError = function () {
- throw new DeveloperError(
- "This function defines an interface and should not be called directly."
- );
- };
-
- var Check = {};
-
- Check.typeOf = {};
- function getUndefinedErrorMessage(name) {
- return name + " is required, actual value was undefined";
- }
- function getFailedTypeErrorMessage(actual, expected, name) {
- return (
- "Expected " +
- name +
- " to be typeof " +
- expected +
- ", actual typeof was " +
- actual
- );
- }
-
- Check.defined = function (name, test) {
- if (!when.defined(test)) {
- throw new DeveloperError(getUndefinedErrorMessage(name));
- }
- };
-
- Check.typeOf.func = function (name, test) {
- if (typeof test !== "function") {
- throw new DeveloperError(
- getFailedTypeErrorMessage(typeof test, "function", name)
- );
- }
- };
-
- Check.typeOf.string = function (name, test) {
- if (typeof test !== "string") {
- throw new DeveloperError(
- getFailedTypeErrorMessage(typeof test, "string", name)
- );
- }
- };
-
- Check.typeOf.number = function (name, test) {
- if (typeof test !== "number") {
- throw new DeveloperError(
- getFailedTypeErrorMessage(typeof test, "number", name)
- );
- }
- };
-
- Check.typeOf.number.lessThan = function (name, test, limit) {
- Check.typeOf.number(name, test);
- if (test >= limit) {
- throw new DeveloperError(
- "Expected " +
- name +
- " to be less than " +
- limit +
- ", actual value was " +
- test
- );
- }
- };
-
- Check.typeOf.number.lessThanOrEquals = function (name, test, limit) {
- Check.typeOf.number(name, test);
- if (test > limit) {
- throw new DeveloperError(
- "Expected " +
- name +
- " to be less than or equal to " +
- limit +
- ", actual value was " +
- test
- );
- }
- };
-
- Check.typeOf.number.greaterThan = function (name, test, limit) {
- Check.typeOf.number(name, test);
- if (test <= limit) {
- throw new DeveloperError(
- "Expected " +
- name +
- " to be greater than " +
- limit +
- ", actual value was " +
- test
- );
- }
- };
-
- Check.typeOf.number.greaterThanOrEquals = function (name, test, limit) {
- Check.typeOf.number(name, test);
- if (test < limit) {
- throw new DeveloperError(
- "Expected " +
- name +
- " to be greater than or equal to" +
- limit +
- ", actual value was " +
- test
- );
- }
- };
-
- Check.typeOf.object = function (name, test) {
- if (typeof test !== "object") {
- throw new DeveloperError(
- getFailedTypeErrorMessage(typeof test, "object", name)
- );
- }
- };
-
- Check.typeOf.bool = function (name, test) {
- if (typeof test !== "boolean") {
- throw new DeveloperError(
- getFailedTypeErrorMessage(typeof test, "boolean", name)
- );
- }
- };
-
- Check.typeOf.number.equals = function (name1, name2, test1, test2) {
- Check.typeOf.number(name1, test1);
- Check.typeOf.number(name2, test2);
- if (test1 !== test2) {
- throw new DeveloperError(
- name1 +
- " must be equal to " +
- name2 +
- ", the actual values are " +
- test1 +
- " and " +
- test2
- );
- }
- };
- exports.Check = Check;
- exports.DeveloperError = DeveloperError;
- });
|