Skip to content

feat(lodash): add sum/mean/sumBy/meanBy/head/last/tail to manifest#966

Merged
proggeramlug merged 1 commit into
mainfrom
feat-lodash-sum-mean-aggregators
May 17, 2026
Merged

feat(lodash): add sum/mean/sumBy/meanBy/head/last/tail to manifest#966
proggeramlug merged 1 commit into
mainfrom
feat-lodash-sum-mean-aggregators

Conversation

@proggeramlug
Copy link
Copy Markdown
Contributor

Summary

  • Adds five new lodash bindings (sum, mean, sumBy, meanBy, tail) to the manifest + NativeModSig table + runtime decls so import _ from 'lodash'; _.sum([...]) (and the other four) compile natively instead of erroring with \lodash.sum` is not implemented in Perry. head/last` were already wired; this batch closes the most common "easy" aggregator gap surfaced by the manifest sweep.
  • New runtime exports in crates/perry-stdlib/src/lodash.rs: js_lodash_sum, js_lodash_mean, js_lodash_sum_by, js_lodash_mean_by (plus a small lodash_to_number helper that mirrors lodash's baseSum undefined-skipping). tail reuses the existing js_lodash_tail runtime — only the manifest + lower_call rows were missing for it.
  • sumBy / meanBy accept the property-shorthand iteratee form only today (_.sumBy(arr, 'n')); function iteratees return NaN to mirror lodash's "unusable iteratee" branch. Closure-call plumbing across the FFI boundary is its own follow-up.

Test plan

  • test-files/test_lodash_sum.ts matches node --experimental-strip-types byte-for-byte: 10 / 2.5 / 3 / 1 / 3.
  • Repro from task spec (_.sum([1,2,3,4,5])15) verified locally.
  • cargo build --release -p perry-runtime -p perry-stdlib -p perry green.
  • CI: lint, cargo-test, parity, compile-smoke, api-docs-drift, security-audit.

Notes

  • The compilePackages: ["lodash"] path is still blocked on a separate module-init TypeError: Cannot read properties of undefined (reading 'prototype') regression that pre-dates this work — reproducible with just _.head([1,2,3]) after enabling compilePackages, so not in scope here. Tested via the standard manifest-route (no compilePackages config).
  • Version bumped to v0.5.979; CHANGELOG entry has the full per-file breakdown.

- New runtime exports js_lodash_sum/_mean/_sum_by/_mean_by in
  perry-stdlib (head/last/tail already existed).
- Manifest rows for sum/mean/sumBy/meanBy/tail (head/last were
  already in the manifest).
- NativeModSig rows for the five new dispatches in lower_call.rs
  (head/last/first already there).
- declare_function decls for the four new symbols (tail already
  declared).
- test-files/test_lodash_sum.ts matches node --experimental-strip-types
  byte-for-byte: 10 / 2.5 / 3 / 1 / 3.

sumBy/meanBy currently accept the property-shorthand iteratee form
only; function iteratees return NaN until closure-call plumbing
across the FFI boundary lands as a follow-up.
@proggeramlug proggeramlug force-pushed the feat-lodash-sum-mean-aggregators branch from 3b195d0 to 3e74e55 Compare May 17, 2026 22:45
@proggeramlug proggeramlug merged commit 978dd30 into main May 17, 2026
5 of 9 checks passed
@proggeramlug proggeramlug deleted the feat-lodash-sum-mean-aggregators branch May 17, 2026 22:46
proggeramlug added a commit that referenced this pull request May 18, 2026
#982)

- New runtime exports js_lodash_max/_min/_max_by/_min_by in
  perry-stdlib (clamp/in_range/random already existed).
- Manifest rows for all seven (max/min/maxBy/minBy/clamp/inRange/random).
- NativeModSig rows for the six new dispatches in lower_call.rs
  (clamp was already there).
- declare_function decls for the four new symbols
  (clamp/in_range/random already declared).
- test-files/test_lodash_max_min.ts matches node --experimental-strip-types
  byte-for-byte: 5 / 1 / { n: 5 } / { n: 1 } / 5 / 0 / 3 / true / false.

maxBy/minBy currently accept the property-shorthand iteratee form only;
function iteratees return undefined until closure-call plumbing across
the FFI boundary lands as a follow-up (same restriction as sumBy/meanBy
from PR #966).
proggeramlug added a commit that referenced this pull request May 18, 2026
PRs #966, #967, #982, #984 added entries to perry-api-manifest::API_MANIFEST
(stream EventEmitter instance methods, stream.prototype, lodash
inRange/max/maxBy/mean/meanBy/min/minBy/random/sum/sumBy/tail) without
rerunning ./scripts/regen_api_docs.sh. Drift has been blocking the
api-docs-drift gate on every subsequent PR; unblocking the next batch.

Coverage moves from 870 → 898 entries across 71 modules. Mechanical
regen, no manifest edits.
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