UNPKG

@kitchenshelf/serverless-rspack

Version:

[Serverless Framework](https://www.serverless.com) plugin for zero-config JavaScript and TypeScript code bundling using the high performance Rust-based JavaScript bundler [`rspack`](https://rspack.dev/guide/start/introduction)

39 lines 1.65 kB
export const humanSize = (size) => { if (size === 0) { return '0.00 B'; } if (size >= Number.MAX_SAFE_INTEGER) { return 'MSI'; } const exponent = Math.floor(Math.log(size) / Math.log(1024)); const sanitized = (size / Math.pow(1024, exponent)).toFixed(2); return `${sanitized} ${['B', 'KB', 'MB', 'GB', 'TB'][exponent]}`; }; /** * Checks if the runtime for the given function is nodejs. * If the runtime is not set , checks the global runtime. * @param {FunctionDefinitionHandler} func the function to be checked * @returns {boolean} true if the function/global runtime is nodejs; false, otherwise */ export function isNodeFunction(func, providerRuntime) { var _a; const runtime = (_a = (func.runtime || providerRuntime)) !== null && _a !== void 0 ? _a : ''; return typeof runtime === 'string' && runtime.startsWith('node'); } export function determineFileParts(handlerFile) { var _a, _b; const regex = /^(.*)\/([^/]+)$/; const result = regex.exec(handlerFile); const filePath = (_a = result === null || result === void 0 ? void 0 : result[1]) !== null && _a !== void 0 ? _a : ''; const fileName = (_b = result === null || result === void 0 ? void 0 : result[2]) !== null && _b !== void 0 ? _b : handlerFile; return { filePath, fileName }; } export function enabledViaSimpleConfig(field) { return typeof field === 'boolean' && field === true; } export function enabledViaConfigObject(field) { return (typeof field === 'object' && field !== null && (field.enable === true || field.enable === undefined)); } //# sourceMappingURL=helpers.js.map