initial commit

This commit is contained in:
2025-09-01 22:12:29 +02:00
parent b1873f9c1d
commit 02a54f61c0
5598 changed files with 903558 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
const memoizer = require('./..');
const assert = require('chai').assert;
const _ = require('lodash');
describe('lru-simultaneos calls', function () {
var loadTimes = 0, memoized;
beforeEach(function () {
loadTimes = 0;
memoized = memoizer({
load: function (a, b, callback) {
loadTimes++;
setTimeout(function () {
callback(null, a + b);
}, 100);
},
hash: function (a, b) {
return a + '-' + b;
},
max: 10
});
});
it('should call once', function (done) {
memoized(1, 2, _.noop);
memoized(1, 2, _.noop);
memoized(1, 2, function (err, result) {
if (err) { return done(err); }
assert.strictEqual(loadTimes, 1);
assert.strictEqual(result, 3);
done();
});
});
});