OLD | NEW |
(Empty) | |
| 1 <!-- |
| 2 @license |
| 3 Copyright (c) 2014 The Polymer Project Authors. All rights reserved. |
| 4 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt |
| 5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt |
| 6 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt |
| 7 Code distributed by Google as part of the polymer project is also |
| 8 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt |
| 9 --> |
| 10 <script> |
| 11 (function(scope) { |
| 12 |
| 13 function withDependencies(task, depends) { |
| 14 depends = depends || []; |
| 15 if (!depends.map) { |
| 16 depends = [depends]; |
| 17 } |
| 18 return task.apply(this, depends.map(marshal)); |
| 19 } |
| 20 |
| 21 function module(name, dependsOrFactory, moduleFactory) { |
| 22 var module = null; |
| 23 switch (arguments.length) { |
| 24 case 0: |
| 25 return; |
| 26 case 2: |
| 27 // dependsOrFactory is `factory` in this case |
| 28 module = dependsOrFactory.apply(this); |
| 29 break; |
| 30 default: |
| 31 // dependsOrFactory is `depends` in this case |
| 32 module = withDependencies(moduleFactory, dependsOrFactory); |
| 33 break; |
| 34 } |
| 35 modules[name] = module; |
| 36 }; |
| 37 |
| 38 function marshal(name) { |
| 39 return modules[name]; |
| 40 } |
| 41 |
| 42 var modules = {}; |
| 43 |
| 44 var using = function(depends, task) { |
| 45 withDependencies(task, depends); |
| 46 }; |
| 47 |
| 48 // exports |
| 49 |
| 50 scope.marshal = marshal; |
| 51 // `module` confuses commonjs detectors |
| 52 scope.modulate = module; |
| 53 scope.using = using; |
| 54 |
| 55 })(this); |
| 56 </script> |
OLD | NEW |