UNPKG

@yinyinfurong_zmr/dbc-can

Version:

A general purpose CAN (Controller Area Network) toolbox with support for .dbc file parsing, CAN message decoding, and more

17 lines 638 B
import fs from 'fs'; import { validateFileExtension } from './FileHandlers'; /** * Utility function for writing a raw dbc string to a .dbc file * @param file location and name of the dbc file to write to * @param fileContent The DBC content that will be loaded into the file */ const dbcWriter = (file, fileContent) => { validateFileExtension(file, '.dbc'); fs.writeFileSync(file, '', { flag: 'w+' }); const lines = fileContent.split('\n'); for (const line of lines) { fs.writeFileSync(file, `${line}\n`, { flag: 'a+' }); } }; export default dbcWriter; //# sourceMappingURL=DbcWriter.js.map