Skip to content

Commit 2dc4cf2

Browse files
committed
Fee-fi-fo-fum!
1 parent 55d4af6 commit 2dc4cf2

File tree

2 files changed

+9
-29
lines changed

2 files changed

+9
-29
lines changed

README.md

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,7 @@ import cc from "classcat"
5454
If you prefer not to use a build system, you can load Classcat from a CDN and it will be globally available through the `window.classcat` object.
5555

5656
```html
57-
<!doctype html>
58-
<html>
59-
<body>
60-
<script src="https://unpkg.com/classcat"></script>
61-
<script>
62-
63-
const cc = classcat
64-
65-
</script>
66-
</body>
67-
</html>
57+
<script src="//unpkg.com/classcat"></script>
6858
```
6959

7060
## Usage
@@ -100,7 +90,7 @@ cc([
10090

10191
## Credits
10292

103-
Classcat is inspired by [JedWatson/classNames](https://github.com/JedWatson/classnames) with support for nested objects and [better performance](/bench/README.md).
93+
Classcat is an alternative to [JedWatson/classNames](https://github.com/JedWatson/classnames) with support for nested objects and [superior performance](/bench/README.md).
10494
The difference between classcat and classNames is that classNames accepts a [variable number of arguments](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments), whereas classcat only accepts a single argument.
10595

10696
```js

src/index.js

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export default function cc(classes, prefix) {
2-
var value
3-
var classNames = ""
2+
var next
43
var type = typeof classes
4+
var result = ""
55

66
prefix = prefix || ""
77

@@ -15,27 +15,17 @@ export default function cc(classes, prefix) {
1515

1616
if (Array.isArray(classes) && classes.length > 0) {
1717
for (var i = 0, len = classes.length; i < len; i++) {
18-
if ((value = cc(classes[i], prefix))) {
19-
classNames += (classNames && " ") + value
18+
if ((next = cc(classes[i], prefix))) {
19+
result += (result && " ") + next
2020
}
2121
}
2222
} else if (type === "object") {
2323
for (var key in classes) {
24-
if ((value = cc(classes[key], prefix + key))) {
25-
classNames += (classNames && " ") + value
24+
if ((next = cc(classes[key], prefix + key))) {
25+
result += (result && " ") + next
2626
}
2727
}
2828
}
2929

30-
return classNames
30+
return result
3131
}
32-
33-
/*
34-
case "object":
35-
for (var key in classes) {
36-
if (next = cc(classes[key], prefix + (isNaN(key) ? key : ""))) {
37-
classNames += (classNames ? " " : "") + next;
38-
}
39-
}
40-
return classNames;
41-
*/

0 commit comments

Comments
 (0)