Members
mix
Syntactic sugar for Mixins
[http://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes/]
class BaseClass { ... }
let Mixin1 = (superclass) => class extends superclass { ... }
let Mixin2 = (superclass) => class extends superclass { ... }
class NewClass extends mix(BaseClass).with(Mixin1, Mixin2) { ... }
- Source:
Methods
addInfoFromUrl(info)
Add info extracted from the URL to the given dictionary
Parameters:
Name | Type | Description |
---|---|---|
info |
* |
- Source:
detectBrowser()
Note: since user agent is easily spoofed, we use a more sophisticated approach, as described here:
https://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser
- Source:
flattenArray()
Recursively flatten an array of arrays
- Source:
getDateStr()
Uses ``time.strftime()``_ to generate a string of the form
2012_Apr_19_1531 for 19th April 3.31pm, 2012.
This is often useful appended to data filenames to provide unique names.
To include the year: getDateStr(format="%Y_%b_%d_%H%M") returns '2011_Mar_16_1307'
depending on locale, can have unicode chars in month names, so utf_8_decode them
For date in the format of the current localization, do:
data.getDateStr(format=locale.nl_langinfo(locale.D_T_FMT))
- Source:
getErrorStack()
Returns the error stack of the calling, exception-throwing function
- Source:
Returns:
the error stack
getPositionFromObject()
Gets the position of the object in pixel unit
[basevisual.py l. 530]
- Source:
getUrlParameters()
Get the URL parameters
returns an iteratable URLSearchParams
example:
const urlParameters = util.getUrlParameters();
for (const [key, value] of urlParameters)
console.log(key + ' = ' + value);
- Source:
isEmpty(x)
Tests if x is an 'empty' value.
Parameters:
Name | Type | Description |
---|---|---|
x |
the value to test |
- Source:
Returns:
true if x one of the following: undefined, [], [undefined]
isInt()
Return whether the value is an integer or a string representing an integer
[https://stackoverflow.com/a/14794066]
- Source:
IsPointInsidePolygon()
Check whether a point lies within a polygon
We are using the algorithm described here: https://wrf.ecse.rpi.edu//Research/Short_Notes/pnpoly.html
- Source:
makeUuid()
Return a Universally Unique Identifier, following RFC4122 version 4
https://www.ietf.org/rfc/rfc4122.txt
- Source:
promiseToTupple(promise)
Parameters:
Name | Type | Description |
---|---|---|
promise |
promise | the promise |
- Source:
selectFromArray(array, selection) → {Array.<Object>}
Select values from an array.
'selection' can be a single integer, an array of indices, or a string to be parsed, e.g.: 5 [1,2,3,10] '1,5,10' '1:2:5' '5:' '-5:-2, 9, 11:5:22'
Parameters:
Name | Type | Description |
---|---|---|
array |
Array.<Object> | the input array |
selection |
number | Array.<number> | string | the selection |
- Source:
Returns:
the array of selected items
- Type
- Array.<Object>
shuffle()
Shuffle an array in place using the Fisher-Yastes's modern algorithm
https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#The_modern_algorithm
- Source:
sliceArray()
Slice an array
- Source:
to_pixiPoint(pos, posUnit, win)
Convert a position to a PIXI Point
Parameters:
Name | Type | Description |
---|---|---|
pos |
* | |
posUnit |
* | |
win |
* |
- Source:
to_px()
[tools/monitorunittools.py l. 73]
- Source:
toNumerical()
Convert obj to its numerical form
number -> number, e.g. 2 -> 2
[number] -> [number], e.g. [1,2,3] -> [1,2,3]
numeral string -> number, e.g. "8" -> 8
[number | numeral string] -> [number], e.g. [1, 2, "3"] -> [1,2,3]
otherwise raise an exception
- Source:
toString()
Convert an object to its string representation
- Source: