antv-l7/node_modules/unist-builder/index.js

28 lines
480 B
JavaScript

'use strict'
var assign = require('object-assign')
module.exports = u
function u(type, props, value) {
var node
if (
(value === null || value === undefined) &&
(typeof props !== 'object' || Array.isArray(props))
) {
value = props
props = {}
}
node = assign({type: String(type)}, props)
if (Array.isArray(value)) {
node.children = value
} else if (value !== null && value !== undefined) {
node.value = String(value)
}
return node
}