Skip to content

Commit fe1e814

Browse files
author
Max Presman
committed
reducing dependence on json library
1 parent c88d993 commit fe1e814

11 files changed

Lines changed: 7 additions & 608 deletions

File tree

Makefile.inc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ PUBNUB_VERSION_MIN_JS=pubnub-$(VERSION).min.js
1111
PUBNUB_UNASSEMBLED_DIR=unassembled
1212
PUBNUB_PLATFORM_JS=$(PUBNUB_UNASSEMBLED_DIR)/platform.js
1313
PUBNUB_PLATFORM_PRE_JS=$(PUBNUB_UNASSEMBLED_DIR)/platform-pre.js
14-
JSON_JS=$(CORE_DIR)/json.js
1514
PUBNUB_COMMON_JS=$(CORE_DIR)/pubnub-common.js
1615
CRYPTO_DIR=$(CORE_DIR)/crypto
1716
GIBBERISH_JS=$(CORE_DIR)/crypto/gibberish-aes.js

core/json.js

Lines changed: 0 additions & 150 deletions
This file was deleted.

smart-tv/pubnub.js

Lines changed: 0 additions & 150 deletions
Original file line numberDiff line numberDiff line change
@@ -1,156 +1,6 @@
11
// Version: 3.8.0
22
/* =-====================================================================-= */
33
/* =-====================================================================-= */
4-
/* =-========================= JSON =============================-= */
5-
/* =-====================================================================-= */
6-
/* =-====================================================================-= */
7-
8-
(window['JSON'] && window['JSON']['stringify']) || (function () {
9-
window['JSON'] || (window['JSON'] = {});
10-
11-
function toJSON(key) {
12-
try { return this.valueOf() }
13-
catch(e) { return null }
14-
}
15-
16-
var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
17-
escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
18-
gap,
19-
indent,
20-
meta = { // table of character substitutions
21-
'\b': '\\b',
22-
'\t': '\\t',
23-
'\n': '\\n',
24-
'\f': '\\f',
25-
'\r': '\\r',
26-
'"' : '\\"',
27-
'\\': '\\\\'
28-
},
29-
rep;
30-
31-
function quote(string) {
32-
escapable.lastIndex = 0;
33-
return escapable.test(string) ?
34-
'"' + string.replace(escapable, function (a) {
35-
var c = meta[a];
36-
return typeof c === 'string' ? c :
37-
'\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
38-
}) + '"' :
39-
'"' + string + '"';
40-
}
41-
42-
function str(key, holder) {
43-
var i, // The loop counter.
44-
k, // The member key.
45-
v, // The member value.
46-
length,
47-
partial,
48-
mind = gap,
49-
value = holder[key];
50-
51-
if (value && typeof value === 'object') {
52-
value = toJSON.call( value, key );
53-
}
54-
55-
if (typeof rep === 'function') {
56-
value = rep.call(holder, key, value);
57-
}
58-
59-
switch (typeof value) {
60-
case 'string':
61-
return quote(value);
62-
63-
case 'number':
64-
return isFinite(value) ? String(value) : 'null';
65-
66-
case 'boolean':
67-
case 'null':
68-
return String(value);
69-
70-
case 'object':
71-
72-
if (!value) {
73-
return 'null';
74-
}
75-
76-
gap += indent;
77-
partial = [];
78-
79-
if (Object.prototype.toString.apply(value) === '[object Array]') {
80-
81-
length = value.length;
82-
for (i = 0; i < length; i += 1) {
83-
partial[i] = str(i, value) || 'null';
84-
}
85-
86-
v = partial.length === 0 ? '[]' :
87-
gap ? '[\n' + gap +
88-
partial.join(',\n' + gap) + '\n' +
89-
mind + ']' :
90-
'[' + partial.join(',') + ']';
91-
gap = mind;
92-
return v;
93-
}
94-
if (rep && typeof rep === 'object') {
95-
length = rep.length;
96-
for (i = 0; i < length; i += 1) {
97-
k = rep[i];
98-
if (typeof k === 'string') {
99-
v = str(k, value);
100-
if (v) {
101-
partial.push(quote(k) + (gap ? ': ' : ':') + v);
102-
}
103-
}
104-
}
105-
} else {
106-
for (k in value) {
107-
if (Object.hasOwnProperty.call(value, k)) {
108-
v = str(k, value);
109-
if (v) {
110-
partial.push(quote(k) + (gap ? ': ' : ':') + v);
111-
}
112-
}
113-
}
114-
}
115-
116-
v = partial.length === 0 ? '{}' :
117-
gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' +
118-
mind + '}' : '{' + partial.join(',') + '}';
119-
gap = mind;
120-
return v;
121-
}
122-
}
123-
124-
if (typeof JSON['stringify'] !== 'function') {
125-
JSON['stringify'] = function (value, replacer, space) {
126-
var i;
127-
gap = '';
128-
indent = '';
129-
130-
if (typeof space === 'number') {
131-
for (i = 0; i < space; i += 1) {
132-
indent += ' ';
133-
}
134-
} else if (typeof space === 'string') {
135-
indent = space;
136-
}
137-
rep = replacer;
138-
if (replacer && typeof replacer !== 'function' &&
139-
(typeof replacer !== 'object' ||
140-
typeof replacer.length !== 'number')) {
141-
throw new Error('JSON.stringify');
142-
}
143-
return str('', {'': value});
144-
};
145-
}
146-
147-
if (typeof JSON['parse'] !== 'function') {
148-
// JSON is parsed on the server for security.
149-
JSON['parse'] = function (text) {return eval('('+text+')')};
150-
}
151-
}());
152-
/* =-====================================================================-= */
153-
/* =-====================================================================-= */
1544
/* =-========================= UTIL =============================-= */
1555
/* =-====================================================================-= */
1566
/* =-====================================================================-= */

smart-tv/pubnub.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

socket.io/socket.io.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

titanium/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ all: build
99
.PHONY : build
1010
build: $(PUBNUB_JS)
1111

12-
$(PUBNUB_JS) : $(JSON_JS) $(PUBNUB_COMMON_JS) $(PUBNUB_PLATFORM_JS)
12+
$(PUBNUB_JS) : $(PUBNUB_COMMON_JS) $(PUBNUB_PLATFORM_JS)
1313
$(ECHO) -n "// " > $(PUBNUB_JS)
1414
$(ECHO) $(VERSION) >> $(PUBNUB_JS)
1515
$(ECHO) "(function(){" >> $(PUBNUB_JS)

web/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ all: build
88
.PHONY : build
99
build: $(PUBNUB_VERSION_MIN_JS)
1010

11-
$(PUBNUB_VERSION_MIN_JS) : $(JSON_JS) $(PUBNUB_COMMON_JS) $(WEBSOCKET_JS) $(PUBNUB_PLATFORM_JS)
11+
$(PUBNUB_VERSION_MIN_JS) : $(PUBNUB_COMMON_JS) $(WEBSOCKET_JS) $(PUBNUB_PLATFORM_JS)
1212
## Full Version
1313
$(ECHO) "// Version: $(VERSION)" > $(PUBNUB_VERSION_JS)
1414
cat $(JSON_JS) $(PUBNUB_PLATFORM_PRE_JS) $(PUBNUB_COMMON_JS) $(CRYPTO_OBJ_JS) $(PUBNUB_PLATFORM_JS) $(WEBSOCKET_JS) >> $(PUBNUB_VERSION_JS)

0 commit comments

Comments
 (0)