Sha256: 666ff9149de8e93ed016840929e4c183206e834f7b20c40a8eac812bf645f2fe
Contents?: true
Size: 1.79 KB
Versions: 62
Compression:
Stored size: 1.79 KB
Contents
/** * @namespace WORKAREA.string */ WORKAREA.registerModule('string', (function () { 'use strict'; var /** * Converts a string to lowercase and replaces all spaces width dashes. * * @param {String} string * @return {String} the dasherized string */ dasherize = function (string) { return string.replace(/\s+/g, '-').toLowerCase(); }, /** * Pluralizes a string, based on a given count. * * @param {Integer} count - The number that determines pluralization * @param {String} string - string to pluralized * @param {String} pluralizedString - optional, overrides pluralized * result of the function * @return {String} the pluralized string */ pluralize = function (count, string, pluralizedString) { if (count > 1 && ! _.isUndefined(pluralizedString)) { return pluralizedString; } else if (count > 1) { return string + 's'; } else { return string; } }, /** * @method * @name titleize * @memberof WORKAREA.string */ titleize = function (string) { if ( ! _.isString(string)) { throw new Error('WORKAREA.string.titleize: expecting string'); } return _.map( $.trim(string).toLowerCase().split(' '), function (subString) { return subString.charAt(0).toUpperCase() + subString.slice(1); } ).join(' '); }; return { titleize: titleize, pluralize: pluralize, dasherize: dasherize }; }()));
Version data entries
62 entries across 62 versions & 1 rubygems