···2525 }
26262727 expect<T>(key: NodeDataKey<T>): T {
2828- let val = this._map.get(key.symbol);
2828+ const val = this._map.get(key.symbol);
2929 if (val !== undefined) {
3030 return val as T;
3131 } else if (key.defaultValue !== undefined) {
···72727373 get children(): Iterable<Node> {
7474 if (this._sortFn) {
7575- let fn = this._sortFn;
7676- let indexed = [...this._children].map((c, i) => [c, i] as const);
7575+ const fn = this._sortFn;
7676+ const indexed = [...this._children].map((c, i) => [c, i] as const);
7777 indexed.sort(([a, ai], [b, bi]) => {
7878- let result = fn(a, b);
7878+ const result = fn(a, b);
7979 if (result !== 0) {
8080 return result;
8181 } else {
···9393 }
94949595 *eval<T>(op: () => Operation<T>): Operation<Result<T>> {
9696- let resolver = withResolvers<Result<T>>();
9696+ const resolver = withResolvers<Result<T>>();
9797 yield* this._channel.send({
9898 resolve: resolver.resolve as (result: Result<unknown>) => void,
9999 operation: op as () => Operation<unknown>,
···109109export function* spawnEvalLoop(
110110 channel: Channel<CallEval, never>,
111111): Operation<void> {
112112- let ready = withResolvers<void>();
112112+ const ready = withResolvers<void>();
113113114114 yield* spawn(function* () {
115115- let sub = yield* channel as Stream<CallEval, never>;
115115+ const sub = yield* channel as Stream<CallEval, never>;
116116 ready.resolve();
117117118118 while (true) {
119119- let next = yield* sub.next();
119119+ const next = yield* sub.next();
120120 if (next.done) {
121121 break;
122122 }
123123- let call = next.value;
124124- let result = yield* box(call.operation);
123123+ const call = next.value;
124124+ const result = yield* box(call.operation);
125125 call.resolve(result);
126126 }
127127 });
+10-10
packages/freedom/src/lib/tree.ts
···14141515export function useTree(root: Component): Operation<Tree> {
1616 return resource<Tree>(function* (provide) {
1717- let output = createSignal<void, never>();
1818- let events = createSignal<unknown, void>();
1717+ const output = createSignal<void, never>();
1818+ const events = createSignal<unknown, void>();
19192020 let counter = 0;
2121- let state: TreeState = {
2121+ const state: TreeState = {
2222 dirty: false,
2323 output,
2424 events,
···33333434 yield* TreeContext.set(state);
35353636- let rootNode = new NodeImpl(state.nextId(), "", undefined);
3636+ const rootNode = new NodeImpl(state.nextId(), "", undefined);
3737 rootNode.remove = () => FreedomApi.operations.remove(rootNode);
3838 state.nodes.set(rootNode.id, rootNode);
39394040- let ready = withResolvers<void>();
4040+ const ready = withResolvers<void>();
41414242 // Spawn root node scope
4343 yield* spawn(function* () {
···5858 state.markDirty();
5959 },
6060 *append(args, next) {
6161- let node = yield* next(...args);
6161+ const node = yield* next(...args);
6262 state.markDirty();
6363 return node;
6464 },
···7575 yield* spawnEvalLoop(rootNode._channel);
76767777 // Subscribe to events, then spawn the event loop
7878- let sub = yield* events;
7878+ const sub = yield* events;
7979 yield* spawn(function* () {
8080 while (true) {
8181- let next = yield* sub.next();
8181+ const next = yield* sub.next();
8282 if (next.done) {
8383 break;
8484 }
8585- let event = next.value;
8585+ const event = next.value;
8686 state.dirty = false;
8787 yield* rootNode.eval(() => DispatchApi.operations.dispatch(event));
8888 if (state.dirty) {
···9999100100 yield* ready.operation;
101101102102- let tree: Tree = {
102102+ const tree: Tree = {
103103 dispatch(event: unknown) {
104104 events.send(event);
105105 },
+2-2
packages/freedom/src/lib/validate.ts
···4040 throw new Error("RegExp instances are not valid JsonValues");
4141 }
4242 if (Array.isArray(value)) {
4343- for (let item of value) {
4343+ for (const item of value) {
4444 validateJsonValue(item);
4545 }
4646 return;
4747 }
4848 if (typeof value === "object" && value !== null) {
4949- for (let key of Object.keys(value)) {
4949+ for (const key of Object.keys(value)) {
5050 validateJsonValue((value as Record<string, unknown>)[key]);
5151 }
5252 return;