Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 41 Next »

ON THIS PAGE

This page describes the mapping between BrightScript and JavaScript APIs. BrightScript functionality is implemented in JavaScript using the BrightSign JavaScript API and the older BS- JavaScript objects; 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. 

BrightScript APIJavaScript EquivalentLibrary

Global Functions



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.lengthJavaScript 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, lengthtarget_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() 

Async operations are always preferable.

Node.js®
WriteAsciiFile()

fs.writeFile()

Async operations are always preferable.

Node.js®
ListDir()

fs.readDir()

Async operations are always preferable.

Node.js®
MatchFiles()

fs.readDir()

Async operations are always preferable. 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()

Async operations are always preferable.

Node.js®
DeleteDirectory()

fs.rmdir()

Async operations are always preferable.

Node.js®
CreateDirectory()

fs.mkdir()

Async operations are always preferable.

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()

Async operations are always preferable.

Node.js®
MoveFile()

fs.rename()

Async operations are always preferable.

Node.js®
MapFilenameToNative()Not applicable
strtoi()

parseInt()

strtoi() parses in base 10, whereas JavaScript supports any base.

JavaScript built-in
rnd()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.PIJavaScript 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 or WebReflection/flatted#flatted 

JavaScript built-in

Core Objects



roArray

Not applicable JavaScript built-in

roAssociativeArray

Not applicable JavaScript built-in

roBoolean

Not applicable JavaScript built-in

roByteArray

Blob()

Note that JavaScript now has typed arrays (for example, Uint8Array) . 

File API

roDouble

Not applicable JavaScript built-in

roFunction

Not applicable JavaScript built-in

roInt, roFloat, roString

Not applicable JavaScript built-in
roListUse JavaScript built-in functionJavaScript built-in
roMessagePortNot applicable JavaScript built-in
roRegexRegExp()JavaScript built-in
roXMLElementDOMParser()JavaScript built-in
roXMLListDOMParser()JavaScript built-in

Presentation Objects



roAudioEventMxNot available
roAudioOutputaudiooutput
roAudioPlayerUse html audio tag
roCanvasWidgetNot applicable 
roClockWidgetNot applicable 
roHdmiInputChangedvideoinput.VideoInputConfiguration.hdmiinputchangedBrightSign JavaScript API
roHdmiOutputChangedvideooutput.VideoOutputConfiguration.hotplugeventBrightSign JavaScript API
roHTMLWidgethtmlwidget
roImageBufferNot applicable
roImagePlayer<img> tag in HTML
roImageWidget<img> tag in HTML
roRectangleNot applicable 
roStreamQueueNot available
roTextFieldNot applicable 
roTextWidgetNot applicable 
roTouchEventTouchEvent()Web API
roTouchScreenNot 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
SetMouseRotation()Not applicable
EnableSerialTouchscreen()Not available
SetSerialTouchscreenConfiguration()Not available
GetDiagnosticInfo()pointerCalibration.getDiagnosticInfoHTML()BrightSign JavaScript API
StartCalibration()pointerCalibration.startCalibration()BrightSign JavaScript API
GetCalibrationStatus()pointerCalibration.getCalibrationStatus()BrightSign JavaScript API
ClearStoredCalibration()pointerCalibration.clearStoredCalibration()BrightSign JavaScript API
StartEventLogging()pointerCalibration.startEventLogging()BrightSign JavaScript API
StopEventLogging()pointerCalibration.stopEventLogging()BrightSign JavaScript API
ClearEventLogs()Not applicable (no information on the log)
SetCalibrationRanges()pointerCalibration.setCalibrationRanges()BrightSign JavaScript API
roVIdeoInputMediaDevices.getUserMedia()Web API
roVideoModevideomodeconfiguration
SetMode()videomodeconfiguration.setMode()BrightSign JavaScript API
SetModeForNextBoot()Not applicable (use @brightsign/videomodeconfiguration SetMode())
GetModeForNextBoot()Not applicable (use @brightsign/videomodeconfiguration getActiveMode())
GetBestMode()videomodeconfiguration.getBestMode()BrightSign JavaScript API
GetMode()videomodeconfiguration.getActiveMode()BrightSign JavaScript API
GetActiveMode()videomodeconfiguration.getActiveMode()BrightSign JavaScript API
GetAvailableModes()videomodeconfiguration.getAvailableModes()BrightSign JavaScript API
GetConfiguredMode()videomodeconfiguration.getConfiguredMode()BrightSign JavaScript API
GetFPSvideomodeconfiguration.getActiveMode()BrightSign JavaScript API
SetDecoderMode()decoderconfiguration.applyConfig()BrightSign JavaScript API
GetDecoderModes()decoderconfiguration.getConfig()BrightSign JavaScript API
Set3DMode()

videooutput.set3dMode()      


Screenshot()screenshot.syncCapture()/asyncCapture()BrightSign JavaScript API
GetResX()videomodeconfiguration.Mode.graphicsPlaneWidthBrightSign JavaScript API
GetRexY()videomodeconfiguration.Mode.graphicsPlaneHeightBrightSign JavaScript API
GetVideoResX()videomodeconfiguration.Mode.widthBrightSign JavaScript API
GetVideoResY()videomodeconfiguration.Mode.heightBrightSign JavaScript API
GetOutputResX()videooutput.Size.widthBrightSign JavaScript API
GetOutputResY()videooutput.Size.heightBrightSign JavaScript API
GetSafeX()BSVideoMode.safeXBS- JavaScript objects
GetSafeY()BSVideoMode.safeY

BS- JavaScript objects

SafeWidth()BSVideoMode.safeWidthBS- JavaScript objects
SafeHeight()BSVideoMOde.safeHeightBS- JavaScript objects
SetGraphicsZOrderNot applicable 
PauseGraphics()compositor.pause()BrightSign JavaScript API
ResumeGraphics()compositor.resume()BrightSign JavaScript API
SetImageSizeThreshold()system.setImageSizeThreshold()BrightSign JavaScript API
AdjustGraphicsColor()videooutput.adjustGraphicColor()
ConfigureHdmiInput()videoinput.ApplyConfig()BrightSign JavaScript API
SetHdmiMetadata()Not available and possibly not applicable
GetHdmiOutputStatus()videooutput.getOutputStatus()BrightSign JavaScript API
GetHdmiInputStatus()videoinput.getStatus()BrightSign JavaScript API
GetCompositorCrc()compositor.getCrc()BrightSign JavaScript API
GetTxHdcpStatus()videooutput.getTxHdcpStatus()BrightSign JavaScript API
ForceHdcpOn()videooutput.forceHdcpOn()BrightSign JavaScript API
DisableHdcpRepeater()videooutput.DisableHdcpRepeater()
SetBackgroundColor()videooutput.setBackgroundColor()BrightSign JavaScript API
SetPowerSaveMode()videooutput.SetPowerSaveMode()BrightSign JavaScript API
IsAttached()videooutput.isAttached()BrightSign JavaScript API
HdmiAudioDisable()videooutput.disableAudio()BrightSign JavaScript API
SetMultiscreenBezel()videooutput.setMultiscreenBezel()BrightSign JavaScript API
SaveEdids()

videooutput.getEdid() returns EDID information as a hex-encoded string.


GetEdidIdentity()videooutput.getEdidIdentity()BrightSign JavaScript API
SetMpcdi()videooutput.setMpcdi()
SetSyncDomain()videooutput.setSyncDomain()BrightSign JavaScript API
roVideoPlayerUse <video> elements with BrightSign properties

File Objects

Use Node.js File API

Hashing and Storage Objects



roBlockCipherNode.js Crypto API
roBrightPackageNode.js Zlib API
roDiskErrorEventNot available
roDiskMonitorNot available
roHashGeneratorNode.js Crypto API
roPassKeyNode.js Crypto API
roRegistryregistry
GetSectionList()registry.read()BrightSign JavaScript API
Delete()registry.write()BrightSign JavaScript API
Flush()Not applicable; registry writes are flushed implicitly
roRegistrySectionregistry
Read()registry.read()BrightSign JavaScript API
Write()registry.write()BrightSign JavaScript API
Delete()registry.write()BrightSign JavaScript API
Exists()Not applicable (Use read followed by a truthy check on the registry key)
Flush()Not applicable; registry writes are flushed implicitly
GetKeyList()Not applicable (Use read followed by Object.keys())
roSqliteDatabaseUse IndexedDB
roSqliteStatementUse IndexedDB
roStorageAttachednode.js fs.watch()
roStorageDetachednode.js fs.watch()
roStorageHotplugnode.js fs.watch()
roStorageInfofilesysteminfo and storageinfo
GetBytesPerBlock()filesysteminfo.getStatistics()BrightSign JavaScript API
GetSizeInMegabytes()filesysteminfo.getStatistics()BrightSign JavaScript API
GetUsedInMegabytes()node.js fs.stat()
GetFreeInMegabytes()filesysteminfo.getStatistics()BrightSign JavaScript API
GetFileSystemType()filesysteminfo.getFileSystemType()BrightSign JavaScript API
GetStorageCardInfo()storageinfo.getStorageCardInfo()BrightSign JavaScript API
roVirtualMemoryNot available

Content Management Objects



roAssetCollectionNot available
roAssetFetcherassetpoolfetcherBrightSign JavaScript API
roAssetPoolassetpoolBrightSign JavaScript API
roAssetPoolFiles

assetpoolfiles


roAssetRealizerassetrealizerBrightSign JavaScript API
roSyncSpecNot applicable

Networking Objects



roDatagramReceiverNode.js Dgram API
roDatagramSenderNode.js Dgram API
roDatagramSocketNode.js Dgram API
roHttpServerNode.js
roKeyStorekeystoreBrightSign JavaScript API
roMediaServernode-media-server 
roMediaStreamerNot available
roMimeStreamNot applicable
roNetworkAdvertisementNot applicable (use node.js)
roNetworkConfigurationnetworkconfiguration
Apply()networkconfiguration.applyConfig()BrightSign JavaScript API
SetupDWS()dwsconfigurationBrightSign JavaScript API
EnableLEDs()networkconfiguration.enableLeds()BrightSign JavaScript API
SetClientIdentifier()networkconfiguration.NetworkInterfaceConfig.clientIdentifierBrightSign JavaScript API
GetClientIdentifier()networkconfiguration.NetworkInterfaceConfig.clientIdentifierBrightSign JavaScript API
SetLoginPassword()hostconfiguration.HostConfigWritable.loginPasswordBrightSign JavaScript API
SetObfuscatedLoginPassword()hostconfiguration.HostConfigWritable.ObfuscatedLoginPasswordBrightSign JavaScript API
SetInboundShaperRate()networkconfiguration.NetworkInterfaceConfig.inboundShaperRateBrightSign JavaScript API
SetMTU()networkconfiguration.NetworkInterfaceConfig.mtuBrightSign JavaScript API
SetRoutingMetric()networkconfiguration.NetworkInterfaceConfig.metricBrightSign JavaScript API
SetDHCP()networkconfiguration.NetworkInterfaceConfig.ipAddressListBrightSign JavaScript API
SetEnabledProtocols()networkconfiguration.NetworkInterfaceConfig.enabledProtocolListBrightSign JavaScript API
SetIP4Address()networkconfiguration.NetworkInterfaceConfig.ipAddressListBrightSign JavaScript API
SetIP4Netmask()networkconfiguration.NetworkInterfaceConfig.ipAddressListBrightSign JavaScript API
SetIP4Broadcast()networkconfiguration.NetworkInterfaceConfig.ipAddressListBrightSign JavaScript API
SetIP4Gateway()networkconfiguration.NetworkInterfaceConfig.ipAddressListBrightSign JavaScript API
SetVlanIds()networkconfiguration.NetworkInterfaceConfig.vlanIdListBrightSign JavaScript API
SetWiFiESSID()/.GetWiFiESSID()networkconfiguration.WiFiInterfaceConfig.essIdBrightSign JavaScript API
SetWiFiPassphrase()networkconfiguration.WiFiInterfaceConfig.passphraseBrightSign JavaScript API
SetWiFiPassphraseAndObfuscate()networkconfiguration.WiFiInterfaceConfig.obfuscatedPassphraseBrightSign JavaScript API
SetWiFiAccessPointMode()networkconfiguration.WiFiInterfaceConfig.accessPointModeBrightSign JavaScript API
SetAccessPointFrequencyMHz()networkconfiguration.WiFiInterfaceConfig.accessPointFrequencyBrightSign JavaScript API
SetWiFiIdentity()networkconfiguration.WiFiInterfaceConfig.identityBrightSign JavaScript API
SetWiFiEapTlsOptions()networkconfiguration.WiFiInterfaceConfig.eapTlsOptionsBrightSign JavaScript API
SetWiFiCACertificates()networkconfiguration.WiFiInterfaceConfig.caCertificatesBrightSign JavaScript API
SetWiFiClientCertificate()networkconfiguration.WiFiInterfaceConfig.clientCertificateBrightSign JavaScript API
SetWiFiPrivateKey()networkconfiguration.WiFiInterfaceConfig.privateKeyBrightSign JavaScript API
SetWiFiSecurityMode()networkconfiguration.WiFiInterfaceConfig.securityModeBrightSign JavaScript API
ConfigureDHCPServer()networkconfiguration.NetworkInterfaceConfig.dhcpServerConfigBrightSign JavaScript API
SetForwardingPolicy()Not available
SetDNSServers()/.AddDNSServer()networkconfiguration.NetworkInterfaceConfig.dnsServerListBrightSign JavaScript API
SetTimeServer()hostconfiguration.HostConfig.timeServerListBrightSign JavaScript API
SetTimeServerIntervalSeconds()/ GetTimeServerIntervalSecons()hostconfiguration.HostConfig.timeServerIntervalBrightSign JavaScript API
SetHostName()/.GetHostName()hostconfiguration.HostConfig.hostNameBrightSign JavaScript API
SetProxy()/.GetProxy()hostconfiguration.HostConfig.proxyBrightSign JavaScript API
SetProxyBypass()/.GetProxyBypass()hostconfiguration.HostConfig.proxyBypassListBrightSign JavaScript API
GetRecoveryUrl()Not available
ResetInterfaceSettings()networkconfiguration.applyConfig()BrightSign JavaScript API
ResetHostSettings()hostconfiguration.applyConfig()BrightSign JavaScript API
GetCurrentConfig()networkconfiguration.getConfig()/hostconfiguration.getConfig()BrightSign JavaScript API
TestInterface()networkdiagnostics.testNetworkInterface()BrightSign JavaScript API
TestInternetConnectivity()networkdiagnostics.testInternetConnectivity()BrightSign JavaScript API
GetNeighborInformation()networkconfiguration.getNeighborInformation()BrightSign JavaScript API
ScanWiFi()networkconfiguration.scan()BrightSign JavaScript API
roNetworkHotplugnetworkhotplug
roNetworkAttachednetworkhotplug
roNetworkDetachednetworkhotplug
roNetworkDiscoveryNot applicable (node.js can be used instead)
roNetworkStatisticsNot applicable (See node module net-stat)
roPtphostconfiguration (see OS 8.0.94 release note)
roRssArticle/roRssParserNot applicable 
roRtspStreamUse <video> elements
roSnmpAgentnet-snmpnpm**
roStreamNot applicable
roSyncManagerBSSyncManagerBS- JavaScript objects
roTCPServer/roTCPStreamnet.socketNode.js®
roUPnPNot applicable
roUrlTransferhttpNode.js®

Input/Output Objects



roBtManagerBSBtManagerBS- JavaScript objects
roBtClientManager/roBtClientBSBtManager
roCecInterfaceBSCECTransmitter/BSCECReceiverBS- JavaScript objects
roChannelManagerobsolete
roControlPortcontrolportBS- JavaScript objects
roGpioControlPortcontrolportBS- JavaScript objects
roIRReceiverBSIRReceiverBS- JavaScript objects
roIRTransmitterBSIRTransmitterBS- JavaScript objects
roIRRemoteBSIRRemote
roKeyboardkeyboardBrightSign JavaScript API
roSequenceManagerNot applicable
roSerialPortBSSerialPortBS- JavaScript objects

System Objects



roDeviceCustomizationNot available
roDeviceInfoBSDeviceInfo
roResourceManagerNot applicable
roSystemLogNot available

Date and Time Objects



roDateTimeDateJavaScript built-in
roSystemTimesystemtimeBrightSign JavaScript API
roTimer.setTimeout()/.setInterval()Web API
roTimeSpanDateJavaScript built-in


 * substr takes parameters as (from, length).
   substring takes parameters as (from, to).
   slice takes parameters as (from, to).

** npm is a registered trademark of npm, Inc.



  • No labels