@ceale/util 1.0.7 → 1.2.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.
@@ -0,0 +1,67 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropNames = Object.getOwnPropertyNames;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __moduleCache = /* @__PURE__ */ new WeakMap;
6
+ var __toCommonJS = (from) => {
7
+ var entry = __moduleCache.get(from), desc;
8
+ if (entry)
9
+ return entry;
10
+ entry = __defProp({}, "__esModule", { value: true });
11
+ if (from && typeof from === "object" || typeof from === "function")
12
+ __getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
13
+ get: () => from[key],
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ }));
16
+ __moduleCache.set(from, entry);
17
+ return entry;
18
+ };
19
+ var __export = (target, all) => {
20
+ for (var name in all)
21
+ __defProp(target, name, {
22
+ get: all[name],
23
+ enumerable: true,
24
+ configurable: true,
25
+ set: (newValue) => all[name] = () => newValue
26
+ });
27
+ };
28
+
29
+ // src/index.ts
30
+ var exports_src = {};
31
+ __export(exports_src, {
32
+ UrlUtil: () => UrlUtil,
33
+ StringUtil: () => StringUtil
34
+ });
35
+ module.exports = __toCommonJS(exports_src);
36
+
37
+ // src/string.ts
38
+ var StringUtil = (str) => ({
39
+ string: str,
40
+ toString: () => str,
41
+ valueOf: () => str,
42
+ removeStart: (searchString) => str.startsWith(searchString) ? str.slice(searchString.length) : str,
43
+ removeEnd: (searchString) => str.endsWith(searchString) ? str.slice(0, -searchString.length) : str,
44
+ removeStartAll(searchString) {
45
+ while (str.startsWith(searchString)) {
46
+ str = str.slice(searchString.length);
47
+ }
48
+ return str;
49
+ },
50
+ removeEndAll(searchString) {
51
+ while (str.endsWith(searchString)) {
52
+ str = str.slice(0, -searchString.length);
53
+ }
54
+ return str;
55
+ }
56
+ });
57
+ // src/url.ts
58
+ var UrlUtil = (url) => ({
59
+ join(...path) {
60
+ return path.filter((p) => p !== "").map((p, index) => {
61
+ if (index === 0) {
62
+ return StringUtil(p).removeEnd("/");
63
+ }
64
+ return "/" + StringUtil(p).removeStart("/");
65
+ }).join("");
66
+ }
67
+ });
@@ -0,0 +1,35 @@
1
+ // src/string.ts
2
+ var StringUtil = (str) => ({
3
+ string: str,
4
+ toString: () => str,
5
+ valueOf: () => str,
6
+ removeStart: (searchString) => str.startsWith(searchString) ? str.slice(searchString.length) : str,
7
+ removeEnd: (searchString) => str.endsWith(searchString) ? str.slice(0, -searchString.length) : str,
8
+ removeStartAll(searchString) {
9
+ while (str.startsWith(searchString)) {
10
+ str = str.slice(searchString.length);
11
+ }
12
+ return str;
13
+ },
14
+ removeEndAll(searchString) {
15
+ while (str.endsWith(searchString)) {
16
+ str = str.slice(0, -searchString.length);
17
+ }
18
+ return str;
19
+ }
20
+ });
21
+ // src/url.ts
22
+ var UrlUtil = (url) => ({
23
+ join(...path) {
24
+ return path.filter((p) => p !== "").map((p, index) => {
25
+ if (index === 0) {
26
+ return StringUtil(p).removeEnd("/");
27
+ }
28
+ return "/" + StringUtil(p).removeStart("/");
29
+ }).join("");
30
+ }
31
+ });
32
+ export {
33
+ UrlUtil,
34
+ StringUtil
35
+ };
@@ -0,0 +1,2 @@
1
+ export * from "./string";
2
+ export * from "./url";
@@ -0,0 +1,9 @@
1
+ export declare const StringUtil: (str: string) => {
2
+ string: string;
3
+ toString: () => string;
4
+ valueOf: () => string;
5
+ removeStart: (searchString: string) => string;
6
+ removeEnd: (searchString: string) => string;
7
+ removeStartAll(searchString: string): string;
8
+ removeEndAll(searchString: string): string;
9
+ };
@@ -0,0 +1,2 @@
1
+ export declare namespace UrlUtil {
2
+ }
package/package.json CHANGED
@@ -1,22 +1,28 @@
1
1
  {
2
2
  "name": "@ceale/util",
3
3
  "author": "Ceale",
4
- "version": "1.0.7",
4
+ "version": "1.2.0",
5
5
  "module": "index.ts",
6
6
  "type": "module",
7
+ "main": "dist/esm/index.js",
8
+ "types": "dist/types/index.d.ts",
9
+ "files": ["dist"],
7
10
  "repository": {
8
11
  "url": "git+https://github.com/Ceale/ts-util.git"
9
12
  },
10
13
  "scripts": {
11
- "build": "bun run build:esm && bun run build:cjs",
14
+ "build": "bun run build:esm && bun run build:cjs && bun run build:ts",
12
15
  "build:esm": "bun build --outdir=dist/esm/ --format=esm --target=node src/index.ts",
13
- "build:cjs": "bun build --outdir=dist/cjs/ --format=cjs --target=node src/index.ts"
16
+ "build:cjs": "bun build --outdir=dist/cjs/ --format=cjs --target=node src/index.ts",
17
+ "build:ts": "tsc --outDir dist/ts/"
14
18
  },
15
19
  "exports": {
16
20
  ".": {
17
21
  "import": "./dist/esm/index.js",
18
- "require": "./dist/cjs/index.js"
19
- }
22
+ "require": "./dist/cjs/index.js",
23
+ "types": "./dist/types/index.d.ts"
24
+ },
25
+ "./package.json": "./package.json"
20
26
  },
21
27
  "devDependencies": {
22
28
  "@types/bun": "latest"
package/bun.lock DELETED
@@ -1,25 +0,0 @@
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/src/index.ts DELETED
@@ -1,2 +0,0 @@
1
- export * from "./string"
2
- export * from "./url"
package/src/string.ts DELETED
@@ -1,22 +0,0 @@
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 DELETED
@@ -1,15 +0,0 @@
1
- import { StringUtil } from "./string"
2
-
3
- export namespace UrlUtil {
4
- const 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 DELETED
@@ -1,33 +0,0 @@
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
- }