Tavily Compare

A lightweight Node.js library that compares three entities by querying the Tavily API.
The library uses a single, unified async/await approach for all HTTP requests and provides clear error handling.

Installation

npm install tavily-compare

Usage

import { compare } from 'tavily-compare';

// Set your Tavily API key in the environment
process.env.TAVILY_API_KEY = 'YOUR_TAVILY_API_KEY';

(async () => {
  try {
    const results = await compare('entity1', 'entity2', 'entity3');
    console.log(results);
    // {
    //   entity1: { ...tavily response... },
    //   entity2: { ...tavily response... },
    //   entity3: { ...tavily response... }
    // }
  } catch (err) {
    console.error(err.message);
  }
})();

API

compare(entity1, entity2, entity3)

  • Parameters
    • entity1 string First entity to compare.
    • entity2 string Second entity to compare.
    • entity3 string Third entity to compare.
  • Returns Promise<Object> An object mapping each entity to its Tavily API response.
  • Throws Error If any API call fails or if arguments are missing.

Testing

Run the test suite with:

npm test

The tests mock the Tavily API to ensure no real HTTP requests are made.

License

MIT © Your Name

S
Description
BroJS: Повторный экзамен #2: Сравнительный обзор 3 сущностей (Tavily)
Readme 98 KiB
Languages
JavaScript 50.2%
Python 46.2%
CSS 2.8%
HTML 0.8%