UNPKG

filepond

Version:

FilePond, where files go to stretch their bits.

73 lines (72 loc) • 1.49 kB
/*! * FilePond v5.0.2 * Copyright (c) 2017-2026 Pqina B.V. * Released under the MIT License * https://filepond.com */ import { isArray as s } from "./test.js"; function a(r, o, n = "entries") { r.forEach((t, i) => { o(t, i), s(t[n]) && a(t[n], o); }); } function p(r, o, n = "children") { r.forEach((t, i) => { if (o(t, i)) return t; s(t[n]) && p(t[n], o); }); } const e = (r, o, n = "entries") => { const t = []; for (const [i, c] of r.entries()) { if (!c) { t.push(c); continue; } const f = o(c, i, r); s(f[n]) && (f[n] = e(c[n], o, n)), t.push(f); } return t; }, h = async (r, o, n = "entries") => { const t = []; for (const [i, c] of r.entries()) { if (!c) { t.push(c); continue; } const f = await o(c, i, r); s(f[n]) && (f[n] = await h(c[n], o, n)), t.push(f); } return t; }, d = (r, o, n = "entries") => { const t = []; for (const i of r) { if (!o(i)) continue; const c = { ...i }; s(c[n]) && (c[n] = d(i[n], o, n)), t.push(c); } return t; }, u = (r, o = "entries") => { let n = []; for (const t of r) n = [...n, t], Array.isArray(t[o]) && n.push(...u(t[o], o)); return n; }, l = (r, o, n = "entries") => { r.sort(o); for (const t of r) { const i = t[n]; i && (t[n] = l(i, o, n)); } return r; }; export { a as eachTree, d as filterTree, p as findTree, u as flattenTree, e as mapTree, h as mapTreeAsync, l as sortTree };