|  | 
| 13 | 13 | 
 | 
| 14 | 14 | /** | 
| 15 | 15 |  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 
| 16 |  | - *                         echo(value[, options]) | 
|  | 16 | + *                         echo(...values) | 
| 17 | 17 |  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 
| 18 | 18 |  * | 
| 19 |  | - * Echos a value inline with your code as comments. | 
|  | 19 | + * Echos one or more values inline with your code as comments. If only one | 
|  | 20 | + * value is provided, return the value itself. If multiple values are provided, | 
|  | 21 | + * return all the values as an array. | 
| 20 | 22 |  * | 
| 21 |  | - * @param {any} value - The value to echo. | 
| 22 |  | - * @param {Object} [options] - The options to format the output. | 
| 23 |  | - * @param {string} [options.quote="double"] - The quote style of the output. | 
| 24 |  | - * @param {number} [options.indent=null] - The indentation of the output. | 
| 25 |  | - * @param {number} [options.limit=200] - The limit of the output. | 
| 26 |  | - * @returns {any} The value. | 
|  | 23 | + * @param {...any} values - The values to echo. | 
|  | 24 | + * @returns {any} The values if multiple values are provided, or the single value. | 
| 27 | 25 |  */ | 
| 28 | 26 | 
 | 
| 29 | 27 | //➜ "Hello, World!" | 
| 30 | 28 | echo("Hello, World!"); | 
| 31 | 29 | 
 | 
| 32 |  | -//➜ 'Hello, World!' | 
| 33 |  | -echo("Hello, World!", {quote: "single"}); | 
|  | 30 | +//➜ 1 2 3 | 
|  | 31 | +echo(1, 2, 3); | 
|  | 32 | + | 
|  | 33 | +//➜ Peter:  Age = 20 | 
|  | 34 | +//➜         Height = 180 | 
|  | 35 | +echo("Peter: ", "Age = 20\nHeight = 180"); | 
|  | 36 | + | 
|  | 37 | +const a = echo(1 + 2); | 
| 34 | 38 | 
 | 
| 35 |  | -//➜ Hello, World! | 
| 36 |  | -echo("Hello, World!", {quote: false}); | 
|  | 39 | +//➜ 3 | 
|  | 40 | +echo(a); | 
| 37 | 41 | 
 | 
| 38 |  | -//➜ { | 
| 39 |  | -//➜   a: 1, | 
| 40 |  | -//➜   b: 2 | 
| 41 |  | -//➜ } | 
| 42 |  | -echo({a: 1, b: 2}, {indent: 2}); | 
|  | 42 | +const numbers = echo(1, 2, 3); | 
| 43 | 43 | 
 | 
| 44 |  | -//➜ [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … | 
| 45 |  | -echo(new Array(100).fill(0), {limit: 80}); | 
|  | 44 | +//➜ [ 1, 2, 3 ] | 
|  | 45 | +echo(numbers); | 
|  | 46 | + | 
|  | 47 | +/** | 
|  | 48 | + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 
|  | 49 | + *                      recho.inspect(value[, options]) | 
|  | 50 | + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 
|  | 51 | + * | 
|  | 52 | + * Formats a value for inspection with customizable options. | 
|  | 53 | + * | 
|  | 54 | + * @param {any} value - The value to inspect. | 
|  | 55 | + * @param {Object} [options] - The options to format the output. | 
|  | 56 | + * @param {string} [options.quote="double"] - The quote style of the output ("single", "double", or false). | 
|  | 57 | + * @param {number} [options.indent=null] - The indentation of the output (null, "\t", or a positive integer). | 
|  | 58 | + * @param {number} [options.limit=200] - The character limit of the output. | 
|  | 59 | + * @returns {string} The formatted string representation of the value. | 
|  | 60 | + */ | 
| 46 | 61 | 
 | 
| 47 | 62 | /** | 
| 48 | 63 |  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 
| @@ -138,7 +153,7 @@ const Noise = recho.require("perlin-noise-3d"); | 
| 138 | 153 |   for (let i = 0; i < 100; i++) { | 
| 139 | 154 |     values.push(noise.get(i / 100, i / 100, i / 100)); | 
| 140 | 155 |   } | 
| 141 |  | -  echo(values, {limit: 80}); | 
|  | 156 | +  echo(recho.inspect(values, {limit: 80})); | 
| 142 | 157 | } | 
| 143 | 158 | 
 | 
| 144 | 159 | const d3 = recho.require("d3-array", "d3-random"); | 
| @@ -166,8 +181,8 @@ const isVisible = recho.toggle(false); | 
| 166 | 181 | //➜ "The button is enabled." | 
| 167 | 182 | //➜ "The button is hidden." | 
| 168 | 183 | { | 
| 169 |  | -  echo(`The button is ${isEnabled ? 'enabled' : 'disabled'}.`); | 
| 170 |  | -  echo(`The button is ${isVisible ? 'visible' : 'hidden'}.`); | 
|  | 184 | +  echo(`The button is ${isEnabled ? "enabled" : "disabled"}.`); | 
|  | 185 | +  echo(`The button is ${isVisible ? "visible" : "hidden"}.`); | 
| 171 | 186 | } | 
| 172 | 187 | 
 | 
| 173 | 188 | /** | 
| @@ -246,6 +261,6 @@ const temperature = recho.number(24, {min: -10, max: 40, step: 0.5}); | 
| 246 | 261 | 
 | 
| 247 | 262 | //➜ "The room temperature is 24 °C (75.2 °F)." | 
| 248 | 263 | { | 
| 249 |  | -  const fahrenheit = (temperature * 9 / 5) + 32; | 
|  | 264 | +  const fahrenheit = (temperature * 9) / 5 + 32; | 
| 250 | 265 |   echo(`The room temperature is ${temperature} °C (${fahrenheit} °F).`); | 
| 251 | 266 | } | 
0 commit comments