MCPcopy Index your code
hub / github.com/share/sharedb / snapshotComparator

Function snapshotComparator

test/BasicQueryableMemoryDB.js:70–91  ·  view source on GitHub ↗
(sortProperties)

Source from the content-addressed store, hash-verified

68
69// sortProperties is an array whose items are each [propertyName, direction].
70function snapshotComparator(sortProperties) {
71 return function(snapshotA, snapshotB) {
72 for (var i = 0; i < sortProperties.length; i++) {
73 var sortProperty = sortProperties[i];
74 var sortKey = sortProperty[0];
75 var sortDirection = sortProperty[1];
76
77 var aPropVal = snapshotA.data[sortKey];
78 var bPropVal = snapshotB.data[sortKey];
79 if (aPropVal < bPropVal) {
80 return -1 * sortDirection;
81 } else if (aPropVal > bPropVal) {
82 return sortDirection;
83 } else if (aPropVal === bPropVal) {
84 continue;
85 } else {
86 throw new Error('Could not compare ' + aPropVal + ' and ' + bPropVal);
87 }
88 }
89 return 0;
90 };
91}

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…