dogedc
v1.1.2
Published
Doge Decimal Classification
Downloads
13
Maintainers
Readme
Doge Decimal Classification
Such classification. Many library. So fun. No Dewey. Wow.
Installation
npm i dogedc
CLI
Doge Decimal Classification now comes with a command-line interface! Amaze.
$ dogedc 123
So determinism. Many indeterminism.
$ dogedc # random class
Very international. Many law. Wow.
You'll need to install it globally (npm i dogedc -g
) to get the CLI on your path.
API Usage
dogedc(classNumber, callback)
— convert class from boring old Dewey Decimal Classification to exciting new Doge Decimal Classification. The callback function is passed any error as its first argument & an object as its second argument, that object has form:
{
'classNumber': '020',
'className': 'Library & information sciences',
'dogeClassName': 'Many library. Such information. Very sciences.'
}
If classNumber
is falsey or not present, dogedc
will pick a random class number & pass that to the callback.
var dogedc = require('dogedc');
// get random Doge Decimal class
dogedc(function(err, ddc) {
console.log('Class number:', ddc.classNumber);
console.log('Doge class name:', ddc.dogeClassName);
});
// look up 020's class name
dogedc('020', function(err, ddc) {
console.log('020', ddc.dogeClassName);
});
The dogedc node module also exposes a toDoge
function for converting tepid plain human speak into awesome beautiful doge speak. It was written specifically for this module, so as a general-purpose doge-ifier your mileage may vary, but it's there.
var toDoge = require('dogedc').toDoge;
console.log(toDoge('Hello World'));
// logs "Many hello. Much world." or some such
Notes
The number
argument passed to dogedc
can be an integer or a string. It's safer to always pass strings because numbers with leading 0s are treated as base 8 in JavaScript (e.g. 020 === 16
);
Right now, only top-level, 3-digit classes work.
I culled the list of Dewey Decimal Classes from the University of Illinois at Urbana-Champaign's list. If there are any errors, blame them ;)
Doge Decimal Classification is the first stochastic classification system.* Class names are randomly generated based on the corresponding Dewey Decimal Classification & well-recognized dogespeak constructions. For this module's users, that means that the resulting dogeClassName
of any given class number may differ each time the module is executed.
I tried using fs.createReadStream
& JSONStream to parse the Dewey JSON file but it turned out to be almost twice as slow as simply using fs.readFile
. That work is on the stream
branch & the testing script is at test/bench.
*…that I'm aware of.