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

node-irsdk-mjo

v1.0.1

Published

iRacing SDK implementation for nodejs

Downloads

90

Readme

node-irsdk-mjo

Unofficial iRacing SDK implementation for Node.js.

Other iRSDK implementations:

Disclaimer

This is a fork of node-irsdk by apihlaja. The original project is no longer maintained and I have made some changes to the code to make it work with the latest version of iRacing.

Pre-requisites

For compiling this package you need node-gyp@^9.0.0.

npm install -g node-gyp

You also need a current version of Python3 and Microsoft Visual Studio Build Tools installed. More information regarding the topic can be found here. I haven't tried this myself (as I already had msbuild installed), but according to the documentation, you could easily run:

npm install -g windows-build-tools

Installing

Make sure you have Node.js v19 x64 or later.

npm install --save node-irsdk-mjo

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 |

var irsdk = require("node-irsdk");
// look for telemetry updates only once per 100 ms
var iracing = irsdk.init({ telemetryUpdateInterval: 100 });

irsdk.getInstance() ⇒ iracing

Get initialized instance of JsIrSdk

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

var irsdk = require("node-irsdk");
var iracing = irsdk.getInstance();

iracing ⇐ events.EventEmitter

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

new JsIrSdk()

JsIrSdk is javascript implementation of iRacing SDK.

Don't use constructor directly, use getInstance.

var iracing = require("node-irsdk").getInstance();

iracing.Consts : IrSdkConsts

iRacing SDK related constants

Kind: instance property of iracing

iracing.camControls : Object

Camera controls

Kind: instance property of iracing

camControls.setState(state)

Change camera tool state

Kind: static method of camControls

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

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

Switch camera, focus on car

Kind: static method of camControls

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

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

Switch camera, focus on position

Kind: static method of camControls

| 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

iracing.playbackControls : Object

Replay and playback controls

Kind: instance property of iracing

playbackControls.play()

Play replay

Kind: static method of playbackControls

iracing.playbackControls.play();

playbackControls.pause()

Pause replay

Kind: static method of playbackControls

iracing.playbackControls.pause();

playbackControls.fastForward([speed])

fast-forward replay

Kind: static method of playbackControls

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

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

playbackControls.rewind([speed])

rewind replay

Kind: static method of playbackControls

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

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

playbackControls.slowForward([divider])

slow-forward replay, slow motion

Kind: static method of playbackControls

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

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

playbackControls.slowBackward([divider])

slow-backward replay, reverse slow motion

Kind: static method of playbackControls

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

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

playbackControls.search(searchMode)

Search things from replay

Kind: static method of playbackControls

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

iracing.playbackControls.search("nextIncident");

playbackControls.searchTs(sessionNum, sessionTimeMS)

Search timestamp

Kind: static method of playbackControls

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

playbackControls.searchFrame(frameNum, rpyPosMode)

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

Kind: static method of playbackControls

| 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

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.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");

"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);
});

"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);
});

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 |

Development

To develop node-irsdk itself, you need working working installation of node-gyp.

Useful commands:

  • npm install builds binary addon
  • npm run ready runs tests and updates docs

Making a new release

  1. Check if license file needs updating
  2. npm run ready
  3. Tag new version using npm version, push to Github
  4. Wait for Appveyor to upload binaries
  5. npm publish
  6. Add release notes to Github, helper npm run release-notes.

License

Released under the MIT License.

Credits

Parts of original irsdk used, license available here: https://github.com/apihlaja/node-irsdk/blob/master/src/cpp/irsdk/irsdk_defines.h (BSD-3-Clause)