MCPcopy
hub / github.com/tensorflow/tfjs / get

Function get

tfjs-core/src/test_async_backends.ts:49–67  ·  view source on GitHub ↗
(target, name, receiver)

Source from the content-addressed store, hash-verified

47const backend: KernelBackend = engine().findBackend('cpu');
48const proxyBackend = new Proxy(asyncBackend, {
49 get(target, name, receiver) {
50 if (name === 'readSync') {
51 throw new Error(
52 `Found dataSync() in a unit test. This is disabled so unit tests ` +
53 `can run in backends that only support async data. Please use ` +
54 `.data() in unit tests or if you truly are testing dataSync(), ` +
55 `constrain your test with SYNC_BACKEND_ENVS`);
56 }
57 //@ts-ignore;
58 const origSymbol = backend[name];
59 if (typeof origSymbol === 'function') {
60 // tslint:disable-next-line:no-any
61 return (...args: any[]) => {
62 return origSymbol.apply(backend, args);
63 };
64 } else {
65 return origSymbol;
66 }
67 }
68});
69
70const proxyBackendName = 'test-async-cpu';

Callers

nothing calls this directly

Calls 1

applyMethod · 0.45

Tested by

no test coverage detected