Skip to content

Commit a72919e

Browse files
committed
Move assert to shared/utils
1 parent bd82bab commit a72919e

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

.changeset/silent-onions-invite.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@solid-devtools/shared": patch
3+
"@solid-devtools/extension": patch
4+
---
5+
6+
Move assert to shared/utils

extension/src/background.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ It has to coordinate the communication between the different scripts based on th
66
77
*/
88

9-
import {error, log} from '@solid-devtools/shared/utils'
9+
import {assert, error, log} from '@solid-devtools/shared/utils'
1010

1111
import {
1212
Place_Name, ConnectionName, type Port,
@@ -37,12 +37,6 @@ chrome.tabs
3737
}
3838
})
3939

40-
function assert(condition: any, message?: string, cause?: any): asserts condition {
41-
if (!condition) {
42-
throw Error(message ?? 'Assertion failed', {cause})
43-
}
44-
}
45-
4640
function get_assert_tab_id(port: Port, place: Place_Name): Tab_Id {
4741
let tab_id = port.sender?.tab?.id
4842
assert(tab_id, `${place} has no port sender tab id.`, port)

packages/shared/src/utils.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ export type UnionMember<T, K extends keyof T> = {
99
data: T[K],
1010
}
1111

12+
export function assert(condition: any, message?: string, cause?: any): asserts condition {
13+
if (!condition) {
14+
throw Error(message ?? 'Assertion failed', {cause})
15+
}
16+
}
17+
1218
export function msg<T, K extends keyof T>(kind: K, data: T[K]): UnionMember<T, K> {
1319
return {kind, data}
1420
}

0 commit comments

Comments
 (0)