@helpers4/node 2.0.0-alpha.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.md ADDED
@@ -0,0 +1,160 @@
1
+ ### GNU LESSER GENERAL PUBLIC LICENSE
2
+
3
+ Version 3, 29 June 2007
4
+
5
+ Copyright (C) 2007 Free Software Foundation, Inc.
6
+ <https://fsf.org/\>
7
+
8
+ Everyone is permitted to copy and distribute verbatim copies of this
9
+ license document, but changing it is not allowed.
10
+
11
+ This version of the GNU Lesser General Public License incorporates the
12
+ terms and conditions of version 3 of the GNU General Public License,
13
+ supplemented by the additional permissions listed below.
14
+
15
+ #### 0. Additional Definitions.
16
+
17
+ As used herein, "this License" refers to version 3 of the GNU Lesser
18
+ General Public License, and the "GNU GPL" refers to version 3 of the
19
+ GNU General Public License.
20
+
21
+ "The Library" refers to a covered work governed by this License, other
22
+ than an Application or a Combined Work as defined below.
23
+
24
+ An "Application" is any work that makes use of an interface provided by
25
+ the Library, but which is not otherwise based on the Library. Defining a
26
+ subclass of a class defined by the Library is deemed a mode of using an
27
+ interface provided by the Library.
28
+
29
+ A "Combined Work" is a work produced by combining or linking an
30
+ Application with the Library. The particular version of the Library with
31
+ which the Combined Work was made is also called the "Linked Version".
32
+
33
+ The "Minimal Corresponding Source" for a Combined Work means the
34
+ Corresponding Source for the Combined Work, excluding any source code
35
+ for portions of the Combined Work that, considered in isolation, are
36
+ based on the Application, and not on the Linked Version.
37
+
38
+ The "Corresponding Application Code" for a Combined Work means the
39
+ object code and/or source code for the Application, including any data
40
+ and utility programs needed for reproducing the Combined Work from the
41
+ Application, but excluding the System Libraries of the Combined Work.
42
+
43
+ #### 1. Exception to Section 3 of the GNU GPL.
44
+
45
+ You may convey a covered work under sections 3 and 4 of this License
46
+ without being bound by section 3 of the GNU GPL.
47
+
48
+ #### 2. Conveying Modified Versions.
49
+
50
+ If you modify a copy of the Library, and, in your modifications, a
51
+ facility refers to a function or data to be supplied by an Application
52
+ that uses the facility (other than as an argument passed when the
53
+ facility is invoked), then you may convey a copy of the modified version:
54
+
55
+ - **a)** under this License, provided that you make a good faith effort
56
+ to ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs whatever
58
+ part of its purpose remains meaningful, or
59
+
60
+ - **b)** under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ #### 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from a
66
+ header file that is part of the Library. You may convey such object code
67
+ under terms of your choice, provided that, if the incorporated material
68
+ is not limited to numerical parameters, data structure layouts and
69
+ accessors, or small macros, inline functions and templates (ten or fewer
70
+ lines in length), you do both of the following:
71
+
72
+ - **a)** Give prominent notice with each copy of the object code that
73
+ the Library is used in it and that the Library and its use are covered
74
+ by this License.
75
+
76
+ - **b)** Accompany the object code with a copy of the GNU GPL and this
77
+ license document.
78
+
79
+ #### 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that, taken
82
+ together, effectively do not restrict modification of the portions of
83
+ the Library contained in the Combined Work and reverse engineering for
84
+ debugging such modifications, if you also do each of the following:
85
+
86
+ - **a)** Give prominent notice with each copy of the Combined Work that
87
+ the Library is used in it and that the Library and its use are covered
88
+ by this License.
89
+
90
+ - **b)** Accompany the Combined Work with a copy of the GNU GPL and
91
+ this license document.
92
+
93
+ - **c)** For a Combined Work that displays copyright notices during
94
+ execution, include the copyright notice for the Library among these
95
+ notices, as well as a reference directing the user to the copies of
96
+ the GNU GPL and this license document.
97
+
98
+ - **d)** Do one of the following:
99
+
100
+ - **0)** Convey the Minimal Corresponding Source under the terms of
101
+ this License, and the Corresponding Application Code in a form
102
+ suitable for, and under terms that permit, the user to recombine or
103
+ relink the Application with a modified version of the Linked Version
104
+ to produce a modified Combined Work, in the manner specified by
105
+ section 6 of the GNU GPL for conveying Corresponding Source.
106
+
107
+ - **1)** Use a suitable shared library mechanism for linking with the
108
+ Library. A suitable mechanism is one that (a) uses at run time a copy
109
+ of the Library already present on the user's computer system, and (b)
110
+ will operate properly with a modified version of the Library that is
111
+ interface-compatible with the Linked Version.
112
+
113
+ - **e)** Provide Installation Information, but only if you would
114
+ otherwise be required to provide such information under section 6 of
115
+ the GNU GPL, and only to the extent that such information is necessary
116
+ to install and execute a modified version of the Combined Work produced
117
+ by recombining or relinking the Application with a modified version of
118
+ the Linked Version. (If you use option 4d0, the Installation
119
+ Information must accompany the Minimal Corresponding Source and
120
+ Corresponding Application Code. If you use option 4d1, you must
121
+ provide the Installation Information in the manner specified by
122
+ section 6 of the GNU GPL for conveying Corresponding Source.)
123
+
124
+ #### 5. Combined Libraries.
125
+
126
+ You may place library facilities that are a work based on the Library
127
+ side by side in a single library together with other library facilities
128
+ that are not Applications and are not covered by this License, and
129
+ convey such a combined library under terms of your choice, if you do
130
+ both of the following:
131
+
132
+ - **a)** Accompany the combined library with a copy of the same work
133
+ based on the Library, uncombined with any other library facilities,
134
+ conveyed under the terms of this License.
135
+
136
+ - **b)** Give prominent notice with the combined library that part of
137
+ it is a work based on the Library, and explaining where to find the
138
+ accompanying uncombined form of the same work.
139
+
140
+ #### 6. Revised Versions of the GNU Lesser General Public License.
141
+
142
+ The Free Software Foundation may publish revised and/or new versions of
143
+ the GNU Lesser General Public License from time to time. Such new
144
+ versions will be similar in spirit to the present version, but may
145
+ differ in detail to address new problems or concerns.
146
+
147
+ Each version is given a distinguishing version number. If the Library as
148
+ you received it specifies that a certain numbered version of the GNU
149
+ Lesser General Public License "or any later version" applies to it, you
150
+ have the option of following the terms and conditions either of that
151
+ published version or of any later version published by the Free Software
152
+ Foundation. If the Library as you received it does not specify a version
153
+ number of the GNU Lesser General Public License, you may choose any
154
+ version of the GNU Lesser General Public License ever published by the
155
+ Free Software Foundation.
156
+
157
+ If the Library as you received it specifies that a proxy can decide
158
+ whether future versions of the GNU Lesser General Public License shall
159
+ apply, that proxy's public statement of acceptance of any version is
160
+ permanent authorization for you to choose that version for the Library.
package/README.md ADDED
@@ -0,0 +1,73 @@
1
+ # @helpers4
2
+
3
+ The `@helpers4` are a collection of helper functions for use in any project, whatever the framework.
4
+ Every helper is a standalone module and supports tree-shaking, so you can use only the helpers you need without embedding the whole library.
5
+
6
+ ## @helpers4/node
7
+
8
+ A set of helpers for working with URLs.
9
+
10
+ ## Documentation
11
+
12
+ [https://helpers4.dev/typescript/categories/node/](https://helpers4.dev/typescript/categories/node/)
13
+
14
+ <!-- AUTOMATIC-METHODS -->
15
+ - isBuffer
16
+ <!-- /AUTOMATIC-METHODS -->
17
+
18
+ ## See
19
+
20
+ <!-- AUTOMATIC-SIBLINGS -->
21
+ - [array](../array)
22
+ - [ci](../ci)
23
+ - [commit](../commit)
24
+ - [date](../date)
25
+ - [function](../function)
26
+ - [id](../id)
27
+ - [markdown](../markdown)
28
+ - [number](../number)
29
+ - [object](../object)
30
+ - [observable](../observable)
31
+ - [promise](../promise)
32
+ - [string](../string)
33
+ - [type](../type)
34
+ - [url](../url)
35
+ - [version](../version)
36
+ <!-- /AUTOMATIC-SIBLINGS -->
37
+
38
+ ## All Available Packages
39
+
40
+ <!-- AUTOMATIC-CATEGORIES-TABLE -->
41
+ | Name | Package | Source Code | Description |
42
+ |------|---------|-------------|-------------|
43
+ | array | [@helpers4/array](https://www.npmjs.com/package/@helpers4/array) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/array) | Array manipulation utilities |
44
+ | ci | [@helpers4/ci](https://www.npmjs.com/package/@helpers4/ci) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/ci) | CI/CD workflow status utilities |
45
+ | commit | [@helpers4/commit](https://www.npmjs.com/package/@helpers4/commit) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/commit) | Conventional Commits parsing and analysis |
46
+ | date | [@helpers4/date](https://www.npmjs.com/package/@helpers4/date) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/date) | Date and time utility functions |
47
+ | function | [@helpers4/function](https://www.npmjs.com/package/@helpers4/function) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/function) | Function utilities and type guards |
48
+ | id | [@helpers4/id](https://www.npmjs.com/package/@helpers4/id) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/id) | Unique identifier generation utilities |
49
+ | markdown | [@helpers4/markdown](https://www.npmjs.com/package/@helpers4/markdown) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/markdown) | Markdown formatting and escaping utilities |
50
+ | node | [@helpers4/node](https://www.npmjs.com/package/@helpers4/node) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/node) | Node.js-specific utilities |
51
+ | number | [@helpers4/number](https://www.npmjs.com/package/@helpers4/number) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/number) | Number utility functions and validation |
52
+ | object | [@helpers4/object](https://www.npmjs.com/package/@helpers4/object) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/object) | Object manipulation utilities |
53
+ | observable | [@helpers4/observable](https://www.npmjs.com/package/@helpers4/observable) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/observable) | Observable utilities and combinators |
54
+ | promise | [@helpers4/promise](https://www.npmjs.com/package/@helpers4/promise) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/promise) | Promise utilities and error handling |
55
+ | string | [@helpers4/string](https://www.npmjs.com/package/@helpers4/string) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/string) | String manipulation and formatting utilities |
56
+ | type | [@helpers4/type](https://www.npmjs.com/package/@helpers4/type) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/type) | Type checking and validation utilities |
57
+ | url | [@helpers4/url](https://www.npmjs.com/package/@helpers4/url) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/url) | URL parsing and manipulation utilities |
58
+ | version | [@helpers4/version](https://www.npmjs.com/package/@helpers4/version) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/version) | Version string manipulation utilities |
59
+ <!-- /AUTOMATIC-CATEGORIES-TABLE -->
60
+
61
+ ## Contributors
62
+
63
+ <table>
64
+ <tr>
65
+ <td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0">
66
+ <a href=https://github.com/baxyz>
67
+ <img src=https://avatars.githubusercontent.com/u/7852177?v=4 width="100;" alt=baxyz/>
68
+ <br />
69
+ <sub style="font-size:14px"><b>baxyz</b></sub>
70
+ </a>
71
+ </td>
72
+ </tr>
73
+ </table>
package/lib/index.d.ts ADDED
@@ -0,0 +1,26 @@
1
+ /**
2
+ * This file is part of helpers4.
3
+ * Copyright (C) 2025 baxyz
4
+ * SPDX-License-Identifier: LGPL-3.0-or-later
5
+ */
6
+ /**
7
+ * Checks if a value is a Node.js Buffer instance.
8
+ *
9
+ * `Buffer` extends `Uint8Array` and is specific to Node.js, Bun, and Deno.
10
+ * In browser-only environments where `Buffer` is not defined, this function
11
+ * always returns `false`.
12
+ *
13
+ * Useful for filtering or type-narrowing in a functional pipeline:
14
+ * `values.filter(isBuffer)`
15
+ *
16
+ * @param value - The value to check
17
+ * @returns True if value is a Buffer
18
+ * @example
19
+ * isBuffer(Buffer.from('hello')) // => true
20
+ * isBuffer(new Uint8Array(8)) // => false
21
+ * isBuffer('hello') // => false
22
+ * @since 2.0.0
23
+ */
24
+ declare function isBuffer(value: unknown): value is Buffer;
25
+
26
+ export { isBuffer };
package/lib/index.js ADDED
@@ -0,0 +1,31 @@
1
+ //#region helpers/node/isBuffer.ts
2
+ /**
3
+ * This file is part of helpers4.
4
+ * Copyright (C) 2025 baxyz
5
+ * SPDX-License-Identifier: LGPL-3.0-or-later
6
+ */
7
+ /**
8
+ * Checks if a value is a Node.js Buffer instance.
9
+ *
10
+ * `Buffer` extends `Uint8Array` and is specific to Node.js, Bun, and Deno.
11
+ * In browser-only environments where `Buffer` is not defined, this function
12
+ * always returns `false`.
13
+ *
14
+ * Useful for filtering or type-narrowing in a functional pipeline:
15
+ * `values.filter(isBuffer)`
16
+ *
17
+ * @param value - The value to check
18
+ * @returns True if value is a Buffer
19
+ * @example
20
+ * isBuffer(Buffer.from('hello')) // => true
21
+ * isBuffer(new Uint8Array(8)) // => false
22
+ * isBuffer('hello') // => false
23
+ * @since 2.0.0
24
+ */
25
+ function isBuffer(value) {
26
+ return typeof Buffer !== "undefined" && value instanceof Buffer;
27
+ }
28
+ //#endregion
29
+ export { isBuffer };
30
+
31
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../helpers/node/isBuffer.ts"],"sourcesContent":["/**\n * This file is part of helpers4.\n * Copyright (C) 2025 baxyz\n * SPDX-License-Identifier: LGPL-3.0-or-later\n */\n\n/**\n * Checks if a value is a Node.js Buffer instance.\n *\n * `Buffer` extends `Uint8Array` and is specific to Node.js, Bun, and Deno.\n * In browser-only environments where `Buffer` is not defined, this function\n * always returns `false`.\n *\n * Useful for filtering or type-narrowing in a functional pipeline:\n * `values.filter(isBuffer)`\n *\n * @param value - The value to check\n * @returns True if value is a Buffer\n * @example\n * isBuffer(Buffer.from('hello')) // => true\n * isBuffer(new Uint8Array(8)) // => false\n * isBuffer('hello') // => false\n * @since 2.0.0\n */\nexport function isBuffer(value: unknown): value is Buffer {\n return typeof Buffer !== 'undefined' && value instanceof Buffer;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAwBA,SAAgB,SAAS,OAAiC;CACxD,OAAO,OAAO,WAAW,eAAe,iBAAiB;AAC3D"}
package/llms.txt ADDED
@@ -0,0 +1,76 @@
1
+ # @helpers4/node
2
+
3
+ > Tree-shakable TypeScript utility functions for the `node` domain.
4
+ > Package: `@helpers4/node` — Version: 2.0.0
5
+ > License: LGPL-3.0-or-later
6
+
7
+ ## Installation
8
+
9
+ ```sh
10
+ npm install @helpers4/node
11
+ # or
12
+ pnpm add @helpers4/node
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```typescript
18
+ import { isBuffer } from '@helpers4/node';
19
+ ```
20
+
21
+ ## Functions
22
+
23
+ | Function | Description |
24
+ |---|---|
25
+ | `isBuffer` | Checks if a value is a Node.js Buffer instance. `Buffer` extends `Uint8Array` and is specific to No |
26
+
27
+ ---
28
+
29
+ ## API Reference
30
+
31
+ ### `isBuffer`
32
+
33
+ Checks if a value is a Node.js Buffer instance.
34
+
35
+ `Buffer` extends `Uint8Array` and is specific to Node.js, Bun, and Deno.
36
+ In browser-only environments where `Buffer` is not defined, this function
37
+ always returns `false`.
38
+
39
+ Useful for filtering or type-narrowing in a functional pipeline:
40
+ `values.filter(isBuffer)`
41
+
42
+ ```typescript
43
+ import { isBuffer } from '@helpers4/node';
44
+
45
+ isBuffer(value: unknown): value is Buffer<ArrayBufferLike>
46
+ ```
47
+
48
+ **Parameters:**
49
+
50
+ - `value: unknown` — The value to check
51
+
52
+ **Returns:** `value is Buffer<ArrayBufferLike>` — True if value is a Buffer
53
+
54
+ **Examples:**
55
+
56
+ *Detect a Node.js Buffer*
57
+
58
+ Returns true only for Buffer instances. Uint8Array is not a Buffer.
59
+
60
+ ```typescript
61
+ isBuffer(Buffer.from('hello')) // => true
62
+ isBuffer(new Uint8Array(8)) // => false
63
+ isBuffer('hello') // => false
64
+ ```
65
+
66
+ *Filter Buffers from a mixed array*
67
+
68
+ Use as a predicate in .filter() to extract Buffer values.
69
+
70
+ ```typescript
71
+ const values = [Buffer.from('a'), 'text', Buffer.alloc(4), 42];
72
+ values.filter(isBuffer)
73
+ // => [Buffer, Buffer]
74
+ ```
75
+
76
+ ---
package/meta/api.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "category": "node",
3
+ "version": "2.0.0",
4
+ "functions": [
5
+ {
6
+ "name": "isBuffer",
7
+ "kind": "function",
8
+ "description": "Checks if a value is a Node.js Buffer instance.\n\n`Buffer` extends `Uint8Array` and is specific to Node.js, Bun, and Deno.\nIn browser-only environments where `Buffer` is not defined, this function\nalways returns `false`.\n\nUseful for filtering or type-narrowing in a functional pipeline:\n`values.filter(isBuffer)`",
9
+ "since": "2.0.0",
10
+ "signatures": [
11
+ {
12
+ "signature": "isBuffer(value: unknown): value is Buffer<ArrayBufferLike>",
13
+ "description": "Checks if a value is a Node.js Buffer instance.\n\n`Buffer` extends `Uint8Array` and is specific to Node.js, Bun, and Deno.\nIn browser-only environments where `Buffer` is not defined, this function\nalways returns `false`.\n\nUseful for filtering or type-narrowing in a functional pipeline:\n`values.filter(isBuffer)`",
14
+ "params": [
15
+ {
16
+ "name": "value",
17
+ "type": "unknown",
18
+ "description": "The value to check"
19
+ }
20
+ ],
21
+ "returns": {
22
+ "type": "value is Buffer<ArrayBufferLike>",
23
+ "description": "True if value is a Buffer"
24
+ }
25
+ }
26
+ ],
27
+ "examples": [
28
+ {
29
+ "title": "Detect a Node.js Buffer",
30
+ "description": "Returns true only for Buffer instances. Uint8Array is not a Buffer.",
31
+ "code": "isBuffer(Buffer.from('hello')) // => true\nisBuffer(new Uint8Array(8)) // => false\nisBuffer('hello') // => false"
32
+ },
33
+ {
34
+ "title": "Filter Buffers from a mixed array",
35
+ "description": "Use as a predicate in .filter() to extract Buffer values.",
36
+ "code": "const values = [Buffer.from('a'), 'text', Buffer.alloc(4), 42];\nvalues.filter(isBuffer)\n// => [Buffer, Buffer]"
37
+ }
38
+ ],
39
+ "sourceFile": "isBuffer.ts"
40
+ }
41
+ ]
42
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "category": "node",
3
+ "label": "Node",
4
+ "smallDescription": "Node.js-specific utilities",
5
+ "description": "Utilities specific to Node.js, Bun, and Deno runtimes (Buffer, streams, etc.)",
6
+ "peerDependencies": {
7
+ "@types/node": ">=22"
8
+ }
9
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "category": "node",
3
+ "functions": [
4
+ {
5
+ "name": "isBuffer",
6
+ "examples": [
7
+ {
8
+ "title": "Detect a Node.js Buffer",
9
+ "description": "Returns true only for Buffer instances. Uint8Array is not a Buffer.",
10
+ "code": "isBuffer(Buffer.from('hello')) // => true\nisBuffer(new Uint8Array(8)) // => false\nisBuffer('hello') // => false"
11
+ },
12
+ {
13
+ "title": "Filter Buffers from a mixed array",
14
+ "description": "Use as a predicate in .filter() to extract Buffer values.",
15
+ "code": "const values = [Buffer.from('a'), 'text', Buffer.alloc(4), 42];\nvalues.filter(isBuffer)\n// => [Buffer, Buffer]"
16
+ }
17
+ ]
18
+ }
19
+ ]
20
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "category": "node",
3
+ "dependencies": []
4
+ }
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@helpers4/node",
3
+ "version": "2.0.0-alpha.0",
4
+ "description": "A set of helpers in TS/JS, compatible with tree-shaking, for node.",
5
+ "author": "baxyz <baxy@etik.com>",
6
+ "license": "LGPL-3.0",
7
+ "homepage": "https://helpers4.dev/typescript/categories/node/",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/helpers4/typescript.git"
11
+ },
12
+ "type": "module",
13
+ "sideEffects": false,
14
+ "main": "lib/index.js",
15
+ "types": "lib/index.d.ts",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./lib/index.d.ts",
19
+ "import": "./lib/index.js"
20
+ },
21
+ "./meta/api.json": "./meta/api.json",
22
+ "./meta/examples.json": "./meta/examples.json",
23
+ "./meta/licenses.json": "./meta/licenses.json",
24
+ "./llms.txt": "./llms.txt",
25
+ "./package.json": "./package.json"
26
+ },
27
+ "keywords": [
28
+ "helpers",
29
+ "node",
30
+ "isBuffer"
31
+ ],
32
+ "files": [
33
+ "lib/index.js",
34
+ "lib/index.d.ts",
35
+ "lib/index.js.map",
36
+ "meta/",
37
+ "llms.txt",
38
+ "LICENSE.md",
39
+ "package.json",
40
+ "README.md"
41
+ ],
42
+ "engines": {
43
+ "node": ">=18.0.0"
44
+ },
45
+ "peerDependencies": {
46
+ "@types/node": "^25.9.1"
47
+ }
48
+ }