@pubby/sdk
Version:
Pubby Development Kit
17 lines (14 loc) • 419 B
JavaScript
import { Transform } from '../lib/transform.js';
import { performance } from '../../polyfills.js';
function throttle(time) {
if (time === void 0) { time = 500; }
var lastTime = 0;
return new Transform(function (data, cb) {
var now = performance.now();
if (lastTime + time <= now) {
cb(null, data);
lastTime = now;
}
});
}
export { throttle };