UNPKG

tastypie

Version:

Tastypie is a webservice API framework for Node.js based on Django's Tastypie Framework. It provides a convenient, yet powerful and highly customizable, abstraction for creating REST-style interfaces

33 lines (29 loc) 808 B
define(function () { /** * Debounce callback execution */ function debounce(fn, threshold, isAsap){ var timeout, result; function debounced(){ var args = arguments, context = this; function delayed(){ if (! isAsap) { result = fn.apply(context, args); } timeout = null; } if (timeout) { clearTimeout(timeout); } else if (isAsap) { result = fn.apply(context, args); } timeout = setTimeout(delayed, threshold); return result; } debounced.cancel = function(){ clearTimeout(timeout); }; return debounced; } return debounce; });