From b3a97bf461f4986aaf50ef99c7afa1b1b1836c5e Mon Sep 17 00:00:00 2001 From: Andreas Linde <42185+DerAndereAndi@users.noreply.github.com> Date: Tue, 7 Sep 2021 20:04:47 +0200 Subject: [PATCH] JS: add underscore javascript lib (#1502) This change is required to actually use the underscore javascript library, as documented here: https://github.com/robertkrimen/otto#underscore --- README.md | 2 +- provider/javascript/init.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d850002ab..eb9687c8e 100644 --- a/README.md +++ b/README.md @@ -523,7 +523,7 @@ All possible values can be found as const [here](https://gitlab.com/bboehmke/sun ### Javascript (read/write) -EVCC includes a bundled Javascript interpreter with Underscore.js library installed. The `js` plugin is able to execute Javascript code from the `script` tag. Useful for quick prototyping: +EVCC includes a bundled Javascript interpreter with Underscore.js library installed, which is directly accessible via `_.` e.g. `_.random(0,5)`. The `js` plugin is able to execute Javascript code from the `script` tag. Useful for quick prototyping: ```yaml source: js diff --git a/provider/javascript/init.go b/provider/javascript/init.go index acff54371..81ba1419a 100644 --- a/provider/javascript/init.go +++ b/provider/javascript/init.go @@ -3,6 +3,7 @@ package javascript import ( "github.com/evcc-io/evcc/util" "github.com/robertkrimen/otto" + _ "github.com/robertkrimen/otto/underscore" ) // Configure initializes JS VMs