Liking cljdoc? Tell your friends :D

clj-assorted-utils.util

Utility and helper functions

Utility and helper functions
raw docstring

add-shutdown-hookclj

(add-shutdown-hook f)

Adds a shutdown hook that will be executed when the JVM is shutdown. The supplied function f will be called when the JVM shuts down. Please note: when using multiple hooks, there is no guarantee with respect to the order in which the hooks will be executed.

Adds a shutdown hook that will be executed when the JVM is shutdown.
The supplied function f will be called when the JVM shuts down.
Please note: when using multiple hooks, there is no guarantee with
respect to the order in which the hooks will be executed.
sourceraw docstring

boolean-array-typeclj

source

byte-array-typeclj

source

byte-seq-to-intclj

(byte-seq-to-int byte-seq)

Convert the byte sequence byte-seq to an integer.

Convert the byte sequence byte-seq to an integer.
sourceraw docstring

change-int-in-byte-vectorclj

(change-int-in-byte-vector v n f)

In the given vector v, change the byte representation of an integer by applying function f.

In the given vector v, change the byte representation of an integer by applying function f.
sourceraw docstring

char-array-typeclj

source

classnameclj

(classname o)

Get classname without leading package names of the given object o.

Get classname without leading package names of the given object o.
sourceraw docstring

compress-object-to-byte-arrayclj

(compress-object-to-byte-array obj)
(compress-object-to-byte-array obj alg)

Write an object into a byte array and compress it. A newly allocated byte array with the serialized and compressed object is returned. The compression algorithm can be specified via the second parameter. Currently GZIP (:gzip) and ZIP (:zip) are supported. The default is GZIP.

Write an object into a byte array and compress it.
A newly allocated byte array with the serialized and compressed object is returned.
The compression algorithm can be specified via the second parameter.
Currently GZIP (:gzip) and ZIP (:zip) are supported.
The default is GZIP.
sourceraw docstring

convert-from-clojure-to-javaclj

(convert-from-clojure-to-java input)

Converts the given Clojure specific data structure (list, map, set, vector) into the equivalent "pure" Java data structure. The mapping is as follows: list and vector -> ArrayList, map -> HashMap, set -> HashSet. Nested data structures will be converted recursively.

Converts the given Clojure specific data structure (list, map, set, vector) into the equivalent "pure" Java data structure.
The mapping is as follows: list and vector -> ArrayList, map -> HashMap, set -> HashSet.
Nested data structures will be converted recursively.
sourceraw docstring

CountDownFlagclj

source

counterclj

(counter)
(counter init)

Convenience function for creating a more powerful counter. The created counter allows to have arbitrary single-argument functions passed for manipulating the internal value. When the created counter is called with no argument the current value is returned. Example: (use 'clj-assorted-utils.util) (let [cntr (counter 123)] (println (cntr)) (cntr inc) (cntr dec) (cntr #(- % 123)) (cntr))

Convenience function for creating a more powerful counter.
The created counter allows to have arbitrary single-argument functions passed for manipulating the internal value.
When the created counter is called with no argument the current value is returned.
Example:
(use 'clj-assorted-utils.util)
(let [cntr (counter 123)]
  (println (cntr))
  (cntr inc)
  (cntr dec)
  (cntr #(- % 123))
  (cntr))
sourceraw docstring

create-string-to-file-outputclj

(create-string-to-file-output out-file)
(create-string-to-file-output out-file arg-map)
source

create-threaded-lineseq-readerclj

(create-threaded-lineseq-reader in-file process-fn)
source

delay-evalcljmacro

(delay-eval d & body)

Evaluates the supplied body with the given delay 'd' ([ms]).

Evaluates the supplied body with the given delay 'd' ([ms]).
sourceraw docstring

delta-counterclj

(delta-counter)

Creates a counter for calculating deltas. The returned delta counter function expects two arguments, a keyword and a numerical value. When called for the first time the initial value will be associated to an internal counter and zero is returned. When called subsequently with the same keyword, the difference between the current value and the stored value is calculated and this delta is returned. The internal counter is then set to the new value. Example: (let [cntr (counter) delta-cntr (delta-counter)] (= 0 (delta-cntr :cntr (cntr))) (cntr inc) (cntr inc) (cntr inc) (= 3 (delta-cntr :cntr (cntr))) (= 0 (delta-cntr :cntr (cntr))))

Creates a counter for calculating deltas.
The returned delta counter function expects two arguments, a keyword and a numerical value.
When called for the first time the initial value will be associated to an internal counter and zero is returned.
When called subsequently with the same keyword, the difference between the current value
and the stored value is calculated and this delta is returned.
The internal counter is then set to the new value.
Example:
(let [cntr (counter)
      delta-cntr (delta-counter)]
  (= 0 (delta-cntr :cntr (cntr)))
  (cntr inc)
  (cntr inc)
  (cntr inc)
  (= 3 (delta-cntr :cntr (cntr)))
  (= 0 (delta-cntr :cntr (cntr))))
sourceraw docstring

dir-exists?clj

(dir-exists? d)

Returns true if f exists and is a directory.

Returns true if f exists and is a directory.
sourceraw docstring

double-array-typeclj

source

execclj

(exec cmd)

Execute the given command.

Execute the given command.
sourceraw docstring

exec-blockingclj

(exec-blocking cmd)

Execute the given command and block until execution has finished.

Execute the given command and block until execution has finished.
sourceraw docstring

exec-with-outclj

(exec-with-out cmd stdout-fn)
(exec-with-out cmd stdout-fn stderr-fn)

Execute the given command and process the output written to stdout with stdout-fn. stdout-fn is run in an own thread. The data written to stdout is passed to stdout-fn line-by-line. When a value of nil is read processing stops and the process in which cmd was executed is destroyed.

Execute the given command and process the output written to stdout with stdout-fn.
stdout-fn is run in an own thread.
The data written to stdout is passed to stdout-fn line-by-line.
When a value of nil is read processing stops and the process in which cmd was executed is destroyed.
sourceraw docstring

executorclj

(executor)

Create an executor for executing fns in an own thread.

Create an executor for executing fns in an own thread.
sourceraw docstring

exists?clj

(exists? f)

Returns true if f exists in the filesystem.

Returns true if f exists in the filesystem.
sourceraw docstring

file-exists?clj

(file-exists? f)

Returns true if f exists and is a file.

Returns true if f exists and is a file.
sourceraw docstring

Flagcljprotocol

await-flagclj

(await-flag this)

Block the current thread until the flag was set.

Block the current thread until the flag was set.

flag-set?clj

(flag-set? this)

Test if flag had been set. Returns true if flag was set and false otherwise.

Test if flag had been set.
Returns true if flag was set and false otherwise.

set-flagclj

(set-flag this)

Set flag to true.

Set flag to true.
source

float-array-typeclj

source

fn-nameclj

(fn-name f)

Get the name of the given fn f.

Get the name of the given fn f.
sourceraw docstring

get-archclj

source

get-defn-arglistsclj

(get-defn-arglists f)

Get the arglists of a function that was defined with defn. This function is intended to be used from within a macor. For a macro version of this functionality please use get-defn-arglists-m.

Get the arglists of a function that was defined with defn.
This function is intended to be used from within a macor.
For a macro version of this functionality please use get-defn-arglists-m.
sourceraw docstring

get-defn-arglists-mcljmacro

(get-defn-arglists-m f)

Macro version of get-defn-arglists.

Macro version of get-defn-arglists.
sourceraw docstring

get-fn-arglistsclj

(get-fn-arglists f)

Returns a map that contains the actual fn that was passed as argument and its arglists. The result will be a map of form: {:fn f :args <f-args>}. This function is intended to be used from within a macor. For a macro version of this functionality please use get-fn-arglists-m.

Returns a map that contains the actual fn that was passed as argument and its arglists.
The result will be a map of form: {:fn f :args <f-args>}.
This function is intended to be used from within a macor.
For a macro version of this functionality please use get-fn-arglists-m.
sourceraw docstring

get-fn-arglists-mcljmacro

(get-fn-arglists-m f)

Macro version of get-fn-arglists.

Macro version of get-fn-arglists.
sourceraw docstring

get-int-from-byte-vectorclj

(get-int-from-byte-vector v n)

From given vector of bytes v get the integer starting at offset n. Starting at offset n the next 4 bytes will be converted to an integer.

From given vector of bytes v get the integer starting at offset n.
Starting at offset n the next 4 bytes will be converted to an integer.
sourceraw docstring

get-osclj

source

get-system-propertyclj

(get-system-property p)

Get system property p. p is a String naming the property go get.

Get system property p. p is a String naming the property go get.
sourceraw docstring

get-with-defaultclj

(get-with-default m k d)

Get a value for the given key k from a map m and if the value does not exist return the default d.

Get a value for the given key k from a map m and if the value does not exist return the default d.
sourceraw docstring

inc-counterclj

(inc-counter c)

Increment the given simple counter c.

Increment the given simple counter c.
sourceraw docstring

int-array-typeclj

source

int-to-byte-vectorclj

(int-to-byte-vector val)

Convert the given integer val to a vector of 4 bytes.

Convert the given integer val to a vector of 4 bytes.
sourceraw docstring

is-dir?clj

(is-dir? d)

Returns true if f is a directory.

Returns true if f is a directory.
sourceraw docstring

is-file?clj

(is-file? f)

Returns true if f is a file.

Returns true if f is a file.
sourceraw docstring

is-os?clj

(is-os? os)
source

long-array-typeclj

source

map-quote-vecclj

(map-quote-vec c)
source

mkdirclj

(mkdir d)

Create directory d and if required all parent directories. This is equivalent to 'mkdir -p d' on Linux systems.

Create directory d and if required all parent directories.
This is equivalent to 'mkdir -p d' on Linux systems.
sourceraw docstring

mkfifoclj

(mkfifo f)
source

object-to-byte-arrayclj

(object-to-byte-array obj)

Write the given object into a byte array. A newly allocated byte arry with the serialized object is returned.

Write the given object into a byte array.
A newly allocated byte arry with the serialized object is returned.
sourceraw docstring

prepare-counterclj

(prepare-counter)
(prepare-counter init)

Prepare a simple counter. Use @ to access the value.

Prepare a simple counter. Use @ to access the value.
sourceraw docstring

prepare-flagclj

(prepare-flag)
(prepare-flag n)

Prepare a flag with default value false.

Prepare a flag with default value false.
sourceraw docstring

(print-err & s)

print to stderr.

print to stderr.
sourceraw docstring

(print-err-ln & s)

Deprecated! Use println-err instead.

Deprecated! Use println-err instead.
sourceraw docstring

println-errclj

(println-err & s)

println to stderr.

println to stderr.
sourceraw docstring

process-input-stream-line-by-lineclj

(process-input-stream-line-by-line input-stream function)

Process the given input stream line-by-line. The data read from the stream is passed to the given function. The function is executed in an own thread.

Process the given input stream line-by-line.
The data read from the stream is passed to the given function.
The function is executed in an own thread.
sourceraw docstring

process-line-by-lineclj

(process-line-by-line location f)

Process input from location line-by-line. Each line is passed to f. The processing is done with a clojure reader. So all locations supported by reader are automatically supported as well.

Process input from location line-by-line.
Each line is passed to f.
The processing is done with a clojure reader.
So all locations supported by reader are automatically supported as well.
sourceraw docstring

reduce-selected-map-entriesclj

(reduce-selected-map-entries m f selected-keys)

Reduce the values of all selected keys of a map m by applying the function f.

Reduce the values of all selected keys of a map m by applying the function f.
sourceraw docstring

rmclj

(rm f)

Delete file f.

Delete file f.
sourceraw docstring

rmdirclj

(rmdir d)

Delete d if d is an empty directory.

Delete d if d is an empty directory.
sourceraw docstring

run-onceclj

(run-once exec f d)
(run-once exec f d tu)

Run f using executor exec once with delay d. Optionally a time unit tu can be given. tu defaults to TimeUnit/MILLISECONDS.

Run f using executor exec once with delay d.
Optionally a time unit tu can be given.
tu defaults to TimeUnit/MILLISECONDS.
sourceraw docstring

run-repeatclj

(run-repeat exec f d)
(run-repeat exec f id d)
(run-repeat exec f id d tu)

Run f repeatedly using executor exec with delay d. Optionally an initial delay, id, and a time unit tu can be given. Time unit is a static member of TimeUnit, e.g., TimeUnit/SECONDS and defaults to TimeUnit/MILLISECONDS.

Run f repeatedly using executor exec with delay d.
Optionally an initial delay, id, and a time unit tu can be given.
Time unit is a static member of TimeUnit, e.g., TimeUnit/SECONDS 
and defaults to TimeUnit/MILLISECONDS.
sourceraw docstring

short-array-typeclj

source

shutdownclj

(shutdown exec)

Shut executor down.

Shut executor down.
sourceraw docstring

shutdown-nowclj

(shutdown-now exec)

Force executor shut down.

Force executor shut down.
sourceraw docstring

sleepclj

(sleep ms)

Sleep for the given number of milliseconds.

Sleep for the given number of milliseconds.
sourceraw docstring

stringify-keywordclj

(stringify-keyword k)

If a keyword is passed returns the name of the keyword. Else the input is left unchanged.

If a keyword is passed returns the name of the keyword.
Else the input is left unchanged.
sourceraw docstring

stringify-mapclj

(stringify-map m)

Convert all keywords in a map to their respective names. This, essentially, is an extended version of clojure.walk/stringify-keys, which only converts the keys to strings.

Convert _all_ keywords in a map to their respective names.
This, essentially, is an extended version of clojure.walk/stringify-keys,
which only converts the keys to strings.
sourceraw docstring

touchclj

(touch f)

If f does not exist, create it.

If f does not exist, create it.
sourceraw docstring

vec-replaceclj

(vec-replace v n delta)

In given vector v replace the content of v starting at index n with delta.

In given vector v replace the content of v starting at index n with delta.
sourceraw docstring

with-eo-strcljmacro

(with-eo-str & body)

Macro that executes body capturing its stdout and stderr output. This returns a map with the following structure: {:all both-stdout-and-std-err-output-in-proper-order :stderr stderr-output :stdout stdout-output}

Macro that executes body capturing its stdout and stderr output.
This returns a map with the following structure:
{:all both-stdout-and-std-err-output-in-proper-order
 :stderr stderr-output
 :stdout stdout-output}
sourceraw docstring

with-err-strcljmacro

(with-err-str & body)

Analog to with-out-str, just for err: https://clojuredocs.org/clojure.core/with-out-str

Analog to with-out-str, just for *err*: https://clojuredocs.org/clojure.core/with-out-str
sourceraw docstring

with-err-str-cbcljmacro

(with-err-str-cb cb-fn & body)

Callback version of with-err-str. This version executes the function cb-fn for every element that was added to the writer. cb-fn is executed after the element was added to the writer.

Callback version of with-err-str.
This version executes the function cb-fn for every element that was added to the writer.
cb-fn is executed after the element was added to the writer.
sourceraw docstring

with-err-str-customcljmacro

(with-err-str-custom write-fn & body)

Customizable version of with-err-str. This version executes the function write-fn for every element that is added to the writer. The element that is added to the writer is the string representation of the return value of write-fn.

Customizable version of with-err-str.
This version executes the function write-fn for every element that is added to the writer.
The element that is added to the writer is the string representation of the return value of write-fn.
sourceraw docstring

with-out-str-cbcljmacro

(with-out-str-cb cb-fn & body)

Callback version of with-out-str: https://clojuredocs.org/clojure.core/with-out-str This version executes the function cb-fn for every element that was added to the writer. cb-fn is executed after the element was added to the writer.

Callback version of with-out-str: https://clojuredocs.org/clojure.core/with-out-str
This version executes the function cb-fn for every element that was added to the writer.
cb-fn is executed after the element was added to the writer.
sourceraw docstring

with-out-str-customcljmacro

(with-out-str-custom write-fn & body)

Customizable version of with-out-str: https://clojuredocs.org/clojure.core/with-out-str This version executes the function write-fn for every element that is added to the writer. The element that is added to the writer is the string representation of the return value of write-fn.

Customizable version of with-out-str: https://clojuredocs.org/clojure.core/with-out-str
This version executes the function write-fn for every element that is added to the writer.
The element that is added to the writer is the string representation of the return value of write-fn.
sourceraw docstring

xml-string-to-mapclj

(xml-string-to-map xml-str)

Takes an XML definition in form of a string and outputs the corresponding map.

Takes an XML definition in form of a string and outputs the corresponding map.
sourceraw docstring

xml-string-to-map-stringifiedclj

(xml-string-to-map-stringified xml-str)

Convert the XML string xml-str to a map with all keywords converted to strings.

Convert the XML string xml-str to a map with all keywords converted to strings.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close