Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/phette23/dogedc
Doge Decimal Classification
https://github.com/phette23/dogedc
Last synced: 11 days ago
JSON representation
Doge Decimal Classification
- Host: GitHub
- URL: https://github.com/phette23/dogedc
- Owner: phette23
- Created: 2014-03-01T19:26:43.000Z (over 10 years ago)
- Default Branch: main
- Last Pushed: 2023-10-17T22:57:53.000Z (about 1 year ago)
- Last Synced: 2024-04-14T23:15:24.431Z (7 months ago)
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/dogedc
- Size: 276 KB
- Stars: 15
- Watchers: 3
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: readme.mdown
Awesome Lists containing this project
README
# Doge Decimal Classification
![Node.js CI](https://github.com/phette23/dogedc/workflows/Node.js%20CI/badge.svg) [![](https://img.shields.io/npm/v/dogedc.svg)](https://www.npmjs.com/package/dogedc)
Such classification. Many library. So fun. No Dewey. Wow.
## Installation
```bash
npm i dogedc
```## CLI
Doge Decimal Classification now comes with a command-line interface! Amaze.
```bash
$ 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:
```js
{
'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.
```js
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.
```js
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](http://www.library.illinois.edu/ugl/about/dewey.html) 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](http://the-toast.net/2014/02/06/linguist-explains-grammar-doge-wow/). 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](https://www.npmjs.org/package/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.
## License
[![](https://www.gnu.org/graphics/gplv3-127x51.png)](http://gplv3.fsf.org/)