6to5-runtime
Advanced tools
Comparing version 3.4.1 to 3.5.0
"use strict"; | ||
var _to5Helpers = require("6to5-runtime/helpers"); | ||
var _core = require("6to5-runtime/core-js"); | ||
@@ -44,7 +46,7 @@ | ||
exports.taggedTemplateLiteral = function (strings, raw) { | ||
return _core.Object.freeze(Object.defineProperties(strings, { | ||
return _to5Helpers.tailCall(_core.Object.freeze, [Object.defineProperties(strings, { | ||
raw: { | ||
value: _core.Object.freeze(raw) | ||
} | ||
})); | ||
})], Object); | ||
}; | ||
@@ -62,3 +64,7 @@ | ||
exports.toArray = function (arr) { | ||
return Array.isArray(arr) ? arr : _core.Array.from(arr); | ||
if (Array.isArray(arr)) { | ||
return arr; | ||
} else { | ||
return _to5Helpers.tailCall(_core.Array.from, [arr], Array); | ||
} | ||
}; | ||
@@ -98,3 +104,3 @@ | ||
exports.defineProperty = function (obj, key, value) { | ||
return Object.defineProperty(obj, key, { | ||
return _to5Helpers.tailCall(Object.defineProperty, [obj, key, { | ||
value: value, | ||
@@ -104,3 +110,3 @@ enumerable: true, | ||
writable: true | ||
}); | ||
}], Object); | ||
}; | ||
@@ -170,3 +176,3 @@ | ||
} else { | ||
return get(parent, property, receiver); | ||
return _to5Helpers.tailCall(get, [parent, property, receiver]); | ||
} | ||
@@ -180,3 +186,3 @@ } else if ("value" in desc && desc.writable) { | ||
} | ||
return getter.call(receiver); | ||
return _to5Helpers.tailCall(getter.call, [receiver], getter); | ||
} | ||
@@ -194,3 +200,3 @@ }; | ||
} else { | ||
return set(parent, property, value, receiver); | ||
return _to5Helpers.tailCall(set, [parent, property, value, receiver]); | ||
} | ||
@@ -205,3 +211,3 @@ } else if ("value" in desc && desc.writable) { | ||
} | ||
return setter.call(receiver, value); | ||
return _to5Helpers.tailCall(setter.call, [receiver, value], setter); | ||
} | ||
@@ -218,2 +224,32 @@ }; | ||
if (obj == null) throw new TypeError("Cannot destructure undefined"); | ||
}; | ||
}; | ||
exports.temporalUndefined = {}; | ||
exports.temporalAssertDefined = function (val, name, undef) { | ||
if (val === undef) { | ||
throw new ReferenceError(name + " is not defined - temporal dead zone"); | ||
} | ||
return true; | ||
}; | ||
exports.tailCall = (function () { | ||
function Tail(func, args, context) { | ||
this.func = func; | ||
this.args = args; | ||
this.context = context; | ||
} | ||
var isRunning = false; | ||
return function (func, args, context) { | ||
var result = new Tail(func, args, context); | ||
if (!isRunning) { | ||
isRunning = true; | ||
do { | ||
result = result.func.apply(result.context, result.args); | ||
} while (result instanceof Tail); | ||
isRunning = false; | ||
} | ||
return result; | ||
}; | ||
})(); |
{ | ||
"name": "6to5-runtime", | ||
"description": "6to5 selfContained runtime", | ||
"version": "3.4.1", | ||
"version": "3.5.0", | ||
"repository": "6to5/6to5", | ||
"author": "Sebastian McKenzie <sebmck@gmail.com>" | ||
} |
"use strict"; | ||
var _to5Helpers = require("6to5-runtime/helpers"); | ||
var _core = require("6to5-runtime/core-js"); | ||
@@ -135,3 +137,3 @@ | ||
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume | ||
return doneResult(); | ||
return _to5Helpers.tailCall(doneResult); | ||
} | ||
@@ -310,3 +312,3 @@ | ||
if (iteratorMethod) { | ||
return iteratorMethod.call(iterable); | ||
return _to5Helpers.tailCall(iteratorMethod.call, [iterable], iteratorMethod); | ||
} | ||
@@ -400,3 +402,3 @@ | ||
// throw the exception. | ||
return handle("end"); | ||
return _to5Helpers.tailCall(handle, ["end"]); | ||
} | ||
@@ -410,13 +412,13 @@ | ||
if (this.prev < entry.catchLoc) { | ||
return handle(entry.catchLoc, true); | ||
return _to5Helpers.tailCall(handle, [entry.catchLoc, true]); | ||
} else if (this.prev < entry.finallyLoc) { | ||
return handle(entry.finallyLoc); | ||
return _to5Helpers.tailCall(handle, [entry.finallyLoc]); | ||
} | ||
} else if (hasCatch) { | ||
if (this.prev < entry.catchLoc) { | ||
return handle(entry.catchLoc, true); | ||
return _to5Helpers.tailCall(handle, [entry.catchLoc, true]); | ||
} | ||
} else if (hasFinally) { | ||
if (this.prev < entry.finallyLoc) { | ||
return handle(entry.finallyLoc); | ||
return _to5Helpers.tailCall(handle, [entry.finallyLoc]); | ||
} | ||
@@ -471,4 +473,5 @@ } else { | ||
finish: function (finallyLoc) { | ||
var _temp; | ||
var entry = this._findFinallyEntry(finallyLoc); | ||
return this.complete(entry.completion); | ||
return _to5Helpers.tailCall((_temp = this).complete, [entry.completion], _temp); | ||
}, | ||
@@ -475,0 +478,0 @@ |
99708
2720