Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR-URL: #266 Credit: @eugene1g Close: #266 Reviewed-by: @isaacs EDIT(@isaacs): edited to move the test into a test file, and run the build before running tests, and specify TS types explicitly for both export types, and document the hybridness.
- Loading branch information
Showing
5 changed files
with
45 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
/nyc_output | ||
/coverage | ||
/bundle | ||
/index.mjs |
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
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,9 @@ | ||
#!/usr/bin/env node | ||
|
||
import { readFile, writeFile } from 'node:fs/promises' | ||
const cjs = await readFile( | ||
new URL('../index.js', import.meta.url), | ||
'utf8' | ||
) | ||
const esm = cjs.replace(/module.exports\s*=\s*/, 'export default ') | ||
await writeFile(new URL('../index.mjs', import.meta.url), esm, 'utf8') |
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,10 @@ | ||
import t from 'tap' | ||
import LRUCache from '../index.mjs' | ||
const c = new LRUCache({ max: 2 }) | ||
t.type(c, LRUCache) | ||
c.set(1, 1) | ||
c.set(2, 2) | ||
c.set(3, 3) | ||
t.equal(c.get(1), undefined) | ||
t.equal(c.get(2), 2) | ||
t.equal(c.get(3), 3) |