A collection of functions to work with strings.
npm install @288-toolkit/stringsA collection of functions to work with strings.
Capitalizes the first letter of a string.
Uncapitalize the first letter of a string.
Converts text to a valid HTML id.
Normalizes a string by replacing accents with their base characters.
Removes line breaks from a string.
Removes all spaces from a string.
Removes trailing slashes from a string.
Returns a string of URL parameters from an object, filtering out null values.
Convert a tagged template literal to a string for syntax highlighting.
``ts
import {
taggedTemplateToStringForSyntaxHighlighting,
type TemplateParamsArray
} from '@288-toolkit/strings';
const html = (t: TemplateStringsArray) => {
return taggedTemplateToStringForSyntaxHighlighting(t);
};
// The string is unmodified but the editor can now syntax highlight it.
html
;
`toBase64
Converts a string into a base64 encoded string.
`typescript
toBase64(str: string): string
`fromBase64
Converts a base64 encoded string into a string.
`typescript
fromBase64(str: string): string
`base64ToUrlSafe
Converts a valid base64 string into a URL-safe base64 string.
`typescript
base64ToUrlSafe(str: string): string
`base64FromUrlSafe
Converts a URL-safe base64 string into a valid base64 string.
`typescript
base64FromUrlSafe(str: string): string
`base64FromBytes
Encodes an array of bytes into a base64 string.
`typescript
base64FromBytes(array: Uint8Array)
`base64ToBytes
Decodes a base64 string into an array of bytes.
`typescript
base64ToBytes(base64: string)
``