Options
All
  • Public
  • Public/Protected
  • All
Menu

A container for various utility functions and constants util object.

Hierarchy

  • Util

Index

Methods

  • base64Decode(string: string): string
  • 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.

    Parameters

    • string: string

    Returns string

    The decoded string

  • base64Encode(string: string, options?: { trimmed?: boolean; urlSafe?: boolean }): string
  • Encode a string as UTF-8 then Base-64 encode the result.

    Parameters

    • string: string

      The string to encode.

    • Optional options: { trimmed?: boolean; urlSafe?: boolean }
      • Optional trimmed?: boolean

        Whether to trim the =/== padding from the string. Default is no.

      • Optional urlSafe?: boolean

        Whether to encode using the URL-safe variant, with - and _ substituted for + and /. Default is no.

    Returns string

  • buildQuery(params: {}): string
  • Build a query from params object

    Parameters

    • params: {}

      Returns string

    • buildQueryUrl(baseUrl: string, params: {}): string
    • Build a URL from a base URL and additional query parameters

      Parameters

      • baseUrl: string
      • params: {}

        Returns string

      • clarify(obscuredString: string): any
      • Decipher a JSON object that has been lightly obscured to prevent constants such as API keys appearing in plaintext in the source files.

        This function will ROT13 decipher the text, apply Base64 decoding, and parse the result as JSON.

        Parameters

        • obscuredString: string

        Returns any

      • localize(string: string): string
      • Localize an English string into the current user interface language, if possible. This will work for strings which match an existing string in PopClip's user interface.

        Parameters

        • string: string

          The string to localize.

        Returns string

        The localized string, or the original string if no localized version was avaiable.

      • parseQuery(query: string): any
      • Parse a query into params object

        Parameters

        • query: string

        Returns any

      Properties

      constant: { KEY_DELETE: 51; KEY_DOWNARROW: 125; KEY_ESCAPE: 53; KEY_LEFTARROW: 123; KEY_RETURN: 36; KEY_RIGHTARROW: 124; KEY_SPACE: 49; KEY_TAB: 48; KEY_UPARROW: 126; MODIFIER_COMMAND: 1048576; MODIFIER_CONTROL: 262144; MODIFIER_OPTION: 524288; MODIFIER_SHIFT: 131072 }

      The constant property is a container for pre-defined constants.

      Type declaration

      • Readonly KEY_DELETE: 51

        Key code for the Delete (⌫) key.

      • Readonly KEY_DOWNARROW: 125

        Key code for the Down Arrow key.

      • Readonly KEY_ESCAPE: 53

        Key code for the Escape key.

      • Readonly KEY_LEFTARROW: 123

        Key code for the Left Arrow key.

      • Readonly KEY_RETURN: 36

        Key code for the Return (↵) key.

      • Readonly KEY_RIGHTARROW: 124

        Key code for the Right Arrow key.

      • Readonly KEY_SPACE: 49

        Key code for the space bar.

      • Readonly KEY_TAB: 48

        Key code for the Tab (⇥) key.

      • Readonly KEY_UPARROW: 126

        Key code for the Up Arrow key.

      • Readonly MODIFIER_COMMAND: 1048576

        Bit mask for the Command (⌘) key.

      • Readonly MODIFIER_CONTROL: 262144

        Bit mask for the Control (⌃) key.

      • Readonly MODIFIER_OPTION: 524288

        Bit mask for the Option (⌥) key.

      • Readonly MODIFIER_SHIFT: 131072

        Bit mask for the Shift (⇧) key.

      Generated using TypeDoc