echokyt 0.0.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 nyigoro
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # 📦 EchoKit
2
+
3
+ A lightweight, zero-dependency utility library for smart text manipulation in TypeScript.
4
+
5
+ [![Tests](https://github.com/nyigoro/EchoKit/actions/workflows/test.yml/badge.svg)](https://github.com/nyigoro/EchoKit/actions)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+
8
+ ## ✨ Features
9
+
10
+ - **Smart Truncate**: Cuts text at word boundaries, not mid-word.
11
+ - **Reading Time**: Quick estimation for blog posts.
12
+ - **Zero Dependencies**: Keep your bundle size tiny.
13
+ - **TypeScript Ready**: Full type definitions included.
14
+
15
+ ## 🚀 Installation
16
+
17
+ ```bash
18
+ npm install echo-kit
19
+ ```
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Estimates reading time in minutes.
3
+ * Assumes an average reading speed of 200 WPM.
4
+ */
5
+ export declare const readingTime: (text: string, wordsPerMinute?: number) => number;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Estimates reading time in minutes.
3
+ * Assumes an average reading speed of 200 WPM.
4
+ */
5
+ export const readingTime = (text, wordsPerMinute = 200) => {
6
+ if (!text.trim())
7
+ return 0;
8
+ const words = text.trim().split(/\s+/).length;
9
+ return Math.ceil(words / wordsPerMinute);
10
+ };
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Converts a string into a URL-friendly slug.
3
+ * Example: "Hello World!" -> "hello-world"
4
+ */
5
+ export declare const slugify: (text: string) => string;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Converts a string into a URL-friendly slug.
3
+ * Example: "Hello World!" -> "hello-world"
4
+ */
5
+ export const slugify = (text) => {
6
+ return text
7
+ .toLowerCase()
8
+ .trim()
9
+ .replace(/[^\w\s-]/g, '') // Remove special characters
10
+ .replace(/[\s_-]+/g, '-') // Replace spaces/underscores with a single hyphen
11
+ .replace(/^-+|-+$/g, ''); // Remove leading/trailing hyphens
12
+ };
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Truncates text at the nearest whole word.
3
+ */
4
+ export declare const smartTruncate: (text: string, limit: number) => string;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Truncates text at the nearest whole word.
3
+ */
4
+ export const smartTruncate = (text, limit) => {
5
+ if (text.length <= limit)
6
+ return text;
7
+ const truncated = text.slice(0, limit);
8
+ const lastSpace = truncated.lastIndexOf(' ');
9
+ const cleanCut = lastSpace > 0 ? truncated.slice(0, lastSpace) : truncated;
10
+ return `${cleanCut}...`;
11
+ };
@@ -0,0 +1,3 @@
1
+ export * from './format/truncate.js';
2
+ export * from './format/slugify.js';
3
+ export * from './analyze/readingTime.js';
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export * from './format/truncate.js';
2
+ export * from './format/slugify.js';
3
+ export * from './analyze/readingTime.js';
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "echokyt",
3
+ "version": "0.0.1",
4
+ "description": "A lightweight text utility library",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.js"
11
+ }
12
+ },
13
+ "files": [
14
+ "dist"
15
+ ],
16
+ "scripts": {
17
+ "build": "tsc",
18
+ "clean": "rimraf dist coverage *.tsbuildinfo",
19
+ "lint": "eslint \"{src,tests}/**/*.ts\"",
20
+ "format": "prettier --write \"**/*.{ts,js,json,md,yml,yaml}\"",
21
+ "test": "jest",
22
+ "prepublishOnly": "npm run test && npm run build"
23
+ },
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://github.com/nyigoro/EchoKit.git"
27
+ },
28
+ "keywords": [],
29
+ "author": "nyigoro",
30
+ "license": "ISC",
31
+ "type": "module",
32
+ "sideEffects": false,
33
+ "engines": {
34
+ "node": ">=18"
35
+ },
36
+ "bugs": {
37
+ "url": "https://github.com/nyigoro/EchoKit/issues"
38
+ },
39
+ "homepage": "https://github.com/nyigoro/EchoKit#readme",
40
+ "devDependencies": {
41
+ "@types/jest": "^29.0.0",
42
+ "@typescript-eslint/eslint-plugin": "^7.18.0",
43
+ "@typescript-eslint/parser": "^7.18.0",
44
+ "eslint": "^8.57.0",
45
+ "jest": "^29.0.0",
46
+ "prettier": "^3.2.5",
47
+ "rimraf": "^5.0.0",
48
+ "ts-jest": "^29.0.0",
49
+ "typescript": "^5.9.3"
50
+ }
51
+ }