@exploreimpact/n8n-utils 0.1.2
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 +21 -0
- package/README.md +37 -0
- package/package.json +29 -0
- package/src/index.js +3 -0
- package/src/utils/parseBool.js +14 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 n8n-utils contributors
|
|
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,37 @@
|
|
|
1
|
+
# n8n-utils
|
|
2
|
+
A JavaScript library to provide common utilities to n8n for usage in "code" nodes.
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install --save-dev @exploreimpact/n8n-utils
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Or globally:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install -g @exploreimpact/n8n-utils
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
An example of how to use the utils:
|
|
20
|
+
|
|
21
|
+
```javascript
|
|
22
|
+
const {
|
|
23
|
+
parseBool,
|
|
24
|
+
} = require('@exploreimpact/n8n-utils');
|
|
25
|
+
|
|
26
|
+
return items.map(item => ({
|
|
27
|
+
json: {
|
|
28
|
+
...item.json,
|
|
29
|
+
isWonderful: parseBool(item.json.wonderful),
|
|
30
|
+
},
|
|
31
|
+
}));
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Release flow
|
|
35
|
+
|
|
36
|
+
To release a new package version, bump the version inside the package.json.
|
|
37
|
+
A GitHub workflow will automatically create a GitHub release and publish to npm.
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@exploreimpact/n8n-utils",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "A JavaScript library to provide common utilities to n8n for usage in \"code\" nodes.",
|
|
5
|
+
"main": "src/index.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"src",
|
|
8
|
+
"README.md",
|
|
9
|
+
"LICENSE"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"n8n",
|
|
14
|
+
"utils",
|
|
15
|
+
"javascript",
|
|
16
|
+
"commonjs"
|
|
17
|
+
],
|
|
18
|
+
"author": {
|
|
19
|
+
"name": "Claudio De Facci",
|
|
20
|
+
"email": "claudio@exploreimpact.de",
|
|
21
|
+
"url": "https://exploreimpact.de"
|
|
22
|
+
},
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"dependencies": {},
|
|
25
|
+
"devDependencies": {},
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=24"
|
|
28
|
+
}
|
|
29
|
+
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
function parseBool(value, fallback = false) {
|
|
2
|
+
if (typeof value === 'boolean') return value;
|
|
3
|
+
if (typeof value === 'number') return value === 1;
|
|
4
|
+
if (typeof value === 'string') {
|
|
5
|
+
const normalized = value.trim().toLowerCase();
|
|
6
|
+
if (!normalized) return fallback;
|
|
7
|
+
return ['true', '1', 'yes', 'ja', 'on'].includes(normalized);
|
|
8
|
+
}
|
|
9
|
+
return fallback;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
module.exports = {
|
|
13
|
+
parseBool,
|
|
14
|
+
};
|