How to use the sift.default function in sift

To help you get started, we’ve selected a few sift examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Automattic / mongoose / lib / helpers / populate / assignVals.js View on Github external
}
    return valueFilter(val, options, populateOptions);
  }

  for (let i = 0; i < docs.length; ++i) {
    const existingVal = utils.getValue(o.path, docs[i]);
    if (existingVal == null && !getVirtual(o.originalModel.schema, o.path)) {
      continue;
    }

    let valueToSet;
    if (count) {
      valueToSet = numDocs(rawIds[i]);
    } else if (Array.isArray(o.match)) {
      valueToSet = Array.isArray(rawIds[i]) ?
        sift(o.match[i], rawIds[i]) :
        sift(o.match[i], [rawIds[i]])[0];
    } else {
      valueToSet = rawIds[i];
    }

    // If we're populating a map, the existing value will be an object, so
    // we need to transform again
    const originalSchema = o.originalModel.schema;
    const isDoc = get(docs[i], '$__', null) != null;
    let isMap = isDoc ?
      existingVal instanceof Map :
      utils.isPOJO(existingVal);
    // If we pass the first check, also make sure the local field's schematype
    // is map (re: gh-6460)
    isMap = isMap && get(originalSchema._getSchema(o.path), '$isSchemaMap');
    if (!o.isVirtual && isMap) {
github Automattic / mongoose / lib / helpers / populate / assignVals.js View on Github external
return valueFilter(val, options, populateOptions);
  }

  for (let i = 0; i < docs.length; ++i) {
    const existingVal = utils.getValue(o.path, docs[i]);
    if (existingVal == null && !getVirtual(o.originalModel.schema, o.path)) {
      continue;
    }

    let valueToSet;
    if (count) {
      valueToSet = numDocs(rawIds[i]);
    } else if (Array.isArray(o.match)) {
      valueToSet = Array.isArray(rawIds[i]) ?
        sift(o.match[i], rawIds[i]) :
        sift(o.match[i], [rawIds[i]])[0];
    } else {
      valueToSet = rawIds[i];
    }

    // If we're populating a map, the existing value will be an object, so
    // we need to transform again
    const originalSchema = o.originalModel.schema;
    const isDoc = get(docs[i], '$__', null) != null;
    let isMap = isDoc ?
      existingVal instanceof Map :
      utils.isPOJO(existingVal);
    // If we pass the first check, also make sure the local field's schematype
    // is map (re: gh-6460)
    isMap = isMap && get(originalSchema._getSchema(o.path), '$isSchemaMap');
    if (!o.isVirtual && isMap) {
      const _keys = existingVal instanceof Map ?
github Hanul / UPPERCASE / SRC / UPPERCASE-CORE / NODE / CLUSTERING / SHARED_STORE.js View on Github external
EACH(storage, (data, id) => {
				if (Sift(filter)(data) === true) {
					result[id] = data;
				}
			});
github crcn / mesh.js / packages / mesh-memory-ds / lib / index.js View on Github external
dsFind: function (_a) {
        var type = _a.type, collectionName = _a.collectionName, query = _a.query, multi = _a.multi;
        var found = (adapter.get(collectionName) || []).filter(sift_1.default(query));
        return found.length ? multi ? found : [found[0]] : [];
    },
    dsInsert: function (_a) {
github lukaszmakuch / endpoint-imposter / src / mocks.js View on Github external
const buildPatternBasedRequestMatcher = pattern => {
  const siftMatcher = sift(pattern);
  return req => siftMatcher(prepareRequestForMatching(req));
};
github taskcluster / taskcluster / services / web-server / src / loaders / workerManager.js View on Github external
resolved: new Date('December 17, 1997 03:24:00'),
              artifacts: {},
            },

            workerPool: 'banana',
            providerId: 'gcp',
            latestTaskStatus: 'great success',

            quarantineUntil: new Date('December 17, 2095 03:24:00'),
            recentErrors: 2,
            latestStarted: new Date(),
            latestResolved: new Date(),
          },
        ];

        return filter ? Promise.resolve(sift(filter, summaries)) : Promise.resolve(summaries);
      })
    );
github assetgraph / assetgraph / lib / compileQuery.js View on Github external
module.exports = function compileQuery(queryObj = {}) {
  return sift(preprocessQueryObj(queryObj));
};
github crcn / mesh.js / packages / mesh-memory-ds / lib / index.js View on Github external
dsRemove: function (_a) {
        var type = _a.type, collectionName = _a.collectionName, query = _a.query;
        var collection = adapter.get(collectionName) || [];
        var filter = sift_1.default(query);
        var ret = [];
        for (var i = collection.length; i--;) {
            var item = collection[i];
            if (filter(item)) {
                ret.push(item);
                collection.splice(i, 1);
            }
        }
        adapter.set(collectionName, collection);
        return ret;
    }
}); }); };

sift

MongoDB query filtering in JavaScript

MIT
Latest version published 8 months ago

Package Health Score

77 / 100
Full package analysis