@elanthia/koschei
v2.2.6
Published
A bridge between the Lich-runtime and a Node.js runtime
Downloads
18
Readme
@elanthia/koschei
Typescript, event-driven, Stream support, perfect for your next integration with Gemstone like building Electron apps, TUIs, or whatever. Wraps a SAX-based parser with robust error recovery and a stack-driven approach.
Features:
- handles monsterbold elegantly by reducing arbitrarily nested
<pushBold> > <a>
tags to<monster>
- maps ugly
<pushBold> | </popBold>
tags to<b> | </b>
like sane people should - should handle all of the ugly cases of the XML-like feed for you
Example:
import net from "net"
import {Parser, Tag} from "@elanthia/koschei"
// make our parser instance
const parser = Parser.of()
// open a socket to a Game feed
// doesn't have to be Lich, but most people are familiar with it
const lich = net.connect({port: LICH_PORT_OR_WHATEVER})
// on any tag (firehose)
parser.on("tag", console.log)
// all tags are also emitted by name
parser.on("monster", App.redraw)
// tell the parser to parse the incoming tcp packets
lich.pipe(parser)