UNPKG

@threlte/core

Version:

A 3D framework for the web, built on top of Svelte and Three.js

18 lines (17 loc) 482 B
/** * Short cicruits if the input is not a function, then calls toString on Function with guaranteed safe behavior */ const isClass = (input) => { return typeof input === 'function' && Function.prototype.toString.call(input).startsWith('class '); }; export const determineRef = (is, args) => { if (isClass(is)) { if (Array.isArray(args)) { return new is(...args); } else { return new is(); } } return is; };