
This is a collection of functions for working with strings.
The generateRandomString function returns a random string.
import { generateRandomString } from '@aracna/core';
// will log a 32 chars random alphanumeric string
console.log(generateRandomString());
// will log a 32 chars random numeric string
console.log(generateRandomString({ alphabet: '0123456789' }));
// will log a 8 chars random alphanumeric string
console.log(generateRandomString({ size: 8 }));The getCapitalizedString function returns a string with the first letter capitalized. Optionally the rest of the letters can be set to lowercase.
import { getCapitalizedString } from '@aracna/core';
// will log "Hello World"
console.log(getCapitalizedString('hello World'));
// will log "Hello world"
console.log(getCapitalizedString('hello World', true));The getCamelCaseString function returns a string in camel case.
import { getCamelCaseString } from '@aracna/core';
// will log "helloWorld"
console.log(getCamelCaseString('hello world'));The getKebabCaseString function returns a string in kebab case.
import { getKebabCaseString } from '@aracna/core';
// will log "hello-world"
console.log(getKebabCaseString('hello world'));The getPascalCaseString function returns a string in pascal case.
import { getPascalCaseString } from '@aracna/core';
// will log "Hello World"
console.log(getPascalCaseString('hello world'));The getSnakeCaseString function returns a string in snake case.
import { getSnakeCaseStranger } from '@aracna/core';
// will log "hello_world"
console.log(getSnakeCaseStranger('hello world'));The getSymbolCaseString function returns a string with a symbol between each word.
import { getKebabCaseString } from '@aracna/core';
// will log "hello.world"
console.log(getSymbolCaseString('hello world', '.'));The isStringFloat function checks if a string is a float.
import { isStringFloat } from '@aracna/core';
// will log true
console.log(isStringFloat('1.5'));The isStringInt function checks if a string is an integer.
import { isStringInt } from '@aracna/core';
// will log true
console.log(isStringInt('1'));The isStringJSON function checks if a string is a JSON.
import { isStringJSON } from '@aracna/core';
// will log true
console.log(isStringJSON('{}'));The isStringURL function checks if a string is a URL.
import { isStringURL } from '@aracna/core';
// will log true
console.log(isStringURL('https://aracna.dariosechi.it'));