Skip to content

Instantly share code, notes, and snippets.

@andyperlitch
andyperlitch / suite.bundle.js
Created September 25, 2013 00:41
An example test suite bundled by browserify
;(function(e,t,n){function i(n,s){if(!t[n]){if(!e[n]){var o=typeof require=="function"&&require;if(!s&&o)return o(n,!0);if(r)return r(n,!0);throw new Error("Cannot find module '"+n+"'")}var u=t[n]={exports:{}, cache:t, map:e[n][1]};e[n][0].call(u.exports,function(t){var r=e[n][1][t];return i(r?r:t)},u,u.exports)}return t[n].exports}var r=typeof require=="function"&&require;for(var s=0;s<n.length;s++)i(n[s]);return i})({1:[function(require,module,exports){
require('./test.spec');
},{"./test.spec":2}],2:[function(require,module,exports){
describe('a basic test suite', function() {
it('should have expect', function() {
expect(expect).to.be.a('function');
});
it('should have two tests', function() {
var originals = {};
exports = module.exports = {
registerMock: function(key, mock, module) {
var map = module.map;
var cache = module.cache;
exports = module.exports = function() {
return "hello";
}
@andyperlitch
andyperlitch / Pretty-Print-Bundle.js
Created July 9, 2013 01:25
A browserify bundle, with better variable names and formatting for better understanding.
;(function(mod_hash, cache_hash, entryArray) {
// Check if require is defined elsewhere
var outerRequire = typeof require == "function" && require;
function invokeModule(index, tried) {
if (!cache_hash[index]) {
// Not in the overrides hash
@andyperlitch
andyperlitch / make_bundle.sh
Last active December 19, 2015 09:49
Testing setup with Blanket.js coverage for Browserify
browserify test/test.bundle.entry.js > test.bundle.js
@andyperlitch
andyperlitch / gist:5454868
Created April 24, 2013 19:30
a simple extension to Backbone.Collection.set method
var oldSet = Backbone.Collection.prototype.set;
Backbone.Collection.prototype.set = function(models, options) {
options = options || {};
oldSet.call(this, models, options);
if (options.silent) return this;
this.trigger('update', this, options);
}
@andyperlitch
andyperlitch / gist:5199751
Created March 19, 2013 20:23
hbs precompile transform
var browserify = require('browserify');
var Stream = require('stream');
// ----------------------------------
// Compile handlebars templates
// ----------------------------------
function createHBTplStream(file) {
var s = new Stream;
s.writable = true;
npm info it worked if it ends with ok
npm verb cli [ 'node', '/usr/local/bin/npm', 'install', '.', '-dd' ]
npm info using npm@1.2.0
npm info using node@v0.8.17
npm verb read json /Users/andyperlitch/malhar/malhar-front/package.json
npm verb readDependencies using package.json deps
npm verb install where, deps [ '/Users/andyperlitch/malhar/malhar-front',
npm verb install [ 'optimist',
npm verb install 'chart',
npm verb install 'ecstatic',