glsl-transpiler
Advanced tools
Comparing version
@@ -47,22 +47,3 @@ 'use strict' | ||
/** | ||
* Check if expression is protected by parentheses | ||
*/ | ||
function isBraced (exp) { | ||
if (/\s/.test(exp)) { | ||
// a + b | ||
if (exp[0] !== '(') return false; | ||
var level = 1; | ||
var len = exp.length; | ||
for (let i = 1; i < len - 1; i++) { | ||
if (exp[i] === '(') level++; | ||
else if (exp[i] === ')') level--; | ||
// (a + b) * c + d | ||
if (level === 0) return false; | ||
} | ||
} | ||
return true; | ||
} | ||
/** | ||
@@ -310,3 +291,3 @@ * Return rendered operation | ||
if (operator != '+' && operator != '-') { | ||
if (!isBraced(left)) opResult += '(' + left + ')' | ||
if (/\s/.test(left) && !(left[0] == '(' && left[left.length - 1] == ')')) opResult += '(' + left + ')' | ||
else opResult += left | ||
@@ -319,3 +300,3 @@ } | ||
if (operator != '+' && operator != '-') { | ||
if (!isBraced(right)) opResult += '(' + right + ')' | ||
if (/\s/.test(right) && !(right[0] == '(' && right[right.length - 1] == ')')) opResult += '(' + right + ')' | ||
else opResult += right | ||
@@ -322,0 +303,0 @@ } |
{ | ||
"name": "glsl-transpiler", | ||
"version": "1.7.1", | ||
"version": "1.7.2", | ||
"description": "Transpile GLSL to JS", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
99061
-0.29%2988
-0.6%