@stackmemoryai/stackmemory
Version:
Project-scoped memory for AI coding tools. Durable context across sessions with MCP integration, frames, smart retrieval, Claude Code skills, and automatic hooks.
34 lines (33 loc) • 1.19 kB
JavaScript
import { fileURLToPath as __fileURLToPath } from 'url';
import { dirname as __pathDirname } from 'path';
const __filename = __fileURLToPath(import.meta.url);
const __dirname = __pathDirname(__filename);
function filterPending(items, filters = {}, now = Date.now()) {
let out = [...items];
const { taskContains, olderThanMs, newerThanMs, sort, limit } = filters;
if (taskContains) {
const q = taskContains.toLowerCase();
out = out.filter((it) => (it.task || "").toLowerCase().includes(q));
}
if (typeof olderThanMs === "number") {
out = out.filter(
(it) => typeof it.createdAt === "number" && now - it.createdAt > olderThanMs
);
}
if (typeof newerThanMs === "number") {
out = out.filter(
(it) => typeof it.createdAt === "number" && now - it.createdAt < newerThanMs
);
}
const getTs = (t) => t === null ? Infinity : t;
if (sort === "asc")
out.sort((a, b) => getTs(a.createdAt) - getTs(b.createdAt));
if (sort === "desc")
out.sort((a, b) => getTs(b.createdAt) - getTs(a.createdAt));
if (typeof limit === "number") out = out.slice(0, limit);
return out;
}
export {
filterPending
};
//# sourceMappingURL=pending-utils.js.map