2019-11-12 21:51:14 +01:00
|
|
|
# Deno Node compatibility
|
|
|
|
|
|
|
|
This module is meant to have a compatibility layer for the
|
2020-01-15 20:13:12 +01:00
|
|
|
[NodeJS standard library](https://nodejs.org/docs/latest-v12.x/api/).
|
2019-11-12 21:51:14 +01:00
|
|
|
|
2020-01-15 20:13:12 +01:00
|
|
|
**Warning**: Any function of this module should not be referred anywhere in the
|
2020-05-11 21:13:06 +08:00
|
|
|
deno standard library as it's a compatibility module.
|
2019-11-19 13:44:59 -08:00
|
|
|
|
2020-01-15 20:13:12 +01:00
|
|
|
## Supported Builtins
|
|
|
|
|
|
|
|
- [ ] assert
|
2020-06-13 08:58:08 -05:00
|
|
|
- [x] buffer
|
2020-01-15 20:13:12 +01:00
|
|
|
- [ ] child_process
|
|
|
|
- [ ] cluster
|
|
|
|
- [ ] console
|
|
|
|
- [ ] crypto
|
|
|
|
- [ ] dgram
|
|
|
|
- [ ] dns
|
2020-02-10 23:19:48 +00:00
|
|
|
- [x] events
|
2020-01-15 20:13:12 +01:00
|
|
|
- [x] fs _partly_
|
|
|
|
- [ ] http
|
|
|
|
- [ ] http2
|
|
|
|
- [ ] https
|
|
|
|
- [x] module
|
|
|
|
- [ ] net
|
2020-01-30 01:57:29 +00:00
|
|
|
- [x] os _partly_
|
2020-01-15 20:13:12 +01:00
|
|
|
- [x] path
|
|
|
|
- [ ] perf_hooks
|
|
|
|
- [x] process _partly_
|
2020-03-14 21:43:49 +01:00
|
|
|
- [x] querystring
|
2020-01-15 20:13:12 +01:00
|
|
|
- [ ] readline
|
|
|
|
- [ ] repl
|
|
|
|
- [ ] stream
|
|
|
|
- [ ] string_decoder
|
|
|
|
- [ ] sys
|
|
|
|
- [x] timers
|
|
|
|
- [ ] tls
|
|
|
|
- [ ] tty
|
|
|
|
- [ ] url
|
|
|
|
- [x] util _partly_
|
|
|
|
- [ ] ~~v8~~ _can't implement_
|
|
|
|
- [ ] vm
|
|
|
|
- [ ] worker_threads
|
|
|
|
- [ ] zlib
|
|
|
|
|
|
|
|
* [x] node globals _partly_
|
|
|
|
|
|
|
|
### Deprecated
|
|
|
|
|
|
|
|
These builtins are deprecated in NodeJS v13 and will probably not be polyfilled:
|
|
|
|
|
|
|
|
- constants
|
|
|
|
- domain
|
|
|
|
- freelist
|
|
|
|
- punycode
|
|
|
|
|
|
|
|
### Experimental
|
|
|
|
|
|
|
|
These builtins are experimental in NodeJS v13 and will not be polyfilled until
|
|
|
|
they are stable:
|
|
|
|
|
|
|
|
- async_hooks
|
|
|
|
- inspector
|
|
|
|
- policies
|
|
|
|
- report
|
|
|
|
- trace_events
|
|
|
|
- wasi
|
|
|
|
|
2019-11-19 13:44:59 -08:00
|
|
|
## CommonJS Module Loading
|
|
|
|
|
|
|
|
`createRequire(...)` is provided to create a `require` function for loading CJS
|
2020-04-30 17:00:02 +03:00
|
|
|
modules. It also sets supported globals.
|
2019-11-19 13:44:59 -08:00
|
|
|
|
|
|
|
```ts
|
2020-10-04 21:18:36 +09:00
|
|
|
import { createRequire } from "https://deno.land/std@$STD_VERSION/node/module.ts";
|
2019-11-19 13:44:59 -08:00
|
|
|
|
2020-04-20 21:30:52 +03:00
|
|
|
const require = createRequire(import.meta.url);
|
2019-11-19 13:44:59 -08:00
|
|
|
// Loads native module polyfill.
|
2020-04-20 21:30:52 +03:00
|
|
|
const path = require("path");
|
2019-11-19 13:44:59 -08:00
|
|
|
// Loads extensionless module.
|
2020-04-20 21:30:52 +03:00
|
|
|
const cjsModule = require("./my_mod");
|
2019-11-19 13:44:59 -08:00
|
|
|
// Visits node_modules.
|
2020-04-20 21:30:52 +03:00
|
|
|
const leftPad = require("left-pad");
|
2019-11-19 13:44:59 -08:00
|
|
|
```
|