Builds a URL query string from an object of parameters.
ReadonlyconstantThe constant property is a container for pre-defined constants.
ReadonlyKEY_DELETE: 51Key code for the Delete (⌫) key.
ReadonlyKEY_DOWNARROW: 125Key code for the Down Arrow key.
ReadonlyKEY_ESCAPE: 53Key code for the Escape key.
ReadonlyKEY_LEFTARROW: 123Key code for the Left Arrow key.
ReadonlyKEY_RETURN: 36Key code for the Return (↵) key.
ReadonlyKEY_RIGHTARROW: 124Key code for the Right Arrow key.
ReadonlyKEY_SPACE: 49Key code for the space bar.
ReadonlyKEY_TAB: 48Key code for the Tab (⇥) key.
ReadonlyKEY_UPARROW: 126Key code for the Up Arrow key.
ReadonlyMODIFIER_COMMAND: 1048576Bit mask for the Command (⌘) key.
ReadonlyMODIFIER_CONTROL: 262144Bit mask for the Control (⌃) key.
ReadonlyMODIFIER_OPTION: 524288Bit mask for the Option (⌥) key.
ReadonlyMODIFIER_SHIFT: 131072Bit mask for the Shift (⇧) key.
Information about the user's locale, as configured in macOS settings. Values are read afresh on each access. A value the locale does not define is the empty string.
ISO 4217 currency code, e.g. "GBP".
Currency symbol, e.g. "£".
Decimal separator for numbers, e.g. ".".
Thousands separator for numbers, e.g. ",".
ISO 639 language code, e.g. "en".
Locale identifier, e.g. "en_GB".
ISO 3166 region code, e.g. "GB".
Parses a URL query string into an object of parameters.
Information about the current time zone, as configured in macOS settings. Values are read afresh on each access.
Abbreviation for the zone in its current state, e.g. "GMT" or "BST".
Whether daylight saving time is currently in effect.
Zone identifier from the IANA database, e.g. "Europe/London".
Current offset from GMT in seconds, including any daylight saving offset.
Decode a Base-64 string and interpret the result as a UTF-8 string.
Accepts both standard and URL-safe variants as input. Also accepts input with or without the =/== end padding.
Throws an error if the input cannot be decoded as a UTF-8 string.
The decoded string
Encode a string as UTF-8 then Base-64 encode the result.
The string to encode.
Optionaloptions: { trimmed?: boolean; urlSafe?: boolean }
Optionaltrimmed?: booleanWhether to trim the =/== padding from the string. Default is no.
OptionalurlSafe?: booleanWhether to encode using the URL-safe variant, with - and _ substituted for + and /. Default is no.
Whether the text contains no misspellings, checked in the given language.
The language must be a code from getSpellingLanguages; any other value throws, so intersect a saved option value with the available list before passing it — a saved language can go stale.
The text to check.
language: the spell checker language code to check in.
Decipher a JSON object that has been lightly obscured to prevent constants such as API client identifiers appearing in plaintext in the source files.
This function will ROT13 decipher the text, apply Base64 decoding, and parse the result as JSON.
Sanitizes an HTML string, removing scripts, styles and other unsafe markup, using sanitize-html.
The HTML to sanitize.
Optionaloptions: object
Reserved; the current implementation ignores it.
The definition of this text from macOS's Dictionary Services, as plain text, or
undefined if the text has no definition.
To open the text in the Dictionary app instead of reading its definition, use
popclip.openUrl with a dict:// URL.
The text to define.
The user's preferred languages (per macOS Language settings), filtered to those the spell checker can check.
Fill the provided TypedArray with cryptographically secure random values.
This aims to work like crypto.getRandomValues() from Web Crypto API.
Internally, it is implemented using Apple's SecRandomCopyBytes.
The array to fill with random values. This will be modified in place.
Replacement guesses for a misspelled word, in the given language. Guesses are returned only when the whole text is a single misspelled word — a sentence containing a misspelling is not a candidate for replacement, so it yields an empty array, as do correctly-spelled words and misspellings or non-words that the checker has no suggestions for.
The same language rule as checkSpelling applies.
The text to get guesses for.
language: the spell checker language code; limit: cap the number of
guesses returned (omit for all).
The languages the system spell checker can check on this Mac, as objects pairing the spell
checker's language code (for example "en", "de", "pt_BR") with a display name
localized for the user's locale. Suitable for building a language option's values and
valueLabels.
Generate hash-based message authentication code (HMAC) using the supplied data, key and algorithm. Implemented internally by Apple's CommonCrypto.
Converts an HTML string to Markdown, using Turndown.
The HTML to convert.
Optionaloptions: object
Turndown options. Defaults to { headingStyle: "atx" }.
Localize an English string into the current user interface language, if possible. This will work for strings which match the name of a built-in action.
The string to localize.
The localized string, or the original string if no localized version was available.
Generate a random integer in range [0, max] with uniform distribution using a cryptographically secure random source.
Maximum value to generate. Supplied value will be coerced to a 32-bit unsigned integer.
Generate a RFC 4122 version 4 UUID using a cryptographically secure random number generator.
UUID string such as "e621e1f8-c36c-495a-93fc-0c247a3e6e5f".
A container for various utility functions and constants, available as the global util object.