@livestore/utils 0.4.0-dev.21 → 0.4.0-dev.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.tsbuildinfo +1 -0
- package/dist/NoopTracer.d.ts.map +1 -1
- package/dist/NoopTracer.js +15 -5
- package/dist/NoopTracer.js.map +1 -1
- package/dist/binary.js +1 -1
- package/dist/binary.js.map +1 -1
- package/dist/browser/Opfs/Opfs.d.ts +3 -3
- package/dist/browser/Opfs/Opfs.d.ts.map +1 -1
- package/dist/browser/Opfs/Opfs.js +1 -1
- package/dist/browser/Opfs/Opfs.js.map +1 -1
- package/dist/browser/Opfs/debug-utils.d.ts.map +1 -1
- package/dist/browser/Opfs/debug-utils.js +2 -2
- package/dist/browser/Opfs/debug-utils.js.map +1 -1
- package/dist/browser/Opfs/utils.d.ts.map +1 -1
- package/dist/browser/Opfs/utils.js +10 -10
- package/dist/browser/Opfs/utils.js.map +1 -1
- package/dist/browser/QuotaExceededError.d.ts.map +1 -1
- package/dist/browser/QuotaExceededError.js.map +1 -1
- package/dist/browser/WebChannelBrowser.d.ts +1 -1
- package/dist/browser/WebChannelBrowser.d.ts.map +1 -1
- package/dist/browser/WebError.d.ts +50 -54
- package/dist/browser/WebError.d.ts.map +1 -1
- package/dist/browser/WebError.js +25 -23
- package/dist/browser/WebError.js.map +1 -1
- package/dist/browser/WebLock.js +9 -9
- package/dist/browser/WebLock.js.map +1 -1
- package/dist/browser/detect.js +6 -6
- package/dist/browser/detect.js.map +1 -1
- package/dist/cuid/cuid.browser.js +1 -1
- package/dist/cuid/cuid.browser.js.map +1 -1
- package/dist/cuid/cuid.node.js +1 -1
- package/dist/cuid/cuid.node.js.map +1 -1
- package/dist/effect/BucketQueue.d.ts +1 -1
- package/dist/effect/BucketQueue.d.ts.map +1 -1
- package/dist/effect/BucketQueue.js.map +1 -1
- package/dist/effect/Debug.d.ts +7 -2
- package/dist/effect/Debug.d.ts.map +1 -1
- package/dist/effect/Debug.js +69 -61
- package/dist/effect/Debug.js.map +1 -1
- package/dist/effect/Effect.d.ts +72 -12
- package/dist/effect/Effect.d.ts.map +1 -1
- package/dist/effect/Effect.js +96 -12
- package/dist/effect/Effect.js.map +1 -1
- package/dist/effect/Error.js +1 -1
- package/dist/effect/Error.js.map +1 -1
- package/dist/effect/Logger.js +2 -2
- package/dist/effect/Logger.js.map +1 -1
- package/dist/effect/RpcClient.d.ts.map +1 -1
- package/dist/effect/RpcClient.js +4 -4
- package/dist/effect/RpcClient.js.map +1 -1
- package/dist/effect/Schema/debug-diff.js +5 -4
- package/dist/effect/Schema/debug-diff.js.map +1 -1
- package/dist/effect/Schema/index.d.ts +5 -3
- package/dist/effect/Schema/index.d.ts.map +1 -1
- package/dist/effect/Schema/index.js +1 -1
- package/dist/effect/Schema/index.js.map +1 -1
- package/dist/effect/ServiceContext.js +6 -6
- package/dist/effect/ServiceContext.js.map +1 -1
- package/dist/effect/Stream.test.js +3 -3
- package/dist/effect/Stream.test.js.map +1 -1
- package/dist/effect/SubscriptionRef.d.ts +4 -4
- package/dist/effect/SubscriptionRef.d.ts.map +1 -1
- package/dist/effect/WebChannel/WebChannel.d.ts +2 -2
- package/dist/effect/WebChannel/WebChannel.d.ts.map +1 -1
- package/dist/effect/WebChannel/WebChannel.js +4 -4
- package/dist/effect/WebChannel/WebChannel.js.map +1 -1
- package/dist/effect/WebChannel/broadcastChannelWithAck.js +4 -4
- package/dist/effect/WebChannel/broadcastChannelWithAck.js.map +1 -1
- package/dist/effect/WebChannel/common.d.ts +1 -1
- package/dist/effect/WebChannel/common.d.ts.map +1 -1
- package/dist/effect/WebChannel/common.js +2 -2
- package/dist/effect/WebChannel/common.js.map +1 -1
- package/dist/effect/WebSocket.js +3 -3
- package/dist/effect/WebSocket.js.map +1 -1
- package/dist/effect/mod.d.ts +1 -1
- package/dist/effect/mod.d.ts.map +1 -1
- package/dist/effect/mod.js +1 -1
- package/dist/effect/mod.js.map +1 -1
- package/dist/effect/spanEvent.d.ts +12 -0
- package/dist/effect/spanEvent.d.ts.map +1 -0
- package/dist/effect/spanEvent.js +12 -0
- package/dist/effect/spanEvent.js.map +1 -0
- package/dist/effect/spanEvent.test.d.ts +2 -0
- package/dist/effect/spanEvent.test.d.ts.map +1 -0
- package/dist/effect/spanEvent.test.js +82 -0
- package/dist/effect/spanEvent.test.js.map +1 -0
- package/dist/env.d.ts.map +1 -1
- package/dist/env.js +1 -1
- package/dist/env.js.map +1 -1
- package/dist/fast-deep-equal.js +9 -9
- package/dist/fast-deep-equal.js.map +1 -1
- package/dist/global.d.ts.map +1 -1
- package/dist/global.js.map +1 -1
- package/dist/misc.d.ts +9 -1
- package/dist/misc.d.ts.map +1 -1
- package/dist/misc.js +11 -3
- package/dist/misc.js.map +1 -1
- package/dist/mod.d.ts +1 -1
- package/dist/mod.d.ts.map +1 -1
- package/dist/mod.js +12 -12
- package/dist/mod.js.map +1 -1
- package/dist/node/ChildProcessRunner/ChildProcessRunner.d.ts.map +1 -1
- package/dist/node/ChildProcessRunner/ChildProcessRunner.js +15 -9
- package/dist/node/ChildProcessRunner/ChildProcessRunner.js.map +1 -1
- package/dist/node/ChildProcessRunner/ChildProcessRunnerTest/ChildProcessRunner.test.d.ts +8 -0
- package/dist/node/ChildProcessRunner/ChildProcessRunnerTest/ChildProcessRunner.test.d.ts.map +1 -1
- package/dist/node/ChildProcessRunner/ChildProcessRunnerTest/ChildProcessRunner.test.js +10 -6
- package/dist/node/ChildProcessRunner/ChildProcessRunnerTest/ChildProcessRunner.test.js.map +1 -1
- package/dist/node/ChildProcessRunner/ChildProcessRunnerTest/serializedWorker.js +2 -2
- package/dist/node/ChildProcessRunner/ChildProcessRunnerTest/serializedWorker.js.map +1 -1
- package/dist/node/ChildProcessRunner/ChildProcessWorker.d.ts.map +1 -1
- package/dist/node/ChildProcessRunner/ChildProcessWorker.js +4 -4
- package/dist/node/ChildProcessRunner/ChildProcessWorker.js.map +1 -1
- package/dist/node/mod.d.ts +31 -4
- package/dist/node/mod.d.ts.map +1 -1
- package/dist/node/mod.js +33 -6
- package/dist/node/mod.js.map +1 -1
- package/dist/object/index.d.ts.map +1 -1
- package/dist/object/index.js.map +1 -1
- package/dist/object/omit.js +1 -1
- package/dist/object/omit.js.map +1 -1
- package/dist/object/stringify-object.js +2 -2
- package/dist/object/stringify-object.js.map +1 -1
- package/dist/object/stringify-object.test.js.map +1 -1
- package/dist/qr.js +11 -11
- package/dist/qr.js.map +1 -1
- package/dist/set.js +1 -1
- package/dist/set.js.map +1 -1
- package/dist/time.js +1 -1
- package/dist/time.js.map +1 -1
- package/package.json +66 -52
- package/src/NoopTracer.ts +20 -9
- package/src/binary.ts +1 -1
- package/src/browser/Opfs/Opfs.ts +12 -4
- package/src/browser/Opfs/debug-utils.ts +8 -6
- package/src/browser/Opfs/utils.ts +11 -10
- package/src/browser/QuotaExceededError.ts +0 -2
- package/src/browser/WebChannelBrowser.ts +1 -1
- package/src/browser/WebError.ts +100 -86
- package/src/browser/WebLock.ts +15 -15
- package/src/browser/detect.ts +6 -6
- package/src/cuid/cuid.browser.ts +1 -1
- package/src/cuid/cuid.node.ts +1 -1
- package/src/effect/BucketQueue.ts +1 -1
- package/src/effect/Debug.ts +73 -55
- package/src/effect/Effect.ts +118 -36
- package/src/effect/Error.ts +1 -1
- package/src/effect/Logger.ts +2 -2
- package/src/effect/RpcClient.ts +7 -6
- package/src/effect/Schema/debug-diff.ts +6 -5
- package/src/effect/Schema/index.ts +9 -6
- package/src/effect/ServiceContext.ts +6 -6
- package/src/effect/Stream.test.ts +5 -4
- package/src/effect/SubscriptionRef.ts +5 -5
- package/src/effect/WebChannel/WebChannel.ts +6 -6
- package/src/effect/WebChannel/broadcastChannelWithAck.ts +4 -4
- package/src/effect/WebChannel/common.ts +4 -4
- package/src/effect/WebSocket.ts +3 -3
- package/src/effect/mod.ts +1 -0
- package/src/effect/spanEvent.test.ts +95 -0
- package/src/effect/spanEvent.ts +15 -0
- package/src/env.ts +2 -1
- package/src/fast-deep-equal.ts +9 -9
- package/src/global.ts +0 -2
- package/src/misc.ts +12 -4
- package/src/mod.ts +11 -11
- package/src/node/ChildProcessRunner/ChildProcessRunner.ts +23 -10
- package/src/node/ChildProcessRunner/ChildProcessRunnerTest/ChildProcessRunner.test.ts +11 -7
- package/src/node/ChildProcessRunner/ChildProcessRunnerTest/serializedWorker.ts +10 -11
- package/src/node/ChildProcessRunner/ChildProcessWorker.ts +5 -4
- package/src/node/mod.ts +38 -6
- package/src/object/index.ts +1 -1
- package/src/object/omit.ts +1 -1
- package/src/object/stringify-object.test.ts +1 -0
- package/src/object/stringify-object.ts +2 -2
- package/src/qr.ts +11 -11
- package/src/set.ts +1 -1
- package/src/time.ts +1 -1
- package/dist/.tsbuildinfo.json +0 -1
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
import { Effect, Stream } from 'effect'
|
|
8
8
|
import prettyBytes from 'pretty-bytes'
|
|
9
|
+
|
|
10
|
+
import type * as WebError from '../WebError.ts'
|
|
9
11
|
import { Opfs } from './Opfs.ts'
|
|
10
12
|
import { getDirectoryHandleByPath, getMetadata, remove } from './utils.ts'
|
|
11
13
|
|
|
@@ -33,10 +35,10 @@ const ROOT_NAME = '/'
|
|
|
33
35
|
const buildTree = Effect.fn('@livestore/utils:Opfs.buildTree')(function* () {
|
|
34
36
|
const rootHandle = yield* Opfs.getRootDirectoryHandle
|
|
35
37
|
|
|
36
|
-
const collectDirectory
|
|
38
|
+
const collectDirectory = (
|
|
37
39
|
handle: FileSystemDirectoryHandle,
|
|
38
40
|
pathSegments: ReadonlyArray<string>,
|
|
39
|
-
)
|
|
41
|
+
): Effect.Effect<OpfsTreeNode, WebError.WebError, Opfs> =>
|
|
40
42
|
Effect.gen(function* () {
|
|
41
43
|
const handlesStream = yield* Opfs.values(handle)
|
|
42
44
|
const handles = yield* handlesStream.pipe(
|
|
@@ -100,17 +102,17 @@ const formatLabel = ({ name, kind, size, lastModified }: OpfsEntryMetadata) => {
|
|
|
100
102
|
return label
|
|
101
103
|
}
|
|
102
104
|
|
|
103
|
-
const logAsciiTree = (node: OpfsTreeNode): Effect.Effect<void
|
|
105
|
+
const logAsciiTree = (node: OpfsTreeNode): Effect.Effect<void> =>
|
|
104
106
|
logAsciiNode(node, { prefix: '', isLast: true, isRoot: true })
|
|
105
107
|
|
|
106
108
|
const logAsciiNode: (
|
|
107
109
|
node: OpfsTreeNode,
|
|
108
110
|
options: { readonly prefix: string; readonly isLast: boolean; readonly isRoot?: boolean },
|
|
109
|
-
) => Effect.Effect<void
|
|
111
|
+
) => Effect.Effect<void> = (node, options) =>
|
|
110
112
|
Effect.gen(function* () {
|
|
111
113
|
const label = formatLabel(node.metadata)
|
|
112
|
-
const branch = options.isRoot ? '' : `${options.prefix}${options.isLast ? '└── ' : '├── '}`
|
|
113
|
-
const nextPrefix = options.isRoot ? '' : `${options.prefix}${options.isLast ? ' ' : '│ '}`
|
|
114
|
+
const branch = options.isRoot === true ? '' : `${options.prefix}${options.isLast === true ? '└── ' : '├── '}`
|
|
115
|
+
const nextPrefix = options.isRoot === true ? '' : `${options.prefix}${options.isLast === true ? ' ' : '│ '}`
|
|
114
116
|
|
|
115
117
|
console.log(`${branch}${label}`)
|
|
116
118
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Effect, Stream } from 'effect'
|
|
2
|
+
|
|
2
3
|
import { Opfs, OpfsError } from './Opfs.ts'
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -30,7 +31,7 @@ const parsePathSegments = (path: string) =>
|
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
for (const segment of segments) {
|
|
33
|
-
if (DISALLOWED_SEGMENTS.has(segment)) {
|
|
34
|
+
if (DISALLOWED_SEGMENTS.has(segment) === true) {
|
|
34
35
|
return yield* new OpfsError({
|
|
35
36
|
message: `Invalid OPFS path '${path}': segment '${segment}' is not supported`,
|
|
36
37
|
})
|
|
@@ -92,7 +93,7 @@ const ensureDirectoryPath = (segments: ReadonlyArray<string>, options: { readonl
|
|
|
92
93
|
currentDirHandle = yield* Opfs.getDirectoryHandle(
|
|
93
94
|
currentDirHandle,
|
|
94
95
|
segment,
|
|
95
|
-
shouldCreate ? { create: true } : undefined,
|
|
96
|
+
shouldCreate === true ? { create: true } : undefined,
|
|
96
97
|
)
|
|
97
98
|
}
|
|
98
99
|
|
|
@@ -110,7 +111,7 @@ export const getDirectoryHandleByPath = Effect.fn('@livestore/utils:Opfs.getDire
|
|
|
110
111
|
path: string,
|
|
111
112
|
options?: FileSystemGetDirectoryOptions,
|
|
112
113
|
) {
|
|
113
|
-
if (isRootPath(path)) return yield* Opfs.getRootDirectoryHandle
|
|
114
|
+
if (isRootPath(path) === true) return yield* Opfs.getRootDirectoryHandle
|
|
114
115
|
|
|
115
116
|
const pathSegments = yield* parsePathSegments(path)
|
|
116
117
|
return yield* traverseDirectoryPath(pathSegments, options)
|
|
@@ -128,7 +129,7 @@ export const remove = Effect.fn('@livestore/utils:Opfs.remove')(function* (
|
|
|
128
129
|
) {
|
|
129
130
|
const recursive = options?.recursive ?? false
|
|
130
131
|
|
|
131
|
-
if (isRootPath(path)) {
|
|
132
|
+
if (isRootPath(path) === true) {
|
|
132
133
|
const rootHandle = yield* Opfs.getRootDirectoryHandle
|
|
133
134
|
const handlesStream = yield* Opfs.values(rootHandle)
|
|
134
135
|
yield* handlesStream.pipe(
|
|
@@ -151,13 +152,13 @@ export const remove = Effect.fn('@livestore/utils:Opfs.remove')(function* (
|
|
|
151
152
|
* @returns `true` if the path resolves to a file or directory, otherwise `false`.
|
|
152
153
|
*/
|
|
153
154
|
export const exists = Effect.fn('@livestore/utils:Opfs.exists')(function* (path: string) {
|
|
154
|
-
if (isRootPath(path)) return true
|
|
155
|
+
if (isRootPath(path) === true) return true
|
|
155
156
|
|
|
156
157
|
const pathSegments = yield* parsePathSegments(path)
|
|
157
158
|
const { parentSegments, leafSegment: targetName } = splitPathSegments(pathSegments)
|
|
158
159
|
|
|
159
160
|
const parentDirHandle = yield* traverseDirectoryPath(parentSegments, { create: false }).pipe(
|
|
160
|
-
Effect.catchTag('
|
|
161
|
+
Effect.catchTag('NotFoundError', () => Effect.succeed(undefined)),
|
|
161
162
|
)
|
|
162
163
|
|
|
163
164
|
if (parentDirHandle === undefined) return false
|
|
@@ -165,7 +166,7 @@ export const exists = Effect.fn('@livestore/utils:Opfs.exists')(function* (path:
|
|
|
165
166
|
return yield* Opfs.getFileHandle(parentDirHandle, targetName).pipe(
|
|
166
167
|
Effect.orElse(() => Opfs.getDirectoryHandle(parentDirHandle, targetName, { create: false })),
|
|
167
168
|
Effect.as(true),
|
|
168
|
-
Effect.catchTag('
|
|
169
|
+
Effect.catchTag('NotFoundError', () => Effect.succeed(false)),
|
|
169
170
|
)
|
|
170
171
|
})
|
|
171
172
|
|
|
@@ -181,7 +182,7 @@ export const makeDirectory = Effect.fn('@livestore/utils:Opfs.makeDirectory')(fu
|
|
|
181
182
|
) {
|
|
182
183
|
const recursive = options?.recursive ?? false
|
|
183
184
|
|
|
184
|
-
if (isRootPath(path)) return
|
|
185
|
+
if (isRootPath(path) === true) return
|
|
185
186
|
|
|
186
187
|
const pathSegments = yield* parsePathSegments(path)
|
|
187
188
|
|
|
@@ -215,7 +216,7 @@ export const getMetadata = Effect.fn('@livestore/utils:Opfs.getMetadata')(functi
|
|
|
215
216
|
* - Only available in Safari 26 or higher (as of Dec 2025, not yet widely available).
|
|
216
217
|
*/
|
|
217
218
|
export const writeFile = Effect.fn('@livestore/utils:Opfs.writeFile')(function* (path: string, data: Uint8Array) {
|
|
218
|
-
if (isRootPath(path)) {
|
|
219
|
+
if (isRootPath(path) === true) {
|
|
219
220
|
return yield* new OpfsError({
|
|
220
221
|
message: `Invalid OPFS path '${path}': cannot write file directly to the OPFS root`,
|
|
221
222
|
})
|
|
@@ -252,7 +253,7 @@ export const syncWriteFile = Effect.fn('@livestore/utils:Opfs.syncWriteFile')(fu
|
|
|
252
253
|
path: string,
|
|
253
254
|
data: Uint8Array,
|
|
254
255
|
) {
|
|
255
|
-
if (isRootPath(path)) {
|
|
256
|
+
if (isRootPath(path) === true) {
|
|
256
257
|
return yield* new OpfsError({
|
|
257
258
|
message: `Invalid OPFS path '${path}': cannot write file directly to the OPFS root`,
|
|
258
259
|
})
|
|
@@ -66,7 +66,7 @@ export const windowChannel = <MsgListen, MsgSend, MsgListenEncoded, MsgSendEncod
|
|
|
66
66
|
}: {
|
|
67
67
|
listenWindow: Window
|
|
68
68
|
sendWindow: Window
|
|
69
|
-
targetOrigin?: string
|
|
69
|
+
targetOrigin?: string | undefined
|
|
70
70
|
ids: { own: string; other: string }
|
|
71
71
|
schema: InputSchema<MsgListen, MsgSend, MsgListenEncoded, MsgSendEncoded>
|
|
72
72
|
}): Effect.Effect<WebChannel<MsgListen, MsgSend>, never, Scope.Scope> =>
|
package/src/browser/WebError.ts
CHANGED
|
@@ -4,12 +4,7 @@ import { Either, ParseResult, Predicate, Schema } from 'effect'
|
|
|
4
4
|
/**
|
|
5
5
|
* Unique identifier for web errors.
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Type-level representation of the web error identifier.
|
|
11
|
-
*/
|
|
12
|
-
export type TypeId = typeof TypeId
|
|
7
|
+
const TypeId = '~@livestore/utils/WebError' as const
|
|
13
8
|
|
|
14
9
|
/**
|
|
15
10
|
* Type guard to check if a value is a web error.
|
|
@@ -48,10 +43,12 @@ export const isWebError = (u: unknown): u is WebError => Predicate.hasProperty(u
|
|
|
48
43
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Evalerror | MDN Reference}
|
|
49
44
|
* @see {@link https://webidl.spec.whatwg.org/#exceptiondef-evalerror | Specification}
|
|
50
45
|
*/
|
|
51
|
-
export class EvalError extends Schema.TaggedError<EvalError>(
|
|
46
|
+
export class EvalError extends Schema.TaggedError<EvalError>(
|
|
47
|
+
`${TypeId}/EvalError`,
|
|
48
|
+
)('EvalError', {
|
|
52
49
|
cause: Schema.instanceOf(globalThis.EvalError),
|
|
53
50
|
}) {
|
|
54
|
-
readonly [TypeId]
|
|
51
|
+
readonly [TypeId] = TypeId
|
|
55
52
|
}
|
|
56
53
|
|
|
57
54
|
/**
|
|
@@ -62,10 +59,12 @@ export class EvalError extends Schema.TaggedError<EvalError>()('@livestore/utils
|
|
|
62
59
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Rangeerror | MDN Reference}
|
|
63
60
|
* @see {@link https://webidl.spec.whatwg.org/#exceptiondef-rangeerror | Specification}
|
|
64
61
|
*/
|
|
65
|
-
export class RangeError extends Schema.TaggedError<RangeError>(
|
|
62
|
+
export class RangeError extends Schema.TaggedError<RangeError>(
|
|
63
|
+
`${TypeId}/RangeError`,
|
|
64
|
+
)('RangeError', {
|
|
66
65
|
cause: Schema.instanceOf(globalThis.RangeError),
|
|
67
66
|
}) {
|
|
68
|
-
readonly [TypeId]
|
|
67
|
+
readonly [TypeId] = TypeId
|
|
69
68
|
}
|
|
70
69
|
|
|
71
70
|
/**
|
|
@@ -76,10 +75,12 @@ export class RangeError extends Schema.TaggedError<RangeError>()('@livestore/uti
|
|
|
76
75
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Referenceerror | MDN Reference}
|
|
77
76
|
* @see {@link https://webidl.spec.whatwg.org/#exceptiondef-referenceerror | Specification}
|
|
78
77
|
*/
|
|
79
|
-
export class ReferenceError extends Schema.TaggedError<ReferenceError>(
|
|
78
|
+
export class ReferenceError extends Schema.TaggedError<ReferenceError>(
|
|
79
|
+
`${TypeId}/ReferenceError`,
|
|
80
|
+
)('ReferenceError', {
|
|
80
81
|
cause: Schema.instanceOf(globalThis.ReferenceError),
|
|
81
82
|
}) {
|
|
82
|
-
readonly [TypeId]
|
|
83
|
+
readonly [TypeId] = TypeId
|
|
83
84
|
}
|
|
84
85
|
|
|
85
86
|
/**
|
|
@@ -90,10 +91,12 @@ export class ReferenceError extends Schema.TaggedError<ReferenceError>()('@lives
|
|
|
90
91
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Typeerror | MDN Reference}
|
|
91
92
|
* @see {@link https://webidl.spec.whatwg.org/#exceptiondef-typeerror | Specification}
|
|
92
93
|
*/
|
|
93
|
-
export class TypeError extends Schema.TaggedError<TypeError>(
|
|
94
|
+
export class TypeError extends Schema.TaggedError<TypeError>(
|
|
95
|
+
`${TypeId}/TypeError`,
|
|
96
|
+
)('TypeError', {
|
|
94
97
|
cause: Schema.instanceOf(globalThis.TypeError),
|
|
95
98
|
}) {
|
|
96
|
-
readonly [TypeId]
|
|
99
|
+
readonly [TypeId] = TypeId
|
|
97
100
|
}
|
|
98
101
|
|
|
99
102
|
/**
|
|
@@ -104,10 +107,12 @@ export class TypeError extends Schema.TaggedError<TypeError>()('@livestore/utils
|
|
|
104
107
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIerror | MDN Reference}
|
|
105
108
|
* @see {@link https://webidl.spec.whatwg.org/#exceptiondef-urierror | Specification}
|
|
106
109
|
*/
|
|
107
|
-
export class URIError extends Schema.TaggedError<URIError>(
|
|
110
|
+
export class URIError extends Schema.TaggedError<URIError>(
|
|
111
|
+
`${TypeId}/URIError`,
|
|
112
|
+
)('URIError', {
|
|
108
113
|
cause: Schema.instanceOf(globalThis.URIError),
|
|
109
114
|
}) {
|
|
110
|
-
readonly [TypeId]
|
|
115
|
+
readonly [TypeId] = TypeId
|
|
111
116
|
}
|
|
112
117
|
|
|
113
118
|
// ============================================================================
|
|
@@ -136,20 +141,19 @@ const domExceptionWithName = (expectedName: string) =>
|
|
|
136
141
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/QuotaExceededError | MDN Reference}
|
|
137
142
|
* @see {@link https://webidl.spec.whatwg.org/#quotaexceedederror | Specification}
|
|
138
143
|
*/
|
|
139
|
-
export class QuotaExceededError extends Schema.TaggedError<QuotaExceededError>(
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
get message(): string {
|
|
144
|
+
export class QuotaExceededError extends Schema.TaggedError<QuotaExceededError>(
|
|
145
|
+
`${TypeId}/QuotaExceededError`,
|
|
146
|
+
)('QuotaExceededError', {
|
|
147
|
+
cause: Schema.Union(
|
|
148
|
+
typeof globalThis.QuotaExceededError === 'function'
|
|
149
|
+
? Schema.instanceOf(globalThis.QuotaExceededError)
|
|
150
|
+
: Schema.Never,
|
|
151
|
+
// Deprecated but still in use in some browsers
|
|
152
|
+
domExceptionWithName('QuotaExceededError'),
|
|
153
|
+
),
|
|
154
|
+
}) {
|
|
155
|
+
readonly [TypeId] = TypeId
|
|
156
|
+
override get message(): string {
|
|
153
157
|
return this.cause.message
|
|
154
158
|
}
|
|
155
159
|
}
|
|
@@ -169,14 +173,13 @@ export class QuotaExceededError extends Schema.TaggedError<QuotaExceededError>()
|
|
|
169
173
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/DOMException#nomodificationallowederror | MDN Reference}
|
|
170
174
|
* @see {@link https://webidl.spec.whatwg.org/#nomodificationallowederror | Specification}
|
|
171
175
|
*/
|
|
172
|
-
export class NoModificationAllowedError extends Schema.TaggedError<NoModificationAllowedError>(
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
get message(): string {
|
|
176
|
+
export class NoModificationAllowedError extends Schema.TaggedError<NoModificationAllowedError>(
|
|
177
|
+
`${TypeId}/NoModificationAllowedError`,
|
|
178
|
+
)('NoModificationAllowedError', {
|
|
179
|
+
cause: domExceptionWithName('NoModificationAllowedError'),
|
|
180
|
+
}) {
|
|
181
|
+
readonly [TypeId] = TypeId
|
|
182
|
+
override get message(): string {
|
|
180
183
|
return this.cause.message
|
|
181
184
|
}
|
|
182
185
|
}
|
|
@@ -189,11 +192,13 @@ export class NoModificationAllowedError extends Schema.TaggedError<NoModificatio
|
|
|
189
192
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/DOMException#notfounderror | MDN Reference}
|
|
190
193
|
* @see {@link https://webidl.spec.whatwg.org/#notfounderror | Specification}
|
|
191
194
|
*/
|
|
192
|
-
export class NotFoundError extends Schema.TaggedError<NotFoundError>(
|
|
195
|
+
export class NotFoundError extends Schema.TaggedError<NotFoundError>(
|
|
196
|
+
`${TypeId}/NotFoundError`,
|
|
197
|
+
)('NotFoundError', {
|
|
193
198
|
cause: domExceptionWithName('NotFoundError'),
|
|
194
199
|
}) {
|
|
195
|
-
readonly [TypeId]
|
|
196
|
-
get message(): string {
|
|
200
|
+
readonly [TypeId] = TypeId
|
|
201
|
+
override get message(): string {
|
|
197
202
|
return this.cause.message
|
|
198
203
|
}
|
|
199
204
|
}
|
|
@@ -206,11 +211,13 @@ export class NotFoundError extends Schema.TaggedError<NotFoundError>()('@livesto
|
|
|
206
211
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/DOMException#notallowederror | MDN Reference}
|
|
207
212
|
* @see {@link https://webidl.spec.whatwg.org/#notallowederror | Specification}
|
|
208
213
|
*/
|
|
209
|
-
export class NotAllowedError extends Schema.TaggedError<NotAllowedError>(
|
|
214
|
+
export class NotAllowedError extends Schema.TaggedError<NotAllowedError>(
|
|
215
|
+
`${TypeId}/NotAllowedError`,
|
|
216
|
+
)('NotAllowedError', {
|
|
210
217
|
cause: domExceptionWithName('NotAllowedError'),
|
|
211
218
|
}) {
|
|
212
|
-
readonly [TypeId]
|
|
213
|
-
get message(): string {
|
|
219
|
+
readonly [TypeId] = TypeId
|
|
220
|
+
override get message(): string {
|
|
214
221
|
return this.cause.message
|
|
215
222
|
}
|
|
216
223
|
}
|
|
@@ -223,14 +230,13 @@ export class NotAllowedError extends Schema.TaggedError<NotAllowedError>()('@liv
|
|
|
223
230
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/DOMException#typemismatcherror | MDN Reference}
|
|
224
231
|
* @see {@link https://webidl.spec.whatwg.org/#typemismatcherror | Specification}
|
|
225
232
|
*/
|
|
226
|
-
export class TypeMismatchError extends Schema.TaggedError<TypeMismatchError>(
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
get message(): string {
|
|
233
|
+
export class TypeMismatchError extends Schema.TaggedError<TypeMismatchError>(
|
|
234
|
+
`${TypeId}/TypeMismatchError`,
|
|
235
|
+
)('TypeMismatchError', {
|
|
236
|
+
cause: domExceptionWithName('TypeMismatchError'),
|
|
237
|
+
}) {
|
|
238
|
+
readonly [TypeId] = TypeId
|
|
239
|
+
override get message(): string {
|
|
234
240
|
return this.cause.message
|
|
235
241
|
}
|
|
236
242
|
}
|
|
@@ -243,14 +249,13 @@ export class TypeMismatchError extends Schema.TaggedError<TypeMismatchError>()(
|
|
|
243
249
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/DOMException#invalidstateerror | MDN Reference}
|
|
244
250
|
* @see {@link https://webidl.spec.whatwg.org/#invalidstateerror | Specification}
|
|
245
251
|
*/
|
|
246
|
-
export class InvalidStateError extends Schema.TaggedError<InvalidStateError>(
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
get message(): string {
|
|
252
|
+
export class InvalidStateError extends Schema.TaggedError<InvalidStateError>(
|
|
253
|
+
`${TypeId}/InvalidStateError`,
|
|
254
|
+
)('InvalidStateError', {
|
|
255
|
+
cause: domExceptionWithName('InvalidStateError'),
|
|
256
|
+
}) {
|
|
257
|
+
readonly [TypeId] = TypeId
|
|
258
|
+
override get message(): string {
|
|
254
259
|
return this.cause.message
|
|
255
260
|
}
|
|
256
261
|
}
|
|
@@ -263,11 +268,13 @@ export class InvalidStateError extends Schema.TaggedError<InvalidStateError>()(
|
|
|
263
268
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/DOMException#aborterror | MDN Reference}
|
|
264
269
|
* @see {@link https://webidl.spec.whatwg.org/#aborterror | Specification}
|
|
265
270
|
*/
|
|
266
|
-
export class AbortError extends Schema.TaggedError<AbortError>(
|
|
271
|
+
export class AbortError extends Schema.TaggedError<AbortError>(
|
|
272
|
+
`${TypeId}/AbortError`,
|
|
273
|
+
)('AbortError', {
|
|
267
274
|
cause: domExceptionWithName('AbortError'),
|
|
268
275
|
}) {
|
|
269
|
-
readonly [TypeId]
|
|
270
|
-
get message(): string {
|
|
276
|
+
readonly [TypeId] = TypeId
|
|
277
|
+
override get message(): string {
|
|
271
278
|
return this.cause.message
|
|
272
279
|
}
|
|
273
280
|
}
|
|
@@ -280,14 +287,13 @@ export class AbortError extends Schema.TaggedError<AbortError>()('@livestore/uti
|
|
|
280
287
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/DOMException#invalidmodificationerror | MDN Reference}
|
|
281
288
|
* @see {@link https://webidl.spec.whatwg.org/#invalidmodificationerror | Specification}
|
|
282
289
|
*/
|
|
283
|
-
export class InvalidModificationError extends Schema.TaggedError<InvalidModificationError>(
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
get message(): string {
|
|
290
|
+
export class InvalidModificationError extends Schema.TaggedError<InvalidModificationError>(
|
|
291
|
+
`${TypeId}/InvalidModificationError`,
|
|
292
|
+
)('InvalidModificationError', {
|
|
293
|
+
cause: domExceptionWithName('InvalidModificationError'),
|
|
294
|
+
}) {
|
|
295
|
+
readonly [TypeId] = TypeId
|
|
296
|
+
override get message(): string {
|
|
291
297
|
return this.cause.message
|
|
292
298
|
}
|
|
293
299
|
}
|
|
@@ -300,11 +306,13 @@ export class InvalidModificationError extends Schema.TaggedError<InvalidModifica
|
|
|
300
306
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/DOMException#securityerror | MDN Reference}
|
|
301
307
|
* @see {@link https://webidl.spec.whatwg.org/#securityerror | Specification}
|
|
302
308
|
*/
|
|
303
|
-
export class SecurityError extends Schema.TaggedError<SecurityError>(
|
|
309
|
+
export class SecurityError extends Schema.TaggedError<SecurityError>(
|
|
310
|
+
`${TypeId}/SecurityError`,
|
|
311
|
+
)('SecurityError', {
|
|
304
312
|
cause: domExceptionWithName('SecurityError'),
|
|
305
313
|
}) {
|
|
306
|
-
readonly [TypeId]
|
|
307
|
-
get message(): string {
|
|
314
|
+
readonly [TypeId] = TypeId
|
|
315
|
+
override get message(): string {
|
|
308
316
|
return this.cause.message
|
|
309
317
|
}
|
|
310
318
|
}
|
|
@@ -317,11 +325,13 @@ export class SecurityError extends Schema.TaggedError<SecurityError>()('@livesto
|
|
|
317
325
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/DOMException#datacloneerror | MDN Reference}
|
|
318
326
|
* @see {@link https://webidl.spec.whatwg.org/#datacloneerror | Specification}
|
|
319
327
|
*/
|
|
320
|
-
export class DataCloneError extends Schema.TaggedError<DataCloneError>(
|
|
328
|
+
export class DataCloneError extends Schema.TaggedError<DataCloneError>(
|
|
329
|
+
`${TypeId}/DataCloneError`,
|
|
330
|
+
)('DataCloneError', {
|
|
321
331
|
cause: domExceptionWithName('DataCloneError'),
|
|
322
332
|
}) {
|
|
323
|
-
readonly [TypeId]
|
|
324
|
-
get message(): string {
|
|
333
|
+
readonly [TypeId] = TypeId
|
|
334
|
+
override get message(): string {
|
|
325
335
|
return this.cause.message
|
|
326
336
|
}
|
|
327
337
|
}
|
|
@@ -357,7 +367,7 @@ export class DataCloneError extends Schema.TaggedError<DataCloneError>()('@lives
|
|
|
357
367
|
* }
|
|
358
368
|
*
|
|
359
369
|
* const program = riskyOperation().pipe(
|
|
360
|
-
* Effect.catchTag("
|
|
370
|
+
* Effect.catchTag("UnknownError", (error) => {
|
|
361
371
|
* console.log(error.message)
|
|
362
372
|
* // "JSON.parse: Could not parse string as JSON"
|
|
363
373
|
* return Effect.succeed("JSON parsing not possible")
|
|
@@ -365,18 +375,22 @@ export class DataCloneError extends Schema.TaggedError<DataCloneError>()('@lives
|
|
|
365
375
|
* )
|
|
366
376
|
* ```
|
|
367
377
|
*/
|
|
368
|
-
export class UnknownError extends Schema.TaggedError<UnknownError>(
|
|
378
|
+
export class UnknownError extends Schema.TaggedError<UnknownError>(
|
|
379
|
+
`${TypeId}/UnknownError`,
|
|
380
|
+
)('UnknownError', {
|
|
369
381
|
module: Schema.optional(Schema.String),
|
|
370
382
|
method: Schema.optional(Schema.String),
|
|
371
383
|
description: Schema.optional(Schema.String),
|
|
372
384
|
cause: Schema.optional(Schema.Defect),
|
|
373
385
|
}) {
|
|
374
|
-
readonly [TypeId]
|
|
375
|
-
get message(): string {
|
|
376
|
-
const messageEnd = Predicate.isUndefined(this.description) ? 'A web error occurred' : this.description
|
|
386
|
+
readonly [TypeId] = TypeId
|
|
387
|
+
override get message(): string {
|
|
388
|
+
const messageEnd = Predicate.isUndefined(this.description) === true ? 'A web error occurred' : this.description
|
|
377
389
|
const moduleMethod =
|
|
378
|
-
Predicate.isString(this.module) && Predicate.isString(this.method)
|
|
379
|
-
|
|
390
|
+
Predicate.isString(this.module) === true && Predicate.isString(this.method) === true
|
|
391
|
+
? `${this.module}.${this.method}`
|
|
392
|
+
: undefined
|
|
393
|
+
return Predicate.isUndefined(moduleMethod) === true ? messageEnd : `${moduleMethod}: ${messageEnd}`
|
|
380
394
|
}
|
|
381
395
|
}
|
|
382
396
|
|
|
@@ -494,7 +508,7 @@ const WebErrorFromUnknown = Schema.transform(Schema.Unknown, WebError, {
|
|
|
494
508
|
strict: true,
|
|
495
509
|
decode: (value) => {
|
|
496
510
|
// Already a WebError
|
|
497
|
-
if (isWebError(value)) return value
|
|
511
|
+
if (isWebError(value) === true) return value
|
|
498
512
|
|
|
499
513
|
// Simple Exception Errors
|
|
500
514
|
if (value instanceof globalThis.EvalError) return new EvalError({ cause: value })
|
|
@@ -593,7 +607,7 @@ export function parseWebError(value: unknown, expected: readonly WebErrorConstru
|
|
|
593
607
|
if (expected.length === 0) return parsed
|
|
594
608
|
|
|
595
609
|
const expectedTags = new Set(expected.map((ErrorConstructor) => ErrorConstructor._tag))
|
|
596
|
-
if (expectedTags.has(parsed._tag)) return parsed
|
|
610
|
+
if (expectedTags.has(parsed._tag) === true) return parsed
|
|
597
611
|
|
|
598
612
|
return parsed instanceof UnknownError ? parsed : new UnknownError({ cause: parsed })
|
|
599
613
|
}
|
package/src/browser/WebLock.ts
CHANGED
|
@@ -18,16 +18,16 @@ export const withLock =
|
|
|
18
18
|
|
|
19
19
|
const exit = yield* Effect.tryPromise<Exit.Exit<A, E>, E | E2>({
|
|
20
20
|
try: (signal) => {
|
|
21
|
-
if (signal.aborted) return 'aborted' as never
|
|
21
|
+
if (signal.aborted === true) return 'aborted' as never
|
|
22
22
|
|
|
23
23
|
// NOTE The 'signal' and 'ifAvailable' options cannot be used together.
|
|
24
24
|
const requestOptions = options?.ifAvailable === true ? options : { ...options, signal }
|
|
25
|
-
return navigator.locks.request(lockName, requestOptions, async (lock) => {
|
|
25
|
+
return navigator.locks.request(lockName, requestOptions, async (lock: Lock | null) => {
|
|
26
26
|
if (lock === null) {
|
|
27
|
-
if (onTaken) {
|
|
28
|
-
const
|
|
29
|
-
if (
|
|
30
|
-
return
|
|
27
|
+
if (onTaken !== undefined) {
|
|
28
|
+
const onTakenExit = await Runtime.runPromiseExit(runtime)(onTaken)
|
|
29
|
+
if (onTakenExit._tag === 'Failure') {
|
|
30
|
+
return onTakenExit
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
return
|
|
@@ -49,10 +49,10 @@ export const withLock =
|
|
|
49
49
|
|
|
50
50
|
export const waitForDeferredLock = (deferred: Deferred.Deferred<void>, lockName: string) =>
|
|
51
51
|
Effect.async<void>((cb, signal) => {
|
|
52
|
-
if (signal.aborted) return
|
|
52
|
+
if (signal.aborted === true) return
|
|
53
53
|
|
|
54
54
|
navigator.locks
|
|
55
|
-
.request(lockName, { signal, mode: 'exclusive', ifAvailable: false }, (_lock) => {
|
|
55
|
+
.request(lockName, { signal, mode: 'exclusive', ifAvailable: false }, (_lock: Lock | null) => {
|
|
56
56
|
// immediately continuing calling Effect since we have the lock
|
|
57
57
|
cb(Effect.void)
|
|
58
58
|
|
|
@@ -72,7 +72,7 @@ export const waitForDeferredLock = (deferred: Deferred.Deferred<void>, lockName:
|
|
|
72
72
|
|
|
73
73
|
export const tryGetDeferredLock = (deferred: Deferred.Deferred<void>, lockName: string) =>
|
|
74
74
|
Effect.async<boolean>((cb, signal) => {
|
|
75
|
-
navigator.locks.request(lockName, { mode: 'exclusive', ifAvailable: true }, (lock) => {
|
|
75
|
+
navigator.locks.request(lockName, { mode: 'exclusive', ifAvailable: true }, (lock: Lock | null) => {
|
|
76
76
|
cb(Effect.succeed(lock !== null))
|
|
77
77
|
|
|
78
78
|
// the code below is still running
|
|
@@ -96,7 +96,7 @@ export const tryGetDeferredLock = (deferred: Deferred.Deferred<void>, lockName:
|
|
|
96
96
|
|
|
97
97
|
export const stealDeferredLock = (deferred: Deferred.Deferred<void>, lockName: string) =>
|
|
98
98
|
Effect.async<boolean>((cb, signal) => {
|
|
99
|
-
navigator.locks.request(lockName, { mode: 'exclusive', steal: true }, (lock) => {
|
|
99
|
+
navigator.locks.request(lockName, { mode: 'exclusive', steal: true }, (lock: Lock | null) => {
|
|
100
100
|
cb(Effect.succeed(lock !== null))
|
|
101
101
|
|
|
102
102
|
// the code below is still running
|
|
@@ -117,9 +117,9 @@ export const stealDeferredLock = (deferred: Deferred.Deferred<void>, lockName: s
|
|
|
117
117
|
|
|
118
118
|
export const waitForLock = (lockName: string) =>
|
|
119
119
|
Effect.async<void>((cb, signal) => {
|
|
120
|
-
if (signal.aborted) return
|
|
120
|
+
if (signal.aborted === true) return
|
|
121
121
|
|
|
122
|
-
navigator.locks.request(lockName, { mode: 'shared', signal, ifAvailable: false }, (_lock) => {
|
|
122
|
+
navigator.locks.request(lockName, { mode: 'shared', signal, ifAvailable: false }, (_lock: Lock | null) => {
|
|
123
123
|
cb(Effect.succeed(void 0))
|
|
124
124
|
})
|
|
125
125
|
})
|
|
@@ -127,10 +127,10 @@ export const waitForLock = (lockName: string) =>
|
|
|
127
127
|
/** Attempts to get the lock if available and waits for it to be stolen */
|
|
128
128
|
export const getLockAndWaitForSteal = (lockName: string) =>
|
|
129
129
|
Effect.async<void>((cb, signal) => {
|
|
130
|
-
if (signal.aborted) return
|
|
130
|
+
if (signal.aborted === true) return
|
|
131
131
|
|
|
132
132
|
navigator.locks
|
|
133
|
-
.request(lockName, { mode: 'exclusive', ifAvailable: true }, async (lock) => {
|
|
133
|
+
.request(lockName, { mode: 'exclusive', ifAvailable: true }, async (lock: Lock | null) => {
|
|
134
134
|
if (lock === null) {
|
|
135
135
|
// Lock wasn't available, resolve immediately
|
|
136
136
|
cb(Effect.succeed(void 0))
|
|
@@ -148,7 +148,7 @@ export const getLockAndWaitForSteal = (lockName: string) =>
|
|
|
148
148
|
resolve()
|
|
149
149
|
})
|
|
150
150
|
|
|
151
|
-
return Promise.race([holdLock, signal.aborted ? Promise.resolve() : holdLock]).catch(() => {})
|
|
151
|
+
return Promise.race([holdLock, signal.aborted === true ? Promise.resolve() : holdLock]).catch(() => {})
|
|
152
152
|
}).catch(() => {})
|
|
153
153
|
|
|
154
154
|
cb(Effect.succeed(void 0))
|
package/src/browser/detect.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export type DetectedBrowser = 'Something' | 'Opera' | 'Chrome' | 'Safari' | 'Firefox' | 'Edge' | 'Browser'
|
|
2
2
|
|
|
3
3
|
export const detectBrowserName: () => DetectedBrowser = () => {
|
|
4
|
-
if (
|
|
4
|
+
if (navigator.userAgent == null) {
|
|
5
5
|
return 'Something'
|
|
6
6
|
}
|
|
7
7
|
|
|
@@ -13,19 +13,19 @@ export const detectBrowserName: () => DetectedBrowser = () => {
|
|
|
13
13
|
|
|
14
14
|
// TODO: also parse out version
|
|
15
15
|
|
|
16
|
-
if (isOpera) {
|
|
16
|
+
if (isOpera === true) {
|
|
17
17
|
return 'Opera'
|
|
18
18
|
}
|
|
19
|
-
if (isChrome) {
|
|
19
|
+
if (isChrome === true) {
|
|
20
20
|
return 'Chrome'
|
|
21
21
|
}
|
|
22
|
-
if (isSafari) {
|
|
22
|
+
if (isSafari === true) {
|
|
23
23
|
return 'Safari'
|
|
24
24
|
}
|
|
25
|
-
if (isFirefox) {
|
|
25
|
+
if (isFirefox === true) {
|
|
26
26
|
return 'Firefox'
|
|
27
27
|
}
|
|
28
|
-
if (isEdge) {
|
|
28
|
+
if (isEdge === true) {
|
|
29
29
|
return 'Edge'
|
|
30
30
|
}
|
|
31
31
|
return 'Browser'
|
package/src/cuid/cuid.browser.ts
CHANGED
|
@@ -82,7 +82,7 @@ export const slug = () => {
|
|
|
82
82
|
|
|
83
83
|
export const isCuid = (stringToCheck: string) => {
|
|
84
84
|
if (typeof stringToCheck !== 'string') return false
|
|
85
|
-
if (stringToCheck.startsWith('c')) return true
|
|
85
|
+
if (stringToCheck.startsWith('c') === true) return true
|
|
86
86
|
return false
|
|
87
87
|
}
|
|
88
88
|
|
package/src/cuid/cuid.node.ts
CHANGED
|
@@ -90,7 +90,7 @@ export const slug = () => {
|
|
|
90
90
|
|
|
91
91
|
export const isCuid = (stringToCheck: string) => {
|
|
92
92
|
if (typeof stringToCheck !== 'string') return false
|
|
93
|
-
if (stringToCheck.startsWith('c')) return true
|
|
93
|
+
if (stringToCheck.startsWith('c') === true) return true
|
|
94
94
|
return false
|
|
95
95
|
}
|
|
96
96
|
|
|
@@ -15,7 +15,7 @@ export const takeBetween = <A>(
|
|
|
15
15
|
bucket: BucketQueue<A>,
|
|
16
16
|
min: number,
|
|
17
17
|
max: number,
|
|
18
|
-
): STM.STM<ReadonlyArray<A
|
|
18
|
+
): STM.STM<ReadonlyArray<A>> =>
|
|
19
19
|
STM.gen(function* () {
|
|
20
20
|
const bucketValue = yield* TRef.get(bucket)
|
|
21
21
|
if (bucketValue.length < min) {
|