A JavaScript-interop library for ClojureScript.
A JavaScript-interop library for ClojureScript.
(apply obj k args)
(apply obj k arg-array)
Apply function k
of obj
, which is bound as this
.
(j/apply o :someFunction #js [arg1 arg2])
(j/apply o .-someFunction #js [arg1 arg2])
Apply function `k` of `obj`, which is bound as `this`. ``` (j/apply o :someFunction #js [arg1 arg2]) (j/apply o .-someFunction #js [arg1 arg2]) ```
(assoc! obj & keyvals)
Sets key-value pairs on obj
, returns obj
.
(j/assoc! o :x 10)
(j/assoc! o .-x 10)
Sets key-value pairs on `obj`, returns `obj`. ``` (j/assoc! o :x 10) (j/assoc! o .-x 10) ```
(assoc-in! obj ks v)
Mutates the value in a nested object structure, where ks is a sequence of keys and v is the new value. If any levels do not exist, objects will be created.
(j/assoc-in! o [:x :y] 10)
(j/assoc-in! o [.-x .-y] 10)
Mutates the value in a nested object structure, where ks is a sequence of keys and v is the new value. If any levels do not exist, objects will be created. ``` (j/assoc-in! o [:x :y] 10) (j/assoc-in! o [.-x .-y] 10) ```
(call obj k & args)
Call function k
of obj
, which is bound as this
.
(j/call o :someFunction arg1 arg2)
(j/call o .-someFunction arg1 arg2)
Call function `k` of `obj`, which is bound as `this`. ``` (j/call o :someFunction arg1 arg2) (j/call o .-someFunction arg1 arg2) ```
(contains? obj k)
Returns true if obj
contains k
.
(j/contains? o :k)
(j/contains? o .-k)
Returns true if `obj` contains `k`. ``` (j/contains? o :k) (j/contains? o .-k) ```
(get obj k)
(get obj k not-found)
Returns the value mapped to key, not-found or nil if key not present.
(j/get o :k)
(j/get o .-k)
Returns the value mapped to key, not-found or nil if key not present. ``` (j/get o :k) (j/get o .-k) ```
(get-in obj ks)
(get-in obj ks not-found)
Returns the value in a nested object structure, where ks is a sequence of keys. Returns nil if the key is not present, or the not-found value if supplied.
(j/get-in o [:x :y] :fallback-value)
(j/get-in o [.-x .-y] :fallback-value)
Returns the value in a nested object structure, where ks is a sequence of keys. Returns nil if the key is not present, or the not-found value if supplied. ``` (j/get-in o [:x :y] :fallback-value) (j/get-in o [.-x .-y] :fallback-value) ```
(lookup obj)
Wraps obj
with an ILookup implementation, to support reading/destructuring. Does not support renamable keys.
(let [{:keys [a b c]} (j/lookup o)]
...)
Wraps `obj` with an ILookup implementation, to support reading/destructuring. Does not support renamable keys. ``` (let [{:keys [a b c]} (j/lookup o)] ...) ```
(obj & keyvals)
Create JavaScript object from an even number arguments representing interleaved keys and values.
(obj :a 1 :b 2 .-c 3 .-d 4)
Create JavaScript object from an even number arguments representing interleaved keys and values. ``` (obj :a 1 :b 2 .-c 3 .-d 4) ```
(push! a v)
(push! array x)
Appends v
to array
and returns the mutated array.
(j/push! arr 10)
Appends `v` to `array` and returns the mutated array. ``` (j/push! arr 10) ```
(select-keys obj ks)
Returns an object containing only those entries in o
whose key is in ks
.
(j/select-keys o [:a :b :c])
(j/select-keys o [.-a .-b .-c])
Returns an object containing only those entries in `o` whose key is in `ks`. ``` (j/select-keys o [:a :b :c]) (j/select-keys o [.-a .-b .-c]) ```
(unshift! a v)
(unshift! array x)
Prepends v
to a
and returns the mutated array.
(j/unshift! arr 10)
Prepends `v` to `a` and returns the mutated array. ``` (j/unshift! arr 10) ```
(update! obj k f & args)
'Updates' a value in a JavaScript object, where k is a key and f is a function that will take the old value and any supplied args and return the new value, which replaces the old value. If the key does not exist, nil is passed as the old value.
(j/update! o :a + 10)
(j/update! o .-a + 10)
'Updates' a value in a JavaScript object, where k is a key and f is a function that will take the old value and any supplied args and return the new value, which replaces the old value. If the key does not exist, nil is passed as the old value. ``` (j/update! o :a + 10) (j/update! o .-a + 10) ```
(update-in! obj ks f & args)
'Updates' a value in a nested object structure, where ks is a sequence of keys and f is a function that will take the old value and any supplied args and return the new value, mutating the nested structure. If any levels do not exist, objects will be created.
(j/update-in! o [:x :y] + 10)
(j/update-in! o [.-x .-y] + 10)
'Updates' a value in a nested object structure, where ks is a sequence of keys and f is a function that will take the old value and any supplied args and return the new value, mutating the nested structure. If any levels do not exist, objects will be created. ``` (j/update-in! o [:x :y] + 10) (j/update-in! o [.-x .-y] + 10) ```
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close