Comparing version 1.0.3 to 1.0.4
# CHANGELOG | ||
## 1.0.4 | ||
- new method: typeofOperatorReduction | ||
## 1.0.3 | ||
@@ -4,0 +8,0 @@ |
@@ -6,2 +6,3 @@ const binaryExpressionReduction = require('./src/binaryExpressionReduction') | ||
const ternaryOperatorReduction = require('./src/ternaryOperatorReduction') | ||
const typeofOperatorReduction = require('./src/typeofOperatorReduction') | ||
@@ -13,3 +14,4 @@ module.exports = { | ||
logicalExpressionReduction, | ||
ternaryOperatorReduction | ||
ternaryOperatorReduction, | ||
typeofOperatorReduction | ||
} |
{ | ||
"name": "astoptech", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "abstract syntax tree optimization techniques", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "node src/binaryExpressionReduction.spec.js && node src/ifStatementRemoval.spec.js && node src/negationOperatorRemoval.spec.js && node src/logicalExpressionReduction.spec.js && node src/ternaryOperatorReduction.spec.js", | ||
"test": "node src/binaryExpressionReduction.spec.js && node src/ifStatementRemoval.spec.js && node src/negationOperatorRemoval.spec.js && node src/logicalExpressionReduction.spec.js && node src/ternaryOperatorReduction.spec.js && node src/typeofOperatorReduction.spec.js", | ||
"lint": "standard" | ||
@@ -9,0 +9,0 @@ }, |
@@ -296,1 +296,36 @@ # astoptech | ||
``` | ||
### typeofOperatorReduction | ||
```js | ||
const foo = typeof "bar" | ||
``` | ||
It's possible to determine the type of some variables during analysis. | ||
```js | ||
const foo = "string" | ||
``` | ||
The tree would be translated from: | ||
```json | ||
{ | ||
"type": "UnaryExpression", | ||
"operator": "typeof", | ||
"prefix": true, | ||
"argument": { | ||
"type": "Literal", | ||
"value": "foo" | ||
} | ||
} | ||
``` | ||
To: | ||
```json | ||
{ | ||
"type": "Literal", | ||
"value": "string" | ||
} | ||
``` |
27002
18
393
331