Code: Select all
/*
//https://babeljs.io/repl/#?browsers=ie%206&build=&builtIns=false&corejs=3.21&spec=false&loose=false&code_lz=Q&debug=false&forceAllTransforms=false&shippedProposals=false&circleciRepo=&evaluate=false&fileSize=false&timeTravel=false&sourceType=module&lineWrap=true&presets=env&prettier=true&targets=&version=7.18.8&externalPlugins=&assumptions=%7B%7D
function* add(x) {
let y = yield(x*5)
return x + y
}
let iterator = add(2)
console.log(iterator.next())
console.log(iterator.next(3))
*/
////////////////////////////////////////////////////////////////////////// some AkelPad code
//Arguments
var bLocal = AkelPad.GetArgValue("Local", false);
//Variables
var hMainWnd = AkelPad.GetMainWnd();
var hWndEdit = AkelPad.GetEditWnd();
var oSys = AkelPad.SystemFunction();
var dwOptions;
////////////////////////////////////////////////////////////////////////// polyfills
if (!Object.create) {
Object.create = function (proto) {
function F() {}
F.prototype = proto;
return new F;
};
}
if (!Array.prototype.forEach) {
Array.prototype.forEach = function (callback, thisArg) {
for (var i = 0; i < this.length; i++) {
callback.call(thisArg, this[i], i, this);
}
};
}
var console = {
log: function () {
for (var i = 0; i < arguments.length; i++) {
if (typeof arguments[i] === "object")
WScript.echo(JSON.stringify(arguments[i], null, 4));
else
WScript.echo(arguments[i]);
}
}
};
////////////////////////////////////////////////////////////////////////// json2.js
if (typeof JSON !== "object") {
JSON = {};
}
(function () {
"use strict";
var rx_one = /^[\],:{}\s]*$/;
var rx_two = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g;
var rx_three = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g;
var rx_four = /(?:^|:|,)(?:\s*\[)+/g;
var rx_escapable = /[\\"\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
var rx_dangerous = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
function f(n) {
// Format integers to have at least two digits.
return (n < 10) ?
"0" + n :
n;
}
function this_value() {
return this.valueOf();
}
if (typeof Date.prototype.toJSON !== "function") {
Date.prototype.toJSON = function () {
return isFinite(this.valueOf()) ?
(
this.getUTCFullYear() +
"-" +
f(this.getUTCMonth() + 1) +
"-" +
f(this.getUTCDate()) +
"T" +
f(this.getUTCHours()) +
":" +
f(this.getUTCMinutes()) +
":" +
f(this.getUTCSeconds()) +
"Z"
) :
null;
};
Boolean.prototype.toJSON = this_value;
Number.prototype.toJSON = this_value;
String.prototype.toJSON = this_value;
}
var gap;
var indent;
var meta;
var rep;
function quote(string) {
// If the string contains no control characters, no quote characters, and no
// backslash characters, then we can safely slap some quotes around it.
// Otherwise we must also replace the offending characters with safe escape
// sequences.
rx_escapable.lastIndex = 0;
return rx_escapable.test(string) ?
"\"" + string.replace(rx_escapable, function (a) {
var c = meta[a];
return typeof c === "string" ?
c :
"\\u" + ("0000" + a.charCodeAt(0).toString(16)).slice(-4);
}) + "\"" :
"\"" + string + "\"";
}
function str(key, holder) {
// Produce a string from holder[key].
var i; // The loop counter.
var k; // The member key.
var v; // The member value.
var length;
var mind = gap;
var partial;
var value = holder[key];
// If the value has a toJSON method, call it to obtain a replacement value.
if (
value &&
typeof value === "object" &&
typeof value.toJSON === "function"
) {
value = value.toJSON(key);
}
// If we were called with a replacer function, then call the replacer to
// obtain a replacement value.
if (typeof rep === "function") {
value = rep.call(holder, key, value);
}
// What happens next depends on the value's type.
switch (typeof value) {
case "string":
return quote(value);
case "number":
// JSON numbers must be finite. Encode non-finite numbers as null.
return (isFinite(value)) ?
String(value) :
"null";
case "boolean":
case "null":
// If the value is a boolean or null, convert it to a string. Note:
// typeof null does not produce "null". The case is included here in
// the remote chance that this gets fixed someday.
return String(value);
// If the type is "object", we might be dealing with an object or an array or
// null.
case "object":
// Due to a specification blunder in ECMAScript, typeof null is "object",
// so watch out for that case.
if (!value) {
return "null";
}
// Make an array to hold the partial results of stringifying this object value.
gap += indent;
partial = [];
// Is the value an array?
if (Object.prototype.toString.apply(value) === "[object Array]") {
// The value is an array. Stringify every element. Use null as a placeholder
// for non-JSON values.
length = value.length;
for (i = 0; i < length; i += 1) {
partial[i] = str(i, value) || "null";
}
// Join all of the elements together, separated with commas, and wrap them in
// brackets.
v = partial.length === 0 ?
"[]" :
gap ?
(
"[\n" +
gap +
partial.join(",\n" + gap) +
"\n" +
mind +
"]"
) :
"[" + partial.join(",") + "]";
gap = mind;
return v;
}
// If the replacer is an array, use it to select the members to be stringified.
if (rep && typeof rep === "object") {
length = rep.length;
for (i = 0; i < length; i += 1) {
if (typeof rep[i] === "string") {
k = rep[i];
v = str(k, value);
if (v) {
partial.push(quote(k) + (
(gap) ?
": " :
":"
) + v);
}
}
}
}
else {
// Otherwise, iterate through all of the keys in the object.
for (k in value) {
if (Object.prototype.hasOwnProperty.call(value, k)) {
v = str(k, value);
if (v) {
partial.push(quote(k) + (
(gap) ?
": " :
":"
) + v);
}
}
}
}
// Join all of the member texts together, separated with commas,
// and wrap them in braces.
v = partial.length === 0 ?
"{}" :
gap ?
"{\n" + gap + partial.join(",\n" + gap) + "\n" + mind + "}" :
"{" + partial.join(",") + "}";
gap = mind;
return v;
}
}
// If the JSON object does not yet have a stringify method, give it one.
if (typeof JSON.stringify !== "function") {
meta = { // table of character substitutions
"\b": "\\b",
"\t": "\\t",
"\n": "\\n",
"\f": "\\f",
"\r": "\\r",
"\"": "\\\"",
"\\": "\\\\"
};
JSON.stringify = function (value, replacer, space) {
// The stringify method takes a value and an optional replacer, and an optional
// space parameter, and returns a JSON text. The replacer can be a function
// that can replace values, or an array of strings that will select the keys.
// A default replacer method can be provided. Use of the space parameter can
// produce text that is more easily readable.
var i;
gap = "";
indent = "";
// If the space parameter is a number, make an indent string containing that
// many spaces.
if (typeof space === "number") {
for (i = 0; i < space; i += 1) {
indent += " ";
}
// If the space parameter is a string, it will be used as the indent string.
}
else if (typeof space === "string") {
indent = space;
}
// If there is a replacer, it must be a function or an array.
// Otherwise, throw an error.
rep = replacer;
if (replacer && typeof replacer !== "function" && (
typeof replacer !== "object" ||
typeof replacer.length !== "number"
)) {
throw new Error("JSON.stringify");
}
// Make a fake root object containing our value under the key of "".
// Return the result of stringifying the value.
return str("", {
"": value
});
};
}
// If the JSON object does not yet have a parse method, give it one.
if (typeof JSON.parse !== "function") {
JSON.parse = function (text, reviver) {
// The parse method takes a text and an optional reviver function, and returns
// a JavaScript value if the text is a valid JSON text.
var j;
function walk(holder, key) {
// The walk method is used to recursively walk the resulting structure so
// that modifications can be made.
var k;
var v;
var value = holder[key];
if (value && typeof value === "object") {
for (k in value) {
if (Object.prototype.hasOwnProperty.call(value, k)) {
v = walk(value, k);
if (v !== undefined) {
value[k] = v;
}
else {
delete value[k];
}
}
}
}
return reviver.call(holder, key, value);
}
// Parsing happens in four stages. In the first stage, we replace certain
// Unicode characters with escape sequences. JavaScript handles many characters
// incorrectly, either silently deleting them, or treating them as line endings.
text = String(text);
rx_dangerous.lastIndex = 0;
if (rx_dangerous.test(text)) {
text = text.replace(rx_dangerous, function (a) {
return (
"\\u" +
("0000" + a.charCodeAt(0).toString(16)).slice(-4)
);
});
}
// In the second stage, we run the text against regular expressions that look
// for non-JSON patterns. We are especially concerned with "()" and "new"
// because they can cause invocation, and "=" because it can cause mutation.
// But just to be safe, we want to reject all unexpected forms.
// We split the second stage into 4 regexp operations in order to work around
// crippling inefficiencies in IE's and Safari's regexp engines. First we
// replace the JSON backslash pairs with "@" (a non-JSON character). Second, we
// replace all simple value tokens with "]" characters. Third, we delete all
// open brackets that follow a colon or comma or that begin the text. Finally,
// we look to see that the remaining characters are only whitespace or "]" or
// "," or ":" or "{" or "}". If that is so, then the text is safe for eval.
if (
rx_one.test(
text
.replace(rx_two, "@")
.replace(rx_three, "]")
.replace(rx_four, "")
)
) {
// In the third stage we use the eval function to compile the text into a
// JavaScript structure. The "{" operator is subject to a syntactic ambiguity
// in JavaScript: it can begin a block or an object literal. We wrap the text
// in parens to eliminate the ambiguity.
j = eval("(" + text + ")");
// In the optional fourth stage, we recursively walk the new structure, passing
// each name/value pair to a reviver function for possible transformation.
return (typeof reviver === "function") ?
walk({
"": j
}, "") :
j;
}
// If the text is not JSON parseable, then a SyntaxError is thrown.
throw new SyntaxError("JSON.parse");
};
}
}());
////////////////////////////////////////////////////////////////////////// transpiled by the https://babeljs.io with TARGETS `ie 6`
"use strict";
function _typeof(obj) {
"@babel/helpers - typeof";
return (
(_typeof =
"function" == typeof Symbol && "symbol" == typeof Symbol.iterator ?
function (obj) {
return typeof obj;
} :
function (obj) {
return obj &&
"function" == typeof Symbol &&
obj.constructor === Symbol &&
obj !== Symbol.prototype ?
"symbol" :
typeof obj;
}),
_typeof(obj)
);
}
function _regeneratorRuntime() {
"use strict";
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
_regeneratorRuntime =
function _regeneratorRuntime() {
return exports;
};
var exports = {},
Op = Object.prototype,
hasOwn = Op.hasOwnProperty,
$Symbol = "function" == typeof Symbol ? Symbol : {},
iteratorSymbol = $Symbol.iterator || "@@iterator",
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
function define(obj, key, value) {
return (
Object.defineProperty(obj, key, {
value: value,
enumerable: !0,
configurable: !0,
writable: !0
}),
obj[key]
);
}
try {
define({}, "");
}
catch (err) {
define = function define(obj, key, value) {
return (obj[key] = value);
};
}
function wrap(innerFn, outerFn, self, tryLocsList) {
var protoGenerator =
outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
generator = Object.create(protoGenerator.prototype),
context = new Context(tryLocsList || []);
return (
(generator._invoke = (function (innerFn, self, context) {
var state = "suspendedStart";
return function (method, arg) {
if ("executing" === state)
throw new Error("Generator is already running");
if ("completed" === state) {
if ("throw" === method) throw arg;
return doneResult();
}
for (context.method = method, context.arg = arg;;) {
var delegate = context.delegate;
if (delegate) {
var delegateResult = maybeInvokeDelegate(delegate, context);
if (delegateResult) {
if (delegateResult === ContinueSentinel) continue;
return delegateResult;
}
}
if ("next" === context.method)
context.sent = context._sent = context.arg;
else if ("throw" === context.method) {
if ("suspendedStart" === state)
throw ((state = "completed"), context.arg);
context.dispatchException(context.arg);
}
else
"return" === context.method &&
context.abrupt("return", context.arg);
state = "executing";
var record = tryCatch(innerFn, self, context);
if ("normal" === record.type) {
if (
((state = context.done ? "completed" : "suspendedYield"),
record.arg === ContinueSentinel)
)
continue;
return {
value: record.arg,
done: context.done
};
}
"throw" === record.type &&
((state = "completed"),
(context.method = "throw"),
(context.arg = record.arg));
}
};
})(innerFn, self, context)),
generator
);
}
function tryCatch(fn, obj, arg) {
try {
return {
type: "normal",
arg: fn.call(obj, arg)
};
}
catch (err) {
return {
type: "throw",
arg: err
};
}
}
exports.wrap = wrap;
var ContinueSentinel = {};
function Generator() {}
function GeneratorFunction() {}
function GeneratorFunctionPrototype() {}
var IteratorPrototype = {};
define(IteratorPrototype, iteratorSymbol, function () {
return this;
});
var getProto = Object.getPrototypeOf,
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
NativeIteratorPrototype &&
NativeIteratorPrototype !== Op &&
hasOwn.call(NativeIteratorPrototype, iteratorSymbol) &&
(IteratorPrototype = NativeIteratorPrototype);
var Gp =
(GeneratorFunctionPrototype.prototype =
Generator.prototype =
Object.create(IteratorPrototype));
function defineIteratorMethods(prototype) {
["next", "throw", "return"].forEach(function (method) {
define(prototype, method, function (arg) {
return this._invoke(method, arg);
});
});
}
function AsyncIterator(generator, PromiseImpl) {
function invoke(method, arg, resolve, reject) {
var record = tryCatch(generator[method], generator, arg);
if ("throw" !== record.type) {
var result = record.arg,
value = result.value;
return value &&
"object" == _typeof(value) &&
hasOwn.call(value, "__await") ?
PromiseImpl.resolve(value.__await).then(
function (value) {
invoke("next", value, resolve, reject);
},
function (err) {
invoke("throw", err, resolve, reject);
}
) :
PromiseImpl.resolve(value).then(
function (unwrapped) {
(result.value = unwrapped), resolve(result);
},
function (error) {
return invoke("throw", error, resolve, reject);
}
);
}
reject(record.arg);
}
var previousPromise;
this._invoke = function (method, arg) {
function callInvokeWithMethodAndArg() {
return new PromiseImpl(function (resolve, reject) {
invoke(method, arg, resolve, reject);
});
}
return (previousPromise = previousPromise ?
previousPromise.then(
callInvokeWithMethodAndArg,
callInvokeWithMethodAndArg
) :
callInvokeWithMethodAndArg());
};
}
function maybeInvokeDelegate(delegate, context) {
var method = delegate.iterator[context.method];
if (undefined === method) {
if (((context.delegate = null), "throw" === context.method)) {
if (
delegate.iterator["return"] &&
((context.method = "return"),
(context.arg = undefined),
maybeInvokeDelegate(delegate, context),
"throw" === context.method)
)
return ContinueSentinel;
(context.method = "throw"),
(context.arg = new TypeError(
"The iterator does not provide a 'throw' method"
));
}
return ContinueSentinel;
}
var record = tryCatch(method, delegate.iterator, context.arg);
if ("throw" === record.type)
return (
(context.method = "throw"),
(context.arg = record.arg),
(context.delegate = null),
ContinueSentinel
);
var info = record.arg;
return info ?
info.done ?
((context[delegate.resultName] = info.value),
(context.next = delegate.nextLoc),
"return" !== context.method &&
((context.method = "next"), (context.arg = undefined)),
(context.delegate = null),
ContinueSentinel) :
info :
((context.method = "throw"),
(context.arg = new TypeError("iterator result is not an object")),
(context.delegate = null),
ContinueSentinel);
}
function pushTryEntry(locs) {
var entry = {
tryLoc: locs[0]
};
1 in locs && (entry.catchLoc = locs[1]),
2 in locs && ((entry.finallyLoc = locs[2]), (entry.afterLoc = locs[3])),
this.tryEntries.push(entry);
}
function resetTryEntry(entry) {
var record = entry.completion || {};
(record.type = "normal"), delete record.arg, (entry.completion = record);
}
function Context(tryLocsList) {
(this.tryEntries = [{
tryLoc: "root"
}]),
tryLocsList.forEach(pushTryEntry, this),
this.reset(!0);
}
function values(iterable) {
if (iterable) {
var iteratorMethod = iterable[iteratorSymbol];
if (iteratorMethod) return iteratorMethod.call(iterable);
if ("function" == typeof iterable.next) return iterable;
if (!isNaN(iterable.length)) {
var i = -1,
next = function next() {
for (; ++i < iterable.length;) {
if (hasOwn.call(iterable, i))
return (next.value = iterable[i]), (next.done = !1), next;
}
return (next.value = undefined), (next.done = !0), next;
};
return (next.next = next);
}
}
return {
next: doneResult
};
}
function doneResult() {
return {
value: undefined,
done: !0
};
}
return (
(GeneratorFunction.prototype = GeneratorFunctionPrototype),
define(Gp, "constructor", GeneratorFunctionPrototype),
define(GeneratorFunctionPrototype, "constructor", GeneratorFunction),
(GeneratorFunction.displayName = define(
GeneratorFunctionPrototype,
toStringTagSymbol,
"GeneratorFunction"
)),
(exports.isGeneratorFunction = function (genFun) {
var ctor = "function" == typeof genFun && genFun.constructor;
return (
!!ctor &&
(ctor === GeneratorFunction ||
"GeneratorFunction" === (ctor.displayName || ctor.name))
);
}),
(exports.mark = function (genFun) {
return (
Object.setPrototypeOf ?
Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) :
((genFun.__proto__ = GeneratorFunctionPrototype),
define(genFun, toStringTagSymbol, "GeneratorFunction")),
(genFun.prototype = Object.create(Gp)),
genFun
);
}),
(exports.awrap = function (arg) {
return {
__await: arg
};
}),
defineIteratorMethods(AsyncIterator.prototype),
define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
return this;
}),
(exports.AsyncIterator = AsyncIterator),
(exports.async = function (
innerFn,
outerFn,
self,
tryLocsList,
PromiseImpl
) {
void 0 === PromiseImpl && (PromiseImpl = Promise);
var iter = new AsyncIterator(
wrap(innerFn, outerFn, self, tryLocsList),
PromiseImpl
);
return exports.isGeneratorFunction(outerFn) ?
iter :
iter.next().then(function (result) {
return result.done ? result.value : iter.next();
});
}),
defineIteratorMethods(Gp),
define(Gp, toStringTagSymbol, "Generator"),
define(Gp, iteratorSymbol, function () {
return this;
}),
define(Gp, "toString", function () {
return "[object Generator]";
}),
(exports.keys = function (object) {
var keys = [];
for (var key in object) {
keys.push(key);
}
return (
keys.reverse(),
function next() {
for (; keys.length;) {
var key = keys.pop();
if (key in object)
return (next.value = key), (next.done = !1), next;
}
return (next.done = !0), next;
}
);
}),
(exports.values = values),
(Context.prototype = {
constructor: Context,
reset: function reset(skipTempReset) {
if (
((this.prev = 0),
(this.next = 0),
(this.sent = this._sent = undefined),
(this.done = !1),
(this.delegate = null),
(this.method = "next"),
(this.arg = undefined),
this.tryEntries.forEach(resetTryEntry),
!skipTempReset)
)
for (var name in this) {
"t" === name.charAt(0) &&
hasOwn.call(this, name) &&
!isNaN(+name.slice(1)) &&
(this[name] = undefined);
}
},
stop: function stop() {
this.done = !0;
var rootRecord = this.tryEntries[0].completion;
if ("throw" === rootRecord.type) throw rootRecord.arg;
return this.rval;
},
dispatchException: function dispatchException(exception) {
if (this.done) throw exception;
var context = this;
function handle(loc, caught) {
return (
(record.type = "throw"),
(record.arg = exception),
(context.next = loc),
caught && ((context.method = "next"), (context.arg = undefined)),
!!caught
);
}
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i],
record = entry.completion;
if ("root" === entry.tryLoc) return handle("end");
if (entry.tryLoc <= this.prev) {
var hasCatch = hasOwn.call(entry, "catchLoc"),
hasFinally = hasOwn.call(entry, "finallyLoc");
if (hasCatch && hasFinally) {
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
}
else if (hasCatch) {
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
}
else {
if (!hasFinally)
throw new Error("try statement without catch or finally");
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
}
}
}
},
abrupt: function abrupt(type, arg) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (
entry.tryLoc <= this.prev &&
hasOwn.call(entry, "finallyLoc") &&
this.prev < entry.finallyLoc
) {
var finallyEntry = entry;
break;
}
}
finallyEntry &&
("break" === type || "continue" === type) &&
finallyEntry.tryLoc <= arg &&
arg <= finallyEntry.finallyLoc &&
(finallyEntry = null);
var record = finallyEntry ? finallyEntry.completion : {};
return (
(record.type = type),
(record.arg = arg),
finallyEntry ?
((this.method = "next"),
(this.next = finallyEntry.finallyLoc),
ContinueSentinel) :
this.complete(record)
);
},
complete: function complete(record, afterLoc) {
if ("throw" === record.type) throw record.arg;
return (
"break" === record.type || "continue" === record.type ?
(this.next = record.arg) :
"return" === record.type ?
((this.rval = this.arg = record.arg),
(this.method = "return"),
(this.next = "end")) :
"normal" === record.type && afterLoc && (this.next = afterLoc),
ContinueSentinel
);
},
finish: function finish(finallyLoc) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.finallyLoc === finallyLoc)
return (
this.complete(entry.completion, entry.afterLoc),
resetTryEntry(entry),
ContinueSentinel
);
}
},
"catch": function _catch(tryLoc) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.tryLoc === tryLoc) {
var record = entry.completion;
if ("throw" === record.type) {
var thrown = record.arg;
resetTryEntry(entry);
}
return thrown;
}
}
throw new Error("illegal catch attempt");
},
delegateYield: function delegateYield(iterable, resultName, nextLoc) {
return (
(this.delegate = {
iterator: values(iterable),
resultName: resultName,
nextLoc: nextLoc
}),
"next" === this.method && (this.arg = undefined),
ContinueSentinel
);
}
}),
exports
);
}
var _marked = /*#__PURE__*/ _regeneratorRuntime().mark(add);
function add(x) {
var y;
return _regeneratorRuntime().wrap(function add$(_context) {
while (1) {
switch ((_context.prev = _context.next)) {
case 0:
_context.next = 2;
return x * 5;
case 2:
y = _context.sent;
return _context.abrupt("return", x + y);
case 4:
case "end":
return _context.stop();
}
}
}, _marked);
}
var iterator = add(2);
console.log(iterator.next());
console.log(iterator.next(3));