Package Exports
- @utsabc/khoj
- @utsabc/khoj/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@utsabc/khoj) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Khoj
A typed library for search and parsing search engine results as JSON
Installation
Install the package using npm:
npm install khojUsage
Here's a basic example of how to use Khoj:
import { search, SearchEngine, SearchOptions } from 'khoj';
const options: SearchOptions = {
query: 'TypeScript libraries',
limit: 10
};
search(options, SearchEngine.Google)
.then(results => {
console.log(results);
})
.catch(error => {
console.error('Error:', error);
});
API
search(options: SearchOptions, engine?: SearchEngine): Promise<SearchResult[]>
Parameters:
options: SearchOptions object (required)engine: SearchEngine enum (optional, defaults to Google)
SearchOptions
An object with the following properties:
import { SearchOptions, SearchResult, SearchEngine } from "./types";query: string (required) - The search querylimit: number (optional) - Maximum number of results to returnuserAgent: string (optional) - Custom user agent stringstart: number (optional) - Starting position for resultsincludeSites: string (optional) - Comma-separated list of sites to include in the searchexcludeSites: string (optional) - Comma-separated list of sites to exclude from the searchverbose: boolean (optional) - Logs Results if enabled
SearchEngine
An enum with the following values:
Google(default)Bing
SearchResult
An object representing a single search result. The exact structure may vary depending on the search engine used.
Development
To set up the project for development:
Clone the repository
Install dependencies:
npm installBuild the project:
npm run buildRun tests:
npm test
License
This project is licensed under the MIT License.