MCPcopy Create free account
hub / github.com/dailydotdev/apps / engineTable

Function engineTable

packages/webapp/__tests__/world/worldKitContract.test.ts:57–82  ·  view source on GitHub ↗
(name: string)

Source from the content-addressed store, hash-verified

55 * the renderer to read them.
56 */
57const engineTable = <T>(name: string): Record<string, T> => {
58 const start = engineSource.indexOf(`const ${name}={`);
59 expect(start).toBeGreaterThan(-1);
60
61 const open = engineSource.indexOf('{', start);
62 let depth = 0;
63 let end = open;
64 for (; end < engineSource.length; end += 1) {
65 if (engineSource[end] === '{') {
66 depth += 1;
67 }
68 if (engineSource[end] === '}') {
69 depth -= 1;
70 if (!depth) {
71 break;
72 }
73 }
74 }
75
76 const json = engineSource
77 .slice(open, end + 1)
78 .replace(/([{,]\s*)([A-Za-z_]\w*)\s*:/g, '$1"$2":')
79 .replace(/,(\s*[}\]])/g, '$1');
80
81 return JSON.parse(json) as Record<string, T>;
82};
83
84describe('world authoring contract', () => {
85 it('grants the same families on both sides', () => {

Callers 1

Calls 1

replaceMethod · 0.80

Tested by

no test coverage detected