Skip to content

Selecting String values

String literals can appear in different statements and locations in JavaScript programs, and when you want to be thorough in your search and don't mind extra noise, (str+) selects for you all instances of the string literal that can be found.

(str+ [value]) is shorthand for:

clojure
(:or (str \1)
     (tpl* \1)
     (comp (str \1))
     (comp (:ref (str \1)))
     (obj (prop (:into (str \1)))))

Which is to say, in English, find me:

  1. a string of that value
  2. a template literal whose contents evaluate to that value
  3. a string of that value placed in a computed property
  4. a reference to a string of that value placed in a computed property
  5. an object whose property is a string of that value

And in JavaScript, assuming we search for (str+ "foo"):

javascript
"foo"
^^^^^
`foo`
^^^^^
`f` + "oo"
^^^^^^^^^^
this["foo"]
     ^^^^^
let bar = { "foo": 1 }
            ^^^^^
let foo_ref = "foo"
              ^^^^^
let bax = { [foo_ref]: 1 }
             ^^^^^^^

Copyright © 2022-present Semantic Works, Inc.