crates/core/tests/snapshots/webpack4_unpack__module-6.snap

GitHub
---
source: crates/core/tests/webpack4_unpack.rs
expression: code
---
import { b, c as c_1, h as h_1, p as p_1, q, w } from "./module-0.js";
import { a as a_1 } from "./module-9.js";
import { a as a_2 } from "./module-12.js";
export const a = {
    type: "@@redux-saga/CHANNEL_END"
};
const l = (e)=>e && e.type === "@@redux-saga/CHANNEL_END";
function c() {
    const e = [];
    return {
        subscribe (t) {
            e.push(t);
            return ()=>w(e, t);
        },
        emit (t) {
            const n = e.slice();
            for(let r = 0, o = n.length; r < o; r++){
                n[r](t);
            }
        }
    };
}
const s = "invalid buffer passed to channel factory function";
const f = "Saga was provided with an undefined action";
function d(e = a_1.fixed()) {
    let t = false;
    let n = [];
    function i() {
        if (t && n.length) {
            throw p_1("Cannot have a closed channel with pending takers");
        }
        if (n.length && !e.isEmpty()) {
            throw p_1("Cannot have pending takers with non empty buffer");
        }
    }
    h_1(e, q.buffer, s);
    return {
        take (o) {
            i();
            h_1(o, q.func, "channel.take's callback must be a function");
            if (t && e.isEmpty()) {
                o(a);
            } else if (e.isEmpty()) {
                n.push(o);
                o.cancel = ()=>w(n, o);
            } else {
                o(e.take());
            }
        },
        put (o) {
            i();
            h_1(o, q.notUndef, f);
            if (!t) {
                if (!n.length) {
                    return e.put(o);
                }
                for(let a = 0; a < n.length; a++){
                    const u = n[a];
                    if (!u[b] || u[b](o)) {
                        n.splice(a, 1);
                        return u(o);
                    }
                }
            }
        },
        flush (n) {
            i();
            h_1(n, q.func, "channel.flush' callback must be a function");
            if (t && e.isEmpty()) {
                n(a);
            } else {
                n(e.flush());
            }
        },
        close () {
            i();
            if (!t && (t = true, n.length)) {
                const e = n;
                n = [];
                for(let r = 0, o = e.length; r < o; r++){
                    e[r](a);
                }
            }
        },
        get __takers__ () {
            return n;
        },
        get __closed__ () {
            return t;
        }
    };
}
function p(e, t = a_1.none(), n) {
    if (arguments.length > 2) {
        h_1(n, q.func, "Invalid match function passed to eventChannel");
    }
    const i = d(t);
    const a = ()=>{
        if (!i.__closed__) {
            if (u) {
                u();
            }
            i.close();
        }
    };
    var u = e((e)=>{
        if (l(e)) {
            a();
        } else if (!(n && !n(e))) {
            i.put(e);
        }
    });
    if (i.__closed__) {
        u();
    }
    if (!q.func(u)) {
        throw new Error("in eventChannel: subscribe should return a function to unsubscribe");
    }
    return {
        take: i.take,
        flush: i.flush,
        close: a
    };
}
function h(e) {
    const t = p((t)=>e((e)=>{
            if (e[c_1]) {
                t(e);
            } else {
                a_2(()=>t(e));
            }
        }));
    return {
        ...t,
        take (e, n) {
            if (arguments.length > 1) {
                h_1(n, q.func, "channel.take's matcher argument must be a function");
                e[b] = n;
            }
            t.take(e);
        }
    };
}
export { l as e };
export { c };
export { d as b };
export { p as d };
export { h as f };