Skip to content

Commit

Permalink
Merge pull request #157 from bloomberg/private-fields-in-in
Browse files Browse the repository at this point in the history
Add new private class element helper: __classPrivateFieldIn
  • Loading branch information
sandersn authored Sep 24, 2021
2 parents 251802e + c1fbc71 commit 481d352
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions modules/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const {
__importDefault,
__classPrivateFieldGet,
__classPrivateFieldSet,
__classPrivateFieldIn,
} = tslib;
export {
__extends,
Expand All @@ -50,4 +51,5 @@ export {
__importDefault,
__classPrivateFieldGet,
__classPrivateFieldSet,
__classPrivateFieldIn,
};
7 changes: 7 additions & 0 deletions tslib.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,11 @@ export declare function __classPrivateFieldSet<T extends new (...args: any[]) =>
kind: "a",
f: (v: V) => void
): V;
/**
* Checking the existence of a private field/method/accessor
*/
export declare function __classPrivateFieldIn(
state: (new (...args: any[]) => unknown) | { has(o: any): boolean },
receiver: unknown,
): boolean;
export declare function __createBinding(object: object, target: object, key: PropertyKey, objectKey?: PropertyKey): void;
5 changes: 5 additions & 0 deletions tslib.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,3 +237,8 @@ export function __classPrivateFieldSet(receiver, state, value, kind, f) {
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
}

export function __classPrivateFieldIn(state, receiver) {
if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object");
return typeof state === "function" ? receiver === state : state.has(receiver);
}
7 changes: 7 additions & 0 deletions tslib.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ var __importStar;
var __importDefault;
var __classPrivateFieldGet;
var __classPrivateFieldSet;
var __classPrivateFieldIn;
var __createBinding;
(function (factory) {
var root = typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : {};
Expand Down Expand Up @@ -279,6 +280,11 @@ var __createBinding;
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};

__classPrivateFieldIn = function (state, receiver) {
if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object");
return typeof state === "function" ? receiver === state : state.has(receiver);
};

exporter("__extends", __extends);
exporter("__assign", __assign);
exporter("__rest", __rest);
Expand All @@ -303,4 +309,5 @@ var __createBinding;
exporter("__importDefault", __importDefault);
exporter("__classPrivateFieldGet", __classPrivateFieldGet);
exporter("__classPrivateFieldSet", __classPrivateFieldSet);
exporter("__classPrivateFieldIn", __classPrivateFieldIn);
});

0 comments on commit 481d352

Please sign in to comment.