one-spaces
Advanced tools
Comparing version 1.0.1 to 1.0.2
/** | ||
* @author TroyTae | ||
* @version 1.0.1 | ||
* @version 1.0.2 | ||
* @name one-spaces | ||
@@ -8,33 +8,18 @@ */ | ||
function joinClassName(className1, className2) { | ||
if (className1) { | ||
className1 += ' '; | ||
} | ||
return className1 + className2; | ||
} | ||
function index () { | ||
function OneSpaces() { | ||
var | ||
key, | ||
argument, | ||
index = arguments.length, | ||
arg, | ||
args = arguments, | ||
index = args.length, | ||
className = '' | ||
; | ||
while (index--) { | ||
if (argument = arguments[index]) { | ||
if (typeof argument == 'string') { | ||
className = joinClassName(className, argument); | ||
} else if (Array.isArray(argument)) { | ||
key = argument.length; | ||
while (key--) { | ||
if (argument[key]) { | ||
className = joinClassName(className, argument[key]); | ||
} | ||
} | ||
if (arg = args[index]) { | ||
if (className) { | ||
className += ' '; | ||
} | ||
if (Array.isArray(arg)) { | ||
className += OneSpaces.apply(null, arg); | ||
} else { | ||
for (key in argument) { | ||
if (argument[key]) { | ||
className = joinClassName(className, key); | ||
} | ||
} | ||
className += arg; | ||
} | ||
@@ -46,2 +31,2 @@ } | ||
module.exports = index; | ||
module.exports = OneSpaces; |
@@ -1,1 +0,1 @@ | ||
var OneSpaces=function(){function e(e,n){return e&&(e+=" "),e+n}return function(){var n,r,i=arguments.length,t="";while(i--)if(r=arguments[i])if("string"==typeof r)t=e(t,r);else if(Array.isArray(r)){n=r.length;while(n--)r[n]&&(t=e(t,r[n]))}else for(n in r)r[n]&&(t=e(t,n));return t}}(); | ||
var OneSpaces=function r(){var a,n=arguments,e=n.length,l="";while(e--)(a=n[e])&&(l&&(l+=" "),Array.isArray(a)?l+=r.apply(null,a):l+=a);return l}; |
{ | ||
"name": "one-spaces", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "A tiny module for making className 😎", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -5,3 +5,3 @@ # One Spaces | ||
## Performance | ||
I wanna create a small and fast module. | ||
I wanna create a small and fast library. | ||
Please see our [benchmark](./bench/README.md) test result! | ||
@@ -28,3 +28,3 @@ | ||
```javascript | ||
OneSpacesMin('cls1', 'cls2'); | ||
OneSpaces('cls1', 'cls2'); | ||
``` | ||
@@ -35,9 +35,9 @@ | ||
```javascript | ||
OneSpacesMin(['cls1', 'cls2']); | ||
OneSpaces(['cls1', 'cls2']); | ||
``` | ||
### object | ||
### exclude falsy | ||
```javascript | ||
OneSpacesMin({ cls1: true, cls2: false }); | ||
OneSpaces(null, true && 'cls1', false && 'cls2'); | ||
``` | ||
@@ -48,3 +48,3 @@ | ||
```javascript | ||
OneSpacesMin('cls1', { none: false }, ['cls2']); | ||
OneSpaces('cls1', false && 'none', ['cls2']); | ||
``` | ||
@@ -51,0 +51,0 @@ |
Sorry, the diff of this file is not supported yet
9325
28