const multipleCalls = require('zhf.multiple-calls');
// 传入正常参数
let isTrigger = false;
const mulCalls = multipleCalls(3, function (result) {
isTrigger = true;
console.log('result', result); // result { a: { a: 1 }, b: { b: 2 }, c: { c: 3 } }
});
mulCalls('a', {a: 1}); // isTrigger is false
mulCalls('b', {b: 2}); // isTrigger is false
mulCalls('c', {c: 3}); // isTrigger is true
// 参入非法参数时,第一参数非法会被纠正成1,第二参数非法会被纠正成空函数
let isTrigger2 = false;
const mulCalls2 = multipleCalls('非法参数', function (result) {
isTrigger2 = true;
console.log('result', result); // result { a: { a: 1 } }
});
mulCalls2('a', {a: 1}); // isTrigger2 is true
// 传入正常参数
let isTrigger3 = false;
const mulCalls3 = multipleCalls(1, function (result) {
isTrigger3 = true;
console.log('result', result); // result {}
});
mulCalls3(); // isTrigger3 is true
zhouhuafei/zhf.multiple-calls
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
No description, website, or topics provided.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published