1
0
mirror of https://github.com/psychopy/psychojs.git synced 2025-05-10 18:50:54 +00:00
psychojs/docs/module-util.html
2022-09-12 13:20:16 +02:00

14793 lines
209 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>util - PsychoJS API</title>
<meta name="keywords" content="psychopy, psychojs, api" />
<meta name="keyword" content="psychopy, psychojs, api" />
<script src="scripts/prettify/prettify.js"></script>
<script src="scripts/prettify/lang-css.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
<script src="scripts/nav.js" defer></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav >
<input type="text" id="nav-search" placeholder="Search" />
<h2><a href="index.html">Home</a></h2><h2><a href="https://psychopy.org" target="_blank" class="menu-item" id="website_link" >Project Website</a></h2><h2><a href="https://discourse.psychopy.org/" target="_blank" class="menu-item" id="forum_link" >Forum</a></h2><h2><a href="https://github.com/psychopy/psychojs" target="_blank" class="menu-item" id="github_link" >Github</a></h2><h3>Modules</h3><ul><li><a href="module-core.html">core</a></li><li><a href="module-data.html">data</a></li><li><a href="module-sound.html">sound</a></li><li><a href="module-util.html">util</a><ul class='methods'><li data-type='method'><a href="module-util.html#~_match">_match</a></li></ul></li><li></li><li><a href="module-visual.html">visual</a></li></ul><h3>Classes</h3><ul><li><a href="AudioClip.html">AudioClip</a><ul class='methods'><li data-type='method'><a href="AudioClip.html#_base64ArrayBuffer">_base64ArrayBuffer</a></li><li data-type='method'><a href="AudioClip.html#_decodeAudio">_decodeAudio</a></li><li data-type='method'><a href="AudioClip.html#_GoogleTranscribe">_GoogleTranscribe</a></li><li data-type='method'><a href="AudioClip.html#download">download</a></li><li data-type='method'><a href="AudioClip.html#getDuration">getDuration</a></li><li data-type='method'><a href="AudioClip.html#setVolume">setVolume</a></li><li data-type='method'><a href="AudioClip.html#startPlayback">startPlayback</a></li><li data-type='method'><a href="AudioClip.html#stopPlayback">stopPlayback</a></li><li data-type='method'><a href="AudioClip.html#transcribe">transcribe</a></li><li data-type='method'><a href="AudioClip.html#upload">upload</a></li></ul></li><li><a href="AudioClipPlayer.html">AudioClipPlayer</a><ul class='methods'><li data-type='method'><a href="AudioClipPlayer.html#getDuration">getDuration</a></li><li data-type='method'><a href="AudioClipPlayer.html#play">play</a></li><li data-type='method'><a href="AudioClipPlayer.html#setDuration">setDuration</a></li><li data-type='method'><a href="AudioClipPlayer.html#setLoops">setLoops</a></li><li data-type='method'><a href="AudioClipPlayer.html#setVolume">setVolume</a></li><li data-type='method'><a href="AudioClipPlayer.html#stop">stop</a></li></ul></li><li><a href="BuilderKeyResponse.html">BuilderKeyResponse</a></li><li><a href="ButtonStim.html">ButtonStim</a><ul class='methods'><li data-type='method'><a href="ButtonStim.html#_addEventListeners">_addEventListeners</a></li><li data-type='method'><a href="ButtonStim.html#_estimateBoundingBox">_estimateBoundingBox</a></li><li data-type='method'><a href="ButtonStim.html#_getAnchor">_getAnchor</a></li><li data-type='method'><a href="ButtonStim.html#_getDefaultLetterHeight">_getDefaultLetterHeight</a></li><li data-type='method'><a href="ButtonStim.html#_getTextInputOptions">_getTextInputOptions</a></li><li data-type='method'><a href="ButtonStim.html#_updateIfNeeded">_updateIfNeeded</a></li><li data-type='method'><a href="ButtonStim.html#clear">clear</a></li><li data-type='method'><a href="ButtonStim.html#getText">getText</a></li><li data-type='method'><a href="ButtonStim.html#reset">reset</a></li><li data-type='method'><a href="ButtonStim.html#setAlignment">setAlignment</a></li><li data-type='method'><a href="ButtonStim.html#setAnchor">setAnchor</a></li><li data-type='method'><a href="ButtonStim.html#setBorderColor">setBorderColor</a></li><li data-type='method'><a href="ButtonStim.html#setColor">setColor</a></li><li data-type='method'><a href="ButtonStim.html#setFillColor">setFillColor</a></li><li data-type='method'><a href="ButtonStim.html#setFitToContent">setFitToContent</a></li><li data-type='method'><a href="ButtonStim.html#setFont">setFont</a></li><li data-type='method'><a href="ButtonStim.html#setLanguageStyle">setLanguageStyle</a></li><li data-type='method'><a href="ButtonStim.html#setLetterHeight">setLetterHeight</a></li><li data-type='method'><a href="ButtonStim.html#setSize">setSize</a></li><li data-type='method'><a href="ButtonStim.html#setText">setText</a></li></ul></li><li><a href="Clock.html">Clock</a><ul class='methods'><li data-type='method'><a href="Clock.html#add">add</a></li><li data-type='method'><a href="Clock.html#getLastResetTime">getLastResetTime</a></li><li data-type='method'><a href="Clock.html#getTime">getTime</a></li><li data-type='method'><a href="Clock.html#reset">reset</a></li></ul></li><li><a href="Color.html">Color</a><ul class='methods'><li data-type='method'><a href="Color.html#toString">toString</a></li></ul></li><li><a href="CountdownTimer.html">CountdownTimer</a><ul class='methods'><li data-type='method'><a href="CountdownTimer.html#add">add</a></li><li data-type='method'><a href="CountdownTimer.html#getLastResetTime">getLastResetTime</a></li><li data-type='method'><a href="CountdownTimer.html#getTime">getTime</a></li><li data-type='method'><a href="CountdownTimer.html#reset">reset</a></li></ul></li><li><a href="EventEmitter.html">EventEmitter</a><ul class='methods'><li data-type='method'><a href="EventEmitter.html#emit">emit</a></li><li data-type='method'><a href="EventEmitter.html#off">off</a></li><li data-type='method'><a href="EventEmitter.html#on">on</a></li><li data-type='method'><a href="EventEmitter.html#once">once</a></li></ul></li><li><a href="EventManager.html">EventManager</a><ul class='methods'><li data-type='method'><a href="EventManager.html#_addKeyListeners">_addKeyListeners</a></li><li data-type='method'><a href="EventManager.html#addMouseListeners">addMouseListeners</a></li><li data-type='method'><a href="EventManager.html#clearEvents">clearEvents</a></li><li data-type='method'><a href="EventManager.html#clearKeys">clearKeys</a></li><li data-type='method'><a href="EventManager.html#getKeys">getKeys</a></li><li data-type='method'><a href="EventManager.html#getMouseInfo">getMouseInfo</a></li><li data-type='method'><a href="EventManager.html#resetMoveClock">resetMoveClock</a></li><li data-type='method'><a href="EventManager.html#startMoveClock">startMoveClock</a></li><li data-type='method'><a href="EventManager.html#stopMoveClock">stopMoveClock</a></li></ul></li><li><a href="ExperimentHandler.html">ExperimentHandler</a><ul class='methods'><li data-type='method'><a href="ExperimentHandler.html#addData">addData</a></li><li data-type='method'><a href="ExperimentHandler.html#addLoop">addLoop</a></li><li data-type='method'><a href="ExperimentHandler.html#isEntryEmpty">isEntryEmpty</a></li><li data-type='method'><a href="ExperimentHandler.html#nextEntry">nextEntry</a></li><li data-type='method'><a href="ExperimentHandler.html#removeLoop">removeLoop</a></li><li data-type='method'><a href="ExperimentHandler.html#save">save</a></li></ul></li><li><a href="FaceDetector.html">FaceDetector</a><ul class='methods'><li data-type='method'><a href="FaceDetector.html#_estimateBoundingBox">_estimateBoundingBox</a></li><li data-type='method'><a href="FaceDetector.html#_initFaceApi">_initFaceApi</a></li><li data-type='method'><a href="FaceDetector.html#_updateIfNeeded">_updateIfNeeded</a></li><li data-type='method'><a href="FaceDetector.html#isReady">isReady</a></li><li data-type='method'><a href="FaceDetector.html#setInput">setInput</a></li><li data-type='method'><a href="FaceDetector.html#start">start</a></li><li data-type='method'><a href="FaceDetector.html#stop">stop</a></li></ul></li><li><a href="Form.html">Form</a><ul class='methods'><li data-type='method'><a href="Form.html#_estimateBoundingBox">_estimateBoundingBox</a></li><li data-type='method'><a href="Form.html#_getBoundingBox_px">_getBoundingBox_px</a></li><li data-type='method'><a href="Form.html#_importItems">_importItems</a></li><li data-type='method'><a href="Form.html#_onChange">_onChange</a></li><li data-type='method'><a href="Form.html#_processItems">_processItems</a></li><li data-type='method'><a href="Form.html#_sanitizeItems">_sanitizeItems</a></li><li data-type='method'><a href="Form.html#_setupStimuli">_setupStimuli</a></li><li data-type='method'><a href="Form.html#_updateDecorations">_updateDecorations</a></li><li data-type='method'><a href="Form.html#_updateIfNeeded">_updateIfNeeded</a></li><li data-type='method'><a href="Form.html#_updateVisibleStimuli">_updateVisibleStimuli</a></li><li data-type='method'><a href="Form.html#addDataToExp">addDataToExp</a></li><li data-type='method'><a href="Form.html#contains">contains</a></li><li data-type='method'><a href="Form.html#draw">draw</a></li><li data-type='method'><a href="Form.html#formComplete">formComplete</a></li><li data-type='method'><a href="Form.html#getData">getData</a></li><li data-type='method'><a href="Form.html#hide">hide</a></li><li data-type='method'><a href="Form.html#refresh">refresh</a></li><li data-type='method'><a href="Form.html#release">release</a></li><li data-type='method'><a href="Form.html#reset">reset</a></li><li data-type='method'><a href="Form.html#setAutoDraw">setAutoDraw</a></li><li data-type='method'><a href="Form.html#setDepth">setDepth</a></li><li data-type='method'><a href="Form.html#setOri">setOri</a></li><li data-type='method'><a href="Form.html#setPos">setPos</a></li><li data-type='method'><a href="Form.html#setSize">setSize</a></li></ul></li><li><a href="GratingStim.html">GratingStim</a><ul class='methods'><li data-type='method'><a href="GratingStim.html#_estimateBoundingBox">_estimateBoundingBox</a></li><li data-type='method'><a href="GratingStim.html#_getDisplaySize">_getDisplaySize</a></li><li data-type='method'><a href="GratingStim.html#_getPixiMeshFromPredefinedShaders">_getPixiMeshFromPredefinedShaders</a></li><li data-type='method'><a href="GratingStim.html#_updateIfNeeded">_updateIfNeeded</a></li><li data-type='method'><a href="GratingStim.html#setBlendmode">setBlendmode</a></li><li data-type='method'><a href="GratingStim.html#setColor">setColor</a></li><li data-type='method'><a href="GratingStim.html#setColorSpace">setColorSpace</a></li><li data-type='method'><a href="GratingStim.html#setInterpolate">setInterpolate</a></li><li data-type='method'><a href="GratingStim.html#setMask">setMask</a></li><li data-type='method'><a href="GratingStim.html#setOpacity">setOpacity</a></li><li data-type='method'><a href="GratingStim.html#setPhase">setPhase</a></li><li data-type='method'><a href="GratingStim.html#setSF">setSF</a></li><li data-type='method'><a href="GratingStim.html#setTex">setTex</a></li></ul></li><li><a href="GUI.html">GUI</a><ul class='methods'><li data-type='method'><a href="GUI.html#_onCancelExperiment">_onCancelExperiment</a></li><li data-type='method'><a href="GUI.html#_onResourceEvents">_onResourceEvents</a></li><li data-type='method'><a href="GUI.html#_onStartExperiment">_onStartExperiment</a></li><li data-type='method'><a href="GUI.html#_setProgressMessage">_setProgressMessage</a></li><li data-type='method'><a href="GUI.html#_updateDialog">_updateDialog</a></li><li data-type='method'><a href="GUI.html#_updateProgressBar">_updateProgressBar</a></li><li data-type='method'><a href="GUI.html#_userFriendlyError">_userFriendlyError</a></li><li data-type='method'><a href="GUI.html#closeDialog">closeDialog</a></li><li data-type='method'><a href="GUI.html#dialog">dialog</a></li><li data-type='method'><a href="GUI.html#DlgFromDict">DlgFromDict</a></li><li data-type='method'><a href="GUI.html#finishDialog">finishDialog</a></li></ul></li><li><a href="ImageStim.html">ImageStim</a><ul class='methods'><li data-type='method'><a href="ImageStim.html#_estimateBoundingBox">_estimateBoundingBox</a></li><li data-type='method'><a href="ImageStim.html#_getDisplaySize">_getDisplaySize</a></li><li data-type='method'><a href="ImageStim.html#_updateIfNeeded">_updateIfNeeded</a></li><li data-type='method'><a href="ImageStim.html#setImage">setImage</a></li><li data-type='method'><a href="ImageStim.html#setInterpolate">setInterpolate</a></li><li data-type='method'><a href="ImageStim.html#setMask">setMask</a></li></ul></li><li><a href="Keyboard.html">Keyboard</a><ul class='methods'><li data-type='method'><a href="Keyboard.html#_addKeyListeners">_addKeyListeners</a></li><li data-type='method'><a href="Keyboard.html#clearEvents">clearEvents</a></li><li data-type='method'><a href="Keyboard.html#getEvents">getEvents</a></li><li data-type='method'><a href="Keyboard.html#getKeys">getKeys</a></li><li data-type='method'><a href="Keyboard.html#start">start</a></li><li data-type='method'><a href="Keyboard.html#stop">stop</a></li></ul></li><li><a href="KeyPress.html">KeyPress</a></li><li><a href="Logger.html">Logger</a><ul class='methods'><li data-type='method'><a href="Logger.html#_customConsoleLayout">_customConsoleLayout</a></li><li data-type='method'><a href="Logger.html#_getValue">_getValue</a></li><li data-type='method'><a href="Logger.html#_throttle">_throttle</a></li><li data-type='method'><a href="Logger.html#data">data</a></li><li data-type='method'><a href="Logger.html#exp">exp</a></li><li data-type='method'><a href="Logger.html#flush">flush</a></li><li data-type='method'><a href="Logger.html#log">log</a></li><li data-type='method'><a href="Logger.html#setLevel">setLevel</a></li></ul></li><li><a href="Microphone.html">Microphone</a><ul class='methods'><li data-type='method'><a href="Microphone.html#_onChange">_onChange</a></li><li data-type='method'><a href="Microphone.html#_prepareRecording">_prepareRecording</a></li><li data-type='method'><a href="Microphone.html#download">download</a></li><li data-type='method'><a href="Microphone.html#flush">flush</a></li><li data-type='method'><a href="Microphone.html#getRecording">getRecording</a></li><li data-type='method'><a href="Microphone.html#pause">pause</a></li><li data-type='method'><a href="Microphone.html#resume">resume</a></li><li data-type='method'><a href="Microphone.html#start">start</a></li><li data-type='method'><a href="Microphone.html#stop">stop</a></li><li data-type='method'><a href="Microphone.html#upload">upload</a></li></ul></li><li><a href="MinimalStim.html">MinimalStim</a><ul class='methods'><li data-type='method'><a href="MinimalStim.html#_updateIfNeeded">_updateIfNeeded</a></li><li data-type='method'><a href="MinimalStim.html#contains">contains</a></li><li data-type='method'><a href="MinimalStim.html#draw">draw</a></li><li data-type='method'><a href="MinimalStim.html#hide">hide</a></li><li data-type='method'><a href="MinimalStim.html#release">release</a></li><li data-type='method'><a href="MinimalStim.html#setAutoDraw">setAutoDraw</a></li></ul></li><li><a href="module-core.PsychoJS.html">PsychoJS</a><ul class='methods'><li data-type='method'><a href="module-core.PsychoJS.html#_captureErrors">_captureErrors</a></li><li data-type='method'><a href="module-core.PsychoJS.html#_configure">_configure</a></li><li data-type='method'><a href="module-core.PsychoJS.html#_getParticipantIPInfo">_getParticipantIPInfo</a></li><li data-type='method'><a href="module-core.PsychoJS.html#_makeStatusTopLevel">_makeStatusTopLevel</a></li><li data-type='method'><a href="module-core.PsychoJS.html#getEnvironment">getEnvironment</a></li><li data-type='method'><a href="module-core.PsychoJS.html#importAttributes">importAttributes</a></li><li data-type='method'><a href="module-core.PsychoJS.html#openWindow">openWindow</a></li><li data-type='method'><a href="module-core.PsychoJS.html#quit">quit</a></li><li data-type='method'><a href="module-core.PsychoJS.html#schedule">schedule</a></li><li data-type='method'><a href="module-core.PsychoJS.html#scheduleCondition">scheduleCondition</a></li><li data-type='method'><a href="module-core.PsychoJS.html#setRedirectUrls">setRedirectUrls</a></li><li data-type='method'><a href="module-core.PsychoJS.html#start">start</a></li><li data-type='method'><a href="module-core.PsychoJS.html#waitForResources">waitForResources</a></li></ul></li><li><a href="module-data.TrialHandler.html">TrialHandler</a><ul class='methods'><li data-type='method'><a href="module-data.TrialHandler.html#_prepareSequence">_prepareSequence</a></li><li data-type='method'><a href="module-data.TrialHandler.html#_prepareTrialList">_prepareTrialList</a></li><li data-type='method'><a href="module-data.TrialHandler.html#addData">addData</a></li><li data-type='method'><a href="module-data.TrialHandler.html#forEach">forEach</a></li><li data-type='method'><a href="module-data.TrialHandler.html#getAttributes">getAttributes</a></li><li data-type='method'><a href="module-data.TrialHandler.html#getCurrentTrial">getCurrentTrial</a></li><li data-type='method'><a href="module-data.TrialHandler.html#getEarlierTrial">getEarlierTrial</a></li><li data-type='method'><a href="module-data.TrialHandler.html#getFutureTrial">getFutureTrial</a></li><li data-type='method'><a href="module-data.TrialHandler.html#getSnapshot">getSnapshot</a></li><li data-type='method'><a href="module-data.TrialHandler.html#getTrial">getTrial</a></li><li data-type='method'><a href="module-data.TrialHandler.html#getTrialIndex">getTrialIndex</a></li><li data-type='method'><a href="module-data.TrialHandler.html#next">next</a></li><li data-type='method'><a href="module-data.TrialHandler.html#setSeed">setSeed</a></li><li data-type='method'><a href="module-data.TrialHandler.html#setTrialIndex">setTrialIndex</a></li><li data-type='method'><a href="module-data.TrialHandler.html#Symbol.iterator">Symbol.iterator</a></li></ul></li><li><a href="module-hardware.Camera.html">Camera</a><ul class='methods'><li data-type='method'><a href="module-hardware.Camera.html#_onChange">_onChange</a></li><li data-type='method'><a href="module-hardware.Camera.html#_prepareRecording">_prepareRecording</a></li><li data-type='method'><a href="module-hardware.Camera.html#_upload">_upload</a></li><li data-type='method'><a href="module-hardware.Camera.html#authorize">authorize</a></li><li data-type='method'><a href="module-hardware.Camera.html#close">close</a></li><li data-type='method'><a href="module-hardware.Camera.html#flush">flush</a></li><li data-type='method'><a href="module-hardware.Camera.html#getRecording">getRecording</a></li><li data-type='method'><a href="module-hardware.Camera.html#getStream">getStream</a></li><li data-type='method'><a href="module-hardware.Camera.html#getVideo">getVideo</a></li><li data-type='method'><a href="module-hardware.Camera.html#isReady">isReady</a></li><li data-type='method'><a href="module-hardware.Camera.html#open">open</a></li><li data-type='method'><a href="module-hardware.Camera.html#pause">pause</a></li><li data-type='method'><a href="module-hardware.Camera.html#record">record</a></li><li data-type='method'><a href="module-hardware.Camera.html#resume">resume</a></li><li data-type='method'><a href="module-hardware.Camera.html#stop">stop</a></li></ul></li><li><a href="module-sound.Sound.html">Sound</a><ul class='methods'><li data-type='method'><a href="module-sound.Sound.html#_getPlayer">_getPlayer</a></li><li data-type='method'><a href="module-sound.Sound.html#getDuration">getDuration</a></li><li data-type='method'><a href="module-sound.Sound.html#play">play</a></li><li data-type='method'><a href="module-sound.Sound.html#setLoops">setLoops</a></li><li data-type='method'><a href="module-sound.Sound.html#setSecs">setSecs</a></li><li data-type='method'><a href="module-sound.Sound.html#setSound">setSound</a></li><li data-type='method'><a href="module-sound.Sound.html#setVolume">setVolume</a></li><li data-type='method'><a href="module-sound.Sound.html#stop">stop</a></li></ul></li><li><a href="module-util.PsychObject.html">PsychObject</a><ul class='methods'><li data-type='method'><a href="module-util.PsychObject.html#_addAttribute">_addAttribute</a></li><li data-type='method'><a href="module-util.PsychObject.html#_setAttribute">_setAttribute</a></li><li data-type='method'><a href="module-util.PsychObject.html#emit">emit</a></li><li data-type='method'><a href="module-util.PsychObject.html#off">off</a></li><li data-type='method'><a href="module-util.PsychObject.html#on">on</a></li><li data-type='method'><a href="module-util.PsychObject.html#once">once</a></li><li data-type='method'><a href="module-util.PsychObject.html#toString">toString</a></li></ul></li><li><a href="module-visual.VisualStim.html">VisualStim</a><ul class='methods'><li data-type='method'><a href="module-visual.VisualStim.html#_estimateBoundingBox">_estimateBoundingBox</a></li><li data-type='method'><a href="module-visual.VisualStim.html#_getBoundingBox_px">_getBoundingBox_px</a></li><li data-type='method'><a href="module-visual.VisualStim.html#_onChange">_onChange</a></li><li data-type='method'><a href="module-visual.VisualStim.html#_updateIfNeeded">_updateIfNeeded</a></li><li data-type='method'><a href="module-visual.VisualStim.html#contains">contains</a></li><li data-type='method'><a href="module-visual.VisualStim.html#draw">draw</a></li><li data-type='method'><a href="module-visual.VisualStim.html#hide">hide</a></li><li data-type='method'><a href="module-visual.VisualStim.html#refresh">refresh</a></li><li data-type='method'><a href="module-visual.VisualStim.html#release">release</a></li><li data-type='method'><a href="module-visual.VisualStim.html#setAutoDraw">setAutoDraw</a></li><li data-type='method'><a href="module-visual.VisualStim.html#setDepth">setDepth</a></li><li data-type='method'><a href="module-visual.VisualStim.html#setOri">setOri</a></li><li data-type='method'><a href="module-visual.VisualStim.html#setPos">setPos</a></li><li data-type='method'><a href="module-visual.VisualStim.html#setSize">setSize</a></li></ul></li><li><a href="MonotonicClock.html">MonotonicClock</a><ul class='methods'><li data-type='method'><a href="MonotonicClock.html#getLastResetTime">getLastResetTime</a></li><li data-type='method'><a href="MonotonicClock.html#getTime">getTime</a></li></ul></li><li><a href="Mouse.html">Mouse</a><ul class='methods'><li data-type='method'><a href="Mouse.html#clickReset">clickReset</a></li><li data-type='method'><a href="Mouse.html#getPos">getPos</a></li><li data-type='method'><a href="Mouse.html#getPressed">getPressed</a></li><li data-type='method'><a href="Mouse.html#getRel">getRel</a></li><li data-type='method'><a href="Mouse.html#getWheelRel">getWheelRel</a></li><li data-type='method'><a href="Mouse.html#isPressedIn">isPressedIn</a></li><li data-type='method'><a href="Mouse.html#mouseMoved">mouseMoved</a></li><li data-type='method'><a href="Mouse.html#mouseMoveTime">mouseMoveTime</a></li></ul></li><li><a href="MovieStim.html">MovieStim</a><ul class='methods'><li data-type='method'><a href="MovieStim.html#_estimateBoundingBox">_estimateBoundingBox</a></li><li data-type='method'><a href="MovieStim.html#_getDisplaySize">_getDisplaySize</a></li><li data-type='method'><a href="MovieStim.html#_updateIfNeeded">_updateIfNeeded</a></li><li data-type='method'><a href="MovieStim.html#pause">pause</a></li><li data-type='method'><a href="MovieStim.html#play">play</a></li><li data-type='method'><a href="MovieStim.html#reset">reset</a></li><li data-type='method'><a href="MovieStim.html#seek">seek</a></li><li data-type='method'><a href="MovieStim.html#setMovie">setMovie</a></li><li data-type='method'><a href="MovieStim.html#stop">stop</a></li></ul></li><li><a href="MultiStairHandler.html">MultiStairHandler</a><ul class='methods'><li data-type='method'><a href="MultiStairHandler.html#_nextTrial">_nextTrial</a></li><li data-type='method'><a href="MultiStairHandler.html#_prepareStaircases">_prepareStaircases</a></li><li data-type='method'><a href="MultiStairHandler.html#_validateConditions">_validateConditions</a></li><li data-type='method'><a href="MultiStairHandler.html#addResponse">addResponse</a></li></ul></li><li><a href="Polygon.html">Polygon</a><ul class='methods'><li data-type='method'><a href="Polygon.html#_estimateBoundingBox">_estimateBoundingBox</a></li><li data-type='method'><a href="Polygon.html#_getPixiPolygon">_getPixiPolygon</a></li><li data-type='method'><a href="Polygon.html#_getVertices_px">_getVertices_px</a></li><li data-type='method'><a href="Polygon.html#_updateIfNeeded">_updateIfNeeded</a></li><li data-type='method'><a href="Polygon.html#contains">contains</a></li><li data-type='method'><a href="Polygon.html#setEdges">setEdges</a></li><li data-type='method'><a href="Polygon.html#setRadius">setRadius</a></li><li data-type='method'><a href="Polygon.html#setVertices">setVertices</a></li></ul></li><li><a href="QuestHandler.html">QuestHandler</a><ul class='methods'><li data-type='method'><a href="QuestHandler.html#_estimateQuestValue">_estimateQuestValue</a></li><li data-type='method'><a href="QuestHandler.html#_setupJsQuest">_setupJsQuest</a></li><li data-type='method'><a href="QuestHandler.html#addResponse">addResponse</a></li><li data-type='method'><a href="QuestHandler.html#confInterval">confInterval</a></li><li data-type='method'><a href="QuestHandler.html#getQuestValue">getQuestValue</a></li><li data-type='method'><a href="QuestHandler.html#mean">mean</a></li><li data-type='method'><a href="QuestHandler.html#mode">mode</a></li><li data-type='method'><a href="QuestHandler.html#quantile">quantile</a></li><li data-type='method'><a href="QuestHandler.html#sd">sd</a></li><li data-type='method'><a href="QuestHandler.html#setMethod">setMethod</a></li><li data-type='method'><a href="QuestHandler.html#simulate">simulate</a></li></ul></li><li><a href="Rect.html">Rect</a><ul class='methods'><li data-type='method'><a href="Rect.html#_estimateBoundingBox">_estimateBoundingBox</a></li><li data-type='method'><a href="Rect.html#_getPixiPolygon">_getPixiPolygon</a></li><li data-type='method'><a href="Rect.html#_getVertices_px">_getVertices_px</a></li><li data-type='method'><a href="Rect.html#_updateIfNeeded">_updateIfNeeded</a></li><li data-type='method'><a href="Rect.html#_updateVertices">_updateVertices</a></li><li data-type='method'><a href="Rect.html#contains">contains</a></li><li data-type='method'><a href="Rect.html#setHeight">setHeight</a></li><li data-type='method'><a href="Rect.html#setVertices">setVertices</a></li><li data-type='method'><a href="Rect.html#setWidth">setWidth</a></li></ul></li><li><a href="Scheduler.html">Scheduler</a><ul class='methods'><li data-type='method'><a href="Scheduler.html#add">add</a></li><li data-type='method'><a href="Scheduler.html#addConditional">addConditional</a></li><li data-type='method'><a href="Scheduler.html#start">start</a></li><li data-type='method'><a href="Scheduler.html#stop">stop</a></li></ul></li><li><a href="ServerManager.html">ServerManager</a><ul class='methods'><li data-type='method'><a href="ServerManager.html#_downloadResources">_downloadResources</a></li><li data-type='method'><a href="ServerManager.html#_listResources">_listResources</a></li><li data-type='method'><a href="ServerManager.html#_queryServerAPI">_queryServerAPI</a></li><li data-type='method'><a href="ServerManager.html#_setupPreloadQueue">_setupPreloadQueue</a></li><li data-type='method'><a href="ServerManager.html#closeSession">closeSession</a></li><li data-type='method'><a href="ServerManager.html#getConfiguration">getConfiguration</a></li><li data-type='method'><a href="ServerManager.html#getResource">getResource</a></li><li data-type='method'><a href="ServerManager.html#getResourceStatus">getResourceStatus</a></li><li data-type='method'><a href="ServerManager.html#openSession">openSession</a></li><li data-type='method'><a href="ServerManager.html#prepareResources">prepareResources</a></li><li data-type='method'><a href="ServerManager.html#resetStatus">resetStatus</a></li><li data-type='method'><a href="ServerManager.html#setStatus">setStatus</a></li><li data-type='method'><a href="ServerManager.html#uploadAudioVideo">uploadAudioVideo</a></li><li data-type='method'><a href="ServerManager.html#uploadData">uploadData</a></li><li data-type='method'><a href="ServerManager.html#uploadLog">uploadLog</a></li><li data-type='method'><a href="ServerManager.html#waitForResources">waitForResources</a></li></ul></li><li><a href="ShapeStim.html">ShapeStim</a><ul class='methods'><li data-type='method'><a href="ShapeStim.html#_estimateBoundingBox">_estimateBoundingBox</a></li><li data-type='method'><a href="ShapeStim.html#_getPixiPolygon">_getPixiPolygon</a></li><li data-type='method'><a href="ShapeStim.html#_getVertices_px">_getVertices_px</a></li><li data-type='method'><a href="ShapeStim.html#_updateIfNeeded">_updateIfNeeded</a></li><li data-type='method'><a href="ShapeStim.html#contains">contains</a></li><li data-type='method'><a href="ShapeStim.html#setVertices">setVertices</a></li></ul></li><li><a href="Shelf.html">Shelf</a><ul class='methods'><li data-type='method'><a href="Shelf.html#_checkAvailability">_checkAvailability</a></li><li data-type='method'><a href="Shelf.html#_checkKey">_checkKey</a></li><li data-type='method'><a href="Shelf.html#_getValue">_getValue</a></li><li data-type='method'><a href="Shelf.html#_updateValue">_updateValue</a></li><li data-type='method'><a href="Shelf.html#addIntegerValue">addIntegerValue</a></li><li data-type='method'><a href="Shelf.html#appendListValue">appendListValue</a></li><li data-type='method'><a href="Shelf.html#clearListValue">clearListValue</a></li><li data-type='method'><a href="Shelf.html#counterBalanceSelect">counterBalanceSelect</a></li><li data-type='method'><a href="Shelf.html#flipBooleanValue">flipBooleanValue</a></li><li data-type='method'><a href="Shelf.html#getBooleanValue">getBooleanValue</a></li><li data-type='method'><a href="Shelf.html#getDictionaryFieldNames">getDictionaryFieldNames</a></li><li data-type='method'><a href="Shelf.html#getDictionaryFieldValue">getDictionaryFieldValue</a></li><li data-type='method'><a href="Shelf.html#getDictionaryValue">getDictionaryValue</a></li><li data-type='method'><a href="Shelf.html#getIntegerValue">getIntegerValue</a></li><li data-type='method'><a href="Shelf.html#getListValue">getListValue</a></li><li data-type='method'><a href="Shelf.html#getTextValue">getTextValue</a></li><li data-type='method'><a href="Shelf.html#incrementComponent">incrementComponent</a></li><li data-type='method'><a href="Shelf.html#popListValue">popListValue</a></li><li data-type='method'><a href="Shelf.html#setBooleanValue">setBooleanValue</a></li><li data-type='method'><a href="Shelf.html#setDictionaryFieldValue">setDictionaryFieldValue</a></li><li data-type='method'><a href="Shelf.html#setDictionaryValue">setDictionaryValue</a></li><li data-type='method'><a href="Shelf.html#setIntegerValue">setIntegerValue</a></li><li data-type='method'><a href="Shelf.html#setListValue">setListValue</a></li><li data-type='method'><a href="Shelf.html#setTextValue">setTextValue</a></li><li data-type='method'><a href="Shelf.html#shuffleListValue">shuffleListValue</a></li></ul></li><li><a href="Slider.html">Slider</a><ul class='methods'><li data-type='method'><a href="Slider.html#_addEventListeners">_addEventListeners</a></li><li data-type='method'><a href="Slider.html#_estimateBoundingBox">_estimateBoundingBox</a></li><li data-type='method'><a href="Slider.html#_getBoundingBox_px">_getBoundingBox_px</a></li><li data-type='method'><a href="Slider.html#_getPosition_px">_getPosition_px</a></li><li data-type='method'><a href="Slider.html#_getTextStyle">_getTextStyle</a></li><li data-type='method'><a href="Slider.html#_granularise">_granularise</a></li><li data-type='method'><a href="Slider.html#_handlePointerDown">_handlePointerDown</a></li><li data-type='method'><a href="Slider.html#_handlePointerMove">_handlePointerMove</a></li><li data-type='method'><a href="Slider.html#_handlePointerUp">_handlePointerUp</a></li><li data-type='method'><a href="Slider.html#_isHorizontal">_isHorizontal</a></li><li data-type='method'><a href="Slider.html#_onChange">_onChange</a></li><li data-type='method'><a href="Slider.html#_posToRating">_posToRating</a></li><li data-type='method'><a href="Slider.html#_ratingToPos">_ratingToPos</a></li><li data-type='method'><a href="Slider.html#_removeEventListeners">_removeEventListeners</a></li><li data-type='method'><a href="Slider.html#_sanitizeAttributes">_sanitizeAttributes</a></li><li data-type='method'><a href="Slider.html#_setupBar">_setupBar</a></li><li data-type='method'><a href="Slider.html#_setupLabels">_setupLabels</a></li><li data-type='method'><a href="Slider.html#_setupMarker">_setupMarker</a></li><li data-type='method'><a href="Slider.html#_setupSlider">_setupSlider</a></li><li data-type='method'><a href="Slider.html#_setupStyle">_setupStyle</a></li><li data-type='method'><a href="Slider.html#_setupTicks">_setupTicks</a></li><li data-type='method'><a href="Slider.html#_updateIfNeeded">_updateIfNeeded</a></li><li data-type='method'><a href="Slider.html#contains">contains</a></li><li data-type='method'><a href="Slider.html#draw">draw</a></li><li data-type='method'><a href="Slider.html#getRating">getRating</a></li><li data-type='method'><a href="Slider.html#getRT">getRT</a></li><li data-type='method'><a href="Slider.html#hide">hide</a></li><li data-type='method'><a href="Slider.html#isMarkerDragging">isMarkerDragging</a></li><li data-type='method'><a href="Slider.html#recordRating">recordRating</a></li><li data-type='method'><a href="Slider.html#refresh">refresh</a></li><li data-type='method'><a href="Slider.html#release">release</a></li><li data-type='method'><a href="Slider.html#reset">reset</a></li><li data-type='method'><a href="Slider.html#setAutoDraw">setAutoDraw</a></li><li data-type='method'><a href="Slider.html#setDepth">setDepth</a></li><li data-type='method'><a href="Slider.html#setMarkerPos">setMarkerPos</a></li><li data-type='method'><a href="Slider.html#setOri">setOri</a></li><li data-type='method'><a href="Slider.html#setPos">setPos</a></li><li data-type='method'><a href="Slider.html#setRating">setRating</a></li><li data-type='method'><a href="Slider.html#setReadOnly">setReadOnly</a></li><li data-type='method'><a href="Slider.html#setSize">setSize</a></li></ul></li><li><a href="SpeechRecognition.html">SpeechRecognition</a><ul class='methods'><li data-type='method'><a href="SpeechRecognition.html#_onChange">_onChange</a></li><li data-type='method'><a href="SpeechRecognition.html#_prepareRecognition">_prepareRecognition</a></li><li data-type='method'><a href="SpeechRecognition.html#clearTranscripts">clearTranscripts</a></li><li data-type='method'><a href="SpeechRecognition.html#getTranscripts">getTranscripts</a></li><li data-type='method'><a href="SpeechRecognition.html#start">start</a></li><li data-type='method'><a href="SpeechRecognition.html#stop">stop</a></li></ul></li><li><a href="TextBox.html">TextBox</a><ul class='methods'><li data-type='method'><a href="TextBox.html#_addEventListeners">_addEventListeners</a></li><li data-type='method'><a href="TextBox.html#_estimateBoundingBox">_estimateBoundingBox</a></li><li data-type='method'><a href="TextBox.html#_getAnchor">_getAnchor</a></li><li data-type='method'><a href="TextBox.html#_getDefaultLetterHeight">_getDefaultLetterHeight</a></li><li data-type='method'><a href="TextBox.html#_getTextInputOptions">_getTextInputOptions</a></li><li data-type='method'><a href="TextBox.html#_updateIfNeeded">_updateIfNeeded</a></li><li data-type='method'><a href="TextBox.html#clear">clear</a></li><li data-type='method'><a href="TextBox.html#getText">getText</a></li><li data-type='method'><a href="TextBox.html#reset">reset</a></li><li data-type='method'><a href="TextBox.html#setAlignment">setAlignment</a></li><li data-type='method'><a href="TextBox.html#setAnchor">setAnchor</a></li><li data-type='method'><a href="TextBox.html#setBorderColor">setBorderColor</a></li><li data-type='method'><a href="TextBox.html#setColor">setColor</a></li><li data-type='method'><a href="TextBox.html#setFillColor">setFillColor</a></li><li data-type='method'><a href="TextBox.html#setFitToContent">setFitToContent</a></li><li data-type='method'><a href="TextBox.html#setFont">setFont</a></li><li data-type='method'><a href="TextBox.html#setLanguageStyle">setLanguageStyle</a></li><li data-type='method'><a href="TextBox.html#setLetterHeight">setLetterHeight</a></li><li data-type='method'><a href="TextBox.html#setSize">setSize</a></li><li data-type='method'><a href="TextBox.html#setText">setText</a></li></ul></li><li><a href="TextStim.html">TextStim</a><ul class='methods'><li data-type='method'><a href="TextStim.html#_estimateBoundingBox">_estimateBoundingBox</a></li><li data-type='method'><a href="TextStim.html#_getAnchor">_getAnchor</a></li><li data-type='method'><a href="TextStim.html#_getDefaultLetterHeight">_getDefaultLetterHeight</a></li><li data-type='method'><a href="TextStim.html#_getDefaultWrapWidth">_getDefaultWrapWidth</a></li><li data-type='method'><a href="TextStim.html#_getTextStyle">_getTextStyle</a></li><li data-type='method'><a href="TextStim.html#_updateIfNeeded">_updateIfNeeded</a></li><li data-type='method'><a href="TextStim.html#getBoundingBox">getBoundingBox</a></li><li data-type='method'><a href="TextStim.html#getTextMetrics">getTextMetrics</a></li><li data-type='method'><a href="TextStim.html#setColor">setColor</a></li></ul></li><li><a href="TonePlayer.html">TonePlayer</a><ul class='methods'><li data-type='method'><a href="TonePlayer.html#_initSoundLibrary">_initSoundLibrary</a></li><li data-type='method'><a href="TonePlayer.html#getDuration">getDuration</a></li><li data-type='method'><a href="TonePlayer.html#play">play</a></li><li data-type='method'><a href="TonePlayer.html#setDuration">setDuration</a></li><li data-type='method'><a href="TonePlayer.html#setLoops">setLoops</a></li><li data-type='method'><a href="TonePlayer.html#setVolume">setVolume</a></li><li data-type='method'><a href="TonePlayer.html#stop">stop</a></li></ul></li><li><a href="TrackPlayer.html">TrackPlayer</a><ul class='methods'><li data-type='method'><a href="TrackPlayer.html#getDuration">getDuration</a></li><li data-type='method'><a href="TrackPlayer.html#play">play</a></li><li data-type='method'><a href="TrackPlayer.html#setDuration">setDuration</a></li><li data-type='method'><a href="TrackPlayer.html#setLoops">setLoops</a></li><li data-type='method'><a href="TrackPlayer.html#setVolume">setVolume</a></li><li data-type='method'><a href="TrackPlayer.html#stop">stop</a></li></ul></li><li><a href="Transcript.html">Transcript</a></li><li><a href="Window.html">Window</a><ul class='methods'><li data-type='method'><a href="Window.html#_fullRefresh">_fullRefresh</a></li><li data-type='method'><a href="Window.html#_refresh">_refresh</a></li><li data-type='method'><a href="Window.html#_setupPixi">_setupPixi</a></li><li data-type='method'><a href="Window.html#_updateIfNeeded">_updateIfNeeded</a></li><li data-type='method'><a href="Window.html#_writeLogOnFlip">_writeLogOnFlip</a></li><li data-type='method'><a href="Window.html#addPixiObject">addPixiObject</a></li><li data-type='method'><a href="Window.html#adjustScreenSize">adjustScreenSize</a></li><li data-type='method'><a href="Window.html#callOnFlip">callOnFlip</a></li><li data-type='method'><a href="Window.html#close">close</a></li><li data-type='method'><a href="Window.html#closeFullScreen">closeFullScreen</a></li><li data-type='method'><a href="Window.html#getActualFrameRate">getActualFrameRate</a></li><li data-type='method'><a href="Window.html#logOnFlip">logOnFlip</a></li><li data-type='method'><a href="Window.html#removePixiObject">removePixiObject</a></li><li data-type='method'><a href="Window.html#render">render</a></li></ul></li></ul><h3>Interfaces</h3><ul><li><a href="SoundPlayer.html">SoundPlayer</a><ul class='methods'><li data-type='method'><a href="SoundPlayer.html#getDuration">getDuration</a></li><li data-type='method'><a href="SoundPlayer.html#play">play</a></li><li data-type='method'><a href="SoundPlayer.html#setDuration">setDuration</a></li><li data-type='method'><a href="SoundPlayer.html#setLoops">setLoops</a></li><li data-type='method'><a href="SoundPlayer.html#setVolume">setVolume</a></li><li data-type='method'><a href="SoundPlayer.html#stop">stop</a></li></ul></li></ul><h3>Mixins</h3><ul><li><a href="module-core.WindowMixin.html">WindowMixin</a><ul class='methods'><li data-type='method'><a href="module-core.WindowMixin.html#_getHorLengthPix">_getHorLengthPix</a></li><li data-type='method'><a href="module-core.WindowMixin.html#_getLengthPix">_getLengthPix</a></li><li data-type='method'><a href="module-core.WindowMixin.html#_getLengthUnits">_getLengthUnits</a></li><li data-type='method'><a href="module-core.WindowMixin.html#_getVerLengthPix">_getVerLengthPix</a></li></ul></li><li><a href="module-util.ColorMixin.html">ColorMixin</a><ul class='methods'><li data-type='method'><a href="module-util.ColorMixin.html#getContrastedColor">getContrastedColor</a></li><li data-type='method'><a href="module-util.ColorMixin.html#setColor">setColor</a></li><li data-type='method'><a href="module-util.ColorMixin.html#setContrast">setContrast</a></li></ul></li></ul>
</nav>
<div id="main">
<h1 class="page-title">util</h1>
<section>
<header>
</header>
<article>
<div class="container-overview">
</div>
<h3 class="subsection-title">Classes</h3>
<dl>
<dt><a href="Clock.html">Clock</a></dt>
<dd></dd>
<dt><a href="Color.html">Color</a></dt>
<dd></dd>
<dt><a href="CountdownTimer.html">CountdownTimer</a></dt>
<dd></dd>
<dt><a href="EventEmitter.html">EventEmitter</a></dt>
<dd></dd>
<dt><a href="module-util.PsychObject.html">PsychObject</a></dt>
<dd></dd>
<dt><a href="MonotonicClock.html">MonotonicClock</a></dt>
<dd></dd>
<dt><a href="Scheduler.html">Scheduler</a></dt>
<dd></dd>
</dl>
<h3 class="subsection-title">Mixins</h3>
<dl>
<dt><a href="module-util.ColorMixin.html">ColorMixin</a></dt>
<dd></dd>
</dl>
<h3 class="subsection-title">Members</h3>
<h4 class="name" id=".mix"><span class="type-signature">(static) </span>mix<span class="type-signature"></span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line24">line 24</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Syntactic sugar for Mixins</p>
<p>This is heavily adapted from: http://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes/</p>
</div>
<h5>Example</h5>
<pre class="prettyprint"><code>class BaseClass { ... }
let Mixin1 = (superclass) => class extends superclass { ... }
let Mixin2 = (superclass) => class extends superclass { ... }
class NewClass extends mix(BaseClass).with(Mixin1, Mixin2) { ... }</code></pre>
<h4 class="name" id=".TEXT_DIRECTION"><span class="type-signature">(static, constant) </span>TEXT_DIRECTION<span class="type-signature"></span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line1410">line 1410</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Enum that stores possible text directions.
Note that Arabic is the same as RTL but added here to support PsychoPy's
languageStyle enum. Arabic reshaping is handled by the browser automatically.</p>
</div>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id=".addInfoFromUrl"><span class="type-signature">(static) </span>addInfoFromUrl<span class="signature">(info)</span><span class="type-signature"></span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line711">line 711</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Add info extracted from the URL to the given dictionary.</p>
<p>We exclude all URL parameters starting with a double underscore
since those are reserved for client/server communication</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>info</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last"><p>the dictionary</p></td>
</tr>
</tbody>
</table>
<h4 class="name" id=".average"><span class="type-signature">(static) </span>average<span class="signature">(input)</span><span class="type-signature"> &rarr; {number}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line1006">line 1006</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Calculate the average of the elements in the input array.</p>
<p>If 'input' is not an array, or if it is an empty array, then we return 0.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>input</code></td>
<td class="type">
<span class="param-type">array</span>
</td>
<td class="description last"><p>an array of numbers, or of objects that can be cast into a number, e.g. ['1', 2.5, 3e1]</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>the average of the elements in the array</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">number</span>
</dd>
</dl>
<h4 class="name" id=".count"><span class="type-signature">(static) </span>count<span class="signature">(input, value)</span><span class="type-signature"></span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line1220">line 1220</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Count the number of elements in the input array that match the given value.</p>
<p> Note: count is able to handle NaN, null, as well as any value convertible to a JSON string.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>input</code></td>
<td class="type">
<span class="param-type">array</span>
</td>
<td class="description last"><p>the input array</p></td>
</tr>
<tr>
<td class="name"><code>value</code></td>
<td class="type">
<span class="param-type">Number</span>
|
<span class="param-type">string</span>
|
<span class="param-type">object</span>
|
<span class="param-type">null</span>
</td>
<td class="description last"><p>the matching value</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>the number of matching elements</p>
</div>
<h4 class="name" id=".detectBrowser"><span class="type-signature">(static) </span>detectBrowser<span class="signature">()</span><span class="type-signature"> &rarr; {string}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line130">line 130</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Detect the user's browser.</p>
<p> Note: since user agent is easily spoofed, we use a more sophisticated approach, as described here:
https://stackoverflow.com/a/9851769</p>
</div>
<h5>Returns:</h5>
<div class="param-desc">
<p>the detected browser, one of 'Opera', 'Firefox', 'Safari',
'IE', 'Edge', 'EdgeChromium', 'Chrome', 'unknown'</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h4 class="name" id=".extensionFromMimeType"><span class="type-signature">(static) </span>extensionFromMimeType<span class="signature">(mimeType)</span><span class="type-signature"> &rarr; {string}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line1321">line 1321</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Return the file extension corresponding to an audio mime type.
If the provided mimeType is not a string (e.g. null, undefined, an array)
or unknown, then '.dat' is returned, instead of throwing an exception.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>mimeType</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"><p>the MIME type, e.g. 'audio/webm;codecs=opus'</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>the corresponding file extension, e.g. '.webm'</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h4 class="name" id=".flattenArray"><span class="type-signature">(static) </span>flattenArray<span class="signature">(array)</span><span class="type-signature"> &rarr; {Array.&lt;Object>}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line800">line 800</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Recursively flatten an array of arrays.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>array</code></td>
<td class="type">
<span class="param-type">Array.&lt;Object></span>
</td>
<td class="description last"><p>the input array of arrays</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>the flatten array</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.&lt;Object></span>
</dd>
</dl>
<h4 class="name" id=".getDownloadSpeed"><span class="type-signature">(static) </span>getDownloadSpeed<span class="signature">(psychoJS, nbDownloads<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {number}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line1360">line 1360</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Get an estimate of the download speed, by repeatedly downloading an image file from a distant
server.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>psychoJS</code></td>
<td class="type">
<span class="param-type"><a href="PsychoJS.html">PsychoJS</a></span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>the instance of PsychoJS</p></td>
</tr>
<tr>
<td class="name"><code>nbDownloads</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
<code>1</code>
</td>
<td class="description last"><p>the number of image downloads over which to average
the download speed</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>the download speed, in megabits per second</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">number</span>
</dd>
</dl>
<h4 class="name" id=".getErrorStack"><span class="type-signature">(static) </span>getErrorStack<span class="signature">()</span><span class="type-signature"> &rarr; {string}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line77">line 77</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Get the error stack of the calling, exception-throwing function.</p>
</div>
<h5>Returns:</h5>
<div class="param-desc">
<p>the error stack as a string</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h4 class="name" id=".getPositionFromObject"><span class="type-signature">(static) </span>getPositionFromObject<span class="signature">(object, units)</span><span class="type-signature"> &rarr; {Array.&lt;number>}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line356">line 356</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Get the position of the object, in pixel units</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>object</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last"><p>the input object</p></td>
</tr>
<tr>
<td class="name"><code>units</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"><p>the units</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>the position of the object, in pixel units</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.&lt;number></span>
</dd>
</dl>
<h4 class="name" id=".getRequestError"><span class="type-signature">(static) </span>getRequestError<span class="signature">(jqXHR, textStatus, errorThrown)</span><span class="type-signature"></span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line642">line 642</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Get the most informative error from the server response from a jquery server request.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>jqXHR</code></td>
<td class="type">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>textStatus</code></td>
<td class="type">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>errorThrown</code></td>
<td class="type">
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<h4 class="name" id=".getUrlParameters"><span class="type-signature">(static) </span>getUrlParameters<span class="signature">()</span><span class="type-signature"> &rarr; {URLSearchParams}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line691">line 691</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Get the URL parameters.</p>
</div>
<h5>Example</h5>
<pre class="prettyprint"><code>const urlParameters = util.getUrlParameters();
for (const [key, value] of urlParameters)
console.log(key + ' = ' + value);</code></pre>
<h5>Returns:</h5>
<div class="param-desc">
<p>the iterable URLSearchParams</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">URLSearchParams</span>
</dd>
</dl>
<h4 class="name" id=".index"><span class="type-signature">(static) </span>index<span class="signature">(input, value)</span><span class="type-signature"></span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line1283">line 1283</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Get the index in the input array of the first element that matches the given value.</p>
<p> Note: index is able to handle NaN, null, as well as any value convertible to a JSON string.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>input</code></td>
<td class="type">
<span class="param-type">array</span>
</td>
<td class="description last"><p>the input array</p></td>
</tr>
<tr>
<td class="name"><code>value</code></td>
<td class="type">
<span class="param-type">Number</span>
|
<span class="param-type">string</span>
|
<span class="param-type">object</span>
|
<span class="param-type">null</span>
</td>
<td class="description last"><p>the matching value</p></td>
</tr>
</tbody>
</table>
<h5>Throws:</h5>
<div class="param-desc usertext">
<p>if the input array does not contain any matching element</p>
</div>
<h5>Returns:</h5>
<div class="param-desc">
<p>the index of the first element that matches the value</p>
</div>
<h4 class="name" id=".isEmpty"><span class="type-signature">(static) </span>isEmpty<span class="signature">(x)</span><span class="type-signature"> &rarr; {boolean}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line99">line 99</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Test if x is an 'empty' value.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>x</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last"><p>the value to test</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>true if x is one of the following: undefined, [], [undefined]</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">boolean</span>
</dd>
</dl>
<h4 class="name" id=".isInt"><span class="type-signature">(static) </span>isInt<span class="signature">(obj)</span><span class="type-signature"> &rarr; {boolean}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line669">line 669</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Test whether an object is either an integer or the string representation of an integer.</p>
<p>This is adapted from: https://stackoverflow.com/a/14794066</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>obj</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last"><p>the input object</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>whether or not the object is an integer or the string representation of an integer</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">boolean</span>
</dd>
</dl>
<h4 class="name" id=".isNumeric"><span class="type-signature">(static) </span>isNumeric<span class="signature">(input)</span><span class="type-signature"> &rarr; {boolean}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line277">line 277</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Check whether a value looks like a number</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>input</code></td>
<td class="type">
<span class="param-type">*</span>
</td>
<td class="description last"><p>Some value</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>Whether or not the value can be converted into a number</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">boolean</span>
</dd>
</dl>
<h4 class="name" id=".IsPointInsidePolygon"><span class="type-signature">(static) </span>IsPointInsidePolygon<span class="signature">(point, vertices)</span><span class="type-signature"> &rarr; {boolean}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line290">line 290</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Check whether a point lies within a polygon</p>
<p>We are using the algorithm described here: https://wrf.ecse.rpi.edu//Research/Short_Notes/pnpoly.html</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>point</code></td>
<td class="type">
<span class="param-type">Array.&lt;number></span>
</td>
<td class="description last"><p>the point</p></td>
</tr>
<tr>
<td class="name"><code>vertices</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last"><p>the vertices defining the polygon</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>whether or not the point lies within the polygon</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">boolean</span>
</dd>
</dl>
<h4 class="name" id=".makeUuid"><span class="type-signature">(static) </span>makeUuid<span class="signature">()</span><span class="type-signature"> &rarr; {string}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line63">line 63</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Get a Universally Unique Identifier (RFC4122 version 4)</p>
<p> See details here: https://www.ietf.org/rfc/rfc4122.txt</p>
</div>
<h5>Returns:</h5>
<div class="param-desc">
<p>the uuid</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h4 class="name" id=".offerDataForDownload"><span class="type-signature">(static) </span>offerDataForDownload<span class="signature">(filename, data, type)</span><span class="type-signature"></span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line862">line 862</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Offer data as download in the browser.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>filename</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"><p>the name of the file to be downloaded</p></td>
</tr>
<tr>
<td class="name"><code>data</code></td>
<td class="type">
<span class="param-type">*</span>
</td>
<td class="description last"><p>the data</p></td>
</tr>
<tr>
<td class="name"><code>type</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"><p>the MIME type of the data, e.g. 'text/csv' or 'application/json'</p></td>
</tr>
</tbody>
</table>
<h4 class="name" id=".pad"><span class="type-signature">(static) </span>pad<span class="signature">(n, width)</span><span class="type-signature"> &rarr; {string}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line1260">line 1260</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Pad the given floating-point number with however many 0 needed at the start such that
the padded integer part of the number is of the given width.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>n</code></td>
<td class="type">
</td>
<td class="description last"><p>the input floating-point number</p></td>
</tr>
<tr>
<td class="name"><code>width</code></td>
<td class="type">
</td>
<td class="description last"><p>the desired width</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<ul>
<li>the padded number, whose integer part has the given width</li>
</ul>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h4 class="name" id=".promiseToTupple"><span class="type-signature">(static) </span>promiseToTupple<span class="signature">(promise)</span><span class="type-signature"> &rarr; {Array.&lt;Object>}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line50">line 50</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Convert the resulting value of a promise into a tupple.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>promise</code></td>
<td class="type">
<span class="param-type">Promise</span>
</td>
<td class="description last"><p>the promise</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>the resulting value in the format [error, return data]
where error is null if there was no error</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.&lt;Object></span>
</dd>
</dl>
<h4 class="name" id=".randchoice"><span class="type-signature">(static) </span>randchoice<span class="signature">(array, randomNumberGenerator<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Array.&lt;Object>}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line339">line 339</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Pick a random value from an array, uses <code>util.shuffle</code> to shuffle the array and returns the last value.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>array</code></td>
<td class="type">
<span class="param-type">Array.&lt;Object></span>
</td>
<td class="attributes">
</td>
<td class="description last"><p>the input 1-D array</p></td>
</tr>
<tr>
<td class="name"><code>randomNumberGenerator</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last"><p>A function used to generated random numbers in the interal [0, 1). Defaults to Math.random</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>a chosen value from the array</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.&lt;Object></span>
</dd>
</dl>
<h4 class="name" id=".randint"><span class="type-signature">(static) </span>randint<span class="signature">(min<span class="signature-attributes">opt</span>, max)</span><span class="type-signature"> &rarr; {number}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line933">line 933</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Generates random integers a-la NumPy's in the &quot;half-open&quot; interval [min, max). In other words, from min inclusive to max exclusive. When max is undefined, as is the case by default, results are chosen from [0, min). An error is thrown if max is less than min.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>min</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
<code>0</code>
</td>
<td class="description last"><p>lowest integer to be drawn, or highest plus one if max is undefined (default)</p></td>
</tr>
<tr>
<td class="name"><code>max</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>one above the largest integer to be drawn</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>a random integer in the requested range (signed)</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">number</span>
</dd>
</dl>
<h4 class="name" id=".range"><span class="type-signature">(static) </span>range<span class="signature">(start<span class="signature-attributes">opt</span>, stop, step<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Array.&lt;Number>}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line1076">line 1076</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Create a sequence of integers.</p>
<p>The sequence is such that the integer at index i is: start + step * i, with i &gt;= 0 and start + step * i &lt; stop</p>
<p> Note: this is a JavaScript implement of the Python range function, which explains the unusual management of arguments.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>start</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
<code>0</code>
</td>
<td class="description last"><p>the value of start</p></td>
</tr>
<tr>
<td class="name"><code>stop</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>the value of stop</p></td>
</tr>
<tr>
<td class="name"><code>step</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
<code>1</code>
</td>
<td class="description last"><p>the value of step</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>the range as an array of numbers</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.&lt;Number></span>
</dd>
</dl>
<h4 class="name" id=".round"><span class="type-signature">(static) </span>round<span class="signature">(input, places)</span><span class="type-signature"> &rarr; {number}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line966">line 966</a>
</li></ul></dd>
<dt class="tag-see">See:</dt>
<dd class="tag-see">
<ul>
<li><a href="https://stackoverflow.com/questions/11832914">Stack Overflow</a></li>
</ul>
</dd>
</dl>
<div class="description usertext">
<p>Round to a certain number of decimal places.</p>
<p>This is the Crib Sheet provided solution, but please note that as of 2020 the most popular SO answer is different.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>input</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>the number to be rounded</p></td>
</tr>
<tr>
<td class="name"><code>places</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>the max number of decimals desired</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>input rounded to the specified number of decimal places at most</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">number</span>
</dd>
</dl>
<h4 class="name" id=".selectFromArray"><span class="type-signature">(static) </span>selectFromArray<span class="signature">(array, selection)</span><span class="type-signature"> &rarr; {Object|Array.&lt;Object>}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line746">line 746</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Select values from an array.</p>
<p> 'selection' can be a single integer, an array of indices, or a string to be parsed, e.g.:
<ul>
<li>5</li>
<li>[1,2,3,10]</li>
<li>'1,5,10'</li>
<li>'1:2:5'</li>
<li>'5:'</li>
<li>'-5:-2, 9, 11:5:22'</li>
</ul></p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>array</code></td>
<td class="type">
<span class="param-type">Array.&lt;Object></span>
</td>
<td class="description last"><p>the input array</p></td>
</tr>
<tr>
<td class="name"><code>selection</code></td>
<td class="type">
<span class="param-type">number</span>
|
<span class="param-type">Array.&lt;number></span>
|
<span class="param-type">string</span>
</td>
<td class="description last"><p>the selection</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>the array of selected items</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Object</span>
|
<span class="param-type">Array.&lt;Object></span>
</dd>
</dl>
<h4 class="name" id=".shuffle"><span class="type-signature">(static) </span>shuffle<span class="signature">(array, randomNumberGenerator<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Array.&lt;Object>}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line318">line 318</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Shuffle an array in place using the Fisher-Yastes's modern algorithm</p>
<p>See details here: https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#The_modern_algorithm</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>array</code></td>
<td class="type">
<span class="param-type">Array.&lt;Object></span>
</td>
<td class="attributes">
</td>
<td class="description last"><p>the input 1-D array</p></td>
</tr>
<tr>
<td class="name"><code>randomNumberGenerator</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last"><p>A function used to generated random numbers in the interal [0, 1). Defaults to Math.random</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>the shuffled array</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.&lt;Object></span>
</dd>
</dl>
<h4 class="name" id=".sliceArray"><span class="type-signature">(static) </span>sliceArray<span class="signature">(array, from<span class="signature-attributes">opt</span>, to<span class="signature-attributes">opt</span>, step<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Array.&lt;Object>}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line821">line 821</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Slice an array.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>array</code></td>
<td class="type">
<span class="param-type">Array.&lt;Object></span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>the input array</p></td>
</tr>
<tr>
<td class="name"><code>from</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
<code>NaN</code>
</td>
<td class="description last"><p>the start of the slice</p></td>
</tr>
<tr>
<td class="name"><code>to</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
<code>NaN</code>
</td>
<td class="description last"><p>the end of the slice</p></td>
</tr>
<tr>
<td class="name"><code>step</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
<code>NaN</code>
</td>
<td class="description last"><p>the step of the slice</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>the array slice</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.&lt;Object></span>
</dd>
</dl>
<h4 class="name" id=".sort"><span class="type-signature">(static) </span>sort<span class="signature">(input)</span><span class="type-signature"> &rarr; {array}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line1029">line 1029</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Sort the elements of the input array, in increasing alphabetical or numerical order.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>input</code></td>
<td class="type">
<span class="param-type">array</span>
</td>
<td class="description last"><p>an array of numbers or of strings</p></td>
</tr>
</tbody>
</table>
<h5>Throws:</h5>
<div class="param-desc usertext">
<p>if 'input' is not an array, or if its elements are not consistent in types, or if they are not all either numbers or
strings</p>
</div>
<h5>Returns:</h5>
<div class="param-desc">
<p>the sorted array</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">array</span>
</dd>
</dl>
<h4 class="name" id=".sum"><span class="type-signature">(static) </span>sum<span class="signature">(input, start)</span><span class="type-signature"> &rarr; {number}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line980">line 980</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Calculate the sum of the elements in the input array.</p>
<p>If 'input' is not an array, then we return start.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>input</code></td>
<td class="type">
<span class="param-type">array</span>
</td>
<td class="description last"><p>an array of numbers, or of objects that can be cast into a number, e.g. ['1', 2.5, 3e1]</p></td>
</tr>
<tr>
<td class="name"><code>start</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>value added to the sum of numbers (a la Python)</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>the sum of the elements in the array + start</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">number</span>
</dd>
</dl>
<h4 class="name" id=".to_height"><span class="type-signature">(static) </span>to_height<span class="signature">(pos, posUnit, win)</span><span class="type-signature"> &rarr; {Array.&lt;number>}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line472">line 472</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Convert the position to height units.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>pos</code></td>
<td class="type">
<span class="param-type">Array.&lt;number></span>
</td>
<td class="description last"><p>the input position</p></td>
</tr>
<tr>
<td class="name"><code>posUnit</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"><p>the position units</p></td>
</tr>
<tr>
<td class="name"><code>win</code></td>
<td class="type">
<span class="param-type"><a href="Window.html">Window</a></span>
</td>
<td class="description last"><p>the associated Window</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>the position in height units</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.&lt;number></span>
</dd>
</dl>
<h4 class="name" id=".to_norm"><span class="type-signature">(static) </span>to_norm<span class="signature">(pos, posUnit, win)</span><span class="type-signature"> &rarr; {Array.&lt;number>}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line443">line 443</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Convert the position to norm units.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>pos</code></td>
<td class="type">
<span class="param-type">Array.&lt;number></span>
</td>
<td class="description last"><p>the input position</p></td>
</tr>
<tr>
<td class="name"><code>posUnit</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"><p>the position units</p></td>
</tr>
<tr>
<td class="name"><code>win</code></td>
<td class="type">
<span class="param-type"><a href="Window.html">Window</a></span>
</td>
<td class="description last"><p>the associated Window</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>the position in norm units</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.&lt;number></span>
</dd>
</dl>
<h4 class="name" id=".to_pixiPoint"><span class="type-signature">(static) </span>to_pixiPoint<span class="signature">(pos, posUnit, win, integerCoordinates<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Array.&lt;number>}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Pixi.js.html">util/Pixi.js</a>, <a href="util_Pixi.js.html#line13">line 13</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Convert a position to a PIXI Point.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>pos</code></td>
<td class="type">
<span class="param-type">Array.&lt;number></span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>the input position</p></td>
</tr>
<tr>
<td class="name"><code>posUnit</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>the position units</p></td>
</tr>
<tr>
<td class="name"><code>win</code></td>
<td class="type">
<span class="param-type"><a href="Window.html">Window</a></span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>the associated Window</p></td>
</tr>
<tr>
<td class="name"><code>integerCoordinates</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
<code>false</code>
</td>
<td class="description last"><p>whether or not to round the PIXI Point coordinates.</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>the position as a PIXI Point</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.&lt;number></span>
</dd>
</dl>
<h4 class="name" id=".to_px"><span class="type-signature">(static) </span>to_px<span class="signature">(pos, posUnit, win, integerCoordinates<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Array.&lt;number>}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line398">line 398</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Convert the position to pixel units.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>pos</code></td>
<td class="type">
<span class="param-type">Array.&lt;number></span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>the input position</p></td>
</tr>
<tr>
<td class="name"><code>posUnit</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>the position units</p></td>
</tr>
<tr>
<td class="name"><code>win</code></td>
<td class="type">
<span class="param-type"><a href="Window.html">Window</a></span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>the associated Window</p></td>
</tr>
<tr>
<td class="name"><code>integerCoordinates</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
<code>false</code>
</td>
<td class="description last"><p>whether or not to round the position coordinates.</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>the position in pixel units</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.&lt;number></span>
</dd>
</dl>
<h4 class="name" id=".to_unit"><span class="type-signature">(static) </span>to_unit<span class="signature">(pos, posUnit, win, targetUnit)</span><span class="type-signature"> &rarr; {Array.&lt;number>}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line541">line 541</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Convert the position to given units.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>pos</code></td>
<td class="type">
<span class="param-type">Array.&lt;number></span>
</td>
<td class="description last"><p>the input position</p></td>
</tr>
<tr>
<td class="name"><code>posUnit</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"><p>the position units</p></td>
</tr>
<tr>
<td class="name"><code>win</code></td>
<td class="type">
<span class="param-type"><a href="Window.html">Window</a></span>
</td>
<td class="description last"><p>the associated Window</p></td>
</tr>
<tr>
<td class="name"><code>targetUnit</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"><p>the target units</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>the position in target units</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.&lt;number></span>
</dd>
</dl>
<h4 class="name" id=".to_win"><span class="type-signature">(static) </span>to_win<span class="signature">(pos, posUnit, win)</span><span class="type-signature"> &rarr; {Array.&lt;number>}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line505">line 505</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Convert the position to window units.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>pos</code></td>
<td class="type">
<span class="param-type">Array.&lt;number></span>
</td>
<td class="description last"><p>the input position</p></td>
</tr>
<tr>
<td class="name"><code>posUnit</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"><p>the position units</p></td>
</tr>
<tr>
<td class="name"><code>win</code></td>
<td class="type">
<span class="param-type"><a href="Window.html">Window</a></span>
</td>
<td class="description last"><p>the associated Window</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>the position in window units</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.&lt;number></span>
</dd>
</dl>
<h4 class="name" id=".toNumerical"><span class="type-signature">(static) </span>toNumerical<span class="signature">(obj)</span><span class="type-signature"> &rarr; {number|Array.&lt;number>}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line210">line 210</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Convert obj to its numerical form.</p>
<ul>
<li>number -> number, e.g. 2 -> 2</li>
<li>[number] -> [number], e.g. [1,2,3] -> [1,2,3]</li>
<li>numeral string -> number, e.g. "8" -> 8</li>
<li>[number | numeral string] -> [number], e.g. [1, 2, "3"] -> [1,2,3]</li>
</ul>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>obj</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last"><p>the input object</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>the numerical form of the input object</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">number</span>
|
<span class="param-type">Array.&lt;number></span>
</dd>
</dl>
<h4 class="name" id=".toString"><span class="type-signature">(static) </span>toString<span class="signature">(object)</span><span class="type-signature"> &rarr; {string}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line576">line 576</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Convert an object to its string representation, taking care of symbols.</p>
<p>Note: if the object is not already a string, we JSON stringify it and detect circularity.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>object</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last"><p>the input object</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>a string representation of the object or 'Object (circular)'</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h4 class="name" id=".turnSquareBracketsIntoArrays"><span class="type-signature">(static) </span>turnSquareBracketsIntoArrays<span class="signature">(input, max)</span><span class="type-signature"> &rarr; {array}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line889">line 889</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Convert a string representing a JSON array, e.g. &quot;[1, 2]&quot; into an array, e.g. [&quot;1&quot;,&quot;2&quot;].
This approach overcomes the built-in JSON parsing limitations when it comes to eg. floats
missing the naught prefix, and is able to process several arrays, e.g. &quot;[1,2][3,4]&quot;.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>input</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"><p>string potentially containing JSON arrays</p></td>
</tr>
<tr>
<td class="name"><code>max</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"><p>how many matches to return, unwrap resulting array if less than two</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>an array if arrays were found, undefined otherwise</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">array</span>
</dd>
</dl>
<h4 class="name" id="~_match"><span class="type-signature">(protected, inner) </span>_match<span class="signature">(value)</span><span class="type-signature"></span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line1159">line 1159</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Create a boolean function that compares an input element to the given value.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>value</code></td>
<td class="type">
<span class="param-type">Number</span>
|
<span class="param-type">string</span>
|
<span class="param-type">object</span>
|
<span class="param-type">null</span>
</td>
<td class="description last"><p>the matching value</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>a function that compares an input element to the given value</p>
</div>
</article>
</section>
<section>
<header>
</header>
<article>
<div class="container-overview">
</div>
<h3 class="subsection-title">Classes</h3>
<dl>
<dt><a href="Clock.html">Clock</a></dt>
<dd></dd>
<dt><a href="Color.html">Color</a></dt>
<dd></dd>
<dt><a href="CountdownTimer.html">CountdownTimer</a></dt>
<dd></dd>
<dt><a href="EventEmitter.html">EventEmitter</a></dt>
<dd></dd>
<dt><a href="module-util.PsychObject.html">PsychObject</a></dt>
<dd></dd>
<dt><a href="MonotonicClock.html">MonotonicClock</a></dt>
<dd></dd>
<dt><a href="Scheduler.html">Scheduler</a></dt>
<dd></dd>
</dl>
<h3 class="subsection-title">Mixins</h3>
<dl>
<dt><a href="module-util.ColorMixin.html">ColorMixin</a></dt>
<dd></dd>
</dl>
<h3 class="subsection-title">Members</h3>
<h4 class="name" id=".mix"><span class="type-signature">(static) </span>mix<span class="type-signature"></span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line24">line 24</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Syntactic sugar for Mixins</p>
<p>This is heavily adapted from: http://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes/</p>
</div>
<h5>Example</h5>
<pre class="prettyprint"><code>class BaseClass { ... }
let Mixin1 = (superclass) => class extends superclass { ... }
let Mixin2 = (superclass) => class extends superclass { ... }
class NewClass extends mix(BaseClass).with(Mixin1, Mixin2) { ... }</code></pre>
<h4 class="name" id=".TEXT_DIRECTION"><span class="type-signature">(static, constant) </span>TEXT_DIRECTION<span class="type-signature"></span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line1410">line 1410</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Enum that stores possible text directions.
Note that Arabic is the same as RTL but added here to support PsychoPy's
languageStyle enum. Arabic reshaping is handled by the browser automatically.</p>
</div>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id=".addInfoFromUrl"><span class="type-signature">(static) </span>addInfoFromUrl<span class="signature">(info)</span><span class="type-signature"></span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line711">line 711</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Add info extracted from the URL to the given dictionary.</p>
<p>We exclude all URL parameters starting with a double underscore
since those are reserved for client/server communication</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>info</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last"><p>the dictionary</p></td>
</tr>
</tbody>
</table>
<h4 class="name" id=".average"><span class="type-signature">(static) </span>average<span class="signature">(input)</span><span class="type-signature"> &rarr; {number}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line1006">line 1006</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Calculate the average of the elements in the input array.</p>
<p>If 'input' is not an array, or if it is an empty array, then we return 0.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>input</code></td>
<td class="type">
<span class="param-type">array</span>
</td>
<td class="description last"><p>an array of numbers, or of objects that can be cast into a number, e.g. ['1', 2.5, 3e1]</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>the average of the elements in the array</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">number</span>
</dd>
</dl>
<h4 class="name" id=".count"><span class="type-signature">(static) </span>count<span class="signature">(input, value)</span><span class="type-signature"></span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line1220">line 1220</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Count the number of elements in the input array that match the given value.</p>
<p> Note: count is able to handle NaN, null, as well as any value convertible to a JSON string.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>input</code></td>
<td class="type">
<span class="param-type">array</span>
</td>
<td class="description last"><p>the input array</p></td>
</tr>
<tr>
<td class="name"><code>value</code></td>
<td class="type">
<span class="param-type">Number</span>
|
<span class="param-type">string</span>
|
<span class="param-type">object</span>
|
<span class="param-type">null</span>
</td>
<td class="description last"><p>the matching value</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>the number of matching elements</p>
</div>
<h4 class="name" id=".detectBrowser"><span class="type-signature">(static) </span>detectBrowser<span class="signature">()</span><span class="type-signature"> &rarr; {string}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line130">line 130</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Detect the user's browser.</p>
<p> Note: since user agent is easily spoofed, we use a more sophisticated approach, as described here:
https://stackoverflow.com/a/9851769</p>
</div>
<h5>Returns:</h5>
<div class="param-desc">
<p>the detected browser, one of 'Opera', 'Firefox', 'Safari',
'IE', 'Edge', 'EdgeChromium', 'Chrome', 'unknown'</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h4 class="name" id=".extensionFromMimeType"><span class="type-signature">(static) </span>extensionFromMimeType<span class="signature">(mimeType)</span><span class="type-signature"> &rarr; {string}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line1321">line 1321</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Return the file extension corresponding to an audio mime type.
If the provided mimeType is not a string (e.g. null, undefined, an array)
or unknown, then '.dat' is returned, instead of throwing an exception.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>mimeType</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"><p>the MIME type, e.g. 'audio/webm;codecs=opus'</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>the corresponding file extension, e.g. '.webm'</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h4 class="name" id=".flattenArray"><span class="type-signature">(static) </span>flattenArray<span class="signature">(array)</span><span class="type-signature"> &rarr; {Array.&lt;Object>}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line800">line 800</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Recursively flatten an array of arrays.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>array</code></td>
<td class="type">
<span class="param-type">Array.&lt;Object></span>
</td>
<td class="description last"><p>the input array of arrays</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>the flatten array</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.&lt;Object></span>
</dd>
</dl>
<h4 class="name" id=".getDownloadSpeed"><span class="type-signature">(static) </span>getDownloadSpeed<span class="signature">(psychoJS, nbDownloads<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {number}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line1360">line 1360</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Get an estimate of the download speed, by repeatedly downloading an image file from a distant
server.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>psychoJS</code></td>
<td class="type">
<span class="param-type"><a href="PsychoJS.html">PsychoJS</a></span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>the instance of PsychoJS</p></td>
</tr>
<tr>
<td class="name"><code>nbDownloads</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
<code>1</code>
</td>
<td class="description last"><p>the number of image downloads over which to average
the download speed</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>the download speed, in megabits per second</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">number</span>
</dd>
</dl>
<h4 class="name" id=".getErrorStack"><span class="type-signature">(static) </span>getErrorStack<span class="signature">()</span><span class="type-signature"> &rarr; {string}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line77">line 77</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Get the error stack of the calling, exception-throwing function.</p>
</div>
<h5>Returns:</h5>
<div class="param-desc">
<p>the error stack as a string</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h4 class="name" id=".getPositionFromObject"><span class="type-signature">(static) </span>getPositionFromObject<span class="signature">(object, units)</span><span class="type-signature"> &rarr; {Array.&lt;number>}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line356">line 356</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Get the position of the object, in pixel units</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>object</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last"><p>the input object</p></td>
</tr>
<tr>
<td class="name"><code>units</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"><p>the units</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>the position of the object, in pixel units</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.&lt;number></span>
</dd>
</dl>
<h4 class="name" id=".getRequestError"><span class="type-signature">(static) </span>getRequestError<span class="signature">(jqXHR, textStatus, errorThrown)</span><span class="type-signature"></span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line642">line 642</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Get the most informative error from the server response from a jquery server request.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>jqXHR</code></td>
<td class="type">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>textStatus</code></td>
<td class="type">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>errorThrown</code></td>
<td class="type">
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<h4 class="name" id=".getUrlParameters"><span class="type-signature">(static) </span>getUrlParameters<span class="signature">()</span><span class="type-signature"> &rarr; {URLSearchParams}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line691">line 691</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Get the URL parameters.</p>
</div>
<h5>Example</h5>
<pre class="prettyprint"><code>const urlParameters = util.getUrlParameters();
for (const [key, value] of urlParameters)
console.log(key + ' = ' + value);</code></pre>
<h5>Returns:</h5>
<div class="param-desc">
<p>the iterable URLSearchParams</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">URLSearchParams</span>
</dd>
</dl>
<h4 class="name" id=".index"><span class="type-signature">(static) </span>index<span class="signature">(input, value)</span><span class="type-signature"></span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line1283">line 1283</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Get the index in the input array of the first element that matches the given value.</p>
<p> Note: index is able to handle NaN, null, as well as any value convertible to a JSON string.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>input</code></td>
<td class="type">
<span class="param-type">array</span>
</td>
<td class="description last"><p>the input array</p></td>
</tr>
<tr>
<td class="name"><code>value</code></td>
<td class="type">
<span class="param-type">Number</span>
|
<span class="param-type">string</span>
|
<span class="param-type">object</span>
|
<span class="param-type">null</span>
</td>
<td class="description last"><p>the matching value</p></td>
</tr>
</tbody>
</table>
<h5>Throws:</h5>
<div class="param-desc usertext">
<p>if the input array does not contain any matching element</p>
</div>
<h5>Returns:</h5>
<div class="param-desc">
<p>the index of the first element that matches the value</p>
</div>
<h4 class="name" id=".isEmpty"><span class="type-signature">(static) </span>isEmpty<span class="signature">(x)</span><span class="type-signature"> &rarr; {boolean}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line99">line 99</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Test if x is an 'empty' value.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>x</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last"><p>the value to test</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>true if x is one of the following: undefined, [], [undefined]</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">boolean</span>
</dd>
</dl>
<h4 class="name" id=".isInt"><span class="type-signature">(static) </span>isInt<span class="signature">(obj)</span><span class="type-signature"> &rarr; {boolean}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line669">line 669</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Test whether an object is either an integer or the string representation of an integer.</p>
<p>This is adapted from: https://stackoverflow.com/a/14794066</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>obj</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last"><p>the input object</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>whether or not the object is an integer or the string representation of an integer</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">boolean</span>
</dd>
</dl>
<h4 class="name" id=".isNumeric"><span class="type-signature">(static) </span>isNumeric<span class="signature">(input)</span><span class="type-signature"> &rarr; {boolean}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line277">line 277</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Check whether a value looks like a number</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>input</code></td>
<td class="type">
<span class="param-type">*</span>
</td>
<td class="description last"><p>Some value</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>Whether or not the value can be converted into a number</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">boolean</span>
</dd>
</dl>
<h4 class="name" id=".IsPointInsidePolygon"><span class="type-signature">(static) </span>IsPointInsidePolygon<span class="signature">(point, vertices)</span><span class="type-signature"> &rarr; {boolean}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line290">line 290</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Check whether a point lies within a polygon</p>
<p>We are using the algorithm described here: https://wrf.ecse.rpi.edu//Research/Short_Notes/pnpoly.html</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>point</code></td>
<td class="type">
<span class="param-type">Array.&lt;number></span>
</td>
<td class="description last"><p>the point</p></td>
</tr>
<tr>
<td class="name"><code>vertices</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last"><p>the vertices defining the polygon</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>whether or not the point lies within the polygon</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">boolean</span>
</dd>
</dl>
<h4 class="name" id=".makeUuid"><span class="type-signature">(static) </span>makeUuid<span class="signature">()</span><span class="type-signature"> &rarr; {string}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line63">line 63</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Get a Universally Unique Identifier (RFC4122 version 4)</p>
<p> See details here: https://www.ietf.org/rfc/rfc4122.txt</p>
</div>
<h5>Returns:</h5>
<div class="param-desc">
<p>the uuid</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h4 class="name" id=".offerDataForDownload"><span class="type-signature">(static) </span>offerDataForDownload<span class="signature">(filename, data, type)</span><span class="type-signature"></span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line862">line 862</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Offer data as download in the browser.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>filename</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"><p>the name of the file to be downloaded</p></td>
</tr>
<tr>
<td class="name"><code>data</code></td>
<td class="type">
<span class="param-type">*</span>
</td>
<td class="description last"><p>the data</p></td>
</tr>
<tr>
<td class="name"><code>type</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"><p>the MIME type of the data, e.g. 'text/csv' or 'application/json'</p></td>
</tr>
</tbody>
</table>
<h4 class="name" id=".pad"><span class="type-signature">(static) </span>pad<span class="signature">(n, width)</span><span class="type-signature"> &rarr; {string}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line1260">line 1260</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Pad the given floating-point number with however many 0 needed at the start such that
the padded integer part of the number is of the given width.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>n</code></td>
<td class="type">
</td>
<td class="description last"><p>the input floating-point number</p></td>
</tr>
<tr>
<td class="name"><code>width</code></td>
<td class="type">
</td>
<td class="description last"><p>the desired width</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<ul>
<li>the padded number, whose integer part has the given width</li>
</ul>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h4 class="name" id=".promiseToTupple"><span class="type-signature">(static) </span>promiseToTupple<span class="signature">(promise)</span><span class="type-signature"> &rarr; {Array.&lt;Object>}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line50">line 50</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Convert the resulting value of a promise into a tupple.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>promise</code></td>
<td class="type">
<span class="param-type">Promise</span>
</td>
<td class="description last"><p>the promise</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>the resulting value in the format [error, return data]
where error is null if there was no error</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.&lt;Object></span>
</dd>
</dl>
<h4 class="name" id=".randchoice"><span class="type-signature">(static) </span>randchoice<span class="signature">(array, randomNumberGenerator<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Array.&lt;Object>}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line339">line 339</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Pick a random value from an array, uses <code>util.shuffle</code> to shuffle the array and returns the last value.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>array</code></td>
<td class="type">
<span class="param-type">Array.&lt;Object></span>
</td>
<td class="attributes">
</td>
<td class="description last"><p>the input 1-D array</p></td>
</tr>
<tr>
<td class="name"><code>randomNumberGenerator</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last"><p>A function used to generated random numbers in the interal [0, 1). Defaults to Math.random</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>a chosen value from the array</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.&lt;Object></span>
</dd>
</dl>
<h4 class="name" id=".randint"><span class="type-signature">(static) </span>randint<span class="signature">(min<span class="signature-attributes">opt</span>, max)</span><span class="type-signature"> &rarr; {number}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line933">line 933</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Generates random integers a-la NumPy's in the &quot;half-open&quot; interval [min, max). In other words, from min inclusive to max exclusive. When max is undefined, as is the case by default, results are chosen from [0, min). An error is thrown if max is less than min.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>min</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
<code>0</code>
</td>
<td class="description last"><p>lowest integer to be drawn, or highest plus one if max is undefined (default)</p></td>
</tr>
<tr>
<td class="name"><code>max</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>one above the largest integer to be drawn</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>a random integer in the requested range (signed)</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">number</span>
</dd>
</dl>
<h4 class="name" id=".range"><span class="type-signature">(static) </span>range<span class="signature">(start<span class="signature-attributes">opt</span>, stop, step<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Array.&lt;Number>}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line1076">line 1076</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Create a sequence of integers.</p>
<p>The sequence is such that the integer at index i is: start + step * i, with i &gt;= 0 and start + step * i &lt; stop</p>
<p> Note: this is a JavaScript implement of the Python range function, which explains the unusual management of arguments.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>start</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
<code>0</code>
</td>
<td class="description last"><p>the value of start</p></td>
</tr>
<tr>
<td class="name"><code>stop</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>the value of stop</p></td>
</tr>
<tr>
<td class="name"><code>step</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
<code>1</code>
</td>
<td class="description last"><p>the value of step</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>the range as an array of numbers</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.&lt;Number></span>
</dd>
</dl>
<h4 class="name" id=".round"><span class="type-signature">(static) </span>round<span class="signature">(input, places)</span><span class="type-signature"> &rarr; {number}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line966">line 966</a>
</li></ul></dd>
<dt class="tag-see">See:</dt>
<dd class="tag-see">
<ul>
<li><a href="https://stackoverflow.com/questions/11832914">Stack Overflow</a></li>
</ul>
</dd>
</dl>
<div class="description usertext">
<p>Round to a certain number of decimal places.</p>
<p>This is the Crib Sheet provided solution, but please note that as of 2020 the most popular SO answer is different.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>input</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>the number to be rounded</p></td>
</tr>
<tr>
<td class="name"><code>places</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>the max number of decimals desired</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>input rounded to the specified number of decimal places at most</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">number</span>
</dd>
</dl>
<h4 class="name" id=".selectFromArray"><span class="type-signature">(static) </span>selectFromArray<span class="signature">(array, selection)</span><span class="type-signature"> &rarr; {Object|Array.&lt;Object>}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line746">line 746</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Select values from an array.</p>
<p> 'selection' can be a single integer, an array of indices, or a string to be parsed, e.g.:
<ul>
<li>5</li>
<li>[1,2,3,10]</li>
<li>'1,5,10'</li>
<li>'1:2:5'</li>
<li>'5:'</li>
<li>'-5:-2, 9, 11:5:22'</li>
</ul></p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>array</code></td>
<td class="type">
<span class="param-type">Array.&lt;Object></span>
</td>
<td class="description last"><p>the input array</p></td>
</tr>
<tr>
<td class="name"><code>selection</code></td>
<td class="type">
<span class="param-type">number</span>
|
<span class="param-type">Array.&lt;number></span>
|
<span class="param-type">string</span>
</td>
<td class="description last"><p>the selection</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>the array of selected items</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Object</span>
|
<span class="param-type">Array.&lt;Object></span>
</dd>
</dl>
<h4 class="name" id=".shuffle"><span class="type-signature">(static) </span>shuffle<span class="signature">(array, randomNumberGenerator<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Array.&lt;Object>}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line318">line 318</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Shuffle an array in place using the Fisher-Yastes's modern algorithm</p>
<p>See details here: https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#The_modern_algorithm</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>array</code></td>
<td class="type">
<span class="param-type">Array.&lt;Object></span>
</td>
<td class="attributes">
</td>
<td class="description last"><p>the input 1-D array</p></td>
</tr>
<tr>
<td class="name"><code>randomNumberGenerator</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last"><p>A function used to generated random numbers in the interal [0, 1). Defaults to Math.random</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>the shuffled array</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.&lt;Object></span>
</dd>
</dl>
<h4 class="name" id=".sliceArray"><span class="type-signature">(static) </span>sliceArray<span class="signature">(array, from<span class="signature-attributes">opt</span>, to<span class="signature-attributes">opt</span>, step<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Array.&lt;Object>}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line821">line 821</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Slice an array.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>array</code></td>
<td class="type">
<span class="param-type">Array.&lt;Object></span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>the input array</p></td>
</tr>
<tr>
<td class="name"><code>from</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
<code>NaN</code>
</td>
<td class="description last"><p>the start of the slice</p></td>
</tr>
<tr>
<td class="name"><code>to</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
<code>NaN</code>
</td>
<td class="description last"><p>the end of the slice</p></td>
</tr>
<tr>
<td class="name"><code>step</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
<code>NaN</code>
</td>
<td class="description last"><p>the step of the slice</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>the array slice</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.&lt;Object></span>
</dd>
</dl>
<h4 class="name" id=".sort"><span class="type-signature">(static) </span>sort<span class="signature">(input)</span><span class="type-signature"> &rarr; {array}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line1029">line 1029</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Sort the elements of the input array, in increasing alphabetical or numerical order.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>input</code></td>
<td class="type">
<span class="param-type">array</span>
</td>
<td class="description last"><p>an array of numbers or of strings</p></td>
</tr>
</tbody>
</table>
<h5>Throws:</h5>
<div class="param-desc usertext">
<p>if 'input' is not an array, or if its elements are not consistent in types, or if they are not all either numbers or
strings</p>
</div>
<h5>Returns:</h5>
<div class="param-desc">
<p>the sorted array</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">array</span>
</dd>
</dl>
<h4 class="name" id=".sum"><span class="type-signature">(static) </span>sum<span class="signature">(input, start)</span><span class="type-signature"> &rarr; {number}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line980">line 980</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Calculate the sum of the elements in the input array.</p>
<p>If 'input' is not an array, then we return start.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>input</code></td>
<td class="type">
<span class="param-type">array</span>
</td>
<td class="description last"><p>an array of numbers, or of objects that can be cast into a number, e.g. ['1', 2.5, 3e1]</p></td>
</tr>
<tr>
<td class="name"><code>start</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>value added to the sum of numbers (a la Python)</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>the sum of the elements in the array + start</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">number</span>
</dd>
</dl>
<h4 class="name" id=".to_height"><span class="type-signature">(static) </span>to_height<span class="signature">(pos, posUnit, win)</span><span class="type-signature"> &rarr; {Array.&lt;number>}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line472">line 472</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Convert the position to height units.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>pos</code></td>
<td class="type">
<span class="param-type">Array.&lt;number></span>
</td>
<td class="description last"><p>the input position</p></td>
</tr>
<tr>
<td class="name"><code>posUnit</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"><p>the position units</p></td>
</tr>
<tr>
<td class="name"><code>win</code></td>
<td class="type">
<span class="param-type"><a href="Window.html">Window</a></span>
</td>
<td class="description last"><p>the associated Window</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>the position in height units</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.&lt;number></span>
</dd>
</dl>
<h4 class="name" id=".to_norm"><span class="type-signature">(static) </span>to_norm<span class="signature">(pos, posUnit, win)</span><span class="type-signature"> &rarr; {Array.&lt;number>}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line443">line 443</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Convert the position to norm units.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>pos</code></td>
<td class="type">
<span class="param-type">Array.&lt;number></span>
</td>
<td class="description last"><p>the input position</p></td>
</tr>
<tr>
<td class="name"><code>posUnit</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"><p>the position units</p></td>
</tr>
<tr>
<td class="name"><code>win</code></td>
<td class="type">
<span class="param-type"><a href="Window.html">Window</a></span>
</td>
<td class="description last"><p>the associated Window</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>the position in norm units</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.&lt;number></span>
</dd>
</dl>
<h4 class="name" id=".to_pixiPoint"><span class="type-signature">(static) </span>to_pixiPoint<span class="signature">(pos, posUnit, win, integerCoordinates<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Array.&lt;number>}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Pixi.js.html">util/Pixi.js</a>, <a href="util_Pixi.js.html#line13">line 13</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Convert a position to a PIXI Point.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>pos</code></td>
<td class="type">
<span class="param-type">Array.&lt;number></span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>the input position</p></td>
</tr>
<tr>
<td class="name"><code>posUnit</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>the position units</p></td>
</tr>
<tr>
<td class="name"><code>win</code></td>
<td class="type">
<span class="param-type"><a href="Window.html">Window</a></span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>the associated Window</p></td>
</tr>
<tr>
<td class="name"><code>integerCoordinates</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
<code>false</code>
</td>
<td class="description last"><p>whether or not to round the PIXI Point coordinates.</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>the position as a PIXI Point</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.&lt;number></span>
</dd>
</dl>
<h4 class="name" id=".to_px"><span class="type-signature">(static) </span>to_px<span class="signature">(pos, posUnit, win, integerCoordinates<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Array.&lt;number>}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line398">line 398</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Convert the position to pixel units.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>pos</code></td>
<td class="type">
<span class="param-type">Array.&lt;number></span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>the input position</p></td>
</tr>
<tr>
<td class="name"><code>posUnit</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>the position units</p></td>
</tr>
<tr>
<td class="name"><code>win</code></td>
<td class="type">
<span class="param-type"><a href="Window.html">Window</a></span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>the associated Window</p></td>
</tr>
<tr>
<td class="name"><code>integerCoordinates</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
<code>false</code>
</td>
<td class="description last"><p>whether or not to round the position coordinates.</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>the position in pixel units</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.&lt;number></span>
</dd>
</dl>
<h4 class="name" id=".to_unit"><span class="type-signature">(static) </span>to_unit<span class="signature">(pos, posUnit, win, targetUnit)</span><span class="type-signature"> &rarr; {Array.&lt;number>}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line541">line 541</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Convert the position to given units.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>pos</code></td>
<td class="type">
<span class="param-type">Array.&lt;number></span>
</td>
<td class="description last"><p>the input position</p></td>
</tr>
<tr>
<td class="name"><code>posUnit</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"><p>the position units</p></td>
</tr>
<tr>
<td class="name"><code>win</code></td>
<td class="type">
<span class="param-type"><a href="Window.html">Window</a></span>
</td>
<td class="description last"><p>the associated Window</p></td>
</tr>
<tr>
<td class="name"><code>targetUnit</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"><p>the target units</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>the position in target units</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.&lt;number></span>
</dd>
</dl>
<h4 class="name" id=".to_win"><span class="type-signature">(static) </span>to_win<span class="signature">(pos, posUnit, win)</span><span class="type-signature"> &rarr; {Array.&lt;number>}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line505">line 505</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Convert the position to window units.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>pos</code></td>
<td class="type">
<span class="param-type">Array.&lt;number></span>
</td>
<td class="description last"><p>the input position</p></td>
</tr>
<tr>
<td class="name"><code>posUnit</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"><p>the position units</p></td>
</tr>
<tr>
<td class="name"><code>win</code></td>
<td class="type">
<span class="param-type"><a href="Window.html">Window</a></span>
</td>
<td class="description last"><p>the associated Window</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>the position in window units</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.&lt;number></span>
</dd>
</dl>
<h4 class="name" id=".toNumerical"><span class="type-signature">(static) </span>toNumerical<span class="signature">(obj)</span><span class="type-signature"> &rarr; {number|Array.&lt;number>}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line210">line 210</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Convert obj to its numerical form.</p>
<ul>
<li>number -> number, e.g. 2 -> 2</li>
<li>[number] -> [number], e.g. [1,2,3] -> [1,2,3]</li>
<li>numeral string -> number, e.g. "8" -> 8</li>
<li>[number | numeral string] -> [number], e.g. [1, 2, "3"] -> [1,2,3]</li>
</ul>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>obj</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last"><p>the input object</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>the numerical form of the input object</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">number</span>
|
<span class="param-type">Array.&lt;number></span>
</dd>
</dl>
<h4 class="name" id=".toString"><span class="type-signature">(static) </span>toString<span class="signature">(object)</span><span class="type-signature"> &rarr; {string}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line576">line 576</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Convert an object to its string representation, taking care of symbols.</p>
<p>Note: if the object is not already a string, we JSON stringify it and detect circularity.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>object</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last"><p>the input object</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>a string representation of the object or 'Object (circular)'</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h4 class="name" id=".turnSquareBracketsIntoArrays"><span class="type-signature">(static) </span>turnSquareBracketsIntoArrays<span class="signature">(input, max)</span><span class="type-signature"> &rarr; {array}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line889">line 889</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Convert a string representing a JSON array, e.g. &quot;[1, 2]&quot; into an array, e.g. [&quot;1&quot;,&quot;2&quot;].
This approach overcomes the built-in JSON parsing limitations when it comes to eg. floats
missing the naught prefix, and is able to process several arrays, e.g. &quot;[1,2][3,4]&quot;.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>input</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"><p>string potentially containing JSON arrays</p></td>
</tr>
<tr>
<td class="name"><code>max</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"><p>how many matches to return, unwrap resulting array if less than two</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>an array if arrays were found, undefined otherwise</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">array</span>
</dd>
</dl>
<h4 class="name" id="~_match"><span class="type-signature">(protected, inner) </span>_match<span class="signature">(value)</span><span class="type-signature"></span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_Util.js.html">util/Util.js</a>, <a href="util_Util.js.html#line1159">line 1159</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>Create a boolean function that compares an input element to the given value.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>value</code></td>
<td class="type">
<span class="param-type">Number</span>
|
<span class="param-type">string</span>
|
<span class="param-type">object</span>
|
<span class="param-type">null</span>
</td>
<td class="description last"><p>the matching value</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>a function that compares an input element to the given value</p>
</div>
</article>
</section>
</div>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.7</a> on Mon Aug 01 2022 10:19:56 GMT+0200 (Central European Summer Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>
<script src="scripts/polyfill.js"></script>
<script src="scripts/linenumber.js"></script>
<script src="scripts/search.js" defer></script>
</body>
</html>