Permalink
Browse files

initial support for bandwidth estimation

  • Loading branch information...
mmarcon committed Jul 26, 2012
1 parent fb3798a commit a5706c0049cd4f1c92b4cec4741dd5b5fc2abf78
Showing with 14 additions and 5 deletions.
  1. +3 −3 dist/jquery.on.demand.min.js
  2. +4 −0 src/jquery.on.demand.js
  3. +7 −2 tools/ondemand-builder.js

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -137,6 +137,10 @@
}
}
};
+ P.hasSize = function(sizeInBytes){
+ //Nothing yet, just...
+ $.noop();
+ };
getInstance = function(options) {
return new OnDemand(options);
@@ -79,7 +79,8 @@ fs.readFile(input, function(err, content) {
}
fs.mkdirSync(outputFolder);
- var matchingFn = '$.onDemand.setOptions({fn2script:function(fn){switch(fn){\n', matchingFnCase = 'case \'{CASE}\': return \'{WHAT}\'; break;\n';
+ var matchingFn = '$.onDemand.setOptions({fn2script:function(fn){switch(fn){\n', matchingFnCase = 'case \'{CASE}\': return \'{WHAT}\'; break;\n',
+ sizeFnTemplate = '(function(){$.onDemand.hasSize({SIZE})})();', sizeFn;
for (g in model.groups) {
data = model.all ? model.all.join('\n') : '';
nss = [];
@@ -94,7 +95,11 @@ fs.readFile(input, function(err, content) {
nss.forEach(function(ns){
data += '$.onDemand.registerAll('+ns+');';
});
- data += '})();';
+ data += '})();\n';
+
+ //Inception...
+ sizeFn = sizeFnTemplate.replace(/\{SIZE\}/, data.length + sizeFnTemplate.length - 6 + (''+data.length).length);
+ data += sizeFn;
fs.writeFileSync(outputFolder + '/' + g + '-ondemand.js', data);
}

0 comments on commit a5706c0

Please sign in to comment.