@faasjs/func 6.0.0-beta.0 → 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/README.md +0 -2
- package/dist/index.cjs +0 -21
- package/dist/index.d.ts +14 -17
- package/dist/index.mjs +1 -19
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -19,8 +19,6 @@ npm install @faasjs/func
|
|
|
19
19
|
|
|
20
20
|
## Functions
|
|
21
21
|
|
|
22
|
-
- [detectNodeRuntime](functions/detectNodeRuntime.md)
|
|
23
|
-
- [loadPackage](functions/loadPackage.md)
|
|
24
22
|
- [nameFunc](functions/nameFunc.md)
|
|
25
23
|
- [useFunc](functions/useFunc.md)
|
|
26
24
|
- [usePlugin](functions/usePlugin.md)
|
package/dist/index.cjs
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
var crypto = require('crypto');
|
|
4
4
|
var logger = require('@faasjs/logger');
|
|
5
5
|
|
|
6
|
-
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
7
6
|
// src/index.ts
|
|
8
7
|
|
|
9
8
|
// src/plugins/run_handler/index.ts
|
|
@@ -37,24 +36,6 @@ function nameFunc(name, handler) {
|
|
|
37
36
|
Object.defineProperty(handler, "name", { value: name });
|
|
38
37
|
return handler;
|
|
39
38
|
}
|
|
40
|
-
function detectNodeRuntime() {
|
|
41
|
-
if (typeof globalThis.require === "function" && typeof module !== "undefined")
|
|
42
|
-
return "commonjs";
|
|
43
|
-
if (typeof ({ url: (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)) }) !== "undefined") return "module";
|
|
44
|
-
throw Error("Unknown runtime");
|
|
45
|
-
}
|
|
46
|
-
async function loadPackage(name) {
|
|
47
|
-
const runtime = detectNodeRuntime();
|
|
48
|
-
if (runtime === "module") {
|
|
49
|
-
const module2 = await import(name);
|
|
50
|
-
return module2.default ? module2.default : module2;
|
|
51
|
-
}
|
|
52
|
-
if (runtime === "commonjs") {
|
|
53
|
-
const module2 = globalThis.require(name);
|
|
54
|
-
return module2.default ? module2.default : module2;
|
|
55
|
-
}
|
|
56
|
-
throw Error("Unknown runtime");
|
|
57
|
-
}
|
|
58
39
|
|
|
59
40
|
// src/index.ts
|
|
60
41
|
var Func = class {
|
|
@@ -222,8 +203,6 @@ function useFunc(handler) {
|
|
|
222
203
|
}
|
|
223
204
|
|
|
224
205
|
exports.Func = Func;
|
|
225
|
-
exports.detectNodeRuntime = detectNodeRuntime;
|
|
226
|
-
exports.loadPackage = loadPackage;
|
|
227
206
|
exports.nameFunc = nameFunc;
|
|
228
207
|
exports.useFunc = useFunc;
|
|
229
208
|
exports.usePlugin = usePlugin;
|
package/dist/index.d.ts
CHANGED
|
@@ -20,28 +20,25 @@ import { Logger } from '@faasjs/logger';
|
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
22
|
declare function nameFunc<T extends (...args: any[]) => any>(name: string, handler: T): T;
|
|
23
|
+
|
|
23
24
|
/**
|
|
24
|
-
*
|
|
25
|
+
* FaasJS's function module.
|
|
25
26
|
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
27
|
+
* [](https://github.com/faasjs/faasjs/blob/main/packages/func/LICENSE)
|
|
28
|
+
* [](https://www.npmjs.com/package/@faasjs/func)
|
|
28
29
|
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
*
|
|
30
|
+
* ## Install
|
|
31
|
+
*
|
|
32
|
+
* ```sh
|
|
33
|
+
* npm install @faasjs/func
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* ## Usage
|
|
36
37
|
*
|
|
37
|
-
*
|
|
38
|
+
* @see {@link useFunc}
|
|
38
39
|
*
|
|
39
|
-
* @
|
|
40
|
-
* @param {string} name - The name of the package to load.
|
|
41
|
-
* @returns {Promise<T>} A promise that resolves to the loaded package.
|
|
42
|
-
* @throws {Error} If the runtime is neither 'module' nor 'commonjs'.
|
|
40
|
+
* @packageDocumentation
|
|
43
41
|
*/
|
|
44
|
-
declare function loadPackage<T = unknown>(name: string): Promise<T>;
|
|
45
42
|
|
|
46
43
|
type Handler<TEvent = any, TContext = any, TResult = any> = (data: InvokeData<TEvent, TContext>) => Promise<TResult>;
|
|
47
44
|
type Next = () => Promise<void>;
|
|
@@ -183,4 +180,4 @@ declare function usePlugin<T extends Plugin>(plugin: T & {
|
|
|
183
180
|
*/
|
|
184
181
|
declare function useFunc<TEvent = any, TContext = any, TResult = any>(handler: () => Handler<TEvent, TContext, TResult>): Func<TEvent, TContext, TResult>;
|
|
185
182
|
|
|
186
|
-
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,
|
|
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
|
@@ -34,24 +34,6 @@ function nameFunc(name, handler) {
|
|
|
34
34
|
Object.defineProperty(handler, "name", { value: name });
|
|
35
35
|
return handler;
|
|
36
36
|
}
|
|
37
|
-
function detectNodeRuntime() {
|
|
38
|
-
if (typeof globalThis.require === "function" && typeof module !== "undefined")
|
|
39
|
-
return "commonjs";
|
|
40
|
-
if (typeof import.meta !== "undefined") return "module";
|
|
41
|
-
throw Error("Unknown runtime");
|
|
42
|
-
}
|
|
43
|
-
async function loadPackage(name) {
|
|
44
|
-
const runtime = detectNodeRuntime();
|
|
45
|
-
if (runtime === "module") {
|
|
46
|
-
const module2 = await import(name);
|
|
47
|
-
return module2.default ? module2.default : module2;
|
|
48
|
-
}
|
|
49
|
-
if (runtime === "commonjs") {
|
|
50
|
-
const module2 = globalThis.require(name);
|
|
51
|
-
return module2.default ? module2.default : module2;
|
|
52
|
-
}
|
|
53
|
-
throw Error("Unknown runtime");
|
|
54
|
-
}
|
|
55
37
|
|
|
56
38
|
// src/index.ts
|
|
57
39
|
var Func = class {
|
|
@@ -218,4 +200,4 @@ function useFunc(handler) {
|
|
|
218
200
|
return func;
|
|
219
201
|
}
|
|
220
202
|
|
|
221
|
-
export { Func,
|
|
203
|
+
export { Func, nameFunc, useFunc, usePlugin };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faasjs/func",
|
|
3
|
-
"version": "6.0.0-beta.
|
|
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": "6.0.0-beta.
|
|
34
|
-
"@faasjs/logger": "6.0.0-beta.
|
|
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": "6.0.0-beta.
|
|
38
|
-
"@faasjs/logger": "6.0.0-beta.
|
|
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",
|