UNPKG

@pubby.club/sdk

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