{"ScriptPreparationCode":null,"TestCases":[{"Name":"Lodash","Code":"// call once every 1000ms\r\nvar sec = _.throttle(function () {\r\n console.log(\u0027every second\u0027);\r\n }, 1000);\r\n// call every 100ms\r\nvar hundredMS = _.throttle(function () {\r\n console.log(\u0027every one hundred ms\u0027);\r\n }, 100);\r\n// a loop for every 33ms\r\nvar loop = function () {\r\n setTimeout(loop, 33)\r\n sec();\r\n hundredMS();\r\n};\r\n// start loop\r\nloop();","IsDeferred":false},{"Name":"Native ","Code":"var throttle = function (func, rate) {\r\n var lastTime = new Date();\r\n func = func || function () {};\r\n rate = rate || 1000;\r\n // the inner method\r\n return function () {\r\n var now = new Date();\r\n if (now - lastTime \u003E= rate) {\r\n func();\r\n lastTime = now;\r\n }\r\n };\r\n};\r\n\r\nvar sec = throttle(function () {\r\n console.log(\u0027one sec\u0027);\r\n }, 1000);\r\n// using it in a loop\r\nvar loop = function () {\r\n setTimeout(loop, 33);\r\n sec();\r\n};\r\nloop();","IsDeferred":false}]}