workers-start 0.2.1 → 0.4.0

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/src/workers.ts CHANGED
@@ -21,7 +21,10 @@ let modulePromise: Promise<WorkersModule | null> | null = null;
21
21
  let override: WorkersModule | null | undefined;
22
22
 
23
23
  function processEnv(): Record<string, string | undefined> {
24
- return (globalThis as { process?: { env?: Record<string, string | undefined> } }).process?.env ?? {};
24
+ return (
25
+ (globalThis as { process?: { env?: Record<string, string | undefined> } })
26
+ .process?.env ?? {}
27
+ );
25
28
  }
26
29
 
27
30
  /** The `cloudflare:workers` module, or null outside workerd. */
@@ -47,7 +50,10 @@ export function setWorkersModule(mod: WorkersModule | null | undefined): void {
47
50
  }
48
51
 
49
52
  /** A binding by name, or null when it is missing or fails the guard. */
50
- export async function getBinding<T>(name: string, guard?: (value: unknown) => value is T): Promise<T | null> {
53
+ export async function getBinding<T>(
54
+ name: string,
55
+ guard?: (value: unknown) => value is T,
56
+ ): Promise<T | null> {
51
57
  const mod = await loadWorkers();
52
58
  const value = mod?.env[name];
53
59
  if (value === undefined || value === null) {
@@ -91,12 +97,20 @@ export async function afterResponse(work: Promise<unknown>): Promise<void> {
91
97
  /** True for a KV namespace (it has `getWithMetadata`, which R2 buckets do not). Use as a `getBinding` guard. */
92
98
  export function isKvNamespace(value: unknown): value is {
93
99
  get(key: string): Promise<string | null>;
94
- put(key: string, value: string, options?: { expirationTtl?: number }): Promise<void>;
100
+ put(
101
+ key: string,
102
+ value: string,
103
+ options?: { expirationTtl?: number },
104
+ ): Promise<void>;
95
105
  } {
96
106
  if (typeof value !== "object" || value === null) {
97
107
  return false;
98
108
  }
99
- const candidate = value as { get?: unknown; put?: unknown; getWithMetadata?: unknown };
109
+ const candidate = value as {
110
+ get?: unknown;
111
+ put?: unknown;
112
+ getWithMetadata?: unknown;
113
+ };
100
114
  return (
101
115
  typeof candidate.get === "function" &&
102
116
  typeof candidate.put === "function" &&
package/biome.preset.json DELETED
@@ -1,47 +0,0 @@
1
- {
2
- "$schema": "https://biomejs.dev/schemas/2.6.8/schema.json",
3
- "formatter": {
4
- "indentStyle": "space",
5
- "indentWidth": 2,
6
- "lineEnding": "lf",
7
- "lineWidth": 80
8
- },
9
- "javascript": {
10
- "formatter": {
11
- "arrowParentheses": "always",
12
- "jsxQuoteStyle": "double",
13
- "quoteProperties": "asNeeded",
14
- "semicolons": "always",
15
- "trailingCommas": "es5"
16
- }
17
- },
18
- "json": {
19
- "formatter": {
20
- "trailingCommas": "none"
21
- }
22
- },
23
- "css": {
24
- "parser": {
25
- "tailwindDirectives": true
26
- }
27
- },
28
- "assist": {
29
- "actions": {
30
- "source": {
31
- "organizeImports": "on",
32
- "useSortedAttributes": "on"
33
- }
34
- }
35
- },
36
- "linter": {
37
- "rules": {
38
- "preset": "recommended",
39
- "security": {
40
- "noDangerouslySetInnerHtml": "off"
41
- },
42
- "performance": {
43
- "useTopLevelRegex": "error"
44
- }
45
- }
46
- }
47
- }