@temporalio/worker
Version:
Temporal.io SDK Worker sub-package
28 lines • 999 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.MiB = void 0;
exports.toMB = toMB;
exports.byteArrayToBuffer = byteArrayToBuffer;
exports.convertToParentWorkflowType = convertToParentWorkflowType;
const workflow_1 = require("@temporalio/workflow");
exports.MiB = 1024 ** 2;
function toMB(bytes, fractionDigits = 2) {
return (bytes / 1024 / 1024).toFixed(fractionDigits);
}
function byteArrayToBuffer(array) {
return array.buffer.slice(array.byteOffset, array.byteLength + array.byteOffset);
}
function convertToParentWorkflowType(parent) {
if (!parent) {
return undefined;
}
if (!parent.workflowId || !parent.runId || !parent.namespace) {
throw new workflow_1.IllegalStateError('Parent INamespacedWorkflowExecution is missing a field that should be defined');
}
return {
workflowId: parent.workflowId,
runId: parent.runId,
namespace: parent.namespace,
};
}
//# sourceMappingURL=utils.js.map