@shaderfrog/core 2.0.1 → 3.0.1

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/util/math.js ADDED
@@ -0,0 +1,6 @@
1
+ export var randomBetween = function (min, max) {
2
+ return Math.random() * (max - min) + min;
3
+ };
4
+ export var range = function (start, end) {
5
+ return Array.from({ length: end - start }, function (_, i) { return i + start; });
6
+ };
@@ -34,7 +34,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
34
34
  }
35
35
  return to.concat(ar || Array.prototype.slice.call(from));
36
36
  };
37
- import { makeFnStatement } from './ast';
37
+ import { makeFnStatement, makeLiteral } from './ast';
38
38
  var log = function () {
39
39
  var _a;
40
40
  var args = [];
@@ -88,17 +88,14 @@ export var addFnStmtWithIndent = function (fnBody, newNode) {
88
88
  return __spreadArray(__spreadArray([], __read(statements), false), [
89
89
  // This simple hack is way easier than trying to modify the function body
90
90
  // opening brace and/or the previous statement
91
- { type: 'literal', literal: '', whitespace: indent },
91
+ makeLiteral('', indent),
92
92
  addWs(newNode, "\n"),
93
93
  ], false);
94
94
  };
95
95
  export var unshiftFnStmtWithIndent = function (fnBody, newNode) {
96
96
  var statements = fnBody.body.statements;
97
97
  var indent = guessFnIndent(fnBody);
98
- return __spreadArray([
99
- addWs(newNode, "\n"),
100
- { type: 'literal', literal: '', whitespace: indent }
101
- ], __read(statements), false);
98
+ return __spreadArray([addWs(newNode, "\n"), makeLiteral('', indent)], __read(statements), false);
102
99
  };
103
100
  export var spliceFnStmtWithIndent = function (fnBody, index) {
104
101
  var newNodes = [];
@@ -108,10 +105,6 @@ export var spliceFnStmtWithIndent = function (fnBody, index) {
108
105
  var statements = fnBody.body.statements;
109
106
  var indent = guessFnIndent(fnBody);
110
107
  return __spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(statements.slice(0, index)), false), __read(newNodes.map(function (n) { return addWs(n, "\n"); })), false), [
111
- {
112
- type: 'literal',
113
- literal: '',
114
- whitespace: indent,
115
- }
108
+ makeLiteral('', indent)
116
109
  ], false), __read(statements.slice(index)), false);
117
110
  };