Separated Matcher.

This commit is contained in:
Radosław Miernik
2017-07-11 21:58:16 +02:00
parent 7275e1d080
commit 7cf9c2116c
4 changed files with 1317 additions and 1311 deletions

View 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
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -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 => {