-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
1,196 additions
and
934 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,5 @@ | ||
node_modules | ||
.DS_Store | ||
*-lock.json | ||
*.lock | ||
*.log | ||
|
||
/coverage | ||
/.nyc_output | ||
|
||
# Editors | ||
*.iml | ||
/.idea | ||
/.vscode | ||
|
||
# Code | ||
/index.* | ||
/cache.* | ||
node_modules | ||
/npm | ||
*.lcov | ||
/cov |
This file was deleted.
Oops, something went wrong.
Empty file.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { suite } from 'npm:@marais/bench'; | ||
import DataLoader from 'npm:dataloader'; | ||
import * as dldr from '../mod.ts'; | ||
import * as dldrCache from '../cache/mod.ts'; | ||
|
||
const loadFn: dldr.LoadFn<any, string> = async (keys: string[]) => Promise.resolve(keys); | ||
|
||
await suite<any[]>( | ||
{ | ||
dldr: () => { | ||
return (keys) => Promise.all(keys.map((key) => dldr.load(loadFn, key))); | ||
}, | ||
'dldr/cache': () => { | ||
const cache = new Map(); | ||
return (keys) => | ||
Promise.all( | ||
keys.map((key) => dldrCache.load(loadFn, cache, key)), | ||
); | ||
}, | ||
dataloader: () => { | ||
const loader = new DataLoader(loadFn as any, { | ||
cache: false, | ||
}); | ||
|
||
return (keys) => loader.loadMany(keys); | ||
}, | ||
'dataloader/cache': () => { | ||
const loader = new DataLoader(loadFn as any, { | ||
cache: true, | ||
}); | ||
|
||
return (keys) => loader.loadMany(keys); | ||
}, | ||
}, | ||
(run) => { | ||
const keys = ['a', 'b', 'c', 'a']; | ||
run( | ||
undefined, | ||
() => keys, | ||
(results) => results.every((result, i) => result === keys[i]), | ||
); | ||
}, | ||
); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.