parse-lfs-message
TypeScript icon, indicating that this package has built-in type declarations

1.2.4 • Public • Published

parse-lfs-message

NPM Version Node.js CI

Convert a Live for Speed message to UTF-8

This module is designed to be used with NodeJS on the server with xi4n or as middleware for other LFS InSim applications. This module will parse any LFS message (chat message, nickname, server name etc.), converting encoded Windows codepage characters to UTF-8. This module leaves message colour encodings intact for processing later.

Install

# Install with Yarn
yarn add parse-lfs-message

# Install with NPM
npm i parse-lfs-message

Usage Example

You can run the example with yarn example or npm run example.

// Require parse-lfs-message module
const parseLFSMessage = require("parse-lfs-message");

// Simulate receiving messages from a buffer
const msg1 = Buffer.from("^72^45 ^7B2^J^4Ï^1 Ayoub", "binary");
const msg2 = Buffer.from("^405 ^J¢^7ϧ^4£ ^7TJ", "binary");

// Parse messages
const parsedMsg1 = parseLFSMessage(msg1);
const parsedMsg2 = parseLFSMessage(msg2);

console.log(parsedMsg1);
// Output: ^72^45 ^7B2^4マ ^1Ayoub

console.log(parsedMsg2);
// Output: ^405 「^7マァ^4」 ^7TJ

Readme

Keywords

none

Package Sidebar

Install

npm i parse-lfs-message

Weekly Downloads

31

Version

1.2.4

License

MIT

Unpacked Size

21.4 kB

Total Files

9

Last publish

Collaborators

  • flamecze
  • pbutcher