GitXplorerGitXplorer
o

thermite

public
60 stars
1 forks
1 issues

Commits

List of commits on branch master.
Unverified
b1d7a4f100c6b2122adb8211a18c049e7af5d116

Add test for bizarre constructor semantics

oomphalos committed 8 years ago
Unverified
2ee21db31c79db2e03d5bb4b4e061956d535603c

Add tests for classes

oomphalos committed 8 years ago
Unverified
98c7bf7afc3d1a46fc2a94729797f2ae1330bdc1

Add browserify

oomphalos committed 8 years ago
Unverified
fb07fef9615ccdf428519867f98ec94970aa3700

Bump version to 0.0.8

oomphalos committed 8 years ago
Unverified
9d9a2e9b0a5af714bbd69c0b31d7b485704ddd68

Rebuild

oomphalos committed 8 years ago
Unverified
2ebe3d4675d69e5b1d87a9bab0045b2f808dbacf

Bump version to 0.0.7

oomphalos committed 8 years ago

README

The README file for this repository.

Thermite

Build Status Coverage

Thermite gives you an API for programmatically live reloading code.

Its main purpose is to act like a library used by development and (experimentally) deployment tools.

Comparison with native browser live code reloading

I love native browser live code reloading and use it in normal development. Nevertheless there are advantages to doing live code reloading with a library.

  • Most runtimes currently do not support live code reloading, so on many browsers, if you want this feature, you're out of luck.
  • Browsers that do support this don't offer direct access to this feature from inside your program.

Thermite doesn't have these restrictions.

I'm not complaining about native browser reloading - I think it's great. But I think there's utility in having a library that gives you direct programmatic access to hot code swapping cross browser.

Demo

The demo is here.

Check it out!

Set Up

If you are using Node, first, npm install thermite, then var thermite = require('thermite')

If you are using the browser, use thermite.min.js. thermite is exposed as a global variable. Or just use browserify.

Basic usage

var hotSwappableCode = thermite.eval('(' + function() {
  document.addEventListener("mousemove", function(evt) {
    console.log(evt.clientX * evt.clientY)
  })
} + ')()')

hotSwappableCode.hotSwap('(' + function() {
  document.addEventListener("mousemove", function(evt) {
    console.log(evt.clientX + evt.clientY)
  })
} + ')()')

Calling hotSwap here doesn't add a second event listener to the DOM. It effectively replaces the reference to the event listener stored in the DOM with a new one.

How it works

Thermite works by rewriting code and proxying each function.

Additionally it stores the initial version of your code in a map.

When you call hotSwap, thermite runs a diff to identify how functions change. It uses this diff to update the map.

Whenever a function runs, it checks its version. When a function finds that its version is lower than the one in the map, it evals the new function (creating it in the proper scope).

License

MIT