one-spaces
Advanced tools
Comparing version 0.7.2 to 0.8.1
/** | ||
* @author TroyTae | ||
* @version 0.7.2 | ||
* @version 0.8.1 | ||
* @name one-spaces | ||
@@ -8,43 +8,50 @@ */ | ||
function isString(str) { | ||
return typeof str === 'string'; | ||
function OneSpaces() { | ||
this.className = ''; | ||
} | ||
function spaceAfterClassName(className) { | ||
return className + ' '; | ||
} | ||
OneSpaces.prototype.addClassName = function(className) { | ||
if (this.className) { | ||
this.className += ' '; | ||
} | ||
this.className += className; | ||
}; | ||
OneSpaces.prototype.setClassNameByArgument = function(argument) { | ||
if (argument) { | ||
if (typeof argument === 'string') { | ||
this.addClassName(argument); | ||
} else if (typeof argument === 'object') { | ||
this.setClassNameByObject(argument); | ||
} | ||
} | ||
}; | ||
OneSpaces.prototype.setClassNameByObject = function(argument) { | ||
var key; | ||
if (Array.isArray(argument)) { | ||
key = argument.length; | ||
while (key--) { | ||
this.setClassNameByArgument(argument[key]); | ||
} | ||
} else { | ||
for (key in argument) { | ||
if (argument[key]) { | ||
this.addClassName(key); | ||
} | ||
} | ||
} | ||
}; | ||
function index () { | ||
var | ||
i = arguments.length, | ||
key, | ||
item, | ||
argument, | ||
className = '' | ||
instance = new OneSpaces() | ||
; | ||
while (i--) { | ||
if (argument = arguments[i]) { | ||
if (typeof argument === 'object') { | ||
if (Array.isArray(argument)) { | ||
key = argument.length; | ||
while (key--) { | ||
if ((item = argument[key]) && isString(item)) { | ||
className += spaceAfterClassName(item); | ||
} | ||
} | ||
} else { | ||
for (key in argument) { | ||
if (argument[key]) { | ||
className += spaceAfterClassName(key); | ||
} | ||
} | ||
} | ||
} else if (isString(argument)) { | ||
className += spaceAfterClassName(argument); | ||
} | ||
} | ||
instance.setClassNameByArgument(arguments[i]); | ||
} | ||
return className; | ||
return instance.className; | ||
} | ||
module.exports = index; |
@@ -1,1 +0,1 @@ | ||
var OneSpaces=function(){"use strict";function e(e){return"string"==typeof e}function n(e){return e+" "}return function(){var r,t,i,f=arguments.length,u="";while(f--)if(i=arguments[f])if("object"==typeof i)if(Array.isArray(i)){r=i.length;while(r--)(t=i[r])&&e(t)&&(u+=n(t))}else for(r in i)i[r]&&(u+=n(r));else e(i)&&(u+=n(i));return u}}(); | ||
var OneSpaces=function(){"use strict";function s(){this.className=""}return s.prototype.addClassName=function(s){this.className&&(this.className+=" "),this.className+=s},s.prototype.setClassNameByArgument=function(s){s&&("string"==typeof s?this.addClassName(s):"object"==typeof s&&this.setClassNameByObject(s))},s.prototype.setClassNameByObject=function(s){var e;if(Array.isArray(s)){e=s.length;while(e--)this.setClassNameByArgument(s[e])}else for(e in s)s[e]&&this.addClassName(e)},function(){var e=arguments.length,t=new s;while(e--)t.setClassNameByArgument(arguments[e]);return t.className}}(); |
{ | ||
"name": "one-spaces", | ||
"version": "0.7.2", | ||
"version": "0.8.1", | ||
"description": "A tiny module for making className 😎", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -1,40 +0,47 @@ | ||
function isString(str) { | ||
return typeof str === 'string'; | ||
function OneSpaces() { | ||
this.className = ''; | ||
} | ||
function spaceAfterClassName(className) { | ||
return className + ' '; | ||
} | ||
OneSpaces.prototype.addClassName = function(className) { | ||
if (this.className) { | ||
this.className += ' '; | ||
} | ||
this.className += className; | ||
}; | ||
OneSpaces.prototype.setClassNameByArgument = function(argument) { | ||
if (argument) { | ||
if (typeof argument === 'string') { | ||
this.addClassName(argument); | ||
} else if (typeof argument === 'object') { | ||
this.setClassNameByObject(argument); | ||
} | ||
} | ||
}; | ||
OneSpaces.prototype.setClassNameByObject = function(argument) { | ||
var key; | ||
if (Array.isArray(argument)) { | ||
key = argument.length; | ||
while (key--) { | ||
this.setClassNameByArgument(argument[key]); | ||
} | ||
} else { | ||
for (key in argument) { | ||
if (argument[key]) { | ||
this.addClassName(key); | ||
} | ||
} | ||
} | ||
}; | ||
export default function () { | ||
var | ||
i = arguments.length, | ||
key, | ||
item, | ||
argument, | ||
className = '' | ||
instance = new OneSpaces() | ||
; | ||
while (i--) { | ||
if (argument = arguments[i]) { | ||
if (typeof argument === 'object') { | ||
if (Array.isArray(argument)) { | ||
key = argument.length; | ||
while (key--) { | ||
if ((item = argument[key]) && isString(item)) { | ||
className += spaceAfterClassName(item); | ||
} | ||
} | ||
} else { | ||
for (key in argument) { | ||
if (argument[key]) { | ||
className += spaceAfterClassName(key); | ||
} | ||
} | ||
} | ||
} else if (isString(argument)) { | ||
className += spaceAfterClassName(argument); | ||
} | ||
} | ||
instance.setClassNameByArgument(arguments[i]); | ||
} | ||
return className; | ||
return instance.className; | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8058
116