UNPKG

@pubby/sdk

Version:
21 lines (16 loc) 522 B
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var transform = require('../lib/transform.js'); var polyfills = require('../../polyfills.js'); function throttle(time) { if (time === void 0) { time = 500; } var lastTime = 0; return new transform.Transform(function (data, cb) { var now = polyfills.performance.now(); if (lastTime + time <= now) { cb(null, data); lastTime = now; } }); } exports.throttle = throttle;