acorn-has-side-effect
A simple module to check whether an expression has any side effects. This is aimed at being useful for writing optimising JavaScript compilers.
Installation
npm install acorn-has-side-effect
Usage
'use strict'; var assert = ;var hasSideEffect = ; ;;;;;;;;;; console;
It assumes that property-access and variable-access should not count as a side effect, even though they technically could be because of property accessors and reference errors etc. For most purposes this should be fine, but it could go wrong in some rare circumstances. You can force it to treat even these nodes as having side effects by passing {strict: true}
for the options.
If you already have an AST, you can pass an acorn AST instead of a string for the source code.
License
MIT