import { coercionInput, checkLevel } from './utils.js';
/** warp module */
export function createModule(options) {
    const { compressSync, compress, decompressSync, decompress, Compressor, Decompressor, TransformStream } = options;
    return {
        compressSync: (data, level) => {
            level = checkLevel(level);
            const input = coercionInput(data, false);
            const output = compressSync(input, level);
            return output;
        },
        compress: async (data, level) => {
            level = checkLevel(level);
            const input = coercionInput(data, true);
            const output = await compress(input, level);
            return output;
        },
        decompressSync: (data) => {
            const input = coercionInput(data, false);
            const output = decompressSync(input);
            return output;
        },
        decompress: async (data) => {
            const input = coercionInput(data, true);
            const output = await decompress(input);
            return output;
        },
        compressor: (level) => {
            level = checkLevel(level);
            const transformer = new TransformStream(new Compressor(level));
            return transformer;
        },
        decompressor: () => {
            const transformer = new TransformStream(new Decompressor());
            return transformer;
        },
    };
}
//# sourceMappingURL=common.js.map