You’re reading the ZotLit v2 docs. Still on v1? Read the v1 docs

ZotLit

Filter Expression functions and methods

Look up what each function, method, and property returns when you filter papers in a ZotLit Query or match them in a Profile Match.

This reference lists every function, method, and property of the Filter Expression language. You write Filter Expressions in the filters and formulas of a query file and in a Profile Match.

Each signature shows the parameters and the type of the result. A parameter marked ? can be left out, and ... takes any number of arguments. A result can also be null when data is missing.

Global functions

A global function is called by its name, such as today().

SignatureDescription
if(condition: any, then: any, else?: any) → anyThe then value when the condition is truthy, otherwise the else value or null; only the selected branch is evaluated.
number(value: any) → numberThe value as a number: a text by the decimal number it starts with, a boolean as 1 or 0, and a date as its timestamp; an empty or blank text gives null, and a text that starts with no number an Error Value.
min(...values: number | null) → numberThe smallest number among the arguments, or null when no argument is a number.
max(...values: number | null) → numberThe largest number among the arguments, or null when no argument is a number.
now() → dateThe instant of the Query Clock as a date with a time, the same for every call in one query.
today() → dateThe calendar day of the Query Clock in the query time zone, as a date.
date(text: string | date) → dateThe text read as a date, or a date unchanged; an empty or blank text gives null, and a text that is not a date an Error Value.
duration(text: string) → durationThe text read as a duration, such as "7d" or "PT1H30M"; an empty or blank text gives null, and a text that is not a duration an Error Value.
list(value: any) → listThe value as a list: a list unchanged, null as the empty list, and any other value as a list of that one element.

Methods

A method is called on a value, such as title.lower(). Each group lists the methods of one value type.

Methods of every value

SignatureDescription
any.toString() → stringThe value as text.
any.isType(type: "any" | "null" | "boolean" | "record" | "number" | "string" | "list" | "date" | "duration" | "regexp" | "error") → booleanWhether the value has the named value type; any names every type.
any.isTruthy() → booleanWhether the value is truthy: false for null, false, 0, the empty text, the empty list, an empty duration, and an Error Value.

Null methods

SignatureDescription
null.isEmpty() → booleanTrue: null is empty.

Number methods

SignatureDescription
number.isEmpty() → booleanFalse: a number is never empty.
number.round(digits?: number) → numberThe number rounded to the nearest integer, or to digits decimal places.
number.ceil() → numberThe number rounded up to an integer.
number.floor() → numberThe number rounded down to an integer.
number.abs() → numberThe absolute value of the number.
number.toFixed(precision: number) → stringThe number as text with precision decimal places, from 0 to 100.

String methods

SignatureDescription
string.isEmpty() → booleanWhether the text is the empty text.
string.lower() → stringThe text in lower case.
string.startsWith(prefix: string) → booleanWhether the text starts with prefix.
string.endsWith(suffix: string) → booleanWhether the text ends with suffix.
string.contains(text: string) → booleanWhether text occurs in the text.
string.containsAny(...texts: string) → booleanWhether the text contains at least one of texts.
string.containsAll(...texts: string) → booleanWhether the text contains every one of texts.
string.trim() → stringThe text without its leading and trailing whitespace.
string.title() → stringThe text with its first code point and each code point after whitespace in upper case.
string.repeat(count: number) → stringThe text repeated count times, for a count from 0 to 10000 and a result of at most 1000000 UTF-16 code units.
string.reverse() → stringThe text with its code points in reverse order.
string.slice(start: number, end?: number) → stringThe part of the text from index start up to, not including, end, counted in UTF-16 code units; a negative index counts from the end.
string.replace(pattern: string | regexp, replacement: string) → stringThe text with every occurrence of a text pattern replaced, or with the matches of a regexp pattern replaced as JavaScript does.
string.split(separator: string | regexp, n?: number) → listThe list of the parts of the text between occurrences of separator, with the captures of a regexp separator between them (null for a group that does not take part), keeping the first n elements when n is given.

List methods

SignatureDescription
list.isEmpty() → booleanWhether the list has no elements.
list.contains(value: any) → booleanWhether the list has an element equal to value.
list.containsAny(...values: any) → booleanWhether the list has an element equal to at least one of the values, or of the elements of a single list argument.
list.containsAll(...values: any) → booleanWhether the list has an element equal to each of the values, or to each element of a single list argument.
list.flat() → listThe list with each element that is a list replaced by its elements, one level deep.
list.join(separator: string) → stringThe elements of the list as text joined by separator, with null as the empty text.
list.reverse() → listThe list with its elements in reverse order.
list.slice(start: number, end?: number) → listThe elements of the list from index start up to, not including, end; a negative index counts from the end.
list.sort() → listThe list in ascending order: numbers by value, texts in the ZotLit Query collation, dates by their start, false before true, and elements of different types grouped by type.
list.unique() → listThe list with only the first of each group of equal elements.
list.filter(expression: any) → listThe elements of the list for which the expression, with value and index bound, is truthy. The expression can use value and index.
list.map(expression: any) → listThe list of the results of the expression for each element, with value and index bound. The expression can use value and index.
list.reduce(expression: any, initial: any) → anyThe result of the expression run on each element in turn, with value, index, and acc bound, where acc is the previous result, starting from initial. The expression can use value, index, and acc.
list.within(path: string) → booleanWhether the list of Collection paths holds the Collection at path or a Collection below it.

Date methods

SignatureDescription
date.isEmpty() → booleanFalse: a date is never empty.
date.date() → dateThe calendar day of a timestamp in the query time zone, or a calendar date unchanged.
date.time() → stringThe time of day of the date in the query time zone, as HH:MM:SS text.
date.format(pattern: string) → stringThe date as text, with the tokens YYYY, MM, DD, HH, mm, and ss of pattern replaced by its parts in the query time zone.
date.relative() → stringThe date as text relative to the Query Clock, such as 3 days ago or in 2 hours.

Regexp methods

SignatureDescription
regexp.matches(text: string) → booleanWhether the regexp matches somewhere in text, or at its start for a regexp with the y flag.

Properties

A property is read from a value without a call, such as title.length.

String properties

SignatureDescription
string.length → numberThe number of UTF-16 code units in the text.

List properties

SignatureDescription
list.length → numberThe number of elements in the list.

Date properties

SignatureDescription
date.year → numberThe year of the date, in the query time zone for a timestamp.
date.month → numberThe month of the date from 1 to 12, in the query time zone for a timestamp, or null for a date of only a year.
date.day → numberThe day of the month of the date, in the query time zone for a timestamp, or null for a date without a day.
date.hour → numberThe hour of the date from 0 to 23 in the query time zone, 0 for a calendar date.
date.minute → numberThe minute of the date in the query time zone, 0 for a calendar date.
date.second → numberThe second of the date in the query time zone, 0 for a calendar date.
date.millisecond → numberThe millisecond of the date in the query time zone, 0 for a calendar date.
date.timestamp → numberThe Unix time in milliseconds of a timestamp, or of the start of a calendar date in the query time zone.

Last updated on

On this page