viddo/atom-textual-velocity

View on GitHub
flow-typed/npm/sifter_vx.x.x.js

Summary

Maintainability
A
0 mins
Test Coverage
// flow-typed signature: e74609033981b389b17494ffa17272ef
// flow-typed version: <<STUB>>/sifter_v0.5.3/flow_v0.62.0

/**
 * This is an autogenerated libdef stub for:
 *
 *   'sifter'
 *
 * Fill this stub out by replacing all the `any` types.
 *
 * Once filled out, we encourage you to share your work with the
 * community by sending a pull request to:
 * https://github.com/flowtype/flow-typed
 */

type sifter$SortSearchOptions = {
  direction?: 'asc' | 'desc';
  field: string;
}

type sifter$SearchOptions = {
  fields: string[];
  limit?: number | void;
  sort?: sifter$SortSearchOptions[];
  sort_empty?: sifter$SortSearchOptions[];
  filter?: boolean;
  conjunction?: 'and' | 'or';
  nesting?: boolean;
  respect_word_boundaries?: boolean;
}

type sifter$SearchResult<T> = {
  options: sifter$SearchOptions,
  query: string,
  tokens: Array<{
    string: string,
    regex: RegExp
  }>,
  total: number,
  items: Array<{
    id: T,
    score: number
  }>
}

declare module 'sifter' {

  declare export type SortSearchOptions = sifter$SortSearchOptions;
  declare export type SearchOptions = sifter$SearchOptions;
  declare export type SearchResult<T> = sifter$SearchResult<T>;

  declare class Sifter<T> {
    items: T;
    constructor (items?: T): this;
    search(query: string, options: sifter$SearchOptions): sifter$SearchResult<$Keys<T>>
  }

  declare module.exports: typeof Sifter;
}