smart-home-engine 1.18.1 → 1.18.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": "smart-home-engine",
3
- "version": "1.18.1",
3
+ "version": "1.18.2",
4
4
  "description": "Node.js based script runner for use in MQTT based Smart Home environments",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/index.js CHANGED
@@ -1005,12 +1005,14 @@ function runScript(script, name, _origin) {
1005
1005
 
1006
1006
  const Sandbox = {
1007
1007
  setTimeout: (fn, delay, ...args) => {
1008
- const id = setTimeout(fn, delay, ...args);
1008
+ const wrapped = args.length ? () => fn(...args) : fn;
1009
+ const id = setTimeout(() => _dispatch(name, wrapped), delay);
1009
1010
  _myTimers.add(id);
1010
1011
  return id;
1011
1012
  },
1012
1013
  setInterval: (fn, delay, ...args) => {
1013
- const id = setInterval(fn, delay, ...args);
1014
+ const wrapped = args.length ? () => fn(...args) : fn;
1015
+ const id = setInterval(() => _dispatch(name, wrapped), delay);
1014
1016
  _myTimers.add(id);
1015
1017
  return id;
1016
1018
  },
@@ -1084,7 +1086,8 @@ function runScript(script, name, _origin) {
1084
1086
  // she.setTimeout / she.clearTimeout — tracked versions for use by stdlib and
1085
1087
  // sandbox modules that don't have direct access to the Sandbox context.
1086
1088
  she.setTimeout = (fn, delay, ...args) => {
1087
- const id = setTimeout(fn, delay, ...args);
1089
+ const wrapped = args.length ? () => fn(...args) : fn;
1090
+ const id = setTimeout(() => _dispatch(name, wrapped), delay);
1088
1091
  _myTimers.add(id);
1089
1092
  return id;
1090
1093
  };