UNPKG

slavery-js

Version:

A simple clustering app that allows you to scale an application on multiple thread, containers or machines

29 lines (23 loc) 894 B
import type { SlaveMethods, Options as ServiceOptions } from '../service/types/index.js'; type callableFunction = (...args: any[]) => any; function isSlaveMethods(obj: any): obj is SlaveMethods { if(obj === null || obj === undefined) return false; return ( obj && typeof obj === 'object' && Object.values(obj).some(value => typeof value === 'function') ); } function isServiceOptions(obj: any): obj is ServiceOptions { if(obj === null || obj === undefined) return false; return ( obj && typeof obj === 'object' && Object.values(obj).every(value => typeof value !== 'function') ); } function isMasterCallback(value: any): value is Function | callableFunction { if(value === null || value === undefined) return false; return typeof value === 'function'; } export { isSlaveMethods, isServiceOptions, isMasterCallback };