Skip to content

Support asynchronous (promised-based) custom matchers #138

@bradvogel

Description

@bradvogel

For our use case, we'd like to implement custom expressions that make database calls. An example of what we'd like to do (that doesn't work today):

sift.use({
  $existsInDb: async function(expectToExist, name) {
    const existsInDb = !!(await db.users.findOne({ name }));
    return existsInDb === expectToExist;
  }
});

const result = await sift({ $existsInDb: true }, ['bob', 'ben', 'brad']);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions