@lokalise/api-common
Advanced tools
Comparing version 3.1.0 to 3.1.1
@@ -1,37 +0,37 @@ | ||
import { encodeCursor as i } from "./cursorCodec.js"; | ||
const r = (e, t) => { | ||
const o = {}; | ||
let n = 0; | ||
for (; n < t.length; ) | ||
t[n] in e && (o[t[n]] = e[t[n]]), n += 1; | ||
return o; | ||
import { encodeCursor as r } from "./cursorCodec.js"; | ||
const d = (t, n) => { | ||
const l = {}; | ||
let o = 0; | ||
for (; o < n.length; ) | ||
n[o] in t && (l[n[o]] = t[n[o]]), o += 1; | ||
return l; | ||
}; | ||
function f(e, t, o) { | ||
if (t !== void 0 && t.length === 0) | ||
function f(t, n, l) { | ||
if (n !== void 0 && n.length === 0) | ||
throw new Error("cursorKeys cannot be an empty array"); | ||
if (e.length === 0) | ||
if (t.length === 0) | ||
return { count: 0 }; | ||
const n = e[e.length - 1]; | ||
let l = ""; | ||
t ? l = t.length === 1 ? n[t[0]] : i(r(n, t)) : l = n.id; | ||
const h = o ? e.length > o : void 0; | ||
const o = l ? Math.min(t.length, l) - 1 : t.length - 1, e = t[o]; | ||
let h = ""; | ||
n ? h = n.length === 1 ? e[n[0]] : r(d(e, n)) : h = e.id; | ||
const i = l ? t.length > l : void 0; | ||
return { | ||
count: o ? Math.min(e.length, o) : e.length, | ||
cursor: l, | ||
hasMore: h | ||
count: l ? Math.min(t.length, l) : t.length, | ||
cursor: h, | ||
hasMore: i | ||
}; | ||
} | ||
async function s(e, t) { | ||
const o = []; | ||
let n; | ||
async function u(t, n) { | ||
const l = []; | ||
let o; | ||
do { | ||
const l = await t({ ...e, after: n }); | ||
o.push(...l.data), n = l.meta.cursor; | ||
} while (n); | ||
return o; | ||
const e = await n({ ...t, after: o }); | ||
l.push(...e.data), o = e.meta.cursor; | ||
} while (o); | ||
return l; | ||
} | ||
export { | ||
f as getMetaForNextPage, | ||
s as getPaginatedEntries | ||
u as getPaginatedEntries | ||
}; | ||
//# sourceMappingURL=paginationUtils.js.map |
{ | ||
"name": "@lokalise/api-common", | ||
"version": "3.1.0", | ||
"version": "3.1.1", | ||
"files": [ | ||
@@ -5,0 +5,0 @@ "dist" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
40173