Skip to content

Commit

Permalink
Merge fa32322 into 7a9187f
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Jun 22, 2021
2 parents 7a9187f + fa32322 commit 6e168a8
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 43 deletions.
2 changes: 1 addition & 1 deletion packages/solid/src/reactive/mutable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function wrap<T extends StateNode>(value: T, name?: string): State<T> {
let p = value[$PROXY];
if (!p) {
Object.defineProperty(value, $PROXY, { value: (p = new Proxy(value, proxyTraps)) });
let keys = Object.keys(value),
const keys = Object.keys(value),
desc = Object.getOwnPropertyDescriptors(value);
for (let i = 0, l = keys.length; i < l; i++) {
const prop = keys[i];
Expand Down
4 changes: 2 additions & 2 deletions packages/solid/src/reactive/scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ function enqueue(taskQueue: Task[], task: Task) {
let n = taskQueue.length - 1;

while (m <= n) {
let k = (n + m) >> 1;
let cmp = task.expirationTime - taskQueue[k].expirationTime;
const k = (n + m) >> 1;
const cmp = task.expirationTime - taskQueue[k].expirationTime;
if (cmp > 0) m = k + 1;
else if (cmp < 0) n = k - 1;
else return k;
Expand Down
28 changes: 14 additions & 14 deletions packages/solid/src/reactive/signal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ export function createRoot<T>(fn: (dispose: () => void) => T, detachedOwner?: Ow
root: Owner =
fn.length === 0 && !"_SOLID_DEV_"
? UNOWNED
: { owned: null, cleanups: null, context: null, owner, attached: !!detachedOwner };
: { owned: null, cleanups: null, context: null, owner, attached: Boolean(detachedOwner) };

if ("_SOLID_DEV_" && owner) root.name = (owner as Computation<any>).name + "-r" + rootCount++;
if ("_SOLID_DEV_" && owner) root.name = `${(owner as Computation<any>).name}-r${rootCount++}`;
Owner = root;
Listener = null;
let result: T;
Expand Down Expand Up @@ -288,7 +288,7 @@ export function createResource<T, U>(
batch(() => {
set(() => v);
setLoading(false);
for (let c of contexts.keys()) c.decrement!();
for (const c of contexts.keys()) c.decrement!();
contexts.clear();
});
}
Expand All @@ -313,7 +313,7 @@ export function createResource<T, U>(
}
function load() {
setError((err = undefined));
let lookup = dynamic ? (source as () => U)() : (source as U);
const lookup = dynamic ? (source as () => U)() : (source as U);
loadedUnderTransition = (Transition && Transition.running) as boolean;
if (lookup == null || (lookup as any) === false) {
loadEnd(pr, untrack(s)!);
Expand Down Expand Up @@ -386,7 +386,7 @@ export function createSelector<T, U>(
fn: (a: U, b: T) => boolean = equalFn as any,
options?: { name?: string }
): (key: U) => boolean {
let subs = new Map<U, Set<Computation<any>>>();
const subs = new Map<U, Set<Computation<any>>>();
const node = createComputation(
(p: T | undefined) => {
const v = source();
Expand Down Expand Up @@ -476,7 +476,7 @@ export function on<T extends (() => any) | (() => any)[], U>(
fn: (values: ReturnTypes<T>, prev: ReturnTypes<T>, prevResults?: U) => U,
options?: { defer?: boolean }
): (prev?: U) => U | undefined {
let isArray = Array.isArray(deps);
const isArray = Array.isArray(deps);
let prev: ReturnTypes<T>;
let defer = options && options.defer;
return prevResult => {
Expand Down Expand Up @@ -585,8 +585,8 @@ export function devComponent<T>(Comp: (props: T) => JSX.Element, props: T) {
export function hashValue(v: any): string {
const s = new Set();
return (
"s" +
(typeof v === "string"
`s${
typeof v === "string"
? hash(v)
: hash(
JSON.stringify(v, (k, v) => {
Expand All @@ -596,7 +596,7 @@ export function hashValue(v: any): string {
}
return v;
}) || ""
))
)}`
);
}

Expand All @@ -605,7 +605,7 @@ export function registerGraph(name: string, value: { value: unknown }): string {
if (Owner) {
let i = 0;
Owner.sourceMap || (Owner.sourceMap = {});
while (Owner.sourceMap[tryName]) tryName = name + "-" + ++i;
while (Owner.sourceMap[tryName]) tryName = `${name}-${++i}`;
Owner.sourceMap[tryName] = value;
}
return tryName;
Expand Down Expand Up @@ -804,9 +804,9 @@ function createComputation<T>(
if ("_SOLID_DEV_")
c.name =
(options && options.name) ||
((Owner as Computation<any>).name || "c") +
"-" +
(Owner.owned || (Owner as Memo<T>).tOwned!).length;
`${(Owner as Computation<any>).name || "c"}-${
(Owner.owned || (Owner as Memo<T>).tOwned!).length
}`;
}
return c;
}
Expand Down Expand Up @@ -1009,7 +1009,7 @@ function resolveChildren(children: any): unknown {
if (Array.isArray(children)) {
const results: any[] = [];
for (let i = 0; i < children.length; i++) {
let result = resolveChildren(children[i]);
const result = resolveChildren(children[i]);
Array.isArray(result) ? results.push.apply(results, result) : results.push(result);
}
return results;
Expand Down
4 changes: 2 additions & 2 deletions packages/solid/src/reactive/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function wrap<T extends StateNode>(value: T, name?: string): State<T> {
let p = value[$PROXY];
if (!p) {
Object.defineProperty(value, $PROXY, { value: (p = new Proxy(value, proxyTraps)) });
let keys = Object.keys(value),
const keys = Object.keys(value),
desc = Object.getOwnPropertyDescriptors(value);
for (let i = 0, l = keys.length; i < l; i++) {
const prop = keys[i];
Expand Down Expand Up @@ -86,7 +86,7 @@ export function unwrap<T extends StateNode>(item: any, set = new Set()): T {
} else {
if (Object.isFrozen(item)) item = Object.assign({}, item);
else set.add(item);
let keys = Object.keys(item),
const keys = Object.keys(item),
desc = Object.getOwnPropertyDescriptors(item);
for (let i = 0, l = keys.length; i < l; i++) {
prop = keys[i];
Expand Down
2 changes: 1 addition & 1 deletion packages/solid/src/reactive/stateModifiers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function applyState(
merge: boolean | undefined,
key: string | null
) {
let previous = parent[property];
const previous = parent[property];
if (target === previous) return;
if (!isWrappable(target) || !isWrappable(previous) || (key && target[key] !== previous[key])) {
target !== previous && setProperty(parent, property, target);
Expand Down
6 changes: 3 additions & 3 deletions packages/solid/src/static/reactive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ export function on<T, U>(
fn: (value: Array<T> | T, prev?: Array<T> | T, prevResults?: U) => U,
options: { defer?: boolean } = {}
): (prev?: U) => U | undefined {
let isArray = Array.isArray(deps);
let defer = options.defer;
const isArray = Array.isArray(deps);
const defer = options.defer;
return () => {
if (defer) return undefined;
let value: Array<T> | T;
Expand Down Expand Up @@ -151,7 +151,7 @@ function resolveChildren(children: any): unknown {
if (Array.isArray(children)) {
const results: any[] = [];
for (let i = 0; i < children.length; i++) {
let result = resolveChildren(children[i]);
const result = resolveChildren(children[i]);
Array.isArray(result) ? results.push.apply(results, result) : results.push(result);
}
return results;
Expand Down
4 changes: 2 additions & 2 deletions packages/solid/src/static/rendering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ export function lazy(fn: () => Promise<{ default: any }>): (props: any) => strin
}

function suspenseComplete(c: SuspenseContextType) {
for (let r of c.resources.values()) {
for (const r of c.resources.values()) {
if (r.loading) return false;
}
return true;
Expand Down Expand Up @@ -440,7 +440,7 @@ export function Suspense(props: { fallback: string; children: string }) {
return sharedConfig.context!.async ? { t: `<#${id}#>` } : props.fallback;
}

const SUSPENSE_REPLACE = /<#([0-9\.]+)\#>/;
const SUSPENSE_REPLACE = /<#([\d.]+)#>/;
export function awaitSuspense(fn: () => any) {
return new Promise(resolve => {
const registry = new Set<string>();
Expand Down
20 changes: 10 additions & 10 deletions packages/solid/test/signals.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe("Create signals", () => {
});
test("Create and read a Memo with initial value", () => {
createRoot(() => {
const memo = createMemo(i => i + " John", "Hello");
const memo = createMemo(i => `${i} John`, "Hello");
expect(memo()).toBe("Hello John");
});
});
Expand All @@ -51,7 +51,7 @@ describe("Create signals", () => {
createRoot(() => {
let temp: string;
const [sign] = createSignal("thoughts");
createComputed(on(sign, v => (temp = "impure " + v)));
createComputed(on(sign, v => (temp = `impure ${v}`)));
expect(temp!).toBe("impure thoughts");
});
});
Expand All @@ -60,15 +60,15 @@ describe("Create signals", () => {
let temp: string;
const [sign] = createSignal("thoughts");
const [num] = createSignal(3);
createComputed(on([sign, num], v => (temp = "impure " + v[1])));
createComputed(on([sign, num], v => (temp = `impure ${v[1]}`)));
expect(temp!).toBe("impure 3");
});
});
test("Create a Computed with explicit deps and lazy evaluation", () => {
createRoot(() => {
let temp: string;
const [sign, set] = createSignal("thoughts");
createComputed(on(sign, v => (temp = "impure " + v), { defer: true }));
createComputed(on(sign, v => (temp = `impure ${v}`), { defer: true }));
expect(temp!).toBeUndefined();
set("minds");
expect(temp!).toBe("impure minds");
Expand Down Expand Up @@ -100,7 +100,7 @@ describe("Update signals", () => {
test("Create and trigger a Memo", () => {
createRoot(() => {
const [name, setName] = createSignal("John"),
memo = createMemo(() => "Hello " + name());
memo = createMemo(() => `Hello ${name()}`);
expect(memo()).toBe("Hello John");
setName("Jake");
expect(memo()).toBe("Hello Jake");
Expand All @@ -110,8 +110,8 @@ describe("Update signals", () => {
createRoot(() => {
let temp: string;
const [name, setName] = createSignal("John"),
memo = createMemo(() => "Hello " + name());
createEffect(() => (temp = memo() + "!!!"));
memo = createMemo(() => `Hello ${name()}`);
createEffect(() => (temp = `${memo()}!!!`));
setTimeout(() => {
expect(temp).toBe("Hello John!!!");
setName("Jake");
Expand All @@ -124,7 +124,7 @@ describe("Update signals", () => {
createRoot(() => {
let temp: string;
const [sign, setSign] = createSignal("thoughts");
createEffect(() => (temp = "unpure " + sign()));
createEffect(() => (temp = `unpure ${sign()}`));
setTimeout(() => {
expect(temp).toBe("unpure thoughts");
setSign("mind");
Expand All @@ -151,7 +151,7 @@ describe("Untrack signals", () => {
createRoot(() => {
let temp: string;
const [sign, setSign] = createSignal("thoughts");
createEffect(() => (temp = "unpure " + untrack(sign)));
createEffect(() => (temp = `unpure ${untrack(sign)}`));
setTimeout(() => {
expect(temp).toBe("unpure thoughts");
setSign("mind");
Expand Down Expand Up @@ -240,7 +240,7 @@ describe("Batch signals", () => {
expect(count).toBe(2);
done();
});
})
});
});
});
test("Handles errors gracefully", done => {
Expand Down
2 changes: 1 addition & 1 deletion packages/solid/test/state.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ describe("Array setState modes", () => {
const [state, setState] = createState({ rows: [1, 2, 3, 4, 5] });
setState(
"rows",
(r, i) => !!(i % 2),
(r, i) => Boolean(i % 2),
r => r * 2
);
expect(state.rows[0]).toBe(1);
Expand Down
2 changes: 1 addition & 1 deletion packages/solid/web/test/for.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ describe("Testing an multi child each control flow", () => {

function apply(array: string[]) {
setList(array);
expect(div.innerHTML).toBe(array.join("") + "z");
expect(div.innerHTML).toBe(`${array.join("")}z`);
setList([n1, n2, n3, n4]);
expect(div.innerHTML).toBe("abcdz");
}
Expand Down
2 changes: 1 addition & 1 deletion packages/solid/web/test/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ describe("Testing an multi child each control flow", () => {

function apply(array: string[]) {
setList(array);
expect(div.innerHTML).toBe(array.join("") + "z");
expect(div.innerHTML).toBe(`${array.join("")}z`);
setList([n1, n2, n3, n4]);
expect(div.innerHTML).toBe("abcdz");
}
Expand Down
10 changes: 5 additions & 5 deletions packages/solid/web/test/switch.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe("Testing a single match switch control flow", () => {
const Component = () => (
<div ref={div}>
<Switch fallback={"fallback"}>
<Match when={!!count() && count() < 2}>1</Match>
<Match when={Boolean(count()) && count() < 2}>1</Match>
</Switch>
</div>
);
Expand Down Expand Up @@ -38,9 +38,9 @@ describe("Testing an only child Switch control flow", () => {
const Component = () => (
<div ref={div}>
<Switch fallback={"fallback"}>
<Match when={!!count() && count() < 2}>1</Match>
<Match when={!!count() && count() < 5}>2</Match>
<Match when={!!count() && count() < 8}>3</Match>
<Match when={Boolean(count()) && count() < 2}>1</Match>
<Match when={Boolean(count()) && count() < 5}>2</Match>
<Match when={Boolean(count()) && count() < 8}>3</Match>
</Switch>
</div>
);
Expand Down Expand Up @@ -160,7 +160,7 @@ describe("Test top level switch control flow", () => {
const [count, setCount] = createSignal(0);
const Component = () => (
<Switch fallback={"fallback"}>
<Match when={!!count() && count() < 2}>1</Match>
<Match when={Boolean(count()) && count() < 2}>1</Match>
</Switch>
);

Expand Down

0 comments on commit 6e168a8

Please sign in to comment.