Skip to content

Commit 5b7c40d

Browse files
committed
first commit
1 parent 0e03c19 commit 5b7c40d

27 files changed

+5177
-2
lines changed

.eslintrc.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"parser": "@typescript-eslint/parser",
3+
"parserOptions": {
4+
"ecmaVersion": 2020,
5+
"sourceType": "module"
6+
},
7+
"plugins": ["@typescript-eslint"],
8+
"rules": {
9+
"import/extensions": ["error", "always"] // Enforce explicit extensions
10+
}
11+
}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ yarn-debug.log*
66
yarn-error.log*
77
lerna-debug.log*
88
.pnpm-debug.log*
9+
.idea
910

1011
# Diagnostic reports (https://nodejs.org/api/report.html)
1112
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

README.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,25 @@
1-
# utils
2-
Lib Utils for your project
1+
# Up Utils
2+
3+
A collection of TypeScript utility functions and helpers for Up Toolkit system.
4+
5+
## Installation
6+
7+
```bash
8+
npm i @uptoolkit/js-utils
9+
```
10+
11+
## Usage
12+
13+
You can use and import these functions into your own project.
14+
15+
````typescript
16+
import { uuid } from '@uptoolkit/js-utils';
17+
````
18+
19+
## Functions
20+
21+
- `uuid()`: Generate a random UUID.
22+
23+
## License
24+
25+
MIT

ignore_list.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
dist/*
2+
node_modules/*
3+
package-lock.json
4+
yarn.lock

jest.config.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export default {
2+
preset: 'ts-jest',
3+
testEnvironment: 'node',
4+
testMatch: ['**/tests/**/*.test.ts'],
5+
collectCoverage: true,
6+
coverageDirectory: 'coverage',
7+
coverageReporters: ['text', 'lcov'],
8+
moduleNameMapper: {
9+
'^@/(.*)$': '<rootDir>/src/$1'
10+
}
11+
};

package.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"name": "@uptoolkit/js-utils",
3+
"version": "1.0.0",
4+
"description": "Lib utils for your next project",
5+
"author": "Daniel Sum <[email protected]>",
6+
"license": "MIT",
7+
"main": "dist/index.js",
8+
"module": "dist/index.mjs",
9+
"types": "dist/index.d.ts",
10+
"exports": {
11+
".": {
12+
"import": "./dist/index.mjs",
13+
"require": "./dist/index.js"
14+
}
15+
},
16+
"files": [
17+
"dist"
18+
],
19+
"scripts": {
20+
"build": "tsup src --format esm,cjs --dts && tsc-alias",
21+
"test": "ts-node -r tsconfig-paths/register node_modules/.bin/jest",
22+
"format:check": "prettier --check .",
23+
"format": "prettier --write .",
24+
"test:watch": "jest --watch"
25+
},
26+
"devDependencies": {
27+
"@types/jest": "^29.5.12",
28+
"jest": "^29.7.0",
29+
"prettier": "^3.4.2",
30+
"ts-jest": "^29.1.2",
31+
"ts-node": "^10.9.2",
32+
"tsc-alias": "^1.8.10",
33+
"tsconfig-paths": "^4.2.0",
34+
"tsup": "^8.3.5",
35+
"typescript": "^5.2.2"
36+
},
37+
"dependencies": {
38+
"clsx": "^2.1.1",
39+
"tailwind-merge": "^2.6.0",
40+
"uuid": "^11.0.5"
41+
},
42+
"type": "module"
43+
}

prettier_config.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"semi": true, // Add a semicolon at the end of statements
3+
"singleQuote": true, // Use single quotes instead of double quotes
4+
"trailingComma": "es5", // Add trailing commas where possible (e.g., objects, arrays)
5+
"tabWidth": 2, // Indent with 2 spaces
6+
"useTabs": false, // Indent using spaces, not tabs
7+
"arrowParens": "always", // Always include parentheses for arrow functions
8+
"bracketSpacing": true, // Add spaces between brackets in object literals
9+
"endOfLine": "lf" // Enforce Unix-style line endings
10+
}

publish.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
# Exit immediately if a command exits with a non-zero status
4+
set -e
5+
6+
# Run the build script
7+
echo "Building the package..."
8+
npm run build
9+
10+
# Check if the build was successful
11+
if [ $? -ne 0 ]; then
12+
echo "Build failed. Exiting."
13+
exit 1
14+
fi
15+
16+
# Publish the package
17+
echo "Publishing the package to npm..."
18+
npm publish
19+
20+
# Check if publish was successful
21+
if [ $? -ne 0 ]; then
22+
echo "Publish failed. Exiting."
23+
exit 1
24+
fi
25+
26+
echo "Package published successfully!"

src/core/index.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Fix an issue that might happend with the BigInt type
2+
// @ts-ignore
3+
if (typeof BigInt.prototype.toJSON === 'undefined') {
4+
// @ts-ignore
5+
BigInt.prototype.toJSON = function () {
6+
return this.toString();
7+
};
8+
}
9+
10+
/**
11+
* Return the Version of Up
12+
*
13+
* @returns string
14+
*/
15+
export function UpVersion(){
16+
return process.env.UP_VERSION;
17+
}

src/date/humanDate.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export function humanizeDate(date: string) {
2+
return (
3+
new Date(date).toLocaleDateString() +
4+
' ' +
5+
new Date(date).toLocaleTimeString()
6+
);
7+
}

0 commit comments

Comments
 (0)