Skip to content

ops/:into

refinement - narrows selection from a container to its children

clojure
(:into val?)

Where:

  1. val: selector to filter child values *

Behavior

  • Without an argument, selects whatever value(s) exist at the position (e.g., all array elements, all object properties).
  • With an argument, selects only child values that match the nested selector.
  • Commonly used to shift focus from a parent construct to its contents (e.g., from array to elements, from call to arguments).

Examples

Extract all import specifiers from a specific module.

clojure
(import react (:into))

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

typescript
import { useState, useEffect } from 'react'
import $ from 'jquery'
import { render } from 'react'

Find object property keys to rename them.

clojure
(obj (prop (:into oldKey)))

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

typescript
const config = { oldKey: 1, newKey: 2 }
const settings = { oldKey: 3 }

Locate array elements that are function expressions for refactoring.

clojure
(arr (el _ (:into (fun))))

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

typescript
const callbacks = [() => {}, function() {}, processData]
const numbers = [1, 2, 3]

Extract all JSX attribute values for sanitization audit.

clojure
(jsx div (attr _ (:into)))

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

typescript
<div className="box" onClick={handler} />
<span title="text" />

Arguments

val

inherit

Copyright © 2022-present Semantic Works, Inc.