@confuzzle/puz-sharing
v1.2.3
Published
.puz crossword reader, writer, and parser with compression and encoding
Maintainers
Readme
@confuzzle/puz-sharing
This package extends @confuzzle/puz-crossword, adding capabilities for compressing and converting .puz files to URL-compatible base64 and emoji. The compressed format should be treated as experimental and will not be backwards-compatible betweeen releases of this package at this stage.
This package makes use of @thi.ng/range-coder by Karsten Schmidt, part of the excellent @thi.ng umbrella library.
Contents
This package provides a single class, ShareablePuz, which extends PuzCrossword with the following additional methods:
ShareablePuz.toCompressed()- return a compressed representation of the crossword as raw bytesShareablePuz.toEmoji()- the compressed representation encoded using@confuzzle/ecoji-buffersShareablePuz.toURL()- the compressed representation encoded using@base64url
Each of these methods has a counterpart returning a new ShareablePuz object from its output x:
ShareablePuz.fromCompressed(x)ShareablePuz.fromEmoji(x)ShareablePuz.fromURL(x)
Example Usage
const ShareablePuz = require('@confuzzle/puz-sharing').ShareablePuz;
const fs = require('fs');
const cw = ShareablePuz.from(fs.readFileSync("test.puz"));
console.log(cw.title) // Test puzzle
const emoji = cw.toEmoji();
console.log(emoji.slice(0, 10)) // 🧩✨0️⃣🌌🇩
const cw2 = ShareablePuz.fromEmoji(emoji);
console.log(cw2.title) // Test puzzle