Skip to content

Sprig functions Argo supports

Argo Workflows bundles Sprig, but only part of it: two functions, env and expandenv, are removed before an expression ever sees them. Argo also adds a handful of its own functions, and expr-lang, the expression language itself, ships a further set of builtins. Argo’s own docs don’t say which Sprig functions are missing or what any of them do, so this page lists all three sets together.

Every function below works the same way: inside {{=...}}, in any field that takes a {{...}} tag. None of them work in depends, which reads step results directly, and none of them work in a plain {{...}} tag, which only substitutes a value. See Expressions for how the two kinds of tag differ.

284 functions

  • absexpr-lang builtin
    abs(number) number

    Gives the absolute value of a number.

    abs(-5) == 5
  • allexpr-lang builtin
    all(list, predicate) bool

    Reports whether every element of a list satisfies a condition.

    all([2, 4, 6], {# % 2 == 0}) == true
  • anyexpr-lang builtin
    any(list, predicate) bool

    Reports whether any element of a list satisfies a condition.

    any([1, 3, 5], {# % 2 == 0}) == false
  • asFloatArgo function
    asFloat(text) number

    Turns text into a number with decimals

    asFloat('4.2') == 4.2
  • asIntArgo function
    asInt(text) number

    Turns text into a whole number

    asInt('42') == 42
  • bitandexpr-lang builtin
    bitand(a number, b number) number

    Bitwise AND of two whole numbers.

    bitand(0b1010, 0b1100) == 0b1000
  • bitnandexpr-lang builtin
    bitnand(a number, b number) number

    Bitwise AND NOT of two whole numbers: bits set in a and not in b.

    bitnand(0b1010, 0b1100) == 0b10
  • bitnotexpr-lang builtin
    bitnot(number) number

    Bitwise NOT of a whole number.

    bitnot(0b1010) == -0b1011
  • bitorexpr-lang builtin
    bitor(a number, b number) number

    Bitwise OR of two whole numbers.

    bitor(0b1010, 0b1100) == 0b1110
  • bitshlexpr-lang builtin
    bitshl(number, places number) number

    Shifts a whole number's bits left.

    bitshl(0b101101, 2) == 0b10110100
  • bitshrexpr-lang builtin
    bitshr(number, places number) number

    Shifts a whole number's bits right, keeping the sign.

    bitshr(0b101101, 2) == 0b1011
  • bitushrexpr-lang builtin
    bitushr(number, places number) number

    Shifts a whole number's bits right, filling with zeros regardless of sign.

    bitushr(4, 1) == 2
  • bitxorexpr-lang builtin
    bitxor(a number, b number) number

    Bitwise XOR of two whole numbers.

    bitxor(0b1010, 0b1100) == 0b110
  • ceilexpr-lang builtin
    ceil(number) number

    Rounds a number up to the nearest whole number.

    ceil(1.5) == 2.0
  • concatexpr-lang builtin
    concat(list, ...lists) list

    Joins two or more lists end to end.

    concat([1, 2], [3, 4]) == [1, 2, 3, 4]
  • countexpr-lang builtin
    count(list, predicate) number

    Counts the elements of a list that satisfy a condition. With no condition, counts the true elements.

    count([1, 2, 3, 4], {# > 2}) == 2
  • dateexpr-lang builtin
    date(text, layout text, zone text) time

    Parses text into a date. An optional layout and time zone say how to read it.

    date('2023-08-14').Year() == 2023
  • durationexpr-lang builtin
    duration(text) duration

    Parses text like 1h or 30m into a duration.

    duration('1h').Seconds() == 3600
  • filterexpr-lang builtin
    filter(list, predicate) list

    Gives a new list of the elements that satisfy a condition.

    filter([1, 2, 3, 4], {# % 2 == 0}) == [2, 4]
  • findexpr-lang builtin
    find(list, predicate) any

    Finds the first element of a list that satisfies a condition.

    find([1, 2, 3, 4], {# > 2}) == 3
  • findIndexexpr-lang builtin
    findIndex(list, predicate) number

    Finds the index of the first element of a list that satisfies a condition.

    findIndex([1, 2, 3, 4], {# > 2}) == 2
  • findLastexpr-lang builtin
    findLast(list, predicate) any

    Finds the last element of a list that satisfies a condition.

    findLast([1, 2, 3, 4], {# > 2}) == 4
  • findLastIndexexpr-lang builtin
    findLastIndex(list, predicate) number

    Finds the index of the last element of a list that satisfies a condition.

    findLastIndex([1, 2, 3, 4], {# > 2}) == 3
  • firstexpr-lang builtin
    first(list) any

    Gives the first element of a list.

    first([1, 2, 3]) == 1
  • flattenexpr-lang builtin
    flatten(list) list

    Flattens a nested list into one dimension.

    flatten([1, 2, [3, 4]]) == [1, 2, 3, 4]
  • floatexpr-lang builtin
    float(value) number

    Turns a number or text into a number with decimals.

    float('123.45') == 123.45
  • floorexpr-lang builtin
    floor(number) number

    Rounds a number down to the nearest whole number.

    floor(1.5) == 1.0
  • fromBase64expr-lang builtin
    fromBase64(text) text

    Decodes base64 text.

    fromBase64('SGVsbG8gV29ybGQ=') == 'Hello World'
  • fromJSONexpr-lang builtin
    fromJSON(text) any

    Reads JSON text into a value.

    fromJSON('{"name": "John", "age": 30}')['name'] == 'John'
  • fromPairsexpr-lang builtin
    fromPairs(list) dict

    Turns a list of [key, value] pairs into a dict.

    fromPairs([['name', 'John']])['name'] == 'John'
  • getexpr-lang builtin
    get(value, index) any

    Reads an element or key from a list or dict, or nil if it isn't there.

    get([1, 2, 3], 1) == 2
  • groupByexpr-lang builtin
    groupBy(list, predicate) dict

    Groups the elements of a list by the result of an expression.

    groupBy([1, 2, 3, 4], {# % 2})[0] == [2, 4]
  • hasPrefixexpr-lang builtin
    hasPrefix(text, prefix text) bool

    Reports whether text starts with a prefix.

    hasPrefix('HelloWorld', 'Hello') == true
  • hasSuffixexpr-lang builtin
    hasSuffix(text, suffix text) bool

    Reports whether text ends with a suffix.

    hasSuffix('HelloWorld', 'World') == true
  • indexOfexpr-lang builtin
    indexOf(text, substr text) number

    Gives the position of the first occurrence of a substring, or -1 if it isn't found.

    indexOf('apple pie', 'pie') == 6
  • intexpr-lang builtin
    int(value) number

    Turns a number or text into a whole number.

    int('123') == 123
  • joinexpr-lang builtin
    join(list, sep text) text

    Joins a list of text into one piece of text, with an optional separator.

    join(['apple', 'orange', 'grape'], ',') == 'apple,orange,grape'
  • jsonpathArgo function
    jsonpath(text, path) any

    Reads a value out of JSON text

    jsonpath('{"region":"eu"}', '$.region') == 'eu'
  • keysexpr-lang builtin
    keys(dict) list

    Lists the keys of a dict.

    len(keys({'name': 'John', 'age': 30})) == 2
  • lastexpr-lang builtin
    last(list) any

    Gives the last element of a list.

    last([1, 2, 3]) == 3
  • lastIndexOfexpr-lang builtin
    lastIndexOf(text, substr text) number

    Gives the position of the last occurrence of a substring, or -1 if it isn't found.

    lastIndexOf('apple pie apple', 'apple') == 10
  • lenexpr-lang builtin
    len(value) number

    Gives the length of a list, dict or piece of text.

    len('Hello') == 5
  • lowerexpr-lang builtin
    lower(text) text

    Turns text to lower case.

    lower('HELLO') == 'hello'
  • mapexpr-lang builtin
    map(list, predicate) list

    Gives a new list by applying an expression to every element.

    map([1, 2, 3], {# * 2}) == [2, 4, 6]
  • maxexpr-lang builtin
    max(number, ...numbers) number

    Gives the largest of the numbers given.

    max(5, 7) == 7
  • meanexpr-lang builtin
    mean(list) number

    Gives the average of the numbers in a list.

    mean([1, 2, 3]) == 2.0
  • medianexpr-lang builtin
    median(list) number

    Gives the median of the numbers in a list.

    median([1, 2, 3]) == 2.0
  • minexpr-lang builtin
    min(number, ...numbers) number

    Gives the smallest of the numbers given.

    min(5, 7) == 5
  • noneexpr-lang builtin
    none(list, predicate) bool

    Reports whether no element of a list satisfies a condition.

    none([1, 3, 5], {# % 2 == 0}) == true
  • nowexpr-lang builtin
    now() time

    Gives the current date and time.

    now().Year() > 2000
  • oneexpr-lang builtin
    one(list, predicate) bool

    Reports whether exactly one element of a list satisfies a condition.

    one([1, 2, 3], {# % 2 == 0}) == true
  • reduceexpr-lang builtin
    reduce(list, predicate, initial) any

    Reduces a list to one value, carrying an accumulator (#acc) through each element. The accumulator starts as the first element unless you give an initial value.

    reduce([1, 2, 3], {#acc + #}, 0) == 6
  • repeatexpr-lang builtin
    repeat(text, n number) text

    Repeats text a number of times.

    repeat('ab', 3) == 'ababab'
  • replaceexpr-lang builtin
    replace(text, old text, new text) text

    Replaces every occurrence of one piece of text with another.

    replace('Hello World', 'World', 'Universe') == 'Hello Universe'
  • reverseexpr-lang builtin
    reverse(list) list

    Reverses the order of a list.

    reverse([3, 1, 4]) == [4, 1, 3]
  • roundexpr-lang builtin
    round(number) number

    Rounds a number to the nearest whole number.

    round(1.5) == 2.0
  • sortexpr-lang builtin
    sort(list, order text) list

    Sorts a list. An optional order is asc or desc.

    sort([3, 1, 4]) == [1, 3, 4]
  • sortByexpr-lang builtin
    sortBy(list, predicate, order text) list

    Sorts a list by the result of an expression. An optional order is asc or desc.

    sortBy([3, 1, 4], {#}) == [1, 3, 4]
  • splitexpr-lang builtin
    split(text, sep text, limit number) list

    Splits text at every occurrence of a separator, up to an optional limit.

    split('apple,orange,grape', ',') == ['apple', 'orange', 'grape']
  • splitAfterexpr-lang builtin
    splitAfter(text, sep text, limit number) list

    Splits text after every occurrence of a separator, keeping the separator on each piece.

    splitAfter('apple,orange,grape', ',') == ['apple,', 'orange,', 'grape']
  • sprig.abbrevSprig function
    sprig.abbrev(width number, text) text

    Shortens text to a width, ending in ... if it was cut.

    sprig.abbrev(7, 'abcdefghij') == 'abcd...'
  • sprig.abbrevbothSprig function
    sprig.abbrevboth(left number, right number, text) text

    Shortens text from both ends, keeping a middle window.

    len(sprig.abbrevboth(5, 10, 'abcdefghijklmnopqrstuvwxyz')) <= 10
  • sprig.addSprig function
    sprig.add(...numbers) number

    Adds numbers together.

    sprig.add(1, 2, 3) == 6
  • sprig.add1Sprig function
    sprig.add1(number) number

    Adds one to a number.

    sprig.add1(1) == 2
  • sprig.add1fSprig function
    sprig.add1f(number) number

    Adds one to a number with decimals.

    sprig.add1f(1.5) == 2.5
  • sprig.addfSprig function
    sprig.addf(...numbers) number

    Adds numbers with decimals together.

    sprig.addf(1.5, 2.5) == 4
  • sprig.adler32sumSprig function
    sprig.adler32sum(text) text

    Checksums text with Adler-32, as a decimal number.

    int(sprig.adler32sum('abc')) > 0
  • sprig.agoSprig function
    sprig.ago(date) text

    Gives how long ago a date was, as text like 3h0m0s.

    len(sprig.ago(sprig.now())) > 0
  • sprig.allSprig function
    sprig.all(value, ...) bool

    Reports whether every value given is non-empty.

    sprig.all('a', 'b') == true
  • sprig.anySprig function
    sprig.any(value, ...) bool

    Reports whether any value given is non-empty.

    sprig.any('', 'b') == true
  • sprig.appendSprig function
    sprig.append(list, value) list

    Adds a value onto the end of a list, giving a new list. Same as push.

    sprig.append([1, 2], 3) == [1, 2, 3]
  • sprig.atoiSprig function
    sprig.atoi(text) number

    Turns text into a whole number. Gives 0 if it isn't one.

    sprig.atoi('42') == 42
  • sprig.b32decSprig function
    sprig.b32dec(text) text

    Decodes base32 text.

    sprig.b32dec(sprig.b32enc('hi')) == 'hi'
  • sprig.b32encSprig function
    sprig.b32enc(text) text

    Encodes text as base32.

    sprig.b32dec(sprig.b32enc('hi')) == 'hi'
  • sprig.b64decSprig function
    sprig.b64dec(text) text

    Decodes base64 text.

    sprig.b64dec('aGk=') == 'hi'
  • sprig.b64encSprig function
    sprig.b64enc(text) text

    Encodes text as base64.

    sprig.b64enc('hi') == 'aGk='
  • sprig.baseSprig function
    sprig.base(path text) text

    Gives the last element of a slash-separated path.

    sprig.base('/foo/bar/baz.txt') == 'baz.txt'
  • sprig.bcryptSprig function
    sprig.bcrypt(text) text

    Hashes text with bcrypt.

    sprig.bcrypt('pw') != ''
  • sprig.biggestSprig function
    sprig.biggest(a number, ...numbers) number

    Gives the largest of the whole numbers passed in. Same as max.

    sprig.biggest(3, 7) == 7
  • sprig.buildCustomCertSprig function
    sprig.buildCustomCert(b64cert text, b64key text) cert

    Builds a certificate object from a base64-encoded certificate and key.

    let ca = sprig.genCA('ci', 1); sprig.buildCustomCert(sprig.b64enc(ca.Cert), sprig.b64enc(ca.Key)).Cert != ''
  • sprig.camelcaseSprig function
    sprig.camelcase(text) text

    Turns snake_case or kebab-case text into PascalCase.

    sprig.camelcase('some_var') == 'SomeVar'
  • sprig.catSprig function
    sprig.cat(value, ...) text

    Joins values with a space, skipping any that are empty.

    sprig.cat('a', 'b', 'c') == 'a b c'
  • sprig.ceilSprig function
    sprig.ceil(number) number

    Rounds a number up to the nearest whole number.

    sprig.ceil(1.5) == 2
  • sprig.chunkSprig function
    sprig.chunk(size number, list) list

    Splits a list into chunks of a size.

    len(sprig.chunk(2, [1, 2, 3, 4, 5])) == 3 && sprig.chunk(2, [1, 2, 3, 4, 5])[0] == [1, 2]
  • sprig.cleanSprig function
    sprig.clean(path text) text

    Simplifies a slash-separated path, resolving . and .. and doubled slashes.

    sprig.clean('/foo/../bar//baz') == '/bar/baz'
  • sprig.coalesceSprig function
    sprig.coalesce(value, ...) any

    Gives the first value that isn't empty.

    sprig.coalesce('', 0, 'x') == 'x'
  • sprig.compactSprig function
    sprig.compact(list) list

    Drops the empty values out of a list.

    sprig.compact(['a', '', 'b']) == ['a', 'b']
  • sprig.concatSprig function
    sprig.concat(list, ...lists) list

    Joins lists end to end into one list.

    sprig.concat([1, 2], [3, 4]) == [1, 2, 3, 4]
  • sprig.containsSprig function
    sprig.contains(substr text, text) bool

    Reports whether text holds a substring.

    sprig.contains('ell', 'Hello') == true
  • sprig.dateSprig function
    sprig.date(layout text, date) text

    Formats a date using this server's local time zone.

    len(sprig.date('2006-01-02', 1700000000)) == 10
  • sprig.date_in_zoneSprig function
    sprig.date_in_zone(layout text, date, zone text) text

    Formats a date in a named time zone. Same as dateInZone.

    sprig.date_in_zone('2006-01-02', 1700000000, 'UTC') == '2023-11-14'
  • sprig.date_modifySprig function
    sprig.date_modify(duration text, date) date

    Adds a duration to a date. Same as dateModify.

    sprig.date_modify('1h', sprig.toDate('2006-01-02', '2024-01-01')).Hour() == 1
  • sprig.dateInZoneSprig function
    sprig.dateInZone(layout text, date, zone text) text

    Formats a date in a named time zone.

    sprig.dateInZone('2006-01-02', 1700000000, 'UTC') == '2023-11-14'
  • sprig.dateModifySprig function
    sprig.dateModify(duration text, date) date

    Adds a duration to a date.

    sprig.dateModify('1h', sprig.toDate('2006-01-02', '2024-01-01')).Hour() == 1
  • sprig.decryptAESSprig function
    sprig.decryptAES(password text, text) text

    Decrypts text that was encrypted with encryptAES and the same password.

    sprig.decryptAES('s3cr3t!', sprig.encryptAES('s3cr3t!', 'hello')) == 'hello'
  • sprig.deepCopySprig function
    sprig.deepCopy(value) any

    Makes an independent copy of a value.

    sprig.deepCopy([1, 2, 3]) == [1, 2, 3]
  • sprig.deepEqualSprig function
    sprig.deepEqual(a, b) bool

    Reports whether two values are deeply equal, comparing lists and dicts field by field.

    sprig.deepEqual([1, 2], [1, 2]) == true
  • sprig.defaultSprig function
    sprig.default(fallback, value) any

    Gives a fallback when a value is empty.

    sprig.default('fallback', '') == 'fallback'
  • sprig.derivePasswordSprig function
    sprig.derivePassword(counter number, kind text, password text, user text, site text) text

    Derives a Master Password style password for a site, the same way every time for the same inputs. Its counter argument needs a Go uint32, and no Sprig or expr function can produce one, so Argo can't actually call this from an expression.

    len(sprig.derivePassword(1, 'long', 'password', 'user', 'example.com')) == 14
  • sprig.dictSprig function
    sprig.dict(key text, value, ...) dict

    Builds a dict out of alternating keys and values.

    len(sprig.dict('a', 1, 'b', 2)) == 2 && sprig.dict('a', 1, 'b', 2)['a'] == 1
  • sprig.digSprig function
    sprig.dig(key, ..., default, dict) any

    Reads a nested value out of a dict by a path of keys, or gives a default if any key is missing.

    sprig.dig('a', 'b', 'nope', sprig.dict('a', sprig.dict('b', 'found'))) == 'found'
  • sprig.dirSprig function
    sprig.dir(path text) text

    Gives every element of a slash-separated path except the last.

    sprig.dir('/foo/bar/baz.txt') == '/foo/bar'
  • sprig.divSprig function
    sprig.div(a number, b number) number

    Divides one number by another, as whole numbers.

    sprig.div(6, 2) == 3
  • sprig.divfSprig function
    sprig.divf(a number, ...numbers) number

    Divides a number with decimals by the numbers after it.

    sprig.divf(9, 3) == 3
  • sprig.durationSprig function
    sprig.duration(seconds text) text

    Turns a number of seconds into text like 5m0s.

    sprig.duration('300') == '5m0s'
  • sprig.durationRoundSprig function
    sprig.durationRound(duration text) text

    Rounds a duration down to its largest whole unit, like 9d.

    sprig.durationRound('220h') == '9d'
  • sprig.emptySprig function
    sprig.empty(value) bool

    Reports whether a value is the zero value for its type: '', 0, false, or an empty list or dict.

    sprig.empty('') == true
  • sprig.encryptAESSprig function
    sprig.encryptAES(password text, text) text

    Encrypts text with AES, using a password as the key.

    sprig.decryptAES('s3cr3t!', sprig.encryptAES('s3cr3t!', 'hello')) == 'hello'
  • sprig.extSprig function
    sprig.ext(path text) text

    Gives the file extension of a slash-separated path, including the dot.

    sprig.ext('/foo/bar.txt') == '.txt'
  • sprig.failSprig function
    sprig.fail(message text) never returns

    Stops the expression with an error carrying your message. Always fails, on purpose.

    sprig.fail('boom')
  • sprig.firstSprig function
    sprig.first(list) any

    Gives the first item of a list.

    sprig.first([1, 2, 3]) == 1
  • sprig.float64Sprig function
    sprig.float64(value) number

    Turns a value into a number with decimals.

    sprig.float64('4.2') == 4.2
  • sprig.floorSprig function
    sprig.floor(number) number

    Rounds a number down to the nearest whole number.

    sprig.floor(1.5) == 1
  • sprig.fromJsonSprig function
    sprig.fromJson(text) any

    Reads JSON text into a value.

    sprig.fromJson('"hi"') == 'hi'
  • sprig.genCASprig function
    sprig.genCA(commonName text, daysValid number) cert

    Generates a self-signed certificate authority.

    sprig.genCA('ci', 1).Cert != ''
  • sprig.genCAWithKeySprig function
    sprig.genCAWithKey(commonName text, daysValid number, privateKey text) cert

    Generates a self-signed certificate authority using a private key you already have.

    sprig.genCAWithKey('ci', 1, sprig.genPrivateKey('ecdsa')).Cert != ''
  • sprig.genPrivateKeySprig function
    sprig.genPrivateKey(kind text) text

    Generates a new PEM-encoded private key, of a kind such as rsa, dsa, ecdsa or ed25519.

    sprig.genPrivateKey('ecdsa') != ''
  • sprig.genSelfSignedCertSprig function
    sprig.genSelfSignedCert(commonName text, ips list, dnsNames list, daysValid number) cert

    Generates a self-signed certificate.

    sprig.genSelfSignedCert('example.com', [], [], 1).Cert != ''
  • sprig.genSelfSignedCertWithKeySprig function
    sprig.genSelfSignedCertWithKey(commonName text, ips list, dnsNames list, daysValid number, privateKey text) cert

    Generates a self-signed certificate using a private key you already have.

    sprig.genSelfSignedCertWithKey('example.com', [], [], 1, sprig.genPrivateKey('ecdsa')).Cert != ''
  • sprig.genSignedCertSprig function
    sprig.genSignedCert(commonName text, ips list, dnsNames list, daysValid number, ca cert) cert

    Generates a certificate signed by a certificate authority.

    sprig.genSignedCert('example.com', [], [], 1, sprig.genCA('ci', 1)).Cert != ''
  • sprig.genSignedCertWithKeySprig function
    sprig.genSignedCertWithKey(commonName text, ips list, dnsNames list, daysValid number, ca cert, privateKey text) cert

    Generates a certificate signed by a certificate authority, using a private key you already have.

    sprig.genSignedCertWithKey('example.com', [], [], 1, sprig.genCA('ci', 1), sprig.genPrivateKey('ecdsa')).Cert != ''
  • sprig.getSprig function
    sprig.get(dict, key text) any

    Reads a key from a dict, or gives an empty value if it's missing.

    sprig.get(sprig.dict('a', 1), 'a') == 1
  • sprig.getHostByNameSprig function
    sprig.getHostByName(host text) text

    Looks up one IP address for a hostname.

    sprig.getHostByName('example.com') != ''
  • sprig.hasSprig function
    sprig.has(value, list) bool

    Reports whether a list holds a value.

    sprig.has(2, [1, 2, 3]) == true
  • sprig.hasKeySprig function
    sprig.hasKey(dict, key text) bool

    Reports whether a dict has a key.

    sprig.hasKey(sprig.dict('a', 1), 'a') == true
  • sprig.hasPrefixSprig function
    sprig.hasPrefix(prefix text, text) bool

    Reports whether text starts with a prefix.

    sprig.hasPrefix('Hello', 'HelloWorld') == true
  • sprig.hasSuffixSprig function
    sprig.hasSuffix(suffix text, text) bool

    Reports whether text ends with a suffix.

    sprig.hasSuffix('World', 'HelloWorld') == true
  • sprig.helloSprig function
    sprig.hello() text

    Returns a fixed greeting. Mostly used to check Sprig is wired up.

    sprig.hello() == 'Hello!'
  • sprig.htmlDateSprig function
    sprig.htmlDate(date) text

    Formats a date as YYYY-MM-DD, using this server's local time zone.

    len(sprig.htmlDate(1700000000)) == 10
  • sprig.htmlDateInZoneSprig function
    sprig.htmlDateInZone(date, zone text) text

    Formats a date as YYYY-MM-DD in a named time zone.

    sprig.htmlDateInZone(1700000000, 'UTC') == '2023-11-14'
  • sprig.htpasswdSprig function
    sprig.htpasswd(username text, password text) text

    Builds a username:bcrypt-hash line for a .htpasswd file.

    len(sprig.htpasswd('ann', 'pw')) > 4
  • sprig.indentSprig function
    sprig.indent(spaces number, text) text

    Adds spaces to the front of every line of text.

    sprig.indent(2, 'a') == ' a'
  • sprig.initialSprig function
    sprig.initial(list) list

    Gives every item of a list except the last.

    sprig.initial([1, 2, 3]) == [1, 2]
  • sprig.initialsSprig function
    sprig.initials(text) text

    Takes the first letter of each word.

    sprig.initials('John Doe') == 'JD'
  • sprig.intSprig function
    sprig.int(value) number

    Turns a value into a whole number.

    sprig.int('42') == 42
  • sprig.int64Sprig function
    sprig.int64(value) number

    Turns a value into a 64-bit whole number.

    sprig.int64('42') == 42
  • sprig.isAbsSprig function
    sprig.isAbs(path text) bool

    Reports whether a slash-separated path is absolute.

    sprig.isAbs('/foo/bar') == true
  • sprig.joinSprig function
    sprig.join(sep text, list) text

    Joins a list into text with a separator between each value.

    sprig.join(',', [1, 2, 3]) == '1,2,3'
  • sprig.kebabcaseSprig function
    sprig.kebabcase(text) text

    Turns CamelCase text into kebab-case.

    sprig.kebabcase('CamelCase') == 'camel-case'
  • sprig.keysSprig function
    sprig.keys(dict, ...) list

    Lists the keys of one or more dicts.

    len(sprig.keys(sprig.dict('a', 1, 'b', 2))) == 2 && 'a' in sprig.keys(sprig.dict('a', 1, 'b', 2))
  • sprig.kindIsSprig function
    sprig.kindIs(kind text, value) bool

    Reports whether a value has a named kind.

    sprig.kindIs('string', 'hi') == true
  • sprig.kindOfSprig function
    sprig.kindOf(value) text

    Names the underlying kind of a value, such as string, slice or map.

    sprig.kindOf('hi') == 'string'
  • sprig.lastSprig function
    sprig.last(list) any

    Gives the last item of a list.

    sprig.last([1, 2, 3]) == 3
  • sprig.listSprig function
    sprig.list(value, ...) list

    Builds a list out of the values given.

    sprig.list(1, 2, 3) == [1, 2, 3]
  • sprig.lowerSprig function
    sprig.lower(text) text

    Turns text to lower case.

    sprig.lower('ABC') == 'abc'
  • sprig.maxSprig function
    sprig.max(a number, ...numbers) number

    Gives the largest of the whole numbers passed in.

    sprig.max(3, 7) == 7
  • sprig.maxfSprig function
    sprig.maxf(a number, ...numbers) number

    Gives the largest of the numbers with decimals passed in.

    sprig.maxf(3.5, 7.1) == 7.1
  • sprig.mergeSprig function
    sprig.merge(dict, ...dicts) dict

    Copies keys from other dicts into the first one that aren't already set there.

    sprig.merge(sprig.dict('a', 1), sprig.dict('b', 2))['a'] == 1 && sprig.merge(sprig.dict('a', 1), sprig.dict('b', 2))['b'] == 2
  • sprig.mergeOverwriteSprig function
    sprig.mergeOverwrite(dict, ...dicts) dict

    Copies keys from other dicts into the first one, overwriting any that were already set.

    sprig.mergeOverwrite(sprig.dict('a', 1), sprig.dict('a', 2))['a'] == 2
  • sprig.minSprig function
    sprig.min(a number, ...numbers) number

    Gives the smallest of the whole numbers passed in.

    sprig.min(3, 7) == 3
  • sprig.minfSprig function
    sprig.minf(a number, ...numbers) number

    Gives the smallest of the numbers with decimals passed in.

    sprig.minf(3.5, 7.1) == 3.5
  • sprig.modSprig function
    sprig.mod(a number, b number) number

    Gives the remainder of dividing one number by another.

    sprig.mod(7, 3) == 1
  • sprig.mulSprig function
    sprig.mul(a number, ...numbers) number

    Multiplies numbers together.

    sprig.mul(2, 3, 4) == 24
  • sprig.mulfSprig function
    sprig.mulf(a number, ...numbers) number

    Multiplies numbers with decimals together.

    sprig.mulf(2.5, 4) == 10
  • sprig.must_date_modifySprig function
    sprig.must_date_modify(duration text, date) date

    Adds a duration to a date, or fails if the duration doesn't parse. Same as mustDateModify.

    sprig.must_date_modify('2h', sprig.toDate('2006-01-02', '2024-01-01')).Hour() == 2
  • sprig.mustAppendSprig function
    sprig.mustAppend(list, value) list

    Adds a value onto the end of a list, or fails if it isn't a list. Same as mustPush.

    sprig.mustAppend([1, 2], 3) == [1, 2, 3]
  • sprig.mustChunkSprig function
    sprig.mustChunk(size number, list) list

    Splits a list into chunks of a size, or fails if it isn't a list.

    len(sprig.mustChunk(2, [1, 2, 3, 4, 5])) == 3 && sprig.mustChunk(2, [1, 2, 3, 4, 5])[0] == [1, 2]
  • sprig.mustCompactSprig function
    sprig.mustCompact(list) list

    Drops the empty values out of a list, or fails if it isn't a list.

    sprig.mustCompact(['a', '', 'b']) == ['a', 'b']
  • sprig.mustDateModifySprig function
    sprig.mustDateModify(duration text, date) date

    Adds a duration to a date, or fails if the duration doesn't parse.

    sprig.mustDateModify('2h', sprig.toDate('2006-01-02', '2024-01-01')).Hour() == 2
  • sprig.mustDeepCopySprig function
    sprig.mustDeepCopy(value) any

    Makes an independent copy of a value, or fails on a bad argument.

    sprig.mustDeepCopy([1, 2, 3]) == [1, 2, 3]
  • sprig.mustFirstSprig function
    sprig.mustFirst(list) any

    Gives the first item of a list, or fails if it isn't a list.

    sprig.mustFirst([1, 2, 3]) == 1
  • sprig.mustFromJsonSprig function
    sprig.mustFromJson(text) any

    Reads JSON text into a value, or fails if it isn't valid JSON.

    sprig.mustFromJson('"hi"') == 'hi'
  • sprig.mustHasSprig function
    sprig.mustHas(value, list) bool

    Reports whether a list holds a value, or fails if it isn't a list.

    sprig.mustHas(2, [1, 2, 3]) == true
  • sprig.mustInitialSprig function
    sprig.mustInitial(list) list

    Gives every item of a list except the last, or fails if it isn't a list.

    sprig.mustInitial([1, 2, 3]) == [1, 2]
  • sprig.mustLastSprig function
    sprig.mustLast(list) any

    Gives the last item of a list, or fails if it isn't a list.

    sprig.mustLast([1, 2, 3]) == 3
  • sprig.mustMergeSprig function
    sprig.mustMerge(dict, ...dicts) dict

    Copies keys from other dicts into the first one, or fails on a bad argument.

    sprig.mustMerge(sprig.dict('a', 1), sprig.dict('b', 2))['b'] == 2
  • sprig.mustMergeOverwriteSprig function
    sprig.mustMergeOverwrite(dict, ...dicts) dict

    Copies keys from other dicts into the first one, overwriting existing keys, or fails on a bad argument.

    sprig.mustMergeOverwrite(sprig.dict('a', 1), sprig.dict('a', 2))['a'] == 2
  • sprig.mustPrependSprig function
    sprig.mustPrepend(list, value) list

    Adds a value onto the front of a list, or fails if it isn't a list.

    sprig.mustPrepend([2, 3], 1) == [1, 2, 3]
  • sprig.mustPushSprig function
    sprig.mustPush(list, value) list

    Adds a value onto the end of a list, or fails if it isn't a list.

    sprig.mustPush([1, 2], 3) == [1, 2, 3]
  • sprig.mustRegexFindSprig function
    sprig.mustRegexFind(pattern text, text) text

    Finds the first match of a regular expression, or fails if the pattern is invalid.

    sprig.mustRegexFind('[0-9]+', 'a123b') == '123'
  • sprig.mustRegexFindAllSprig function
    sprig.mustRegexFindAll(pattern text, text, limit number) list

    Finds every match of a regular expression, or fails if the pattern is invalid.

    sprig.mustRegexFindAll('[0-9]+', 'a1 b22 c333', -1) == ['1', '22', '333']
  • sprig.mustRegexMatchSprig function
    sprig.mustRegexMatch(pattern text, text) bool

    Reports whether text matches a regular expression, or fails if the pattern is invalid.

    sprig.mustRegexMatch('^[a-z]+$', 'abc') == true
  • sprig.mustRegexReplaceAllSprig function
    sprig.mustRegexReplaceAll(pattern text, text, replacement text) text

    Replaces every match of a regular expression, or fails if the pattern is invalid.

    sprig.mustRegexReplaceAll('[0-9]+', 'a123b456', 'X') == 'aXbX'
  • sprig.mustRegexReplaceAllLiteralSprig function
    sprig.mustRegexReplaceAllLiteral(pattern text, text, replacement text) text

    Replaces every match with a literal replacement, or fails if the pattern is invalid.

    sprig.mustRegexReplaceAllLiteral('([a-z]+)', 'abc', '$1$1') == '$1$1'
  • sprig.mustRegexSplitSprig function
    sprig.mustRegexSplit(pattern text, text, limit number) list

    Splits text at each match of a regular expression, or fails if the pattern is invalid.

    sprig.mustRegexSplit(' +', 'a b c', -1) == ['a', 'b', 'c']
  • sprig.mustRestSprig function
    sprig.mustRest(list) list

    Gives every item of a list except the first, or fails if it isn't a list.

    sprig.mustRest([1, 2, 3]) == [2, 3]
  • sprig.mustReverseSprig function
    sprig.mustReverse(list) list

    Reverses the order of a list, or fails if it isn't a list.

    sprig.mustReverse([1, 2, 3]) == [3, 2, 1]
  • sprig.mustSliceSprig function
    sprig.mustSlice(list, start number, end number) list

    Takes a slice of a list between two positions, or fails if it isn't a list.

    sprig.mustSlice([1, 2, 3, 4, 5], 1, 3) == [2, 3]
  • sprig.mustToDateSprig function
    sprig.mustToDate(layout text, text) date

    Parses text into a date, or fails if it doesn't match the layout.

    sprig.mustToDate('2006-01-02', '2024-01-01').Year() == 2024
  • sprig.mustToJsonSprig function
    sprig.mustToJson(value) text

    Turns a value into JSON text, or fails if it can't be.

    sprig.mustFromJson(sprig.mustToJson('hi')) == 'hi'
  • sprig.mustToPrettyJsonSprig function
    sprig.mustToPrettyJson(value) text

    Turns a value into indented JSON text, or fails if it can't be.

    sprig.mustFromJson(sprig.mustToPrettyJson('hi')) == 'hi'
  • sprig.mustToRawJsonSprig function
    sprig.mustToRawJson(value) text

    Turns a value into JSON text without HTML escaping, or fails if it can't be.

    sprig.mustFromJson(sprig.mustToRawJson('hi')) == 'hi'
  • sprig.mustUniqSprig function
    sprig.mustUniq(list) list

    Drops repeated values out of a list, or fails if it isn't a list.

    sprig.mustUniq([1, 2, 2, 3]) == [1, 2, 3]
  • sprig.mustWithoutSprig function
    sprig.mustWithout(list, ...values) list

    Drops matching values out of a list, or fails if it isn't a list.

    sprig.mustWithout([1, 2, 3], 2) == [1, 3]
  • sprig.nindentSprig function
    sprig.nindent(spaces number, text) text

    Same as indent, but with a newline in front too.

    sprig.nindent(2, 'a: 1') == '\n a: 1'
  • sprig.nospaceSprig function
    sprig.nospace(text) text

    Removes every whitespace character from text.

    sprig.nospace('a b c') == 'abc'
  • sprig.nowSprig function
    sprig.now() time

    Gives the current date and time.

    sprig.now().Year() > 2000
  • sprig.omitSprig function
    sprig.omit(dict, ...keys) dict

    Drops the named keys from a dict.

    len(sprig.omit(sprig.dict('a', 1, 'b', 2), 'a')) == 1 && sprig.omit(sprig.dict('a', 1, 'b', 2), 'a')['b'] == 2
  • sprig.osBaseSprig function
    sprig.osBase(path text) text

    Gives the last element of a path, using this server's path style.

    sprig.osBase('/foo/bar/baz.txt') == 'baz.txt'
  • sprig.osCleanSprig function
    sprig.osClean(path text) text

    Simplifies a path, using this server's path style.

    sprig.osClean('/foo/../bar//baz') == '/bar/baz'
  • sprig.osDirSprig function
    sprig.osDir(path text) text

    Gives every element of a path except the last, using this server's path style.

    sprig.osDir('/foo/bar/baz.txt') == '/foo/bar'
  • sprig.osExtSprig function
    sprig.osExt(path text) text

    Gives the file extension of a path, using this server's path style.

    sprig.osExt('/foo/bar.txt') == '.txt'
  • sprig.osIsAbsSprig function
    sprig.osIsAbs(path text) bool

    Reports whether a path is absolute, using this server's path style.

    sprig.osIsAbs('/foo/bar') == true
  • sprig.pickSprig function
    sprig.pick(dict, ...keys) dict

    Keeps only the named keys of a dict.

    len(sprig.pick(sprig.dict('a', 1, 'b', 2), 'a')) == 1 && sprig.pick(sprig.dict('a', 1, 'b', 2), 'a')['a'] == 1
  • sprig.pluckSprig function
    sprig.pluck(key text, dict, ...) list

    Reads one key from several dicts, giving a list of the values found.

    sprig.pluck('a', sprig.dict('a', 1), sprig.dict('a', 2)) == [1, 2]
  • sprig.pluralSprig function
    sprig.plural(one text, many text, count number) text

    Picks the singular or plural word for a count.

    sprig.plural('apple', 'apples', 2) == 'apples'
  • sprig.prependSprig function
    sprig.prepend(list, value) list

    Adds a value onto the front of a list, giving a new list.

    sprig.prepend([2, 3], 1) == [1, 2, 3]
  • sprig.pushSprig function
    sprig.push(list, value) list

    Adds a value onto the end of a list, giving a new list.

    sprig.push([1, 2], 3) == [1, 2, 3]
  • sprig.quoteSprig function
    sprig.quote(value, ...) text

    Wraps each value in double quotes and joins them with a space.

    sprig.quote('a', 'b') == '"a" "b"'
  • sprig.randAlphaSprig function
    sprig.randAlpha(length number) text

    Makes a random string of letters.

    len(sprig.randAlpha(8)) == 8
  • sprig.randAlphaNumSprig function
    sprig.randAlphaNum(length number) text

    Makes a random string of letters and digits.

    len(sprig.randAlphaNum(8)) == 8
  • sprig.randAsciiSprig function
    sprig.randAscii(length number) text

    Makes a random string of ASCII characters.

    len(sprig.randAscii(8)) == 8
  • sprig.randBytesSprig function
    sprig.randBytes(count number) text

    Makes random bytes, base64-encoded.

    len(sprig.b64dec(sprig.randBytes(8))) == 8
  • sprig.randIntSprig function
    sprig.randInt(min number, max number) number

    Picks a random whole number in a range, including the low end and excluding the high end.

    sprig.randInt(5, 6) == 5
  • sprig.randNumericSprig function
    sprig.randNumeric(length number) text

    Makes a random string of digits.

    len(sprig.randNumeric(8)) == 8
  • sprig.regexFindSprig function
    sprig.regexFind(pattern text, text) text

    Finds the first match of a regular expression in text.

    sprig.regexFind('[0-9]+', 'a123b') == '123'
  • sprig.regexFindAllSprig function
    sprig.regexFindAll(pattern text, text, limit number) list

    Finds every match of a regular expression in text, up to a limit (-1 for no limit).

    sprig.regexFindAll('[0-9]+', 'a1 b22 c333', -1) == ['1', '22', '333']
  • sprig.regexMatchSprig function
    sprig.regexMatch(pattern text, text) bool

    Reports whether text matches a regular expression.

    sprig.regexMatch('^[a-z]+$', 'abc') == true
  • sprig.regexQuoteMetaSprig function
    sprig.regexQuoteMeta(text) text

    Escapes the regular expression special characters in text, so it can be matched literally.

    sprig.regexMatch(sprig.regexQuoteMeta('a.b*c'), 'a.b*c') == true
  • sprig.regexReplaceAllSprig function
    sprig.regexReplaceAll(pattern text, text, replacement text) text

    Replaces every match of a regular expression with a replacement, which may use $1 for groups.

    sprig.regexReplaceAll('[0-9]+', 'a123b456', 'X') == 'aXbX'
  • sprig.regexReplaceAllLiteralSprig function
    sprig.regexReplaceAllLiteral(pattern text, text, replacement text) text

    Replaces every match of a regular expression with a replacement, taken literally rather than as $1-style groups.

    sprig.regexReplaceAllLiteral('([a-z]+)', 'abc', '$1$1') == '$1$1'
  • sprig.regexSplitSprig function
    sprig.regexSplit(pattern text, text, limit number) list

    Splits text at each match of a regular expression, up to a limit (-1 for no limit).

    sprig.regexSplit(' +', 'a b c', -1) == ['a', 'b', 'c']
  • sprig.repeatSprig function
    sprig.repeat(count number, text) text

    Repeats text a number of times.

    sprig.repeat(3, 'ab') == 'ababab'
  • sprig.replaceSprig function
    sprig.replace(old text, new text, text) text

    Replaces every occurrence of one piece of text with another.

    sprig.replace('l', 'L', 'hello') == 'heLLo'
  • sprig.restSprig function
    sprig.rest(list) list

    Gives every item of a list except the first.

    sprig.rest([1, 2, 3]) == [2, 3]
  • sprig.reverseSprig function
    sprig.reverse(list) list

    Reverses the order of a list.

    sprig.reverse([1, 2, 3]) == [3, 2, 1]
  • sprig.roundSprig function
    sprig.round(number, places number) number

    Rounds a number to a given number of decimal places.

    sprig.round(3.14159, 2) == 3.14
  • sprig.semverSprig function
    sprig.semver(version text) version

    Parses a semantic version string.

    sprig.semver('1.2.3').String() == '1.2.3'
  • sprig.semverCompareSprig function
    sprig.semverCompare(constraint text, version text) bool

    Reports whether a version satisfies a constraint, such as >=1.0.0.

    sprig.semverCompare('>=1.0.0', '1.2.3') == true
  • sprig.seqSprig function
    sprig.seq(...numbers) text

    Builds a space-separated list of numbers, like a start, step and stop.

    sprig.seq(3) == '1 2 3'
  • sprig.setSprig function
    sprig.set(dict, key text, value) dict

    Sets a key on a dict, giving the same dict back.

    sprig.set(sprig.dict('a', 1), 'b', 2)['b'] == 2
  • sprig.sha1sumSprig function
    sprig.sha1sum(text) text

    Hashes text with SHA-1, as hex.

    len(sprig.sha1sum('abc')) == 40
  • sprig.sha256sumSprig function
    sprig.sha256sum(text) text

    Hashes text with SHA-256, as hex.

    len(sprig.sha256sum('abc')) == 64
  • sprig.sha512sumSprig function
    sprig.sha512sum(text) text

    Hashes text with SHA-512, as hex.

    len(sprig.sha512sum('abc')) == 128
  • sprig.shuffleSprig function
    sprig.shuffle(text) text

    Puts the characters of text in a random order.

    len(sprig.shuffle('abcdef')) == 6
  • sprig.sliceSprig function
    sprig.slice(list, start number, end number) list

    Takes a slice of a list between two positions.

    sprig.slice([1, 2, 3, 4, 5], 1, 3) == [2, 3]
  • sprig.snakecaseSprig function
    sprig.snakecase(text) text

    Turns CamelCase text into snake_case.

    sprig.snakecase('CamelCase') == 'camel_case'
  • sprig.sortAlphaSprig function
    sprig.sortAlpha(list) list

    Sorts a list of text alphabetically.

    sprig.sortAlpha(['b', 'a', 'c']) == ['a', 'b', 'c']
  • sprig.splitSprig function
    sprig.split(sep text, text) dict

    Splits text at a separator into a dict keyed _0, _1, and so on.

    sprig.split(',', 'a,b')['_0'] == 'a' && sprig.split(',', 'a,b')['_1'] == 'b'
  • sprig.splitListSprig function
    sprig.splitList(sep text, text) list

    Splits text at a separator into a list.

    sprig.splitList(',', 'a,b,c') == ['a', 'b', 'c']
  • sprig.splitnSprig function
    sprig.splitn(sep text, n number, text) dict

    Splits text at a separator into at most n pieces, as a dict keyed _0, _1, and so on.

    sprig.splitn(',', 2, 'a,b,c')['_0'] == 'a' && sprig.splitn(',', 2, 'a,b,c')['_1'] == 'b,c'
  • sprig.squoteSprig function
    sprig.squote(value, ...) text

    Wraps each value in single quotes and joins them with a space.

    sprig.squote('a', 'b') == "'a' 'b'"
  • sprig.subSprig function
    sprig.sub(a number, b number) number

    Subtracts one number from another.

    sprig.sub(5, 2) == 3
  • sprig.subfSprig function
    sprig.subf(a number, ...numbers) number

    Subtracts numbers with decimals from the first one.

    sprig.subf(5.5, 2) == 3.5
  • sprig.substrSprig function
    sprig.substr(start number, end number, text) text

    Takes a slice of text between two positions.

    sprig.substr(0, 3, 'hello') == 'hel'
  • sprig.swapcaseSprig function
    sprig.swapcase(text) text

    Swaps upper case letters to lower case and back.

    sprig.swapcase('Hello') == 'hELLO'
  • sprig.ternarySprig function
    sprig.ternary(whenTrue, whenFalse, condition bool) any

    Picks one of two values based on a condition.

    sprig.ternary('yes', 'no', true) == 'yes'
  • sprig.titleSprig function
    sprig.title(text) text

    Capitalizes the first letter of each word.

    sprig.title('hello world') == 'Hello World'
  • sprig.toDateSprig function
    sprig.toDate(layout text, text) date

    Parses text into a date, using this server's local time zone.

    sprig.toDate('2006-01-02', '2024-01-01').Year() == 2024
  • sprig.toDecimalSprig function
    sprig.toDecimal(text) number

    Reads text as a Unix-style octal number and gives it back as decimal.

    sprig.toDecimal('755') == 493
  • sprig.toJsonSprig function
    sprig.toJson(value) text

    Turns a value into JSON text.

    sprig.fromJson(sprig.toJson('hi')) == 'hi'
  • sprig.toPrettyJsonSprig function
    sprig.toPrettyJson(value) text

    Turns a value into indented JSON text.

    sprig.fromJson(sprig.toPrettyJson('hi')) == 'hi'
  • sprig.toRawJsonSprig function
    sprig.toRawJson(value) text

    Turns a value into JSON text, without escaping HTML characters like < and &.

    sprig.fromJson(sprig.toRawJson('hi')) == 'hi'
  • sprig.toStringSprig function
    sprig.toString(value) text

    Turns a value into text.

    sprig.toString(42) == '42'
  • sprig.toStringsSprig function
    sprig.toStrings(list) list

    Turns a list of any values into a list of text.

    sprig.toStrings([1, 2, 3]) == ['1', '2', '3']
  • sprig.trimSprig function
    sprig.trim(text) text

    Removes leading and trailing whitespace.

    sprig.trim(' hi ') == 'hi'
  • sprig.trimallSprig function
    sprig.trimall(cutset text, text) text

    Removes any of a set of characters from both ends of text. Deprecated in favor of trimAll.

    sprig.trimall('$', '$$hi$$') == 'hi'
  • sprig.trimAllSprig function
    sprig.trimAll(cutset text, text) text

    Removes any of a set of characters from both ends of text.

    sprig.trimAll('$', '$$hi$$') == 'hi'
  • sprig.trimPrefixSprig function
    sprig.trimPrefix(prefix text, text) text

    Removes a prefix from text, if it has one.

    sprig.trimPrefix('/root/', '/root/path') == 'path'
  • sprig.trimSuffixSprig function
    sprig.trimSuffix(suffix text, text) text

    Removes a suffix from text, if it has one.

    sprig.trimSuffix('.txt', 'file.txt') == 'file'
  • sprig.truncSprig function
    sprig.trunc(n number, text) text

    Cuts text to a length. A negative length keeps that many characters from the end.

    sprig.trunc(3, 'hello') == 'hel'
  • sprig.tupleSprig function
    sprig.tuple(value, ...) list

    Builds a list out of the values given. Same as list.

    sprig.tuple(1, 2, 3) == [1, 2, 3]
  • sprig.typeIsSprig function
    sprig.typeIs(type text, value) bool

    Reports whether a value is a named Go type.

    sprig.typeIs('string', 'hi') == true
  • sprig.typeIsLikeSprig function
    sprig.typeIsLike(type text, value) bool

    Same as typeIs, but also matches a pointer to that type.

    sprig.typeIsLike('string', 'hi') == true
  • sprig.typeOfSprig function
    sprig.typeOf(value) text

    Names the Go type of a value.

    sprig.typeOf('hi') == 'string'
  • sprig.uniqSprig function
    sprig.uniq(list) list

    Drops repeated values out of a list.

    sprig.uniq([1, 2, 2, 3]) == [1, 2, 3]
  • sprig.unixEpochSprig function
    sprig.unixEpoch(date) text

    Gives the Unix timestamp of a date, as text.

    int(sprig.unixEpoch(sprig.now())) > 1600000000
  • sprig.unsetSprig function
    sprig.unset(dict, key text) dict

    Removes a key from a dict, giving the same dict back.

    sprig.hasKey(sprig.unset(sprig.dict('a', 1, 'b', 2), 'b'), 'b') == false
  • sprig.untilSprig function
    sprig.until(count number) list

    Counts from 0 up to (not including) a number, as a list.

    toJson(sprig.until(3)) == '[0,1,2]'
  • sprig.untilStepSprig function
    sprig.untilStep(start number, stop number, step number) list

    Counts from a start up to a stop, by a step, as a list.

    toJson(sprig.untilStep(0, 10, 4)) == '[0,4,8]'
  • sprig.untitleSprig function
    sprig.untitle(text) text

    Lowercases the first letter of text.

    sprig.untitle('Hello') == 'hello'
  • sprig.upperSprig function
    sprig.upper(text) text

    Turns text to upper case.

    sprig.upper('abc') == 'ABC'
  • sprig.urlJoinSprig function
    sprig.urlJoin(dict) text

    Builds a URL out of a dict of parts.

    sprig.urlJoin(sprig.dict('scheme', 'https', 'host', 'example.com', 'path', '/x')) == 'https://example.com/x'
  • sprig.urlParseSprig function
    sprig.urlParse(url text) dict

    Breaks a URL down into a dict of its parts.

    sprig.urlParse('https://example.com/path?q=1')['host'] == 'example.com'
  • sprig.uuidv4Sprig function
    sprig.uuidv4() text

    Makes a random version 4 UUID.

    len(sprig.uuidv4()) == 36
  • sprig.valuesSprig function
    sprig.values(dict) list

    Lists the values of a dict.

    len(sprig.values(sprig.dict('a', 1, 'b', 2))) == 2 && 1 in sprig.values(sprig.dict('a', 1, 'b', 2))
  • sprig.withoutSprig function
    sprig.without(list, ...values) list

    Drops matching values out of a list.

    sprig.without([1, 2, 3], 2) == [1, 3]
  • sprig.wrapSprig function
    sprig.wrap(width number, text) text

    Wraps text onto new lines so no line is longer than a width.

    sprig.contains('\n', sprig.wrap(5, 'a b c d e')) == true
  • sprig.wrapWithSprig function
    sprig.wrapWith(width number, sep text, text) text

    Wraps text at a width, joining the lines with a separator you choose instead of a newline.

    sprig.contains('|', sprig.wrapWith(5, '|', 'a b c d e')) == true
  • stringexpr-lang builtin
    string(value) text

    Turns a value into text.

    string(123) == '123'
  • sumexpr-lang builtin
    sum(list) number

    Adds up the numbers in a list.

    sum([1, 2, 3]) == 6
  • takeexpr-lang builtin
    take(list, n number) list

    Gives the first n elements of a list.

    take([1, 2, 3, 4], 2) == [1, 2]
  • timezoneexpr-lang builtin
    timezone(name text) timezone

    Looks up a named time zone, for use with dates.

    timezone('UTC') != nil
  • toBase64expr-lang builtin
    toBase64(text) text

    Encodes text as base64.

    toBase64('Hello World') == 'SGVsbG8gV29ybGQ='
  • toJsonArgo function
    toJson(value) text

    Turns a value into JSON text

    toJson(asInt('1')) == '1'
  • toJSONexpr-lang builtin
    toJSON(value) text

    Turns a value into indented JSON text.

    {'name': 'John'} == fromJSON(toJSON({'name': 'John'}))
  • toPairsexpr-lang builtin
    toPairs(dict) list

    Turns a dict into a list of [key, value] pairs.

    toPairs({'name': 'John'})[0][0] == 'name' && toPairs({'name': 'John'})[0][1] == 'John'
  • trimexpr-lang builtin
    trim(text, chars text) text

    Removes whitespace, or a given set of characters, from both ends of text.

    trim(' Hello ') == 'Hello'
  • trimPrefixexpr-lang builtin
    trimPrefix(text, prefix text) text

    Removes a prefix from text, if it has one.

    trimPrefix('HelloWorld', 'Hello') == 'World'
  • trimSuffixexpr-lang builtin
    trimSuffix(text, suffix text) text

    Removes a suffix from text, if it has one.

    trimSuffix('HelloWorld', 'World') == 'Hello'
  • typeexpr-lang builtin
    type(value) text

    Names the type of a value: nil, bool, int, uint, float, string, array or map.

    type(42) == 'int'
  • uniqexpr-lang builtin
    uniq(list) list

    Drops repeated values out of a list.

    uniq([1, 2, 3, 2, 1]) == [1, 2, 3]
  • upperexpr-lang builtin
    upper(text) text

    Turns text to upper case.

    upper('hello') == 'HELLO'
  • valuesexpr-lang builtin
    values(dict) list

    Lists the values of a dict.

    len(values({'name': 'John', 'age': 30})) == 2