@radcliffetech/symbolos-core
Version:
Core symbolic simulation and execution engine for Symbolos
25 lines (24 loc) • 716 B
JavaScript
export const getSymbolicWorldStore = (world) => {
const artifacts = Array.from(world.artifacts.values());
return {
getByType(type) {
return artifacts.filter((o) => o.type === type);
},
getById(id) {
return world.artifacts.get(id);
},
getByIds(ids) {
return ids
.map((id) => world.artifacts.get(id))
.filter((o) => o !== undefined);
},
getLatestOfType(type) {
return artifacts
.filter((o) => o.type === type)
.sort((a, b) => (b.tick ?? 0) - (a.tick ?? 0))[0];
},
getAll() {
return artifacts;
},
};
};