Comparing version 0.1.2 to 0.1.3
@@ -57,6 +57,13 @@ "use strict"; | ||
var timer; | ||
return function () { | ||
var delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 250; | ||
return function (option) { | ||
var _ref = option || {}, | ||
_ref$delay = _ref.delay, | ||
delay = _ref$delay === void 0 ? 250 : _ref$delay, | ||
args = _ref.args, | ||
scope = _ref.scope; | ||
clearTimeout(timer); | ||
timer = setTimeout(func, defaultDelay || delay); | ||
timer = setTimeout(function () { | ||
return (0, _callfunc["default"])(func, args, scope); | ||
}, defaultDelay || delay); | ||
}; | ||
@@ -77,8 +84,12 @@ }; | ||
var run = function run() { | ||
var run = function run(option) { | ||
var _ref2 = option || {}, | ||
args = _ref2.args, | ||
scope = _ref2.scope; | ||
lastCall = false; | ||
(0, _callfunc["default"])(func); | ||
(0, _callfunc["default"])(func, args, scope); | ||
}; | ||
return function () { | ||
return function (option) { | ||
lastCall = true; | ||
@@ -88,3 +99,3 @@ | ||
waiting = true; | ||
run(); | ||
run(option); | ||
setTimeout(function () { | ||
@@ -94,3 +105,3 @@ waiting = false; | ||
if (needRunLast && lastCall) { | ||
run(); | ||
run(option); | ||
} | ||
@@ -97,0 +108,0 @@ }, threshhold); |
@@ -24,6 +24,13 @@ import callfunc from "./callfunc"; | ||
var timer; | ||
return function () { | ||
var delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 250; | ||
return function (option) { | ||
var _ref = option || {}, | ||
_ref$delay = _ref.delay, | ||
delay = _ref$delay === void 0 ? 250 : _ref$delay, | ||
args = _ref.args, | ||
scope = _ref.scope; | ||
clearTimeout(timer); | ||
timer = setTimeout(func, defaultDelay || delay); | ||
timer = setTimeout(function () { | ||
return callfunc(func, args, scope); | ||
}, defaultDelay || delay); | ||
}; | ||
@@ -42,8 +49,12 @@ }; | ||
var run = function run() { | ||
var run = function run(option) { | ||
var _ref2 = option || {}, | ||
args = _ref2.args, | ||
scope = _ref2.scope; | ||
lastCall = false; | ||
callfunc(func); | ||
callfunc(func, args, scope); | ||
}; | ||
return function () { | ||
return function (option) { | ||
lastCall = true; | ||
@@ -53,3 +64,3 @@ | ||
waiting = true; | ||
run(); | ||
run(option); | ||
setTimeout(function () { | ||
@@ -59,3 +70,3 @@ waiting = false; | ||
if (needRunLast && lastCall) { | ||
run(); | ||
run(option); | ||
} | ||
@@ -62,0 +73,0 @@ }, threshhold); |
{ | ||
"name": "call-func", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "call function", | ||
@@ -5,0 +5,0 @@ "repository": "react-atomic/react-atomic-organism", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34007
922