@mysetup/helpers 2.0.1 → 2.0.6

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.
Files changed (34) hide show
  1. package/README.md +46 -0
  2. package/dist/index.d.ts +0 -1
  3. package/dist/src/arrayMethods/arrayMethods.d.ts +0 -1
  4. package/dist/src/arrayMethods/index.d.ts +0 -1
  5. package/dist/src/formatPhoneNumber/formatPhoneNumber.d.ts +0 -1
  6. package/dist/src/formatPhoneNumber/index.d.ts +0 -1
  7. package/dist/src/generate-cache-key/generate-cache-key.d.ts +0 -1
  8. package/dist/src/generate-cache-key/index.d.ts +0 -1
  9. package/dist/src/getCrypto/getCrypto.d.ts +0 -1
  10. package/dist/src/getCrypto/index.d.ts +0 -1
  11. package/dist/src/getDateTimeDiff/getDateTimeDiff.d.ts +0 -1
  12. package/dist/src/getDateTimeDiff/index.d.ts +0 -1
  13. package/dist/src/getTextWidth/getTextWidth.d.ts +0 -1
  14. package/dist/src/getTextWidth/index.d.ts +0 -1
  15. package/dist/src/index.d.ts +0 -1
  16. package/dist/src/setCookie/index.d.ts +0 -1
  17. package/dist/src/setCookie/setCookie.d.ts +0 -1
  18. package/package.json +69 -50
  19. package/dist/index.d.ts.map +0 -1
  20. package/dist/src/arrayMethods/arrayMethods.d.ts.map +0 -1
  21. package/dist/src/arrayMethods/index.d.ts.map +0 -1
  22. package/dist/src/formatPhoneNumber/formatPhoneNumber.d.ts.map +0 -1
  23. package/dist/src/formatPhoneNumber/index.d.ts.map +0 -1
  24. package/dist/src/generate-cache-key/generate-cache-key.d.ts.map +0 -1
  25. package/dist/src/generate-cache-key/index.d.ts.map +0 -1
  26. package/dist/src/getCrypto/getCrypto.d.ts.map +0 -1
  27. package/dist/src/getCrypto/index.d.ts.map +0 -1
  28. package/dist/src/getDateTimeDiff/getDateTimeDiff.d.ts.map +0 -1
  29. package/dist/src/getDateTimeDiff/index.d.ts.map +0 -1
  30. package/dist/src/getTextWidth/getTextWidth.d.ts.map +0 -1
  31. package/dist/src/getTextWidth/index.d.ts.map +0 -1
  32. package/dist/src/index.d.ts.map +0 -1
  33. package/dist/src/setCookie/index.d.ts.map +0 -1
  34. package/dist/src/setCookie/setCookie.d.ts.map +0 -1
package/README.md ADDED
@@ -0,0 +1,46 @@
1
+ # @mysetup/helpers
2
+
3
+ Shared utility helpers for browser and server applications.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pnpm add @mysetup/helpers
9
+ ```
10
+
11
+ ## Supported libraries and runtimes
12
+
13
+ | Supported | Notes |
14
+ | ----------------- | ------------------------------------------------------------- |
15
+ | Vite | Root exports are supported |
16
+ | Next.js | Root exports are supported; crypto helpers are server-only |
17
+ | Node.js | Full support including `@mysetup/helpers/crypto` |
18
+ | Browser-only APIs | `getTextWidth` and `setCookie` should only run in the browser |
19
+
20
+ ## Browser and universal usage
21
+
22
+ ```ts
23
+ import {
24
+ formatPhoneNumber,
25
+ generateCacheKey,
26
+ getDateTimeDiff,
27
+ } from "@mysetup/helpers";
28
+
29
+ const formatted = formatPhoneNumber("9876543210");
30
+ const cacheKey = generateCacheKey("brand", "production", "users");
31
+ const diff = getDateTimeDiff("2025-01-01T00:00:00Z");
32
+ ```
33
+
34
+ ## Node.js only usage
35
+
36
+ ```ts
37
+ import { decodeData, encodeData } from "@mysetup/helpers/crypto";
38
+
39
+ const encrypted = encodeData("hello", process.env.DATA_KEY || "");
40
+ const decrypted = decodeData(encrypted, process.env.DATA_KEY || "");
41
+ ```
42
+
43
+ ## Notes
44
+
45
+ - `getTextWidth` and `setCookie` should only be called in the browser.
46
+ - `encodeData` and `decodeData` should only be used in Node.js or other runtimes that expose the Node `crypto` module.
package/dist/index.d.ts CHANGED
@@ -1,2 +1 @@
1
1
  export * from "./src";
2
- //# sourceMappingURL=index.d.ts.map
@@ -6,4 +6,3 @@
6
6
  * @returns lonest string in array
7
7
  */
8
8
  export declare function longestStrInArray<T extends object>(array: T[], key: keyof T): string;
9
- //# sourceMappingURL=arrayMethods.d.ts.map
@@ -1,2 +1 @@
1
1
  export * from "./arrayMethods";
2
- //# sourceMappingURL=index.d.ts.map
@@ -1,3 +1,2 @@
1
1
  export declare function formatPhoneNumber(phoneNumber: string): string | null;
2
2
  export declare const phoneNumberAutoFormat: (phoneNumber: string) => string;
3
- //# sourceMappingURL=formatPhoneNumber.d.ts.map
@@ -1,2 +1 @@
1
1
  export * from "./formatPhoneNumber";
2
- //# sourceMappingURL=index.d.ts.map
@@ -1,2 +1 @@
1
1
  export declare const generateCacheKey: (brand: string, environment: string, key: string) => string;
2
- //# sourceMappingURL=generate-cache-key.d.ts.map
@@ -1,2 +1 @@
1
1
  export * from "./generate-cache-key";
2
- //# sourceMappingURL=index.d.ts.map
@@ -1,3 +1,2 @@
1
1
  export declare const encodeData: (data: string, dataKey: string) => string;
2
2
  export declare const decodeData: (encryptedData: string, dataKey: string) => string;
3
- //# sourceMappingURL=getCrypto.d.ts.map
@@ -1,2 +1 @@
1
1
  export * from "./getCrypto";
2
- //# sourceMappingURL=index.d.ts.map
@@ -8,4 +8,3 @@ export declare const getDateTimeDiff: (fromDate: string, toDate?: string) => {
8
8
  minutes: () => number;
9
9
  asMilliseconds: () => number;
10
10
  };
11
- //# sourceMappingURL=getDateTimeDiff.d.ts.map
@@ -1,2 +1 @@
1
1
  export * from "./getDateTimeDiff";
2
- //# sourceMappingURL=index.d.ts.map
@@ -5,4 +5,3 @@
5
5
  * @returns width in px of the given text
6
6
  */
7
7
  export declare const getTextWidth: (text: string, font?: string) => number | undefined;
8
- //# sourceMappingURL=getTextWidth.d.ts.map
@@ -1,2 +1 @@
1
1
  export * from "./getTextWidth";
2
- //# sourceMappingURL=index.d.ts.map
@@ -5,4 +5,3 @@ export * from "./getCrypto";
5
5
  export * from "./getDateTimeDiff";
6
6
  export * from "./getTextWidth";
7
7
  export * from "./setCookie";
8
- //# sourceMappingURL=index.d.ts.map
@@ -1,2 +1 @@
1
1
  export * from "./setCookie";
2
- //# sourceMappingURL=index.d.ts.map
@@ -1,2 +1 @@
1
1
  export declare const setCookie: (cname: string, cvalue: string, exdays: number) => void;
2
- //# sourceMappingURL=setCookie.d.ts.map
package/package.json CHANGED
@@ -1,53 +1,72 @@
1
1
  {
2
- "name": "@mysetup/helpers",
3
- "version": "2.0.1",
4
- "license": "MIT",
5
- "main": "dist/index.js",
6
- "files": [
7
- "dist"
8
- ],
9
- "exports": {
10
- ".": {
11
- "types": "./dist/index.d.ts",
12
- "import": "./dist/index.js",
13
- "require": "./dist/index.js"
14
- },
15
- "./package.json": "./package.json"
2
+ "name": "@mysetup/helpers",
3
+ "version": "2.0.6",
4
+ "description": "Shared utility helpers for browser and server applications.",
5
+ "author": "krishnaraj <krishnaraj.webdev@gmail.com>",
6
+ "license": "MIT",
7
+ "keywords": [
8
+ "helpers",
9
+ "utilities",
10
+ "typescript",
11
+ "react",
12
+ "nodejs"
13
+ ],
14
+ "publishConfig": {
15
+ "access": "public"
16
+ },
17
+ "main": "dist/index.js",
18
+ "types": "dist/index.d.ts",
19
+ "sideEffects": false,
20
+ "files": [
21
+ "dist",
22
+ "README.md"
23
+ ],
24
+ "exports": {
25
+ ".": {
26
+ "types": "./dist/index.d.ts",
27
+ "import": "./dist/index.js",
28
+ "require": "./dist/index.js"
16
29
  },
17
- "scripts": {
18
- "build": "rm -rf ./dist && tsc -p tsconfig.build.json",
19
- "lint": "eslint .",
20
- "test": "jest",
21
- "test:update": "pnpm test -- -u",
22
- "test:coverage": "jest --coverage",
23
- "typecheck": "tsc --noEmit",
24
- "format": "prettier --write \"**/*.{ts,tsx,md,js,mjs,json}\"",
25
- "checks": "pnpm typecheck && pnpm lint && pnpm test",
26
- "clean": "rm -rf node_modules .swc dist pnpm-lock.yaml && echo \"✅ Successfully removed \""
30
+ "./crypto": {
31
+ "types": "./dist/src/getCrypto/index.d.ts",
32
+ "import": "./dist/src/getCrypto/index.js",
33
+ "require": "./dist/src/getCrypto/index.js"
27
34
  },
28
- "dependencies": {
29
- "@mysetup/logger": "latest",
30
- "dayjs": "^1.11.13"
31
- },
32
- "devDependencies": {
33
- "@mysetup/eslint-config": "latest",
34
- "@mysetup/jest-config": "latest",
35
- "@mysetup/prettier-config": "latest",
36
- "@mysetup/tsconfig": "latest",
37
- "@mysetup/types": "latest",
38
- "@types/jest": "^29.5.14",
39
- "@types/node": "^22.13.1",
40
- "@types/react": "^18.3.1",
41
- "@types/react-dom": "^18.3.1",
42
- "jest": "^29.7.0",
43
- "next": "^15.1.9",
44
- "react": "^18.3.1",
45
- "react-dom": "^18.3.1",
46
- "typescript": "5.5.4"
47
- },
48
- "prettier": "@mysetup/prettier-config",
49
- "engines": {
50
- "node": ">=20.15.1"
51
- },
52
- "packageManager": "pnpm@9.9.0"
53
- }
35
+ "./package.json": "./package.json"
36
+ },
37
+ "dependencies": {
38
+ "dayjs": "^1.11.13",
39
+ "@mysetup/logger": "^2.0.6"
40
+ },
41
+ "devDependencies": {
42
+ "@types/jest": "^29.5.14",
43
+ "@types/node": "^22.13.1",
44
+ "@types/react": "^18.3.1",
45
+ "@types/react-dom": "^18.3.1",
46
+ "jest": "^29.7.0",
47
+ "next": "^15.1.9",
48
+ "react": "^18.3.1",
49
+ "react-dom": "^18.3.1",
50
+ "typescript": "5.5.4",
51
+ "@mysetup/jest-config": "^2.0.6",
52
+ "@mysetup/prettier-config": "^2.0.6",
53
+ "@mysetup/eslint-config": "^2.0.7",
54
+ "@mysetup/types": "^2.0.9",
55
+ "@mysetup/tsconfig": "^2.0.6"
56
+ },
57
+ "prettier": "@mysetup/prettier-config",
58
+ "engines": {
59
+ "node": ">=20.15.1"
60
+ },
61
+ "scripts": {
62
+ "build": "node ../scripts/package-fs.cjs remove dist && tsc -p tsconfig.build.json",
63
+ "lint": "node ../scripts/run-eslint.cjs .",
64
+ "test": "jest",
65
+ "test:update": "pnpm test -- -u",
66
+ "test:coverage": "jest --coverage",
67
+ "typecheck": "tsc --noEmit",
68
+ "format": "prettier --write \"**/*.{ts,tsx,md,js,mjs,json}\"",
69
+ "checks": "pnpm typecheck && pnpm lint && pnpm test && pnpm build",
70
+ "clean": "node ../scripts/package-fs.cjs remove node_modules .swc dist pnpm-lock.yaml && echo \"Cleaned\""
71
+ }
72
+ }
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"arrayMethods.d.ts","sourceRoot":"","sources":["../../../src/arrayMethods/arrayMethods.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,MAAM,CAAC,UAc3E"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/arrayMethods/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"formatPhoneNumber.d.ts","sourceRoot":"","sources":["../../../src/formatPhoneNumber/formatPhoneNumber.ts"],"names":[],"mappings":"AAEA,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAUpE;AAED,eAAO,MAAM,qBAAqB,gBAAiB,MAAM,KAAG,MAM3D,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/formatPhoneNumber/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"generate-cache-key.d.ts","sourceRoot":"","sources":["../../../src/generate-cache-key/generate-cache-key.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,UAClB,MAAM,eACA,MAAM,OACd,MAAM,WAGd,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/generate-cache-key/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"getCrypto.d.ts","sourceRoot":"","sources":["../../../src/getCrypto/getCrypto.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,UAAU,SAAU,MAAM,WAAW,MAAM,KAAG,MAgB1D,CAAC;AAEF,eAAO,MAAM,UAAU,kBAAmB,MAAM,WAAW,MAAM,KAAG,MAoBnE,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/getCrypto/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"getDateTimeDiff.d.ts","sourceRoot":"","sources":["../../../src/getDateTimeDiff/getDateTimeDiff.ts"],"names":[],"mappings":"AACA,OAAO,cAAc,MAAM,uBAAuB,CAAC;AAMnD,eAAO,MAAM,eAAe,aAAc,MAAM,WAAW,MAAM;;;;;;;;CAqChE,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/getDateTimeDiff/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"getTextWidth.d.ts","sourceRoot":"","sources":["../../../src/getTextWidth/getTextWidth.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,YAAY,SAAU,MAAM,SAAS,MAAM,uBAWvD,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/getTextWidth/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/setCookie/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"setCookie.d.ts","sourceRoot":"","sources":["../../../src/setCookie/setCookie.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,UAAW,MAAM,UAAU,MAAM,UAAU,MAAM,SAKtE,CAAC"}