Lodash utility library exported as ES6 modules for modern JavaScript applications with tree-shaking support.
—
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Pending
The risk profile of this skill
String manipulation utilities for case conversion, trimming, templating, and text processing operations.
Functions for converting string case and capitalization.
/**
* Converts string to camel case
* @param {string} str - The string to convert
* @returns {string} Returns the camel cased string
*/
function camelCase(str);
/**
* Converts string to kebab case
* @param {string} str - The string to convert
* @returns {string} Returns the kebab cased string
*/
function kebabCase(str);
/**
* Converts string to snake case
* @param {string} str - The string to convert
* @returns {string} Returns the snake cased string
*/
function snakeCase(str);
/**
* Converts string to start case
* @param {string} str - The string to convert
* @returns {string} Returns the start cased string
*/
function startCase(str);
/**
* Converts string to lower case
* @param {string} str - The string to convert
* @returns {string} Returns the lower cased string
*/
function lowerCase(str);
/**
* Converts string to upper case
* @param {string} str - The string to convert
* @returns {string} Returns the upper cased string
*/
function upperCase(str);
/**
* Converts the first character of string to upper case and the remaining to lower case
* @param {string} str - The string to capitalize
* @returns {string} Returns the capitalized string
*/
function capitalize(str);
/**
* Converts the first character of string to lower case
* @param {string} str - The string to convert
* @returns {string} Returns the converted string
*/
function lowerFirst(str);
/**
* Converts the first character of string to upper case
* @param {string} str - The string to convert
* @returns {string} Returns the converted string
*/
function upperFirst(str);
/**
* Converts string, as space separated words, to lower case
* @param {string} str - The string to convert
* @returns {string} Returns the lower cased string
*/
function toLower(str);
/**
* Converts string, as space separated words, to upper case
* @param {string} str - The string to convert
* @returns {string} Returns the upper cased string
*/
function toUpper(str);Functions for trimming whitespace and padding strings.
/**
* Removes leading and trailing whitespace or specified characters from string
* @param {string} str - The string to trim
* @param {string} chars - The characters to trim
* @returns {string} Returns the trimmed string
*/
function trim(str, chars);
/**
* Removes trailing whitespace or specified characters from string
* @param {string} str - The string to trim
* @param {string} chars - The characters to trim
* @returns {string} Returns the trimmed string
*/
function trimEnd(str, chars);
/**
* Removes leading whitespace or specified characters from string
* @param {string} str - The string to trim
* @param {string} chars - The characters to trim
* @returns {string} Returns the trimmed string
*/
function trimStart(str, chars);
/**
* Pads string on the left and right sides if it's shorter than length
* @param {string} str - The string to pad
* @param {number} length - The padding length
* @param {string} chars - The string used as padding
* @returns {string} Returns the padded string
*/
function pad(str, length, chars);
/**
* Pads string on the right side if it's shorter than length
* @param {string} str - The string to pad
* @param {number} length - The padding length
* @param {string} chars - The string used as padding
* @returns {string} Returns the padded string
*/
function padEnd(str, length, chars);
/**
* Pads string on the left side if it's shorter than length
* @param {string} str - The string to pad
* @param {number} length - The padding length
* @param {string} chars - The string used as padding
* @returns {string} Returns the padded string
*/
function padStart(str, length, chars);Functions for testing string content and boundaries.
/**
* Checks if string ends with the given target string
* @param {string} str - The string to inspect
* @param {string} target - The string to search for
* @param {number} position - The position to search up to
* @returns {boolean} Returns true if string ends with target, else false
*/
function endsWith(str, target, position);
/**
* Checks if string starts with the given target string
* @param {string} str - The string to inspect
* @param {string} target - The string to search for
* @param {number} position - The position to search from
* @returns {boolean} Returns true if string starts with target, else false
*/
function startsWith(str, target, position);Functions for escaping and unescaping special characters.
/**
* Converts the characters "&", "<", ">", '"', and "'" in string to their corresponding HTML entities
* @param {string} str - The string to escape
* @returns {string} Returns the escaped string
*/
function escape(str);
/**
* The inverse of escape; converts HTML entities back to characters
* @param {string} str - The string to unescape
* @returns {string} Returns the unescaped string
*/
function unescape(str);
/**
* Escapes the RegExp special characters "^", "$", "\\", ".", "*", "+", "?", "(", ")", "[", "]", "{", "}", and "|" in string
* @param {string} str - The string to escape
* @returns {string} Returns the escaped string
*/
function escapeRegExp(str);Functions for modifying and transforming strings.
/**
* Deburrs string by converting Latin-1 Supplement and Latin Extended-A letters to basic Latin letters
* @param {string} str - The string to deburr
* @returns {string} Returns the deburred string
*/
function deburr(str);
/**
* Repeats the given string n times
* @param {string} str - The string to repeat
* @param {number} n - The number of times to repeat the string
* @returns {string} Returns the repeated string
*/
function repeat(str, n);
/**
* Replaces matches for pattern in string with replacement
* @param {string} str - The string to modify
* @param {RegExp|string} pattern - The pattern to replace
* @param {Function|string} replacement - The match replacement
* @returns {string} Returns the modified string
*/
function replace(str, pattern, replacement);
/**
* Splits string by separator
* @param {string} str - The string to split
* @param {RegExp|string} separator - The separator pattern to split by
* @param {number} limit - The length to truncate results to
* @returns {Array} Returns the string segments
*/
function split(str, separator, limit);
/**
* Truncates string if it's longer than the given maximum string length
* @param {string} str - The string to truncate
* @param {Object} options - The options object
* @param {number} options.length - The maximum string length
* @param {string} options.omission - The string to indicate text is omitted
* @param {RegExp|string} options.separator - The separator pattern to truncate to
* @returns {string} Returns the truncated string
*/
function truncate(str, options);
/**
* Splits string into an array of its words
* @param {string} str - The string to inspect
* @param {RegExp|string} pattern - The pattern to match words
* @returns {Array} Returns the words of string
*/
function words(str, pattern);Functions for converting strings to other types.
/**
* Converts string to an integer of the specified radix
* @param {string} str - The string to convert
* @param {number} radix - The radix to interpret the value by
* @returns {number} Returns the converted integer
*/
function parseInt(str, radix);Advanced templating functionality for dynamic string generation.
/**
* Creates a compiled template function that can interpolate data properties in "interpolate" delimiters
* @param {string} str - The template string
* @param {Object} options - The options object
* @param {RegExp} options.escape - The HTML "escape" delimiter
* @param {RegExp} options.evaluate - The "evaluate" delimiter
* @param {Object} options.imports - An object to import into the template as free variables
* @param {RegExp} options.interpolate - The "interpolate" delimiter
* @param {string} options.sourceURL - The sourceURL of the template's compiled source
* @param {string} options.variable - The data object variable name
* @returns {Function} Returns the compiled template function
*/
function template(str, options);Configuration object for template function behavior.
/**
* Template settings configuration object
* @type {Object}
* @property {RegExp} escape - Used to detect data property values to be HTML-escaped
* @property {RegExp} evaluate - Used to detect code to be evaluated
* @property {RegExp} interpolate - Used to detect data property values to inject
* @property {string} variable - Used to reference the data object in the template text
* @property {Object} imports - Used to import variables into the compiled template
*/
const templateSettings;import { camelCase, kebabCase, snakeCase, startCase, capitalize } from "lodash-es";
const text = "hello world example";
// Different case conversions
const camelCased = camelCase(text); // "helloWorldExample"
const kebabCased = kebabCase(text); // "hello-world-example"
const snakeCased = snakeCase(text); // "hello_world_example"
const startCased = startCase(text); // "Hello World Example"
const capitalized = capitalize(text); // "Hello world example"
// Converting mixed case strings
const mixedCase = "XMLHttpRequest";
const kebab = kebabCase(mixedCase); // "xml-http-request"
const snake = snakeCase(mixedCase); // "xml_http_request"import { trim, trimStart, trimEnd, pad, padStart, padEnd } from "lodash-es";
const text = " hello world ";
const customTrim = "-_-hello-_-";
// Basic trimming
const trimmed = trim(text); // "hello world"
const trimmedStart = trimStart(text); // "hello world "
const trimmedEnd = trimEnd(text); // " hello world"
// Custom character trimming
const customTrimmed = trim(customTrim, "_-"); // "hello"
// Padding
const shortText = "hi";
const padded = pad(shortText, 10); // " hi "
const paddedStart = padStart(shortText, 5, "0"); // "000hi"
const paddedEnd = padEnd(shortText, 5, "!"); // "hi!!!"import { repeat, replace, split, truncate, words, deburr } from "lodash-es";
// Repeat string
const repeated = repeat("abc", 3); // "abcabcabc"
// Replace text
const text = "Hello world, wonderful world";
const replaced = replace(text, /world/g, "universe"); // "Hello universe, wonderful universe"
// Split string
const sentence = "apple,banana,cherry";
const fruits = split(sentence, ","); // ["apple", "banana", "cherry"]
const limited = split(sentence, ",", 2); // ["apple", "banana"]
// Truncate long text
const longText = "This is a very long sentence that needs to be truncated";
const truncated = truncate(longText, {
length: 30,
omission: "...",
separator: " "
}); // "This is a very long sentence..."
// Extract words
const wordsArray = words("hello world, how are you?"); // ["hello", "world", "how", "are", "you"]
// Remove accents
const accented = "déjà vu café";
const deburred = deburr(accented); // "deja vu cafe"import { startsWith, endsWith } from "lodash-es";
const filename = "document.pdf";
const url = "https://example.com/api/users";
// Test string boundaries
const isPdf = endsWith(filename, ".pdf"); // true
const isHttps = startsWith(url, "https://"); // true
const isApi = startsWith(url, "api", 20); // true (starts at position 20)import { escape, unescape, escapeRegExp } from "lodash-es";
// HTML escaping
const html = '<div class="container">Hello & welcome</div>';
const escaped = escape(html); // "<div class="container">Hello & welcome</div>"
const unescaped = unescape(escaped); // original HTML
// RegExp escaping
const userInput = "How much $ do you have? (in USD)";
const regexSafe = escapeRegExp(userInput); // "How much \\$ do you have\\? \\(in USD\\)"
const regex = new RegExp(regexSafe); // Safe to use in regeximport { template, templateSettings } from "lodash-es";
// Basic templating
const compiled = template("Hello <%= name %>!");
const result = compiled({ name: "Alice" }); // "Hello Alice!"
// Advanced templating with logic
const advancedTemplate = template(`
<% if (users.length) { %>
<ul>
<% users.forEach(function(user) { %>
<li><%- user.name %> (<%- user.age %>)</li>
<% }); %>
</ul>
<% } else { %>
<p>No users found.</p>
<% } %>
`);
const users = [
{ name: "Alice", age: 25 },
{ name: "Bob", age: 30 }
];
const html = advancedTemplate({ users });
// Custom template settings
const customTemplate = template("Hello {{name}}!", {
interpolate: /\{\{([\s\S]+?)\}\}/g
});
const customResult = customTemplate({ name: "World" }); // "Hello World!"