forked from pubnub/javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.js
More file actions
executable file
·79 lines (69 loc) · 1.65 KB
/
Copy pathutils.js
File metadata and controls
executable file
·79 lines (69 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/* global it, assert, PUBNUB, _ */
/* eslint no-unused-vars: 0 */
/* eslint camelcase: 0 */
var in_list = function (list, str) {
for (var x in list) {
if (list[x] === str) return true;
}
return false;
};
var in_list_deep = function (list, obj) {
for (var x in list) {
if (_.isEqual(list[x], obj)) return true;
}
return false;
};
var variationRunner = function (testFun) {
it('over http', function (done) {
testFun(done, {});
});
it('over https', function (done) {
testFun(done, { ssl: true });
});
it('over http w/ presence', function (done) {
testFun(done, {
presence: function (r) {
if (!r.action) { assert.ok(false, 'presence called'); }
}
});
});
it('over https w/ presence', function (done) {
testFun(done, {
ssl: true,
presence: function (r) {
if (!r.action) { assert.ok(false, 'presence called'); }
}
});
});
};
var get_random = function () {
return Math.floor((Math.random() * 100000000000) + 1);
};
var _pubnub_subscribe = function (pubnub, args, config) {
if (config && config.presence) args.presence = config.presence;
return pubnub.subscribe(args);
};
var _pubnub_init = function (args, config, pn) {
if (config) {
args.ssl = config.ssl;
args.jsonp = config.jsonp;
// args.cipher_key = config.cipher_key;
}
if (pn) {
return pn.init(args);
} else {
return PUBNUB.init(args);
}
};
var _pubnub = function (args, config, pn) {
if (config) {
args.ssl = config.ssl;
args.jsonp = config.jsonp;
// args.cipher_key = config.cipher_key;
}
if (pn) {
return pn(args);
} else {
return PUBNUB(args);
}
};