Socket
Book a DemoInstallSign in
Socket

hyperxify

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hyperxify

browserify transform for hyperx

Source
npmnpm
Version
1.1.0
Version published
Weekly downloads
1
-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

hyperxify

browserify transform for hyperx

This module will compile your hyperx template strings down to javascript expressions so that you don't need to send the hyperx library over the wire.

example

Given some hyperx code:

var vdom = require('virtual-dom')
var hyperx = require('hyperx')
var hx = hyperx(vdom.h)

var main = require('main-loop')
var loop = main({ times: 0 }, render, vdom)
document.querySelector('#content').appendChild(loop.target)

function render (state) {
  return hx`<div>
    <h1>clicked ${state.times} times</h1>
    <button onclick=${onclick}>click me!</button>
  </div>`

  function onclick () {
    loop.update({ times: state.times + 1 })
  }
}

Compile with browserify using -t hyperxify:

$ browserify -t hyperxify main.js > bundle.js

If you look in the bundle.js file, you can see that the hyperx template strings have been replaced with calls to vdom.h, which is how hyperx was invoked:

$ <bundle.js head -n16 | tail -n+2
var vdom = require('virtual-dom')
var hyperx = 0
var hx = 0

var main = require('main-loop')
var loop = main({ times: 0 }, render, vdom)
document.querySelector('#content').appendChild(loop.target)

function render (state) {
  return vdom.h("div",{},["\n    ",vdom.h("h1",{},["clicked ",state.times," times"]),"\n    ",vdom.h("button",{"onclick":onclick},["click me!"]),"\n  "])

  function onclick () {
    loop.update({ times: state.times + 1 })
  }
}

license

BSD

Keywords

hyperx

FAQs

Package last updated on 22 Jan 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts