Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
fetch
✓ import { fetch } from 'iso-web'
✗ import fetch from 'iso-web/fetch'
Named export, not default. Works in Node.js 18+ without polyfill.
EventTarget
✓ import { EventTarget } from 'iso-web'
✗ const { EventTarget } = require('iso-web')
ESM-only since v3. Use dynamic import for CJS.
AbortSignal
✓ import { AbortSignal } from 'iso-web'
✗ import { AbortController } from 'iso-web'
AbortController is not re-exported; use global AbortController.
crypto
✓ import { crypto } from 'iso-web'
✗ import crypto from 'crypto'
Exposes Web Crypto API (SubtleCrypto), not Node's crypto module.
doh
✓ import { doh } from 'iso-web'
✗ import { DOH } from 'iso-web'
All lowercase export name.
Demonstrates usage of fetch, crypto, doh, and EventTarget exports with type safety.
import { fetch, crypto, doh, EventTarget } from 'iso-web';
// Fetch example
async function getData() {
const response = await fetch('https://api.example.com/data');
return response.json();
}
// Crypto example
async function hashPassword(password) {
const encoder = new TextEncoder();
const data = encoder.encode(password);
const hash = await crypto.subtle.digest('SHA-256', data);
return hash;
}
// DoH example
async function resolveDNS(domain) {
const result = await doh.query(domain, 'A');
return result.answers;
}
// EventTarget example
const target = new EventTarget();
target.addEventListener('custom', (e) => console.log(e.detail));
target.dispatchEvent(new CustomEvent('custom', { detail: 'hello' }));
console.log('All examples work cross-platform');
Errors
Common errors & fixes
Cannot find module 'iso-web' or its corresponding type declarations.
TypeScript may not resolve the package types; check tsconfig 'moduleResolution'.
fixSet 'moduleResolution' to 'node16' or 'bundler' in tsconfig.json.
Unsupported private field on AbortSignal.
Using the deprecated AbortSignal export from iso-web in an environment with native AbortSignal.
fixRemove the import and use global AbortSignal.
Failed to execute 'digest' on 'SubtleCrypto': Algorithm: Unrecognized name.
Invalid algorithm name passed to crypto.subtle.digest.
fixUse valid algorithm names like 'SHA-256', 'SHA-384', 'SHA-512'.
Audit
Dependencies
No dependency data recorded yet.