mercredi 7 mars 2018

How does the d3js library register itself into the runtime, with its own name

Can someone explain this code :

(function (global, factory) {
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
    typeof define === 'function' && define.amd ? define(['exports'], factory) :
      (factory((global.d3 = global.d3 || {})));
}(this, (function (exports) { 'use strict';

specifically in terms of how this particular library register itself in the runtime with its own name (which is 'd3').

I figure that this is more/less an IIFE pattern. But can't get to work out on how it register itself with its own name in the runtime.

Aucun commentaire:

Enregistrer un commentaire