Add compose.js

Missing docblock & tests.