js-utils-kit 0.5.5 → 1.0.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/README.md CHANGED
@@ -1,44 +1,9 @@
1
- <div align="center">
1
+ # js-utils-kit
2
2
 
3
- <!-- [![img](https://capsule-render.vercel.app/api?type=waving&height=300&color=gradient&text=Js%20Utils%20Kit&section=footer&desc=Modular%20JavaScript%20utilities%20with%20type%20support%20for%20strings,%20objects,%20arrays,%20and%20more&descAlign=49&descAlignY=72&animation=fadeIn&textBg=false)](https://github.com/TenEplaysOfficial/js-utils-kit) -->
3
+ > _Modular JavaScript utilities with type support_
4
4
 
5
- # Js Utils Kit
6
-
7
- _Modular JavaScript utilities with type support for strings, objects, arrays and more_
8
-
9
- [![Build](https://github.com/teneplaysofficial/js-utils-kit/actions/workflows/publish.yml/badge.svg)](https://github.com/TenEplaysOfficial/js-utils-kit)
10
- [![Test](https://github.com/teneplaysofficial/js-utils-kit/actions/workflows/test.yml/badge.svg)](https://github.com/TenEplaysOfficial/js-utils-kit)
11
- [![codecov](https://codecov.io/github/teneplaysofficial/js-utils-kit/graph/badge.svg?token=9CEFGKSU2S)](https://github.com/TenEplaysOfficial/js-utils-kit)
12
- [![npm version](https://img.shields.io/npm/v/js-utils-kit.svg?logo=npm)](https://www.npmjs.com/package/js-utils-kit)
13
- [![JSR](https://jsr.io/badges/@tene/js-utils-kit)](https://jsr.io/@tene/js-utils-kit)
14
- [![JSR Score](https://jsr.io/badges/@tene/js-utils-kit/score)](https://jsr.io/@tene/js-utils-kit)
15
- [![License](https://img.shields.io/github/license/TenEplaysOfficial/js-utils-kit.svg?logo=open-source-initiative)](https://github.com/TenEplaysOfficial/js-utils-kit/blob/main/LICENSE)
16
- [![GitHub stars](https://img.shields.io/github/stars/TenEplaysOfficial/js-utils-kit?style=flat&logo=github)](https://github.com/TenEplaysOfficial/js-utils-kit/stargazers)
17
- [![Issues](https://img.shields.io/github/issues/TenEplaysOfficial/js-utils-kit?logo=github)](https://github.com/TenEplaysOfficial/js-utils-kit/issues)
18
- [![PRs](https://img.shields.io/github/issues-pr/TenEplaysOfficial/js-utils-kit?logo=github)](https://github.com/TenEplaysOfficial/js-utils-kit/pulls)
19
- [![Last Commit](https://img.shields.io/github/last-commit/TenEplaysOfficial/js-utils-kit?logo=git)](https://github.com/TenEplaysOfficial/js-utils-kit/commits)
5
+ [![npm version](https://img.shields.io/npm/v/js-utils-kit.svg?logo=npm&color=brightgreen)](https://www.npmjs.com/package/js-utils-kit)
20
6
  [![Downloads](https://img.shields.io/npm/dt/js-utils-kit?logo=npm)](https://www.npmjs.com/package/js-utils-kit)
21
- [![Type Support](https://img.shields.io/badge/type-support-blue?logo=typescript)](https://github.com/TenEplaysOfficial/js-utils-kit)
22
- [![Sponsor](https://img.shields.io/badge/funding-sponsor-yellow?logo=githubsponsors)](https://github.com/sponsors/TenEplaysOfficial)
23
- [![Follow @teneplays on X](https://img.shields.io/badge/follow-@teneplays-fff?logo=x)](https://x.com/teneplays)
24
-
25
- </div>
26
-
27
- ## Overview
28
-
29
- **JS Utils Kit** is a compact and reliable library of essential JavaScript utility functions. It includes helpers for arrays, objects, numbers, promises, type checking, and more. Designed for performance and modularity, it integrates easily into JavaScript and TypeScript projects with minimal impact on bundle size.
30
-
31
- > Streamline your code with battle-tested, tree-shakable utilities.
32
-
33
- This package includes utilities designed for both browser and Node.js environments, clearly organized and optimized for cross-platform compatibility.
34
-
35
- ## Features
36
-
37
- - Organized by category (e.g., `number`, `string`, `file`, etc.)
38
- - Fully typed in TypeScript
39
- - Thoroughly tested with Jest
40
- - Tree‑shakeable and supports both ESM and CJS
41
- - CLI-ready tools for file and system operations
42
7
 
43
8
  ## Installation
44
9
 
@@ -54,138 +19,32 @@ pnpm add js-utils-kit
54
19
 
55
20
  # via bun
56
21
  bun add js-utils-kit
57
-
58
- # via Deno (using npm)
59
- deno add npm:js-utils-kit
60
-
61
- # via Deno (using JSR)
62
- deno add jsr:@tene/js-utils-kit
63
-
64
- # via JSR
65
- npx jsr add @tene/js-utils-kit
66
22
  ```
67
23
 
68
24
  ## Usage
69
25
 
70
- `js-utils-kit` offers a modular structure for utilities across different categories like `number`, `string`, `array`, `object`, `env`, and more. You can use full or scoped imports depending on your preference and project setup.
71
-
72
- ### Recommended Import
73
-
74
- Import only what you need by utility category:
75
-
76
26
  ```ts
77
- import number from 'js-utils-kit/number';
78
- import string from 'js-utils-kit/string';
79
- import array from 'js-utils-kit/array';
80
- import object from 'js-utils-kit/object';
81
- import env from 'js-utils-kit/env';
27
+ import { capitalize, clamp, isBrowser, isEmpty, unique } from 'js-utils-kit';
82
28
 
83
- console.log(number.clamp(150, 0, 100)); // 100
84
- console.log(string.capitalize('hello world')); // 'Hello World'
85
- console.log(array.unique([1, 2, 2, 3])); // [1, 2, 3]
86
- console.log(object.isEmpty({})); // true
87
- console.log(env.isBrowser()); // true/false
29
+ console.log(clamp(150, 0, 100)); // 100
30
+ console.log(capitalize('hello world')); // 'Hello World'
31
+ console.log(unique([1, 2, 2, 3])); // [1, 2, 3]
32
+ console.log(isEmpty({})); // true
33
+ console.log(isBrowser()); // true/false
88
34
  ```
89
35
 
90
- ### Full Import (All utils in one namespace)
36
+ or
91
37
 
92
38
  ```ts
93
39
  import * as kit from 'js-utils-kit';
94
40
 
95
- console.log(kit.number.clamp(150, 0, 100)); // 100
96
- console.log(kit.string.capitalize('hello')); // 'Hello'
97
- console.log(kit.array.unique([1, 1, 2])); // [1, 2]
98
- console.log(kit.object.isEmpty({})); // true
99
- console.log(kit.env.isNode()); // true/false
100
- ```
101
-
102
- ### Named Imports
103
-
104
- ```ts
105
- import { number, string, env } from 'js-utils-kit';
106
-
107
- console.log(number.clamp(42, 0, 100)); // 42
108
- console.log(string.capitalize('js-utils-kit')); // 'Js-utils-kit'
109
- console.log(env.isDev()); // true/false
110
- ```
111
-
112
- ### Using JSR or Deno
113
-
114
- ```ts
115
- import { number, string, env } from '@tene/js-utils-kit';
116
- // or
117
- import { number, string, env } from 'jsr:@tene/js-utils-kit';
118
- // or
119
- import number from '@tene/js-utils-kit/number';
120
- import string from '@tene/js-utils-kit/string';
121
- import array from '@tene/js-utils-kit/array';
122
- import object from '@tene/js-utils-kit/object';
123
- import env from '@tene/js-utils-kit/env';
124
- ```
125
-
126
- ### CommonJS Usage
127
-
128
- ```js
129
- const { number, string, array, object, env } = require('js-utils-kit');
130
-
131
- console.log(number.clamp(150, 0, 100)); // 100
132
- console.log(string.capitalize('hello world')); // 'Hello World'
133
- console.log(array.unique([1, 2, 2, 3])); // [1, 2, 3]
134
- console.log(object.isEmpty({})); // true
135
- console.log(env.isBrowser()); // true/false
41
+ console.log(kit.clamp(150, 0, 100)); // 100
42
+ console.log(kit.capitalize('hello')); // 'Hello'
43
+ console.log(kit.unique([1, 1, 2])); // [1, 2]
44
+ console.log(kit.isEmpty({})); // true
45
+ console.log(kit.isNode()); // true/false
136
46
  ```
137
47
 
138
48
  ## Documentation
139
49
 
140
- Full documentation available at [GitHub Pages](https://js-utils.js.org/modules.html)
141
-
142
- ## Requirements
143
-
144
- - Node.js: Version `18.0.0` or higher
145
- - Yarn (or npm as an alternative)
146
- - TypeScript (optional, for TypeScript projects or development)
147
- - Browsers: Modern browsers for browser-based usage
148
-
149
- ## Contributing
150
-
151
- We welcome contributions whether it's fixing bugs, adding utilities, improving docs, or writing tests. See [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines and join our [GitHub Discussions](https://github.com/TenEplaysOfficial/js-utils-kit/discussions) to share ideas or propose features.
152
-
153
- ## FAQ
154
-
155
- <details>
156
- <summary>Does it work in browsers?</summary>
157
-
158
- Yes, **JS Utils Kit** is compatible with modern browsers and Node.js.
159
-
160
- </details>
161
-
162
- <details>
163
- <summary>Do I need TypeScript?</summary>
164
-
165
- No, the library works in plain JavaScript, but TypeScript users benefit from full type definitions and editor support.
166
-
167
- </details>
168
-
169
- <details>
170
- <summary>How do I report a bug?</summary>
171
-
172
- Open an issue on [GitHub](https://github.com/TenEplaysOfficial/js-utils-kit/issues) or join the [Discussions](https://github.com/TenEplaysOfficial/js-utils-kit/discussions) to ask questions or share feedback.
173
-
174
- </details>
175
-
176
- <details>
177
- <summary>How can I optimize bundle size?</summary>
178
-
179
- Import only what you need:
180
-
181
- ```ts
182
- import { clamp } from 'js-utils-kit/number';
183
- ```
184
-
185
- This enables tree-shaking for smaller, optimized bundles.
186
-
187
- </details>
188
-
189
- ## License
190
-
191
- Released under the [MIT License](LICENSE)
50
+ Full documentation is available at [js-utils.js.org](https://js-utils.js.org/modules.html)
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var e=require("./array/index.cjs"),s=require("./char/index.cjs"),t=require("./env/index.cjs"),r=require("./file/index.cjs"),i=require("./number/index.cjs"),o=require("./object/index.cjs"),p=require("./string/index.cjs"),n=require("./validate-BKQ-HFTd.js");require("fs"),require("path"),require("archiver"),exports.array=e.default,exports.all=s.all,exports.char=s.default,exports.digits=s.digits,exports.lowercase=s.lowercase,exports.uppercase=s.uppercase,Object.defineProperty(exports,"Environment",{enumerable:!0,get:function(){return t.Environment}}),exports.env=t.default,exports.getRunTimeEnvironment=t.getRunTimeEnvironment,exports.isBrowser=t.isBrowser,exports.isDev=t.isDev,exports.isNode=t.isNode,exports.isProd=t.isProd,exports.isTest=t.isTest,exports.createArchive=r.createArchive,exports.file=r.default,exports.clamp=i.clamp,exports.getMilliseconds=i.getMilliseconds,exports.isEven=i.isEven,exports.isOdd=i.isOdd,exports.number=i.default,exports.randomFloat=i.randomFloat,exports.randomInt=i.randomInt,exports.isEmptyObject=o.isEmptyObject,exports.isNonEmptyObject=o.isNonEmptyObject,exports.isObject=o.isObject,exports.mergeObj=o.mergeObj,exports.object=o.default,exports.capitalize=p.capitalize,exports.containsWhitespace=p.containsWhitespace,exports.countChars=p.countChars,exports.countFrequencies=p.countFrequencies,exports.countLines=p.countLines,exports.countSubstring=p.countSubstring,exports.countWords=p.countWords,exports.endsWithPunctuation=p.endsWithPunctuation,exports.isAlphabetic=p.isAlphabetic,exports.isCamelCase=p.isCamelCase,exports.isEmail=p.isEmail,exports.isKebabCase=p.isKebabCase,exports.isLowerCase=p.isLowerCase,exports.isNonEmptyString=p.isNonEmptyString,exports.isNumericString=p.isNumericString,exports.isPascalCase=p.isPascalCase,exports.isSnakeCase=p.isSnakeCase,exports.isString=p.isString,exports.isURL=p.isURL,exports.isUpperCase=p.isUpperCase,exports.longestWord=p.longestWord,exports.longestWordLength=p.longestWordLength,exports.padLeft=p.padLeft,exports.padRight=p.padRight,exports.repeatString=p.repeatString,exports.shortestWord=p.shortestWord,exports.shortestWordLength=p.shortestWordLength,exports.splitString=p.splitString,exports.startsWithUppercase=p.startsWithUppercase,exports.string=p.default,exports.stripSymbols=p.stripSymbols,exports.trim=p.trim,exports.truncate=p.truncate,exports.uniqueChars=p.uniqueChars,exports.isArray=n.isArray,exports.isDefined=n.isDefined,exports.isUndefinedOrNull=n.isUndefinedOrNull;
1
+ var e=require(`@js-utils-kit/core`);Object.keys(e).forEach(function(t){t!==`default`&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})});
@@ -0,0 +1 @@
1
+ export * from "@js-utils-kit/core";
@@ -0,0 +1 @@
1
+ export * from "@js-utils-kit/core";
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ export*from"@js-utils-kit/core";export{};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "js-utils-kit",
3
3
  "displayName": "JS Utils Kit",
4
- "version": "0.5.5",
4
+ "version": "1.0.0",
5
5
  "description": "Essential JavaScript helpers",
6
6
  "license": "MIT",
7
7
  "private": false,
@@ -38,134 +38,21 @@
38
38
  ],
39
39
  "type": "module",
40
40
  "files": [
41
- "dist/**/*"
41
+ "dist"
42
42
  ],
43
- "bin": {
44
- "js-utils-kit": "dist/cli/index.js"
45
- },
46
- "main": "dist/index.cjs",
47
- "module": "dist/index.js",
48
- "types": "dist/index.d.ts",
43
+ "main": "./dist/index.cjs",
44
+ "module": "./dist/index.mjs",
45
+ "types": "./dist/index.d.cts",
49
46
  "exports": {
50
47
  ".": {
51
- "import": "./dist/index.js",
52
48
  "require": "./dist/index.cjs",
53
- "types": "./dist/index.d.ts"
54
- },
55
- "./array": {
56
- "import": "./dist/array/index.js",
57
- "require": "./dist/array/index.cjs",
58
- "types": "./dist/array/index.d.ts"
59
- },
60
- "./char": {
61
- "import": "./dist/char/index.js",
62
- "require": "./dist/char/index.cjs",
63
- "types": "./dist/char/index.d.ts"
64
- },
65
- "./cli": {
66
- "import": "./dist/cli/index.js",
67
- "require": "./dist/cli/index.cjs",
68
- "types": "./dist/cli/index.d.ts"
69
- },
70
- "./env": {
71
- "import": "./dist/env/index.js",
72
- "require": "./dist/env/index.cjs",
73
- "types": "./dist/env/index.d.ts"
74
- },
75
- "./file": {
76
- "import": "./dist/file/index.js",
77
- "require": "./dist/file/index.cjs",
78
- "types": "./dist/file/index.d.ts"
79
- },
80
- "./number": {
81
- "import": "./dist/number/index.js",
82
- "require": "./dist/number/index.cjs",
83
- "types": "./dist/number/index.d.ts"
84
- },
85
- "./object": {
86
- "import": "./dist/object/index.js",
87
- "require": "./dist/object/index.cjs",
88
- "types": "./dist/object/index.d.ts"
89
- },
90
- "./string": {
91
- "import": "./dist/string/index.js",
92
- "require": "./dist/string/index.cjs",
93
- "types": "./dist/string/index.d.ts"
49
+ "import": "./dist/index.mjs"
94
50
  }
95
51
  },
96
- "lint-staged": {
97
- "*.{js,mjs,ts,json,md}": "yarn lint:fix",
98
- "*.{js,mjs,ts,json,md,yml}": "yarn format"
52
+ "dependencies": {
53
+ "@js-utils-kit/core": "1.1.1"
99
54
  },
100
55
  "scripts": {
101
- "test": "jest",
102
- "prebuild": "yarn gen:indexes",
103
- "build": "rollup -c",
104
- "postbuild": "yarn gen:exports && yarn docs",
105
- "release": "release-it",
106
- "watch": "rollup -c --watch",
107
- "lint": "eslint .",
108
- "lint:fix": "npx eslint --fix",
109
- "format": "prettier --write",
110
- "format:check": "prettier --check .",
111
- "prepare": "husky",
112
- "prepare:release": "yarn test && yarn prebuild && yarn build && yarn postbuild",
113
- "docs": "typedoc",
114
- "gen:exports": "node scripts/gen-exports.js",
115
- "gen:indexes": "node scripts/gen-indexes.js"
116
- },
117
- "prettier": {
118
- "semi": true,
119
- "singleQuote": true,
120
- "printWidth": 100,
121
- "trailingComma": "all",
122
- "tabWidth": 2
123
- },
124
- "jest": {
125
- "preset": "ts-jest/presets/default-esm",
126
- "testEnvironment": "node",
127
- "extensionsToTreatAsEsm": [
128
- ".ts"
129
- ],
130
- "moduleNameMapper": {
131
- "^(\\.{1,2}/.*)\\.js": "$1"
132
- }
133
- },
134
- "devDependencies": {
135
- "@eslint/compat": "^1.4.0",
136
- "@eslint/js": "^9.29.0",
137
- "@eslint/json": "^0.13.0",
138
- "@eslint/markdown": "^7.0.0",
139
- "@release-it/conventional-changelog": "^10.0.1",
140
- "@rollup/plugin-commonjs": "^28.0.6",
141
- "@rollup/plugin-json": "^6.1.0",
142
- "@rollup/plugin-node-resolve": "^16.0.1",
143
- "@rollup/plugin-terser": "^0.4.4",
144
- "@rollup/plugin-typescript": "^12.1.3",
145
- "@types/archiver": "^6.0.3",
146
- "@types/jest": "^30.0.0",
147
- "@types/node": "^24.0.4",
148
- "eslint": "^9.29.0",
149
- "globals": "^16.2.0",
150
- "husky": "^9.1.7",
151
- "jest": "^30.0.3",
152
- "jest-environment-node": "^30.0.2",
153
- "lint-staged": "^16.1.2",
154
- "prettier": "^3.6.0",
155
- "release-it": "^19.0.3",
156
- "rollup": "^4.44.0",
157
- "rollup-plugin-delete": "^3.0.1",
158
- "rollup-plugin-dts": "^6.2.1",
159
- "rollup-plugin-peer-deps-external": "^2.2.4",
160
- "ts-jest": "^29.4.0",
161
- "tslib": "^2.8.1",
162
- "typedoc": "^0.28.5",
163
- "typescript": "^5.8.3",
164
- "typescript-eslint": "^8.35.0"
165
- },
166
- "dependencies": {
167
- "archiver": "^7.0.1",
168
- "commander": "^14.0.0",
169
- "ora": "^8.2.0"
56
+ "build": "tsdown"
170
57
  }
171
- }
58
+ }
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var r=require("../validate-BKQ-HFTd.js"),e={isArray:r.isArray};exports.isArray=r.isArray,exports.default=e;
@@ -1,21 +0,0 @@
1
- /**
2
- * Checks if a value is a defined array.
3
- * @param value - The value to check.
4
- * @returns True if the value is a defined array, false otherwise.
5
- * @example
6
- * ```ts
7
- * console.log(isArray([1, 2, 3])); // true
8
- * console.log(isArray([])); // true
9
- * console.log(isArray({})); // false
10
- * console.log(isArray(null)); // false
11
- * console.log(isArray(undefined)); // false
12
- * console.log(isArray("hello")); // false
13
- * ```
14
- */
15
- declare function isArray<T>(value: T): boolean;
16
-
17
- declare const _default: {
18
- isArray: typeof isArray;
19
- };
20
-
21
- export { _default as default, isArray };
@@ -1 +0,0 @@
1
- import{i as a}from"../validate-D9J7otjc.js";var r={isArray:a};export{r as default,a as isArray};
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const r=()=>Array.from({length:26},(r,e)=>String.fromCharCode(97+e)),e=()=>Array.from({length:26},(r,e)=>String.fromCharCode(65+e)),o=()=>Array.from({length:10},(r,e)=>String.fromCharCode(48+e)),t=()=>[...r(),...e(),...o()];var s={lowercase:r,uppercase:e,digits:o,all:t};exports.all=t,exports.default=s,exports.digits=o,exports.lowercase=r,exports.uppercase=e;
@@ -1,41 +0,0 @@
1
- /**
2
- * Generates an array of lowercase ASCII alphabet characters (a–z).
3
- *
4
- * @returns An array containing 'a' to 'z'.
5
- * @example
6
- * lowercase(); // ['a', 'b', ..., 'z']
7
- */
8
- declare const lowercase: () => string[];
9
- /**
10
- * Generates an array of uppercase ASCII alphabet characters (A–Z).
11
- *
12
- * @returns An array containing 'A' to 'Z'.
13
- * @example
14
- * uppercase(); // ['A', 'B', ..., 'Z']
15
- */
16
- declare const uppercase: () => string[];
17
- /**
18
- * Generates an array of ASCII digit characters (0–9).
19
- *
20
- * @returns An array containing '0' to '9'.
21
- * @example
22
- * digits(); // ['0', '1', ..., '9']
23
- */
24
- declare const digits: () => string[];
25
- /**
26
- * Combines lowercase, uppercase, and digit characters into a single array.
27
- *
28
- * @returns An array containing 'a'–'z', 'A'–'Z', and '0'–'9'.
29
- * @example
30
- * all(); // ['a', ..., 'z', 'A', ..., 'Z', '0', ..., '9']
31
- */
32
- declare const all: () => string[];
33
-
34
- declare const _default: {
35
- lowercase: () => string[];
36
- uppercase: () => string[];
37
- digits: () => string[];
38
- all: () => string[];
39
- };
40
-
41
- export { all, _default as default, digits, lowercase, uppercase };
@@ -1 +0,0 @@
1
- const r=()=>Array.from({length:26},(r,a)=>String.fromCharCode(97+a)),a=()=>Array.from({length:26},(r,a)=>String.fromCharCode(65+a)),e=()=>Array.from({length:10},(r,a)=>String.fromCharCode(48+a)),o=()=>[...r(),...a(),...e()];var t={lowercase:r,uppercase:a,digits:e,all:o};export{o as all,t as default,e as digits,r as lowercase,a as uppercase};
package/dist/cli/index.js DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import r from"ora";import{Command as e}from"commander";import o from"fs";import t from"path";import i from"archiver";var n="JS Utils Kit",s="0.5.4",c="Essential JavaScript helpers";const a=new e;a.name(n).description(c).version(s).enablePositionalOptions(),a.command("createArchive").description("Creates a archive from a specified directory").requiredOption("-f, --format <format>","Archive format (zip or tar)").requiredOption("-s, --source <source>","Source directory path").requiredOption("-d, --destination <destination>","Destination archive file").action(async e=>{const n=r("Creating archive...").start();try{await function({format:r,source:e,destination:n,options:s={},log:c=!0,onSuccess:a}){const d=t.resolve(e);if(!o.existsSync(d)||!o.statSync(d).isDirectory())throw new Error(`Source directory "${e}" does not exist or is not a directory.`);const m=o.createWriteStream(n);"zip"===r&&(s={...s,zlib:{level:9}});const p=i(r,s);return new Promise((r,o)=>{m.on("close",()=>{const e=p.pointer();c&&console.log(`${n} created: ${e} total bytes`),a&&a(e),r()}),p.on("error",r=>{o(r)}),p.pipe(m),p.directory(e,!1),p.finalize().catch(r=>o(r instanceof Error?r:new Error(String(r))))})}({format:e.format,source:e.source,destination:e.destination,log:!1,onSuccess:r=>{n.succeed(`Archive created successfully at ${e.destination} (${r} bytes).`)}})}catch(r){n.fail("Failed to create archive: "+(r instanceof Error?r.message:"Unknown error")),process.exit(1)}}),a.parse();
@@ -1 +0,0 @@
1
- "use strict";var e;function n(){switch(process.env.NODE_ENV){case exports.Environment.PROD:return exports.Environment.PROD;case exports.Environment.DEV:return exports.Environment.DEV;case exports.Environment.TEST:return exports.Environment.TEST;default:return exports.Environment.UNKNOWN}}function r(){return process.env.NODE_ENV===exports.Environment.PROD}function o(){return process.env.NODE_ENV===exports.Environment.DEV}function t(){return process.env.NODE_ENV===exports.Environment.TEST}function s(){return"undefined"!=typeof process&&null!==process.versions&&null!==process.versions.node}function i(){return"undefined"!=typeof window&&void 0!==window.document}Object.defineProperty(exports,"__esModule",{value:!0}),exports.Environment=void 0,(e=exports.Environment||(exports.Environment={})).PROD="production",e.DEV="development",e.TEST="test",e.UNKNOWN="unknown";var p={getRunTimeEnvironment:n,isProd:r,isDev:o,isTest:t,isNode:s,isBrowser:i};exports.default=p,exports.getRunTimeEnvironment=n,exports.isBrowser=i,exports.isDev=o,exports.isNode=s,exports.isProd=r,exports.isTest=t;
@@ -1,128 +0,0 @@
1
- /**
2
- * Represents the standard runtime environments used in application development.
3
- *
4
- * This enum is typically used with `process.env.NODE_ENV` to determine
5
- * whether the app is running in development, production, or test mode.
6
- *
7
- * @example
8
- * ```ts
9
- * if (process.env.NODE_ENV === Environment.DEV) {
10
- * console.log('Running in development mode');
11
- * }
12
- * ```
13
- */
14
- declare enum Environment {
15
- /** Production environment (`"production"`) */
16
- PROD = "production",
17
- /** Development environment (`"development"`) */
18
- DEV = "development",
19
- /** Testing environment (`"test"`) */
20
- TEST = "test",
21
- /** Unknown or undefined environment */
22
- UNKNOWN = "unknown"
23
- }
24
- /**
25
- * Returns the current runtime environment as one of the defined `Environment` enum values.
26
- *
27
- * @returns The current environment.
28
- *
29
- * @example
30
- * ```ts
31
- * const env = getRunTimeEnvironment();
32
- * if (env === "development") {
33
- * console.log('Dev mode enabled');
34
- * }
35
- * ```
36
- */
37
- declare function getRunTimeEnvironment(): Environment;
38
- /**
39
- * Checks if the current environment is production.
40
- *
41
- * This is determined by comparing `process.env.NODE_ENV` with `'production'`.
42
- *
43
- * @returns `true` if `NODE_ENV` is set to production.
44
- *
45
- * @example
46
- * ```ts
47
- * if (isProd()) {
48
- * enableAnalytics();
49
- * }
50
- * ```
51
- */
52
- declare function isProd(): boolean;
53
- /**
54
- * Checks if the current environment is development.
55
- *
56
- * This is determined by comparing `process.env.NODE_ENV` with `'development'`.
57
- *
58
- * @returns `true` if `NODE_ENV` is set to development.
59
- *
60
- * @example
61
- * ```ts
62
- * if (isDev()) {
63
- * console.log('Dev mode enabled');
64
- * }
65
- * ```
66
- */
67
- declare function isDev(): boolean;
68
- /**
69
- * Checks if the current environment is testing.
70
- *
71
- * This is determined by comparing `process.env.NODE_ENV` with `'test'`.
72
- *
73
- * @returns `true` if `NODE_ENV` is set to test.
74
- *
75
- * @example
76
- * ```ts
77
- * if (isTest()) {
78
- * mockDatabase();
79
- * }
80
- * ```
81
- */
82
- declare function isTest(): boolean;
83
- /**
84
- * Checks if the current runtime environment is Node.js.
85
- *
86
- * This function is useful to conditionally execute server-side logic.
87
- * It detects the Node.js environment by verifying the presence of the
88
- * global `process` object and its `versions.node` property.
89
- *
90
- * @returns `true` if running in Node.js, otherwise `false`.
91
- *
92
- * @example
93
- * ```ts
94
- * if (isNode()) {
95
- * console.log('Running in Node.js environment');
96
- * }
97
- * ```
98
- *
99
- * @see {@link https://nodejs.org/api/process.html | Node.js process documentation}
100
- */
101
- declare function isNode(): boolean;
102
- /**
103
- * Checks if the current runtime environment is a browser.
104
- *
105
- * This function helps detect whether code is executing in a web browser
106
- * by confirming the existence of the global `window` and `document` objects.
107
- *
108
- * @returns `true` if running in a browser, otherwise `false`.
109
- *
110
- * @example
111
- * ```ts
112
- * if (isBrowser()) {
113
- * console.log('Running in a browser environment');
114
- * }
115
- * ```
116
- */
117
- declare function isBrowser(): boolean;
118
-
119
- declare const _default: {
120
- getRunTimeEnvironment: typeof getRunTimeEnvironment;
121
- isProd: typeof isProd;
122
- isDev: typeof isDev;
123
- isTest: typeof isTest;
124
- isNode: typeof isNode;
125
- isBrowser: typeof isBrowser;
126
- };
127
-
128
- export { Environment, _default as default, getRunTimeEnvironment, isBrowser, isDev, isNode, isProd, isTest };
package/dist/env/index.js DELETED
@@ -1 +0,0 @@
1
- var n;function e(){switch(process.env.NODE_ENV){case n.PROD:return n.PROD;case n.DEV:return n.DEV;case n.TEST:return n.TEST;default:return n.UNKNOWN}}function r(){return process.env.NODE_ENV===n.PROD}function o(){return process.env.NODE_ENV===n.DEV}function s(){return process.env.NODE_ENV===n.TEST}function t(){return"undefined"!=typeof process&&null!==process.versions&&null!==process.versions.node}function u(){return"undefined"!=typeof window&&void 0!==window.document}!function(n){n.PROD="production",n.DEV="development",n.TEST="test",n.UNKNOWN="unknown"}(n||(n={}));var i={getRunTimeEnvironment:e,isProd:r,isDev:o,isTest:s,isNode:t,isBrowser:u};export{n as Environment,i as default,e as getRunTimeEnvironment,u as isBrowser,o as isDev,t as isNode,r as isProd,s as isTest};
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("fs"),r=require("path"),t=require("archiver");function o({format:o,source:i,destination:c,options:s={},log:n=!0,onSuccess:a}){const l=r.resolve(i);if(!e.existsSync(l)||!e.statSync(l).isDirectory())throw new Error(`Source directory "${i}" does not exist or is not a directory.`);const u=e.createWriteStream(c);"zip"===o&&(s={...s,zlib:{level:9}});const p=t(o,s);return new Promise((e,r)=>{u.on("close",()=>{const r=p.pointer();n&&console.log(`${c} created: ${r} total bytes`),a&&a(r),e()}),p.on("error",e=>{r(e)}),p.pipe(u),p.directory(i,!1),p.finalize().catch(e=>r(e instanceof Error?e:new Error(String(e))))})}var i={createArchive:o};exports.createArchive=o,exports.default=i;