@bejibun/core 0.1.16

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Havea Crenata
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,28 @@
1
+ <div align="center">
2
+
3
+ ![GitHub top language](https://img.shields.io/github/languages/top/crenata/bejibun-core)
4
+ ![GitHub all releases](https://img.shields.io/github/downloads/crenata/bejibun-core/total)
5
+ ![GitHub issues](https://img.shields.io/github/issues/crenata/bejibun-core)
6
+ ![GitHub](https://img.shields.io/github/license/crenata/bejibun-core)
7
+ ![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/crenata/bejibun-core?display_name=tag&include_prereleases)
8
+
9
+ </div>
10
+
11
+ # Core of Bejibun
12
+ Core of Bejibun Framework.
13
+
14
+ ## Usage
15
+
16
+ ### Installation
17
+ Install the package.
18
+
19
+ ```bash
20
+ # Using Bun
21
+ bun add @bejibun/core
22
+
23
+ # Using Bejibun
24
+ bun ace install @bejibun/core
25
+ ```
26
+
27
+ ## Contributors
28
+ - [Havea Crenata](mailto:havea.crenata@gmail.com)
@@ -0,0 +1 @@
1
+ export * from "@/index";
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ export * from "@/index";
@@ -0,0 +1,7 @@
1
+ export default class EnumBuilder {
2
+ protected enums: any;
3
+ constructor(enums: any);
4
+ getName(value: number): string | undefined;
5
+ getValue(key: string): number;
6
+ toArray(): Array<any>;
7
+ }
@@ -0,0 +1,23 @@
1
+ import { isEmpty } from "@/utils/utils";
2
+ export default class EnumBuilder {
3
+ enums;
4
+ constructor(enums) {
5
+ if (isEmpty(enums))
6
+ throw new Error("The enum parameter is required.");
7
+ this.enums = enums;
8
+ }
9
+ getName(value) {
10
+ return Object.keys(this.enums).find(item => this.enums[item] === value);
11
+ }
12
+ getValue(key) {
13
+ return this.enums[key];
14
+ }
15
+ toArray() {
16
+ return Object.keys(this.enums)
17
+ .filter(key => isNaN(Number(key)))
18
+ .map(key => ({
19
+ name: key,
20
+ value: this.getValue(key)
21
+ }));
22
+ }
23
+ }
@@ -0,0 +1,6 @@
1
+ export default class StrBuilder {
2
+ protected value: string;
3
+ constructor();
4
+ setValue(value: string): StrBuilder;
5
+ toPascalCase(combine?: boolean): StrBuilder | string;
6
+ }
@@ -0,0 +1,19 @@
1
+ import { defineValue, isNotEmpty } from "@/utils/utils";
2
+ export default class StrBuilder {
3
+ value;
4
+ constructor() {
5
+ this.value = "";
6
+ }
7
+ setValue(value) {
8
+ this.value = value;
9
+ return this;
10
+ }
11
+ toPascalCase(combine) {
12
+ this.value = defineValue(this.value.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g), [])
13
+ .map((x) => x.slice(0, 1).toUpperCase() + x.slice(1).toLowerCase())
14
+ .join("");
15
+ if (isNotEmpty(combine))
16
+ return this;
17
+ return this.value;
18
+ }
19
+ }
@@ -0,0 +1,3 @@
1
+ export * from "@/utils/Enum";
2
+ export * from "@/utils/Str";
3
+ export * from "@/utils/utils";
@@ -0,0 +1,3 @@
1
+ export * from "@/utils/Enum";
2
+ export * from "@/utils/Str";
3
+ export * from "@/utils/utils";
@@ -0,0 +1,4 @@
1
+ import EnumBuilder from "@/builders/EnumBuilder";
2
+ export default class Enum {
3
+ static setEnums(enums: any): EnumBuilder;
4
+ }
@@ -0,0 +1,6 @@
1
+ import EnumBuilder from "@/builders/EnumBuilder";
2
+ export default class Enum {
3
+ static setEnums(enums) {
4
+ return new EnumBuilder(enums);
5
+ }
6
+ }
@@ -0,0 +1,4 @@
1
+ import StrBuilder from "@/builders/StrBuilder";
2
+ export default class Str {
3
+ static toPascalCase(value: string, combine?: boolean): StrBuilder | string;
4
+ }
@@ -0,0 +1,6 @@
1
+ import StrBuilder from "@/builders/StrBuilder";
2
+ export default class Str {
3
+ static toPascalCase(value, combine) {
4
+ return new StrBuilder().setValue(value).toPascalCase(combine);
5
+ }
6
+ }
@@ -0,0 +1,4 @@
1
+ export declare const isEmpty: (value: any) => boolean;
2
+ export declare const isNotEmpty: (value: any) => boolean;
3
+ export declare const defineValue: (value: any, defaultValue?: any) => any;
4
+ export declare const ask: (question: string) => Promise<string>;
@@ -0,0 +1,31 @@
1
+ import readline from "readline";
2
+ export const isEmpty = (value) => {
3
+ return (value === undefined ||
4
+ value === null ||
5
+ value === false ||
6
+ value === 0 ||
7
+ value === 0n ||
8
+ (typeof value === "string" && value.trim() === "") ||
9
+ (Array.isArray(value) && value.length === 0) ||
10
+ (typeof value === "object" && !Array.isArray(value) && Object.keys(value).length === 0));
11
+ };
12
+ export const isNotEmpty = (value) => {
13
+ return !isEmpty(value);
14
+ };
15
+ export const defineValue = (value, defaultValue = null) => {
16
+ if (isNotEmpty(value))
17
+ return value;
18
+ return defaultValue;
19
+ };
20
+ export const ask = (question) => {
21
+ const rl = readline.createInterface({
22
+ input: process.stdin,
23
+ output: process.stdout
24
+ });
25
+ return new Promise((resolve, reject) => {
26
+ return rl.question(question, (answer) => {
27
+ rl.close();
28
+ resolve(answer.trim());
29
+ });
30
+ });
31
+ };
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@bejibun/core",
3
+ "version": "0.1.16",
4
+ "description": "Core of Bejibun Framework",
5
+ "keywords": [
6
+ "bun",
7
+ "bun framework",
8
+ "core",
9
+ "bejibun",
10
+ "typescript"
11
+ ],
12
+ "homepage": "https://github.com/crenata/bejibun-core#readme",
13
+ "bugs": {
14
+ "url": "https://github.com/crenata/bejibun-core/issues"
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/crenata/bejibun-core.git"
19
+ },
20
+ "license": "MIT",
21
+ "author": "Havea Crenata <havea.crenata@gmail.com>",
22
+ "type": "module",
23
+ "main": "./dist/index.js",
24
+ "types": "./dist/index.d.ts",
25
+ "exports": {
26
+ ".": {
27
+ "import": "./dist/index.js",
28
+ "types": "./dist/index.d.ts"
29
+ }
30
+ },
31
+ "files": [
32
+ "dist"
33
+ ],
34
+ "scripts": {
35
+ "build": "tsc --project tsconfig.json"
36
+ },
37
+ "dependencies": {
38
+ "bun-types": "^1.3.0",
39
+ "csstype": "^3.1.3",
40
+ "typescript": "^5.9.3",
41
+ "undici-types": "^7.14.0"
42
+ },
43
+ "devDependencies": {
44
+ "@types/bun": "latest"
45
+ },
46
+ "peerDependencies": {
47
+ "typescript": "^5"
48
+ }
49
+ }