'use strict'

const Stream = require('./lib/Stream');

// factory
module.exports = (env, adapter) => {

    if (!adapter.read || !adapter.mod) {
        throw new Error('Flow: No "mod" or "read" methods on adapter.');
    }

    const scope = {
        env: env || {},
        mod: adapter.mod,
        read: adapter.read,

        // cache must have "get", "set" and "reset" methods
        cache: adapter.cache,

        // reset cache
        reset: () => {

            if (typeof adapter.reset === 'function') {
                adapter.reset();
            }

            adapter.cache.reset();
        }
    };

    return scope.flow = (event, options) => {
        return Stream(scope, event, options);
    };
};

"use strict"

// Polyfill for setImmediate, extends the global scope.
require("setimmediate");

const Stream = require("./lib/Stream");

module.exports = (env, adapter) => {

    if (!adapter.cache || !adapter.read || !adapter.mod) {
        throw new Error("Flow: Invalid adapter.");
    }

    const scope = {
        env: env || {},
        mod: adapter.mod,
        read: adapter.read,
        cache: adapter.cache,
        reset: () => {

            if (typeof adapter.reset === "function") {
                adapter.reset();
            }

            adapter.cache.reset();
        }
    };

    return scope.flow = (event, options) => {
        return Stream(scope, event, options);
    };
};

replace single quotes with double quotes