get-reading-time 1.3.4 → 1.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/publish.yml +58 -0
- package/dist/index.d.mts +5 -27
- package/dist/index.d.ts +5 -27
- package/dist/index.js +4 -39
- package/dist/index.mjs +4 -38
- package/package.json +3 -3
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
name: Publish get-reading-time to npm
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
# Trigger automatically when pushing to main or master
|
|
5
|
+
push:
|
|
6
|
+
branches:
|
|
7
|
+
- main
|
|
8
|
+
- master
|
|
9
|
+
# Trigger when a GitHub Release is created
|
|
10
|
+
release:
|
|
11
|
+
types: [created]
|
|
12
|
+
# Allow manual trigger from the GitHub Actions tab
|
|
13
|
+
workflow_dispatch:
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
publish:
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
permissions:
|
|
19
|
+
contents: read
|
|
20
|
+
packages: write
|
|
21
|
+
|
|
22
|
+
steps:
|
|
23
|
+
- name: Checkout repository
|
|
24
|
+
uses: actions/checkout@v4
|
|
25
|
+
|
|
26
|
+
- name: Setup Node.js
|
|
27
|
+
uses: actions/setup-node@v4
|
|
28
|
+
with:
|
|
29
|
+
node-version: '20' # the node version to use
|
|
30
|
+
registry-url: 'https://registry.npmjs.org'
|
|
31
|
+
|
|
32
|
+
- name: Install dependencies
|
|
33
|
+
run: npm install --legacy-peer-deps --force
|
|
34
|
+
|
|
35
|
+
- name: Build the package
|
|
36
|
+
run: npm run build
|
|
37
|
+
|
|
38
|
+
- name: Publish to NPM
|
|
39
|
+
run: |
|
|
40
|
+
npm publish --access public
|
|
41
|
+
env:
|
|
42
|
+
# This connects the step to the token we'll create in GitHub secrets
|
|
43
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
44
|
+
|
|
45
|
+
- name: Setup Node.js for GitHub Packages
|
|
46
|
+
uses: actions/setup-node@v4
|
|
47
|
+
with:
|
|
48
|
+
node-version: '20'
|
|
49
|
+
registry-url: 'https://npm.pkg.github.com'
|
|
50
|
+
|
|
51
|
+
- name: Publish to GitHub Packages
|
|
52
|
+
run: |
|
|
53
|
+
# GitHub Packages requires the package name to be scoped to the repository owner
|
|
54
|
+
npm pkg set name="@nurahmed123/get-reading-time"
|
|
55
|
+
npm publish
|
|
56
|
+
env:
|
|
57
|
+
# The GITHUB_TOKEN is automatically provided by GitHub Actions!
|
|
58
|
+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
package/dist/index.d.mts
CHANGED
|
@@ -45,7 +45,7 @@ interface TextAnalysisResult {
|
|
|
45
45
|
*/
|
|
46
46
|
declare function analyzeText(text: string, wordsPerMinute?: number): TextAnalysisResult;
|
|
47
47
|
|
|
48
|
-
type ApiResponse$
|
|
48
|
+
type ApiResponse$2 = {
|
|
49
49
|
/** The corrected text output */
|
|
50
50
|
content?: string;
|
|
51
51
|
/** Error message if the request fails */
|
|
@@ -65,10 +65,10 @@ type ApiResponse$3 = {
|
|
|
65
65
|
* console.log(result.content); // "Hello, how are you?"
|
|
66
66
|
* ```
|
|
67
67
|
*/
|
|
68
|
-
declare function getPunch(text: string): Promise<ApiResponse$
|
|
68
|
+
declare function getPunch(text: string): Promise<ApiResponse$2>;
|
|
69
69
|
|
|
70
70
|
type SupportedLanguages = "English" | "Spanish" | "French" | "German" | "Finnish" | "Chinese" | "Japanese" | "Arabic" | "Russian" | "Hindi" | "Bengali" | "Portuguese" | "Korean" | "Italian" | "Dutch" | "Turkish" | "Polish" | "Swedish" | "Thai" | "Greek" | "Hebrew" | "Vietnamese" | "Indonesian" | "Filipino" | "Romanian" | "Czech" | "Hungarian" | "Danish" | "Norwegian" | "Ukrainian" | "Malay" | "Urdu" | "Persian (Farsi)" | "Tamil" | "Telugu" | "Marathi" | "Gujarati" | "Punjabi" | "Swahili" | "Hausa" | "Yoruba" | "Zulu" | "Burmese" | "Khmer" | "Lao";
|
|
71
|
-
type ApiResponse$
|
|
71
|
+
type ApiResponse$1 = {
|
|
72
72
|
/** The translated content */
|
|
73
73
|
content?: string;
|
|
74
74
|
/** Error message, if any */
|
|
@@ -89,29 +89,7 @@ type ApiResponse$2 = {
|
|
|
89
89
|
* console.log(result.content); // "Bonjour, monde!"
|
|
90
90
|
* ```
|
|
91
91
|
*/
|
|
92
|
-
declare function langTrans(content: string, language: SupportedLanguages): Promise<ApiResponse$
|
|
93
|
-
|
|
94
|
-
type ApiResponse$1 = {
|
|
95
|
-
/** The corrected text output */
|
|
96
|
-
content?: string;
|
|
97
|
-
/** Error message if the request fails */
|
|
98
|
-
error?: string;
|
|
99
|
-
/** HTTP Status Code (200 = Success, 500 = Error) */
|
|
100
|
-
status_code: number;
|
|
101
|
-
};
|
|
102
|
-
/**
|
|
103
|
-
* ✨ Fixes capitalization and punctuation in a given text.
|
|
104
|
-
*
|
|
105
|
-
* @param text - The text that needs correction.
|
|
106
|
-
* @returns A Promise resolving to an object with the corrected text or an error message.
|
|
107
|
-
*
|
|
108
|
-
* @example
|
|
109
|
-
* ```typescript
|
|
110
|
-
* const result = await askAI("How are you?").then((result) => result.content);;
|
|
111
|
-
* console.log(result.content); // "I am good"
|
|
112
|
-
* ```
|
|
113
|
-
*/
|
|
114
|
-
declare function askAI(text: string): Promise<ApiResponse$1>;
|
|
92
|
+
declare function langTrans(content: string, language: SupportedLanguages): Promise<ApiResponse$1>;
|
|
115
93
|
|
|
116
94
|
/**
|
|
117
95
|
* Represents the final response returned by the tableMaker function.
|
|
@@ -170,4 +148,4 @@ declare class aiTexGen {
|
|
|
170
148
|
private formatErrorDetails;
|
|
171
149
|
}
|
|
172
150
|
|
|
173
|
-
export { aiTexGen, analyzeText,
|
|
151
|
+
export { aiTexGen, analyzeText, getPunch, langTrans, tableMaker };
|
package/dist/index.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ interface TextAnalysisResult {
|
|
|
45
45
|
*/
|
|
46
46
|
declare function analyzeText(text: string, wordsPerMinute?: number): TextAnalysisResult;
|
|
47
47
|
|
|
48
|
-
type ApiResponse$
|
|
48
|
+
type ApiResponse$2 = {
|
|
49
49
|
/** The corrected text output */
|
|
50
50
|
content?: string;
|
|
51
51
|
/** Error message if the request fails */
|
|
@@ -65,10 +65,10 @@ type ApiResponse$3 = {
|
|
|
65
65
|
* console.log(result.content); // "Hello, how are you?"
|
|
66
66
|
* ```
|
|
67
67
|
*/
|
|
68
|
-
declare function getPunch(text: string): Promise<ApiResponse$
|
|
68
|
+
declare function getPunch(text: string): Promise<ApiResponse$2>;
|
|
69
69
|
|
|
70
70
|
type SupportedLanguages = "English" | "Spanish" | "French" | "German" | "Finnish" | "Chinese" | "Japanese" | "Arabic" | "Russian" | "Hindi" | "Bengali" | "Portuguese" | "Korean" | "Italian" | "Dutch" | "Turkish" | "Polish" | "Swedish" | "Thai" | "Greek" | "Hebrew" | "Vietnamese" | "Indonesian" | "Filipino" | "Romanian" | "Czech" | "Hungarian" | "Danish" | "Norwegian" | "Ukrainian" | "Malay" | "Urdu" | "Persian (Farsi)" | "Tamil" | "Telugu" | "Marathi" | "Gujarati" | "Punjabi" | "Swahili" | "Hausa" | "Yoruba" | "Zulu" | "Burmese" | "Khmer" | "Lao";
|
|
71
|
-
type ApiResponse$
|
|
71
|
+
type ApiResponse$1 = {
|
|
72
72
|
/** The translated content */
|
|
73
73
|
content?: string;
|
|
74
74
|
/** Error message, if any */
|
|
@@ -89,29 +89,7 @@ type ApiResponse$2 = {
|
|
|
89
89
|
* console.log(result.content); // "Bonjour, monde!"
|
|
90
90
|
* ```
|
|
91
91
|
*/
|
|
92
|
-
declare function langTrans(content: string, language: SupportedLanguages): Promise<ApiResponse$
|
|
93
|
-
|
|
94
|
-
type ApiResponse$1 = {
|
|
95
|
-
/** The corrected text output */
|
|
96
|
-
content?: string;
|
|
97
|
-
/** Error message if the request fails */
|
|
98
|
-
error?: string;
|
|
99
|
-
/** HTTP Status Code (200 = Success, 500 = Error) */
|
|
100
|
-
status_code: number;
|
|
101
|
-
};
|
|
102
|
-
/**
|
|
103
|
-
* ✨ Fixes capitalization and punctuation in a given text.
|
|
104
|
-
*
|
|
105
|
-
* @param text - The text that needs correction.
|
|
106
|
-
* @returns A Promise resolving to an object with the corrected text or an error message.
|
|
107
|
-
*
|
|
108
|
-
* @example
|
|
109
|
-
* ```typescript
|
|
110
|
-
* const result = await askAI("How are you?").then((result) => result.content);;
|
|
111
|
-
* console.log(result.content); // "I am good"
|
|
112
|
-
* ```
|
|
113
|
-
*/
|
|
114
|
-
declare function askAI(text: string): Promise<ApiResponse$1>;
|
|
92
|
+
declare function langTrans(content: string, language: SupportedLanguages): Promise<ApiResponse$1>;
|
|
115
93
|
|
|
116
94
|
/**
|
|
117
95
|
* Represents the final response returned by the tableMaker function.
|
|
@@ -170,4 +148,4 @@ declare class aiTexGen {
|
|
|
170
148
|
private formatErrorDetails;
|
|
171
149
|
}
|
|
172
150
|
|
|
173
|
-
export { aiTexGen, analyzeText,
|
|
151
|
+
export { aiTexGen, analyzeText, getPunch, langTrans, tableMaker };
|
package/dist/index.js
CHANGED
|
@@ -52,7 +52,6 @@ var index_exports = {};
|
|
|
52
52
|
__export(index_exports, {
|
|
53
53
|
aiTexGen: () => aiTexGen,
|
|
54
54
|
analyzeText: () => analyzeText,
|
|
55
|
-
askAI: () => askAI,
|
|
56
55
|
getPunch: () => getPunch,
|
|
57
56
|
langTrans: () => langTrans,
|
|
58
57
|
tableMaker: () => tableMaker
|
|
@@ -251,42 +250,9 @@ function langTrans(content, language) {
|
|
|
251
250
|
});
|
|
252
251
|
}
|
|
253
252
|
|
|
254
|
-
// src/utils/
|
|
253
|
+
// src/utils/tableMaker.ts
|
|
255
254
|
var import_axios3 = __toESM(require("axios"));
|
|
256
255
|
var API_URL3 = "https://ai.hackclub.com/chat/completions";
|
|
257
|
-
function askAI(text) {
|
|
258
|
-
return __async(this, null, function* () {
|
|
259
|
-
var _a, _b, _c, _d, _e, _f;
|
|
260
|
-
try {
|
|
261
|
-
const response = yield import_axios3.default.post(API_URL3, {
|
|
262
|
-
messages: [
|
|
263
|
-
{
|
|
264
|
-
role: "user",
|
|
265
|
-
content: `"${text}"`
|
|
266
|
-
}
|
|
267
|
-
],
|
|
268
|
-
temperature: 0
|
|
269
|
-
// Keep corrections consistent
|
|
270
|
-
});
|
|
271
|
-
const correctedText = (_d = (_c = (_b = (_a = response.data.choices) == null ? void 0 : _a[0]) == null ? void 0 : _b.message) == null ? void 0 : _c.content) == null ? void 0 : _d.trim();
|
|
272
|
-
if (!correctedText) {
|
|
273
|
-
console.warn("API returned no content.");
|
|
274
|
-
return { content: "No content generated", status_code: 200 };
|
|
275
|
-
}
|
|
276
|
-
return { content: correctedText, status_code: 200 };
|
|
277
|
-
} catch (error) {
|
|
278
|
-
console.error("Error :", error);
|
|
279
|
-
return {
|
|
280
|
-
error: ((_f = (_e = error.response) == null ? void 0 : _e.data) == null ? void 0 : _f.error) || "Failed to get response from the AI server.",
|
|
281
|
-
status_code: 500
|
|
282
|
-
};
|
|
283
|
-
}
|
|
284
|
-
});
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
// src/utils/tableMaker.ts
|
|
288
|
-
var import_axios4 = __toESM(require("axios"));
|
|
289
|
-
var API_URL4 = "https://ai.hackclub.com/chat/completions";
|
|
290
256
|
function tableMaker(content) {
|
|
291
257
|
return __async(this, null, function* () {
|
|
292
258
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
@@ -294,7 +260,7 @@ function tableMaker(content) {
|
|
|
294
260
|
return { error: "Input data cannot be empty.", status_code: 400 };
|
|
295
261
|
}
|
|
296
262
|
try {
|
|
297
|
-
const response = yield
|
|
263
|
+
const response = yield import_axios3.default.post(API_URL3, {
|
|
298
264
|
messages: [
|
|
299
265
|
{
|
|
300
266
|
role: "user",
|
|
@@ -348,7 +314,7 @@ function formatMarkdownTable(table) {
|
|
|
348
314
|
}
|
|
349
315
|
|
|
350
316
|
// src/utils/aiTexGen.ts
|
|
351
|
-
var
|
|
317
|
+
var import_axios4 = __toESM(require("axios"));
|
|
352
318
|
var aiTexGen = class {
|
|
353
319
|
// Constructor initializes the API URL
|
|
354
320
|
constructor() {
|
|
@@ -379,7 +345,7 @@ var aiTexGen = class {
|
|
|
379
345
|
this.validateInputs(topic, wordCount);
|
|
380
346
|
const formatInstruction = markdown ? "Use proper Markdown formatting." : "Use plain text formatting.";
|
|
381
347
|
const prompt = `Write a detailed article about ${topic}, aiming for a maximum of ${wordCount} words. ${formatInstruction}`;
|
|
382
|
-
const response = yield
|
|
348
|
+
const response = yield import_axios4.default.post(this.apiUrl, {
|
|
383
349
|
messages: [
|
|
384
350
|
{
|
|
385
351
|
role: "user",
|
|
@@ -426,7 +392,6 @@ var aiTexGen = class {
|
|
|
426
392
|
0 && (module.exports = {
|
|
427
393
|
aiTexGen,
|
|
428
394
|
analyzeText,
|
|
429
|
-
askAI,
|
|
430
395
|
getPunch,
|
|
431
396
|
langTrans,
|
|
432
397
|
tableMaker
|
package/dist/index.mjs
CHANGED
|
@@ -211,42 +211,9 @@ function langTrans(content, language) {
|
|
|
211
211
|
});
|
|
212
212
|
}
|
|
213
213
|
|
|
214
|
-
// src/utils/
|
|
214
|
+
// src/utils/tableMaker.ts
|
|
215
215
|
import axios3 from "axios";
|
|
216
216
|
var API_URL3 = "https://ai.hackclub.com/chat/completions";
|
|
217
|
-
function askAI(text) {
|
|
218
|
-
return __async(this, null, function* () {
|
|
219
|
-
var _a, _b, _c, _d, _e, _f;
|
|
220
|
-
try {
|
|
221
|
-
const response = yield axios3.post(API_URL3, {
|
|
222
|
-
messages: [
|
|
223
|
-
{
|
|
224
|
-
role: "user",
|
|
225
|
-
content: `"${text}"`
|
|
226
|
-
}
|
|
227
|
-
],
|
|
228
|
-
temperature: 0
|
|
229
|
-
// Keep corrections consistent
|
|
230
|
-
});
|
|
231
|
-
const correctedText = (_d = (_c = (_b = (_a = response.data.choices) == null ? void 0 : _a[0]) == null ? void 0 : _b.message) == null ? void 0 : _c.content) == null ? void 0 : _d.trim();
|
|
232
|
-
if (!correctedText) {
|
|
233
|
-
console.warn("API returned no content.");
|
|
234
|
-
return { content: "No content generated", status_code: 200 };
|
|
235
|
-
}
|
|
236
|
-
return { content: correctedText, status_code: 200 };
|
|
237
|
-
} catch (error) {
|
|
238
|
-
console.error("Error :", error);
|
|
239
|
-
return {
|
|
240
|
-
error: ((_f = (_e = error.response) == null ? void 0 : _e.data) == null ? void 0 : _f.error) || "Failed to get response from the AI server.",
|
|
241
|
-
status_code: 500
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
// src/utils/tableMaker.ts
|
|
248
|
-
import axios4 from "axios";
|
|
249
|
-
var API_URL4 = "https://ai.hackclub.com/chat/completions";
|
|
250
217
|
function tableMaker(content) {
|
|
251
218
|
return __async(this, null, function* () {
|
|
252
219
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
@@ -254,7 +221,7 @@ function tableMaker(content) {
|
|
|
254
221
|
return { error: "Input data cannot be empty.", status_code: 400 };
|
|
255
222
|
}
|
|
256
223
|
try {
|
|
257
|
-
const response = yield
|
|
224
|
+
const response = yield axios3.post(API_URL3, {
|
|
258
225
|
messages: [
|
|
259
226
|
{
|
|
260
227
|
role: "user",
|
|
@@ -308,7 +275,7 @@ function formatMarkdownTable(table) {
|
|
|
308
275
|
}
|
|
309
276
|
|
|
310
277
|
// src/utils/aiTexGen.ts
|
|
311
|
-
import
|
|
278
|
+
import axios4 from "axios";
|
|
312
279
|
var aiTexGen = class {
|
|
313
280
|
// Constructor initializes the API URL
|
|
314
281
|
constructor() {
|
|
@@ -339,7 +306,7 @@ var aiTexGen = class {
|
|
|
339
306
|
this.validateInputs(topic, wordCount);
|
|
340
307
|
const formatInstruction = markdown ? "Use proper Markdown formatting." : "Use plain text formatting.";
|
|
341
308
|
const prompt = `Write a detailed article about ${topic}, aiming for a maximum of ${wordCount} words. ${formatInstruction}`;
|
|
342
|
-
const response = yield
|
|
309
|
+
const response = yield axios4.post(this.apiUrl, {
|
|
343
310
|
messages: [
|
|
344
311
|
{
|
|
345
312
|
role: "user",
|
|
@@ -385,7 +352,6 @@ var aiTexGen = class {
|
|
|
385
352
|
export {
|
|
386
353
|
aiTexGen,
|
|
387
354
|
analyzeText,
|
|
388
|
-
askAI,
|
|
389
355
|
getPunch,
|
|
390
356
|
langTrans,
|
|
391
357
|
tableMaker
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "get-reading-time",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.5",
|
|
4
4
|
"main": "/dist/index.js",
|
|
5
5
|
"module": "/dist/index.mjs",
|
|
6
6
|
"types": "/dist/index.d.ts",
|
|
@@ -9,14 +9,14 @@
|
|
|
9
9
|
"start": "node dist/test.js",
|
|
10
10
|
"lint": "tsc",
|
|
11
11
|
"prepare": "npm run build"
|
|
12
|
-
},
|
|
12
|
+
},
|
|
13
13
|
"repository": {
|
|
14
14
|
"type": "git",
|
|
15
15
|
"url": "git+https://github.com/nurahmed123/get-reading-time.git",
|
|
16
16
|
"license": "https://github.com/nurahmed123/get-reading-time/blob/main/LICENSE"
|
|
17
17
|
},
|
|
18
18
|
"publishConfig": {
|
|
19
|
-
"
|
|
19
|
+
"access": "public"
|
|
20
20
|
},
|
|
21
21
|
"keywords": [
|
|
22
22
|
"get-reading-time",
|