@emohk/utils 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/LICENSE ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright 2026 Ronald Mak
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # @emohk/utils
2
+
3
+ The package contains a collection of utility functions that can be used in various projects.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @emohk/utils
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ Go to the [API documentation](https://github.com/emocreation/js-utils/blob/main/docs/API.md) for more information.
14
+
15
+ ## Development
16
+
17
+ To install dependencies:
18
+
19
+ ```bash
20
+ bun install
21
+ ```
22
+
23
+ To build:
24
+
25
+ ```bash
26
+ bun run build
27
+ ```
28
+
29
+ To generate typescript declarations:
30
+
31
+ ```bash
32
+ bun run declare
33
+ ```
34
+
35
+ To generate documentation:
36
+
37
+ ```bash
38
+ bun run docs
39
+ ```
40
+
41
+ This project was created using `bun init` in bun v1.3.6. [Bun](https://bun.com) is a fast all-in-one JavaScript runtime.
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ var{defineProperty:E,getOwnPropertyNames:G,getOwnPropertyDescriptor:H}=Object,I=Object.prototype.hasOwnProperty;var F=new WeakMap,J=(q)=>{var B=F.get(q),D;if(B)return B;if(B=E({},"__esModule",{value:!0}),q&&typeof q==="object"||typeof q==="function")G(q).map((C)=>!I.call(B,C)&&E(B,C,{get:()=>q[C],enumerable:!(D=H(q,C))||D.enumerable}));return F.set(q,B),B};var K=(q,B)=>{for(var D in B)E(q,D,{get:B[D],enumerable:!0,configurable:!0,set:(C)=>B[D]=()=>C})};var P={};K(P,{hasValues:()=>N,chunk:()=>O,checkStringPresent:()=>L,checkObject:()=>M});module.exports=J(P);var L=(q)=>typeof q==="string"&&q.trim().length>0,M=(q)=>typeof q==="object"&&q!==null&&!Array.isArray(q)&&q.constructor===Object,N=(q)=>Array.isArray(q)&&q.length>0,O=(q,B)=>Array.from({length:Math.ceil(q.length/B)},(D,C)=>q.slice(C*B,C*B+B));
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Checks if a value is a non-empty string after trimming whitespace.
3
+ * @param value - The value to check
4
+ * @returns True if the value is a string with content after trimming, false otherwise
5
+ * @example
6
+ * ```ts
7
+ * checkStringPresent('hello world') // true
8
+ * checkStringPresent('') // false
9
+ * checkStringPresent(' ') // false
10
+ * checkStringPresent(null) // false
11
+ * checkStringPresent(undefined) // false
12
+ * ```
13
+ */
14
+ export declare const checkStringPresent: (value: any) => value is string;
15
+ /**
16
+ * Checks if a value is a plain object (not null, not array).
17
+ * @param object - The value to check
18
+ * @returns True if the value is a plain object, false otherwise
19
+ * @example
20
+ * ```ts
21
+ * checkObject({}) // true
22
+ * checkObject([]) // false
23
+ * checkObject(null) // false
24
+ * checkObject(undefined) // false
25
+ * ```
26
+ */
27
+ export declare const checkObject: (object: any) => object is Record<string, any>;
28
+ /**
29
+ * Checks if a value is a non-empty array.
30
+ * @param raw - The value to check
31
+ * @returns True if the value is an array with at least one element, false otherwise
32
+ * @example
33
+ * ```ts
34
+ * hasValues([1, 2, 3]) // true
35
+ * hasValues([]) // false
36
+ * hasValues({}) // false
37
+ * hasValues('') // false
38
+ * hasValues(' ') // false
39
+ * hasValues(0) // false
40
+ * hasValues(null) // false
41
+ * hasValues(undefined) // false
42
+ * ```
43
+ */
44
+ export declare const hasValues: (raw: any) => raw is any[];
45
+ /**
46
+ * Splits an array into smaller chunks of a specified size.
47
+ * @param arr - The array to split into chunks
48
+ * @param size - The size of each chunk
49
+ * @returns An array of arrays, where each sub-array contains at most 'size' elements from the original array
50
+ * @example
51
+ * ```ts
52
+ * chunk([1, 2, 3, 4, 5, 6], 2) // [[1, 2], [3, 4], [5, 6]]
53
+ * chunk([1, 2, 3, 4, 5, 6], 3) // [[1, 2, 3], [4, 5, 6]]
54
+ * chunk([1, 2, 3, 4, 5, 6], 4) // [[1, 2, 3, 4], [5, 6]]
55
+ * ```
56
+ */
57
+ export declare const chunk: (arr: any[], size: number) => any[][];
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ var E=(q)=>typeof q==="string"&&q.trim().length>0,F=(q)=>typeof q==="object"&&q!==null&&!Array.isArray(q)&&q.constructor===Object,G=(q)=>Array.isArray(q)&&q.length>0,H=(q,B)=>Array.from({length:Math.ceil(q.length/B)},(D,C)=>q.slice(C*B,C*B+B));export{G as hasValues,H as chunk,E as checkStringPresent,F as checkObject};
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@emohk/utils",
3
+ "version": "1.0.0",
4
+ "description": "A collection of utility functions for various projects.",
5
+ "type": "module",
6
+ "module": "./dist/index.mjs",
7
+ "main": "./dist/index.cjs",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.mjs",
13
+ "require": "./dist/index.cjs"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist",
18
+ "README.md",
19
+ "LICENSE"
20
+ ],
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "https://github.com/emocreation/js-utils.git"
24
+ },
25
+ "devDependencies": {
26
+ "@types/bun": "latest",
27
+ "typedoc": "^0.28.16",
28
+ "typedoc-plugin-markdown": "^4.9.0"
29
+ },
30
+ "peerDependencies": {
31
+ "typescript": "^5.9.3"
32
+ },
33
+ "scripts": {
34
+ "build": "bun run build.ts",
35
+ "declare": "tsc index.ts --declaration --emitDeclarationOnly --outDir dist",
36
+ "docs": "typedoc",
37
+ "prepublishOnly": "bun run build && bun run declare"
38
+ },
39
+ "author": "Ronald Mak",
40
+ "license": "MIT"
41
+ }