Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing error: Unexpected token (after computed property name) #989

Closed
patrickroberts opened this issue Sep 18, 2017 · 1 comment

Comments

@patrickroberts
Copy link

commented Sep 18, 2017

function characterRange (minCharacter, maxCharacter) {
  const lower = minCharacter.charCodeAt(0)
  const upper = maxCharacter.charCodeAt(0)

  return Array(upper - lower + 1)
    .fill()
    .map((_, index) => String.fromCharCode(lower + index))
    .join('')
}

const base64 =
  characterRange('A', 'Z') +
  characterRange('a', 'z') +
  characterRange('0', '9') +
  '+/'

const unbase64 = Array.from(base64)
  .reduce((table, character, index) => {
    table[character.charCodeAt(0)] = index
    return table
  }), { ['='.charCodeAt(0)]: 64 })
                             ^ line 21:column 30

Generates an error:

21:30 - Parsing error: Unexpected token 64 (null)

I believe that for some reason standard@10.0.3 fails to parse computed property names, as changing the accumulator object literal of Array#reduce() to any variation of a computed property name causes the same error.

Is this a bug?

@patrickroberts

This comment has been minimized.

Copy link
Author

commented Sep 18, 2017

Nevermind, I just noticed I had an extra closing parenthesis on the same line... sorry to bother.

@lock lock bot locked as resolved and limited conversation to collaborators May 10, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
1 participant
You can’t perform that action at this time.