mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Separated Matcher.
This commit is contained in:
30
packages/minimongo/common.js
Normal file
30
packages/minimongo/common.js
Normal file
@@ -0,0 +1,30 @@
|
||||
import {LocalCollection} from './local_collection.js';
|
||||
|
||||
export function isIndexable (obj) {
|
||||
return Array.isArray(obj) || LocalCollection._isPlainObject(obj);
|
||||
}
|
||||
|
||||
export function isNumericKey (s) {
|
||||
return /^[0-9]+$/.test(s);
|
||||
}
|
||||
|
||||
// Returns true if this is an object with at least one key and all keys begin
|
||||
// with $. Unless inconsistentOK is set, throws if some keys begin with $ and
|
||||
// others don't.
|
||||
export function isOperatorObject (valueSelector, inconsistentOK) {
|
||||
if (!LocalCollection._isPlainObject(valueSelector))
|
||||
return false;
|
||||
|
||||
var theseAreOperators = undefined;
|
||||
Object.keys(valueSelector).forEach(function (selKey) {
|
||||
var thisIsOperator = selKey.substr(0, 1) === '$';
|
||||
if (theseAreOperators === undefined) {
|
||||
theseAreOperators = thisIsOperator;
|
||||
} else if (theseAreOperators !== thisIsOperator) {
|
||||
if (!inconsistentOK)
|
||||
throw new Error(`Inconsistent operator: ${JSON.stringify(valueSelector)}`);
|
||||
theseAreOperators = false;
|
||||
}
|
||||
});
|
||||
return !!theseAreOperators; // {} has no operators
|
||||
}
|
||||
1259
packages/minimongo/matcher.js
Normal file
1259
packages/minimongo/matcher.js
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -24,6 +24,9 @@ Package.onUse(api => {
|
||||
|
||||
api.addFiles('minimongo.js');
|
||||
api.addFiles('minimongo_server.js', 'server');
|
||||
|
||||
// api.mainModule('client_main.js', 'client');
|
||||
// api.mainModule('server_main.js', 'server');
|
||||
});
|
||||
|
||||
Package.onTest(api => {
|
||||
|
||||
Reference in New Issue
Block a user