apps-script-utils 2.1.1 Help

Base utilities

Framework-agnostic functions for type checking and validation (isX/nonX/requireX), string, array, and object manipulation, and JSON/HTML handling. These do not depend on the Google Apps Script runtime.

A New marker indicates a function added in the latest release; a Deprecated marker indicates a function scheduled for removal in a future release.

Function

Return type

Brief description

chunk

Array

Divides an array into multiple smaller arrays of a specified size.

compact New

Array

Drops every falsy value from an array, narrowing the element type without a cast.

decodeHtml

String

Decodes HTML entities (e.g., &-> &) back to plain text.

diff New

Number

Returns the interval between two dates in a chosen unit, counting calendar units by the calendar.

encodeHtml

String

Encodes a string for safe rendering in HTML.

equals New

Boolean

Compares two values deeply and null-safely; the counterpart of hashCode.

escapeHtml

String

Escapes special characters (<, >, &, etc.) for HTML.

escapeRegExp

String

Escapes special characters for safe use within regular expressions.

escapeXml

String

Escapes special characters for safe use in XML documents.

first New

Any

Takes the first element of an array, or its first n elements.

flat New

Object

Flattens a nested object into a single level of dotted keys, keeping arrays whole.

getDaysInMonth New

Number

Returns the number of calendar days in the month a given date falls in.

getDaysLeftInMonth New

Number

Returns the number of calendar days between a date and the end of its month.

getPath New

Any

Reads a nested property by path, returning a fallback when the path does not resolve.

hashCode

Number

Generates a numeric hash code for a given string.

intersect New

Array

Finds the values present in every given array, in the order of the first.

is2DArray

Boolean

Validates if a value is a two-dimensional array.

isArray

Boolean

Validates if a value is an Array.

isBoolean

Boolean

Validates if a value is a boolean.

isConsistent2DArray

Boolean

Validates if a 2D array has uniform inner array lengths.

isCountable

Boolean

Checks if a value is a non-negative safe integer.

isDouble New

Boolean

Checks if a value is a finite number carrying a fractional part; a synonym of isFloat.

isEmail

Boolean

Validates if a string follows a proper email format.

isEmpty

Boolean

Checks if a value is considered empty (null, undefined, empty string/array/object).

isException

Boolean

Validates if a value is an instance of Exception or a derived class.

isFloat New

Boolean

Checks if a value is a finite number carrying a fractional part.

isFunction

Boolean

Validates if a value is a function.

isFunctionLike

Boolean

Validates if a value is "function-like" (e.g., callable).

isInteger

Boolean

Checks if a value is a number and an integer.

isLength

Boolean

Validates if a value is a valid array-like length.

isNaN New

Boolean

Checks if a value is the NaN number, without the coercion the global isNaN performs.

isNil

Boolean

Checks if a value is null or undefined.

isNonNegative New

Boolean

Checks if a value is a number greater than or equal to zero.

isNull

Boolean

Checks if a value is null.

isNumber

Boolean

Validates if a value is a number.

isNumberLike

Boolean

Checks if a value can be reliably converted to a number.

isObject

Boolean

Validates if a value is a plain object (excluding null and arrays).

isObjectLike

Boolean

Checks if a value is an object (including arrays and functions).

isRegExp

Boolean

Validates if a value is a regular expression.

isSafeInteger New

Boolean

Checks if a value is a number and a safe integer (exactly representable as an IEEE-754 double).

isScalar

Boolean

Checks if a value is a primitive scalar type (string, number, boolean, symbol, bigint).

isString

Boolean

Validates if a value is a string.

isSymbol

Boolean

Validates if a value is a symbol.

last New

Any

Takes the last element of an array, or its last n elements in their original order.

merge New

String

Substitutes object values into {{ key }} placeholders in a template string.

nonDouble New

Boolean

Validates if a value is not a finite number carrying a fractional part; a synonym of nonFloat.

nonEmptyString Deprecated

String

Validates that the given value is a non-empty string. Use requireNonEmptyString instead.

isUndefined

Boolean

Checks if a value is undefined.

isUrl

Boolean

Validates if a string is a properly formatted URL.

isValidLocale

Boolean

Validates if a string is a valid BCP 47 locale code.

isValidSlug

Boolean

Validates if a string is a URL-friendly slug.

isValidVersion

Boolean

Validates if a string follows Semantic Versioning rules.

isVersionCompatible

Boolean

Determines if two version strings are compatible based on SemVer.

non2DArray New

Boolean

Validates if a value is not a two-dimensional array.

nonArray

Boolean

Checks if a value is NOT an Array.

nonBoolean

Boolean

Checks if a value is NOT a boolean.

nonConsistent2DArray New

Boolean

Validates if a 2D array does not have uniform inner array lengths.

nonEmpty

Boolean

Checks if a value is NOT empty.

nonException New

Boolean

Validates if a value is not an instance of Exception or a derived class.

nonFloat New

Boolean

Validates if a value is not a finite number carrying a fractional part.

nonFunction New

Boolean

Checks if a value is NOT a Function.

nonCountable New

Boolean

Validates if a value is not a countable number (a non-negative safe integer).

nonFunctionLike New

Boolean

Validates if a value is not "function-like" (e.g., callable).

nonInteger New

Boolean

Validates if a value is not a number and an integer.

nonLength New

Boolean

Validates if a value is not a valid array-like length.

nonNaN New

Boolean

Validates if a value is not the NaN number, without coercing it first.

nonNil

Boolean

Checks if a value is NOT null or undefined.

nonNull

Boolean

Checks if a value is NOT null.

nonNegative Deprecated

Boolean

Checks if a value is a non-negative number. Use isNonNegative instead.

nonNumber

Boolean

Checks if a value is NOT a number.

nonNumberLike New

Boolean

Validates if a value is not a number in a broader sense (e.g., a numeric string).

nonObject New

Boolean

Validates if a value is not an Object.

nonObjectLike New

Boolean

Validates if a value is not an object in a broader sense (functions included).

nonRegExp New

Boolean

Validates if a value is not a regular expression.

nonSafeInteger New

Boolean

Validates if a value is not a safe integer.

nonScalar

Boolean

Checks if a value is NOT a scalar type.

nonString

Boolean

Checks if a value is NOT a string.

nonSymbol

Boolean

Checks if a value is NOT a Symbol.

nonUndefined

Boolean

Checks if a value is NOT undefined.

nonUrl New

Boolean

Validates if a value is not a properly formatted URL.

nonValidEmail New

Boolean

Validates if a string is not a properly formatted email address.

nonValidLocale New

Boolean

Validates if a string is not a valid locale code.

nonValidSlug New

Boolean

Validates if a string is not a valid slug.

nonValidVersion New

Boolean

Validates if a string is not a valid version.

nonVersionCompatible New

Boolean

Validates if one version is not compatible with (i.e. lower than) another.

now

Number

Returns the current timestamp in milliseconds.

ObjectTag

Enum

Enum representing Object#toString result references in uppercase.

objectToString

String

Converts a value to its Object#toString tag, e.g. [object Array].

offset New

Date

Shifts a date by an interval and returns a new Date, never mutating the input.

parseJson Deprecated

Object

Safely parses a JSON string, handling potential errors.

require2DArray New

Array

Ensures a value is a non-empty two-dimensional array, throwing otherwise.

requireArray New

Array

Ensures a value is an Array, throwing IllegalArgumentException otherwise.

requireBoolean New

Boolean

Ensures a value is a boolean, throwing IllegalArgumentException otherwise.

requireConsistent2DArray New

Array

Ensures a 2D array has uniform inner array lengths, throwing otherwise.

requireCountable New

Number

Ensures a value is a countable number (a non-negative safe integer), throwing otherwise.

requireDouble New

Number

Ensures a value is a finite number carrying a fractional part, throwing otherwise; a synonym of requireFloat.

requireEmpty New

Any

Ensures a value is empty, throwing IllegalArgumentException otherwise.

requireException New

Exception

Ensures a value is an Exception or a derived class, throwing otherwise.

requireFloat New

Number

Ensures a value is a finite number carrying a fractional part, throwing otherwise.

requireFunction New

Function

Ensures a value is a function, throwing IllegalArgumentException otherwise.

requireFunctionLike New

Function

Ensures a value is callable in a broader sense, throwing IllegalArgumentException otherwise.

requireInteger New

Number

Ensures a value is an integer, throwing IllegalArgumentException otherwise.

requireLength New

Number

Ensures a value is a valid array-like length, throwing IllegalArgumentException otherwise.

requireNaN New

Number

Ensures a value is the NaN number, without coercing it first, throwing otherwise.

requireNil New

Null | Undefined

Ensures a value is null or undefined, throwing otherwise.

requireNonArray New

Any

Ensures a value is not an Array, throwing IllegalArgumentException otherwise.

requireNonBoolean New

Any

Ensures a value is not a boolean, throwing IllegalArgumentException otherwise.

requireNonDouble New

Any

Ensures a value is not a finite number carrying a fractional part, throwing otherwise; a synonym of requireNonFloat.

requireNonEmpty New

Any

Ensures a value is not empty, throwing IllegalArgumentException otherwise.

requireNonFloat New

Any

Ensures a value is not a finite number carrying a fractional part, throwing otherwise.

requireNonInteger New

Any

Ensures a value is not an integer, throwing otherwise.

requireNonNaN New

Any

Ensures a value is not the NaN number, throwing otherwise.

requireNonSafeInteger New

Any

Ensures a value is not a safe integer, throwing otherwise.

requireSafeInteger New

Number

Ensures a value is a safe integer (exactly representable as an IEEE-754 double), throwing otherwise.

requireSymbol New

Symbol

Ensures a value is a Symbol, throwing IllegalArgumentException otherwise.

requireNonEmptyString

String

Ensures a string is not empty, otherwise throws an exception.

requireNonException New

Any

Ensures a value is not an Exception, throwing IllegalArgumentException otherwise.

requireNonFunction New

Any

Ensures a value is not a function, throwing IllegalArgumentException otherwise.

requireNonFunctionLike New

Any

Ensures a value is not callable, throwing IllegalArgumentException otherwise.

requireNoNilElements New

Array

Throws IllegalArgumentException if an array, Set or Map holds a null or undefined element.

requireNonLength New

Any

Ensures a value is not a valid array-like length, throwing IllegalArgumentException otherwise.

requireNonNil New

Any

Ensures a value is neither null nor undefined, throwing IllegalArgumentException.

requireNonNull

any

Ensures a value is not null, otherwise throws an exception.

requireNonNumber New

Any

Ensures a value is not a number, throwing IllegalArgumentException otherwise.

requireNonNumberLike New

Any

Ensures a value is not numeric in a broader sense, throwing IllegalArgumentException otherwise.

requireNonObject New

Any

Ensures a value is not an Object, throwing IllegalArgumentException otherwise.

requireNonObjectLike New

Any

Ensures a value is not object-like (functions included), throwing IllegalArgumentException otherwise.

requireNonRegExp New

Any

Ensures a value is not a regular expression, throwing IllegalArgumentException otherwise.

requireNonScalar New

Any

Ensures a value is not a scalar primitive, throwing IllegalArgumentException otherwise.

requireNonString New

Any

Ensures a value is not a string, throwing IllegalArgumentException otherwise.

requireNonSymbol New

Any

Ensures a value is not a Symbol, throwing IllegalArgumentException otherwise.

requireNonUndefined New

Any

Ensures a value is not undefined, throwing IllegalArgumentException otherwise.

requireNull New

Null

Ensures a value is null, throwing IllegalArgumentException otherwise.

requireNumber New

Number

Ensures a value is a number, throwing IllegalArgumentException otherwise.

requireNumberLike New

Number | String

Ensures a value is numeric in a broader sense (a number or a numeric string), throwing otherwise.

requireObject New

Object

Ensures a value is an Object, throwing IllegalArgumentException otherwise.

requireObjectLike New

Object

Ensures a value is object-like (functions included), throwing IllegalArgumentException otherwise.

requireRegExp New

RegExp

Ensures a value is a regular expression, throwing IllegalArgumentException otherwise.

requireScalar New

Scalar

Ensures a value is a scalar primitive, throwing IllegalArgumentException otherwise.

requireState New

void

Throws IllegalStateException when a condition does not hold.

requireString

String

Ensures a value is a string, otherwise throws an exception.

requireUndefined New

Undefined

Ensures a value is undefined, throwing IllegalArgumentException otherwise.

requireUrl New

String

Ensures a value is a properly formatted URL, throwing otherwise.

requireValidEmail

String

Ensures a string is a valid email, otherwise throws an exception.

requireValidLocale New

String

Ensures a string is a valid locale code, throwing otherwise.

requireValidSlug New

String

Ensures a string is a valid slug, throwing otherwise.

requireValidVersion New

String

Ensures a string is a valid version, throwing otherwise.

requireVersionCompatible New

String

Ensures one version is at least another, throwing otherwise.

retry New

T

Calls a function until it succeeds, waiting longer between each failure.

setPath New

Object

Writes a nested property by path, creating missing levels and refusing prototype keys.

StopWatch New

StopWatch

Times a sequence of named tasks and prints a breakdown.

stringifyJson

String

Safely converts an object to a JSON string.

toCamelCase

String

Converts a string to camelCase.

toInteger

Number \| null

Converts a value to an integer, returning null on failure.

toKebabCase

String

Converts a string to kebab-case.

toLowerCase

String

Converts a string to lowercase.

toProperCase

String

Converts a string to Proper Case (capitalizing the first letter of each word).

toSnakeCase

String

Converts a string to snake_case.

toUpperCase

String

Converts a string to uppercase.

transpose

Array

Flips a 2D array over its diagonal (swaps rows and columns).

unique New

Array

Removes duplicates from an array, keeping the first occurrence of each value.

versionCompare

Number

Compares two version strings, returning -1, 0, or 1.

without New

Array

Excludes the given values from an array, comparing with SameValueZero.

23 September 2026

This documentation was generated with AI (Claude) from the library's source code.