@mysetup/helpers 2.0.1 → 2.0.3
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 +46 -0
- package/dist/index.d.ts +0 -1
- package/dist/src/arrayMethods/arrayMethods.d.ts +0 -1
- package/dist/src/arrayMethods/index.d.ts +0 -1
- package/dist/src/formatPhoneNumber/formatPhoneNumber.d.ts +0 -1
- package/dist/src/formatPhoneNumber/index.d.ts +0 -1
- package/dist/src/generate-cache-key/generate-cache-key.d.ts +0 -1
- package/dist/src/generate-cache-key/index.d.ts +0 -1
- package/dist/src/getCrypto/getCrypto.d.ts +0 -1
- package/dist/src/getCrypto/index.d.ts +0 -1
- package/dist/src/getDateTimeDiff/getDateTimeDiff.d.ts +0 -1
- package/dist/src/getDateTimeDiff/index.d.ts +0 -1
- package/dist/src/getTextWidth/getTextWidth.d.ts +0 -1
- package/dist/src/getTextWidth/index.d.ts +0 -1
- package/dist/src/index.d.ts +0 -2
- package/dist/src/index.js +0 -1
- package/dist/src/setCookie/index.d.ts +0 -1
- package/dist/src/setCookie/setCookie.d.ts +0 -1
- package/package.json +68 -50
- package/dist/index.d.ts.map +0 -1
- package/dist/src/arrayMethods/arrayMethods.d.ts.map +0 -1
- package/dist/src/arrayMethods/index.d.ts.map +0 -1
- package/dist/src/formatPhoneNumber/formatPhoneNumber.d.ts.map +0 -1
- package/dist/src/formatPhoneNumber/index.d.ts.map +0 -1
- package/dist/src/generate-cache-key/generate-cache-key.d.ts.map +0 -1
- package/dist/src/generate-cache-key/index.d.ts.map +0 -1
- package/dist/src/getCrypto/getCrypto.d.ts.map +0 -1
- package/dist/src/getCrypto/index.d.ts.map +0 -1
- package/dist/src/getDateTimeDiff/getDateTimeDiff.d.ts.map +0 -1
- package/dist/src/getDateTimeDiff/index.d.ts.map +0 -1
- package/dist/src/getTextWidth/getTextWidth.d.ts.map +0 -1
- package/dist/src/getTextWidth/index.d.ts.map +0 -1
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/setCookie/index.d.ts.map +0 -1
- 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
package/dist/src/index.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
export * from "./arrayMethods";
|
|
2
2
|
export * from "./formatPhoneNumber";
|
|
3
3
|
export * from "./generate-cache-key";
|
|
4
|
-
export * from "./getCrypto";
|
|
5
4
|
export * from "./getDateTimeDiff";
|
|
6
5
|
export * from "./getTextWidth";
|
|
7
6
|
export * from "./setCookie";
|
|
8
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,53 +1,71 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
"name": "@mysetup/helpers",
|
|
3
|
+
"version": "2.0.3",
|
|
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
|
+
],
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"import": "./dist/index.js",
|
|
27
|
+
"require": "./dist/index.js"
|
|
16
28
|
},
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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 \""
|
|
29
|
+
"./crypto": {
|
|
30
|
+
"types": "./dist/src/getCrypto/index.d.ts",
|
|
31
|
+
"import": "./dist/src/getCrypto/index.js",
|
|
32
|
+
"require": "./dist/src/getCrypto/index.js"
|
|
27
33
|
},
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
"
|
|
53
|
-
}
|
|
34
|
+
"./package.json": "./package.json"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"dayjs": "^1.11.13",
|
|
38
|
+
"@mysetup/logger": "^2.0.4"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@types/jest": "^29.5.14",
|
|
42
|
+
"@types/node": "^22.13.1",
|
|
43
|
+
"@types/react": "^18.3.1",
|
|
44
|
+
"@types/react-dom": "^18.3.1",
|
|
45
|
+
"jest": "^29.7.0",
|
|
46
|
+
"next": "^15.1.9",
|
|
47
|
+
"react": "^18.3.1",
|
|
48
|
+
"react-dom": "^18.3.1",
|
|
49
|
+
"typescript": "5.5.4",
|
|
50
|
+
"@mysetup/tsconfig": "^2.0.4",
|
|
51
|
+
"@mysetup/eslint-config": "^2.0.5",
|
|
52
|
+
"@mysetup/prettier-config": "^2.0.4",
|
|
53
|
+
"@mysetup/jest-config": "^2.0.4",
|
|
54
|
+
"@mysetup/types": "^2.0.7"
|
|
55
|
+
},
|
|
56
|
+
"prettier": "@mysetup/prettier-config",
|
|
57
|
+
"engines": {
|
|
58
|
+
"node": ">=20.15.1"
|
|
59
|
+
},
|
|
60
|
+
"scripts": {
|
|
61
|
+
"build": "node ../scripts/package-fs.cjs remove dist && tsc -p tsconfig.build.json",
|
|
62
|
+
"lint": "node ../scripts/run-eslint.cjs .",
|
|
63
|
+
"test": "jest",
|
|
64
|
+
"test:update": "pnpm test -- -u",
|
|
65
|
+
"test:coverage": "jest --coverage",
|
|
66
|
+
"typecheck": "tsc --noEmit",
|
|
67
|
+
"format": "prettier --write \"**/*.{ts,tsx,md,js,mjs,json}\"",
|
|
68
|
+
"checks": "pnpm typecheck && pnpm lint && pnpm test && pnpm build",
|
|
69
|
+
"clean": "node ../scripts/package-fs.cjs remove node_modules .swc dist pnpm-lock.yaml && echo \"Cleaned\""
|
|
70
|
+
}
|
|
71
|
+
}
|
package/dist/index.d.ts.map
DELETED
|
@@ -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"}
|
package/dist/src/index.d.ts.map
DELETED
|
@@ -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"}
|