Skip to content

Latest commit

 

History

History
43 lines (33 loc) · 618 Bytes

README.md

File metadata and controls

43 lines (33 loc) · 618 Bytes

define.js

define.js is a minimalist module system for js

define(function one() {
  return 1;
});

define(function two(one) {
  return one + one;
});
// modules may be anonymous
define(function(window, one, two) {
  window.console.log('The sum of one and two is ', one + two);
});
// modules may be stateful
define(function counter() {
  var calls = 0;
  return function() { return ++calls; };
});

define(function(window, counter) {
  window.console.log(counter(), counter());
});
// modules may be safe
define(function(notDefined) {
  // throws an error!
});