Skip to content

Commit

Permalink
add helpers for private-named instance fields
Browse files Browse the repository at this point in the history
  • Loading branch information
mgunter6 committed Sep 12, 2019
1 parent ec58992 commit 5c72ae8
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tslib.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ export declare function __asyncValues(o: any): any;
export declare function __makeTemplateObject(cooked: string[], raw: string[]): TemplateStringsArray;
export declare function __importStar<T>(mod: T): T;
export declare function __importDefault<T>(mod: T): T | { default: T };
export declare function __classPrivateFieldGet(receiver: any, privateMap: WeakMap<any, any>): any;
export declare function __classPrivateFieldSet(receiver: any, privateMap: WeakMap<any, any>, value: any): any;
15 changes: 15 additions & 0 deletions tslib.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,18 @@ export function __importStar(mod) {
export function __importDefault(mod) {
return (mod && mod.__esModule) ? mod : { default: mod };
}

export function __classPrivateFieldGet(receiver, privateMap) {
if (!privateMap.has(receiver)) {
throw new TypeError("attempted to get private field on non-instance");
}
return privateMap.get(receiver);
}

export function __classPrivateFieldSet(receiver, privateMap, value) {
if (!privateMap.has(receiver)) {
throw new TypeError("attempted to set private field on non-instance");
}
privateMap.set(receiver, value);
return value;
}
19 changes: 19 additions & 0 deletions tslib.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ var __asyncValues;
var __makeTemplateObject;
var __importStar;
var __importDefault;
var __classPrivateFieldGet;
var __classPrivateFieldSet;
(function (factory) {
var root = typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : {};
if (typeof define === "function" && define.amd) {
Expand Down Expand Up @@ -234,6 +236,21 @@ var __importDefault;
return (mod && mod.__esModule) ? mod : { "default": mod };
};

__classPrivateFieldGet = function (receiver, privateMap) {
if (!privateMap.has(receiver)) {
throw new TypeError("attempted to get private field on non-instance");
}
return privateMap.get(receiver);
};

__classPrivateFieldSet = function (receiver, privateMap, value) {
if (!privateMap.has(receiver)) {
throw new TypeError("attempted to set private field on non-instance");
}
privateMap.set(receiver, value);
return value;
}

exporter("__extends", __extends);
exporter("__assign", __assign);
exporter("__rest", __rest);
Expand All @@ -254,4 +271,6 @@ var __importDefault;
exporter("__makeTemplateObject", __makeTemplateObject);
exporter("__importStar", __importStar);
exporter("__importDefault", __importDefault);
exporter("__classPrivateFieldGet", __classPrivateFieldGet);
exporter("__classPrivateFieldSet", __classPrivateFieldSet);
});

0 comments on commit 5c72ae8

Please sign in to comment.