diff --git a/src/object-graph.ts b/src/object-graph.ts index c3441e4..f335df6 100644 --- a/src/object-graph.ts +++ b/src/object-graph.ts @@ -22,6 +22,14 @@ export class ObjectGraph> { } } + /** + * @description Returns the keys of the object graph. + * @since 0.1.0 + */ + public keys() { + return this.nodes.keys(); + } + /** * @description Returns the length of the object graph. * @since 0.1.0 diff --git a/tests/object-graph.test.ts b/tests/object-graph.test.ts index 622d564..d6a25bd 100644 --- a/tests/object-graph.test.ts +++ b/tests/object-graph.test.ts @@ -9,6 +9,14 @@ import { type Size, } from "../mocks/object-graph.mock"; +describe("keys", () => { + test("get the keys of the object graph", () => { + const shirtsObjectGraph = new ObjectGraph(shirtsMock, (shirt) => shirt.sku); + + expect(Array.from(shirtsObjectGraph.keys())).toEqual(["1", "2", "3", "4", "5", "6", "7", "8"]); + }); +}); + describe("length", () => { test("get the length of the object graph", () => { const shirtToAdd: Shirt = { sku: "9", color: "orange", size: "small" };