Files
n8n-docs/_yaml/data-functions.yml

451 lines
16 KiB
YAML

df_types:
- df_durationUnit: &df_durationUnit
- second
- minute
- hour
- day
- week
- month
- year
df_string:
- funcName: extractDomain
returns: String
description: Extracts a domain from a string containing a valid URL. Returns undefined if none is found.
- funcName: extractEmail
returns: String
description: Extracts an email from a string. Returns undefined if none is found.
- funcName: extractUrl
returns: String
description: Extracts a URL from a string. Returns undefined if none is found.
# - funcName: hash
# args:
# - argName: algo
# optional: true
# longName: Algorithm
# type: String enum
# description: Which hashing algorithm to use.
# default: md5
# options:
# - md5
# - base64
# - sha1
# returns: String
# description: Returns a string hashed with the given algorithm.
- funcName: isDomain
returns: Boolean
description: Checks if a string is a domain.
- funcName: isEmail
returns: Boolean
description: Checks if a string is an email.
- funcName: isEmpty
returns: Boolean
description: Checks if a string is empty.
- funcName: isNotEmpty
returns: Boolean
description: Checks if a string has content.
- funcName: isNumeric
returns: Boolean
description: Checks if a string only contains digits.
- funcName: isUrl
returns: Boolean
description: Checks if a string is a valid URL.
- funcName: isURL
returns: Boolean
description: See <a href="#string-isUrl">isUrl</a>
# - funcName: quote
# args:
# - argName: mark
# optional: true
# longName: String
# type: String
# description: Which quote mark style to use.
# default: >
# "
# returns: String
# description: Returns a string wrapped in the quotation marks. Default quotation is <code>"</code>.
- funcName: removeMarkdown
returns: String
description: Removes Markdown formatting from a string.
- funcName: replaceSpecialChars
returns: String
description: Replaces non-ASCII characters in a string with an ASCII representation.
- funcName: removeTags
returns: String
description: Remove tags, such as HTML or XML, from a string.
- funcName: toDate
returns: Date
description: Converts a string to a date.
- funcName: toDecimalNumber
returns: Number
description: See <a href="#string-toFloat">toFloat</a>
- funcName: toFloat
returns: Number
description: Converts a string to a decimal number.
- funcName: toInt
returns: Number
description: Converts a string to an integer.
- funcName: toSentenceCase
returns: String
description: Formats a string to sentence case.
- funcName: toSnakeCase
returns: String
description: Formats a string to snake case.
- funcName: toTitleCase
returns: String
description: Formats a string to title case.
- funcName: toWholeNumber
returns: Number
description: Converts a string to a whole number.
# - funcName: urlDecode
# args:
# - argName: entireString
# optional: true
# longName: Boolean
# type: Boolean
# description: Whether to decode characters that are part of the URI syntax (true) or not (false).
# default: false
# returns: String
# description: Decodes a URL-encoded string. It decodes any percent-encoded characters in the input string, and replaces them with their original characters.
# - funcName: urlEncode
# args:
# - argName: entireString
# optional: true
# longName: Boolean
# type: Boolean
# description: Whether to encode characters that are part of the URI syntax (true) or not (false).
# default: false
# returns: String
# description: Encodes a string to be used/included in a URL.
df_object:
- funcName: isEmpty
returns: Boolean
description: Checks if the Object has no key-value pairs.
# - funcName: merge
# args:
# - argName: object
# optional: false
# longName: Object
# type: Object
# description: The Object to merge with the base Object.
# returns: Object
# description: Merges two Objects into a single Object using the first as the base Object. If a key exists in both Objects, the key in the base Object takes precedence.
# - funcName: hasField
# args:
# - argName: fieldName
# optional: false
# longName: String
# type: String
# description: The field to search for.
# returns: Boolean
# description: Checks if the Object has a given field. Only top-level keys are supported.
# - funcName: removeField
# args:
# - argName: key
# optional: false
# longName: String
# type: String
# description: The field key of the field to remove.
# returns: Object
# description: Removes a given field from the Object
# - funcName: removeFieldsContaining
# args:
# - argName: value
# optional: false
# longName: String
# type: String
# description: The field value of the field to remove.
# returns: Object
# description: Removes fields with a given value from the Object.
# - funcName: keepFieldsContaining
# args:
# - argName: value
# optional: false
# longName: String
# type: String
# description: The field value of the field to keep.
# returns: Object
# description: Removes fields that do not match the given value from the Object.
- funcName: compact
returns: Object
description: Removes empty values from an Object.
- funcName: urlEncode
returns: String
description: Transforms an Object into a URL parameter list. Only top-level keys are supported.
df_number:
- funcName: ceil
returns: Number
description: Rounds up a number to a whole number.
- funcName: floor
returns: Number
description: Rounds down a number to a whole number.
# - funcName: format
# args:
# - argName: locales
# optional: true
# longName: LanguageCode
# type: String
# description: An IETF BCP 47 language tag.
# default: en-US
# - argName: options
# optional: true
# longName: FormatOptions
# type: Object
# description: Configure options for number formatting. Refer to <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat" target=_blank>MDN | Intl.NumberFormat()</a> for more information.
# returns: String
# description: This is a wrapper around <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat" target=_blank>Intl.NumberFormat()</a>. Returns a formatted string of a number based on the given LanguageCode and FormatOptions. When no arguments are given, transforms the number in a like format 1.234.
- funcName: isEven
returns: Boolean
description: Returns true if the number is even. Only works on whole numbers.
- funcName: isOdd
returns: Boolean
description: Returns true if the number is odd. Only works on whole numbers.
# - funcName: round
# args:
# - argName: decimalPlaces
# optional: true
# longName: Number
# type: Number
# default: "0"
# description: How many decimal places to round to.
# returns: Number
# description: Returns the value of a number rounded to the nearest whole number.
df_date:
# - funcName: beginningOf
# args:
# - argName: unit
# optional: true
# longName: DurationUnit
# type: String enum
# description: A valid string specifying the time unit.
# default: week
# options: *df_durationUnit
# returns: Date
# description: Transform a Date to the start of the given time period.
- funcName: endOfMonth
returns: Date
description: Transforms a Date to the end of the month.
# - funcName: extract
# args:
# - argName: datePart
# optional: true
# longName: DurationUnit
# type: String enum
# description: A valid string specifying the time unit.
# default: week
# options: *df_durationUnit
# returns: Number
# description: Extracts the part defined in datePart from a Date.
# - funcName: format
# args:
# - argName: fmt
# optional: false
# longName: TimeFormat
# type: String enum
# description: A valid string specifying the time format. Refer to <a href="https://moment.github.io/luxon/#/formatting?id=table-of-tokens" target=_blank>Luxon | Table of tokens</a> for formats.
# returns: String
# description: Formats a Date in the given structure
# - funcName: isBetween
# args:
# - argName: date1
# optional: false
# longName: Date | DateTime
# type: Date or DateTime
# description: The first date in the range.
# - argName: date2
# optional: false
# longName: Date | DateTime
# type: Date or DateTime
# description: The last date in the range.
# returns: Boolean
# description: Checks if a Date is between two given dates.
- funcName: isDst
returns: Boolean
description: Checks if a Date is within Daylight Savings Time.
# - funcName: isInLast
# args:
# - argName: n
# optional: true
# longName: Number
# type: Number
# description: The number of units. For example, to check if the date is in the last nine weeks, enter 9.
# default: "0"
# - argName: unit
# optional: true
# longName: DurationUnit
# type: String enum
# description: A valid string specifying the time unit.
# default: minutes
# options: *df_durationUnit
# returns: Boolean
# description: Checks if a Date is within a given time period.
- funcName: isWeekend
returns: Boolean
description: Checks if the Date falls on a Saturday or Sunday.
# - funcName: minus
# args:
# - argName: n
# optional: false
# longName: Number
# type: Number
# description: The number of units. For example, to subtract nine seconds, enter 9 here.
# - argName: unit
# optional: true
# longName: DurationUnit
# type: String enum
# description: A valid string specifying the time unit.
# default: minute
# options: *df_durationUnit
# returns: Date
# description: Subtracts a given time period from a Date.
# - funcName: plus
# args:
# - argName: n
# optional: false
# longName: Number
# type: Number
# description: The number of units. For example, to add nine seconds, enter 9 here.
# - argName: unit
# optional: true
# longName: DurationUnit
# type: String enum
# description: A valid string specifying the time unit.
# default: minute
# options: *df_durationUnit
# returns: Date
# description: Adds a given time period from a Date.
df_array:
- funcName: average
returns: Number
description: Returns the value of elements in an array
# - funcName: chunk
# args:
# - argName: size
# optional: false
# longName: Number
# type: Number
# description: The size of each chunk.
# returns: Array
# description: Splits arrays into chunks with a length of size
- funcName: compact
returns: Array
description: Removes empty values from the array.
# - funcName: difference
# args:
# - argName: arr
# optional: false
# longName: Array
# type: Array
# description: The array to compare to the base array.
# returns: Array
# description: Compares two arrays. Returns all elements in the base array that aren't present in arr.
# - funcName: intersection
# args:
# - argName: arr
# optional: false
# longName: Array
# type: Array
# description: The array to compare to the base array.
# returns: Array
# description: Compares two arrays. Returns all elements in the base array that are present in arr.
- funcName: first
returns: Array item
description: Returns the first element of the array.
- funcName: isEmpty
returns: Boolean
description: Checks if the array doesn't have any elements.
- funcName: isNotEmpty
returns: Boolean
description: Checks if the array has elements.
- funcName: last
returns: Array item
description: Returns the last element of the array.
- funcName: max
returns: Number
description: Returns the highest value in an array.
# - funcName: merge
# args:
# - argName: arr
# optional: false
# longName: Array
# type: Array
# description: The array to merge into the base array.
# returns: Array
# description: Merges two Object-arrays into one array by merging the key-value pairs of each element.
- funcName: min
returns: Number
description: Gets the minimum value from a number-only array.
# - funcName: pluck
# args:
# - argName: fieldName
# optional: false,
# longName: String
# type: String
# description: The key(s) you want to retrieve. You can enter as many keys as you want, as comma-separated strings.
# returns: Array
# description: Returns an array of Objects where keys equal the given field names.
- funcName: randomItem
returns: Array item
description: Returns a random element from an array.
# - funcName: removeDuplicates
# args:
# - argName: key
# optional: true
# longName: String
# type: String
# description: A key, or comma-separated list of keys, to check for duplicates.
# returns: Array
# description: Removes duplicates from an array.
# - funcName: renameKeys
# args:
# - argName: from
# optional: false
# longName: String
# type: String
# description: The key you want to rename.
# - argName: to
# optional: false
# longName: String
# type: String
# description: The new name.
# returns: Array
# description: Renames all matching keys in the array. You can rename more than one key by entering a series of comma separated strings, in the pattern oldKeyName, newKeyName.
# - funcName: smartJoin
# args:
# - argName: keyField
# optional: false
# longName: String
# type: String
# description: The key to join.
# - argName: nameField
# optional: false
# longName: String
# type: String
# description: The value to join.
# returns: Array
# description: Operates on an array of objects where each object contains key-value pairs. Creates a new object containing key-value pairs, where the key is the value of the first pair, and the value is the value of the second pair. Removes non-matching and empty values and trims any whitespace before joining.
# examples:
# - exampleName: Basic usage
# code: _macros/data-function-code/smartjoin-code.md
# output: _macros/data-function-code/smartjoin-output.md
- funcName: sum
returns: Number
description: Returns the total sum all the values in an array of parsable numbers.
# - funcName: union
# args:
# - argName: arr
# optional: false
# longName: Array
# type: Array
# description: The array to compare to the base array.
# returns: Array
# description: Concatenates two arrays and then removes duplicate.
# - funcName: unique
# args:
# - argName: key
# optional: true
# longName: String
# type: String
# description: A key, or comma-separated list of keys, to check for duplicates.
# returns: Array
# description: Remove duplicates from an array.