npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

iracing-sdk-js

v1.3.0

Published

iRacing SDK implementation for Node.js

Downloads

11

Readme

iracing-sdk-js

(Another) Unofficial iRacing SDK implementation for Node.js.

npm version

iracing-sdk-js provides data access (live telemetry and session info) and most of the available commands. You can find some usage examples in the examples directory, and there are some data samples too.

Installing

Make sure you are running Node.js v21 x64 or later. (Currently requires Node 21 for latest node test runner implementation, but should work with Node 20 too.)

npm install --save iracing-sdk-js

yarn add iracing-sdk-js --save

API documentation

irsdk

irsdk.init([opts]) ⇒ iracing

Initialize JsIrSdk, can be done once before using getInstance first time.

Kind: static method of irsdk
Returns: iracing - Running instance of JsIrSdk

| Param | Type | Default | Description | | --- | --- | --- | --- | | [opts] | Object | | Options | | [opts.telemetryUpdateInterval] | Integer | 0 | Telemetry update interval, milliseconds | | [opts.sessionInfoUpdateInterval] | Integer | 0 | SessionInfo update interval, milliseconds | | [opts.sessionInfoParser] | sessionInfoParser | | Custom parser for session info |

const irsdk = require('iracing-sdk-js')
// look for telemetry updates only once per 100 ms
const iracing = irsdk.init({telemetryUpdateInterval: 100})

irsdk.getInstance() ⇒ iracing

Get initialized instance of JsIrSdk

Kind: static method of irsdk
Returns: iracing - Running instance of JsIrSdk

const irsdk = require('iracing-sdk-js')
const iracing = irsdk.getInstance()

iracing ⇐ events.EventEmitter

JsIrSdk is javascript implementation of iRacing SDK.

Don't use constructor directly, use getInstance.

Kind: global class
Extends: events.EventEmitter
Emits: Connected, Disconnected, Telemetry, TelemetryDescription, SessionInfo
See: EventEmitter API

iracing.telemetry

Latest telemetry, may be null or undefined

Kind: instance property of iracing

iracing.telemetryDescription

Latest telemetry, may be null or undefined

Kind: instance property of iracing

iracing.sessionInfo

Latest telemetry, may be null or undefined

Kind: instance property of iracing

iracing.Consts : IrSdkConsts

iRacing SDK related constants

Kind: instance property of iracing

iracing.camControls : Object

Camera controls

Kind: instance property of iracing

iracing.playbackControls : Object

Replay and playback controls

Kind: instance property of iracing

iracing.execCmd(msgId, [arg1], [arg2], [arg3])

Execute any of available commands, excl. FFB command

Kind: instance method of iracing

| Param | Type | Description | | --- | --- | --- | | msgId | Integer | Message id | | [arg1] | Integer | 1st argument | | [arg2] | Integer | 2nd argument | | [arg3] | Integer | 3rd argument |

iracing.reloadTextures()

Reload all car textures

Kind: instance method of iracing

iracing.reloadTextures() // reload all paints

iracing.reloadTexture(carIdx)

Reload car's texture

Kind: instance method of iracing

| Param | Type | Description | | --- | --- | --- | | carIdx | Integer | car to reload |

iracing.reloadTexture(1) // reload paint of carIdx=1

iracing.execChatCmd(cmd, [arg])

Execute chat command

Kind: instance method of iracing

| Param | Type | Description | | --- | --- | --- | | cmd | ChatCommand | | | [arg] | Integer | Command argument, if needed |

iracing.execChatCmd('cancel') // close chat window

iracing.execChatMacro(num)

Execute chat macro

Kind: instance method of iracing

| Param | Type | Description | | --- | --- | --- | | num | Integer | Macro's number (0-15) |

iracing.execChatMacro(1) // macro 1

iracing.execPitCmd(cmd, [arg])

Execute pit command

Kind: instance method of iracing

| Param | Type | Description | | --- | --- | --- | | cmd | PitCommand | | | [arg] | Integer | Command argument, if needed |

// full tank, no tires, no tear off
iracing.execPitCmd('clear')
iracing.execPitCmd('fuel', 999) // 999 liters
iracing.execPitCmd('lf') // new left front
iracing.execPitCmd('lr', 200) // new left rear, 200 kPa

iracing.execTelemetryCmd(cmd)

Control telemetry logging (ibt file)

Kind: instance method of iracing

| Param | Type | Description | | --- | --- | --- | | cmd | TelemCommand | Command: start/stop/restart |

iracing.execTelemetryCmd('restart')

"TelemetryDescription"

Telemetry description, contains description of available telemetry values

Kind: event emitted by iracing

iracing.on('TelemetryDescription', function (data) {
  console.log(evt)
})

"Telemetry"

Telemetry update

Kind: event emitted by iracing

iracing.on('Telemetry', function (evt) {
  console.log(evt)
})

"SessionInfo"

SessionInfo update

Kind: event emitted by iracing

iracing.on('SessionInfo', function (evt) {
  console.log(evt)
})

"update"

any update event

Kind: event emitted by iracing

iracing.on('update', function (evt) {
  console.log(evt)
})

"Connected"

iRacing, sim, is started

Kind: event emitted by iracing

iracing.on('Connected', function (evt) {
  console.log(evt)
})

"Disconnected"

iRacing, sim, was closed

Kind: event emitted by iracing

iracing.on('Disconnected', function (evt) {
  console.log(evt)
})

iracing~sessionInfoParser ⇒ Object

Parser for SessionInfo YAML

Kind: inner typedef of iracing
Returns: Object - parsed session info

| Param | Type | Description | | --- | --- | --- | | sessionInfo | String | SessionInfo YAML |

IrSdkConsts

IrSdkConsts, iRacing SDK constants/enums.

Kind: global constant

var IrSdkConsts = require('node-irsdk').getInstance().Consts

IrSdkConsts.BroadcastMsg

Available command messages.

Kind: static enum of IrSdkConsts
Properties

| Name | Default | Description | | --- | --- | --- | | CamSwitchPos | 0 | Switch cam, args: car position, group, camera | | CamSwitchNum | 1 | Switch cam, args, driver #, group, camera | | CamSetState | 2 | Set cam state, args: CameraState, unused, unused | | ReplaySetPlaySpeed | 3 | Set replay speed, args: speed, slowMotion, unused | | ReplaySetPlayPosition | 4 | Jump to frame, args: RpyPosMode, Frame Number (high, low) | | ReplaySearch | 5 | Search things from replay, args: RpySrchMode, unused, unused | | ReplaySetState | 6 | Set replay state, args: RpyStateMode, unused, unused | | ReloadTextures | 7 | Reload textures, args: ReloadTexturesMode, carIdx, unused | | ChatComand | 8 | Chat commands, args: ChatCommand, subCommand, unused | | PitCommand | 9 | Pit commands, args: PitCommand, parameter | | TelemCommand | 10 | Disk telemetry commands, args: TelemCommand, unused, unused | | FFBCommand | 11 | not supported by node-irsdk*: Change FFB settings, args: FFBCommandMode, value (float, high, low) | | ReplaySearchSessionTime | 12 | Search by timestamp, args: sessionNum, sessionTimeMS (high, low) |

IrSdkConsts.CameraState

Camera state Camera state is bitfield; use these values to compose a new state.

Kind: static enum of IrSdkConsts
Properties

| Name | Default | Description | | --- | --- | --- | | IsSessionScreen | 1 | Is driver out of the car | | IsScenicActive | 2 | The scenic camera is active (no focus car) | | CamToolActive | 4 | Activate camera tool | | UIHidden | 8 | Hide UI | | UseAutoShotSelection | 16 | Enable auto shot selection | | UseTemporaryEdits | 32 | Enable temporary edits | | UseKeyAcceleration | 64 | Enable key acceleration | | UseKey10xAcceleration | 128 | Enable 10x key acceleration | | UseMouseAimMode | 256 | Enable mouse aim |

IrSdkConsts.RpyPosMode

Kind: static enum of IrSdkConsts
Properties

| Name | Default | Description | | --- | --- | --- | | Begin | 0 | Frame number is relative to beginning | | Current | 1 | Frame number is relative to current frame | | End | 2 | Frame number is relative to end |

IrSdkConsts.RpySrchMode

Kind: static enum of IrSdkConsts
Properties

| Name | Default | | --- | --- | | ToStart | 0 | | ToEnd | 1 | | PrevSession | 2 | | NextSession | 3 | | PrevLap | 4 | | NextLap | 5 | | PrevFrame | 6 | | NextFrame | 7 | | PrevIncident | 8 | | NextIncident | 9 |

IrSdkConsts.RpyStateMode

Kind: static enum of IrSdkConsts
Properties

| Name | Default | Description | | --- | --- | --- | | EraseTape | 0 | Clear any data in the replay tape (works only if replay spooling disabled) |

IrSdkConsts.ReloadTexturesMode

Kind: static enum of IrSdkConsts
Properties

| Name | Default | | --- | --- | | All | 0 | | CarIdx | 1 |

IrSdkConsts.ChatCommand

Kind: static enum of IrSdkConsts
Properties

| Name | Default | Description | | --- | --- | --- | | Macro | 0 | Macro, give macro num (0-15) as argument | | BeginChat | 1 | Open up a new chat window | | Reply | 2 | Reply to last private chat | | Cancel | 3 | Close chat window |

IrSdkConsts.PitCommand

Kind: static enum of IrSdkConsts
Properties

| Name | Default | Description | | --- | --- | --- | | Clear | 0 | Clear all pit checkboxes | | WS | 1 | Clean the winshield, using one tear off | | Fuel | 2 | Request fuel, optional argument: liters | | LF | 3 | Request new left front, optional argument: pressure in kPa | | RF | 4 | Request new right front, optional argument: pressure in kPa | | LR | 5 | Request new left rear, optional argument: pressure in kPa | | RR | 6 | Request new right rear, optional argument: pressure in kPa | | ClearTires | 7 | Clear tire pit checkboxes | | FR | 8 | Request a fast repair | | ClearWS | 9 | Disable clear windshield | | ClearFR | 10 | Disable fast repair | | ClearFuel | 11 | Disable refueling |

IrSdkConsts.TelemCommand

Kind: static enum of IrSdkConsts
Properties

| Name | Default | Description | | --- | --- | --- | | Stop | 0 | Turn telemetry recording off | | Start | 1 | Turn telemetry recording on | | Restart | 2 | Write current file to disk and start a new one |

IrSdkConsts.CamFocusAt

When switching camera, these can be used instead of car number / position

Kind: static enum of IrSdkConsts
Properties

| Name | Default | Description | | --- | --- | --- | | Incident | -3 | | | Leader | -2 | | | Exciting | -1 | | | Driver | 0 | Use car number / position instead of this |

setState(state)

Change camera tool state

Kind: global function

| Param | Type | Description | | --- | --- | --- | | state | CameraState | new state |

// hide UI and enable mouse aim
var States = iracing.Consts.CameraState
var state = States.CamToolActive | States.UIHidden | States.UseMouseAimMode
iracing.camControls.setState(state)

switchToCar(carNum, [camGroupNum], [camNum])

Switch camera, focus on car

Kind: global function

| Param | Type | Description | | --- | --- | --- | | carNum | Integer | String | CamFocusAt | Car to focus on | | [camGroupNum] | Integer | Select camera group | | [camNum] | Integer | Select camera |

// show car #2
iracing.camControls.switchToCar(2)
      
// show car #02
iracing.camControls.switchToCar('02')
      
// show leader
iracing.camControls.switchToCar('leader')
      
// show car #2 using cam group 3
iracing.camControls.switchToCar(2, 3)

switchToPos(position, [camGroupNum], [camNum])

Switch camera, focus on position

Kind: global function

| Param | Type | Description | | --- | --- | --- | | position | Integer | CamFocusAt | Position to focus on | | [camGroupNum] | Integer | Select camera group | | [camNum] | Integer | Select camera |

iracing.camControls.switchToPos(2) // show P2

play()

Play replay

Kind: global function

iracing.playbackControls.play()

pause()

Pause replay

Kind: global function

iracing.playbackControls.pause()

fastForward([speed])

fast-forward replay

Kind: global function

| Param | Type | Default | Description | | --- | --- | --- | --- | | [speed] | Integer | 2 | FF speed, something between 2-16 works |

iracing.playbackControls.fastForward() // double speed FF

rewind([speed])

rewind replay

Kind: global function

| Param | Type | Default | Description | | --- | --- | --- | --- | | [speed] | Integer | 2 | RW speed, something between 2-16 works |

iracing.playbackControls.rewind() // double speed RW

slowForward([divider])

slow-forward replay, slow motion

Kind: global function

| Param | Type | Default | Description | | --- | --- | --- | --- | | [divider] | Integer | 2 | divider of speed, something between 2-17 works |

iracing.playbackControls.slowForward(2) // half speed

slowBackward([divider])

slow-backward replay, reverse slow motion

Kind: global function

| Param | Type | Default | Description | | --- | --- | --- | --- | | [divider] | Integer | 2 | divider of speed, something between 2-17 works |

iracing.playbackControls.slowBackward(2) // half speed RW

search(searchMode)

Search things from replay

Kind: global function

| Param | Type | Description | | --- | --- | --- | | searchMode | RpySrchMode | what to search |

iracing.playbackControls.search('nextIncident')

searchTs(sessionNum, sessionTimeMS)

Search timestamp

Kind: global function

| Param | Type | Description | | --- | --- | --- | | sessionNum | Integer | Session number | | sessionTimeMS | Integer | Session time in milliseconds |

// jump to 2nd minute of 3rd session
iracing.playbackControls.searchTs(2, 2*60*1000)

searchFrame(frameNum, rpyPosMode)

Go to frame. Frame counting can be relative to begin, end or current.

Kind: global function

| Param | Type | Description | | --- | --- | --- | | frameNum | Integer | Frame number | | rpyPosMode | RpyPosMode | Is frame number relative to begin, end or current frame |

iracing.playbackControls.searchFrame(1, 'current') // go to 1 frame forward

Development

To develop iracing-sdk-js itself, you need working working installation of node-gyp.

Useful commands:

  • yarn rebuild rebuilds binary addon
  • yarn test runs mocked tests
  • yarn smoke-tests runs tests that requires iRacing to be running
  • yarn ready runs all tests and updates docs

License

Released under the MIT License.

Credits

Originally based on node-irsdk by apihlaja.

Parts of original irsdk used, license available here: https://github.com/friss/iracing-sdk-js/blob/main/src/cpp/irsdk/irsdk_defines.h (BSD-3-Clause)