All files / near-membrane-base/src connector.ts

71.43% Statements 5/7
66.67% Branches 4/6
100% Functions 2/2
71.43% Lines 5/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22        4x         4x     4x       23x     23x    
import { TypeErrorCtor } from '@locker/near-membrane-shared';
import { createMembraneMarshall } from './membrane';
import type { Connector } from './types';
 
const createMembraneMarshallSourceInStrictMode = `
'use strict';
(${createMembraneMarshall})`;
 
export function createBlueConnector(globalObject: typeof globalThis): Connector {
    Iif (typeof globalObject !== 'object' || globalObject === null) {
        throw new TypeErrorCtor('Missing globalObject.');
    }
    return createMembraneMarshall(globalObject);
}
 
export function createRedConnector(evaluator: typeof eval): Connector {
    Iif (typeof evaluator !== 'function') {
        throw new TypeErrorCtor('Missing evaluator function.');
    }
    return evaluator(createMembraneMarshallSourceInStrictMode)() as Connector;
}