From f3120e888e732e4f029a969c7344aede417d1bb0 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 10 Nov 2016 10:08:31 -0800 Subject: [PATCH 1/3] Add __rest helper --- tslib.d.ts | 3 ++- tslib.js | 11 ++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/tslib.d.ts b/tslib.d.ts index 20221da..774e68b 100644 --- a/tslib.d.ts +++ b/tslib.d.ts @@ -14,8 +14,9 @@ and limitations under the License. ***************************************************************************** */ export declare function __extends(d: Function, b: Function): void; export declare function __assign(t: any, ...sources: any[]): any; +export declare function __rest(t: any, propertyNames: string[]): any; export declare function __decorate(decorators: Function[], target: any, key?: string | symbol, desc?: any): any; export declare function __param(paramIndex: number, decorator: Function): Function; export declare function __metadata(metadataKey: any, metadataValue: any): Function; export declare function __awaiter(thisArg: any, _arguments: any, P: Function, generator: Function): any; -export declare function __generator(thisArg: any, body: Function): any; \ No newline at end of file +export declare function __generator(thisArg: any, body: Function): any; diff --git a/tslib.js b/tslib.js index 4423782..7a89622 100644 --- a/tslib.js +++ b/tslib.js @@ -15,6 +15,7 @@ and limitations under the License. /* global global, define, System, Reflect, Promise */ var __extends; var __assign; +var __rest; var __decorate; var __param; var __metadata; @@ -57,6 +58,13 @@ var __generator; return t; }; + __rest = (this && this.__rest) || function (s, e) { + var t = {}; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && !e.indexOf(p)) + t[p] = s[p]; + return t; + };; + __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); @@ -111,9 +119,10 @@ var __generator; exporter("__extends", __extends); exporter("__assign", __assign); + exporter("__rest", __rest); exporter("__decorate", __decorate); exporter("__param", __param); exporter("__metadata", __metadata); exporter("__awaiter", __awaiter); exporter("__generator", __generator); -}); \ No newline at end of file +}); From 177a35e4420d52f631655178cca9094a390be2fe Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Fri, 11 Nov 2016 08:33:01 -0800 Subject: [PATCH 2/3] Address PR comments. 1. Clean up __rest definition 2. Add __rest to tslib.es6.js --- tslib.es6.js | 9 ++++++++- tslib.js | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/tslib.es6.js b/tslib.es6.js index f9d7325..5773973 100644 --- a/tslib.es6.js +++ b/tslib.es6.js @@ -21,6 +21,13 @@ export const __assign = Object.assign || function (t) { return t; }; +export const __rest = function (s, e) { + var t = {}; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && !e.indexOf(p)) + t[p] = s[p]; + return t; +}; + 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); @@ -43,4 +50,4 @@ 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()); }); -}; \ No newline at end of file +}; diff --git a/tslib.js b/tslib.js index 7a89622..0712664 100644 --- a/tslib.js +++ b/tslib.js @@ -58,12 +58,12 @@ var __generator; return t; }; - __rest = (this && this.__rest) || function (s, e) { + __rest = function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && !e.indexOf(p)) t[p] = s[p]; return t; - };; + }; __decorate = function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; From 3e929fa5e950f1725c6c3ac2b6ee564d324bfb55 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 16 Nov 2016 09:59:59 -0800 Subject: [PATCH 3/3] Update __rest emit to handle symbols --- tslib.es6.js | 5 ++++- tslib.js | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tslib.es6.js b/tslib.es6.js index 5773973..87717cb 100644 --- a/tslib.es6.js +++ b/tslib.es6.js @@ -23,8 +23,11 @@ export const __assign = Object.assign || function (t) { export const __rest = function (s, e) { var t = {}; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && !e.indexOf(p)) + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; + if (typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) + t[p[i]] = s[p[i]]; return t; }; diff --git a/tslib.js b/tslib.js index 0712664..b3556c3 100644 --- a/tslib.js +++ b/tslib.js @@ -60,8 +60,11 @@ var __generator; __rest = function (s, e) { var t = {}; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && !e.indexOf(p)) + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; + if (typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) + t[p[i]] = s[p[i]]; return t; };