Security News
Research
Supply Chain Attack on Rspack npm Packages Injects Cryptojacking Malware
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
chesstournament
Advanced tools
chesstournament.js
is a JavaScript library to manage chess tournaments.
Note: As this library is under development, it has not been published on npm yet.
You can use this library in node.js as well as natively in your favorite browser. For node.js simply install it using npm:
npm install chesstournament
For browser usage:
<script src="chesstournament.js"></script>
var Tournament = require('chesstournament');
var Player = Tournament.Player;
var Team = Tournament.Team;
var type = 'team'; // either 'individual' or 'team'
var tournament = new Tournament(type);
var team = new Team('Chess Club One'); // create a new Team
tournament.teams.add(team); // and register it
team.players.add(new Player('Falco')); // add some
team.players.add(new Player('Jacob')); // nice team mates
// or simply import a SWT file by the chesstournament-SWT-support plugin
Tournament.from.use(require('chesstournament-SWT-support'));
Tournament.from('my/tournament.SWT', function(err, importedTournament) {
console.log(importedTournament.rounds.length);
});
chesstournament.js
provides an easy way to bind import and export plugins.
You can simply register such a plugin to your Tournament module:
// import plugin
Tournament.from.use(require('my-import-handler'));
// export plugin
Tournament.to.use(require('my-export-handler'));
The so registered plugins can be used via Tournament.from()
and
tournament.to()
:
// input can be everything the import plugin supports, for example
// a filename or the content itself
Tournament.from('your input here', handleImportedTournament);
function handleImportedTournament(err, tournament) {
// do what you want
// for example export it to another format
tournament.to.myRegisteredExport(options, handleExportedTournament);
// alternatively use
Tournament.to.myRegisteredExport(tournament, options, handleExportedTournament);
}
function handleExportedTournament(err, export) {
console.log(export);
}
There is currently only one userland plugin to import existing tournaments from Swiss-Chess Tournament (SWT) files. This list will get updated once there are more plugins:
A plugin which provides both import and export functionalities is specified by an object of the following form:
{
// Name of this format, so a direct call Tournament.from[name] is
// possible, e.g. Tournament.from.CTX('your CTX data', handleTournament);
name: 'CTX',
// Function to determine if this importer should be used, depending
// on the content, which might also be a filename.
determine: function determineFunction(content) { return true; }
// Function to import this format. Keep in mind, that content might
// also be a filename.
import: function importFunction(content, callback) { callback(err, tournament); }
// Function to export into this format.
export: function exportFunction(tournament, options, callback) { callback(err, exported); }
}
If only the import
attribute is specified, it is an import plugin. Same
applies to export
.
Import as well as export plugins can also be registered directly by assigning it
to the Tournament.from
and Tournament.to
objects:
// register import plugin
Tournament.from.myFormat = function importFunction(content, callback) { callback(err, tournament); };
// necessary if you also want to use the shortcut Tournament.from()
Tournament.from.myFormat.determine = function determineFunction(content) { return true; };
// register export plugin
Tournament.to.myFormat = function exportFunction(tournament, options, callback) { callback(err, exported); };
FAQs
A JavaScript library to manage Chess Tournaments
We found that chesstournament demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.
Security News
Sonar’s acquisition of Tidelift highlights a growing industry shift toward sustainable open source funding, addressing maintainer burnout and critical software dependencies.