vinh-strings-utils 3.1.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.
package/README.md ADDED
@@ -0,0 +1,77 @@
1
+ # @org/strings
2
+
3
+ String manipulation utilities for TypeScript applications.
4
+
5
+ ## ๐Ÿ“ฆ Package Information
6
+
7
+ - **Version**: 0.0.1
8
+ - **Publishable**: โœ… Yes
9
+ - **Tag**: `scope:strings`
10
+ - **Module Boundaries**: Can only import from `scope:shared` packages
11
+
12
+ ## ๐Ÿš€ Features
13
+
14
+ This package provides essential string manipulation utilities:
15
+
16
+ - **capitalize** - Capitalizes the first letter of a string
17
+ - **slugify** - Converts strings to URL-friendly slugs
18
+
19
+ ## ๐Ÿ“ Usage Examples
20
+
21
+ ```typescript
22
+ import { capitalize, slugify } from '@org/strings';
23
+
24
+ // Capitalize strings
25
+ capitalize('hello world'); // 'Hello world'
26
+ capitalize('typescript'); // 'Typescript'
27
+
28
+ // Create URL-friendly slugs
29
+ slugify('Hello World!'); // 'hello-world'
30
+ slugify('TypeScript & JavaScript'); // 'typescript-javascript'
31
+ ```
32
+
33
+ ## ๐Ÿ› ๏ธ Custom Commands
34
+
35
+ This package includes a custom build command to demonstrate Nx's flexibility:
36
+
37
+ ```bash
38
+ # Run the custom build-base command
39
+ nx run strings:build-base
40
+
41
+ # This will output: "Running build-base for strings. This can be replaced with arbitrary commands."
42
+ ```
43
+
44
+ ## ๐Ÿงช Testing
45
+
46
+ ```bash
47
+ # Run tests for this package
48
+ nx test strings
49
+
50
+ # Run tests in watch mode
51
+ nx test strings --watch
52
+ ```
53
+
54
+ ## ๐Ÿ—๏ธ Building
55
+
56
+ ```bash
57
+ # Build the package
58
+ nx build strings
59
+
60
+ # The build output will be in dist/packages/strings
61
+ ```
62
+
63
+ ## ๐Ÿ“‹ Available Commands
64
+
65
+ ```bash
66
+ nx build strings # Build the package
67
+ nx test strings # Run tests
68
+ nx lint strings # Lint the package
69
+ nx run strings:build-base # Run custom build command
70
+ ```
71
+
72
+ ## ๐Ÿ”’ Module Boundaries
73
+
74
+ This package has the tag `scope:strings` and can only import from:
75
+ - `@org/utils` (tagged with `scope:shared`)
76
+
77
+ Attempting to import from `@org/colors` or `@org/async` will result in a linting error due to module boundary constraints.
@@ -0,0 +1,3 @@
1
+ export * from './lib/slugify.js';
2
+ export * from './lib/capitalize.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from './lib/slugify.js';
2
+ export * from './lib/capitalize.js';
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Capitalize first letter of each word
3
+ */
4
+ export declare function capitalize(text: string, allWords?: boolean): string;
5
+ //# sourceMappingURL=capitalize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capitalize.d.ts","sourceRoot":"","sources":["../../src/lib/capitalize.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,UAAO,GAAG,MAAM,CAYhE"}
@@ -0,0 +1,15 @@
1
+ import { validateType } from '@org/utils';
2
+ /**
3
+ * Capitalize first letter of each word
4
+ */
5
+ export function capitalize(text, allWords = true) {
6
+ if (!validateType(text, 'string')) {
7
+ throw new TypeError('Input must be a string');
8
+ }
9
+ if (!text)
10
+ return text;
11
+ if (allWords) {
12
+ return text.replace(/\b\w/g, (char) => char.toUpperCase());
13
+ }
14
+ return text.charAt(0).toUpperCase() + text.slice(1).toLowerCase();
15
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Convert text to URL-friendly slug
3
+ */
4
+ export declare function slugify(text: string): string;
5
+ //# sourceMappingURL=slugify.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slugify.d.ts","sourceRoot":"","sources":["../../src/lib/slugify.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAW5C"}
@@ -0,0 +1,15 @@
1
+ import { validateType } from '@org/utils';
2
+ /**
3
+ * Convert text to URL-friendly slug
4
+ */
5
+ export function slugify(text) {
6
+ if (!validateType(text, 'string')) {
7
+ throw new TypeError('Input must be a string');
8
+ }
9
+ return text
10
+ .toLowerCase()
11
+ .trim()
12
+ .replace(/[^\w\s-]/g, '') // Remove non-word chars
13
+ .replace(/[\s_-]+/g, '-') // Replace spaces, underscores, multiple hyphens with single hyphen
14
+ .replace(/^-+|-+$/g, ''); // Remove leading/trailing hyphens
15
+ }
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "vinh-strings-utils",
3
+ "version": "3.1.0",
4
+ "type": "module",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ "./package.json": "./package.json",
10
+ ".": {
11
+ "@org/source": "./src/index.ts",
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js",
14
+ "default": "./dist/index.js"
15
+ }
16
+ },
17
+ "files": [
18
+ "dist",
19
+ "!**/*.tsbuildinfo"
20
+ ],
21
+ "dependencies": {
22
+ "tslib": "^2.3.0"
23
+ },
24
+ "devDependencies": {
25
+ "vite": "^7.0.0",
26
+ "@org/utils": "0.0.1"
27
+ },
28
+ "nx": {
29
+ "tags": [
30
+ "scope:strings"
31
+ ],
32
+ "targets": {
33
+ "build-base": {
34
+ "command": "echo 'Running build-base for strings. This can be replaced with arbitrary commands.'",
35
+ "cache": true
36
+ },
37
+ "build": {
38
+ "dependsOn": [
39
+ "build-base"
40
+ ]
41
+ }
42
+ }
43
+ }
44
+ }