MCPcopy Index your code
hub / github.com/gpujs/gpu.js / functionToIGPUFunction

Method functionToIGPUFunction

src/backend/kernel.js:907–927  ·  view source on GitHub ↗

* * @param {String|Function} source * @param {IFunctionSettings} [settings] * @returns {IGPUFunction}

(source, settings = {})

Source from the content-addressed store, hash-verified

905 * @returns {IGPUFunction}
906 */
907 functionToIGPUFunction(source, settings = {}) {
908 if (typeof source !== 'string' && typeof source !== 'function') throw new Error('source not a string or function');
909 const sourceString = typeof source === 'string' ? source : source.toString();
910 let argumentTypes = [];
911
912 if (Array.isArray(settings.argumentTypes)) {
913 argumentTypes = settings.argumentTypes;
914 } else if (typeof settings.argumentTypes === 'object') {
915 argumentTypes = utils.getArgumentNamesFromString(sourceString)
916 .map(name => settings.argumentTypes[name]) || [];
917 } else {
918 argumentTypes = settings.argumentTypes || [];
919 }
920
921 return {
922 name: utils.getFunctionNameFromString(sourceString) || null,
923 source: sourceString,
924 argumentTypes,
925 returnType: settings.returnType || null,
926 };
927 }
928
929 /**
930 *

Callers 2

addFunctionMethod · 0.95
kernel.jsFile · 0.80

Calls 1

toStringMethod · 0.45

Tested by

no test coverage detected