Module: src/modules/Utils

Utils module
Source:

Classes

jsonpRequest
Logger

Methods

(static) composeApiString(api, params) → {String}

A function to compose query string
Parameters:
Name Type Description
api Strinq
params Object a key value object: will be append to ?key=value&key2=value2
Source:
Returns:
the string composed
Type
String
Example
var API = "http://jsonplaceholder.typicode.com/comments"
var url = composeApiString(API, {postId:1});
// url will be "http://jsonplaceholder.typicode.com/comments?postId=1"

(static) getImageRaw(options, _onProgressopt) → {Promise.<(Blob|ArrayBuffer|Error)>}

getImageRaw from a specific url
Parameters:
Name Type Attributes Default Description
options Object the options object
Properties
Name Type Attributes Default Description
url String http or whatever
responseType String <optional>
"blob" possible values arraybuffer|blob
mimeType String <optional>
"image/jpeg" possible values "image/png"|"image/jpeg" used only if "blob" is set as responseType
withCredentials Boolean set with credentials before send
_onProgress function <optional>
function(){}
Source:
Returns:
Type
Promise.<(Blob|ArrayBuffer|Error)>

(static) getJSON(url) → {Promise.<(Object|String)>}

getJSON
Parameters:
Name Type Description
url String for example http://jsonplaceholder.typicode.com/comments?postId=1
Source:
Returns:
the string error is the statuscode
Type
Promise.<(Object|String)>

(static) Iterator(array) → {Object}

Iterator
Parameters:
Name Type Description
array Array the array you want to transform in iterator
Source:
Returns:
- an iterator-like object
Type
Object
Example
var myArray = ["pippo", "pluto", "paperino"];
var it = Utils.Iterator(myArray);
it.next().value === "pippo"; //true
it.next().value === "pluto"; //true
it.next(true).value === "paperino" //false because with true you can reset it!