{"bugs":{"url":"https://github.com/gett/common/issues"},"dist":{"shasum":"3c7182f678bd1e3681cd5cc348c759fe8dd22394","tarball":"https://registry.npmjs.org/common/-/common-0.2.5.tgz","integrity":"sha512-bjuztiY8Wcz2V9dPpa0XdF0unGWqAGsnyKDGV7g6xDcaZfpufRrxV35qhuhjwv1h0jEPeiCHWKAQFLj702jGnA==","signatures":[{"sig":"MEUCIQDdItp+AAnOI+7idkc+Aj7qSONAR/6z7wjx16Bk+907uwIgN/g/HttIn1g3gxON7S+Vpe/g6K7xJJv2RdQKMZGcsPI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"./index.js","name":"common","_from":".","author":{"name":"Ge.tt","email":"hello@ge.tt"},"readme":"# Common\nA utility module for both node.js and the browser.  \nIt is available through npm:\n\n\tnpm install common\n\nOr as minified js file for the browser:\n\n\t<script src='common.min.js'></script>\n\nThis module among other things contains a fork of [step](https://github.com/creationix/step) that also provides error handling\n\n``` js\ncommon.step([\n\tfunction(next) { // next is the last argument, except in the last handler\n\t\tfs.readFile(__filename, 'utf-8', next);\n\t},\n\tfunction(file) {\n\t\tconsole.log(file);\n\t}\n], function(err) {\n\t// any error received in a callback will be forwarded here\n});\n```\n\nIt also contains a shortcut to the `EventEmitter` prototype and a compatible implementation of this for the browser.\n\n``` js\nvar MyEmitter = common.emitter(function() {\n\tthis.foo = 42;\n});\n\nvar me = new MyEmitter();\n\nme.emit('foo', me.foo); // emits 'foo',42\n```\n\nThere is also a more general method for extending prototypes called `extend`:\n\n``` js\n// this prototype is the same as above\nvar MyEmitter = common.extend(events.EventEmitter, function() {\n\tthis.foo = 42;\n});\n```\n\nIf you want to use futures you can use the `future` function to create a future:\n\n``` js\nvar fut = common.future();\n\nfut.get(function(val) {\n\tconsole.log(val);\n});\nsetTimeout(function() {\n\tfut.put(42); // results in the previous .get being called and all future .get's will be called synchroniously\n}, 1000)\n```\n\nTo do string formatting you can use `format`:\n\n``` js\n// you can parse the arguments to a pattern one by one\ncommon.format('define {0} here', 'pattern'); // returns 'define pattern here'\n\n// or as a map or array\ncommon.format('define {foo} here', {foo:'pattern'}); // same as above\n```\nThere is a `log` method that just accepts the does the same as `format` except it prints out the result using `console.log` if available\n\nTo generate a simple weak symbols (often used when generating keys for a map) use `gensym`\n\n``` js\ncommon.gensym() // returns 's0'\ncommon.gensym() // returns 's1'\n```\n\nIf you instead of a weak symbol need a strong one use `uuid`:\n\n``` js\ncommon.uuid(); // returns a strong id, ex: ngDl6IdovME9JKvIxgED0FK1kzURxfZaCq48-0\n```\n\nCommon can also encode integers into alphanumerical notation using `encode`:\n\n``` js\ncommon.encode(1000); // returns G8\n```\n\nTo ensure that a method cannot be called more than once you can use the `once` function:\n\n``` js\nvar fn = common.once(function() {\n\tconsole.log('hello');\n});\n\nfn(); // prints hello\nfn(); // does nothing\n```\n\nBesides the above common implements two of the utilities mentioned in The Good Parts, `memoizer` and `curry`.  \n","_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"repository":{"url":"git://github.com/gett/common.git","type":"git"},"_npmVersion":"1.3.8","description":"A utility package with some useful functional stuff","maintainers":[{"name":"mafintosh","email":"m@ge.tt"},{"name":"ianjorgensen","email":"jorgensen.ian@gmail.com"}],"contributors":[{"name":"Mathias Buus Madsen","email":"m@ge.tt"}],"readmeFilename":"README.md","_id":"common@0.2.5","version":"0.2.5"}