Permalink
Browse files

fix build process; use submodules; bump version to 0.1.4; update bina…

…rypack version
  • Loading branch information...
1 parent 591c6e3 commit 28ec11739fb4cf7e8953c5ed9257e0f5b3792554 @ericz ericz committed Aug 28, 2012
Showing with 10 additions and 740 deletions.
  1. +7 −3 bin/build.js
  2. +1 −0 deps/EventEmitter
  3. +0 −161 deps/EventEmitter.js
  4. +0 −569 deps/binarypack.js
  5. +1 −0 deps/js-binarypack
  6. +0 −4 dist/binary.js
  7. +1 −3 dist/binary.min.js
View
@@ -12,7 +12,8 @@ var fs = require('fs')
* @api private
*/
-var template = '/*! binary.%ext% build:' + package.version + ', %type%. Copyright(c) 2012 Eric Zhang <eric@ericzhang.com> MIT Licensed */\n(function(exports){\n'
+var template = '/*! binary.%ext% build:' + package.version + ', %type%. Copyright(c) 2012 Eric Zhang <eric@ericzhang.com> MIT Licensed */'
+ , prefix = '\n(function(exports){\n'
, development = template.replace('%type%', 'development').replace('%ext%', 'js')
, production = template.replace('%type%', 'production').replace('%ext%', 'min.js')
, suffix = '\n})(this);\n';
@@ -37,8 +38,9 @@ var starttagIF = '// if node'
*/
var base = [
- '../deps/binarypack.js'
- , '../deps/EventEmitter.js'
+ '../deps/js-binarypack/lib/bufferbuilder.js'
+ , '../deps/js-binarypack/lib/binarypack.js'
+ , '../deps/EventEmitter/EventEmitter.js'
, 'util.js'
, 'client/stream.js'
, 'client/blob_stream.js'
@@ -114,6 +116,8 @@ var builder = module.exports = function () {
var code = development
, ignore = 0;
+ code += prefix;
+
files.forEach(function (file) {
code += results[file];
});
Submodule EventEmitter added at 5c347b
View
@@ -1,161 +0,0 @@
-/**
- * Light EventEmitter. Ported from Node.js/events.js
- * Eric Zhang
- */
-
-/**
- * EventEmitter class
- * Creates an object with event registering and firing methods
- */
-function EventEmitter() {
- // Initialise required storage variables
- this._events = {};
-}
-
-var isArray = Array.isArray;
-
-
-EventEmitter.prototype.addListener = function(type, listener, scope, once) {
- if ('function' !== typeof listener) {
- throw new Error('addListener only takes instances of Function');
- }
-
- // To avoid recursion in the case that type == "newListeners"! Before
- // adding it to the listeners, first emit "newListeners".
- this.emit('newListener', type, typeof listener.listener === 'function' ?
- listener.listener : listener);
-
- if (!this._events[type]) {
- // Optimize the case of one listener. Don't need the extra array object.
- this._events[type] = listener;
- } else if (isArray(this._events[type])) {
-
- // If we've already got an array, just append.
- this._events[type].push(listener);
-
- } else {
- // Adding the second element, need to change to array.
- this._events[type] = [this._events[type], listener];
- }
-
-};
-
-EventEmitter.prototype.on = EventEmitter.prototype.addListener;
-
-EventEmitter.prototype.once = function(type, listener, scope) {
- if ('function' !== typeof listener) {
- throw new Error('.once only takes instances of Function');
- }
-
- var self = this;
- function g() {
- self.removeListener(type, g);
- listener.apply(this, arguments);
- };
-
- g.listener = listener;
- self.on(type, g);
-
- return this;
-};
-
-EventEmitter.prototype.removeListener = function(type, listener, scope) {
- if ('function' !== typeof listener) {
- throw new Error('removeListener only takes instances of Function');
- }
-
- // does not use listeners(), so no side effect of creating _events[type]
- if (!this._events[type]) return this;
-
- var list = this._events[type];
-
- if (isArray(list)) {
- var position = -1;
- for (var i = 0, length = list.length; i < length; i++) {
- if (list[i] === listener ||
- (list[i].listener && list[i].listener === listener))
- {
- position = i;
- break;
- }
- }
-
- if (position < 0) return this;
- list.splice(position, 1);
- if (list.length == 0)
- delete this._events[type];
- } else if (list === listener ||
- (list.listener && list.listener === listener))
- {
- delete this._events[type];
- }
-
- return this;
-};
-
-
-EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
-
-
-EventEmitter.prototype.removeAllListeners = function(type) {
- if (arguments.length === 0) {
- this._events = {};
- return this;
- }
-
- // does not use listeners(), so no side effect of creating _events[type]
- if (type && this._events && this._events[type]) this._events[type] = null;
- return this;
-};
-
-EventEmitter.prototype.listeners = function(type) {
- if (!this._events[type]) this._events[type] = [];
- if (!isArray(this._events[type])) {
- this._events[type] = [this._events[type]];
- }
- return this._events[type];
-};
-
-EventEmitter.prototype.emit = function(type) {
- var type = arguments[0];
- var handler = this._events[type];
- if (!handler) return false;
-
- if (typeof handler == 'function') {
- switch (arguments.length) {
- // fast cases
- case 1:
- handler.call(this);
- break;
- case 2:
- handler.call(this, arguments[1]);
- break;
- case 3:
- handler.call(this, arguments[1], arguments[2]);
- break;
- // slower
- default:
- var l = arguments.length;
- var args = new Array(l - 1);
- for (var i = 1; i < l; i++) args[i - 1] = arguments[i];
- handler.apply(this, args);
- }
- return true;
-
- } else if (isArray(handler)) {
- var l = arguments.length;
- var args = new Array(l - 1);
- for (var i = 1; i < l; i++) args[i - 1] = arguments[i];
-
- var listeners = handler.slice();
- for (var i = 0, l = listeners.length; i < l; i++) {
- listeners[i].apply(this, args);
- }
- return true;
- } else {
- return false;
- }
-};
-
-
-
Oops, something went wrong.

0 comments on commit 28ec117

Please sign in to comment.