@edadma/logo 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edadma/logo",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Logo programming language interpreter with React component",
5
5
  "main": "dist/main.js",
6
6
  "module": "dist/main.js",
@@ -7,6 +7,10 @@ import org.scalajs.dom.html
7
7
 
8
8
  import scala.math.Pi
9
9
 
10
+ /** Singleton representing "no value" from commands like print, fd, etc. */
11
+ @JSExportTopLevel("LogoUnit")
12
+ object LogoUnitJS extends js.Object
13
+
10
14
  @js.native
11
15
  trait LogoDrawing extends js.Object:
12
16
  val lines: js.Array[LineData] = js.native
@@ -69,10 +73,13 @@ class LogoJS(canvas: html.Canvas) extends js.Object:
69
73
  logo.interp(program)
70
74
  if !autoRender then render()
71
75
 
72
- /** Execute a single command */
73
- def execute(command: String): Unit =
74
- logo.interp(command)
76
+ /** Execute a single command, returns result (undefined for commands with no output) */
77
+ def execute(command: String): js.UndefOr[String] =
78
+ val result = logo.interp(command)
75
79
  if !autoRender then render()
80
+ result match
81
+ case LogoUnit => js.undefined
82
+ case v => v.toString
76
83
 
77
84
  /** Clear the screen and reset turtle */
78
85
  def clear(): Unit =