Skip to content

Quirk with LiveScript's dash-to-camelCase conversion in cursor paths #81

Description

@chrisvfritz
# Given a cursor where a key is defined with dashes
data = arch.cursor do
  name-with-dashes: 'value'

# Trying to grab the name using a string with dashes will not work, because 
# although non-literal object keys are transformed to camelCase in LiveScript, 
# dashes in string literals are not
data.get \name-with-dashes .deref! # => null

# To correctly find the name, you have to use the camelCased string that 
# LiveScript converts the key to:
data.get \nameWithDashes .deref! # => "value"

This isn't technically a bug - just how LiveScript works. But I can see a lot of people, especially those new to LiveScript (which may even be most people using LiveScript in Arch), tripping over it. I think a good solution might be to always camelCase the string passed to get unless a non-null value exists for the non-camelCased version. Thoughts?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions