manu-sapiens's picture
copy of omnitool_latest - should be working
b39afbe
raw
history blame
674 Bytes
/**
* Copyright (c) 2023 MERCENARIES.AI PTE. LTD.
* All rights reserved.
*/
import CustomSocket from './CustomSocket';
import { type WorkerContext } from '../openapi/types';
class BooleanSocket extends CustomSocket {
async handleInput(ctx: WorkerContext, value: any): Promise<any | null> {
if (Array.isArray(value)) {
value = value[0]; // If array is passed in, just take the first element.
}
return Boolean(value); // Convert to boolean.
}
async handleOutput(ctx: WorkerContext, value: any): Promise<any | null> {
return await this.handleInput(ctx, value); // Use the same logic for input and output.
}
}
export default BooleanSocket;