Home Reference Source

Function

Static Public Summary
public

When the browser encounters an error it creates an “Error Stack” which contains within it the location where the error ocurred right down to the file’s URL, line number, and character.

public

A helper function that returns just path See getScriptContext for info on how this works.

public

A helper function that returns the path and name of the calling script See getScriptContext for info on how this works.

public

A helper function that returns just the URL of the calling script See getScriptContext for info on how this works.

public

ld(date: Date, long: bool, options: options): string

A shorthand function for getting a localized date

public

ldo(date: Date, options: options): string

A shorthand function for getting a localized date or time string using your own options

public

ldt(date: Date, long: bool, options: options): string

A shorthand function for getting a localized date and time

public

lt(key: string, defaultValue: string): string

A shorthand function for getting a translation

public

styleInfoComparator(info1: *, info2: *): number

A sort comparator that sorts {StyleInfo}s from most to least important/specific/load-order

public

throttle(func: *, wait: *, leading: boolean, trailing: boolean): *

Static Public

public getScriptContext(err: Error): Object source

import {getScriptContext} from 'potassium-es/src/ScriptContext.js'

When the browser encounters an error it creates an “Error Stack” which contains within it the location where the error ocurred right down to the file’s URL, line number, and character. This means a script can know its source code’s URL and we can even pass arguments through the URL itself! Hold on to your hats because this is JSONP without the server!! We must call “new Error()” in the file we want to inspect the context of, and then pass that as an argument into here:

Params:

NameTypeAttributeDescription
err Error

a JS Error created in the script for which you want context

Return:

Object

Example:

import {getScriptContext} from './ScriptContext.js'
const context = getScriptContext(new Error)
context.url  // {string} URL of this script

public getScriptPath(err: Error): string source

import {getScriptPath} from 'potassium-es/src/ScriptContext.js'

A helper function that returns just path See getScriptContext for info on how this works.

Params:

NameTypeAttributeDescription
err Error

a JS Error created in the script for which you want context

Return:

string

path like /path/to/ of the script in which the err Error was created, but not the script name itself

Example:

import {getScriptPath} from './ScriptContext.js'
const path = getScriptPath(new Error) // '/path/to/' (does not include the script name)

public getScriptPathname(err: Error): string source

import {getScriptPathname} from 'potassium-es/src/ScriptContext.js'

A helper function that returns the path and name of the calling script See getScriptContext for info on how this works.

Params:

NameTypeAttributeDescription
err Error

a JS Error created in the script for which you want context

Return:

string

path/name like /path/to/script.js of the script in which the err Error was created

Example:

import {getScriptPathname} from './ScriptContext.js'
const path = getScriptPathname(new Error) // '/path/to/script.js'

public getScriptURL(err: Error): string source

import {getScriptURL} from 'potassium-es/src/ScriptContext.js'

A helper function that returns just the URL of the calling script See getScriptContext for info on how this works.

Params:

NameTypeAttributeDescription
err Error

a JS Error created in the script for which you want context

Return:

string

url of the script in which the err Error was created

Example:

import {getScriptURL} from './ScriptContext.js'
const url = getScriptURL(new Error) // `https://some-domain/path/to/script.js` 

public ld(date: Date, long: bool, options: options): string source

A shorthand function for getting a localized date

Params:

NameTypeAttributeDescription
date Date
long bool
  • optional
  • default: true
options options
  • optional
  • default: null

Return:

string

a localized string representing the date

public ldo(date: Date, options: options): string source

import {ldo} from 'potassium-es/src/Localizer.js'

A shorthand function for getting a localized date or time string using your own options

Params:

NameTypeAttributeDescription
date Date
options options
  • optional
  • default: null

Return:

string

a localized string representing the date

See:

public ldt(date: Date, long: bool, options: options): string source

import {ldt} from 'potassium-es/src/Localizer.js'

A shorthand function for getting a localized date and time

Params:

NameTypeAttributeDescription
date Date
long bool
  • optional
  • default: true
options options
  • optional
  • default: null

Return:

string

a localized string representing the date and time

public lt(key: string, defaultValue: string): string source

A shorthand function for getting a translation

Params:

NameTypeAttributeDescription
key string

the source phrase, like 'Hello!'

defaultValue string
  • optional
  • default: null

the value to return if there is no translation

Return:

string

a translation, like '¡Hola!'

public styleInfoComparator(info1: *, info2: *): number source

import {styleInfoComparator} from 'potassium-es/src/style/StyleInfo.js'

A sort comparator that sorts {StyleInfo}s from most to least important/specific/load-order

Params:

NameTypeAttributeDescription
info1 *
info2 *

Return:

number

public throttle(func: *, wait: *, leading: boolean, trailing: boolean): * source

import {throttle} from 'potassium-es/src/throttle.js'

Params:

NameTypeAttributeDescription
func *
wait *
leading boolean
  • optional
  • default: true
trailing boolean
  • optional
  • default: true

Return:

*