diff --git a/gridfs-stream/gridfs-stream-tests.ts b/gridfs-stream/gridfs-stream-tests.ts
new file mode 100644
index 000000000..c9ca457c2
--- /dev/null
+++ b/gridfs-stream/gridfs-stream-tests.ts
@@ -0,0 +1,37 @@
+///
+///
+///
+
+// Samples from:
+// https://github.com/aheckmann/gridfs-stream
+
+import fs = require('fs');
+import mongo = require('mongodb');
+import Grid = require('gridfs-stream');
+
+// create or use an existing mongodb-native db instance
+var db = new mongo.Db('gridfs-stream-test', new mongo.Server("127.0.0.1", 27017));
+var gfs = Grid(db, mongo);
+
+// streaming to gridfs
+var writestream = gfs.createWriteStream({
+ filename: 'my_file.txt'
+});
+fs.createReadStream('blob.txt').pipe(writestream);
+
+// streaming from gridfs
+var readstream = gfs.createReadStream({
+ filename: 'my_file.txt'
+});
+
+//error handling, e.g. file does not exist
+readstream.on('error', function (err: any) {
+ console.log('An error occurred!', err);
+ throw err;
+});
+
+var bufs: Array = [];
+readstream.on('data', function(d: any){ bufs.push(d); });
+readstream.on('end', function() {
+ var buf = Buffer.concat(bufs);
+});
diff --git a/gridfs-stream/gridfs-stream.d.ts b/gridfs-stream/gridfs-stream.d.ts
index 11bc3adb2..515f56a4c 100644
--- a/gridfs-stream/gridfs-stream.d.ts
+++ b/gridfs-stream/gridfs-stream.d.ts
@@ -51,13 +51,13 @@ declare module "gridfs-stream" {
files: mongo.Collection;
collection: mongo.Collection;
- createWriteStream(options?: GridFSStream.Options) : GridFSStream.WriteStream;
- createReadStream(options?: GridFSStream.Options) : GridFSStream.ReadStream;
- createWriteStream(options?: string) : GridFSStream.WriteStream;
- createReadStream(options?: string) : GridFSStream.ReadStream;
+ createWriteStream(options?: GridFSStream.Options): GridFSStream.WriteStream;
+ createReadStream(options?: GridFSStream.Options): GridFSStream.ReadStream;
+ createWriteStream(options?: string): GridFSStream.WriteStream;
+ createReadStream(options?: string): GridFSStream.ReadStream;
- remove(options: GridFSStream.Options, callback: (err: Error) => void);
- exist(options: GridFSStream.Options, callback: (err: Error, found: boolean) => void);
+ remove(options: GridFSStream.Options, callback: (err: Error) => void): void;
+ exist(options: GridFSStream.Options, callback: (err: Error, found: boolean) => void): void;
}
}