6 ms·
Since this is a link to a github repo, I checked the source code. I personally using tabs as opposed to 2 or 3 spaces makes the code ugly. Can someone help me
by guiomie 12y ago
Since this is a link to a github repo, I checked the source code. I personally using tabs as opposed to 2 or 3 spaces makes the code ugly.
Can someone help me undertand "require('./user/auth')(User);
" ?? from https://github.com/NodeBB/NodeBB/blob/master/src/user.js https://github.com/NodeBB/NodeBB/blob/master/src/user.js
- runj__ 12y agoIt initializes the Auth module with the User object. The Auth module in turn extends the User object with the property 'auth'. The auth property is then extended with a 'logAttempt' function and a 'clearLoginAttempts' function. The User object in the parent context can then use these properties. Oh, and I agree that the tabbing makes it look ridiculous. Javascript should use two spaces, nothing more, nothing less (let the fight begin).
- b3n 12y ago> Oh, and I agree that the tabbing makes it look ridiculous. Javascript should use two spaces, nothing more, nothing less (let the fight begin). That's not the code's fault, GitHub should set the tab-size[1] property to something more legible. [1] http://www.w3.org/TR/css3-text/#tab-size http://www.w3.org/TR/css3-text/#tab-size
- deleted 12y ago[deleted]
- Q_the_Novice 12y agoAlso found the coding style a bit complicated and confusing - looks like they are passing the User module to other modules(in this case the auth module) and adding methods.
- guiomie 12y agoYah, the module is actually an exported function. Makes sense, but a bit confusing.
- simon_renoult 12y ago"require('./user/auth')(User);" is a simple call to the "./user/auth" module with User as a parameter. Check https://github.com/NodeBB/NodeBB/blob/master/src/user/auth.js https://github.com/NodeBB/NodeBB/blob/master/src/user/auth.j...
- romanovcode 12y agorequire, require, require. Reminds me of early php days puke.