Skip to content

Commit 249916b

Browse files
committed
Refactor to improve bundle size
1 parent 80b0e94 commit 249916b

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

index.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,17 @@
33
module.exports = u
44

55
function u(type, props, value) {
6-
var node
6+
var node = {type: String(type)}
77

8-
if (
9-
(value === null || value === undefined) &&
10-
(typeof props !== 'object' || Array.isArray(props))
11-
) {
8+
if (value == null && (typeof props !== 'object' || Array.isArray(props))) {
129
value = props
13-
props = {}
10+
} else {
11+
Object.assign(node, props)
1412
}
1513

16-
node = Object.assign({type: String(type)}, props)
17-
1814
if (Array.isArray(value)) {
1915
node.children = value
20-
} else if (value !== null && value !== undefined) {
16+
} else if (value != null) {
2117
node.value = String(value)
2218
}
2319

package.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,17 @@
7272
"esnext": false,
7373
"ignore": [
7474
"types/"
75-
]
75+
],
76+
"rules": {
77+
"eqeqeq": [
78+
"error",
79+
"always",
80+
{
81+
"null": "ignore"
82+
}
83+
],
84+
"no-eq-null": "off"
85+
}
7686
},
7787
"remarkConfig": {
7888
"plugins": [

0 commit comments

Comments
 (0)