@utilix-tech/sdk 0.6.0 → 0.8.0

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.
@@ -2332,6 +2332,73 @@ function detectPassiveVoice(text) {
2332
2332
  const passivePercent = totalSentences > 0 ? Math.round(passiveSentences / totalSentences * 1e3) / 10 : 0;
2333
2333
  return { sentences: analyzed, totalSentences, passiveSentences, passivePercent };
2334
2334
  }
2335
+ function countSyllables(word) {
2336
+ const w = word.toLowerCase().replace(/[^a-z]/g, "");
2337
+ if (w.length === 0) return 0;
2338
+ if (w.length <= 3) return 1;
2339
+ let count = 0;
2340
+ let prevWasVowel = false;
2341
+ for (const ch of w) {
2342
+ const isVowel = "aeiouy".includes(ch);
2343
+ if (isVowel && !prevWasVowel) count++;
2344
+ prevWasVowel = isVowel;
2345
+ }
2346
+ if (w.endsWith("e") && !w.endsWith("le") && count > 1) count--;
2347
+ if (w.endsWith("le") && w.length > 2 && !"aeiouy".includes(w[w.length - 3])) count++;
2348
+ return Math.max(count, 1);
2349
+ }
2350
+ function readabilityGradeLabel(fleschReadingEase) {
2351
+ if (fleschReadingEase >= 90) return "Very easy (5th grade)";
2352
+ if (fleschReadingEase >= 80) return "Easy (6th grade)";
2353
+ if (fleschReadingEase >= 70) return "Fairly easy (7th grade)";
2354
+ if (fleschReadingEase >= 60) return "Standard (8th-9th grade)";
2355
+ if (fleschReadingEase >= 50) return "Fairly difficult (10th-12th grade)";
2356
+ if (fleschReadingEase >= 30) return "Difficult (college)";
2357
+ return "Very difficult (college graduate)";
2358
+ }
2359
+ function round1(n) {
2360
+ return Math.round(n * 10) / 10;
2361
+ }
2362
+ function scoreReadability(text) {
2363
+ const sentences = splitIntoSentences(text);
2364
+ const words = text.match(/[a-zA-Z']+/g) ?? [];
2365
+ const sentenceCount2 = Math.max(sentences.length, 1);
2366
+ const wordCount = words.length;
2367
+ const syllableCounts = words.map(countSyllables);
2368
+ const syllableCount2 = syllableCounts.reduce((a, b) => a + b, 0);
2369
+ const complexWordCount = syllableCounts.filter((c) => c >= 3).length;
2370
+ if (wordCount === 0) {
2371
+ return {
2372
+ wordCount: 0,
2373
+ sentenceCount: 0,
2374
+ syllableCount: 0,
2375
+ complexWordCount: 0,
2376
+ avgWordsPerSentence: 0,
2377
+ avgSyllablesPerWord: 0,
2378
+ fleschReadingEase: 0,
2379
+ fleschKincaidGrade: 0,
2380
+ gunningFog: 0,
2381
+ readingLevel: "No text to score"
2382
+ };
2383
+ }
2384
+ const avgWordsPerSentence = wordCount / sentenceCount2;
2385
+ const avgSyllablesPerWord = syllableCount2 / wordCount;
2386
+ const fleschReadingEase = round1(206.835 - 1.015 * avgWordsPerSentence - 84.6 * avgSyllablesPerWord);
2387
+ const fleschKincaidGrade = round1(0.39 * avgWordsPerSentence + 11.8 * avgSyllablesPerWord - 15.59);
2388
+ const gunningFog = round1(0.4 * (avgWordsPerSentence + 100 * (complexWordCount / wordCount)));
2389
+ return {
2390
+ wordCount,
2391
+ sentenceCount: sentences.length,
2392
+ syllableCount: syllableCount2,
2393
+ complexWordCount,
2394
+ avgWordsPerSentence: round1(avgWordsPerSentence),
2395
+ avgSyllablesPerWord: round1(avgSyllablesPerWord),
2396
+ fleschReadingEase,
2397
+ fleschKincaidGrade,
2398
+ gunningFog,
2399
+ readingLevel: readabilityGradeLabel(fleschReadingEase)
2400
+ };
2401
+ }
2335
2402
 
2336
2403
  exports.CASE_FORMATS = CASE_FORMATS;
2337
2404
  exports.DEFAULT_CONVERT_OPTIONS = DEFAULT_CONVERT_OPTIONS;
@@ -2380,6 +2447,7 @@ exports.parseTableData = parseTableData;
2380
2447
  exports.readabilityScore = readabilityScore;
2381
2448
  exports.renderMarkdown = renderMarkdown;
2382
2449
  exports.romanToNumber = romanToNumber;
2450
+ exports.scoreReadability = scoreReadability;
2383
2451
  exports.sentenceCount = sentenceCount;
2384
2452
  exports.slugify = slugify;
2385
2453
  exports.slugifyAll = slugifyAll;
@@ -1 +1 @@
1
- export { A as AsciiFont, a as AsciiOptions, C as CASE_FORMATS, b as CaseFormat, c as ConvertOptions, D as DEFAULT_CONVERT_OPTIONS, d as DiffFile, e as DiffHunk, f as DiffLine, g as DiffResult, h as DiffType, i as DiffViewerLine, E as ESCAPE_MODES, j as EscapeMode, L as LINE_OPS, k as LineOp, l as LineType, m as LoremUnit, M as MORSE_CODE, n as MarkdownResult, o as MorseOptions, P as ParsedDiff, p as ParsedTable, q as PassiveVoiceMatch, r as PassiveVoiceResult, s as PassiveVoiceSentence, R as ReadabilityScore, S as SlugSeparator, T as TableOptions, u as TextAnalysis, W as WordCountResult, v as addBorder, w as analyzeText, x as applyOp, y as applyOps, z as centerText, B as convertAll, F as convertCase, G as countWords, H as csvToHtml, I as csvToMarkdown, J as detectDelimiter, K as detectPassiveVoice, N as diffLines, O as diffLinesSimple, Q as diffStats, U as escapeAll, V as escapeString, X as extractHeadings, Y as formatReadingTime, Z as generate, _ as generateDiff, $ as generateHtmlTable, a0 as generateMarkdownTable, a1 as generateParagraphs, a2 as generateSentences, a3 as generateWords, a4 as getAvailableFonts, a5 as getMorseForChar, a6 as getMorseTiming, a7 as htmlToMarkdown, a8 as isValidMorse, a9 as markdownToHtml, aa as morseToText, ab as numberToOrdinal, ac as numberToRoman, ad as numberToWords, ae as ordinalWords, af as parseDiff, ag as parseTableData, ah as readabilityScore, ai as renderMarkdown, aj as romanToNumber, ak as sentenceCount, al as slugify, am as slugifyAll, an as syllableCount, ao as textToAscii, ap as textToMorse, aq as unescapeString, ar as wordFrequency } from '../text-CI7JAl7F.cjs';
1
+ export { A as AsciiFont, a as AsciiOptions, C as CASE_FORMATS, b as CaseFormat, c as ConvertOptions, D as DEFAULT_CONVERT_OPTIONS, d as DiffFile, e as DiffHunk, f as DiffLine, g as DiffResult, h as DiffType, i as DiffViewerLine, E as ESCAPE_MODES, j as EscapeMode, L as LINE_OPS, k as LineOp, l as LineType, m as LoremUnit, M as MORSE_CODE, n as MarkdownResult, o as MorseOptions, P as ParsedDiff, p as ParsedTable, q as PassiveVoiceMatch, r as PassiveVoiceResult, s as PassiveVoiceSentence, R as ReadabilityResult, u as ReadabilityScore, S as SlugSeparator, T as TableOptions, v as TextAnalysis, W as WordCountResult, w as addBorder, x as analyzeText, y as applyOp, z as applyOps, B as centerText, F as convertAll, G as convertCase, H as countWords, I as csvToHtml, J as csvToMarkdown, K as detectDelimiter, N as detectPassiveVoice, O as diffLines, Q as diffLinesSimple, U as diffStats, V as escapeAll, X as escapeString, Y as extractHeadings, Z as formatReadingTime, _ as generate, $ as generateDiff, a0 as generateHtmlTable, a1 as generateMarkdownTable, a2 as generateParagraphs, a3 as generateSentences, a4 as generateWords, a5 as getAvailableFonts, a6 as getMorseForChar, a7 as getMorseTiming, a8 as htmlToMarkdown, a9 as isValidMorse, aa as markdownToHtml, ab as morseToText, ac as numberToOrdinal, ad as numberToRoman, ae as numberToWords, af as ordinalWords, ag as parseDiff, ah as parseTableData, ai as readabilityScore, aj as renderMarkdown, ak as romanToNumber, al as scoreReadability, am as sentenceCount, an as slugify, ao as slugifyAll, ap as syllableCount, aq as textToAscii, ar as textToMorse, as as unescapeString, at as wordFrequency } from '../text-Bbx-tZ43.cjs';
@@ -1 +1 @@
1
- export { A as AsciiFont, a as AsciiOptions, C as CASE_FORMATS, b as CaseFormat, c as ConvertOptions, D as DEFAULT_CONVERT_OPTIONS, d as DiffFile, e as DiffHunk, f as DiffLine, g as DiffResult, h as DiffType, i as DiffViewerLine, E as ESCAPE_MODES, j as EscapeMode, L as LINE_OPS, k as LineOp, l as LineType, m as LoremUnit, M as MORSE_CODE, n as MarkdownResult, o as MorseOptions, P as ParsedDiff, p as ParsedTable, q as PassiveVoiceMatch, r as PassiveVoiceResult, s as PassiveVoiceSentence, R as ReadabilityScore, S as SlugSeparator, T as TableOptions, u as TextAnalysis, W as WordCountResult, v as addBorder, w as analyzeText, x as applyOp, y as applyOps, z as centerText, B as convertAll, F as convertCase, G as countWords, H as csvToHtml, I as csvToMarkdown, J as detectDelimiter, K as detectPassiveVoice, N as diffLines, O as diffLinesSimple, Q as diffStats, U as escapeAll, V as escapeString, X as extractHeadings, Y as formatReadingTime, Z as generate, _ as generateDiff, $ as generateHtmlTable, a0 as generateMarkdownTable, a1 as generateParagraphs, a2 as generateSentences, a3 as generateWords, a4 as getAvailableFonts, a5 as getMorseForChar, a6 as getMorseTiming, a7 as htmlToMarkdown, a8 as isValidMorse, a9 as markdownToHtml, aa as morseToText, ab as numberToOrdinal, ac as numberToRoman, ad as numberToWords, ae as ordinalWords, af as parseDiff, ag as parseTableData, ah as readabilityScore, ai as renderMarkdown, aj as romanToNumber, ak as sentenceCount, al as slugify, am as slugifyAll, an as syllableCount, ao as textToAscii, ap as textToMorse, aq as unescapeString, ar as wordFrequency } from '../text-CI7JAl7F.js';
1
+ export { A as AsciiFont, a as AsciiOptions, C as CASE_FORMATS, b as CaseFormat, c as ConvertOptions, D as DEFAULT_CONVERT_OPTIONS, d as DiffFile, e as DiffHunk, f as DiffLine, g as DiffResult, h as DiffType, i as DiffViewerLine, E as ESCAPE_MODES, j as EscapeMode, L as LINE_OPS, k as LineOp, l as LineType, m as LoremUnit, M as MORSE_CODE, n as MarkdownResult, o as MorseOptions, P as ParsedDiff, p as ParsedTable, q as PassiveVoiceMatch, r as PassiveVoiceResult, s as PassiveVoiceSentence, R as ReadabilityResult, u as ReadabilityScore, S as SlugSeparator, T as TableOptions, v as TextAnalysis, W as WordCountResult, w as addBorder, x as analyzeText, y as applyOp, z as applyOps, B as centerText, F as convertAll, G as convertCase, H as countWords, I as csvToHtml, J as csvToMarkdown, K as detectDelimiter, N as detectPassiveVoice, O as diffLines, Q as diffLinesSimple, U as diffStats, V as escapeAll, X as escapeString, Y as extractHeadings, Z as formatReadingTime, _ as generate, $ as generateDiff, a0 as generateHtmlTable, a1 as generateMarkdownTable, a2 as generateParagraphs, a3 as generateSentences, a4 as generateWords, a5 as getAvailableFonts, a6 as getMorseForChar, a7 as getMorseTiming, a8 as htmlToMarkdown, a9 as isValidMorse, aa as markdownToHtml, ab as morseToText, ac as numberToOrdinal, ad as numberToRoman, ae as numberToWords, af as ordinalWords, ag as parseDiff, ah as parseTableData, ai as readabilityScore, aj as renderMarkdown, ak as romanToNumber, al as scoreReadability, am as sentenceCount, an as slugify, ao as slugifyAll, ap as syllableCount, aq as textToAscii, ar as textToMorse, as as unescapeString, at as wordFrequency } from '../text-Bbx-tZ43.js';
@@ -1,2 +1,2 @@
1
- export { CASE_FORMATS, DEFAULT_CONVERT_OPTIONS, ESCAPE_MODES, LINE_OPS, MORSE_CODE, addBorder, analyzeText, applyOp, applyOps, centerText, convertAll, convertCase, countWords, csvToHtml, csvToMarkdown, detectDelimiter, detectPassiveVoice, diffLines, diffLinesSimple, diffStats, escapeAll, escapeString, extractHeadings, formatReadingTime, generate, generateDiff, generateHtmlTable, generateMarkdownTable, generateParagraphs, generateSentences, generateWords, getAvailableFonts, getMorseForChar, getMorseTiming, htmlToMarkdown, isValidMorse, markdownToHtml, morseToText, numberToOrdinal, numberToRoman, numberToWords, ordinalWords, parseDiff, parseTableData, readabilityScore, renderMarkdown, romanToNumber, sentenceCount, slugify, slugifyAll, syllableCount, textToAscii, textToMorse, unescapeString, wordFrequency } from '../chunk-YBBYFAOV.js';
1
+ export { CASE_FORMATS, DEFAULT_CONVERT_OPTIONS, ESCAPE_MODES, LINE_OPS, MORSE_CODE, addBorder, analyzeText, applyOp, applyOps, centerText, convertAll, convertCase, countWords, csvToHtml, csvToMarkdown, detectDelimiter, detectPassiveVoice, diffLines, diffLinesSimple, diffStats, escapeAll, escapeString, extractHeadings, formatReadingTime, generate, generateDiff, generateHtmlTable, generateMarkdownTable, generateParagraphs, generateSentences, generateWords, getAvailableFonts, getMorseForChar, getMorseTiming, htmlToMarkdown, isValidMorse, markdownToHtml, morseToText, numberToOrdinal, numberToRoman, numberToWords, ordinalWords, parseDiff, parseTableData, readabilityScore, renderMarkdown, romanToNumber, scoreReadability, sentenceCount, slugify, slugifyAll, syllableCount, textToAscii, textToMorse, unescapeString, wordFrequency } from '../chunk-F57WMKZO.js';
2
2
  import '../chunk-MLKGABMK.js';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@utilix-tech/sdk",
3
- "version": "0.6.0",
4
- "description": "140+ developer utility tools for Node.js: JSON, encoding, hashing, color, CSS, network and more. Runs locally, no API key required.",
3
+ "version": "0.8.0",
4
+ "description": "153+ developer utility tools for Node.js: JSON, encoding, hashing, color, CSS, network and more. Runs locally, no API key required.",
5
5
  "author": "Utilix <hello@utilix.tech>",
6
6
  "license": "MIT",
7
7
  "homepage": "https://www.utilix.tech/docs#node-sdk",
@@ -28,7 +28,12 @@
28
28
  "regex",
29
29
  "uuid",
30
30
  "api-client",
31
- "utilix"
31
+ "utilix",
32
+ "ai-agent",
33
+ "llm-tools",
34
+ "rag",
35
+ "yaml",
36
+ "base64"
32
37
  ],
33
38
  "engines": {
34
39
  "node": ">=18"
@@ -1,82 +0,0 @@
1
- type ImageFormat = 'png' | 'jpeg' | 'gif' | 'webp' | 'bmp';
2
- interface ImageInfo {
3
- format: ImageFormat;
4
- width: number;
5
- height: number;
6
- bitDepth?: number;
7
- colorType?: string;
8
- hasAlpha?: boolean;
9
- }
10
- interface ImageInfoError {
11
- error: string;
12
- }
13
- /**
14
- * Read image format, dimensions, and basic color info straight from file
15
- * bytes — no decoding, no image library, no canvas. Supports PNG, JPEG,
16
- * GIF, WebP, and BMP.
17
- */
18
- declare function readImageInfo(bytes: Uint8Array): ImageInfo | ImageInfoError;
19
- interface ExifData {
20
- make?: string;
21
- model?: string;
22
- software?: string;
23
- orientation?: number;
24
- orientationLabel?: string;
25
- dateTime?: string;
26
- dateTimeOriginal?: string;
27
- exposureTime?: string;
28
- fNumber?: number;
29
- isoSpeed?: number;
30
- focalLength?: number;
31
- gpsLatitude?: number;
32
- gpsLongitude?: number;
33
- tagCount: number;
34
- }
35
- interface ExifError {
36
- error: string;
37
- }
38
- /**
39
- * Read common EXIF tags (make, model, orientation, timestamps, exposure
40
- * settings, GPS coordinates) directly from a JPEG's APP1 segment. Only
41
- * JPEG is supported: PNG, WebP, and other formats don't carry EXIF the
42
- * same way and are rejected with an error.
43
- */
44
- declare function readExifData(bytes: Uint8Array): ExifData | ExifError;
45
- interface PdfMetadata {
46
- version: string | null;
47
- pageCount: number | null;
48
- title: string | null;
49
- author: string | null;
50
- subject: string | null;
51
- keywords: string | null;
52
- creator: string | null;
53
- producer: string | null;
54
- creationDate: string | null;
55
- modDate: string | null;
56
- encrypted: boolean;
57
- }
58
- interface PdfMetadataError {
59
- error: string;
60
- }
61
- /**
62
- * Read PDF metadata (title, author, dates, page count, encryption flag)
63
- * straight from the file's trailer/Info dictionary and page tree — no
64
- * pdf.js or other PDF rendering library required.
65
- */
66
- declare function readPdfMetadata(bytes: Uint8Array): PdfMetadata | PdfMetadataError;
67
-
68
- type media_ExifData = ExifData;
69
- type media_ExifError = ExifError;
70
- type media_ImageFormat = ImageFormat;
71
- type media_ImageInfo = ImageInfo;
72
- type media_ImageInfoError = ImageInfoError;
73
- type media_PdfMetadata = PdfMetadata;
74
- type media_PdfMetadataError = PdfMetadataError;
75
- declare const media_readExifData: typeof readExifData;
76
- declare const media_readImageInfo: typeof readImageInfo;
77
- declare const media_readPdfMetadata: typeof readPdfMetadata;
78
- declare namespace media {
79
- export { type media_ExifData as ExifData, type media_ExifError as ExifError, type media_ImageFormat as ImageFormat, type media_ImageInfo as ImageInfo, type media_ImageInfoError as ImageInfoError, type media_PdfMetadata as PdfMetadata, type media_PdfMetadataError as PdfMetadataError, media_readExifData as readExifData, media_readImageInfo as readImageInfo, media_readPdfMetadata as readPdfMetadata };
80
- }
81
-
82
- export { type ExifData as E, type ImageFormat as I, type PdfMetadata as P, type ExifError as a, type ImageInfo as b, type ImageInfoError as c, type PdfMetadataError as d, readImageInfo as e, readPdfMetadata as f, media as m, readExifData as r };
@@ -1,82 +0,0 @@
1
- type ImageFormat = 'png' | 'jpeg' | 'gif' | 'webp' | 'bmp';
2
- interface ImageInfo {
3
- format: ImageFormat;
4
- width: number;
5
- height: number;
6
- bitDepth?: number;
7
- colorType?: string;
8
- hasAlpha?: boolean;
9
- }
10
- interface ImageInfoError {
11
- error: string;
12
- }
13
- /**
14
- * Read image format, dimensions, and basic color info straight from file
15
- * bytes — no decoding, no image library, no canvas. Supports PNG, JPEG,
16
- * GIF, WebP, and BMP.
17
- */
18
- declare function readImageInfo(bytes: Uint8Array): ImageInfo | ImageInfoError;
19
- interface ExifData {
20
- make?: string;
21
- model?: string;
22
- software?: string;
23
- orientation?: number;
24
- orientationLabel?: string;
25
- dateTime?: string;
26
- dateTimeOriginal?: string;
27
- exposureTime?: string;
28
- fNumber?: number;
29
- isoSpeed?: number;
30
- focalLength?: number;
31
- gpsLatitude?: number;
32
- gpsLongitude?: number;
33
- tagCount: number;
34
- }
35
- interface ExifError {
36
- error: string;
37
- }
38
- /**
39
- * Read common EXIF tags (make, model, orientation, timestamps, exposure
40
- * settings, GPS coordinates) directly from a JPEG's APP1 segment. Only
41
- * JPEG is supported: PNG, WebP, and other formats don't carry EXIF the
42
- * same way and are rejected with an error.
43
- */
44
- declare function readExifData(bytes: Uint8Array): ExifData | ExifError;
45
- interface PdfMetadata {
46
- version: string | null;
47
- pageCount: number | null;
48
- title: string | null;
49
- author: string | null;
50
- subject: string | null;
51
- keywords: string | null;
52
- creator: string | null;
53
- producer: string | null;
54
- creationDate: string | null;
55
- modDate: string | null;
56
- encrypted: boolean;
57
- }
58
- interface PdfMetadataError {
59
- error: string;
60
- }
61
- /**
62
- * Read PDF metadata (title, author, dates, page count, encryption flag)
63
- * straight from the file's trailer/Info dictionary and page tree — no
64
- * pdf.js or other PDF rendering library required.
65
- */
66
- declare function readPdfMetadata(bytes: Uint8Array): PdfMetadata | PdfMetadataError;
67
-
68
- type media_ExifData = ExifData;
69
- type media_ExifError = ExifError;
70
- type media_ImageFormat = ImageFormat;
71
- type media_ImageInfo = ImageInfo;
72
- type media_ImageInfoError = ImageInfoError;
73
- type media_PdfMetadata = PdfMetadata;
74
- type media_PdfMetadataError = PdfMetadataError;
75
- declare const media_readExifData: typeof readExifData;
76
- declare const media_readImageInfo: typeof readImageInfo;
77
- declare const media_readPdfMetadata: typeof readPdfMetadata;
78
- declare namespace media {
79
- export { type media_ExifData as ExifData, type media_ExifError as ExifError, type media_ImageFormat as ImageFormat, type media_ImageInfo as ImageInfo, type media_ImageInfoError as ImageInfoError, type media_PdfMetadata as PdfMetadata, type media_PdfMetadataError as PdfMetadataError, media_readExifData as readExifData, media_readImageInfo as readImageInfo, media_readPdfMetadata as readPdfMetadata };
80
- }
81
-
82
- export { type ExifData as E, type ImageFormat as I, type PdfMetadata as P, type ExifError as a, type ImageInfo as b, type ImageInfoError as c, type PdfMetadataError as d, readImageInfo as e, readPdfMetadata as f, media as m, readExifData as r };