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 🙏

© 2025 – Pkg Stats / Ryan Hefner

clonkrefiniparser

v1.0.0

Published

Lightweight parser for INI-Files and Clonk (R) game references

Readme

JavaScript INI Parser

This library allows you to parse any valid INI file. However, its main goal is to be able to parse any game reference of the game Clonk (R) (see http://www.clonk.de), including the main masterserver's output. Since the used format hasn't really changed since Clonk Planet was released, it should be compatible with any network-capable version of Clonk, including OpenClonk and Clonk Rage.

It is implemented in pure JavaScript and bundled as a CommonJS-module, but it can also be used in non-moduled environments like modern ES5-browsers.

Example Usage

Parse an INI file in node.js and output the generated JSON to the console:

var refparse = require('clonkrefiniparser'),
	fs = require('fs'),
	fh = fs.createReadStream("input.ini", "r");

refparse.parseReferenceStream(fh, function(err, root){
	// Root element contains the top-level sections
	if(err){
		console.warn("Error: " + err);
	} else {
		console.log("Data read: " + JSON.stringify(root));
	}
});
	

Request an INI file in node.js over HTTP, parse it and output the generated JSON to the console:

var refparse = require('clonkrefiniparser'),
	http = require('http');

// Request game information from the OpenClonk masterserver
http.get("http://boom.openclonk.org/server/", function(fh){
	refparse.parseReferenceStream(fh, function(err, root){
		// Root element contains the top-level sections
		if(err){
			console.warn("Error: " + err);
		} else {
			console.log("Data read: " + JSON.stringify(root));
		}
	});
});

Parse an INI file in the browser (assuming ref.js was previously loaded in a script-tag) and output it using an alert-window:

var root = parseReferenceString("[OpenClonk]\nMOTD=<c 0fff0f>OpenClonk released!</c>");
alert(JSON.stringify(root));

Usage information

parseReferenceStream is the preferred method in a node.js-environment and can be used asynchronously. It uses the data read from a provided ReadableStream, which is read line by line. This allows it to process rather big files. The given callback is executed when the underlying stream casts the 'end'-event.

In case your parsed file is built up like a tree (used by Clonk), by default 2 spaces mean one level. Note that the parser accepts multiple sections with the same names on one level. Because of this, the following reference produces this output:

[Reference]
GameId=382
Title="Foo"
	
  [Info]
  Comment="Hello world"

[Reference]
GameId=394
Title="Bar"

Turns into:

{"Reference": 
	[
		{	"GameId":	382,
			"Title":	"foo"
			"Info":		{	"Comment":	"Hello world"	}
		},
		{	"GameId":	394,
			"Title":	"Bar"
		}
	]
}

Consult the node.js-documentation on its Stream-API for further information on the usage of parseReferenceStream.