Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

example: add deno console #3428

Closed
wants to merge 1 commit into from
Closed

Conversation

ahaoboy
Copy link
Contributor

@ahaoboy ahaoboy commented Oct 27, 2023

This Pull Request implements the console.log function using Deno.

This is an incomplete implementation, but it covers most use cases. I don't know how to implement some complex functions like the getProxyDetails, getPromiseDetails in Boa, so the output of promises is always 'Promise.

boa_examples/scripts/deno/01_console.js copy from https://github.com/denoland/deno/blob/main/ext/console/01_console.js
boa_examples/scripts/deno/00_core.js is a polyfill for deno.primordials

console.log(1, 'a', false, true, Promise.resolve(1), Symbol(1))
console.log(new Set([1, 2, 3, 4]))
console.log(new Map([[1, 2], ['a', 'b'], [false, true]]))
let a = [1]
a[1] = a;
console.log(a)
let b = {a: [1,2,'a']}
b['b'] = b;
console.log(b)
console.log(new Error("console error"))

deno.console

image

boa_runtime::Console;

image

@ahaoboy ahaoboy force-pushed the example/deno-console branch from e98fab1 to f868128 Compare October 27, 2023 09:37
@ahaoboy ahaoboy force-pushed the example/deno-console branch from f868128 to 6b3ea3d Compare October 27, 2023 09:48
@codecov
Copy link

codecov bot commented Oct 27, 2023

Codecov Report

Attention: 16 lines in your changes are missing coverage. Please review.

Comparison is base (fee4048) 45.40% compared to head (6b3ea3d) 45.39%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3428      +/-   ##
==========================================
- Coverage   45.40%   45.39%   -0.02%     
==========================================
  Files         483      484       +1     
  Lines       49790    49806      +16     
==========================================
  Hits        22609    22609              
- Misses      27181    27197      +16     
Files Coverage Δ
boa_examples/src/bin/deno_console.rs 0.00% <0.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jedel1043
Copy link
Member

Uhhhh, I don't think this should be an example. This is a fully fledged implementation of console.log, and examples are supposed to explain how to use a certain API in a simple, well documented way.

That being said, maybe we could reuse this to prettify our console.log implementation?

@ahaoboy
Copy link
Contributor Author

ahaoboy commented Nov 14, 2023

Uhhhh, I don't think this should be an example. This is a fully fledged implementation of console.log, and examples are supposed to explain how to use a certain API in a simple, well documented way.

That being said, maybe we could reuse this to prettify our console.log implementation?

As an example, it's indeed a bit too extensive 😂. Originally, I intended to implement the complete console.log function purely in rust, but it's too complex. If you think that boa can reuse this log function, then I'll open a new PR to replace boa_runtime\src\console.

@jedel1043
Copy link
Member

If you think that boa can reuse this log function, then I'll open a new PR to replace boa_runtime\src\console.

That would be wonderful!

@jedel1043
Copy link
Member

Closing in favour of #3468

@jedel1043 jedel1043 closed this Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants