Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4400614

Browse files
committed
Ensurewait of_.debounce and_.throttle defaults to0. [closes#991]
1 parent6840b2c commit4400614

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

‎lodash.src.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7376,7 +7376,7 @@
73767376
*@memberOf _
73777377
*@category Function
73787378
*@param {Function} func The function to debounce.
7379-
*@param {number} wait The number of milliseconds to delay.
7379+
*@param {number}[wait=0] The number of milliseconds to delay.
73807380
*@param {Object} [options] The options object.
73817381
*@param {boolean} [options.leading=false] Specify invoking on the leading
73827382
* edge of the timeout.
@@ -7434,7 +7434,7 @@
74347434
if(typeoffunc!='function'){
74357435
thrownewTypeError(FUNC_ERROR_TEXT);
74367436
}
7437-
wait=wait<0 ?0 :wait;
7437+
wait=wait<0 ?0 :(+wait||0);
74387438
if(options===true){
74397439
varleading=true;
74407440
trailing=false;
@@ -7955,7 +7955,7 @@
79557955
*@memberOf _
79567956
*@category Function
79577957
*@param {Function} func The function to throttle.
7958-
*@param {number} wait The number of milliseconds to throttle invocations to.
7958+
*@param {number}[wait=0] The number of milliseconds to throttle invocations to.
79597959
*@param {Object} [options] The options object.
79607960
*@param {boolean} [options.leading=true] Specify invoking on the leading
79617961
* edge of the timeout.

‎test/test.js‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13889,6 +13889,28 @@
1388913889
ok(pass);
1389013890
});
1389113891

13892+
asyncTest('_.'+methodName+' should have a default `wait` of `0`',1,function(){
13893+
if(!(isRhino&&isModularize)){
13894+
varcallCount=0;
13895+
13896+
varfunced=func(function(){
13897+
callCount++;
13898+
});
13899+
13900+
funced();
13901+
13902+
setTimeout(function(){
13903+
funced();
13904+
strictEqual(callCount,isDebounce ?1 :2);
13905+
QUnit.start();
13906+
},32);
13907+
}
13908+
else{
13909+
skipTest();
13910+
QUnit.start();
13911+
}
13912+
});
13913+
1389213914
asyncTest('_.'+methodName+' should call `func` with the correct `this` binding',1,function(){
1389313915
if(!(isRhino&&isModularize)){
1389413916
varobject={

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp