wip: migrate to bun

This commit is contained in:
jdalton
2023-09-16 14:47:50 -07:00
parent 2da024c3b4
commit 97d4a2fe19
1052 changed files with 30244 additions and 26856 deletions

36
test/once.spec.ts Normal file
View File

@@ -0,0 +1,36 @@
import assert from 'node:assert';
import { _ } from './utils';
describe('once', () => {
it('should invoke `func` once', () => {
let count = 0,
once = _.once(() => ++count);
once();
assert.strictEqual(once(), 1);
assert.strictEqual(count, 1);
});
it('should ignore recursive calls', () => {
let count = 0;
var once = _.once(() => {
once();
return ++count;
});
assert.strictEqual(once(), 1);
assert.strictEqual(count, 1);
});
it('should not throw more than once', () => {
const once = _.once(() => {
throw new Error();
});
assert.throws(once);
once();
assert.ok(true);
});
});