UNPKG

@naturalcycles/js-lib

Version:

Standard library for universal (browser + Node.js) javascript

32 lines (31 loc) 826 B
/** * @returns * e.g `NameOfYourClass.methodName` * or `NameOfYourClass(instanceId).methodName` */ export function _getMethodSignature(ctx, keyStr) { const { instanceId } = ctx; return `${ctx.constructor.name}${instanceId ? `#${instanceId}` : ''}.${keyStr}`; } /** * @returns `NameOfYourClass.methodName` */ export function _getTargetMethodSignature(target, keyStr) { return `${target.constructor.name}.${keyStr}`; } /** * @example * e.g for method (a: string, b: string, c: string) * returns: * a, b, c */ export function _getArgsSignature(args = [], logArgs = true) { if (!logArgs) return ''; return args .map(arg => { const s = arg && typeof arg === 'object' ? JSON.stringify(arg) : String(arg); return s.length > 30 ? '...' : s; }) .join(', '); }