From 824a2d9f587ca017fc71b84d835e72f54f9c87c4 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Wed, 7 Nov 2018 18:02:36 +0100 Subject: Began rewrite --- node_modules/locutus/python/string/capwords.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 node_modules/locutus/python/string/capwords.js (limited to 'node_modules/locutus/python/string/capwords.js') diff --git a/node_modules/locutus/python/string/capwords.js b/node_modules/locutus/python/string/capwords.js new file mode 100644 index 0000000..ddd855a --- /dev/null +++ b/node_modules/locutus/python/string/capwords.js @@ -0,0 +1,21 @@ +'use strict'; + +module.exports = function capwords(str) { + // discuss at: http://locutus.io/python/capwords/ + // original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com) + // improved by: Waldo Malqui Silva (http://waldo.malqui.info) + // improved by: Robin + // improved by: Kevin van Zonneveld (http://kvz.io) + // bugfixed by: Onno Marsman (https://twitter.com/onnomarsman) + // input by: James (http://www.james-bell.co.uk/) + // example 1: capwords('kevin van zonneveld') + // returns 1: 'Kevin Van Zonneveld' + // example 2: capwords('HELLO WORLD') + // returns 2: 'HELLO WORLD' + + var pattern = /^([a-z\u00E0-\u00FC])|\s+([a-z\u00E0-\u00FC])/g; + return (str + '').replace(pattern, function ($1) { + return $1.toUpperCase(); + }); +}; +//# sourceMappingURL=capwords.js.map \ No newline at end of file -- cgit v1.2.3