Search npm packages by web scraping and without indexing all npm packages
It's good question. I used npm module to search packages, but npm first must indexing all packages then search. some of developers have problem with npm search. So I made a decision to create a module to search package without indexing all package. I use web scraping and site search to search packages.
First install the module : npm install enpeem-search
. then :
import search from 'eneepm-search';
search('yo', 1, 2).then((result) => {
console.log(result);
});
/* result
[ { name: 'yo-api-wrapper',
author: 'hinderberg',
description: 'Yo api wrapper for nodejs',
stars: '1',
version: '0.0.1',
url: 'https://www.npmjs.com/package/yo-api-wrapper' } ]
*/
search('some-thing-every-thing', 2).catch(() => {
console.log('Not found'); //'Not found'
})
search(query [,limit] [,skip])
type: String
required: Yes
The search query.
type: Number
required: No
default: 1
Limit result from 1 to 20.
type: Number
required: No
default: 0
Skip the first n
results.
enpeem-search returns a Promise.
result is a Array
that includes result as Object
.
Object has:
name
: name of the packageauthor
: author of the packagedescription
: description of the packagestars
: stars of the packageversion
: version of the packageurl
: URL of the package
Feel free to fill an issue or create a pull request, I'll check it ASAP.
Just don't forgot build your code:
gulp build