Permalink
Browse files

Added some simple examples.

  • Loading branch information...
1 parent 93aa985 commit 2e00d52c4047f3b443c8242ed3dcb556413c3e44 @clarkf committed Feb 8, 2012
Showing with 18 additions and 0 deletions.
  1. +6 −0 examples/decoding.js
  2. +12 −0 examples/encoding.js
View
@@ -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());
View
@@ -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.