@@ -75,18 +75,11 @@ async function awaitReply(msg, question, limit = 60000) {
75
75
76
76
/* MISCELLANEOUS NON-CRITICAL FUNCTIONS */
77
77
78
- // EXTENDING NATIVE TYPES IS BAD PRACTICE. Why? Because if JavaScript adds this
79
- // later, this conflicts with native code. Also, if some other lib you use does
80
- // this, a conflict also occurs. KNOWING THIS however, the following 2 methods
81
- // are, we feel, very useful in code.
82
-
83
- // <String>.toProperCase() returns a proper-cased string such as:
84
- // "Mary had a little lamb".toProperCase() returns "Mary Had A Little Lamb"
85
- Object . defineProperty ( String . prototype , "toProperCase" , {
86
- value : function ( ) {
87
- return this . replace ( / ( [ ^ \W _ ] + [ ^ \s - ] * ) * / g, ( txt ) => txt . charAt ( 0 ) . toUpperCase ( ) + txt . substr ( 1 ) . toLowerCase ( ) ) ;
88
- }
89
- } ) ;
78
+ // toProperCase(String) returns a proper-cased string such as:
79
+ // toProperCase("Mary had a little lamb") returns "Mary Had A Little Lamb"
80
+ function toProperCase ( string ) {
81
+ return string . replace ( / ( [ ^ \W _ ] + [ ^ \s - ] * ) * / g, ( txt ) => txt . charAt ( 0 ) . toUpperCase ( ) + txt . substr ( 1 ) . toLowerCase ( ) ) ;
82
+ }
90
83
91
84
// These 2 process methods will catch exceptions and give *more details* about the error and stack trace.
92
85
process . on ( "uncaughtException" , ( err ) => {
@@ -103,4 +96,4 @@ process.on("unhandledRejection", err => {
103
96
console . error ( err ) ;
104
97
} ) ;
105
98
106
- module . exports = { getSettings, permlevel, awaitReply } ;
99
+ module . exports = { getSettings, permlevel, awaitReply, toProperCase } ;
0 commit comments