Skip to content

(mem) - JavaScript

property access

clojure
(mem prop? obj?)

Where:

  1. prop: property name or computed key (the b in a.b or the expr in a[expr]) *
  2. obj: value being accessed (the a in a.b) *

Matching:

  1. dot access, e.g. a.b
  2. computed access, e.g. a[expr]
  3. private fields, e.g. a.#field

Examples

Remove a deprecated debug flag by finding reads of config.debug.

clojure
(mem debug config)

Selects in lines { 1 } but not in { 2, 3 }:

typescript
if (config.debug) { log("debug") }
if (config.verbose) { log("debug") }
if (settings.debug) { log("debug") }

Migrate storage keys by finding direct access to localStorage["token"].

clojure
(mem (comp (str "token")) localStorage)

Selects in lines { 1 } but not in { 2, 3 }:

typescript
const token = localStorage["token"]
const session = localStorage["session"]
const token2 = sessionStorage["token"]

Audit inline styling by finding uses of the style property.

clojure
(mem style)

Selects in lines { 1, 2 } but not in { 3 }:

typescript
button.style.color = "red"
card.style = {}
styles.theme = "dark"

Arguments

prop

obj

Copyright © 2022-present Semantic Works, Inc.