Repository navigation
feat: add minBy, maxBy, sumBy, meanBy, string case utils, and zipObject - #392
Merged
Merged
Conversation
…e, capitalize, and zipObject Tier-2 additions selected by per-function npm download demand: - minBy/maxBy: element with the smallest/largest f value, undefined on empty, first element wins ties; Iterable/AsyncIterable duals with the AsyncFunctionException guard for async callbacks in sync context - sumBy/meanBy: sum/average of mapped values (0 / NaN on empty), same sync/async duals and curried pipeline form - camelCase/kebabCase/snakeCase: share one unicode-aware word splitter (case boundaries, acronyms, digit runs) in _internal/words - capitalize: first char upper, rest lower - zipObject: pairs keys with values position by position; missing values become undefined, extra values are ignored Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
A regex literal with the "u" flag and \p{...} escapes is ES2018-only
syntax, so tsc rejected it (TS1501) when emitting the es5-targeted
esm5 build. The RegExp constructor form compiles as plain ES5 syntax;
runtimes without unicode regex support throw only when the string case
functions are actually called.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds nine more utilities selected by per-function npm download demand (lodash.camelcase 50M/wk, lodash.sortby-adjacent aggregation utils, lodash.kebabcase 9M/wk, lodash.capitalize 3.5M/wk), following the conventions of #391.
Aggregation — fills the gap that
max/min/sum/averageonly acceptIterable<number>:maxBy(f, iterable)/minBy(f, iterable): element with the largest/smallestfvalue;undefinedon empty, first element wins ties. Sync/async duals like the rest of the library, with theAsyncFunctionExceptionguard when an async callback is used in a sync context.sumBy(f, iterable)/meanBy(f, iterable): sum/average of mapped values (0/NaNon empty, matchingsum/averagesemantics).All four support
Iterable/AsyncIterableand the curried pipeline form.String — the highest-demand subset of the case utilities:
camelCase,kebabCase,snakeCase: share a single unicode-aware word splitter (_internal/words) that handles case boundaries, acronyms (XMLHttpRequest→xml,Http,Request), and digit runs.capitalize: first character upper, rest lower.Object:
zipObject(keys, values): pairs keys with values position by position; keys without a value getundefined(key still created), extra values are ignored. Literal key unions are preserved (zipObject(["a", "b"] as const, ...)→Record<"a" | "b", ...>).Each function ships with jest specs (44 new tests), type-check tests, index registration, function.json entries, and ko/ja/zh docs pages.
Test plan
compile:checkexit 0; lint 0 errors; prettier clean🤖 Generated with Claude Code