A simple module to parse/generate ed2k link for nodejs.
You can use this command to install:
npm install ed2k-link
You should require the module first:
ed2k = require('ed2k-link');
Code:
ed2k.parse("ed2k://|file|foo.bar|123|0123456789ABCDEF0123456789ABCDEF|/");
Output:
{ filename: 'foo.bar',
ed2k: '0123456789ABCDEF0123456789ABCDEF',
aich: '',
hashset: [],
sources: { client: [], url: [] },
length: 123 }
Code:
var link = ed2k.parse("ed2k://|file|foo.bar|123|0123456789ABCDEF0123456789ABCDEF|/");
link.toString();
Output:
ed2k://|file|foo.bar|123|0123456789ABCDEF0123456789ABCDEF|/
Code:
//node-like callback
ed2k.generate("./foo.bar", function(err, link) {
console.log(link);
});
//Promise
ed2k.generate("./foo.bar").then(function(link) {
console.log(link);
});
Output:
{ filename: 'foo.bar',
ed2k: '0123456789ABCDEF0123456789ABCDEF',
aich: '',
hashset: [],
sources: { client: [], url: [] },
length: 123 }
The project is released under the MIT license.
Author: lightpacerabbit@gmail.com