Skip to content

Commit

Permalink
Define collectSeedReferences, which returns all seedReferences in a g…
Browse files Browse the repository at this point in the history
…iven ExpandedSeedData.

This will be useful for validation.

Part of #39.
  • Loading branch information
jkomoros committed Jul 6, 2023
1 parent 967c9f3 commit 0646458
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import {
nestedSeedDataObject,
SeedDataObject,
nestedSeedDataArray,
SeedDataArray
SeedDataArray,
seedReference
} from './types.js';

import {
Expand Down Expand Up @@ -98,6 +99,18 @@ export const expandSeedPacket = (packet : SeedPacket) : ExpandedSeedPacket => {
return result;
};

//TODO: unexport
export const collectSeedReferences = (data : ExpandedSeedData) : SeedReference[] => {
const result : SeedReference[] = [];
for (const value of Object.values(data)) {
const parsed = seedReference.safeParse(value);
if(parsed.success) {
result.push(parsed.data);
}
}
return result;
};

export class Seed<D extends ExpandedSeedData = ExpandedSeedData> {

_garden : Garden;
Expand Down

0 comments on commit 0646458

Please sign in to comment.