mongodb-livedata-server 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/livedata_server.d.ts +4 -4
- package/dist/livedata_server.js +11 -11
- package/dist/meteor/binary-heap/max_heap.d.ts +31 -31
- package/dist/meteor/binary-heap/max_heap.js +186 -186
- package/dist/meteor/binary-heap/min_heap.d.ts +6 -6
- package/dist/meteor/binary-heap/min_heap.js +17 -17
- package/dist/meteor/binary-heap/min_max_heap.d.ts +11 -11
- package/dist/meteor/binary-heap/min_max_heap.js +48 -48
- package/dist/meteor/callback-hook/hook.d.ts +11 -11
- package/dist/meteor/callback-hook/hook.js +78 -78
- package/dist/meteor/ddp/crossbar.d.ts +15 -15
- package/dist/meteor/ddp/crossbar.js +136 -136
- package/dist/meteor/ddp/heartbeat.d.ts +19 -19
- package/dist/meteor/ddp/heartbeat.js +77 -77
- package/dist/meteor/ddp/livedata_server.d.ts +141 -142
- package/dist/meteor/ddp/livedata_server.js +403 -403
- package/dist/meteor/ddp/method-invocation.d.ts +35 -35
- package/dist/meteor/ddp/method-invocation.js +72 -72
- package/dist/meteor/ddp/random-stream.d.ts +8 -8
- package/dist/meteor/ddp/random-stream.js +100 -100
- package/dist/meteor/ddp/session-collection-view.d.ts +20 -20
- package/dist/meteor/ddp/session-collection-view.js +106 -106
- package/dist/meteor/ddp/session-document-view.d.ts +8 -8
- package/dist/meteor/ddp/session-document-view.js +82 -82
- package/dist/meteor/ddp/session.d.ts +75 -74
- package/dist/meteor/ddp/session.js +590 -589
- package/dist/meteor/ddp/stream_server.d.ts +20 -21
- package/dist/meteor/ddp/stream_server.js +181 -181
- package/dist/meteor/ddp/subscription.d.ts +94 -94
- package/dist/meteor/ddp/subscription.js +370 -370
- package/dist/meteor/ddp/utils.d.ts +8 -8
- package/dist/meteor/ddp/utils.js +104 -104
- package/dist/meteor/ddp/writefence.d.ts +20 -20
- package/dist/meteor/ddp/writefence.js +111 -111
- package/dist/meteor/diff-sequence/diff.d.ts +17 -17
- package/dist/meteor/diff-sequence/diff.js +257 -257
- package/dist/meteor/ejson/ejson.d.ts +82 -82
- package/dist/meteor/ejson/ejson.js +568 -569
- package/dist/meteor/ejson/stringify.d.ts +2 -2
- package/dist/meteor/ejson/stringify.js +119 -119
- package/dist/meteor/ejson/utils.d.ts +12 -12
- package/dist/meteor/ejson/utils.js +42 -42
- package/dist/meteor/mongo/caching_change_observer.d.ts +16 -16
- package/dist/meteor/mongo/caching_change_observer.js +63 -63
- package/dist/meteor/mongo/doc_fetcher.d.ts +7 -7
- package/dist/meteor/mongo/doc_fetcher.js +53 -53
- package/dist/meteor/mongo/geojson_utils.d.ts +3 -3
- package/dist/meteor/mongo/geojson_utils.js +40 -41
- package/dist/meteor/mongo/live_connection.d.ts +28 -28
- package/dist/meteor/mongo/live_connection.js +264 -264
- package/dist/meteor/mongo/live_cursor.d.ts +25 -25
- package/dist/meteor/mongo/live_cursor.js +60 -60
- package/dist/meteor/mongo/minimongo_common.d.ts +84 -84
- package/dist/meteor/mongo/minimongo_common.js +1998 -2002
- package/dist/meteor/mongo/minimongo_matcher.d.ts +23 -23
- package/dist/meteor/mongo/minimongo_matcher.js +283 -283
- package/dist/meteor/mongo/minimongo_sorter.d.ts +16 -16
- package/dist/meteor/mongo/minimongo_sorter.js +268 -268
- package/dist/meteor/mongo/observe_driver_utils.d.ts +9 -9
- package/dist/meteor/mongo/observe_driver_utils.js +72 -73
- package/dist/meteor/mongo/observe_multiplexer.d.ts +46 -46
- package/dist/meteor/mongo/observe_multiplexer.js +203 -203
- package/dist/meteor/mongo/oplog-observe-driver.d.ts +68 -68
- package/dist/meteor/mongo/oplog-observe-driver.js +918 -918
- package/dist/meteor/mongo/oplog_tailing.d.ts +35 -35
- package/dist/meteor/mongo/oplog_tailing.js +352 -352
- package/dist/meteor/mongo/oplog_v2_converter.d.ts +1 -1
- package/dist/meteor/mongo/oplog_v2_converter.js +125 -126
- package/dist/meteor/mongo/polling_observe_driver.d.ts +30 -30
- package/dist/meteor/mongo/polling_observe_driver.js +216 -221
- package/dist/meteor/mongo/synchronous-cursor.d.ts +17 -17
- package/dist/meteor/mongo/synchronous-cursor.js +261 -261
- package/dist/meteor/mongo/synchronous-queue.d.ts +13 -13
- package/dist/meteor/mongo/synchronous-queue.js +110 -110
- package/dist/meteor/ordered-dict/ordered_dict.d.ts +31 -31
- package/dist/meteor/ordered-dict/ordered_dict.js +198 -198
- package/dist/meteor/random/AbstractRandomGenerator.d.ts +42 -42
- package/dist/meteor/random/AbstractRandomGenerator.js +92 -92
- package/dist/meteor/random/AleaRandomGenerator.d.ts +13 -13
- package/dist/meteor/random/AleaRandomGenerator.js +90 -90
- package/dist/meteor/random/NodeRandomGenerator.d.ts +16 -16
- package/dist/meteor/random/NodeRandomGenerator.js +42 -42
- package/dist/meteor/random/createAleaGenerator.d.ts +2 -2
- package/dist/meteor/random/createAleaGenerator.js +32 -32
- package/dist/meteor/random/createRandom.d.ts +1 -1
- package/dist/meteor/random/createRandom.js +22 -22
- package/dist/meteor/random/main.d.ts +1 -1
- package/dist/meteor/random/main.js +12 -12
- package/dist/meteor/types.d.ts +1 -1
- package/dist/meteor/types.js +2 -2
- package/package.json +6 -5
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const canonicalStringify: (value: any, options: any) => string;
|
|
2
|
-
export default canonicalStringify;
|
|
1
|
+
declare const canonicalStringify: (value: any, options: any) => string;
|
|
2
|
+
export default canonicalStringify;
|
|
@@ -1,119 +1,119 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Based on json2.js from https://github.com/douglascrockford/JSON-js
|
|
3
|
-
//
|
|
4
|
-
// json2.js
|
|
5
|
-
// 2012-10-08
|
|
6
|
-
//
|
|
7
|
-
// Public Domain.
|
|
8
|
-
//
|
|
9
|
-
// NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
function quote(string) {
|
|
12
|
-
return JSON.stringify(string);
|
|
13
|
-
}
|
|
14
|
-
const str = (key, holder, singleIndent, outerIndent, canonical) => {
|
|
15
|
-
const value = holder[key];
|
|
16
|
-
// What happens next depends on the value's type.
|
|
17
|
-
switch (typeof value) {
|
|
18
|
-
case 'string':
|
|
19
|
-
return quote(value);
|
|
20
|
-
case 'number':
|
|
21
|
-
// JSON numbers must be finite. Encode non-finite numbers as null.
|
|
22
|
-
return isFinite(value) ? String(value) : 'null';
|
|
23
|
-
case 'boolean':
|
|
24
|
-
return String(value);
|
|
25
|
-
// If the type is 'object', we might be dealing with an object or an array or
|
|
26
|
-
// null.
|
|
27
|
-
case 'object': {
|
|
28
|
-
// Due to a specification blunder in ECMAScript, typeof null is 'object',
|
|
29
|
-
// so watch out for that case.
|
|
30
|
-
if (!value) {
|
|
31
|
-
return 'null';
|
|
32
|
-
}
|
|
33
|
-
// Make an array to hold the partial results of stringifying this object
|
|
34
|
-
// value.
|
|
35
|
-
const innerIndent = outerIndent + singleIndent;
|
|
36
|
-
const partial = [];
|
|
37
|
-
let v;
|
|
38
|
-
// Is the value an array?
|
|
39
|
-
if (Array.isArray(value) || ({}).hasOwnProperty.call(value, 'callee')) {
|
|
40
|
-
// The value is an array. Stringify every element. Use null as a
|
|
41
|
-
// placeholder for non-JSON values.
|
|
42
|
-
const length = value.length;
|
|
43
|
-
for (let i = 0; i < length; i += 1) {
|
|
44
|
-
partial[i] =
|
|
45
|
-
str(i, value, singleIndent, innerIndent, canonical) || 'null';
|
|
46
|
-
}
|
|
47
|
-
// Join all of the elements together, separated with commas, and wrap
|
|
48
|
-
// them in brackets.
|
|
49
|
-
if (partial.length === 0) {
|
|
50
|
-
v = '[]';
|
|
51
|
-
}
|
|
52
|
-
else if (innerIndent) {
|
|
53
|
-
v = '[\n' +
|
|
54
|
-
innerIndent +
|
|
55
|
-
partial.join(',\n' +
|
|
56
|
-
innerIndent) +
|
|
57
|
-
'\n' +
|
|
58
|
-
outerIndent +
|
|
59
|
-
']';
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
v = '[' + partial.join(',') + ']';
|
|
63
|
-
}
|
|
64
|
-
return v;
|
|
65
|
-
}
|
|
66
|
-
// Iterate through all of the keys in the object.
|
|
67
|
-
let keys = Object.keys(value);
|
|
68
|
-
if (canonical) {
|
|
69
|
-
keys = keys.sort();
|
|
70
|
-
}
|
|
71
|
-
keys.forEach(k => {
|
|
72
|
-
v = str(k, value, singleIndent, innerIndent, canonical);
|
|
73
|
-
if (v) {
|
|
74
|
-
partial.push(quote(k) + (innerIndent ? ': ' : ':') + v);
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
// Join all of the member texts together, separated with commas,
|
|
78
|
-
// and wrap them in braces.
|
|
79
|
-
if (partial.length === 0) {
|
|
80
|
-
v = '{}';
|
|
81
|
-
}
|
|
82
|
-
else if (innerIndent) {
|
|
83
|
-
v = '{\n' +
|
|
84
|
-
innerIndent +
|
|
85
|
-
partial.join(',\n' +
|
|
86
|
-
innerIndent) +
|
|
87
|
-
'\n' +
|
|
88
|
-
outerIndent +
|
|
89
|
-
'}';
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
v = '{' + partial.join(',') + '}';
|
|
93
|
-
}
|
|
94
|
-
return v;
|
|
95
|
-
}
|
|
96
|
-
default: // Do nothing
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
// If the JSON object does not yet have a stringify method, give it one.
|
|
100
|
-
const canonicalStringify = (value, options) => {
|
|
101
|
-
// Make a fake root object containing our value under the key of ''.
|
|
102
|
-
// Return the result of stringifying the value.
|
|
103
|
-
const allOptions = Object.assign({
|
|
104
|
-
indent: '',
|
|
105
|
-
canonical: false,
|
|
106
|
-
}, options);
|
|
107
|
-
if (allOptions.indent === true) {
|
|
108
|
-
allOptions.indent = ' ';
|
|
109
|
-
}
|
|
110
|
-
else if (typeof allOptions.indent === 'number') {
|
|
111
|
-
let newIndent = '';
|
|
112
|
-
for (let i = 0; i < allOptions.indent; i++) {
|
|
113
|
-
newIndent += ' ';
|
|
114
|
-
}
|
|
115
|
-
allOptions.indent = newIndent;
|
|
116
|
-
}
|
|
117
|
-
return str('', { '': value }, allOptions.indent, '', allOptions.canonical);
|
|
118
|
-
};
|
|
119
|
-
exports.default = canonicalStringify;
|
|
1
|
+
"use strict";
|
|
2
|
+
// Based on json2.js from https://github.com/douglascrockford/JSON-js
|
|
3
|
+
//
|
|
4
|
+
// json2.js
|
|
5
|
+
// 2012-10-08
|
|
6
|
+
//
|
|
7
|
+
// Public Domain.
|
|
8
|
+
//
|
|
9
|
+
// NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
function quote(string) {
|
|
12
|
+
return JSON.stringify(string);
|
|
13
|
+
}
|
|
14
|
+
const str = (key, holder, singleIndent, outerIndent, canonical) => {
|
|
15
|
+
const value = holder[key];
|
|
16
|
+
// What happens next depends on the value's type.
|
|
17
|
+
switch (typeof value) {
|
|
18
|
+
case 'string':
|
|
19
|
+
return quote(value);
|
|
20
|
+
case 'number':
|
|
21
|
+
// JSON numbers must be finite. Encode non-finite numbers as null.
|
|
22
|
+
return isFinite(value) ? String(value) : 'null';
|
|
23
|
+
case 'boolean':
|
|
24
|
+
return String(value);
|
|
25
|
+
// If the type is 'object', we might be dealing with an object or an array or
|
|
26
|
+
// null.
|
|
27
|
+
case 'object': {
|
|
28
|
+
// Due to a specification blunder in ECMAScript, typeof null is 'object',
|
|
29
|
+
// so watch out for that case.
|
|
30
|
+
if (!value) {
|
|
31
|
+
return 'null';
|
|
32
|
+
}
|
|
33
|
+
// Make an array to hold the partial results of stringifying this object
|
|
34
|
+
// value.
|
|
35
|
+
const innerIndent = outerIndent + singleIndent;
|
|
36
|
+
const partial = [];
|
|
37
|
+
let v;
|
|
38
|
+
// Is the value an array?
|
|
39
|
+
if (Array.isArray(value) || ({}).hasOwnProperty.call(value, 'callee')) {
|
|
40
|
+
// The value is an array. Stringify every element. Use null as a
|
|
41
|
+
// placeholder for non-JSON values.
|
|
42
|
+
const length = value.length;
|
|
43
|
+
for (let i = 0; i < length; i += 1) {
|
|
44
|
+
partial[i] =
|
|
45
|
+
str(i, value, singleIndent, innerIndent, canonical) || 'null';
|
|
46
|
+
}
|
|
47
|
+
// Join all of the elements together, separated with commas, and wrap
|
|
48
|
+
// them in brackets.
|
|
49
|
+
if (partial.length === 0) {
|
|
50
|
+
v = '[]';
|
|
51
|
+
}
|
|
52
|
+
else if (innerIndent) {
|
|
53
|
+
v = '[\n' +
|
|
54
|
+
innerIndent +
|
|
55
|
+
partial.join(',\n' +
|
|
56
|
+
innerIndent) +
|
|
57
|
+
'\n' +
|
|
58
|
+
outerIndent +
|
|
59
|
+
']';
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
v = '[' + partial.join(',') + ']';
|
|
63
|
+
}
|
|
64
|
+
return v;
|
|
65
|
+
}
|
|
66
|
+
// Iterate through all of the keys in the object.
|
|
67
|
+
let keys = Object.keys(value);
|
|
68
|
+
if (canonical) {
|
|
69
|
+
keys = keys.sort();
|
|
70
|
+
}
|
|
71
|
+
keys.forEach(k => {
|
|
72
|
+
v = str(k, value, singleIndent, innerIndent, canonical);
|
|
73
|
+
if (v) {
|
|
74
|
+
partial.push(quote(k) + (innerIndent ? ': ' : ':') + v);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
// Join all of the member texts together, separated with commas,
|
|
78
|
+
// and wrap them in braces.
|
|
79
|
+
if (partial.length === 0) {
|
|
80
|
+
v = '{}';
|
|
81
|
+
}
|
|
82
|
+
else if (innerIndent) {
|
|
83
|
+
v = '{\n' +
|
|
84
|
+
innerIndent +
|
|
85
|
+
partial.join(',\n' +
|
|
86
|
+
innerIndent) +
|
|
87
|
+
'\n' +
|
|
88
|
+
outerIndent +
|
|
89
|
+
'}';
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
v = '{' + partial.join(',') + '}';
|
|
93
|
+
}
|
|
94
|
+
return v;
|
|
95
|
+
}
|
|
96
|
+
default: // Do nothing
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
// If the JSON object does not yet have a stringify method, give it one.
|
|
100
|
+
const canonicalStringify = (value, options) => {
|
|
101
|
+
// Make a fake root object containing our value under the key of ''.
|
|
102
|
+
// Return the result of stringifying the value.
|
|
103
|
+
const allOptions = Object.assign({
|
|
104
|
+
indent: '',
|
|
105
|
+
canonical: false,
|
|
106
|
+
}, options);
|
|
107
|
+
if (allOptions.indent === true) {
|
|
108
|
+
allOptions.indent = ' ';
|
|
109
|
+
}
|
|
110
|
+
else if (typeof allOptions.indent === 'number') {
|
|
111
|
+
let newIndent = '';
|
|
112
|
+
for (let i = 0; i < allOptions.indent; i++) {
|
|
113
|
+
newIndent += ' ';
|
|
114
|
+
}
|
|
115
|
+
allOptions.indent = newIndent;
|
|
116
|
+
}
|
|
117
|
+
return str('', { '': value }, allOptions.indent, '', allOptions.canonical);
|
|
118
|
+
};
|
|
119
|
+
exports.default = canonicalStringify;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export declare const isFunction: (fn: any) => boolean;
|
|
2
|
-
export declare const isObject: (fn: any) => boolean;
|
|
3
|
-
export declare const keysOf: (obj: any) => string[];
|
|
4
|
-
export declare const lengthOf: (obj: any) => number;
|
|
5
|
-
export declare const hasOwn: (obj: any, prop: any) => any;
|
|
6
|
-
export declare const convertMapToObject: (map: any) => unknown;
|
|
7
|
-
export declare function isArguments(obj: any): obj is ArrayLike<any>;
|
|
8
|
-
export declare const isInfOrNaN: (obj: any) => boolean;
|
|
9
|
-
export declare const checkError: {
|
|
10
|
-
maxStack: (msgError: any) => boolean;
|
|
11
|
-
};
|
|
12
|
-
export declare function handleError<F extends (...args: any[]) => any>(fn: F, ...args: any[]): ReturnType<F>;
|
|
1
|
+
export declare const isFunction: (fn: any) => boolean;
|
|
2
|
+
export declare const isObject: (fn: any) => boolean;
|
|
3
|
+
export declare const keysOf: (obj: any) => string[];
|
|
4
|
+
export declare const lengthOf: (obj: any) => number;
|
|
5
|
+
export declare const hasOwn: (obj: any, prop: any) => any;
|
|
6
|
+
export declare const convertMapToObject: (map: any) => unknown;
|
|
7
|
+
export declare function isArguments(obj: any): obj is ArrayLike<any>;
|
|
8
|
+
export declare const isInfOrNaN: (obj: any) => boolean;
|
|
9
|
+
export declare const checkError: {
|
|
10
|
+
maxStack: (msgError: any) => boolean;
|
|
11
|
+
};
|
|
12
|
+
export declare function handleError<F extends (...args: any[]) => any>(fn: F, ...args: any[]): ReturnType<F>;
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
exports.
|
|
6
|
-
const
|
|
7
|
-
exports.
|
|
8
|
-
const
|
|
9
|
-
exports.
|
|
10
|
-
const
|
|
11
|
-
exports.
|
|
12
|
-
const
|
|
13
|
-
exports.
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
exports.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
exports.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkError = exports.isInfOrNaN = exports.convertMapToObject = exports.hasOwn = exports.lengthOf = exports.keysOf = exports.isObject = exports.isFunction = void 0;
|
|
4
|
+
exports.isArguments = isArguments;
|
|
5
|
+
exports.handleError = handleError;
|
|
6
|
+
const isFunction = (fn) => typeof fn === 'function';
|
|
7
|
+
exports.isFunction = isFunction;
|
|
8
|
+
const isObject = (fn) => typeof fn === 'object';
|
|
9
|
+
exports.isObject = isObject;
|
|
10
|
+
const keysOf = (obj) => Object.keys(obj);
|
|
11
|
+
exports.keysOf = keysOf;
|
|
12
|
+
const lengthOf = (obj) => Object.keys(obj).length;
|
|
13
|
+
exports.lengthOf = lengthOf;
|
|
14
|
+
const hasOwn = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
|
|
15
|
+
exports.hasOwn = hasOwn;
|
|
16
|
+
const convertMapToObject = (map) => Array.from(map).reduce((acc, [key, value]) => {
|
|
17
|
+
// reassign to not create new object
|
|
18
|
+
acc[key] = value;
|
|
19
|
+
return acc;
|
|
20
|
+
}, {});
|
|
21
|
+
exports.convertMapToObject = convertMapToObject;
|
|
22
|
+
function isArguments(obj) {
|
|
23
|
+
return obj != null && (0, exports.hasOwn)(obj, 'callee');
|
|
24
|
+
}
|
|
25
|
+
const isInfOrNaN = obj => Number.isNaN(obj) || obj === Infinity || obj === -Infinity;
|
|
26
|
+
exports.isInfOrNaN = isInfOrNaN;
|
|
27
|
+
exports.checkError = {
|
|
28
|
+
maxStack: (msgError) => new RegExp('Maximum call stack size exceeded', 'g').test(msgError),
|
|
29
|
+
};
|
|
30
|
+
function handleError(fn, ...args) {
|
|
31
|
+
try {
|
|
32
|
+
return fn.apply(this, args);
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
const isMaxStack = exports.checkError.maxStack(error.message);
|
|
36
|
+
if (isMaxStack) {
|
|
37
|
+
throw new Error('Converting circular structure to JSON');
|
|
38
|
+
}
|
|
39
|
+
throw error;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { OrderedDict } from "../ordered-dict/ordered_dict";
|
|
2
|
-
export declare class _CachingChangeObserver {
|
|
3
|
-
docs: OrderedDict | Map<string, any>;
|
|
4
|
-
applyChange: {
|
|
5
|
-
initialAdds?: (docs: OrderedDict | Map<string, any>) => void;
|
|
6
|
-
added?: (id: string, fields: any) => void;
|
|
7
|
-
changed?: (id: string, fields: any) => void;
|
|
8
|
-
removed?: (id: string) => void;
|
|
9
|
-
addedBefore?: (id: string, fields: any, before: any) => void;
|
|
10
|
-
movedBefore?: (id: string, before: any) => void;
|
|
11
|
-
};
|
|
12
|
-
private ordered;
|
|
13
|
-
constructor(options?: {
|
|
14
|
-
ordered?: boolean;
|
|
15
|
-
});
|
|
16
|
-
}
|
|
1
|
+
import { OrderedDict } from "../ordered-dict/ordered_dict";
|
|
2
|
+
export declare class _CachingChangeObserver {
|
|
3
|
+
docs: OrderedDict | Map<string, any>;
|
|
4
|
+
applyChange: {
|
|
5
|
+
initialAdds?: (docs: OrderedDict | Map<string, any>) => void;
|
|
6
|
+
added?: (id: string, fields: any) => void;
|
|
7
|
+
changed?: (id: string, fields: any) => void;
|
|
8
|
+
removed?: (id: string) => void;
|
|
9
|
+
addedBefore?: (id: string, fields: any, before: any) => void;
|
|
10
|
+
movedBefore?: (id: string, before: any) => void;
|
|
11
|
+
};
|
|
12
|
+
private ordered;
|
|
13
|
+
constructor(options?: {
|
|
14
|
+
ordered?: boolean;
|
|
15
|
+
});
|
|
16
|
+
}
|
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// _CachingChangeObserver is an object which receives observeChanges callbacks
|
|
3
|
-
// and keeps a cache of the current cursor state up to date in this.docs. Users
|
|
4
|
-
// of this class should read the docs field but not modify it. You should pass
|
|
5
|
-
// the "applyChange" field as the callbacks to the underlying observeChanges
|
|
6
|
-
// call. Optionally, you can specify your own observeChanges callbacks which are
|
|
7
|
-
// invoked immediately before the docs field is updated; this object is made
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports._CachingChangeObserver = void 0;
|
|
10
|
-
const diff_1 = require("../diff-sequence/diff");
|
|
11
|
-
const ordered_dict_1 = require("../ordered-dict/ordered_dict");
|
|
12
|
-
// available as `this` to those callbacks.
|
|
13
|
-
class _CachingChangeObserver {
|
|
14
|
-
constructor(options = {}) {
|
|
15
|
-
this.ordered = options.ordered || false;
|
|
16
|
-
if (this.ordered) {
|
|
17
|
-
this.docs = new ordered_dict_1.OrderedDict();
|
|
18
|
-
this.applyChange = {
|
|
19
|
-
addedBefore: (id, fields, before) => {
|
|
20
|
-
// Take a shallow copy since the top-level properties can be changed
|
|
21
|
-
const doc = Object.assign({}, fields);
|
|
22
|
-
doc._id = id;
|
|
23
|
-
// XXX could `before` be a falsy ID? Technically
|
|
24
|
-
// idStringify seems to allow for them -- though
|
|
25
|
-
// OrderedDict won't call stringify on a falsy arg.
|
|
26
|
-
this.docs.putBefore(id, doc, before || null);
|
|
27
|
-
},
|
|
28
|
-
movedBefore: (id, before) => {
|
|
29
|
-
const doc = this.docs.get(id);
|
|
30
|
-
this.docs.moveBefore(id, before || null);
|
|
31
|
-
},
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
this.docs = new Map();
|
|
36
|
-
this.applyChange = {
|
|
37
|
-
added: (id, fields) => {
|
|
38
|
-
// Take a shallow copy since the top-level properties can be changed
|
|
39
|
-
const doc = Object.assign({}, fields);
|
|
40
|
-
doc._id = id;
|
|
41
|
-
this.docs.set(id, doc);
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
this.applyChange.initialAdds = (docs) => {
|
|
46
|
-
this.docs = docs;
|
|
47
|
-
};
|
|
48
|
-
// The methods in _IdMap and OrderedDict used by these callbacks are
|
|
49
|
-
// identical.
|
|
50
|
-
this.applyChange.changed = (id, fields) => {
|
|
51
|
-
const doc = this.docs.get(id);
|
|
52
|
-
if (!doc) {
|
|
53
|
-
throw new Error(`Unknown id for changed: ${id}`);
|
|
54
|
-
}
|
|
55
|
-
diff_1.DiffSequence.applyChanges(doc, fields);
|
|
56
|
-
};
|
|
57
|
-
this.applyChange.removed = id => {
|
|
58
|
-
this.docs.delete(id);
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
exports._CachingChangeObserver = _CachingChangeObserver;
|
|
63
|
-
;
|
|
1
|
+
"use strict";
|
|
2
|
+
// _CachingChangeObserver is an object which receives observeChanges callbacks
|
|
3
|
+
// and keeps a cache of the current cursor state up to date in this.docs. Users
|
|
4
|
+
// of this class should read the docs field but not modify it. You should pass
|
|
5
|
+
// the "applyChange" field as the callbacks to the underlying observeChanges
|
|
6
|
+
// call. Optionally, you can specify your own observeChanges callbacks which are
|
|
7
|
+
// invoked immediately before the docs field is updated; this object is made
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports._CachingChangeObserver = void 0;
|
|
10
|
+
const diff_1 = require("../diff-sequence/diff");
|
|
11
|
+
const ordered_dict_1 = require("../ordered-dict/ordered_dict");
|
|
12
|
+
// available as `this` to those callbacks.
|
|
13
|
+
class _CachingChangeObserver {
|
|
14
|
+
constructor(options = {}) {
|
|
15
|
+
this.ordered = options.ordered || false;
|
|
16
|
+
if (this.ordered) {
|
|
17
|
+
this.docs = new ordered_dict_1.OrderedDict();
|
|
18
|
+
this.applyChange = {
|
|
19
|
+
addedBefore: (id, fields, before) => {
|
|
20
|
+
// Take a shallow copy since the top-level properties can be changed
|
|
21
|
+
const doc = Object.assign({}, fields);
|
|
22
|
+
doc._id = id;
|
|
23
|
+
// XXX could `before` be a falsy ID? Technically
|
|
24
|
+
// idStringify seems to allow for them -- though
|
|
25
|
+
// OrderedDict won't call stringify on a falsy arg.
|
|
26
|
+
this.docs.putBefore(id, doc, before || null);
|
|
27
|
+
},
|
|
28
|
+
movedBefore: (id, before) => {
|
|
29
|
+
const doc = this.docs.get(id);
|
|
30
|
+
this.docs.moveBefore(id, before || null);
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
this.docs = new Map();
|
|
36
|
+
this.applyChange = {
|
|
37
|
+
added: (id, fields) => {
|
|
38
|
+
// Take a shallow copy since the top-level properties can be changed
|
|
39
|
+
const doc = Object.assign({}, fields);
|
|
40
|
+
doc._id = id;
|
|
41
|
+
this.docs.set(id, doc);
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
this.applyChange.initialAdds = (docs) => {
|
|
46
|
+
this.docs = docs;
|
|
47
|
+
};
|
|
48
|
+
// The methods in _IdMap and OrderedDict used by these callbacks are
|
|
49
|
+
// identical.
|
|
50
|
+
this.applyChange.changed = (id, fields) => {
|
|
51
|
+
const doc = this.docs.get(id);
|
|
52
|
+
if (!doc) {
|
|
53
|
+
throw new Error(`Unknown id for changed: ${id}`);
|
|
54
|
+
}
|
|
55
|
+
diff_1.DiffSequence.applyChanges(doc, fields);
|
|
56
|
+
};
|
|
57
|
+
this.applyChange.removed = id => {
|
|
58
|
+
this.docs.delete(id);
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports._CachingChangeObserver = _CachingChangeObserver;
|
|
63
|
+
;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as MongoDB from "mongodb";
|
|
2
|
-
export declare class DocFetcher {
|
|
3
|
-
private db;
|
|
4
|
-
private _callbacksForOp;
|
|
5
|
-
constructor(db: MongoDB.Db);
|
|
6
|
-
fetch(collectionName: string, id: string, op: Object, callback: Function): Promise<void>;
|
|
7
|
-
}
|
|
1
|
+
import * as MongoDB from "mongodb";
|
|
2
|
+
export declare class DocFetcher {
|
|
3
|
+
private db;
|
|
4
|
+
private _callbacksForOp;
|
|
5
|
+
constructor(db: MongoDB.Db);
|
|
6
|
+
fetch(collectionName: string, id: string, op: Object, callback: Function): Promise<void>;
|
|
7
|
+
}
|
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DocFetcher = void 0;
|
|
4
|
-
const ejson_1 = require("../ejson/ejson");
|
|
5
|
-
class DocFetcher {
|
|
6
|
-
constructor(db) {
|
|
7
|
-
this.db = db;
|
|
8
|
-
this._callbacksForOp = new Map();
|
|
9
|
-
}
|
|
10
|
-
// Fetches document "id" from collectionName, returning it or null if not
|
|
11
|
-
// found.
|
|
12
|
-
//
|
|
13
|
-
// If you make multiple calls to fetch() with the same op reference,
|
|
14
|
-
// DocFetcher may assume that they all return the same document. (It does
|
|
15
|
-
// not check to see if collectionName/id match.)
|
|
16
|
-
//
|
|
17
|
-
// You may assume that callback is never called synchronously (and in fact
|
|
18
|
-
// OplogObserveDriver does so).
|
|
19
|
-
async fetch(collectionName, id, op, callback) {
|
|
20
|
-
const self = this;
|
|
21
|
-
// If there's already an in-progress fetch for this cache key, yield until
|
|
22
|
-
// it's done and return whatever it returns.
|
|
23
|
-
if (self._callbacksForOp.has(op)) {
|
|
24
|
-
self._callbacksForOp.get(op).push(callback);
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
const callbacks = [callback];
|
|
28
|
-
self._callbacksForOp.set(op, callbacks);
|
|
29
|
-
try {
|
|
30
|
-
var doc = await self.db.collection(collectionName).findOne({ _id: id }) || null;
|
|
31
|
-
// Return doc to all relevant callbacks. Note that this array can
|
|
32
|
-
// continue to grow during callback execution.
|
|
33
|
-
while (callbacks.length > 0) {
|
|
34
|
-
// Clone the document so that the various calls to fetch don't return
|
|
35
|
-
// objects that are intertwingled with each other. Clone before
|
|
36
|
-
// popping the future, so that if clone throws, the error gets passed
|
|
37
|
-
// to the next callback.
|
|
38
|
-
callbacks.pop()(null, (0, ejson_1.clone)(doc));
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
catch (e) {
|
|
42
|
-
while (callbacks.length > 0) {
|
|
43
|
-
callbacks.pop()(e);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
finally {
|
|
47
|
-
// XXX consider keeping the doc around for a period of time before
|
|
48
|
-
// removing from the cache
|
|
49
|
-
self._callbacksForOp.delete(op);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
exports.DocFetcher = DocFetcher;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DocFetcher = void 0;
|
|
4
|
+
const ejson_1 = require("../ejson/ejson");
|
|
5
|
+
class DocFetcher {
|
|
6
|
+
constructor(db) {
|
|
7
|
+
this.db = db;
|
|
8
|
+
this._callbacksForOp = new Map();
|
|
9
|
+
}
|
|
10
|
+
// Fetches document "id" from collectionName, returning it or null if not
|
|
11
|
+
// found.
|
|
12
|
+
//
|
|
13
|
+
// If you make multiple calls to fetch() with the same op reference,
|
|
14
|
+
// DocFetcher may assume that they all return the same document. (It does
|
|
15
|
+
// not check to see if collectionName/id match.)
|
|
16
|
+
//
|
|
17
|
+
// You may assume that callback is never called synchronously (and in fact
|
|
18
|
+
// OplogObserveDriver does so).
|
|
19
|
+
async fetch(collectionName, id, op, callback) {
|
|
20
|
+
const self = this;
|
|
21
|
+
// If there's already an in-progress fetch for this cache key, yield until
|
|
22
|
+
// it's done and return whatever it returns.
|
|
23
|
+
if (self._callbacksForOp.has(op)) {
|
|
24
|
+
self._callbacksForOp.get(op).push(callback);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const callbacks = [callback];
|
|
28
|
+
self._callbacksForOp.set(op, callbacks);
|
|
29
|
+
try {
|
|
30
|
+
var doc = await self.db.collection(collectionName).findOne({ _id: id }) || null;
|
|
31
|
+
// Return doc to all relevant callbacks. Note that this array can
|
|
32
|
+
// continue to grow during callback execution.
|
|
33
|
+
while (callbacks.length > 0) {
|
|
34
|
+
// Clone the document so that the various calls to fetch don't return
|
|
35
|
+
// objects that are intertwingled with each other. Clone before
|
|
36
|
+
// popping the future, so that if clone throws, the error gets passed
|
|
37
|
+
// to the next callback.
|
|
38
|
+
callbacks.pop()(null, (0, ejson_1.clone)(doc));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
catch (e) {
|
|
42
|
+
while (callbacks.length > 0) {
|
|
43
|
+
callbacks.pop()(e);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
finally {
|
|
47
|
+
// XXX consider keeping the doc around for a period of time before
|
|
48
|
+
// removing from the cache
|
|
49
|
+
self._callbacksForOp.delete(op);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.DocFetcher = DocFetcher;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare function numberToRadius(number: any): number;
|
|
2
|
-
export declare function pointDistance(pt1: any, pt2: any): number;
|
|
3
|
-
export declare function geometryWithinRadius(geometry: any, center: any, radius: any): boolean;
|
|
1
|
+
export declare function numberToRadius(number: any): number;
|
|
2
|
+
export declare function pointDistance(pt1: any, pt2: any): number;
|
|
3
|
+
export declare function geometryWithinRadius(geometry: any, center: any, radius: any): boolean;
|