badlib 0.0.1 → 0.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/package.json +5 -1
- package/src/functions/cn.ts +6 -6
- package/src/functions/getObjectKeys.ts +1 -1
- package/src/functions/index.ts +1 -1
- package/src/functions/tryCatch.ts +25 -0
- package/src/index.ts +1 -1
- package/.github/workflows/publish.yml +0 -42
- package/tsconfig.json +0 -39
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "badlib",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -19,5 +19,9 @@
|
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"clsx": "^2.1.1",
|
|
21
21
|
"tailwind-merge": "^3.4.0"
|
|
22
|
+
},
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "https://github.com/BADtochka/badlib"
|
|
22
26
|
}
|
|
23
27
|
}
|
package/src/functions/cn.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { clsx, type ClassValue } from 'clsx';
|
|
2
|
-
import { twMerge } from 'tailwind-merge';
|
|
3
|
-
|
|
4
|
-
export const cn = (...inputs: ClassValue[]) => {
|
|
5
|
-
return twMerge(clsx(inputs));
|
|
6
|
-
};
|
|
1
|
+
import { clsx, type ClassValue } from 'clsx';
|
|
2
|
+
import { twMerge } from 'tailwind-merge';
|
|
3
|
+
|
|
4
|
+
export const cn = (...inputs: ClassValue[]) => {
|
|
5
|
+
return twMerge(clsx(inputs));
|
|
6
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const getObjectKeys = <T extends {}>(obj: T) => Object.keys(obj) as (keyof T)[];
|
|
1
|
+
export const getObjectKeys = <T extends {}>(obj: T) => Object.keys(obj) as (keyof T)[];
|
package/src/functions/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from '.';
|
|
1
|
+
export * from '.';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Thanks Theo for this function.
|
|
2
|
+
// Source: https://gist.github.com/t3dotgg/a486c4ae66d32bf17c09c73609dacc5b
|
|
3
|
+
|
|
4
|
+
// Types for the result object with discriminated union
|
|
5
|
+
type Success<T> = {
|
|
6
|
+
data: T;
|
|
7
|
+
error: null;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
type Failure<E> = {
|
|
11
|
+
data: null;
|
|
12
|
+
error: E;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
type Result<T, E = Error> = Success<T> | Failure<E>;
|
|
16
|
+
|
|
17
|
+
// Main wrapper function
|
|
18
|
+
export async function tryCatch<T, E = Error>(promise: Promise<T>): Promise<Result<T, E>> {
|
|
19
|
+
try {
|
|
20
|
+
const data = await promise;
|
|
21
|
+
return { data, error: null };
|
|
22
|
+
} catch (error) {
|
|
23
|
+
return { data: null, error: error as E };
|
|
24
|
+
}
|
|
25
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * as functions from './functions';
|
|
1
|
+
export * as functions from './functions';
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
name: Publish to npm
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- main
|
|
7
|
-
|
|
8
|
-
permissions:
|
|
9
|
-
contents: write
|
|
10
|
-
id-token: write
|
|
11
|
-
|
|
12
|
-
jobs:
|
|
13
|
-
publish:
|
|
14
|
-
runs-on: ubuntu-latest
|
|
15
|
-
|
|
16
|
-
steps:
|
|
17
|
-
- uses: actions/checkout@v4
|
|
18
|
-
with:
|
|
19
|
-
fetch-depth: 0
|
|
20
|
-
|
|
21
|
-
- uses: oven-sh/setup-bun@v1
|
|
22
|
-
|
|
23
|
-
- run: bun install --frozen-lockfile
|
|
24
|
-
|
|
25
|
-
- name: Bump version (patch)
|
|
26
|
-
run: |
|
|
27
|
-
npm version patch -m "chore(release): v%s"
|
|
28
|
-
|
|
29
|
-
- name: Build
|
|
30
|
-
run: bun run build
|
|
31
|
-
|
|
32
|
-
- name: Configure npm auth
|
|
33
|
-
run: |
|
|
34
|
-
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
|
|
35
|
-
env:
|
|
36
|
-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
37
|
-
|
|
38
|
-
- name: Publish
|
|
39
|
-
run: npm publish --access public
|
|
40
|
-
|
|
41
|
-
- name: Push version bump
|
|
42
|
-
run: git push --follow-tags
|
package/tsconfig.json
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
/* Language & runtime */
|
|
4
|
-
"target": "ES2019",
|
|
5
|
-
"lib": [
|
|
6
|
-
"ES2019",
|
|
7
|
-
"DOM"
|
|
8
|
-
],
|
|
9
|
-
"jsx": "react-jsx",
|
|
10
|
-
/* Module system */
|
|
11
|
-
"module": "ESNext",
|
|
12
|
-
"moduleResolution": "node",
|
|
13
|
-
"moduleDetection": "force",
|
|
14
|
-
"verbatimModuleSyntax": true,
|
|
15
|
-
/* Output */
|
|
16
|
-
"rootDir": "src",
|
|
17
|
-
"outDir": "dist",
|
|
18
|
-
"declaration": true,
|
|
19
|
-
"declarationMap": true,
|
|
20
|
-
"sourceMap": true,
|
|
21
|
-
"emitDeclarationOnly": false,
|
|
22
|
-
"noEmit": false,
|
|
23
|
-
/* Interop & compatibility */
|
|
24
|
-
"esModuleInterop": true,
|
|
25
|
-
"forceConsistentCasingInFileNames": true,
|
|
26
|
-
/* Type safety */
|
|
27
|
-
"strict": true,
|
|
28
|
-
"noUncheckedIndexedAccess": true,
|
|
29
|
-
"noImplicitOverride": true,
|
|
30
|
-
"noFallthroughCasesInSwitch": true,
|
|
31
|
-
/* Performance / DX */
|
|
32
|
-
"skipLibCheck": true,
|
|
33
|
-
/* Pathing */
|
|
34
|
-
"baseUrl": "./src"
|
|
35
|
-
},
|
|
36
|
-
"include": [
|
|
37
|
-
"src"
|
|
38
|
-
],
|
|
39
|
-
}
|