Untitled

mail@pastecode.io avatar
unknown
javascript
a year ago
543 B
23
Indexable
function mockQueryStream(this: any) {
  const streamObj = {
    on: (event: string, callback: any) => {
      switch (event) {
        case 'data':
          this.get().then(res => {
            res.forEach(doc => {
              callback(doc);
            });
          });
          return streamObj;

        case 'end':
        case 'error':
          callback();
          return streamObj;
        default:
          return streamObj;
      }
    },
  };

  return streamObj;
}

export default mockQueryStream;