[Pkg-javascript-commits] [sockjs-client] 10/434: Local references to SockJS renamed to Sock, for better minification - 200 bytes saved.

Tonnerre Lombard tonnerre-guest at moszumanska.debian.org
Wed Jan 8 00:46:57 UTC 2014


This is an automated email from the git hooks/post-receive script.

tonnerre-guest pushed a commit to branch master
in repository sockjs-client.

commit dd94f5e96d314424ccd06a891e7b3febe7752fec
Author: Marek Majkowski <majek04 at gmail.com>
Date:   Sat Jul 23 21:48:38 2011 +0100

    Local references to SockJS renamed to Sock, for better minification - 200 bytes saved.
---
 lib/sockjs.js | 66 +++++++++++++++++++++++++++++------------------------------
 1 file changed, 33 insertions(+), 33 deletions(-)

diff --git a/lib/sockjs.js b/lib/sockjs.js
index f7a2084..6389aaf 100644
--- a/lib/sockjs.js
+++ b/lib/sockjs.js
@@ -1,5 +1,5 @@
 // Public object.
-SockJS = function(url, protocols, options) {
+var Sock = SockJS = function(url, protocols, options) {
     this._options = {devel: true, debug: true};
     if (typeof options !== 'undefined') {
         utils.objectExtend(this._options, options);
@@ -15,26 +15,26 @@ SockJS = function(url, protocols, options) {
     default: this._protocols = protocols; break;
     }
     this.protocol = undefined;
-    this.readyState = SockJS.CONNECTING;
+    this.readyState = Sock.CONNECTING;
     this._try_next_protocol();
 };
 // Inheritance
-SockJS.prototype = new REventTarget();
+Sock.prototype = new REventTarget();
 
-SockJS.version = "0.0.1";
+Sock.version = "0.0.1";
 
-SockJS.CONNECTING = 0;
-SockJS.OPEN = 1;
-SockJS.CLOSING = 2;
-SockJS.CLOSED = 3;
+Sock.CONNECTING = 0;
+Sock.OPEN = 1;
+Sock.CLOSING = 2;
+Sock.CLOSED = 3;
 
-SockJS.prototype._debug = function() {
+Sock.prototype._debug = function() {
     if ('console' in window && console.log) {
         console.log.apply(console, arguments);
     }
 };
 
-// SockJS.prototype._emit = function(eventType, value, t) {
+// Sock.prototype._emit = function(eventType, value, t) {
 //     this._debug('emit', eventType, value, t);
 //     if (this._protocol_is_fine === false &&
 //         (eventType === 'open' || eventType === 'message')) {
@@ -61,45 +61,45 @@ SockJS.prototype._debug = function() {
 //     //this.dispatchEvent(eventType, value);
 // };
 
-SockJS.prototype._didOpen = function() {
-    if (this.readyState !== SockJS.CONNECTING)
+Sock.prototype._didOpen = function() {
+    if (this.readyState !== Sock.CONNECTING)
             throw 'INVALID_STATE_ERR';
-    this.readyState = SockJS.OPEN;
+    this.readyState = Sock.OPEN;
     this.dispatchEvent(new SimpleEvent("open"));
 };
 
-SockJS.prototype._didClose = function(status, reason) {
-    if (this.readyState !== SockJS.CONNECTING &&
-        this.readyState !== SockJS.OPEN &&
-        this.readyState !== SockJS.CLOSING)
+Sock.prototype._didClose = function(status, reason) {
+    if (this.readyState !== Sock.CONNECTING &&
+        this.readyState !== Sock.OPEN &&
+        this.readyState !== Sock.CLOSING)
             throw 'INVALID_STATE_ERR';
 
     var close_event = new SimpleEvent("close", {status: status, reason: reason});
-    if (this.readyState === SockJS.CONNECTING) {
+    if (this.readyState === Sock.CONNECTING) {
         if (this._try_next_protocol(close_event) === false) {
-            this.readyState = SockJS.CLOSED;
+            this.readyState = Sock.CLOSED;
             var e = new SimpleEvent("close", {status: 2000,
                                               reason: "All transports failed."});
             this.dispatchEvent(e);
         }
     } else {
-        if (this.readyState === SockJS.CLOSING &&
+        if (this.readyState === Sock.CLOSING &&
             status === 1001 && this._close_status) {
             close_event = new SimpleEvent("close", {status: this._close_status,
                                                     reason: this._close_reason});
         }
-        this.readyState = SockJS.CLOSED;
+        this.readyState = Sock.CLOSED;
         this.dispatchEvent(close_event);
     }
 };
 
-SockJS.prototype._didMessage = function(data) {
-    if (this.readyState !== SockJS.OPEN)
+Sock.prototype._didMessage = function(data) {
+    if (this.readyState !== Sock.OPEN)
             return;
     this.dispatchEvent(new SimpleEvent("message", {data: data}));
 };
 
-SockJS.prototype._try_next_protocol = function(close_event) {
+Sock.prototype._try_next_protocol = function(close_event) {
     if (this.protocol)
         this._debug('Closed transport:', this.protocol, close_event);
 
@@ -113,8 +113,8 @@ SockJS.prototype._try_next_protocol = function(close_event) {
     }
 
     this._debug('Opening transport:', this.protocol);
-    if (SockJS[this.protocol].enabled() === true) {
-        this._transport = new SockJS[this.protocol](this, this._trans_url, this._base_url);
+    if (Sock[this.protocol].enabled() === true) {
+        this._transport = new Sock[this.protocol](this, this._trans_url, this._base_url);
         return true;
     }
     var e = new SimpleEvent("close", {status: 1000,
@@ -122,22 +122,22 @@ SockJS.prototype._try_next_protocol = function(close_event) {
     return this._try_next_protocol(e);
 };
 
-SockJS.prototype.close = function(status, reason) {
-    if(this.readyState !== SockJS.CONNECTING &&
-       this.readyState !== SockJS.OPEN) {
+Sock.prototype.close = function(status, reason) {
+    if(this.readyState !== Sock.CONNECTING &&
+       this.readyState !== Sock.OPEN) {
         return false;
     }
-    this.readyState = SockJS.CLOSING;
+    this.readyState = Sock.CLOSING;
     this._close_status = status || 1000;
     this._close_reason = reason || "Normal closure";
     this._transport.doClose();
     return true;
 };
 
-SockJS.prototype.send = function(data) {
-    if (this.readyState === SockJS.CONNECTING)
+Sock.prototype.send = function(data) {
+    if (this.readyState === Sock.CONNECTING)
             throw 'INVALID_STATE_ERR';
-    if (this.readyState === SockJS.OPEN) {
+    if (this.readyState === Sock.OPEN) {
         this._transport.doSend(data);
     }
     return true;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/sockjs-client.git



More information about the Pkg-javascript-commits mailing list