Skip to content

Commit d1f40da

Browse files
committed
readme
1 parent ac88634 commit d1f40da

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -185,28 +185,28 @@ const result = parseQueryDetailedSync('SELECT * FROM users WHERE active = true')
185185

186186
### `isReady(): boolean`
187187

188-
Checks if the WebAssembly module is initialized and ready for synchronous operations. This is useful when using sync methods to avoid "WASM module not initialized" errors.
188+
Checks if the WebAssembly module is initialized and ready for synchronous operations. This is only needed when using the synchronous methods (`parseQuerySync`, `deparseSync`, etc.).
189189

190190
```typescript
191-
import { isReady, parseQuerySync, parseQuery } from 'libpg-query';
191+
import { isReady, parseQuerySync } from 'libpg-query';
192192

193193
// Check if module is ready before using sync methods
194194
if (isReady()) {
195195
const result = parseQuerySync('SELECT * FROM users');
196196
} else {
197-
// Initialize by calling any async method first
198-
await parseQuery('SELECT 1');
199-
// Now sync methods will work
200-
const result = parseQuerySync('SELECT * FROM users');
197+
// Module needs initialization
198+
console.warn('WASM module not initialized. Use async methods first to initialize.');
201199
}
202200

203-
// Alternative pattern - always safe
201+
// Recommended pattern for sync methods
204202
if (!isReady()) {
205-
await parseQuery('SELECT 1'); // Initialize module
203+
throw new Error('WASM module not initialized. Use async methods first to initialize.');
206204
}
207205
const result = parseQuerySync('SELECT * FROM users');
208206
```
209207

208+
Note: The async methods (`parseQuery`, `deparse`, `parsePlPgSQL`, etc.) handle initialization automatically and are always safe to use. The `isReady()` check is only needed for the synchronous versions of these methods.
209+
210210
### Type Definitions
211211

212212
```typescript

0 commit comments

Comments
 (0)