swc/bundler/tests/.cache/deno/2fe78d73018d170c2f18b33bd51c3c048497ec10.ts
강동윤 bbaf619f63
fix(bundler): Fix bugs (#1437)
swc_bundler:
 - [x] Fix wrapped esms. (denoland/deno#9307)
 - [x] Make test secure.
2021-03-02 17:33:03 +09:00

22 lines
591 B
TypeScript

// Loaded from https://deno.land/x/dndb@0.2.4/src/methods/find.js
import { matches, project } from '../../deps.ts';
import { ReadFileStream } from '../storage.ts';
export default async (filename, query, projection) => {
let stream = new ReadFileStream(filename);
let found = [];
query = query || {};
stream.on('document', obj => {
if (matches(query , obj)){
obj = Object.keys(projection).length ? project(obj, projection) : obj;
found.push(obj)
}
})
return new Promise((resolve, reject) => {
stream.on('end', () => {
resolve(found);
})
})
}