From 17bbdadbb4cc06a212aece58e25d90f232f0d472 Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Tue, 14 Mar 2023 13:41:49 +0900 Subject: [PATCH] Update std.js --- lib/std.js | 69 ++++++++++++++++++++++++++---------------------------- 1 file changed, 33 insertions(+), 36 deletions(-) diff --git a/lib/std.js b/lib/std.js index c4ec7d4..b1bf963 100644 --- a/lib/std.js +++ b/lib/std.js @@ -10,7 +10,6 @@ ///////////////////////////////////////////////////////////////////////////////// // Polyfills ///////////////////////////////////////////////////////////////////////////////// - if (!Function.prototype.GetResource) { Function.prototype.GetResource = function(ResourceName) { if (!this.Resources) { @@ -56,7 +55,8 @@ if (!Enumerator.prototype.toArray2) { x[c.name] = c.value; } } else { - var i = 0, d = []; + var i = 0, + d = []; while (true) { try { d.push(c.value(i)); @@ -95,18 +95,19 @@ function sleep(ms, callback) { cur = Date.now(); } end = Date.now(); - + //WScript.Sleep(ms); if (typeof callback === "function") - callback() - ; + callback(); } else if (typeof window !== "undefined") { if (typeof callback === "function") - handler = setTimeout(callback, ms); - ; + handler = setTimeout(callback, ms);; } - return { 'ms': end, 'handler': handler }; + return { + 'ms': end, + 'handler': handler + }; }; function repeat(target, callback, onError, onNextInterval, onNext) { @@ -171,7 +172,9 @@ function repeat(target, callback, onError, onNextInterval, onNext) { } } - return { 'ms': end, 'handler': handler }; + return { + 'ms': end, 'handler': handler + }; case "object": var arr = target; @@ -180,15 +183,11 @@ function repeat(target, callback, onError, onNextInterval, onNext) { try { if (typeof callback === "function") if (callback(i, arr[i]) === false) - break - ; - ; + break;; } catch (e) { if (typeof onError === "function") if (onError(e, i, arr[i]) === false) - break - ; - ; + break;; } } } @@ -210,8 +209,7 @@ function rotate(target, callback, onError) { } } catch (e) { if (typeof onError === "function") - stop = onError(e, i, arr[i]); - ; + stop = onError(e, i, arr[i]);; } i++; @@ -221,9 +219,10 @@ function rotate(target, callback, onError) { function range() { var args = arguments; - var N = [], start, end, step; + var N = [], + start, end, step; - switch(args.length) { + switch (args.length) { case 3: start = args[0]; end = args[1]; @@ -244,8 +243,7 @@ function range() { } for (var i = start; i < end; i = i + step) - N.push(i) - ; + N.push(i); return N; }; @@ -260,14 +258,13 @@ function splitLn(s) { function addslashes(s) { return s.toString().replace(/\\/g, '\\\\'). - replace(/\u0008/g, '\\b'). - replace(/\t/g, '\\t'). - replace(/\n/g, '\\n'). - replace(/\f/g, '\\f'). - replace(/\r/g, '\\r'). - replace(/'/g, '\\\''). - replace(/"/g, '\\"') - ; + replace(/\u0008/g, '\\b'). + replace(/\t/g, '\\t'). + replace(/\n/g, '\\n'). + replace(/\f/g, '\\f'). + replace(/\r/g, '\\r'). + replace(/'/g, '\\\''). + replace(/"/g, '\\"'); }; ///////////////////////////////////////////////////////////////////////////////// @@ -326,8 +323,8 @@ function StdEvent(type) { this.target = null; this.currentTarget = null; this.eventPhase = StdEvent.NONE; - this.bubbles = false; // Not used but to be compatible - this.composed = false; // Not used but to be compatible + this.bubbles = false; // Not used but to be compatible + this.composed = false; // Not used but to be compatible this.preventDefault = function() { this.defaultPrevented = true; @@ -347,9 +344,9 @@ function StdEvent(type) { this.stopPropagation = function() {}; }; StdEvent.NONE = 0; -StdEvent.CAPTURING_PHASE = 1; // Not used but to be compatible +StdEvent.CAPTURING_PHASE = 1; // Not used but to be compatible StdEvent.AT_TARGET = 2; -StdEvent.BUBBLING_PHASE = 3; // Not used but to be compatible +StdEvent.BUBBLING_PHASE = 3; // Not used but to be compatible function StdEventTarget() { this.__events__ = []; @@ -408,7 +405,7 @@ function AsyncFunction(f, _filename) { // increase number of async functions AsyncFunction.counter++; - + // decrease number of async functions var _this = this; var _f = function() { @@ -439,7 +436,7 @@ AsyncFunction.bind = function(exports, args) { try { exports[f](args); result = true; - } catch(e) { + } catch (e) { console.error("AsyncFunction.bind exception", e.message); result = false; } @@ -479,7 +476,7 @@ function GeneratorFunction(f, callback) { this._nextState++; } } - + this._done = (typeof this._callback !== "undefined" ? this._callback(this) : false); return {