-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update has.js #101
base: master
Are you sure you want to change the base?
Update has.js #101
Changes from 2 commits
40b2be2
86fd9d8
704aedc
f269bbe
81248c0
86b810a
04a4553
5ff1ca9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -149,7 +149,12 @@ | |
// Expose has() | ||
// some AMD build optimizers, like r.js, check for specific condition patterns like the following: | ||
if(typeof define == "function" && typeof define.amd == "object" && define.amd){ | ||
define("has", function(){ | ||
define("has", ['module'], function(module){ | ||
var moduleConfig = {}; | ||
if (typeof module.config === "function") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lets match the style: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's ok to remove spaces but why do you want to use non-strict comparation for that? eqeqeq works faster and typeof always returns string There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code going to be hit a few million times is it? Naw, it's a micro-opt and counter to the existing style. Technically because |
||
moduleConfig = module.config() || {}; | ||
for (var propKey in moduleConfig) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Undefined values in a for-in should not error,e.g. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. moduleConfig can't be undefined because if somehow There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code style seems to favor hoisting vars out (it was a phase :P). So that would make it: var propKey, moduleConfig;
if(typeof module.config == "function"){
moduleConfig = module.config();
}
for(propKey in moduleConfig){ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if we just use simple code for this as @jrburke has done in https://github.com/requirejs/text/blob/master/text.js#L23 var moduleConfig = (module.config && module.config()) || {};
for(var propKey in moduleConfig){
has.add(propKey, moduleConfig[propKey]);
} something like that above There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Naw, different project styles. We are consuming a foreign thing so have to be more cautious whereas that plugin expects to work with RequireJS and its constructs. |
||
has.add(propKey, moduleConfig[propKey]); | ||
return has; | ||
}); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consistent double quote use
'module'
->"module"