@faasjs/func 5.0.1 → 6.0.0-beta.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.
package/dist/index.cjs CHANGED
@@ -31,6 +31,12 @@ var RunHandler = class {
31
31
  }
32
32
  };
33
33
 
34
+ // src/utils.ts
35
+ function nameFunc(name, handler) {
36
+ Object.defineProperty(handler, "name", { value: name });
37
+ return handler;
38
+ }
39
+
34
40
  // src/index.ts
35
41
  var Func = class {
36
42
  plugins;
@@ -154,7 +160,7 @@ var Func = class {
154
160
  event,
155
161
  context,
156
162
  callback,
157
- response: void 0,
163
+ response: undefined,
158
164
  handler: this.handler,
159
165
  logger: logger$1,
160
166
  config: this.config
@@ -195,10 +201,6 @@ function useFunc(handler) {
195
201
  plugins = [];
196
202
  return func;
197
203
  }
198
- function nameFunc(name, handler) {
199
- Object.defineProperty(handler, "name", { value: name });
200
- return handler;
201
- }
202
204
 
203
205
  exports.Func = Func;
204
206
  exports.nameFunc = nameFunc;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,45 @@
1
1
  import { Logger } from '@faasjs/logger';
2
2
 
3
+ /**
4
+ * Assigns a name to a given function handler, which will be displayed in logs and error messages.
5
+ *
6
+ * @template T - The type of the function handler.
7
+ * @param {string} name - The name to assign to the function handler.
8
+ * @param {T} handler - The function handler to which the name will be assigned.
9
+ * @returns {T} - The original function handler with the assigned name.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * import { nameFunc } from '@faasjs/func'
14
+ *
15
+ * const handler = nameFunc('myHandler', () => {
16
+ * return 'Hello World'
17
+ * })
18
+ *
19
+ * console.log(handler.name) // => 'myHandler'
20
+ * ```
21
+ */
22
+ declare function nameFunc<T extends (...args: any[]) => any>(name: string, handler: T): T;
23
+
24
+ /**
25
+ * FaasJS's function module.
26
+ *
27
+ * [![License: MIT](https://img.shields.io/npm/l/@faasjs/func.svg)](https://github.com/faasjs/faasjs/blob/main/packages/func/LICENSE)
28
+ * [![NPM Version](https://img.shields.io/npm/v/@faasjs/func.svg)](https://www.npmjs.com/package/@faasjs/func)
29
+ *
30
+ * ## Install
31
+ *
32
+ * ```sh
33
+ * npm install @faasjs/func
34
+ * ```
35
+ *
36
+ * ## Usage
37
+ *
38
+ * @see {@link useFunc}
39
+ *
40
+ * @packageDocumentation
41
+ */
42
+
3
43
  type Handler<TEvent = any, TContext = any, TResult = any> = (data: InvokeData<TEvent, TContext>) => Promise<TResult>;
4
44
  type Next = () => Promise<void>;
5
45
  type ExportedHandler<TEvent = any, TContext = any, TResult = any> = (event?: TEvent, context?: TContext, callback?: (...args: any) => any) => Promise<TResult>;
@@ -139,25 +179,5 @@ declare function usePlugin<T extends Plugin>(plugin: T & {
139
179
  * ```
140
180
  */
141
181
  declare function useFunc<TEvent = any, TContext = any, TResult = any>(handler: () => Handler<TEvent, TContext, TResult>): Func<TEvent, TContext, TResult>;
142
- /**
143
- * Assigns a name to a given function handler, which will be displayed in logs and error messages.
144
- *
145
- * @template T - The type of the function handler.
146
- * @param {string} name - The name to assign to the function handler.
147
- * @param {T} handler - The function handler to which the name will be assigned.
148
- * @returns {T} - The original function handler with the assigned name.
149
- *
150
- * @example
151
- * ```ts
152
- * import { nameFunc } from '@faasjs/func'
153
- *
154
- * const handler = nameFunc('myHandler', () => {
155
- * return 'Hello World'
156
- * })
157
- *
158
- * console.log(handler.name) // => 'myHandler'
159
- * ```
160
- */
161
- declare function nameFunc<T extends (...args: any[]) => any>(name: string, handler: T): T;
162
182
 
163
183
  export { type Config, type ExportedHandler, Func, type FuncConfig, type FuncEventType, type FuncReturnType, type Handler, type InvokeData, type LifeCycleKey, type MountData, type Next, type Plugin, type UseifyPlugin, nameFunc, useFunc, usePlugin };
package/dist/index.mjs CHANGED
@@ -29,6 +29,12 @@ var RunHandler = class {
29
29
  }
30
30
  };
31
31
 
32
+ // src/utils.ts
33
+ function nameFunc(name, handler) {
34
+ Object.defineProperty(handler, "name", { value: name });
35
+ return handler;
36
+ }
37
+
32
38
  // src/index.ts
33
39
  var Func = class {
34
40
  plugins;
@@ -152,7 +158,7 @@ var Func = class {
152
158
  event,
153
159
  context,
154
160
  callback,
155
- response: void 0,
161
+ response: undefined,
156
162
  handler: this.handler,
157
163
  logger,
158
164
  config: this.config
@@ -193,9 +199,5 @@ function useFunc(handler) {
193
199
  plugins = [];
194
200
  return func;
195
201
  }
196
- function nameFunc(name, handler) {
197
- Object.defineProperty(handler, "name", { value: name });
198
- return handler;
199
- }
200
202
 
201
203
  export { Func, nameFunc, useFunc, usePlugin };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faasjs/func",
3
- "version": "5.0.1",
3
+ "version": "6.0.0-beta.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -30,12 +30,12 @@
30
30
  "dist"
31
31
  ],
32
32
  "peerDependencies": {
33
- "@faasjs/deep_merge": "5.0.1",
34
- "@faasjs/logger": "5.0.1"
33
+ "@faasjs/deep_merge": "6.0.0-beta.1",
34
+ "@faasjs/logger": "6.0.0-beta.1"
35
35
  },
36
36
  "devDependencies": {
37
- "@faasjs/deep_merge": "5.0.1",
38
- "@faasjs/logger": "5.0.1"
37
+ "@faasjs/deep_merge": "6.0.0-beta.1",
38
+ "@faasjs/logger": "6.0.0-beta.1"
39
39
  },
40
40
  "engines": {
41
41
  "node": ">=22.0.0",