Skip to content

feat: add minBy, maxBy, sumBy, meanBy, string case utils, and zipObject - #392

Merged
ppeeou merged 3 commits into
mainfrom
feat/tier2-utils
Aug 8, 2026
Merged

ppeeou merged 3 commits into
mainfrom
feat/tier2-utils

Conversation

@ppeeou

@ppeeou ppeeou commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

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/average only accept Iterable<number>:

  • maxBy(f, iterable) / minBy(f, iterable): element with the largest/smallest f value; undefined on empty, first element wins ties. Sync/async duals like the rest of the library, with the AsyncFunctionException guard when an async callback is used in a sync context.
  • sumBy(f, iterable) / meanBy(f, iterable): sum/average of mapped values (0 / NaN on empty, matching sum/average semantics).

All four support Iterable/AsyncIterable and 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 get undefined (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

  • Full jest suite passes (136 suites, 1231 tests); compile:check exit 0; lint 0 errors; prettier clean
  • api-extractor/api-documenter pipeline verified to generate the nine English doc pages

🤖 Generated with Claude Code

ppeeou and others added 2 commits August 8, 2026 15:56
…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>
@ppeeou
ppeeou merged commit 57828b8 into main Aug 8, 2026
4 checks passed
@ppeeou
ppeeou deleted the feat/tier2-utils branch August 8, 2026 07:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant