| Crates.io | f1-nexus-node |
| lib.rs | f1-nexus-node |
| version | 1.0.0-alpha.2 |
| created_at | 2025-12-17 02:34:00.859978+00 |
| updated_at | 2025-12-17 02:34:00.859978+00 |
| description | F1 Nexus NAPI-RS bindings for Node.js |
| homepage | |
| repository | https://github.com/mrkingsleyobi/f1-nexus |
| max_upload_size | |
| id | 1989203 |
| size | 817,751 |
High-performance Node.js bindings for F1 Nexus using NAPI-RS - Formula 1 race strategy optimization with native speed.
npm install @f1-nexus/node
const f1 = require('@f1-nexus/node');
// Optimize pit strategy
const params = {
track: 'monaco',
totalLaps: 78,
currentLap: 1,
availableCompounds: ['C1', 'C2', 'C3'],
fuelRemaining: 110.0,
position: 3
};
const strategy = JSON.parse(f1.optimizeStrategy(JSON.stringify(params)));
console.log('Optimal Strategy:');
console.log(`Starting compound: ${strategy.startingCompound}`);
strategy.pitStops.forEach((stop, i) => {
console.log(`Stop ${i + 1}: Lap ${stop.lap} → ${stop.compound}`);
});
console.log(`Predicted time: ${strategy.predictedRaceTime.toFixed(2)}s`);
console.log(`Confidence: ${(strategy.confidence * 100).toFixed(1)}%`);
import * as f1 from '@f1-nexus/node';
interface OptimizeParams {
track: string;
totalLaps: number;
currentLap?: number;
availableCompounds: string[];
fuelRemaining?: number;
position?: number;
}
interface Strategy {
strategyId: string;
startingCompound: string;
pitStops: Array<{
lap: number;
compound: string;
pitLoss: number;
reason: string;
confidence: number;
}>;
predictedRaceTime: number;
confidence: number;
}
const params: OptimizeParams = {
track: 'silverstone',
totalLaps: 52,
availableCompounds: ['C1', 'C2', 'C3']
};
const strategy: Strategy = JSON.parse(
f1.optimizeStrategy(JSON.stringify(params))
);
const express = require('express');
const f1 = require('@f1-nexus/node');
const app = express();
app.use(express.json());
app.post('/api/optimize', (req, res) => {
try {
const strategy = JSON.parse(
f1.optimizeStrategy(JSON.stringify(req.body))
);
res.json({ success: true, strategy });
} catch (error) {
res.status(500).json({ success: false, error: error.message });
}
});
app.listen(3000, () => {
console.log('F1 strategy API running on port 3000');
});
optimizeStrategy(paramsJson: string): stringFind optimal pit stop strategy using dynamic programming.
Input JSON:
{
"track": "monaco",
"totalLaps": 78,
"currentLap": 1,
"availableCompounds": ["C1", "C2", "C3"],
"fuelRemaining": 110.0,
"position": 3,
"competitors": []
}
Output JSON: Optimized strategy with pit stops, compounds, and predicted time
simulateRace(paramsJson: string): stringRun Monte Carlo simulation to validate strategy.
Input: Strategy + simulation config (JSON) Output: Distribution of finish times, DNF probability (JSON)
predictTireLife(paramsJson: string): stringPredict tire degradation and optimal pit window.
Input: Tire data + track conditions (JSON) Output: Remaining laps, degradation curve (JSON)
getCircuits(): string[]Get list of supported F1 circuits.
Returns: Array of circuit IDs
getTireCompounds(): string[]Get list of tire compound types.
Returns: Array of compound IDs (C0-C5, Intermediate, Wet)
version(): stringGet package version.
Returns: Version string
Optimization (70 laps, 3 compounds):
├─ @f1-nexus/node: 45ms
├─ Pure JavaScript: 4,200ms
└─ Speedup: 93x
Simulation (10,000 iterations):
├─ @f1-nexus/node: 1,850ms
├─ Pure JavaScript: 185,000ms
└─ Speedup: 100x
#!/usr/bin/env node
const f1 = require('@f1-nexus/node');
const params = {
track: process.argv[2] || 'monaco',
totalLaps: parseInt(process.argv[3]) || 78,
availableCompounds: ['C1', 'C2', 'C3']
};
const strategy = JSON.parse(f1.optimizeStrategy(JSON.stringify(params)));
console.table(strategy.pitStops);
const { Worker } = require('worker_threads');
const f1 = require('@f1-nexus/node');
// Run heavy simulations in worker threads
const worker = new Worker('./strategy-worker.js');
worker.postMessage({
action: 'simulate',
params: { /* ... */ }
});
worker.on('message', (result) => {
console.log('Simulation complete:', result);
});
@f1-nexus/wasm - Browser WASM bindingsf1-nexus-cli - Command-line interfaceLicensed under either of Apache License, Version 2.0 or MIT license at your option.