How to use the capitalize function from underscore.string
Find comprehensive JavaScript underscore.string.capitalize code examples handpicked from public code repositorys.
underscore.string.capitalize is a method in the Underscore.string library that capitalizes the first letter of a string, making the string appear as a proper noun or sentence.
GitHub: guyoung/CaptfEncoder
7 8 9 10 11 12 13 14 15 16 17
/** * 将字符串的第一个字母转换为大写。 * @param str */ function capitalize(str) { return _s.capitalize(str); } /** *
+ 4 other calls in file
GitHub: artsy/force
124 125 126 127 128 129 130 131 132 133
if (req.query.denied) { return next(new Error(`${provider} denied`)) } // Determine if we're linking the account and handle any Gravity errors // that we can do a better job explaining and redirecting for. const providerName = capitalize(provider) const linkingAccount = req.user != null passport.authenticate(provider)(req, res, function (err) { let msg
+ 12 other calls in file
How does underscore.string.capitalize work?
underscore.string.capitalize is a method in the Underscore.string library that capitalizes the first letter of a string, making the string appear as a proper noun or sentence. When you call _.capitalize(string), the function takes a string as an argument and returns a new string with the first letter capitalized. The remaining characters in the string are preserved. For example, if you call _.capitalize('hello, world!'), the function will return the string "Hello, world!". Note that _.capitalize only capitalizes the first letter of the string. If you need to capitalize the first letter of each word in a string, you can use _.titleize instead. In essence, _.capitalize provides a simple way to capitalize the first letter of a string, which can be useful for formatting strings in a more readable or standardized way.
193 194 195 196 197 198 199 200 201 202
consumes: [ 'application/json', 'application/xml' ], info: { title: _.map(_str.words(_str.humanize(concurSwagger.resourcePath)), w => { return _str.capitalize(w); }).join(' '), description: '', version: concurSwagger.apiVersion }, tags: [{
GitHub: zebrunner/stf
71 72 73 74 75 76 77 78 79 80
var logLevelsLowerCase = _.map(service.logLevels, function(level) { return level.toLowerCase() }) var logLevelsCapitalized = _.map(logLevelsLowerCase, function(level) { return _s.capitalize(level) }) for (var i = 2; i < 8; ++i) { service.filters.levelNumbers.push({number: i, name: logLevelsCapitalized[i]})
+ 2 other calls in file
Ai Example
1 2 3 4 5 6 7
const _ = require("underscore.string"); const str = "the quick brown fox jumps over the lazy dog"; const capitalizedStr = _.capitalize(str); console.log(capitalizedStr);
In this example, we first import the underscore.string library. We then define a string to capitalize: 'the quick brown fox jumps over the lazy dog'. Next, we call _.capitalize(str) to create a new string with the first letter of the original string capitalized. The resulting string, capitalizedStr, will be "The quick brown fox jumps over the lazy dog", with the first letter capitalized. Note that _.capitalize only capitalizes the first letter of the string, leaving the rest of the characters unchanged.
GitHub: artsy/artsy-passport
103 104 105 106 107 108 109 110 111 112 113
module.exports.afterSocialAuth = provider => (function(req, res, next) { if (req.query.denied) { return next(new Error(`${provider} denied`)); } // Determine if we're linking the account and handle any Gravity errors // that we can do a better job explaining and redirecting for. const providerName = capitalize(provider); const linkingAccount = (req.user != null); passport.authenticate(provider)(req, res, function(err) { let msg; if (err && err.response && err.response.body && err.response.body.error === 'User Already Exists') {
GitHub: ahlwong/dakota-cassandra
90 91 92 93 94 95 96 97 98 99
}, getterSetterName: function(columnName) { return columnName.trim().replace(/\s/g, '_'); }, validatorSanitizerName: function(operation, columnName) { var name = nm_s.capitalize(columnName.trim().replace(/\s/g, '_')); return operation + name; }, typeSpecificSetterName: function(operation, columnName) { var name = nm_s.capitalize(columnName.trim().replace(/\s/g, '_'));
+ 9 other calls in file
124 125 126 127 128 129 130 131 132 133 134
// ============= // = Callbacks = // ============= nm_.each(Schema._CALLBACK_KEYS, function(key, index) { var methodName = 'add' + nm_s.capitalize(key) + 'Callback'; Schema.prototype[methodName] = function(callback) { addCallback.call(this, key, callback); }; });
+ 3 other calls in file
25 26 27 28 29 30 31 32 33 34 35 36
exports.lowerCase = function(value, options, callback){ callback(null, String(value).toLowerCase()); }; exports.capitalize = function(value, options, callback){ callback(null, str.capitalize(String(value))); }; exports.clean = function(value, options, callback){ callback(null, str.clean(String(value)));
+ 2 other calls in file
154 155 156 157 158 159 160 161 162 163 164 165
}; return `#${color.r}${color.g}${color.b}`; }; const cleanAll = (str) => { return capitalize(cleanDiacritics(str), true); }; module.exports.returnMonth = (str) => { const m = cleanAll(str);
GitHub: Kiubi/alpha
16 17 18 19 20 21 22 23 24 25
parseFilters: { left: function(value, args) { return value.substring(0, args[0] && args[0] <= value.length ? args[0] : value.length); }, ucfirst: function(value) { return _string.capitalize(value); }, strtoupper: function(value) { return value.toUpperCase(); },
+ 2 other calls in file
21 22 23 24 25 26 27 28 29 30
*/ let getAllSettingsFromComponentName = (componentName) => { const style = 'css'; let cleanedPaths = getCleanedPathName(componentName); let componentParts = cleanedPaths.split('/'); let componentBaseName = _.capitalize(componentParts.pop()); let componentPartPath = componentParts.join('/'); let componentFullName = _.classify(_.replaceAll(componentName, '/', '_')); let styleSettings = configUtils.getChoiceByKey('style', style); let componentPath = configUtils.getChoiceByKey('path', 'component');
+ 5 other calls in file
94 95 96 97 98 99 100 101 102 103
/** * Sets the concrete API Service (e.g. TwitterService) and its overrides */ _setupConcreteService() { sails.log.info('BaseAppService: _setupConcreteService()'); // var serviceName = s.capitalize(this.playlistitem.appType)+'Service'; // if(_.isUndefined(global[serviceName])) { // sails.log.error('No Service "'+serviceName+'" found.'); // }
+ 3 other calls in file
91 92 93 94 95 96 97 98 99 100
/** * Sets the concrete API Service (e.g. TwitterService) and its overrides */ _setupConcreteService: function() { sails.log.info('AppService: _setupConcreteService()'); var serviceName = s.capitalize(this.playlistitem.appType)+'Service'; if(_.isUndefined(global[serviceName])) { sails.log.error('No Service "'+serviceName+'" found.'); }
+ 3 other calls in file
157 158 159 160 161 162 163 164 165 166 167 168
// and should be translated into N.(N.N.) Last function fix_author(a) { let name = a.name; let components = $.words(name, ","); let first_name = $.capitalize($.clean(components[1]), true); let last_name = $.capitalize($.clean(components[0]), true); if (_.isPlainObject(patt[last_name])) { ({ name } = patt[last_name]);
+ 3 other calls in file
GitHub: dushenyan/myresume
149 150 151 152 153 154 155 156 157 158
_.each(resume.skills, function (skill_info) { var levels = ['Beginner', 'Intermediate', 'Advanced', 'Master']; if (skill_info.level) { skill_info.skill_class = skill_info.level.toLowerCase(); skill_info.level = _s.capitalize(skill_info.level.trim()); skill_info.display_progress_bar = _.contains(levels, skill_info.level); } });
189 190 191 192 193 194 195 196 197 198
// do not try to match verbs, levenhstain could confuse "off" with "on" in phrasal verbs, also // it doesn't catch infinitive, checked in a following rule if (this.type === 'verb' || this.type === 'date') { return false; } var capitalizedType = _s.capitalize(this.type); // if the type is ok, capture the text or verify, nlp-compromise types are always capitalized (like noun), // while custom lexicons can be in any case (that explains the double or) if (term.tags[capitalizedType] || term.tags[this.type] || this.type === 'word') { if (!_.isEmpty(this.text)) {
underscore.string.slugify is the most popular function in underscore.string (323 examples)