Skip to content

Commit

Permalink
feat(node): add console module (#892)
Browse files Browse the repository at this point in the history
This just exports the `console` object.

Note that Deno's console doesn't have all the same methods as Node's, so this isn't a perfect polyfill. Node has these extra properties:
- `Console`
- `context`
- `profile`
- `profileEnd`
- `timeStamp`
  • Loading branch information
Liamolucko authored May 1, 2021
1 parent a0984a6 commit ebafcb6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ deno standard library as it's a compatibility module.
- [x] buffer
- [x] child_process _partly_
- [ ] cluster
- [ ] console
- [x] console _partly_
- [x] constants _partly_
- [x] crypto _partly_
- [ ] dgram
Expand Down
23 changes: 23 additions & 0 deletions node/console.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export default console;

export const {
assert,
clear,
count,
countReset,
debug,
dir,
dirxml,
error,
group,
groupCollapsed,
groupEnd,
info,
log,
table,
time,
timeEnd,
timeLog,
trace,
warn,
} = console;
2 changes: 2 additions & 0 deletions node/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import "./global.ts";
import nodeAssert from "./assert.ts";
import nodeBuffer from "./buffer.ts";
import nodeCrypto from "./crypto.ts";
import nodeConsole from "./console.ts";
import nodeConstants from "./constants.ts";
import nodeChildProcess from "./child_process.ts";
import nodeEvents from "./events.ts";
Expand Down Expand Up @@ -637,6 +638,7 @@ nativeModulePolyfill.set("timers", createNativeModule("timers", nodeTimers));
nativeModulePolyfill.set("tty", createNativeModule("tty", nodeTty));
nativeModulePolyfill.set("url", createNativeModule("url", nodeUrl));
nativeModulePolyfill.set("util", createNativeModule("util", nodeUtil));
nativeModulePolyfill.set("console", createNativeModule("console", nodeConsole));

function loadNativeModule(
_filename: string,
Expand Down

0 comments on commit ebafcb6

Please sign in to comment.