### Install libnpmsearch Source: https://www.npmjs.com/package/libnpmsearch/v/1.0.0?activeTab=dependents Command to install the libnpmsearch package using npm. ```bash $ npm install libnpmsearch ``` -------------------------------- ### Stream Search Results with libnpmsearch (Example Output) Source: https://www.npmjs.com/package/libnpmsearch/v/2.0.2?activeTab=dependencies This example shows the format of individual entries emitted by the `search.stream` function. Each entry represents a package matching the search query. ```javascript => // entry 1 { name: 'libnpm', description: 'programmatic npm API', ...etc } // entry 2 { name: 'libnpmsearch', description: 'Programmatic API for searching in npm and compatible registries', ...etc } // etc ``` -------------------------------- ### Basic Search with libnpmsearch Source: https://www.npmjs.com/package/libnpmsearch/v/1.0.0?activeTab=dependencies Demonstrates how to perform a basic search using the libnpmsearch library. Requires the 'libnpmsearch' package to be installed. ```javascript const search = require('libnpmsearch') console.log(await search('libnpm')) => [ { name: 'libnpm', description: 'programmatic npm API', ...etc }, { name: 'libnpmsearch', description: 'Programmatic API for searching in npm and compatible registries', ...etc }, ...more ] ``` -------------------------------- ### Search with Detailed Results Source: https://www.npmjs.com/package/libnpmsearch/v/9.0.1 Example of using the search function with the 'detailed' option enabled to get more information about package scores. Requires an async context. ```javascript await search('libnpm', { detailed: true }) => { package: { name: 'libnpm', description: 'programmatic npm API', ...etc }, score: 0.98, searchScore: 1 } ``` -------------------------------- ### Example Streamed Search Output Source: https://www.npmjs.com/package/libnpmsearch/v/7.0.4?activeTab=code Illustrates the output of processing streamed search results, showing individual package objects as they are logged to the console. ```javascript // entry 1 { name: 'libnpm', description: 'programmatic npm API', ...etc } // entry 2 { name: 'libnpmsearch', description: 'Programmatic API for searching in npm and compatible registries', ...etc } // etc ``` -------------------------------- ### Search with libnpmsearch (Promise API) Source: https://www.npmjs.com/package/libnpmsearch/v/1.0.0?activeTab=dependencies Shows how to use the `search` function from libnpmsearch to get search results as a Promise. The `query` can be a string or an array of terms. An optional `opts.limit` can be provided. ```javascript await search('libnpm') => [ { name: 'libnpm', description: 'programmatic npm API', ...etc }, { name: 'libnpmsearch', description: 'Programmatic API for searching in npm and compatible registries', ...etc }, ...more ] ``` -------------------------------- ### Install Specific Version of libnpmsearch Source: https://www.npmjs.com/package/libnpmsearch/v/5.0.3 Command to install a specific version of the libnpmsearch package. ```bash npm i libnpmsearch@5.0.3 ``` -------------------------------- ### Install Specific Version of libnpmsearch Source: https://www.npmjs.com/package/libnpmsearch/v/3.0.1?activeTab=readme Command to install a specific version (3.0.1) of the libnpmsearch package. ```bash npm i libnpmsearch@3.0.1 ``` -------------------------------- ### Install Specific Version of libnpmsearch Source: https://www.npmjs.com/package/libnpmsearch/v/4.0.1?activeTab=dependencies Command to install a specific version (4.0.1) of the libnpmsearch package. ```bash npm i libnpmsearch@4.0.1 ``` -------------------------------- ### Basic Search with libnpmsearch Source: https://www.npmjs.com/package/libnpmsearch/v/1.0.0?activeTab=dependents Demonstrates how to perform a basic search for packages using the `search` function. Requires `async/await`. ```javascript const search = require('libnpmsearch') console.log(await search('libnpm')) ``` -------------------------------- ### Search with Authentication Token Source: https://www.npmjs.com/package/libnpmsearch/v/9.0.1 Shows how to pass an authentication token for private registry access. Requires an async context. ```javascript await search('private-package', { token: 'YOUR_AUTH_TOKEN' }) => [ { name: 'private-package', description: 'A private package', ...etc }, ... ] ``` -------------------------------- ### Search with Pagination Source: https://www.npmjs.com/package/libnpmsearch/v/9.0.1 Illustrates how to paginate search results using the 'limit' and 'from' options. Requires an async context. ```javascript await search('libnpm', { limit: 10, from: 20 }) => [ { name: 'libnpm', description: 'programmatic npm API', ...etc }, ... ] ``` -------------------------------- ### Advanced Search with libnpmsearch Source: https://www.npmjs.com/package/libnpmsearch/v/1.0.0?activeTab=versions Demonstrates how to use the `search()` function with a query. The returned Promise resolves to an array of search results. ```javascript await search('libnpm') ``` -------------------------------- ### Search with Detailed Results Source: https://www.npmjs.com/package/libnpmsearch/v/7.0.3?activeTab=versions Shows how to use the `detailed: true` option to get more information about search results, including scoring. This is useful for building UIs. ```javascript await search('libnpm', { detailed: true }) => { name: 'libnpm', description: 'programmatic npm API', score: 0.99, searchScore: 1, package: { name: 'libnpm', version: '7.0.3', description: 'programmatic npm API', ... } } ``` -------------------------------- ### Streaming Search Results with libnpmsearch Source: https://www.npmjs.com/package/libnpmsearch/v/1.0.0?activeTab=dependents Demonstrates how to use `search.stream` to receive search results as a stream. This is useful for handling a large number of results efficiently. ```javascript search.stream('libnpm').on('data', console.log) ``` -------------------------------- ### Search with Limit and Offset Source: https://www.npmjs.com/package/libnpmsearch/v/7.0.3?activeTab=versions Demonstrates how to paginate search results using the `limit` and `from` options. `limit` specifies the maximum number of results, and `from` sets the offset for pagination. ```javascript await search('libnpm', { limit: 10, from: 20 }) => [ { name: 'libnpm', description: 'programmatic npm API', ...etc } ] ``` -------------------------------- ### Search with Custom Weights Source: https://www.npmjs.com/package/libnpmsearch/v/9.0.1 Demonstrates how to set custom weights for quality, maintenance, and popularity metrics when sorting search results. Requires an async context. ```javascript await search('libnpm', { quality: 0.5, maintenance: 0.65, popularity: 0.98 }) => [ { name: 'libnpm', description: 'programmatic npm API', ...etc }, ... ] ``` -------------------------------- ### `search(query, [opts])` Source: https://www.npmjs.com/package/libnpmsearch/v/3.0.1?activeTab=dependencies Performs a search query against the npm registry and returns a Promise that resolves to an array of search results. ```APIDOC ## `search(query, [opts]) -> Promise` ### Description Performs a search query against the npm registry. The `query` can be a String or an Array of search terms. The `opts.limit` parameter can be used to constrain the number of results returned. ### Parameters #### `query` - **Type**: String | Array - **Description**: The search term(s). #### `opts` (Optional) - **Type**: Object - **Description**: Options to customize the search. See 'Search Options' for details. ### Returns - **Type**: Promise> - **Description**: A Promise that resolves to an array of search results. Each result object has the following format: ``` { name: String, version: SemverString, description: String || null, maintainers: [ { username: String, email: String }, ...etc ] || null, keywords: [String] || null, date: Date || null } ``` ### Example ```javascript const search = require('libnpmsearch'); const results = await search('libnpm', { limit: 10 }); console.log(results); ``` ``` -------------------------------- ### Search for packages Source: https://www.npmjs.com/package/libnpmsearch/v/3.0.1?activeTab=dependents Use the `search` function to find packages matching a query. It returns a promise that resolves to an array of package objects. ```javascript const search = require('libnpmsearch') console.log(await search('libnpm')) => [ { name: 'libnpm', description: 'programmatic npm API', ...etc }, { name: 'libnpmsearch', description: 'Programmatic API for searching in npm and compatible registries', ...etc }, ...more ] ``` ```javascript await search('libnpm') => [ { name: 'libnpm', description: 'programmatic npm API', ...etc }, { name: 'libnpmsearch', description: 'Programmatic API for searching in npm and compatible registries', ...etc }, ...more ] ``` -------------------------------- ### Search Results Format Source: https://www.npmjs.com/package/libnpmsearch/v/7.0.4?activeTab=code Illustrates the expected structure of search results returned by the `search()` function, including package name, version, description, maintainers, keywords, and date. ```json { name: 'libnpm', version: 'SemverString', description: 'String || null', maintainers: [ { username: 'String', email: 'String' }, ...etc ] || null, keywords: [String] || null, date: Date || null } ``` -------------------------------- ### search(query, [opts]) Source: https://www.npmjs.com/package/libnpmsearch/v/1.0.0?activeTab=dependencies Performs a search query against the npm registry and returns a Promise that resolves to an array of search results. The query can be a string or an array of search terms. Options can be passed to control the search, such as limiting the number of results. ```APIDOC ## search(query, [opts]) -> Promise ### Description Performs a search query against the npm registry and returns a Promise that resolves to an array of search results. The query can be a string or an array of search terms. Options can be passed to control the search, such as limiting the number of results. ### Parameters #### Path Parameters * None #### Query Parameters * **query** (String | Array) - The search term(s). * **opts.limit** (Number) - Optional. Limits the number of returned results. * **opts.token** (String) - Optional. Authentication token for the registry. * **opts.Promise** (Object) - Optional. A custom Promise class to use. ### Request Example ```javascript await search('libnpm') ``` ### Response #### Success Response (Promise resolves to Array) - **name** (String) - The name of the package. - **version** (SemverString) - The version of the package. - **description** (String || null) - The package description. - **maintainers** (Array<{username: String, email: String}> || null) - List of maintainers. - **keywords** (Array || null) - Associated keywords. - **date** (Date || null) - The publication date. #### Response Example ```json [ { "name": "libnpm", "description": "programmatic npm API", "version": "1.0.0", "maintainers": null, "keywords": null, "date": null }, { "name": "libnpmsearch", "description": "Programmatic API for searching in npm and compatible registries", "version": "1.0.0", "maintainers": null, "keywords": null, "date": null } ] ``` ``` -------------------------------- ### search(query, [opts]) Source: https://www.npmjs.com/package/libnpmsearch/v/1.0.0?activeTab=readme Performs a search query against the npm registry and returns a Promise that resolves to an array of search results. The query can be a string or an array of search terms. Options can be passed to control the search, such as limiting the number of results. ```APIDOC ## search(query, [opts]) -> Promise ### Description Performs a search query against the npm registry and returns a Promise that resolves to an array of search results. The query can be a string or an array of search terms. Options can be passed to control the search, such as limiting the number of results. ### Parameters #### Path Parameters None #### Query Parameters * **query** (String | Array) - Required - The search term(s). * **opts.limit** (Number) - Optional - The maximum number of results to return. * **opts.token** (String) - Optional - Authentication token for the registry. * **opts.Promise** (Object) - Optional - A custom Promise class to use. ### Request Example ```javascript await search('libnpm') ``` ### Response #### Success Response (Promise Resolved) - **name** (String) - The name of the package. - **version** (SemverString) - The version of the package. - **description** (String || null) - The package description. - **maintainers** (Array || null) - An array of maintainer objects, each with username and email. - **keywords** (Array || null) - An array of keywords associated with the package. - **date** (Date || null) - The publication date of the package. #### Response Example ```json [ { "name": "libnpm", "description": "programmatic npm API", "version": "1.0.0", "maintainers": null, "keywords": null, "date": "2023-01-01T12:00:00.000Z" } ] ``` ``` -------------------------------- ### Stream Search Results with libnpmsearch Source: https://www.npmjs.com/package/libnpmsearch/v/1.0.0?activeTab=dependencies Demonstrates how to use `search.stream` to receive search results as a stream. Each entry is emitted as a 'data' event. An optional `opts.limit` can be provided. ```javascript search.stream('libnpm').on('data', console.log) => // entry 1 { name: 'libnpm', description: 'programmatic npm API', ...etc } // entry 2 { name: 'libnpmsearch', description: 'Programmatic API for searching in npm and compatible registries', ...etc } // etc ``` -------------------------------- ### search.stream(query, [opts]) Source: https://www.npmjs.com/package/libnpmsearch/v/1.0.0?activeTab=readme Performs a search query against the npm registry and returns a Stream that emits individual search results. This is useful for handling large result sets efficiently. The query can be a string or an array of search terms. Options can be passed to control the search, such as limiting the number of results. ```APIDOC ## search.stream(query, [opts]) -> Stream ### Description Performs a search query against the npm registry and returns a Stream that emits individual search results. This is useful for handling large result sets efficiently. The query can be a string or an array of search terms. Options can be passed to control the search, such as limiting the number of results. ### Parameters #### Path Parameters None #### Query Parameters * **query** (String | Array) - Required - The search term(s). * **opts.limit** (Number) - Optional - The maximum number of results to return. You may receive more, or fewer results, at the endpoint's discretion. * **opts.token** (String) - Optional - Authentication token for the registry. * **opts.Promise** (Object) - Optional - A custom Promise class to use. ### Request Example ```javascript search.stream('libnpm').on('data', console.log) ``` ### Response #### Success Response (Stream Emits) Each emitted entry from the stream has the following format: - **name** (String) - The name of the package. - **version** (SemverString) - The version of the package. - **description** (String || null) - The package description. - **maintainers** (Array || null) - An array of maintainer objects, each with username and email. - **keywords** (Array || null) - An array of keywords associated with the package. - **date** (Date || null) - The publication date of the package. #### Response Example (Emitted Data) ```json { "name": "libnpm", "description": "programmatic npm API", "version": "1.0.0", "maintainers": null, "keywords": null, "date": "2023-01-01T12:00:00.000Z" } ``` ``` -------------------------------- ### search.stream(query, [opts]) Source: https://www.npmjs.com/package/libnpmsearch/v/1.0.0?activeTab=dependencies Performs a search query against the npm registry and returns a Stream that emits each search result individually. This is useful for handling large result sets efficiently. The query can be a string or an array of search terms. Options can be passed to control the search, such as limiting the number of results. ```APIDOC ## search.stream(query, [opts]) -> Stream ### Description Performs a search query against the npm registry and returns a Stream that emits each search result individually. This is useful for handling large result sets efficiently. The query can be a string or an array of search terms. Options can be passed to control the search, such as limiting the number of results. ### Parameters #### Path Parameters * None #### Query Parameters * **query** (String | Array) - The search term(s). * **opts.limit** (Number) - Optional. Limits the number of returned results. * **opts.token** (String) - Optional. Authentication token for the registry. * **opts.Promise** (Object) - Optional. A custom Promise class to use. ### Request Example ```javascript search.stream('libnpm').on('data', console.log) ``` ### Response #### Success Response (Stream emits objects) - **name** (String) - The name of the package. - **version** (SemverString) - The version of the package. - **description** (String || null) - The package description. - **maintainers** (Array<{username: String, email: String}> || null) - List of maintainers. - **keywords** (Array || null) - Associated keywords. - **date** (Date || null) - The publication date. #### Response Example ```json // entry 1 { "name": "libnpm", "description": "programmatic npm API", "version": "1.0.0", "maintainers": null, "keywords": null, "date": null } // entry 2 { "name": "libnpmsearch", "description": "Programmatic API for searching in npm and compatible registries", "version": "1.0.0", "maintainers": null, "keywords": null, "date": null } ``` ``` -------------------------------- ### search(query, [opts]) Source: https://www.npmjs.com/package/libnpmsearch/v/1.0.0 Performs a search query against the npm registry. The query can be a string or an array of strings. Options can be provided to limit results or pass through registry options. ```APIDOC ## search(query, [opts]) -> Promise ### Description Performs a search query against the npm registry. The query can be a string or an array of strings. Options can be provided to limit results or pass through registry options. ### Parameters #### Path Parameters None #### Query Parameters * **query** (String | Array) - Required - The search term(s). * **opts** (Object) - Optional - Configuration options. * **opts.limit** (Number) - Optional - The maximum number of results to request from the API. * **opts.token** (String) - Optional - Authentication token for the registry. * **opts.Promise** (Object) - Optional - A custom Promise class to use. ### Request Example ```javascript await search('libnpm') ``` ### Response #### Success Response - **Array** - An array of search result objects. * **name** (String) - The name of the package. * **version** (SemverString) - The version of the package. * **description** (String || null) - The package description. * **maintainers** (Array<{username: String, email: String}> || null) - List of maintainers. * **keywords** (Array || null) - List of keywords. * **date** (Date || null) - The publication date. #### Response Example ```json [ { "name": "libnpm", "description": "programmatic npm API", "version": "1.0.0", "maintainers": [], "keywords": [], "date": "2023-01-01T12:00:00.000Z" } ] ``` ```