To use the words()
function from the Lodash library in TypeScript, you should first install the Lodash library and add its types to your project.
You can install Lodash using npm:
26 chars2 lines
You can then import the words()
function from Lodash and use it in your TypeScript code like this:
index.ts188 chars7 lines
Note that the words()
function splits a string into an array of words, separated by whitespace. You can also pass a pattern as the second argument to split the string by a different separator. The typings for lodash should be available automatically if you're using TypeScript >= 2.6.0.
gistlibby LogSnag