woolball-client
Version:
Client-side library for Woolball enabling secure browser resource sharing for distributed AI task processing
21 lines (20 loc) • 770 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.isNodeEnvironment = isNodeEnvironment;
exports.getTransformersDevice = getTransformersDevice;
/**
* Utility function to check if the code is running in a Node.js environment
* @returns boolean indicating if the environment is Node.js
*/
function isNodeEnvironment() {
return typeof process !== 'undefined' &&
process.versions != null &&
process.versions.node != null;
}
/**
* Get the appropriate device for transformers.js based on the current environment
* @returns 'cpu' for Node.js environment, 'wasm' or 'webgpu' for browser environment
*/
function getTransformersDevice(defaultDevice = 'wasm') {
return isNodeEnvironment() ? 'cpu' : defaultDevice;
}