BrightScript-JavaScript Migration Guide
10 min
this page describes the mapping between brightscript and javascript apis brightscript functionality is implemented in javascript using the brightsign javascript api docid\ o2uiynvkbsyd1qxcvhvcn and the older brightscript javascript objects docid\ urrxhu7l v9ea zhy0jv3 ; brightscript apis are not ported when standard javascript libraries provide equivalent functionality if the javascript equivalent is "not available", the functionality is not currently implemented but should be in the future if the equivalent is "not applicable", the corresponding brightscript method would be meaningless in javascript or is otherwise unnecessary global functions brightscript api javascript equivalent library createobject() not applicable restartscript() not applicable restartapplication() process exit() node js® sleep() not applicable asc() string charcodeat() javascript built in chr() string fromcharcode() javascript built in len() string length javascript built in str() number tostring() javascript built in strl() number tostring() javascript built in val() number() javascript built in abs() math abs() javascript built in atn() math atan() javascript built in csng() not applicable cdbl() not applicable cint() not applicable cos() math cos() javascript built in exp() math exp() javascript built in fix() number tofixed() javascript built in int() math trunc() javascript built in log() math log() javascript built in sgn() math sign() javascript built in sgnl() math sign() javascript built in sin() math sin() javascript built in tan() math tan() javascript built in sqr() math sqrt() javascript built in left(target string, n) target string substr(0, n) javascript built in right(target string, n) target string substr(target string length n) target string substr( n) javascript built in stringi() string repeat() javascript built in mid(target string, start position, length target string substr(start position, length) javascript built in instr() string indexof() javascript built in getinterface() access object interfaces as strings wait() not applicable in javascript, unless the function is used without reference to ports, and merely to delay execution for a time, in which case, use settimeout() javascript built in readasciifile() readfilesync() node js® writeasciifile() fs writefile() node js® listdir() fs readdir() node js® matchfiles() fs readdir() additional javascript code is needed to complete matching node js® lcase() string tolowercase() javascript built in ucase() string touppercase() javascript built in deletefile() fs unlink() node js® deletedirectory() fs rmdir() node js® createdirectory() fs mkdir() node js® rebootsystem() system reboot() brightsign javascript api shutdownsystem() not available uptime() os uptime() node js® formatdrive() no exact equivalent ejectdrive() not available copyfile() fs copyfile() node js® movefile() fs rename() node js® mapfilenametonative() not applicable strtoi() parseint() strtoi() parses in base 10, whereas javascript supports any base javascript built in rnd() math random() https //developer mozilla org/en us/docs/web/javascript/reference/global objects/math/random javascript built in rungarbagecollector() not applicable getdefaultdrive() not applicable node js® setdefaultdrive() process chdir() node js® enablezonesupport() not applicable enableaudiomixer() not applicable pi() math pi javascript built in parsejson() json parse() brightscript returns invalid in the case of problematic strings, whereas javascript throws an exception javascript built in formatjson() json stringify() json stringify must be invoked with a custom replacer, for example, cyclic object value https //developer mozilla org/en us/docs/web/javascript/reference/errors/cyclic object value or webreflection/flatted#flatted https //github com/webreflection/flatted#flatted javascript built in substr takes parameters as (from, length) substring takes parameters as (from, to) slice takes parameters as (from, to) async operations are always preferable core objects brightscript api javascript equivalent library roarray not applicable javascript built in https //developer mozilla org/en us/docs/web/javascript/guide/expressions and operators roassociativearray not applicable javascript built in https //developer mozilla org/en us/docs/web/javascript/guide/expressions and operators roboolean not applicable javascript built in https //developer mozilla org/en us/docs/web/javascript/guide/expressions and operators robytearray blob() (javascript now has typed arrays https //developer mozilla org/en us/docs/web/javascript/typed arrays for example, uint8array https //developer mozilla org/en us/docs/web/javascript/reference/global objects/uint8array ) rodouble not applicable javascript built in https //developer mozilla org/en us/docs/web/javascript/guide/expressions and operators rofunction not applicable javascript built in https //developer mozilla org/en us/docs/web/javascript/guide/expressions and operators roint, rofloat, rostring not applicable javascript built in https //developer mozilla org/en us/docs/web/javascript/guide/expressions and operators rolist use javascript built in function javascript built in https //developer mozilla org/en us/docs/web/javascript/guide/expressions and operators romessageport not applicable javascript built in https //developer mozilla org/en us/docs/web/javascript/guide/expressions and operators roregex regexp() javascript built in https //developer mozilla org/en us/docs/web/javascript/guide/expressions and operators roxmlelement domparser() javascript built in https //developer mozilla org/en us/docs/web/javascript/guide/expressions and operators roxmllist domparser() javascript built in https //developer mozilla org/en us/docs/web/javascript/guide/expressions and operators presentation objects brightscript api javascript equivalent library roaudioeventmx not available roaudiooutput audiooutput docid\ lxzj2b4solxtnxkxxkob5 roaudioplayer use html audio tag rocanvaswidget not applicable roclockwidget not applicable rohdmiinputchanged videoinput videoinputconfiguration hdmiinputchanged brightsign javascript api docid\ xdorxw7wvzcnnu2 5upuy rohdmioutputchanged videooutput videooutputconfiguration hotplugevent brightsign javascript api docid\ xdorxw7wvzcnnu2 5upuy rohtmlwidget htmlwidget docid\ pmpuh3a0vr8ohjopsjwo7 roimagebuffer not applicable roimageplayer \<img> tag in html https //developer mozilla org/en us/docs/web/html/element/img roimagewidget \<img> tag in html https //developer mozilla org/en us/docs/web/html/element/img rorectangle not applicable rostreamqueue not available rotextfield not applicable rotextwidget not applicable rotouchevent touchevent() web api rotouchscreen not available setresolution() browser performs mapping addrectangle() map css cursor properties to hardware cursor addcircleregion() map css cursor properties to hardware cursor clearregions() not applicable getdevicename() not applicable setcursorposition() simulate mouse cursor events in javascript setcursorbitmap() map css cursor properties to hardware cursor enablecursor() map css cursor properties to hardware cursor enablerollover() not applicable enableregion() map css cursor properties to hardware cursor setrolloverorigin() map css cursor properties to hardware cursor ismousepresent() pointer ismousepresent() brightsign javascript api docid\ wydfi oewp1uofqjvyhhu setmouserotation() not applicable enableserialtouchscreen() not available setserialtouchscreenconfiguration() not available getdiagnosticinfo() pointercalibration getdiagnosticinfohtml() brightsign javascript api docid\ wydfi oewp1uofqjvyhhu startcalibration() pointercalibration startcalibration() brightsign javascript api docid\ wydfi oewp1uofqjvyhhu getcalibrationstatus() pointercalibration getcalibrationstatus() brightsign javascript api docid\ wydfi oewp1uofqjvyhhu clearstoredcalibration() pointercalibration clearstoredcalibration() brightsign javascript api docid\ wydfi oewp1uofqjvyhhu starteventlogging() pointercalibration starteventlogging() brightsign javascript api docid\ wydfi oewp1uofqjvyhhu stopeventlogging() pointercalibration stopeventlogging() brightsign javascript api docid\ wydfi oewp1uofqjvyhhu cleareventlogs() not applicable (no information on the log) setcalibrationranges() pointercalibration setcalibrationranges() brightsign javascript api docid\ wydfi oewp1uofqjvyhhu rovideoinput mediadevices getusermedia() web api rovideomode videomodeconfiguration docid\ uupzxkyflbsolyh8olces setmode() videomodeconfiguration setmode() brightsign javascript api docid\ qq734nqz0hcwni0unsdmp setmodefornextboot() not applicable (use @brightsign/videomodeconfiguration setmode()) getmodefornextboot() not applicable (use @brightsign/videomodeconfiguration getactivemode()) getbestmode() videomodeconfiguration getbestmode() brightsign javascript api docid\ qq734nqz0hcwni0unsdmp getmode() videomodeconfiguration getactivemode() brightsign javascript api docid\ qq734nqz0hcwni0unsdmp getactivemode() videomodeconfiguration getactivemode() brightsign javascript api docid\ qq734nqz0hcwni0unsdmp getavailablemodes() videomodeconfiguration getavailablemodes() brightsign javascript api docid\ qq734nqz0hcwni0unsdmp getconfiguredmode() videomodeconfiguration getconfiguredmode() brightsign javascript api docid\ qq734nqz0hcwni0unsdmp getfps videomodeconfiguration getactivemode() brightsign javascript api docid\ qq734nqz0hcwni0unsdmp setdecodermode() decoderconfiguration applyconfig() brightsign javascript api docid\ qq734nqz0hcwni0unsdmp getdecodermodes() decoderconfiguration getconfig() brightsign javascript api docid\ qq734nqz0hcwni0unsdmp set3dmode() videooutput set3dmode() screenshot() screenshot synccapture()/asynccapture() brightsign javascript api docid\ qq734nqz0hcwni0unsdmp getresx() videomodeconfiguration mode graphicsplanewidth brightsign javascript api docid\ qq734nqz0hcwni0unsdmp getrexy() videomodeconfiguration mode graphicsplaneheight brightsign javascript api docid\ qq734nqz0hcwni0unsdmp getvideoresx() videomodeconfiguration mode width brightsign javascript api docid\ qq734nqz0hcwni0unsdmp getvideoresy() videomodeconfiguration mode height brightsign javascript api docid\ qq734nqz0hcwni0unsdmp getoutputresx() videooutput size width brightsign javascript api docid\ qq734nqz0hcwni0unsdmp getoutputresy() videooutput size height brightsign javascript api docid\ qq734nqz0hcwni0unsdmp getsafex() bsvideomode safex bs javascript objects getsafey() bsvideomode safey bs javascript objects safewidth() bsvideomode safewidth bs javascript objects safeheight() bsvideomode safeheight bs javascript objects setgraphicszorder not applicable pausegraphics() compositor pause() brightsign javascript api docid\ qq734nqz0hcwni0unsdmp resumegraphics() compositor resume() brightsign javascript api docid\ qq734nqz0hcwni0unsdmp setimagesizethreshold() system setimagesizethreshold() brightsign javascript api docid\ qq734nqz0hcwni0unsdmp adjustgraphicscolor() videooutput adjustgraphiccolor() configurehdmiinput() videoinput applyconfig() brightsign javascript api docid\ qq734nqz0hcwni0unsdmp sethdmimetadata() not available and possibly not applicable gethdmioutputstatus() videooutput getoutputstatus() brightsign javascript api docid\ qq734nqz0hcwni0unsdmp gethdmiinputstatus() videoinput getstatus() brightsign javascript api docid\ qq734nqz0hcwni0unsdmp getcompositorcrc() compositor getcrc() brightsign javascript api docid\ qq734nqz0hcwni0unsdmp gettxhdcpstatus() videooutput gettxhdcpstatus() brightsign javascript api docid\ qq734nqz0hcwni0unsdmp forcehdcpon() videooutput forcehdcpon() brightsign javascript api docid\ qq734nqz0hcwni0unsdmp disablehdcprepeater() videooutput disablehdcprepeater() setbackgroundcolor() videooutput setbackgroundcolor() brightsign javascript api docid\ qq734nqz0hcwni0unsdmp setpowersavemode() videooutput setpowersavemode() brightsign javascript api docid\ qq734nqz0hcwni0unsdmp isattached() videooutput isattached() brightsign javascript api docid\ qq734nqz0hcwni0unsdmp hdmiaudiodisable() videooutput disableaudio() brightsign javascript api docid\ qq734nqz0hcwni0unsdmp setmultiscreenbezel() videooutput setmultiscreenbezel() brightsign javascript api docid\ qq734nqz0hcwni0unsdmp saveedids() videooutput getedid() returns edid information as a hex encoded string getedididentity() videooutput getedididentity() brightsign javascript api docid\ qq734nqz0hcwni0unsdmp setmpcdi() videooutput setmpcdi() setsyncdomain() videooutput setsyncdomain() brightsign javascript api docid\ qq734nqz0hcwni0unsdmp rovideoplayer use \<video> elements with brightsign properties docid\ e6ujleh69q0jmmv8kytrp file objects use the node js file api hashing and storage objects brightscript api javascript equivalent library roblockcipher node js crypto api robrightpackage node js zlib api rodiskerrorevent not available rodiskmonitor not available rohashgenerator node js crypto api ropasskey node js crypto api roregistry registry docid\ txwoombd2 u12dfegx7ga getsectionlist() registry read() brightsign javascript api docid\ ytpsfntswyfmxx8pcqjlf delete() registry write() brightsign javascript api docid\ ytpsfntswyfmxx8pcqjlf flush() not applicable; registry writes are flushed implicitly roregistrysection registry docid\ txwoombd2 u12dfegx7ga read() registry read() brightsign javascript api docid\ ffm73tjd bthw4 p 0jvg write() registry write() brightsign javascript api docid\ ffm73tjd bthw4 p 0jvg exists() not applicable (use read followed by a truthy check on the registry key) getkeylist() not applicable (use read followed by object keys()) rosqlitedatabase use indexeddb rosqlitestatement use indexeddb rostorageattached node js fs watch() rostoragedetached node js fs watch() rostoragehotplug node js fs watch() rostorageinfo filesysteminfo docid\ qulnl7zrhwc5fgokcgai7 and storageinfo docid\ roz3o77euxtyzvj dspin getbytesperblock() filesysteminfo getstatistics() brightsign javascript api docid\ bczooenmoifnrbeny6zki getsizeinmegabytes() filesysteminfo getstatistics() brightsign javascript api docid\ bczooenmoifnrbeny6zki getusedinmegabytes() node js fs stat() getfreeinmegabytes() filesysteminfo getstatistics() brightsign javascript api docid\ bczooenmoifnrbeny6zki getfilesystemtype() filesysteminfo getfilesystemtype() brightscript javascript api docid\ bczooenmoifnrbeny6zki getstoragecardinfo() storageinfo getstoragecardinfo() brightscript javascript api docid\ bczooenmoifnrbeny6zki rovirtualmemory not available content management objects brightscript api javascript equivalent library roassetcollection not available roassetfetcher assetpoolfetcher docid\ hg03eush xkkpfofwdgcz brightsign javascript api docid 1aqogvxana1wfjwf8thmd roassetpool assetpool docid\ ny8nhrk1 740wpryl p8d brightsign javascript api docid\ dz9zc0ke6jlqnibunuq0n roassetpoolfiles assetpoolfiles docid\ nhocamfrj0avahj vearr roassetrealizer assetrealizer docid\ xnl0us14gwg7euiz2xsdm brightsign javascript api docid\ yov qcutlenarbm fzmfv rosyncspec not applicable networking objects brightscript api javascript equivalent library rodatagramreceiver node js dgram api rodatagramsender node js dgram api rodatagramsocket node js dgram api rohttpserver node js rokeystore keystore docid 6alp0aixrzlhv4cbkebvz brightscript javascript api docid\ ghsznw9es8temurqxq du romediaserver node media server romediastreamer not available romimestream not applicable ronetworkadvertisement not applicable (use node js) ronetworkconfiguration networkconfiguration docid 6ms7rdjwwhp21clmedrwv apply() networkconfiguration applyconfig() brightscript javascript api docid\ u6zceyqddlz9xdakttmjs setupdws() dwsconfiguration brightscript javascript api docid\ u6zceyqddlz9xdakttmjs enableleds() networkconfiguration enableleds() brightscript javascript api docid\ u6zceyqddlz9xdakttmjs setclientidentifier() networkconfiguration networkinterfaceconfig clientidentifier brightscript javascript api docid\ u6zceyqddlz9xdakttmjs getclientidentifier() networkconfiguration networkinterfaceconfig clientidentifier brightscript javascript api docid\ u6zceyqddlz9xdakttmjs setloginpassword() hostconfiguration hostconfigwritable loginpassword brightscript javascript api docid\ u6zceyqddlz9xdakttmjs setobfuscatedloginpassword() hostconfiguration hostconfigwritable obfuscatedloginpassword brightscript javascript api docid\ u6zceyqddlz9xdakttmjs setinboundshaperrate() networkconfiguration networkinterfaceconfig inboundshaperrate brightscript javascript api docid\ u6zceyqddlz9xdakttmjs setmtu() networkconfiguration networkinterfaceconfig mtu brightscript javascript api docid\ u6zceyqddlz9xdakttmjs setroutingmetric() networkconfiguration networkinterfaceconfig metric brightscript javascript api docid\ u6zceyqddlz9xdakttmjs setdhcp() networkconfiguration networkinterfaceconfig ipaddresslist brightscript javascript api docid\ u6zceyqddlz9xdakttmjs setenabledprotocols() networkconfiguration networkinterfaceconfig enabledprotocollist brightscript javascript api docid\ u6zceyqddlz9xdakttmjs setip4address() networkconfiguration networkinterfaceconfig ipaddresslist brightscript javascript api docid\ u6zceyqddlz9xdakttmjs setip4netmask() networkconfiguration networkinterfaceconfig ipaddresslist brightscript javascript api docid\ u6zceyqddlz9xdakttmjs setip4broadcast() networkconfiguration networkinterfaceconfig ipaddresslist brightscript javascript api docid\ u6zceyqddlz9xdakttmjs setip4gateway() networkconfiguration networkinterfaceconfig ipaddresslist brightscript javascript api docid\ u6zceyqddlz9xdakttmjs setvlanids() networkconfiguration networkinterfaceconfig vlanidlist brightscript javascript api docid\ u6zceyqddlz9xdakttmjs setwifiessid()/ getwifiessid() networkconfiguration wifiinterfaceconfig essid brightscript javascript api docid\ u6zceyqddlz9xdakttmjs setwifipassphrase() networkconfiguration wifiinterfaceconfig passphrase brightscript javascript api docid\ u6zceyqddlz9xdakttmjs setwifipassphraseandobfuscate() networkconfiguration wifiinterfaceconfig obfuscatedpassphrase brightscript javascript api docid\ u6zceyqddlz9xdakttmjs setwifiaccesspointmode() networkconfiguration wifiinterfaceconfig accesspointmode brightscript javascript api docid\ u6zceyqddlz9xdakttmjs setaccesspointfrequencymhz() networkconfiguration wifiinterfaceconfig accesspointfrequency brightscript javascript api docid\ u6zceyqddlz9xdakttmjs setwifiidentity() networkconfiguration wifiinterfaceconfig identity brightscript javascript api docid\ u6zceyqddlz9xdakttmjs setwifieaptlsoptions() networkconfiguration wifiinterfaceconfig eaptlsoptions brightscript javascript api docid\ u6zceyqddlz9xdakttmjs setwificacertificates() networkconfiguration wifiinterfaceconfig cacertificates brightscript javascript api docid\ u6zceyqddlz9xdakttmjs setwificlientcertificate() networkconfiguration wifiinterfaceconfig clientcertificate brightscript javascript api docid\ u6zceyqddlz9xdakttmjs setwifiprivatekey() networkconfiguration wifiinterfaceconfig privatekey brightscript javascript api docid\ u6zceyqddlz9xdakttmjs setwifisecuritymode() networkconfiguration wifiinterfaceconfig securitymode brightscript javascript api docid\ u6zceyqddlz9xdakttmjs configuredhcpserver() networkconfiguration networkinterfaceconfig dhcpserverconfig brightscript javascript api docid\ u6zceyqddlz9xdakttmjs setforwardingpolicy() not available setdnsservers()/ adddnsserver() networkconfiguration networkinterfaceconfig dnsserverlist brightscript javascript api docid\ u6zceyqddlz9xdakttmjs settimeserver() hostconfiguration hostconfig timeserverlist brightscript javascript api docid\ u6zceyqddlz9xdakttmjs settimeserverintervalseconds()/ gettimeserverintervalsecons() hostconfiguration hostconfig timeserverinterval brightscript javascript api docid\ u6zceyqddlz9xdakttmjs sethostname()/ gethostname() hostconfiguration hostconfig hostname brightscript javascript api docid\ u6zceyqddlz9xdakttmjs setproxy()/ getproxy() hostconfiguration hostconfig proxy brightscript javascript api docid\ u6zceyqddlz9xdakttmjs setproxybypass()/ getproxybypass() hostconfiguration hostconfig proxybypasslist brightscript javascript api docid\ u6zceyqddlz9xdakttmjs getrecoveryurl() not available resetinterfacesettings() networkconfiguration applyconfig() brightscript javascript api docid\ u6zceyqddlz9xdakttmjs resethostsettings() hostconfiguration applyconfig() brightscript javascript api docid\ u6zceyqddlz9xdakttmjs getcurrentconfig() networkconfiguration getconfig()/hostconfiguration getconfig() brightscript javascript api docid\ u6zceyqddlz9xdakttmjs testinterface() networkdiagnostics testnetworkinterface() brightscript javascript api docid\ u6zceyqddlz9xdakttmjs testinternetconnectivity() networkdiagnostics testinternetconnectivity() brightscript javascript api docid\ u6zceyqddlz9xdakttmjs getneighborinformation() networkconfiguration getneighborinformation() brightscript javascript api docid\ u6zceyqddlz9xdakttmjs scanwifi() networkconfiguration scan() brightscript javascript api docid\ u6zceyqddlz9xdakttmjs ronetworkhotplug networkhotplug docid\ neizljqnwcice75ocwkol ronetworkattached networkhotplug docid\ neizljqnwcice75ocwkol ronetworkdetached networkhotplug docid\ neizljqnwcice75ocwkol ronetworkdiscovery not applicable (node js can be used instead) ronetworkstatistics not applicable (see node module net stat) roptp hostconfiguration docid\ p1dkloqhlm9wxsswmpeek (see os 8 0 94 release note) rorssarticle/rorssparser not applicable rortspstream use \<video> elements rosnmpagent net snmp npm rostream not applicable rosyncmanager bssyncmanager docid\ dqnx2ot2tdkxynmrglncp bs javascript objects rotcpserver/rotcpstream net socket node js® roupnp not applicable rourltransfer http node js® npm is a registered trademark of npm, inc input/output objects brightscript api javascript equivalent library robtmanager bsbtmanager docid\ cf7q7xsa9drtcq3btxv a bs javascript objects robtclientmanager/robtclient bsbtmanager docid\ cf7q7xsa9drtcq3btxv a rocecinterface cec docid\ sgfokqfxwmjxxofs13htk rochannelmanager obsolete rocontrolport controlport docid\ n8yocsdagogqcp1oyuolw bs javascript objects rogpiocontrolport controlport docid\ n8yocsdagogqcp1oyuolw bs javascript objects roirreceiver bsirreceiver docid\ w5oqmftxhlg8lwiswtg7r bs javascript objects roirtransmitter bsirtransmitter docid\ og4yl3pefza5nkgkbgblv bs javascript objects roirremote bsirremote rokeyboard keyboard docid\ mnjv4rn7rm 2fslsjtqgc brightscript javascript api docid\ vnjf6gns75 lmizet3b1y rosequencemanager not applicable roserialport bsserialport docid\ zmqun8zm06aosrid6esfb bs javascript objects system objects brightscript api javascript equivalent library rodevicecustomization not available rodeviceinfo bsdeviceinfo docid\ s5s40p5kdirwx7eujzsba roresourcemanager not applicable rosystemlog not available date and time objects brightscript api javascript equivalent library rodatetime date javascript built in rosystemtime systemtime docid\ pwlrn rjihdhgwl2tbwc0 brightscript javascript api docid\ hwr0zojgtzxxnuhdlhlf9 rotimer settimeout()/ setinterval() web api rotimespan date javascript built in