lib/gridfs-stream/index.js
function GridFSBucket(db, options) {
  Emitter.apply(this);
  this.setMaxListeners(0);

  if (options && typeof options === 'object') {
    options = shallowClone(options);
    var keys = Object.keys(DEFAULT_GRIDFS_BUCKET_OPTIONS);
    for (var i = 0; i < keys.length; ++i) {
      if (!options[keys[i]]) {
        options[keys[i]] = DEFAULT_GRIDFS_BUCKET_OPTIONS[keys[i]];
      }
    }
  } else {
    options = DEFAULT_GRIDFS_BUCKET_OPTIONS;
  }

  this.s = {
    db: db,
    options: options,
    _chunksCollection: db.collection(options.bucketName + '.chunks'),
    _filesCollection: db.collection(options.bucketName + '.files'),
    checkedIndexes: false,
    calledOpenUploadStream: false,
    promiseLibrary: db.s.promiseLibrary || Promise
  };
}
function GridFSBucket(db, options) {
  Emitter.apply(this);
  this.setMaxListeners(0);

  if (options && typeof options === 'object') {
    options = shallowClone(options);
    var keys = Object.keys(DEFAULT_GRIDFS_BUCKET_OPTIONS);
    for (var i = 0; i < keys.length; ++i) {
      if (!options[keys[i]]) {
        options[keys[i]] = DEFAULT_GRIDFS_BUCKET_OPTIONS[keys[i]];
      }
    }
  } else {
    options = DEFAULT_GRIDFS_BUCKET_OPTIONS;
  }

  this.s = {
    db: db,
    options: options,
    _chunksCollection: db.collection(options.bucketName + '.chunks'),
    _filesCollection: db.collection(options.bucketName + '.files'),
    checkedIndexes: false,
    calledOpenUploadStream: false,
    promiseLibrary: db.s.promiseLibrary || Promise
  };
}
function GridFSBucket ( db , options ) { Emitter . apply ( this ) ; this . setMaxListeners ( 0 ) ; if ( options && typeof options === 'object' ) { options = shallowClone ( options ) ; var keys = Object . keys ( DEFAULT_GRIDFS_BUCKET_OPTIONS ) ; for ( var i = 0 ; i < keys . length ; ++ i ) { if ( ! options [ keys [ i ] ] ) { options [ keys [ i ] ] = DEFAULT_GRIDFS_BUCKET_OPTIONS [ keys [ i ] ] ; } } } else { options = DEFAULT_GRIDFS_BUCKET_OPTIONS ; } this . s = { db : db , options : options , _chunksCollection : db . collection ( options . bucketName + '.chunks' ) , _filesCollection : db . collection ( options . bucketName + '.files' ) , checkedIndexes : false , calledOpenUploadStream : false , promiseLibrary : db . s . promiseLibrary || Promise } ; }
Constructor for a streaming GridFS interface
@class
@param {Db} db A db handle
@param {object} [options] Optional settings.
@param {string} [options.bucketName="fs"] The 'files' and 'chunks' collections will be prefixed with the bucket name followed by a dot.
@param {number} [options.chunkSizeBytes=255 * 1024] Number of bytes stored in each chunk. Defaults to 255KB
@param {object} [options.writeConcern] Optional write concern to be passed to write operations, for instance `{ w: 1 }`
@param {object} [options.readPreference] Optional read preference to be passed to read operations
@fires GridFSBucketWriteStream#index
@return {GridFSBucket}
Constructor for a streaming GridFS interface