Buckets:
| const FakeTimers = require('@sinonjs/fake-timers') | |
| const fs = require('fs') | |
| const SonicBoom = require('../') | |
| const { file, runTests } = require('./helper') | |
| runTests(buildTests) | |
| function buildTests (test, sync) { | |
| // Reset the umask for testing | |
| process.umask(0o000) | |
| test('periodicflush_off', (t) => { | |
| t.plan(4) | |
| const clock = FakeTimers.install() | |
| const dest = file() | |
| const fd = fs.openSync(dest, 'w') | |
| const stream = new SonicBoom({ fd, sync, minLength: 5000 }) | |
| t.ok(stream.write('hello world\n')) | |
| setTimeout(function () { | |
| fs.readFile(dest, 'utf8', function (err, data) { | |
| t.error(err) | |
| t.equal(data, '') | |
| stream.destroy() | |
| t.pass('file empty') | |
| }) | |
| }, 2000) | |
| clock.tick(2000) | |
| clock.uninstall() | |
| }) | |
| test('periodicflush_on', (t) => { | |
| t.plan(4) | |
| const clock = FakeTimers.install() | |
| const dest = file() | |
| const fd = fs.openSync(dest, 'w') | |
| const stream = new SonicBoom({ fd, sync, minLength: 5000, periodicFlush: 1000 }) | |
| t.ok(stream.write('hello world\n')) | |
| setTimeout(function () { | |
| fs.readFile(dest, 'utf8', function (err, data) { | |
| t.error(err) | |
| t.equal(data, 'hello world\n') | |
| stream.destroy() | |
| t.pass('file not empty') | |
| }) | |
| }, 2000) | |
| clock.tick(2000) | |
| clock.uninstall() | |
| }) | |
| } | |
Xet Storage Details
- Size:
- 1.36 kB
- Xet hash:
- 4f1c94319aa67a5e9d08fd9d1f175a4d7ecc4b92d783a108cb489944a4d5e646
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.