| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- class types {
- static check_string(target, none = false) {
- if (none && (target === undefined || target === null)) {
- return;
- }
- if (typeof(target) !== "string") {
- throw new TypeError("Target must be string.");
- }
- }
- static check_number(target, none = false) {
- if (none && (target === undefined || target === null)) {
- return;
- }
- if (typeof(target) !== "number") {
- throw new TypeError("Target must be number.");
- }
- }
- static check_html_element(target, none = false) {
- if (none && (target === undefined || target === null)) {
- return;
- }
- if (target instanceof HTMLElement) {
- return;
- }
- throw new TypeError("Target must be an HTML Element.");
- }
- static check_callback(target, none = false) {
- if (none && (target === undefined || target === null)) {
- return;
- }
- if (typeof(target) !== "function") {
- throw new TypeError("Target must be an callback.");
- }
- }
- static check_boolean(target, none = false) {
- if (none && (target === undefined || target === null)) {
- return;
- }
- if (typeof(target) !== "boolean") {
- throw new TypeError("Target must be an boolean.");
- }
- }
- static block_strings(target, blocked) {
- for (const string in blocked) {
- if (target.search(string) !== -1) {
- const fail = "Target can not contain \"" + string + "\".";
- throw new TypeError(fail);
- }
- }
- }
- }
- export { types };
|