Tea extends several built-in JavaScript types with additional prototype methods, and also provides static utility methods onDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/pompom454/tea/llms.txt
Use this file to discover all available pages before exploring further.
Math, RegExp, Serial, String, and jQuery. Most are Tea/SugarCube extensions; some are standard JavaScript built-ins documented here for convenience.
Methods marked JS built-in are native JavaScript — consult MDN for the full specification. jQuery extensions are documented fully at api.jquery.com.
Array methods
Array methods
All
Array methods are called on an array instance: $myArray.methodName(...).| Method | Signature | Description |
|---|---|---|
concatUnique | concatUnique(members…) → Array | Concatenates members to a new array, skipping any that already exist. |
count | count(needle [, pos]) → number | Counts how many times needle appears, starting at pos (default 0). |
countWith | countWith(predicate [, thisArg]) → number | Counts members that pass a predicate function. |
deleteAll | deleteAll(needles…) → Array | Removes all instances of the given values. Returns the removed items. |
deleteAt | deleteAt(indices…) → Array | Removes members at the given zero-based indices. Returns the removed items. |
deleteFirst | deleteFirst(needles…) → Array | Removes the first instance of each given value. Returns the removed items. |
deleteLast | deleteLast(needles…) → Array | Removes the last instance of each given value. Returns the removed items. |
deleteWith | deleteWith(predicate [, thisArg]) → Array | Removes all members that pass the predicate. Returns the removed items. |
first | first() → any | Returns the first member without modifying the array. |
includesAll | includesAll(needles…) → boolean | Returns true if all given values are present. |
includesAny | includesAny(needles…) → boolean | Returns true if any given value is present. |
last | last() → any | Returns the last member without modifying the array. |
pluck | pluck() → any | Removes and returns a random member. Modifies the array. |
pluckMany | pluckMany(want) → Array | Removes and returns want randomly chosen unique members. |
pushUnique | pushUnique(members…) → number | Appends members that don’t already exist. Returns new length. |
random | random() → any | Returns a random member without modifying the array. |
randomMany | randomMany(want) → Array | Returns a new array of want randomly chosen unique members without modifying the original. |
shuffle | shuffle() → Array | Randomly shuffles the array in-place. Returns the array. |
toShuffled | toShuffled() → Array | Returns a new randomly shuffled copy. Does not modify the original. |
toUnique | toUnique() → Array | Returns a new copy with all duplicates removed. Does not modify the original. |
unshiftUnique | unshiftUnique(members…) → number | Prepends members that don’t already exist. Returns new length. |
deleteWith predicate example:jQuery methods
jQuery methods
Tea adds several accessibility and wikification helpers to the jQuery prototype and to the Instance methods (called on
Makes element(s) fully keyboard-accessible clickables. Sets ARIA attributes and registers both mouse-click and Enter/Space key handlers. Returns the jQuery instance for chaining.Options object properties:
Changes the disabled state of WAI-ARIA clickable element(s) created via
Returns
Wikifies TwineScript markup in
Wikifies the named passage and appends its rendered output to the target element(s).
Static methods (called on
Wikifies the given markup and discards the output. Useful for invoking macros purely for their side-effects.
Wikifies the named passage and discards the output.
$/jQuery static object.Instance methods (called on $(selector))
<jQuery>.ariaClick([options,] handler) → jQuery
Makes element(s) fully keyboard-accessible clickables. Sets ARIA attributes and registers both mouse-click and Enter/Space key handlers. Returns the jQuery instance for chaining.Options object properties:namespace(string) — Period-separated event namespaces.one(boolean) — Single-use handler. Default:false.selector(string) — Delegated event filter selector.data(any) — Data passed asevent.data.tabindex(number) —tabindexattribute value. Default:0.controls(string) —aria-controlsattribute value.pressed(string) —aria-pressedattribute value ("true"or"false").label(string) —aria-labelandtitleattribute value.
<jQuery>.ariaDisabled(state) → jQuery
Changes the disabled state of WAI-ARIA clickable element(s) created via ariaClick().<jQuery>.ariaIsDisabled() → boolean
Returns true if any of the targeted WAI-ARIA clickable element(s) are currently disabled.<jQuery>.wiki(sources…) → jQuery
Wikifies TwineScript markup in sources and appends the result to the target element(s). Returns the jQuery instance for chaining.<jQuery>.wikiPassage(passageName) → jQuery
Wikifies the named passage and appends its rendered output to the target element(s).Static methods (called on $ or jQuery)
jQuery.wiki(sources…)
Wikifies the given markup and discards the output. Useful for invoking macros purely for their side-effects.jQuery.wikiPassage(passageName)
Wikifies the named passage and discards the output.Math methods
Math methods
Math.clamp(num, min, max) → number
Returns num clamped to the range [min, max]. Does not modify the original.The number to clamp. May be a numeric string.
The lower bound.
The upper bound.
Math.trunc(num) → number
(JavaScript built-in) Returns the integer part of num by removing any fractional digits. Does not round.RegExp methods
RegExp methods
Serial methods
Serial methods
Serial.createReviver(code [, data]) → Array
Returns the given code string (and optional data chunk) wrapped in the deserialization reviver format. Intended for use inside a custom class’s .toJSON() method so instances can be properly revived when deserializing story saves.JavaScript code string that reconstructs the instance. The special variable
$ReviveData$ holds the passed data during revival.Data to make available as
$ReviveData$ during revival. Do not pass this directly — pass a clone of the instance’s own data to avoid infinite recursion in the serializer.String methods
String methods
All
Returns the number of times
Returns the first Unicode code point of the string as a new string. Correctly handles multi-unit code points (e.g., emoji).
Returns the last Unicode code point of the string as a new string.
Returns
Returns
Returns a new string with the first character converted to uppercase using the locale-aware rules of
Returns a new string with the first character converted to uppercase using standard
Static method. Returns a formatted string by replacing
String instance methods are called on a string value: $myString.methodName(...).<String>.count(needle [, position]) → number
Returns the number of times needle appears within the string, starting at position (default 0). Case-sensitive.<String>.first() → string
Returns the first Unicode code point of the string as a new string. Correctly handles multi-unit code points (e.g., emoji).<String>.last() → string
Returns the last Unicode code point of the string as a new string.<String>.includesAll(needles…) → boolean
Returns true if all given substrings are found within the string.<String>.includesAny(needles…) → boolean
Returns true if any given substring is found within the string.<String>.toLocaleUpperFirst() → string
Returns a new string with the first character converted to uppercase using the locale-aware rules of toLocaleUpperCase().<String>.toUpperFirst() → string
Returns a new string with the first character converted to uppercase using standard toUpperCase() rules.String.format(format, arguments…) → string
Static method. Returns a formatted string by replacing {index} format items with the corresponding arguments. Supports optional alignment: {index,alignment} where a positive alignment right-pads and a negative alignment left-pads the field.The format string containing
{index} or {index,alignment} placeholders.Values corresponding by index to the placeholders. May be a list or a single array.