-
Notifications
You must be signed in to change notification settings - Fork 3
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
6 changed files
with
122 additions
and
5 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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: Build | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
lint: | ||
name: Lint | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Setup | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 20.x | ||
|
||
- name: Install tools | ||
run: npm install --location=global bslint | ||
|
||
- name: Install dependencies | ||
run: npm install | ||
|
||
- name: Lint | ||
run: npm run lint | ||
|
||
test: | ||
name: Test | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest] | ||
node: [16.x, 18.x, 20.x] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node }} | ||
|
||
- name: Install dependencies | ||
run: npm install | ||
|
||
- name: Test | ||
run: npm test | ||
|
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,3 +1,5 @@ | ||
'use strict'; | ||
|
||
module.exports = require('./lru'); | ||
const LRU = require('./lru'); | ||
|
||
module.exports = LRU; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 |
---|---|---|
|
@@ -15,14 +15,14 @@ | |
"author": "Christopher Jeffrey <[email protected]>", | ||
"main": "./lib/blru.js", | ||
"scripts": { | ||
"lint": "eslint lib/ test/ || exit 0", | ||
"lint": "eslint lib/ test/", | ||
"test": "bmocha --reporter spec test/*-test.js" | ||
}, | ||
"dependencies": { | ||
"bsert": "~0.0.10" | ||
"bsert": "~0.0.12" | ||
}, | ||
"devDependencies": { | ||
"bmocha": "^2.1.0" | ||
"bmocha": "^2.1.8" | ||
}, | ||
"engines": { | ||
"node": ">=8.0.0" | ||
|
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,23 @@ | ||
'use strict'; | ||
|
||
const assert = require('bsert'); | ||
const LRU = require('../lib/lru'); | ||
|
||
describe('LRU', function() { | ||
it('should test lru', () => { | ||
const cap = 10; | ||
const all = 100; | ||
const lru = new LRU(cap); | ||
|
||
for (let i = 0; i < all; i++) | ||
lru.set(i, i); | ||
|
||
for (let i = 0; i < all - cap; i++) | ||
assert(!lru.has(i)); | ||
|
||
for (let i = all - cap; i < all; i++) { | ||
assert(lru.has(i)); | ||
assert.strictEqual(lru.get(i), i); | ||
} | ||
}); | ||
}); |