# jashkenas/underscore architecture

> Architecture diagram of the GitHub repository jashkenas/underscore, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jashkenas/underscore
- Repository: https://github.com/jashkenas/underscore

## Overview

Underscore.js is a JavaScript utility library for functional operations on collections and objects, with no core-object extensions. A consumer enters through the package’s module exports and uses collection, array, object, type-checking, functional, or template helpers; the library returns computed values or callbacks. The graph groups related APIs rather than listing every helper. Internal edges are limited to relationships visible in excerpts or source-index references; unsampled implementation details are not inferred.

Main entry points: [`modules/index.js`](https://github.com/jashkenas/underscore/blob/master/modules/index.js) (Named exports), [`modules/isEqual.js`](https://github.com/jashkenas/underscore/blob/master/modules/isEqual.js) (Deep equality), [`modules/allKeys.js`](https://github.com/jashkenas/underscore/blob/master/modules/allKeys.js) (Object operations), [`modules/isDataView.js`](https://github.com/jashkenas/underscore/blob/master/modules/isDataView.js) (Type checks)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Public API"]
  node_api["Named exports<br/>[index.js]"]
  node_oop["OOP wrapper<br/>[underscore.js]"]
end

subgraph group_collections["Collection Operations"]
  node_iter["Collection iteration<br/>[map.js]"]
  node_aggregate["Collection aggregation<br/>[groupBy.js]"]
  node_array["Array operations<br/>[uniq.js]"]
end

subgraph group_objects["Objects and Types"]
  node_object["Object operations<br/>[allKeys.js]"]
  node_deep["Deep equality<br/>[isEqual.js]"]
  node_typechecks["Type checks<br/>[isDataView.js]"]
  node_setup["Runtime setup<br/>[_setup.js]"]
  node_propertykeys["Property-key compatibility"]
end

subgraph group_functions["Function Utilities"]
  node_callables["Function helpers<br/>[partial.js]"]
  node_timing["Timing helpers<br/>[debounce.js]"]
end

subgraph group_utilities["Utilities and Templates"]
  node_template["Template compiler<br/>[template.js]"]
  node_templatecfg["Template settings"]
  node_argument["Argument adapter<br/>[restArguments.js]"]
end

node_consumer(("Library consumer"))

node_consumer -->|"uses exports"| node_api
node_api -->|"exports"| node_iter
node_api -->|"exports"| node_aggregate
node_api -->|"exports"| node_array
node_api -->|"exports"| node_object
node_api -->|"exports"| node_deep
node_api -->|"exports"| node_typechecks
node_api -->|"exports"| node_callables
node_api -->|"exports"| node_timing
node_api -->|"exports"| node_template
node_api -->|"exports"| node_oop
node_object -->|"collects keys"| node_propertykeys
node_deep -->|"checks type"| node_typechecks
node_deep -->|"reads keys"| node_object
node_typechecks -->|"uses setup"| node_setup
node_propertykeys -->|"uses setup"| node_setup
node_template -->|"loads settings"| node_templatecfg
node_timing -->|"wraps arguments"| node_argument

click node_api "https://github.com/jashkenas/underscore/blob/master/modules/index.js"
click node_oop "https://github.com/jashkenas/underscore/blob/master/modules/underscore.js"
click node_iter "https://github.com/jashkenas/underscore/blob/master/modules/map.js"
click node_aggregate "https://github.com/jashkenas/underscore/blob/master/modules/groupBy.js"
click node_array "https://github.com/jashkenas/underscore/blob/master/modules/uniq.js"
click node_object "https://github.com/jashkenas/underscore/blob/master/modules/allKeys.js"
click node_deep "https://github.com/jashkenas/underscore/blob/master/modules/isEqual.js"
click node_typechecks "https://github.com/jashkenas/underscore/blob/master/modules/isDataView.js"
click node_setup "https://github.com/jashkenas/underscore/blob/master/modules/_setup.js"
click node_propertykeys "https://github.com/jashkenas/underscore/blob/master/modules/_collectNonEnumProps.js"
click node_callables "https://github.com/jashkenas/underscore/blob/master/modules/partial.js"
click node_timing "https://github.com/jashkenas/underscore/blob/master/modules/debounce.js"
click node_template "https://github.com/jashkenas/underscore/blob/master/modules/template.js"
click node_templatecfg "https://github.com/jashkenas/underscore/blob/master/modules/templateSettings.js"
click node_argument "https://github.com/jashkenas/underscore/blob/master/modules/restArguments.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_api,node_oop toneBlue
class node_iter,node_aggregate,node_array toneAmber
class node_object,node_deep,node_typechecks,node_setup,node_propertykeys toneMint
class node_callables,node_timing toneRose
class node_template,node_templatecfg,node_argument,node_consumer toneIndigo
```

## Components

### Public API

- [Named exports](https://github.com/jashkenas/underscore/blob/master/modules/index.js): `modules/index.js`
- [OOP wrapper](https://github.com/jashkenas/underscore/blob/master/modules/underscore.js): `modules/underscore.js`

### Collection Operations

- [Collection iteration](https://github.com/jashkenas/underscore/blob/master/modules/map.js): `modules/map.js`
- [Collection aggregation](https://github.com/jashkenas/underscore/blob/master/modules/groupBy.js): `modules/groupBy.js`
- [Array operations](https://github.com/jashkenas/underscore/blob/master/modules/uniq.js): `modules/uniq.js`

### Objects and Types

- [Object operations](https://github.com/jashkenas/underscore/blob/master/modules/allKeys.js): `modules/allKeys.js`
- [Deep equality](https://github.com/jashkenas/underscore/blob/master/modules/isEqual.js): `modules/isEqual.js`
- [Type checks](https://github.com/jashkenas/underscore/blob/master/modules/isDataView.js): `modules/isDataView.js`
- [Runtime setup](https://github.com/jashkenas/underscore/blob/master/modules/_setup.js): `modules/_setup.js`
- [Property-key compatibility](https://github.com/jashkenas/underscore/blob/master/modules/_collectNonEnumProps.js): `modules/_collectNonEnumProps.js`

### Function Utilities

- [Function helpers](https://github.com/jashkenas/underscore/blob/master/modules/partial.js): `modules/partial.js`
- [Timing helpers](https://github.com/jashkenas/underscore/blob/master/modules/debounce.js): `modules/debounce.js`

### Utilities and Templates

- [Template compiler](https://github.com/jashkenas/underscore/blob/master/modules/template.js): `modules/template.js`
- [Template settings](https://github.com/jashkenas/underscore/blob/master/modules/templateSettings.js): `modules/templateSettings.js`
- [Argument adapter](https://github.com/jashkenas/underscore/blob/master/modules/restArguments.js): `modules/restArguments.js`

### Other components

- **Library consumer**

## Connections

- Library consumer → Named exports: uses exports
- Named exports → Collection iteration: exports (evidence: `modules/index.js`)
- Named exports → Collection aggregation: exports (evidence: `modules/index.js`)
- Named exports → Array operations: exports (evidence: `modules/index.js`)
- Named exports → Object operations: exports (evidence: `modules/index.js`)
- Named exports → Deep equality: exports (evidence: `modules/index.js`)
- Named exports → Type checks: exports (evidence: `modules/index.js`)
- Named exports → Function helpers: exports (evidence: `modules/index.js`)
- Named exports → Timing helpers: exports (evidence: `modules/index.js`)
- Named exports → Template compiler: exports (evidence: `modules/index.js`)
- Named exports → OOP wrapper: exports (evidence: `modules/index.js`)
- Object operations → Property-key compatibility: collects keys (evidence: `modules/allKeys.js`)
- Deep equality → Type checks: checks type (evidence: `modules/isEqual.js`)
- Deep equality → Object operations: reads keys (evidence: `modules/isEqual.js`)
- Type checks → Runtime setup: uses setup (evidence: `modules/isDataView.js`)
- Property-key compatibility → Runtime setup: uses setup (evidence: `modules/_collectNonEnumProps.js`)
- Template compiler → Template settings: loads settings (evidence: `modules/template.js`)
- Timing helpers → Argument adapter: wraps arguments (evidence: `modules/debounce.js`)
