index.js
This file
Path
src/index.js
43 lines · 705 bytes · JavaScript
Last changed by
chore: dedicated string vs number var usage;Luke Edwardsbefore adoption554ad31
History of this fileTake it
import module logicLuke Edwardsbefore adoption30520d3
lines 1–2why, one step back1function toVal(mix) {2 var k, y, str='';fix: guard all `toVal` calls;Luke Edwardsbefore adoption019ec02
line 3why, one step back3fix: reorder typeof checksLuke Edwardsbefore adoption08a5a7f
lines 4–6why, one step back4 if (typeof mix === 'string' || typeof mix === 'number') {5 str += mix;6 } else if (typeof mix === 'object') {fix: guard all `toVal` calls;Luke Edwardsbefore adoption019ec02
line 7why, one step back7 if (Array.isArray(mix)) {chore: cache arguments/array lengths (#26)Jalal azimibefore adoptiondeff09b
lines 8–9why, one step back8 var len=mix.length;9 for (k=0; k < len; k++) {fix: guard all `toVal` calls;Luke Edwardsbefore adoption019ec02
line 10why, one step back10 if (mix[k]) {fix: use falsey check from arguments;Luke Edwardsbefore adoption4fa8811
line 11why, one step back11 if (y = toVal(mix[k])) {chore: rearrange pkg keysLuke Edwardsbefore adoption42bf238
lines 12–14why, one step back12 str && (str += ' ');13 str += y;14 }fix: separate object vs array loopLuke Edwardsbefore adoption91f5e68
line 15why, one step back15 }fix: guard all `toVal` calls;Luke Edwardsbefore adoption019ec02
lines 16–17why, one step back16 }17 } else {chore: dedicated string vs number var usage;Luke Edwardsbefore adoption554ad31
lines 18–19why, one step back18 for (y in mix) {19 if (mix[y]) {fix: guard all `toVal` calls;Luke Edwardsbefore adoption019ec02
line 20why, one step back20 str && (str += ' ');chore: dedicated string vs number var usage;Luke Edwardsbefore adoption554ad31
line 21why, one step back21 str += y;import module logicLuke Edwardsbefore adoption30520d3
lines 22–25why, one step back22 }23 }24 }25 }fix: guard all `toVal` calls;Luke Edwardsbefore adoption019ec02
line 26why, one step back26import module logicLuke Edwardsbefore adoption30520d3
lines 27–29why, one step back27 return str;28}29feat: add named `clsx` export alias (#44)danikazebefore adoption56ab81f
line 30why, one step back30export function clsx() {chore: cache arguments/array lengths (#26)Jalal azimibefore adoptiondeff09b
lines 31–33why, one step back31 var i=0, tmp, x, str='', len=arguments.length;32 for (; i < len; i++) {33 if (tmp = arguments[i]) {fix: use falsey check from arguments;Luke Edwardsbefore adoption4fa8811
lines 34–37why, one step back34 if (x = toVal(tmp)) {35 str && (str += ' ');36 str += x37 }import module logicLuke Edwardsbefore adoption30520d3
lines 38–40why, one step back38 }39 }40 return str;41}feat: add named `clsx` export alias (#44)danikazebefore adoption56ab81f
lines 42–43why, one step back4243export default clsx;