1.0.5 • Published 6 years ago

zhf.multiple-calls v1.0.5

Weekly downloads
3
License
ISC
Repository
github
Last release
6 years ago

至少调用多次才会触发函数

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
1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago