@agape/string
Advanced tools
Comparing version 1.1.2 to 1.2.0
@@ -20,2 +20,8 @@ /** | ||
/** | ||
* Returns a string formatted as a label. Adds spaces between words, | ||
* replacing underscores and hyphens, captilize the first word. | ||
* @param string A string to be returned as spoken words | ||
*/ | ||
export declare function labelize(string?: string): string; | ||
/** | ||
* Returns a string formatted as a class name. Removes all spaces and symbols, | ||
@@ -22,0 +28,0 @@ * captializes the first letter of each word. |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.titalize = exports.quanitfy = exports.pluralize = exports.classify = exports.verbalize = exports.tokenize = exports.camelize = void 0; | ||
exports.titalize = exports.quanitfy = exports.pluralize = exports.classify = exports.labelize = exports.verbalize = exports.tokenize = exports.camelize = void 0; | ||
/** | ||
@@ -42,2 +42,3 @@ * Returns a string formatted in camel case. | ||
.replace(/(.)([A-Z][a-z]+)/g, (str, left, right) => { return left + ' ' + right; }) | ||
.replace(/([a-z0-9])([A-Z])/g, (str, left, right) => { return left + ' ' + right; }) | ||
.replace(/[-_]/, ' ') | ||
@@ -48,2 +49,17 @@ .replace(/^([a-z])/, (str) => { return str.toUpperCase(); }); | ||
/** | ||
* Returns a string formatted as a label. Adds spaces between words, | ||
* replacing underscores and hyphens, captilize the first word. | ||
* @param string A string to be returned as spoken words | ||
*/ | ||
function labelize(string) { | ||
string = string === undefined ? this : string; | ||
return string | ||
.replace(/(.)([A-Z][a-z]+)/g, (str, left, right) => { return left + ' ' + right; }) | ||
.replace(/([a-z0-9])([A-Z])/g, (str, left, right) => { return left + ' ' + right; }) | ||
.replace(/[-_]/, ' ') | ||
.toLocaleLowerCase() | ||
.replace(/^([a-z])/, (str) => { return str.toUpperCase(); }); | ||
} | ||
exports.labelize = labelize; | ||
/** | ||
* Returns a string formatted as a class name. Removes all spaces and symbols, | ||
@@ -77,2 +93,5 @@ * captializes the first letter of each word. | ||
} | ||
else if (string.endsWith('s')) { | ||
return string; | ||
} | ||
else { | ||
@@ -79,0 +98,0 @@ return string + 's'; |
@@ -20,2 +20,8 @@ /** | ||
/** | ||
* Returns a string formatted as a label. Adds spaces between words, | ||
* replacing underscores and hyphens, captilize the first word. | ||
* @param string A string to be returned as spoken words | ||
*/ | ||
export declare function labelize(string?: string): string; | ||
/** | ||
* Returns a string formatted as a class name. Removes all spaces and symbols, | ||
@@ -22,0 +28,0 @@ * captializes the first letter of each word. |
@@ -37,2 +37,3 @@ /** | ||
.replace(/(.)([A-Z][a-z]+)/g, (str, left, right) => { return left + ' ' + right; }) | ||
.replace(/([a-z0-9])([A-Z])/g, (str, left, right) => { return left + ' ' + right; }) | ||
.replace(/[-_]/, ' ') | ||
@@ -42,2 +43,16 @@ .replace(/^([a-z])/, (str) => { return str.toUpperCase(); }); | ||
/** | ||
* Returns a string formatted as a label. Adds spaces between words, | ||
* replacing underscores and hyphens, captilize the first word. | ||
* @param string A string to be returned as spoken words | ||
*/ | ||
export function labelize(string) { | ||
string = string === undefined ? this : string; | ||
return string | ||
.replace(/(.)([A-Z][a-z]+)/g, (str, left, right) => { return left + ' ' + right; }) | ||
.replace(/([a-z0-9])([A-Z])/g, (str, left, right) => { return left + ' ' + right; }) | ||
.replace(/[-_]/, ' ') | ||
.toLocaleLowerCase() | ||
.replace(/^([a-z])/, (str) => { return str.toUpperCase(); }); | ||
} | ||
/** | ||
* Returns a string formatted as a class name. Removes all spaces and symbols, | ||
@@ -70,2 +85,5 @@ * captializes the first letter of each word. | ||
} | ||
else if (string.endsWith('s')) { | ||
return string; | ||
} | ||
else { | ||
@@ -72,0 +90,0 @@ return string + 's'; |
@@ -20,2 +20,8 @@ /** | ||
/** | ||
* Returns a string formatted as a label. Adds spaces between words, | ||
* replacing underscores and hyphens, captilize the first word. | ||
* @param string A string to be returned as spoken words | ||
*/ | ||
export declare function labelize(string?: string): string; | ||
/** | ||
* Returns a string formatted as a class name. Removes all spaces and symbols, | ||
@@ -22,0 +28,0 @@ * captializes the first letter of each word. |
@@ -37,2 +37,3 @@ /** | ||
.replace(/(.)([A-Z][a-z]+)/g, (str, left, right) => { return left + ' ' + right; }) | ||
.replace(/([a-z0-9])([A-Z])/g, (str, left, right) => { return left + ' ' + right; }) | ||
.replace(/[-_]/, ' ') | ||
@@ -42,2 +43,16 @@ .replace(/^([a-z])/, (str) => { return str.toUpperCase(); }); | ||
/** | ||
* Returns a string formatted as a label. Adds spaces between words, | ||
* replacing underscores and hyphens, captilize the first word. | ||
* @param string A string to be returned as spoken words | ||
*/ | ||
export function labelize(string) { | ||
string = string === undefined ? this : string; | ||
return string | ||
.replace(/(.)([A-Z][a-z]+)/g, (str, left, right) => { return left + ' ' + right; }) | ||
.replace(/([a-z0-9])([A-Z])/g, (str, left, right) => { return left + ' ' + right; }) | ||
.replace(/[-_]/, ' ') | ||
.toLocaleLowerCase() | ||
.replace(/^([a-z])/, (str) => { return str.toUpperCase(); }); | ||
} | ||
/** | ||
* Returns a string formatted as a class name. Removes all spaces and symbols, | ||
@@ -70,2 +85,5 @@ * captializes the first letter of each word. | ||
} | ||
else if (string.endsWith('s')) { | ||
return string; | ||
} | ||
else { | ||
@@ -72,0 +90,0 @@ return string + 's'; |
{ | ||
"name": "@agape/string", | ||
"version": "1.1.2", | ||
"version": "1.2.0", | ||
"description": "String and token manipulation", | ||
"main": "./cjs/index.js", | ||
"module": "./es2020/index.js", | ||
"keywords": [ | ||
"agape", | ||
"object", | ||
"traits" | ||
"string" | ||
], | ||
"author": "Maverik Minett", | ||
"license": "MIT", | ||
"dependencies": { | ||
"reflect-metadata": "^0.1.13" | ||
}, | ||
"es2020": "./esm2020/index.js", | ||
@@ -27,5 +24,6 @@ "es2015": "./esm2015/index.js", | ||
"default": "./es2020/index.js", | ||
"require": "./cjs/index.js" | ||
"require": "./cjs/index.js", | ||
"import": "./es2020/index.js" | ||
} | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Copyleft License
License(Experimental) Copyleft license information was found
Found 1 instance in 1 package
No License Found
License(Experimental) License information could not be found
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found
Found 1 instance in 1 package
37712
0
0
575
- Removedreflect-metadata@^0.1.13
- Removedreflect-metadata@0.1.14(transitive)