Skip to content

Commit

Permalink
Added some simple examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
clarkf committed Feb 8, 2012
1 parent 93aa985 commit 2e00d52
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions examples/decoding.js
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,6 @@
var bencoding = require('../'),
data = new Buffer('d3:inti1024768e3:str5:abcde4:listli1ei2ei3eee'),
result = bencoding.decode(data);

console.log(result);
console.log(result.toJSON());
12 changes: 12 additions & 0 deletions examples/encoding.js
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,12 @@
var bencoding = require('../'),
object = {
'string': "Hello World",
'integer': 12345,
'dictionary': {
'key': "This is a string within a dictionary"
},
'list': [1, 2, 3, 4, 'string', 5, {}]
},
result = bencoding.encode(object);

console.log(result.toString());

0 comments on commit 2e00d52

Please sign in to comment.