zfedoran / dcraw.js

Decode or convert RAW camera images using JavaScript
GNU General Public License v2.0
76 stars 14 forks source link

Cannot assign to "args" because it is a constant #6

Closed thril closed 9 months ago

thril commented 2 years ago

Problem

In the generated lib output (dcraw/dist/dcraw.js), the const variable args is reassigned, which is causing an error (and preventing a valid build). The beautified output below shows this:

const args = [];
if (options) {
  ...
  for (var prop in options) {
    const val = options[prop];
    if (val !== undefined) {
      ...
      if (prop.match(/[A r C k S n H t o b g q m s]/)) {
        args = args.concat(val.toString().split(/\s/)) // <-------- reassignment
      }

Solution

The creation of the variable should use the let identifier so that it can be reassigned.