rsnext/examples/with-web-worker/worker.ts
Henrik Wenz cc7fd2c247
chore: refactor with-web-worker example (#40844)
## Changes

- Updated dependencies
- Migrated to typescript
- Removed `div` in favour of Fragment
- Replaces `var` with `let` since we don't need global hoisting here

## Documentation / Examples

- [x] Make sure the linting passes by running `pnpm lint`
- [x] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
2022-09-23 14:08:30 -07:00

6 lines
197 B
TypeScript

// This is a module worker, so we can use imports (in the browser too!)
import pi from './utils/pi'
addEventListener('message', (event: MessageEvent<number>) => {
postMessage(pi(event.data))
})