mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-20 16:41:04 +00:00
Update std.js
This commit is contained in:
parent
6abe48ba5a
commit
6ab0343834
50
lib/std.js
50
lib/std.js
|
@ -449,54 +449,6 @@ AsyncFunction.bind = function(exports, args) {
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
function GeneratorFunction(f, callback) {
|
|
||||||
this._f = f;
|
|
||||||
this._callback = callback;
|
|
||||||
this._nextState = 0;
|
|
||||||
this._state = 0;
|
|
||||||
this._value = undefined;
|
|
||||||
this._done = false;
|
|
||||||
this._yield = function(value) {
|
|
||||||
if (this._nextState < this._state) {
|
|
||||||
throw new ReferenceError("CONTINUE");
|
|
||||||
} else {
|
|
||||||
this._value = value;
|
|
||||||
this._state++;
|
|
||||||
throw new ReferenceError("BREAK");
|
|
||||||
}
|
|
||||||
throw new RangeError("OUT OF RANGE");
|
|
||||||
};
|
|
||||||
|
|
||||||
this.next = function() {
|
|
||||||
this._nextState = 0;
|
|
||||||
|
|
||||||
var go = true;
|
|
||||||
while (go) {
|
|
||||||
try {
|
|
||||||
this._f(this._yield);
|
|
||||||
} catch (e) {
|
|
||||||
go = (e.message == "CONTINUE");
|
|
||||||
this._nextState++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this._done = (typeof this._callback !== "undefined" ? this._callback(this) : false);
|
|
||||||
|
|
||||||
return {
|
|
||||||
value: this._value,
|
|
||||||
done: this._done
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
this['return'] = function() {
|
|
||||||
// Not implemented
|
|
||||||
};
|
|
||||||
|
|
||||||
this['throw'] = function() {
|
|
||||||
// Not implemented
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function GeneratorFunction(f, callback) {
|
function GeneratorFunction(f, callback) {
|
||||||
this._f = f;
|
this._f = f;
|
||||||
this._callback = callback;
|
this._callback = callback;
|
||||||
|
@ -565,7 +517,7 @@ global.splitLn = splitLn;
|
||||||
global.addslashes = addslashes;
|
global.addslashes = addslashes;
|
||||||
global.AsyncFunction = AsyncFunction;
|
global.AsyncFunction = AsyncFunction;
|
||||||
|
|
||||||
exports.VERSIONINFO = "Standard Library (std.js) version 0.8";
|
exports.VERSIONINFO = "Standard Library (std.js) version 0.8.1";
|
||||||
exports.global = global;
|
exports.global = global;
|
||||||
exports.require = global.require;
|
exports.require = global.require;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user