Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
styleh-components / src / deps / css / stringify / compiler.ts
Size: Mime:
/**
 * Expose `Compiler`.
 */

/**
 * Initialize a compiler.
 *
 * @param {Type} name
 * @return {Type}
 * @api public
 */

function Compiler(opts) {
  this.options = opts || {}
}

/**
 * Emit `str`
 */

Compiler.prototype.emit = function(str) {
  return str
}

/**
 * Visit `node`.
 */

Compiler.prototype.visit = function(node) {
  return this[node.type](node)
}

/**
 * Map visit over array of `nodes`, optionally using a `delim`
 */

Compiler.prototype.mapVisit = function(nodes, delim) {
  let buf = ''
  delim = delim || ''

  for (let i = 0, length = nodes.length; i < length; i++) {
    buf += this.visit(nodes[i])
    if (delim && i < length - 1) {
      buf += this.emit(delim)
    }
  }

  return buf
}

export default Compiler