Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
Signed-off-by: Eric Tucker <[email protected]>
  • Loading branch information
Eric Tucker authored and Tucker-Eric committed Jun 8, 2024
1 parent b2becb3 commit 134bf2a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/opa.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,13 +270,15 @@ function _preparePolicy(env, wasm, memory) {
async function _loadPolicy(policyWasm, memory, customBuiltins) {
const env = {};

const isStreaming = policyWasm instanceof Response || policyWasm instanceof Promise;
const isStreaming = policyWasm instanceof Response ||
policyWasm instanceof Promise;

const importObject = _importObject(env, memory, customBuiltins);

const wasm = await (isStreaming
? WebAssembly.instantiateStreaming(policyWasm, importObject)
: WebAssembly.instantiate(policyWasm, importObject));
const wasm =
await (isStreaming
? WebAssembly.instantiateStreaming(policyWasm, importObject)
: WebAssembly.instantiate(policyWasm, importObject));

return _preparePolicy(env, wasm, memory);
}
Expand Down
4 changes: 3 additions & 1 deletion test/browser-integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ test("loadPolicy should allow for a response object that resolves to a fetched w
const result = await page.evaluate(async function () {
// NOTE: Paths are evaluated relative to the project root.
const { default: opa } = await import("/dist/opa-wasm-browser.esm.js");
const policy = await opa.loadPolicy(fetch("/test/fixtures/multiple-entrypoints/policy.wasm"));
const policy = await opa.loadPolicy(
fetch("/test/fixtures/multiple-entrypoints/policy.wasm"),
);
return policy.evaluate({}, "example/one");
});
expect(result).toEqual([
Expand Down

0 comments on commit 134bf2a

Please sign in to comment.