Skip to content

ops/:and

logical AND - matches when all nested selectors match (intersection)

clojure
(:and selector [selector...])

Where:

  1. selector: selectors that must all match *

Examples

Find objects with required fields but lacking optional ones.

clojure
(obj (:and (prop host) (prop port) (:not (prop timeout))))

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

typescript
const config1 = { host: 'localhost', port: 3000 }
const config2 = { host: 'localhost', port: 3000, timeout: 5000 }
const config3 = { host: 'localhost' }

Locate function calls with specific argument types at multiple positions.

clojure
(call fetch (:and (arg 1 (str)) (arg 2 (obj (prop method)))))

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

typescript
fetch('/api', { method: 'POST' })
fetch('/api', {})
fetch('/api')

Find arrays containing both numbers and strings.

clojure
(arr (:and (el _ (num)) (el _ (str))))

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

typescript
const mixed = [1, 'foo', 2]
const numbers = [1, 2, 3]
const strings = ['foo', 'bar']

Arguments

selector

inherit

Copyright © 2022-present Semantic Works, Inc.