Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
function XG(n, l, t) {
return Qa(fu([Sc, t])),
KG(l) || BG(n, l, pS) ? Array.isArray(t) || Nu(t) && !Mu(t) ? Tt.h(bu(t), 2) && BG(n, qt(t), $h) ? (Qa(fu([lw, "probably lookup ref", Wa.w(fu([new os(null, 5, ["vs", t, "(type vs)", Yn(t), "(count vs)", bu(t), "(first vs)", qt(t), "(is-attr? db (first vs) :db.unique/identity)", BG(n, qt(t), $h)], null)]))])),
new Ri(null, 1, 5, _i, [t], null)) : (Qa(fu([Lk])),
t) : (Qa(fu([xh, "not a collection at all, so definitely a single value", Wa.w(fu([new os(null, 6, ["vs", t, "(type vs)", Yn(t), "(arrays/array? vs)", Array.isArray(t), "(coll? vs)", Nu(t), "(vector? vs)", Hu(t), "(map? vs)", Mu(t)], null)]))])),
Qa(fu([Yo, "(satisfies? ICollection x)", null != t ? !!(8 & t.A || Rn === t.vg) || !t.A && Wn(ol, t) : Wn(ol, t)])),
new Ri(null, 1, 5, _i, [t], null)) : (Qa(fu([Fb, "not a multival context", new os(null, 4, ["a", l, "(type a)", Yn(l), "(reverse-ref? a)", KG(l), "(multival? db a)", BG(n, l, pS)], null)])),
new Ri(null, 1, 5, _i, [t], null))
}
function gS(a, b, c) {
yk(D([tm, c]));
if (bS(b) || SR(a, b, kF)) {
if (Array.isArray(c) || ff(c) && !jf(c)) {
if (A.h(I(c), 2) && SR(a, F(c), Tn)) return yk(D([Wo, "probably lookup ref", tk.w(D([new k(null, 5, ["vs", c, "(type vs)", oc(c), "(count vs)", I(c), "(first vs)", F(c), "(is-attr? db (first vs) :db.unique/identity)", SR(a, F(c), Tn)], null)]))])), new P(null, 1, 5, Q, [c], null);
yk(D([Fz]));
return c
}
yk(D([sn, "not a collection at all, so definitely a single value", tk.w(D([new k(null, 6, ["vs", c, "(type vs)", oc(c), "(arrays/array? vs)", Array.isArray(c),
"(coll? vs)", ff(c), "(vector? vs)", lf(c), "(map? vs)", jf(c)
], null)]))]));
yk(D([Ml, "(satisfies? ICollection x)", null != c ? c.A & 8 || h === c.vg ? !0 : c.A ? !1 : mc(Ec, c) : mc(Ec, c)]));
return new P(null, 1, 5, Q, [c], null)
}
yk(D([Cv, "not a multival context", new k(null, 4, ["a", b, "(type a)", oc(b), "(reverse-ref? a)", bS(b), "(multival? db a)", SR(a, b, kF)], null)]));
return new P(null, 1, 5, Q, [c], null)
}
(defn- maybe-wrap-multival [db a vs]
(println ::maybe-wrap-multival.arg.vs vs)
(cond
;; not a multival context
(not (or (reverse-ref? a)
(multival? db a)))
(do (println ::maybe-wrap-multival.a
"not a multival context"
{"a" a
"(type a)" (type a)
"(reverse-ref? a)" (reverse-ref? a)
"(multival? db a)" (multival? db a)})
[vs])
;; not a collection at all, so definitely a single value
(not (or (arrays/array? vs)
(and (coll? vs) (not (map? vs)))))
(do (println ::maybe-wrap-multival.b
"not a collection at all, so definitely a single value"
(pr-str {"vs" vs
"(type vs)" (type vs)
"(arrays/array? vs)" (arrays/array? vs)
"(coll? vs)" (coll? vs)
"(map? vs)" (map? vs)}))
#?(:cljs (println ::maybe-wrap-multival "(satisfies? ICollection vs)" (satisfies? ICollection vs)))
[vs])
;; probably lookup ref
(and (= (count vs) 2)
(is-attr? db (first vs) :db.unique/identity))
(do (println ::maybe-wrap-multival.c
"probably lookup ref"
(pr-str {"vs" vs
"(type vs)" (type vs)
"(count vs)" (count vs)
"(first vs)" (first vs)
"(is-attr? db (first vs) :db.unique/identity)" (is-attr? db (first vs) :db.unique/identity)}))
[vs])
:else (do (println ::maybe-wrap-multival.d) vs)))
:datascript.db/maybe-wrap-multival.arg.vs
[{:sighting/id 123}]
:datascript.db/maybe-wrap-multival.b
not a collection at all, so definitely a single value
{"vs" [{:sighting/id 123}],
"(type vs)" #object[_i],
"(arrays/array? vs)" false,
"(coll? vs)" false,
"(map? vs)" false}
:datascript.db/maybe-wrap-multival
(satisfies? ICollection vs) true
datascript.db.maybe_wrap_multival = function(a, b, c) {
cljs.core.println.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([cljs.core.cst$kw$datascript$db_SLASH_maybe_DASH_wrap_DASH_multival$arg$vs, c], 0));
if (datascript.db.reverse_ref_QMARK_(b) || datascript.db.multival_QMARK_(a, b)) {
if (me.tonsky.persistent_sorted_set.arrays.array_QMARK_(c) || cljs.core.coll_QMARK_(c) && !cljs.core.map_QMARK_(c)) {
if (cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(cljs.core.count(c), 2) && datascript.db.is_attr_QMARK_(a, cljs.core.first(c), cljs.core.cst$kw$db$unique_SLASH_identity)) {
return cljs.core.println.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([cljs.core.cst$kw$datascript$db_SLASH_maybe_DASH_wrap_DASH_multival$c, "probably lookup ref", cljs.core.pr_str.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([new cljs.core.PersistentArrayMap(null, 5, ["vs", c, "(type vs)", cljs.core.type(c), "(count vs)", cljs.core.count(c), "(first vs)", cljs.core.first(c), "(is-attr? db (first vs) :db.unique/identity)",
datascript.db.is_attr_QMARK_(a, cljs.core.first(c), cljs.core.cst$kw$db$unique_SLASH_identity)
], null)], 0))], 0)), new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [c], null);
}
cljs.core.println.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([cljs.core.cst$kw$datascript$db_SLASH_maybe_DASH_wrap_DASH_multival$d], 0));
return c;
}
cljs.core.println.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([cljs.core.cst$kw$datascript$db_SLASH_maybe_DASH_wrap_DASH_multival$b, "not a collection at all, so definitely a single value", cljs.core.pr_str.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([new cljs.core.PersistentArrayMap(null, 6, [
"vs", c,
"(type vs)", cljs.core.type(c),
"(arrays/array? vs)", me.tonsky.persistent_sorted_set.arrays.array_QMARK_(c),
"(coll? vs)", cljs.core.coll_QMARK_(c),
"(vector? vs)", cljs.core.vector_QMARK_(c),
"(map? vs)", cljs.core.map_QMARK_(c)
], null)], 0))], 0));
cljs.core.println.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(
[cljs.core.cst$kw$datascript$db_SLASH_maybe_DASH_wrap_DASH_multival,
"(satisfies? ICollection x)", null != c ? c.cljs$lang$protocol_mask$partition0$ & 8 || cljs.core.PROTOCOL_SENTINEL === c.cljs$core$ICollection$ ? !0 : c.cljs$lang$protocol_mask$partition0$ ? !1 : cljs.core.native_satisfies_QMARK_(cljs.core.ICollection, c) : cljs.core.native_satisfies_QMARK_(cljs.core.ICollection, c)
], 0));
return new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [c], null);
}
cljs.core.println.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([cljs.core.cst$kw$datascript$db_SLASH_maybe_DASH_wrap_DASH_multival$a, "not a multival context", new cljs.core.PersistentArrayMap(null, 4, ["a", b, "(type a)", cljs.core.type(b), "(reverse-ref? a)", datascript.db.reverse_ref_QMARK_(b), "(multival? db a)", datascript.db.multival_QMARK_(a, b)], null)], 0));
return new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [c], null);
};
@olivergeorge
Copy link
Author

olivergeorge commented Nov 21, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment