-
Notifications
You must be signed in to change notification settings - Fork 439
Expand file tree
/
Copy pathsignals.ts
More file actions
27 lines (22 loc) · 771 Bytes
/
signals.ts
File metadata and controls
27 lines (22 loc) · 771 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*
* Copyright (c) 2024, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
import { isFalse } from './assert';
let trustedSignals: WeakSet<object>;
export function setTrustedSignalSet(signals: WeakSet<object>) {
isFalse(trustedSignals, 'Trusted Signal Set is already set!');
trustedSignals = signals;
}
export function addTrustedSignal(signal: object) {
// This should be a no-op when the trustedSignals set isn't set by runtime
trustedSignals?.add(signal);
}
export function isTrustedSignal(target: object): boolean {
if (!trustedSignals) {
return false;
}
return trustedSignals.has(target);
}