falkordb 6.5.0 → 6.5.1

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.
@@ -7,8 +7,20 @@ function transformArguments(name, script, replace = false) {
7
7
  args.push('REPLACE');
8
8
  }
9
9
  args.push(name);
10
- // If script is a function, convert it to string
11
- const scriptStr = typeof script === 'function' ? script.toString() : script;
10
+ // If script is a function, convert it to string and add falkor.register() call
11
+ let scriptStr;
12
+ if (typeof script === 'function') {
13
+ const functionStr = script.toString();
14
+ const functionName = script.name;
15
+ if (!functionName) {
16
+ throw new Error('Function must have a name to be registered as a UDF');
17
+ }
18
+ // Add the function definition and register call
19
+ scriptStr = `${functionStr}\nfalkor.register("${functionName}", ${functionName});`;
20
+ }
21
+ else {
22
+ scriptStr = script;
23
+ }
12
24
  args.push(scriptStr);
13
25
  return args;
14
26
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "falkordb",
3
- "version": "6.5.0",
3
+ "version": "6.5.1",
4
4
  "description": "A FalkorDB javascript library",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",