MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / $define

Function $define

lib/web/polyfill.js:428–460  ·  view source on GitHub ↗
(type, name, source)

Source from the content-addressed store, hash-verified

426 , BIND = 16
427 , WRAP = 32;
428function $define(type, name, source){
429 var key, own, out, exp
430 , isGlobal = type & GLOBAL
431 , target = isGlobal ? global : (type & STATIC)
432 ? global[name] : (global[name] || ObjectProto)[PROTOTYPE]
433 , exports = isGlobal ? core : core[name] || (core[name] = {});
434 if(isGlobal)source = name;
435 for(key in source){
436 // there is a similar native
437 own = !(type & FORCED) && target && key in target
438 && (!isFunction(target[key]) || isNative(target[key]));
439 // export native or passed
440 out = (own ? target : source)[key];
441 // prevent global pollution for namespaces
442 if(!framework && isGlobal && !isFunction(target[key]))exp = source[key];
443 // bind timers to global for call from export context
444 else if(type & BIND && own)exp = ctx(out, global);
445 // wrap global constructors for prevent change them in library
446 else if(type & WRAP && !framework && target[key] == out){
447 exp = function(param){
448 return this instanceof out ? new out(param) : out(param);
449 };
450 exp[PROTOTYPE] = out[PROTOTYPE];
451 } else exp = type & PROTO && isFunction(out) ? ctx(call, out) : out;
452 // extend global
453 if(framework && target && !own){
454 if(isGlobal)target[key] = out;
455 else delete target[key] && hidden(target, key, out);
456 }
457 // export
458 if(exports[key] != out)hidden(exports, key, exp);
459 }
460}
461// CommonJS export
462if(typeof module != 'undefined' && module.exports)module.exports = core;
463// RequireJS export

Callers 4

defineStdIteratorsFunction · 0.85
polyfill.jsFile · 0.85
wrapObjectMethodFunction · 0.85
getCollectionFunction · 0.85

Calls 3

isNativeFunction · 0.85
ctxFunction · 0.85
isFunctionFunction · 0.70

Tested by

no test coverage detected