To use the trimStart
function from the Lodash library in TypeScript, first, we need to install the Lodash library by running the below command.
19 chars2 lines
Next, we can import the trimStart
function from Lodash and then call it on a string to remove the whitespace from the beginning of the string.
index.ts122 chars5 lines
We can also provide a second argument to specify the characters that we want to remove from the beginning of the string.
index.ts94 chars3 lines
In the above example, we want to remove both underscore and hyphen characters from the beginning of the string. So we provided "_-" as the second argument to the trimStart
function.
gistlibby LogSnag