mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-03 00:27:50 +00:00
Remove semicolons.
This commit is contained in:
30
cond.js
30
cond.js
@@ -1,5 +1,5 @@
|
||||
import apply from './.internal/apply.js';
|
||||
import arrayMap from './.internal/arrayMap.js';
|
||||
import apply from './.internal/apply.js'
|
||||
import arrayMap from './.internal/arrayMap.js'
|
||||
|
||||
/**
|
||||
* Creates a function that iterates over `pairs` and invokes the corresponding
|
||||
@@ -17,36 +17,36 @@ import arrayMap from './.internal/arrayMap.js';
|
||||
* [matches({ 'a': 1 }), constant('matches A')],
|
||||
* [conforms({ 'b': isNumber }), constant('matches B')],
|
||||
* [stubTrue, constant('no match')]
|
||||
* ]);
|
||||
* ])
|
||||
*
|
||||
* func({ 'a': 1, 'b': 2 });
|
||||
* func({ 'a': 1, 'b': 2 })
|
||||
* // => 'matches A'
|
||||
*
|
||||
* func({ 'a': 0, 'b': 1 });
|
||||
* func({ 'a': 0, 'b': 1 })
|
||||
* // => 'matches B'
|
||||
*
|
||||
* func({ 'a': '1', 'b': '2' });
|
||||
* func({ 'a': '1', 'b': '2' })
|
||||
* // => 'no match'
|
||||
*/
|
||||
function cond(pairs) {
|
||||
const length = pairs == null ? 0 : pairs.length;
|
||||
const length = pairs == null ? 0 : pairs.length
|
||||
|
||||
pairs = !length ? [] : arrayMap(pairs, pair => {
|
||||
if (typeof pair[1] != 'function') {
|
||||
throw new TypeError('Expected a function');
|
||||
throw new TypeError('Expected a function')
|
||||
}
|
||||
return [pair[0], pair[1]];
|
||||
});
|
||||
return [pair[0], pair[1]]
|
||||
})
|
||||
|
||||
return (...args) => {
|
||||
let index = -1;
|
||||
let index = -1
|
||||
while (++index < length) {
|
||||
const pair = pairs[index];
|
||||
const pair = pairs[index]
|
||||
if (apply(pair[0], this, args)) {
|
||||
return apply(pair[1], this, args);
|
||||
return apply(pair[1], this, args)
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export default cond;
|
||||
export default cond
|
||||
|
||||
Reference in New Issue
Block a user