Utils

Utils

Class that fills in Endpoint.utils namespace provides utility methods used throughout the library, can be exported

Constructor

new Utils()

Source:

Methods

interpolate(baseString, params) → {String}

Like js template literal, replace '${here}' with {here: 'there'} // "there" Usage: interpolate("${greet}, ${noun}", {greet: 'hello', noun: 'world'}) // "Hello, World"

Parameters:
Name Type Description
baseString String

A string with ${x} placeholders

params Object

key/value for substitution

Source:

makeQueryString() → {String}

Convert an obj to string of params used in query strings supports multiple query strings as arrays, e.g.: {fields: [], key: 'value'} converts to ?key=value - No fields included as it is empty array {arr: ['one', two'], key: 'value'} converts to ?array=one&array=two&key=value

Source:

translateToTemplate()

Convert strings that have {name.subname} pattern to ${name_subname} so can be interpolated Used internally; required since Google APIs use former pattern instead of latter

Source: