tag:blogger.com,1999:blog-5993074704535120230.post3972829765194843569..comments2014-01-03T17:22:31.355-08:00Comments on Random bits of foo: String replace the better way.Erinhttp://www.blogger.com/profile/02595867288580221282noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-5993074704535120230.post-76492340268424285782012-03-23T08:32:13.590-07:002012-03-23T08:32:13.590-07:00It's actually an internal function in a trie o...It's actually an internal function in a trie object so that would be over kill.Erinhttps://www.blogger.com/profile/02595867288580221282noreply@blogger.comtag:blogger.com,1999:blog-5993074704535120230.post-39938836214013723192012-03-22T14:43:29.352-07:002012-03-22T14:43:29.352-07:00Love your change to use the module pattern. Could ...Love your change to use the module pattern. Could have made it more "objecty" looking like this:<br /><br /><b><br />var AccentRemover = (funciton() {<br /> // translation tables go here<br /> ...<br /> function removeAccents(s) {<br /> return s.replace ... // your anonymous function body goes here<br /> }<br /> return {<br /> removeAccents: removeAccents<br /> };<br />})();<br /></b><br /><br />Then you would call it like this:<br /><br /><b><br /> var result = AccentRemover.removeAccents('some string');<br /></b><br /><br />I've become quite fond of the module pattern in general, and this naming convention in specific in my recent work. I like the "AccentRemover" naming beacause it communicates intent that this is a module possibly with its own state and its own scope.<br /><br />Sorry for the lack of indenting. Stupid blogger.com.<br /><br />Also, have you looked into qunit for unit testing code like this? I have liked it.Unknownhttps://www.blogger.com/profile/06882415672602095092noreply@blogger.comtag:blogger.com,1999:blog-5993074704535120230.post-34749853497662932362012-03-22T13:44:05.843-07:002012-03-22T13:44:05.843-07:00Thanks for pointing out my error. Naomi pointed o...Thanks for pointing out my error. Naomi pointed out an actual bug.Erinhttps://www.blogger.com/profile/02595867288580221282noreply@blogger.comtag:blogger.com,1999:blog-5993074704535120230.post-71445823349541070942012-03-22T13:40:43.041-07:002012-03-22T13:40:43.041-07:00Wait, you got a massive speed boost _and_ a perfor...Wait, you got a massive speed boost _and_ a performance bump at the same time? Together? Simultaneously? NO WAY!Ishpeckhttps://www.blogger.com/profile/06825418921052334722noreply@blogger.com