feat(stdlib): add immutable array ops, deep set, and isEqual comparator
Adds arrays/{move,insert,swap,remove}, collections/set, and comparators/isEqual (NaN/Date/RegExp/Map/Set/cycle-safe), wired into the barrels.
This commit is contained in:
@@ -31,7 +31,7 @@ export function levenshteinDistance(left: string, right: string): number {
|
||||
|
||||
for (let j = 1; j <= innerLength; j++) {
|
||||
const cost = outerChar === inner[j - 1] ? 0 : 1;
|
||||
current[j]! = Math.min(
|
||||
current[j] = Math.min(
|
||||
prev[j]! + 1, // insertion
|
||||
current[j - 1]! + 1, // deletion
|
||||
prev[j - 1]! + cost, // substitution
|
||||
|
||||
@@ -15,7 +15,7 @@ export type TemplateFallback = string | ((key: string) => string);
|
||||
/**
|
||||
* Type of a template string with placeholders.
|
||||
*/
|
||||
const TEMPLATE_PLACEHOLDER = /\{\s*([^{}]+?)\s*\}/gm;
|
||||
const TEMPLATE_PLACEHOLDER = /\{([^{}]+)\}/g;
|
||||
|
||||
/**
|
||||
* Removes the placeholder syntax from a template string.
|
||||
@@ -82,8 +82,8 @@ export function templateObject<
|
||||
T extends string,
|
||||
A extends GenerateTypes<ExtractPlaceholders<T>, TemplateValue> & Collection,
|
||||
>(template: T, args: A, fallback?: TemplateFallback): string {
|
||||
return template.replace(TEMPLATE_PLACEHOLDER, (_match, key: string) => {
|
||||
const value = get(args, key);
|
||||
return template.replaceAll(TEMPLATE_PLACEHOLDER, (_match, key: string) => {
|
||||
const value = get(args, key.trim());
|
||||
|
||||
if (value !== null && value !== undefined)
|
||||
return String(value);
|
||||
|
||||
Reference in New Issue
Block a user