CodeVetter · Repo Unpack · Feature catalog
lodash/lodash
User-facing surface is the lodash API itself (~300 methods attached to the `lodash` function plus a lazy-evaluating chain wrapper), the `fp` variant, and the four per-method build/doc npm scripts. `fp/_mapping.js` is the declarative feature table that defines the entire FP surface: aliases, arity buckets, rearg orders, spread configs, mutation classes and skip lists. The repo also ships two interactive HTML surfaces — a QUnit test runner with build/loader dropdowns, and a Benchmark.js perf page comparing lodash against Underscore. There is no HTTP API, no routes, and no CLI subcommands; the `lib/*/build-*.js` scripts are the closest thing to commands and take their target directory from the last `process.argv` element.
- The full lodash API is assembled by explicit `lodash.<name> = <fn>` assignment inside `runInContext`, including `lodash.runInContext`, `lodash.VERSION` and the chainable `lodash.prototype.*` sequence methods (`at`, `chain`, `commit`, `next`, `plant`, `reverse`, `toJSON`/`valueOf`/`value`).
- Lazy evaluation is a first-class feature: `LazyWrapper.prototype.clone/reverse/value` are installed and a `realNames` registry maps minified function names back to method names so shortcut fusion survives minification.
- `fp/_mapping.js` declares the FP surface across 12 exported tables — `aliasToReal`, `aryMethod`, `aryRearg`, `iterateeAry`, `iterateeRearg`, `methodRearg`, `methodSpread`, `mutate`, `realToAlias`, `remap`, `skipFixed`, `skipRearg`.
- The FP immutability guarantee is table-driven: `mapping.mutate` classifies mutating methods into `array` (fill, pull*, remove, reverse), `object` (assign*, defaults*, merge*) and `set` (set, setWith, unset, update, updateWith), each wrapped with a different cloner.
- `fp/_convertBrowser.js` self-installs when loaded after lodash in a browser: if a global `_` with `runInContext` exists, it reassigns `_ = browserConvert(_.runInContext())`, converting the page's lodash in place.
- FP conversion is configurable per-call and per-method through five boolean options — `cap`, `curry`, `fixed`, `immutable`, `rearg` — each defaulting to `true`, exposed as `fp.convert({...})` and `fp.someMethod.convert({...})`.
- `npm run build:main-modules <target>` copies `dist/lodash.core.js`, `dist/lodash.core.min.js` and `dist/lodash.min.js` into a target directory as `core.js`, `core.min.js` and `lodash.min.js` — the per-method npm package layout.
- `npm run build:fp-modules <target>` globs the target's existing `*.js` modules (ignoring `_*.js`, `core.js`, `fp.js`, `index.js`, `lodash.js`), adds alias and remap paths, and emits one `fp/<name>.js` per method chosen from four `.jst` templates (`alias`, `category`, `thru`, `module`).
- `npm run doc:fp` renders the public FP-Guide wiki page from `lib/fp/template/doc/wiki.jst`, computing the method lists at build time with helpers `toFuncList` (sorted, chunked by 5) and `toArgOrder` (index permutation → `(a, b, c)` string).
- The QUnit runner page exposes a build selector (lodash dev/prod, lodash-core dev/prod) and a loader selector (none, Curl, Dojo, RequireJS) that rewrite `location.href` query params, letting a human test any build/loader combination in-browser.
- `perf/index.html` plus `perf/perf.js` is a Benchmark.js A/B suite that loads lodash and a comparison library (default Underscore), scores each into `score.a`/`score.b`, and renders output through an embedded Firebug Lite console.
- `test/remove.js` is a small standalone Node utility that takes a `/pattern/flags` string plus a file path and strips matched line groups in place — used to prune generated sources.
- `_.template` is a full templating feature with configurable `escape`/`evaluate`/`interpolate` delimiters and `imports`/`variable`/`sourceURL` options, compiled to a real function via the `Function` constructor.
- `_.runInContext(context)` lets callers swap built-ins: `contextProps` lists the 30 globals (Array, Buffer, Map, Promise, Set, Symbol, WeakMap, setTimeout, …) that get `_.pick`-ed from `root` and defaulted into the supplied context.