Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
"version": "1.0.8",
"description": "A simple module for the server-side allowing you to connect to the ChatGPT and receive the response back in chunks so you can stream the response to the user.",
"main": "index.js",
"exports": {
".": {
"import": "./index.js",
"require": "./index.js"
}
},
"scripts": {
"test": "jest"
},
Expand Down
21 changes: 21 additions & 0 deletions test/commonjs-import.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Test CommonJS import in CommonJS context
const { fetchStreamedChat, fetchStreamedChatContent } = require('../index');

describe('CommonJS imports', () => {
test('should export fetchStreamedChat function via require', () => {
expect(typeof fetchStreamedChat).toBe('function');
expect(fetchStreamedChat.name).toBe('fetchStreamedChat');
});

test('should export fetchStreamedChatContent function via require', () => {
expect(typeof fetchStreamedChatContent).toBe('function');
expect(fetchStreamedChatContent.name).toBe('fetchStreamedChatContent');
});

test('should have correct function signatures', () => {
// fetchStreamedChat should accept 2 parameters
expect(fetchStreamedChat.length).toBe(2);
// fetchStreamedChatContent should accept 1 parameter (options) with optional callbacks
expect(fetchStreamedChatContent.length).toBe(1);
});
});
8 changes: 8 additions & 0 deletions test/es-import-test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Simple script to test ES module imports work
// Run with: node test/es-import-test.mjs

import { fetchStreamedChat, fetchStreamedChatContent } from '../index.js';

console.log('✓ ES module imports working');
console.log(' fetchStreamedChat:', typeof fetchStreamedChat);
console.log(' fetchStreamedChatContent:', typeof fetchStreamedChatContent);