@ceale/util 1.0.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,15 @@
1
+ # @ceale/util
2
+
3
+ To install dependencies:
4
+
5
+ ```bash
6
+ bun install
7
+ ```
8
+
9
+ To run:
10
+
11
+ ```bash
12
+ bun run index.ts
13
+ ```
14
+
15
+ This project was created using `bun init` in bun v1.2.16. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.
package/bun.lock ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "lockfileVersion": 1,
3
+ "workspaces": {
4
+ "": {
5
+ "name": "@ceale/util",
6
+ "devDependencies": {
7
+ "@types/bun": "latest",
8
+ },
9
+ "peerDependencies": {
10
+ "typescript": "^5",
11
+ },
12
+ },
13
+ },
14
+ "packages": {
15
+ "@types/bun": ["@types/bun@1.2.17", "https://registry.npmmirror.com/@types/bun/-/bun-1.2.17.tgz", { "dependencies": { "bun-types": "1.2.17" } }, "sha512-l/BYs/JYt+cXA/0+wUhulYJB6a6p//GTPiJ7nV+QHa8iiId4HZmnu/3J/SowP5g0rTiERY2kfGKXEK5Ehltx4Q=="],
16
+
17
+ "@types/node": ["@types/node@24.0.4", "https://registry.npmmirror.com/@types/node/-/node-24.0.4.tgz", { "dependencies": { "undici-types": "~7.8.0" } }, "sha512-ulyqAkrhnuNq9pB76DRBTkcS6YsmDALy6Ua63V8OhrOBgbcYt6IOdzpw5P1+dyRIyMerzLkeYWBeOXPpA9GMAA=="],
18
+
19
+ "bun-types": ["bun-types@1.2.17", "https://registry.npmmirror.com/bun-types/-/bun-types-1.2.17.tgz", { "dependencies": { "@types/node": "*" } }, "sha512-ElC7ItwT3SCQwYZDYoAH+q6KT4Fxjl8DtZ6qDulUFBmXA8YB4xo+l54J9ZJN+k2pphfn9vk7kfubeSd5QfTVJQ=="],
20
+
21
+ "typescript": ["typescript@5.8.3", "https://registry.npmmirror.com/typescript/-/typescript-5.8.3.tgz", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ=="],
22
+
23
+ "undici-types": ["undici-types@7.8.0", "https://registry.npmmirror.com/undici-types/-/undici-types-7.8.0.tgz", {}, "sha512-9UJ2xGDvQ43tYyVMpuHlsgApydB8ZKfVYTsLDhXkFL/6gfkp+U8xTGdh8pMJv1SpZna0zxG1DwsKZsreLbXBxw=="],
24
+ }
25
+ }
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@ceale/util",
3
+ "author": "Ceale",
4
+ "version": "1.0.0",
5
+ "module": "index.ts",
6
+ "type": "module",
7
+ "scripts": {
8
+ "build": "bun run build:esm && bun run build:cjs",
9
+ "build:esm": "bun build --outdir=dist/esm/ --format=esm --target=node src/index.ts",
10
+ "build:cjs": "bun build --outdir=dist/cjs/ --format=cjs --target=node src/index.ts"
11
+ },
12
+ "exports": {
13
+ ".": {
14
+ "import": "./dist/esm/index.js",
15
+ "require": "./dist/cjs/index.js"
16
+ }
17
+ },
18
+ "devDependencies": {
19
+ "@types/bun": "latest"
20
+ },
21
+ "peerDependencies": {
22
+ "typescript": "^5"
23
+ }
24
+ }
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./string"
2
+ export * from "./url"
package/src/string.ts ADDED
@@ -0,0 +1,22 @@
1
+ import { inspect } from 'util'
2
+
3
+ export const StringUtil = (str: string) => ({
4
+ string: str,
5
+ toString: () => str,
6
+ valueOf: () => str,
7
+
8
+ removeStart: (searchString: string) => str.startsWith(searchString) ? str.slice(searchString.length) : str,
9
+ removeEnd: (searchString: string) => str.endsWith(searchString) ? str.slice(0, -searchString.length) : str,
10
+ removeStartAll(searchString: string) {
11
+ while (str.startsWith(searchString)) {
12
+ str = str.slice(searchString.length)
13
+ }
14
+ return str
15
+ },
16
+ removeEndAll(searchString: string) {
17
+ while (str.endsWith(searchString)) {
18
+ str = str.slice(0, -searchString.length)
19
+ }
20
+ return str
21
+ }
22
+ })
package/src/url.ts ADDED
@@ -0,0 +1,15 @@
1
+ import { StringUtil } from "./string"
2
+
3
+ export const UrlUtil = (url: string) => ({
4
+ join(...path: string[]) {
5
+ return path
6
+ .filter(p => p !== '')
7
+ .map((p, index) => {
8
+ if (index === 0) {
9
+ return StringUtil(p).removeEnd("/")
10
+ }
11
+ return "/" + StringUtil(p).removeStart("/")
12
+ })
13
+ .join("")
14
+ }
15
+ })
package/tsconfig.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "compilerOptions": {
3
+ // Environment setup & latest features
4
+ "lib": ["ESNext"],
5
+ "target": "ESNext",
6
+ "module": "Preserve",
7
+ "moduleDetection": "force",
8
+ "allowJs": true,
9
+
10
+ // Bundler mode
11
+ "moduleResolution": "bundler",
12
+ "allowImportingTsExtensions": true,
13
+ "verbatimModuleSyntax": true,
14
+ "noEmit": true,
15
+
16
+ // Best practices
17
+ "strict": true,
18
+ "skipLibCheck": true,
19
+ "noFallthroughCasesInSwitch": true,
20
+ "noUncheckedIndexedAccess": true,
21
+ "noImplicitOverride": true,
22
+
23
+ // Some stricter flags (disabled by default)
24
+ "noUnusedLocals": false,
25
+ "noUnusedParameters": false,
26
+ "noPropertyAccessFromIndexSignature": false,
27
+
28
+ "baseUrl": ".",
29
+ "paths": {
30
+ "~/*": ["src/*"]
31
+ }
32
+ }
33
+ }