Skip to content

Conversation

@pearmini
Copy link
Collaborator

@pearmini pearmini commented Oct 15, 2025

@yiyujin Jin mentioned some inconsistency with echo and console.log:

//➜ "a"
echo("a", "b", "c");

console.log("a", "b", "c"); // a b c

This is because the actual signature of echo is echo(value, formatOptions). Although you can use string concatenation to achieve the similar result:

//➜ "a b c"
echo("a" + " b" + " c");

But it's inconvenient and also confusing for the user who is familiar with console.log. Also, it uses the built-in stringfy behavior which may work unexpected:

//➜ "array [, 1, 2, 3]" 
echo("array " + [null, 1, 2, 3])

So it's better update the echo signature to echo(...values). In addition to that, we also expose an extra helper function recho.inspect(value, options) for custom formatting:

//➜ "a b c"
echo("a" , "b", "c");

//➜ {                 
//➜   key: [ 1, 2, 3 ]
//➜ }                 
echo(recho.inspect({key: [1, 2, 3]}, {indent: 2}));

//➜ Peter:  Age = 20    
//➜         Height = 180
echo("Peter: ", "Age = 20\nHeight = 180");
  • code
  • docs
  • tests
  • examples

@pearmini pearmini marked this pull request as draft October 15, 2025 15:23
@pearmini pearmini changed the title Remove options paramter for echo Remove options parameter for echo Oct 15, 2025
@pearmini pearmini changed the title Remove options parameter for echo Refactor echo signature to support echo multiple values Oct 15, 2025
@pearmini pearmini force-pushed the echo-mutiple-values branch from 5aea928 to 2431357 Compare October 15, 2025 15:25
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Oct 15, 2025

Deploying recho with  Cloudflare Pages  Cloudflare Pages

Latest commit: 784c0d0
Status: ✅  Deploy successful!
Preview URL: https://c98da9ad.recho.pages.dev
Branch Preview URL: https://echo-mutiple-values.recho.pages.dev

View logs

@pearmini pearmini requested a review from Copilot October 15, 2025 16:40
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the echo function signature to support echoing multiple values in a single call, while maintaining backward compatibility for single-value usage. The key changes include moving inspector options to a dedicated recho.inspect() function and implementing horizontal merging of multiple values.

  • Refactored echo function to accept multiple arguments (...values) instead of (value, options)
  • Added new recho.inspect() function to handle formatting options previously passed to echo
  • Updated all existing code to use recho.inspect() when formatting options are needed

Reviewed Changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
runtime/index.js Core implementation of multi-value echo with horizontal merging logic
runtime/inspect.js New inspector module with formatting functionality
runtime/stdlib.js Export new inspect functions
test/js/echo-multiple-values.js Test cases for multiple value echoing
test/output/echoMultipleValues.js Expected output for multiple value tests
app/docs/*.recho.js Documentation updates showing new API usage
app/examples/*.recho.js Example updates to use new recho.inspect() syntax

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@pearmini pearmini force-pushed the echo-mutiple-values branch from 1bbdb40 to 4a7c633 Compare October 15, 2025 16:41
@pearmini pearmini marked this pull request as ready for review October 15, 2025 16:56
@pearmini pearmini requested a review from chengluyu October 15, 2025 16:56
@pearmini pearmini merged commit 6fe7e34 into main Oct 15, 2025
2 checks passed
@pearmini pearmini deleted the echo-mutiple-values branch October 15, 2025 18:54
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