UNPKG

@commodo/fields-storage

Version:

We're working hard to get all the docs in order. New articles will be added daily.

46 lines (35 loc) 917 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.decodeCursor = exports.encodeCursor = void 0; const encodeCursor = cursor => { if (!cursor) { return null; } return Buffer.from(JSON.stringify(cursor)).toString("base64"); }; exports.encodeCursor = encodeCursor; const decodeCursor = cursor => { if (!cursor) { return null; } const value = JSON.parse(Buffer.from(cursor, "base64").toString("ascii")); if (value && typeof value === "object") { for (let key in value) { if (typeof key !== "string") { continue; } const possibleDate = new Date(value[key]); try { if (possibleDate.toISOString() === value[key]) { value[key] = possibleDate; } } catch (_unused) {// Do nothing. } } } return value; }; exports.decodeCursor = decodeCursor; //# sourceMappingURL=cursor.js.map