{"_id":"erlang","_rev":"13-b1a980d2f61a9685f244aef58a2f392e","name":"erlang","description":"Erlang interoperability with Javascript","dist-tags":{"latest":"1.0.0"},"versions":{"0.1.0":{"name":"erlang","version":"0.1.0","author":{"name":"Jason Smith","email":"jhs@couchone.com"},"description":"Erlang interoperability with Javascript","homepage":"http://github.com/jhs/erlang.js","repository":{"type":"git","url":"git://github.com/jhs/erlang.js"},"engines":["node"],"main":"api","_id":"erlang@0.1.0","_nodeSupported":true,"_npmVersion":"0.2.10-1","_nodeVersion":"v0.2.4","dist":{"shasum":"0c7b1aae757cade74201e3f6e5888bf3289251ed","tarball":"https://registry.npmjs.org/erlang/-/erlang-0.1.0.tgz","integrity":"sha512-yyvy2Z2apNCgFeXQXz6FxrL8ZRwsEPnpVSCFlvamPTncRb+K9lRSv4S6DN5omIv+kELar4c+ZuwMmSzffx0RqA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICtOEYOcH/4xIoSvnAgbQMtJ0Ax4rLtYDpN66P26l//wAiAOVtLs5LlQpLNDSHRTn/vB6kQe7VIGL6UGXI8Ps+S2Rw=="}]},"directories":{}},"0.2.0":{"name":"erlang","version":"0.2.0","author":{"name":"Iris Couch","email":"jhs@iriscouch.com"},"description":"Erlang interoperability with Javascript","homepage":"http://github.com/iriscouch/erlang.js","repository":{"type":"git","url":"git://github.com/iriscouch/erlang.js.git"},"engines":["node"],"main":"api","_npmUser":{"name":"jhs","email":"jhs@iriscouch.com"},"_id":"erlang@0.2.0","dependencies":{},"devDependencies":{},"_engineSupported":true,"_npmVersion":"1.0.104","_nodeVersion":"v0.6.2","_defaultsLoaded":true,"dist":{"shasum":"cf1730d1124c89ea1e147aa1be4d7571142c92de","tarball":"https://registry.npmjs.org/erlang/-/erlang-0.2.0.tgz","integrity":"sha512-g2k/UD/G9OF3eZg3wWehnB1eMdGIwfwBgIoM0zqysyU+ohYtf6qr+BR6Gk3IJWzInHAZ/qRyrFAlWPHRpoJq5w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDd8UROuTQNkB712OPqSQbosDX8fy3EjJUxhfRtLsG1hgIgGn8BDdyBuszwut5SJfuKIYPnf+GCgTBKBngs5fErVnU="}]},"maintainers":[{"name":"jhs","email":"jhs@iriscouch.com"},{"name":"jhs","email":"jhs@couchone.com"}],"directories":{}},"1.0.0":{"name":"erlang","version":"1.0.0","author":{"name":"Jason Smith","email":"jason.h.smith@gmail.com"},"description":"Erlang interoperability with Javascript","homepage":"http://github.com/iriscouch/erlang.js","repository":{"type":"git","url":"git://github.com/iriscouch/erlang.js.git"},"engines":["node"],"main":"./api.js","scripts":{"test":"tap test/"},"dependencies":{"debug":"~1.0.4"},"devDependencies":{"tap":"~0.4.8","async":"~0.2.10","traceback":"~0.3.1"},"gitHead":"04144e474bd6512297182b5d0350118ee7244ba3","bugs":{"url":"https://github.com/iriscouch/erlang.js/issues"},"_id":"erlang@1.0.0","_shasum":"c8d9420460b6e851d8da40b0ecca6bc9bcfc18ee","_from":".","_npmVersion":"3.8.9","_nodeVersion":"6.2.0","_npmUser":{"name":"jhs","email":"jason.h.smith@gmail.com"},"dist":{"shasum":"c8d9420460b6e851d8da40b0ecca6bc9bcfc18ee","tarball":"https://registry.npmjs.org/erlang/-/erlang-1.0.0.tgz","integrity":"sha512-wiWoJAl4LZA/Sa7oks/sacKZO1M/OinpDujNs5McgZaaIBZMuiHhiaoLK7kbwVB5rd9JIyRdMeyhVXYiGxEyPA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDIxYu/TMy0tcZQ4JWjfd2NkwYE5HX5xuNx4p2wD7vq+AiBZe+dPxZXGWpG6grZoucoNsWL30daHyaM77fWdOAYR1A=="}]},"maintainers":[{"name":"jhs","email":"jhs@iriscouch.com"},{"name":"jhs","email":"jhs@couchone.com"}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/erlang-1.0.0.tgz_1469078439575_0.7170672193169594"},"directories":{}}},"maintainers":[{"name":"jhs","email":"jhs@iriscouch.com"},{"name":"jhs","email":"jhs@couchone.com"}],"time":{"modified":"2022-06-17T08:03:04.257Z","created":"2010-12-20T16:13:21.172Z","0.1.0":"2010-12-20T16:13:22.146Z","0.2.0":"2011-11-24T02:30:19.182Z","1.0.0":"2016-07-21T05:20:42.219Z"},"author":{"name":"Jason Smith","email":"jason.h.smith@gmail.com"},"repository":{"type":"git","url":"git://github.com/iriscouch/erlang.js.git"},"readme":"# erlang.js\n\n## Basic Erlang and Node.js interoperability\n\nErlang.js is a simple JavaScript library to support the standard Erlang data encoding format (`term_to_binary`).\n\nIf you send data to an Erlang program, and that program will run `binary_to_term()`, then you need Erlang.js.\n\nErlang.js was spun off from production code used at Iris Couch. Erlang.js is available as an npm module.\n\n    npm install erlang\n\n## Examples\n\nSo far, only `term_to_binary` is implemented. Pass a data structure to `term_to_binary()` and it will return a Node.js buffer of that data, encoded.\n\n## Data Types\n\nSome data types encode as you would expect: numbers, arrays, and booleans.\n\nBut Erlang has foreign data types. Erlang.js supports a simple mechanism to represent those in JavaScript.\n\n### Strings\n\nJavaScript strings are converted to Erlang strings (i.e. lists of integers).\n\n```javascript\nterm_to_binary(\"I am a string\") // Encodes the Erlang string \"I am a string\"\n```\n\n### Atoms\n\n`{atom:\"Foo\"}` encodes as Erlang `'Foo'`. You can also use a shorthand, `{a:\"Foo\"}`.\n\n```javascript\nterm_to_binary({a:\"POST\"}) // Encodes the atom 'POST'\n```\n\n### Binaries\n\n`{binary:\"Foo\"}` encodes as Erlang `<<\"Foo\">>`. You can also use a shorthand, `{b:\"Foo\"}`.\n\n```javascript\nterm_to_binary({b:\"POST\"}) // Encodes the binary <<\"POST\">>\n```\n\n### Tuples\n\n`{tuple:[\"foo\", \"bar\"]}` encodes as Erlang `{\"foo\", \"bar\"}`. You can also use a shorthand, `{t:[\"foo\", \"bar\"]}`.\n\n```javascript\nvar foo = {a:\"foo\"} // an atom\nterm_to_binary({t:[foo, \"bar\"]}) // Encodes the tuple {foo, \"bar\"}\n```\n\n## Optlists\n\nIn JavaScript, if an API has tons of options, it tends to use an object.\n\n```javascript\n// An API with so many options it uses a single object argument:\nrequest({url:\"http://jsonip.com\", json:true}, my_callback)\n```\n\nErlang does not have this (for one thing, all data is always immutable). Instead it uses option lists (optlists) of mostly atoms and tagged tuples.\n\n```erlang\nOptions = [set, public, {keypos, 1}, {write_concurrency, true}, compressed],\nets:new(my_table, Options).\n```\n\nOptlists are common in Erlang. You can build them manually with `term_to_binary()`, but the data structure is messy and distracting. Erlang.js provides an alternative, `optlist_to_binary()` which encodes more readable and obvious JavaScript data structures.\n\n`optlist_to_binary()` encodes its arguments as an array. Each argument must be:\n\n1. A short string (all-lowercase, up to 255 characters): converted to an atom\n2. A 2-array where the first element is a short string: converted to a tagged tuple\n3. An object with only one key/val pair: converted to a tagged tuple\n\nTo encode the optlist from the above Erlang example:\n\n```javascript\noptlist_to_binary('set', 'public', ['keypos', 1], {write_concurrency:true}, 'compressed')\n\n/* Same as\nterm_to_binary([ { atom: 'set' }\n               , { atom: 'public' }\n               , { tuple: [ { atom: 'keypos' }, 1 ] }\n               , { tuple: [ { atom: 'write_concurrency' }, true ] }\n               , { atom: 'compressed' }\n               ])\n*/\n```\n\n## License\n\nApache 2.0\n\nSee the [Apache 2.0 license](named/blob/master/LICENSE).\n\n[tap]: https://github.com/isaacs/node-tap\n[def]: https://github.com/iriscouch/defaultable\n","homepage":"http://github.com/iriscouch/erlang.js","bugs":{"url":"https://github.com/iriscouch/erlang.js/issues"},"readmeFilename":"README.md","users":{"lagora":true,"qujian":true,"apterion":true}}