GithubHelp home page GithubHelp logo

alexxnica / queries Goto Github PK

View Code? Open in Web Editor NEW

This project forked from npms-io/queries

0.0 1.0 0.0 60 KB

Module that offers a variety of queries around npms data.

License: MIT License

JavaScript 100.00%

queries's Introduction

@npms/queries

NPM version Downloads Build Status Coverage Status Dependency status Dev Dependency status

Module that offers a variety of queries around npms data.

Installation

$ npm install @npms/queries

Usage

For now, only queries related to search are available. Though, the goal of this module is to provide other interesting queries in the near future, such as top ranked modules, top authors, etc.

.search(q, esClient, [options]) -> Promise

Performs a search query.

Besides normal text, q supports qualifiers to express filters and other modifiers. The esClient accepts a elasticsearch instance or a config to instantiate it.

You may read the API docs to know which qualifiers are available.

const queries = require('@npms/queries');

// ...
queries.search('test framework', esClient)
.then((res) => {
    console.log('total', res.total);
    console.log('results', res.results);
});

Available options:

  • from: The offset in which to start searching from, defaults to 0
  • size: The total number of results to return, defaults to 25
  • throwOnInvalid: Whether to reject the promise if the query has invalid qualifiers or not, defaults to false (if false, invalid qualifiers will be removed from q)

.search.suggestions(q, esClient, [options]) -> Promise

Fetch search suggestions to be typically displayed when doing autocomplete.

Only normal text is supported in q but any qualifiers will be automatically discarded. The esClient accepts a elasticsearch instance or a config to instantiate it.

const queries = require('@npms/queries');

// ...
queries.search.suggestions('gulp', esClient)
.then((suggestions) => console.log('suggestions', suggestions));

Available options:

  • size: The total number of results to return, defaults to 25

Tests

$ npm test
$ npm test-cov to get coverage report

License

Released under the MIT License.

queries's People

Contributors

satazor avatar atduarte avatar greenkeeperio-bot avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.