From 9e0ff02892502ed7c66f82438f669fa5bcd35035 Mon Sep 17 00:00:00 2001 From: Frank Wallis Date: Sat, 1 Oct 2016 00:22:07 +0100 Subject: [PATCH 1/6] Add __generator helper to es6 source --- tslib.es6.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tslib.es6.js b/tslib.es6.js index f9d7325..8430b41 100644 --- a/tslib.es6.js +++ b/tslib.es6.js @@ -43,4 +43,32 @@ export const __awaiter = function (thisArg, _arguments, P, generator) { function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments)).next()); }); +}; + +export const __generator = function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t; + return { next: verb(0), "throw": verb(1), "return": verb(2) }; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [0, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } }; \ No newline at end of file From 0d128b46368b20a1fff251816fcc962c9a62f361 Mon Sep 17 00:00:00 2001 From: Frank Wallis Date: Sat, 1 Oct 2016 00:22:51 +0100 Subject: [PATCH 2/6] populate jsnext:main in package.json to support rollup --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 558a048..0099653 100644 --- a/package.json +++ b/package.json @@ -27,5 +27,6 @@ "url": "https://github.com/Microsoft/tslib.git" }, "main": "tslib.js", + "jsnext:main": "tslib.es6.js", "typings": "tslib.d.ts" } From 2af77d76c71a1bb6e932aa405b033388a8b035c4 Mon Sep 17 00:00:00 2001 From: Frank Wallis Date: Sat, 1 Oct 2016 09:35:44 +0100 Subject: [PATCH 3/6] Add __extends helper to es6 source --- tslib.es6.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tslib.es6.js b/tslib.es6.js index 8430b41..0b95d2e 100644 --- a/tslib.es6.js +++ b/tslib.es6.js @@ -21,6 +21,12 @@ export const __assign = Object.assign || function (t) { return t; }; +export const __extends = function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; + export const __decorate = function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); From b373b5852d85ce423445752426a0c209fb1630d4 Mon Sep 17 00:00:00 2001 From: Frank Wallis Date: Wed, 5 Oct 2016 20:48:03 +0100 Subject: [PATCH 4/6] Change const -> var to support es6 modules with es5 target for rollup --- tslib.es6.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tslib.es6.js b/tslib.es6.js index 0b95d2e..228cf44 100644 --- a/tslib.es6.js +++ b/tslib.es6.js @@ -13,7 +13,7 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ /* global Reflect, Promise */ -export const __assign = Object.assign || function (t) { +export var __assign = Object.assign || function (t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; @@ -21,28 +21,28 @@ export const __assign = Object.assign || function (t) { return t; }; -export const __extends = function (d, b) { +export var __extends = function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; -export const __decorate = function (decorators, target, key, desc) { +export var __decorate = function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; -export const __param = function (paramIndex, decorator) { +export var __param = function (paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } }; -export const __metadata = function (metadataKey, metadataValue) { +export var __metadata = function (metadataKey, metadataValue) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); }; -export const __awaiter = function (thisArg, _arguments, P, generator) { +export var __awaiter = function (thisArg, _arguments, P, generator) { return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } } @@ -51,7 +51,7 @@ export const __awaiter = function (thisArg, _arguments, P, generator) { }); }; -export const __generator = function (thisArg, body) { +export var __generator = function (thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t; return { next: verb(0), "throw": verb(1), "return": verb(2) }; function verb(n) { return function (v) { return step([n, v]); }; } From 0d1a7368fb5ddc8c98ef583a12b6abae1ba125e0 Mon Sep 17 00:00:00 2001 From: Frank Wallis Date: Wed, 5 Oct 2016 21:09:16 +0100 Subject: [PATCH 5/6] Fix ordering of functions --- tslib.es6.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tslib.es6.js b/tslib.es6.js index 228cf44..cf51ec2 100644 --- a/tslib.es6.js +++ b/tslib.es6.js @@ -13,6 +13,12 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ /* global Reflect, Promise */ +export var __extends = function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; + export var __assign = Object.assign || function (t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; @@ -21,12 +27,6 @@ export var __assign = Object.assign || function (t) { return t; }; -export var __extends = function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; - export var __decorate = function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); From ee86b0c27a6b8cd9a8149b20d0a7ceb0958e4287 Mon Sep 17 00:00:00 2001 From: frankwallis Date: Tue, 8 Nov 2016 09:30:07 +0000 Subject: [PATCH 6/6] add "module" field to package.json --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 0099653..cd6c4b1 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "url": "https://github.com/Microsoft/tslib.git" }, "main": "tslib.js", + "module": "tslib.es6.js", "jsnext:main": "tslib.es6.js", "typings": "tslib.d.ts" }