A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/reagent-project/reagent-utils below:

reagent-project/reagent-utils: a collection of helper functions for use with Reagent

This library provides a number of convenience helpers for use with Reagent.

(contains-key? k)

is the key present in the cookies

(contains-val? v)

is the value present in the cookies (as string)

(count)

returns the number of cookies

(empty?)

true if no cookies are set

(get k & [default])

gets the value at the key (as edn), optional default when value is not found

(get-raw k & [default])

gets the value at the key (as string), optional default when value is not found

(keys)

returns all the keys for the cookies

(raw-vals)

returns cookie values (as strings)

(remove! k)(remove! k path domain)

removes a cookie, optionally for a specific path and/or domain

(set! k content & [{:keys [max-age path domain secure? raw?]} :as opts])

sets a cookie, the max-age for session cookie
following optional parameters may be passed in as a map:
:max-age - defaults to -1
:path - path of the cookie, defaults to the full request path
:domain - domain of the cookie, when null the browser will use the full request host name
:secure? - boolean specifying whether the cookie should only be sent over a secure channel
:raw? - boolean specifying whether content should be stored raw, or as EDN

(vals)

returns cookie values (as edn)

(hash s hash-type & [hex?])

(date-format date fmt & [tz])

(format fmt & args)

Formats a string using goog.string.format.
e.g: (format "Cost: %.2f" 10.0234)

(pluralize items & [word ending1 ending2 :as opts])

pluralizes the word based on the number of items
(util/pluralize ["John"] "lad")
(util/pluralize ["John" "James"] "lad")
(util/pluralize ["Alice"] "lad" "y" "ies")

(printf fmt & args)

Prints formatted output, as per format

(remove-tags s & tags)

removes specified tags, eg:
(remove-tags "<p>foo bar</p>" "p")

(assoc-in! ks v)

Associates a value in the session, where ks is a
sequence of keys and v is the new value and returns
a new nested structure. If any levels do not exist,
hash-maps will be created.

(clear!)

Remove all data from the session and start over cleanly.

(get k & [default])

Get the key's value from the session, returns nil if it doesn't exist.

(get! k & [default])

Destructive get from the session. This returns the current value of the key
and then removes it from the session.

(get-in ks & [default])

Gets the value at the path specified by the vector ks from the session,
returns nil if it doesn't exist.

(get-in! ks & [default])

Destructive get from the session. This returns the current value of the path
specified by the vector ks and then removes it from the session.

(remove! k)

Remove a key from the session

(swap! f & args)

Replace the current session's value with the result of executing f with
the current value and args.

(update! k f & args)

Updates a value in session where k is a key and f
is the function that takes the old value along with any
supplied args and return the new value. If key is not
present it will be added.

(update-in! ks f & args)

Updates a value in the session, where ks is a
sequence of keys and f is a function that will
take the old value along with any supplied args and return
the new value. If any levels do not exist, hash-maps
will be created.
Functions for validating input and setting string errors on fields.

(equal-to? v n)

Returns true if the string represents a number = given.

(greater-than? v n)

Returns true if the string represents a number > given.

(has-value? v)

Returns true if v is truthy and not an empty string.

(has-values? coll)

Returns true if all members of the collection has-value? This works on maps as well.

(is-email? v)

Returns true if v is an email address

(less-than? v n)

Returns true if the string represents a number < given.

(matches-regex? v regex)

Returns true if the string matches the given regular expression

(max-length? v len)

Returns true if v is less than or equal to the given len

(min-length? v len)

Returns true if v is greater than or equal to the given len

(not-nil? v)

Returns true if v is not nil

(valid-number? v)

Returns true if the string can be parsed to a Long

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4