-
Notifications
You must be signed in to change notification settings - Fork 4
/
j.coffee
81 lines (69 loc) · 2.05 KB
/
j.coffee
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
80
81
# Copyright 2015, Quixey Inc.
# All rights reserved.
#
# Licensed under the Modified BSD License found in the
# LICENSE file in the root directory of this source tree.
J = {}
J.stores = {}
J.counts = {}
J.inc = (countName, num = 1) ->
J.counts[countName] ?= 0
J.counts[countName] += num
J.g = J.graph = {} # jid: object
J.debugGraph = Meteor.settings?.public?.jframework?.debug?.graph ? false
J.debugTags = Meteor.settings?.public?.jframework?.debug?.tags ? false
J._nextId = 0
J.getNextId = ->
jid = J._nextId
J._nextId += 1
jid
J.getIds = {}
J.getValueIds = {}
J.forEachIds = {}
J.mapIds = {}
if Meteor.isServer
cslLog = console.log
console.log = ->
cslLog.apply console, arguments
console.debug = ->
cslLog.apply console, arguments
console.info = ->
cslLog.apply console, arguments
console.warn = ->
cslLog.apply console, arguments
console.groupCollapsed = ->
cslLog.apply console, arguments
console.groupEnd = ->
cslLog.apply console, arguments
console.group = ->
cslLog.apply console, arguments
Mongo.Collection.prototype._getFindOptions = (args) ->
# Monkey-patch this function because Meteor uses the check
# library which instantiates heavy Error objects and
# hurts performance.
if args.length < 2
transform: @_transform
else
_.extend(
transform: @_transform
args[1]
)
J.stats = ->
for id, x of J.graph
if x instanceof J.List
if x._valuesVar?
J.inc 'compactLists'
J.inc 'compactListElements', x._valuesVar._value.length
else
J.inc 'expandedLists'
J.inc 'expandedListElements', x._arr.length
if x.fineGrained
J.inc 'fineGrainedLists'
else
J.inc 'courseGrainedLists'
else if x instanceof J.Dict
if x.fineGrained
J.inc 'fineGrainedDicts'
else
J.inc 'courseGrainedDicts'
J.counts