{"id":20930331,"url":"https://github.com/jmlweb/mochila","last_synced_at":"2026-01-27T16:05:52.448Z","repository":{"id":204791623,"uuid":"711170985","full_name":"jmlweb/mochila","owner":"jmlweb","description":"Your Lightweight Travel Companion for TypeScript Programming","archived":false,"fork":false,"pushed_at":"2024-08-30T21:32:23.000Z","size":1398,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-13T19:32:24.419Z","etag":null,"topics":["functional-programming","typescript","utils"],"latest_commit_sha":null,"homepage":"https://jmlweb.github.io/mochila/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jmlweb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-10-28T12:28:11.000Z","updated_at":"2024-08-30T21:31:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"9111335f-5daa-46fd-a176-2727969ecd43","html_url":"https://github.com/jmlweb/mochila","commit_stats":{"total_commits":37,"total_committers":2,"mean_commits":18.5,"dds":0.1351351351351351,"last_synced_commit":"3d7daf8d5c91b9c6316c8c5dded9ea4cbf004871"},"previous_names":["jmlweb/mochila"],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/jmlweb/mochila","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmlweb%2Fmochila","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmlweb%2Fmochila/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmlweb%2Fmochila/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmlweb%2Fmochila/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jmlweb","download_url":"https://codeload.github.com/jmlweb/mochila/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmlweb%2Fmochila/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272793018,"owners_count":24993830,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-30T02:00:09.474Z","response_time":77,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["functional-programming","typescript","utils"],"created_at":"2024-11-18T21:32:01.933Z","updated_at":"2026-01-27T16:05:52.442Z","avatar_url":"https://github.com/jmlweb.png","language":"TypeScript","readme":"# 🎒 Mochila\n\nYour Lightweight Travel Companion for TypeScript Programming\n\n[![npm version](https://img.shields.io/npm/v/mochila-ts)](https://www.npmjs.com/package/mochila-ts)\n[![CI](https://img.shields.io/github/actions/workflow/status/jmlweb/mochila/test.yml)](https://github.com/jmlweb/mochila)\n[![Coverage](https://img.shields.io/badge/coverage-95%25-brightgreen)](./jest.config.js)\n[![TypeScript](https://img.shields.io/badge/TypeScript-5.0%2B-blue)](https://www.typescriptlang.org/)\n\n**79+ composable TypeScript utilities** using a data-last curried pattern for seamless function composition.\n\n[Documentation](https://jmlweb.github.io/mochila/modules.html) • [GitHub](https://github.com/jmlweb/mochila) • [Contributing](./DEVELOPMENT.md)\n\n## Table of Contents\n\n- [Philosophy](#philosophy)\n- [Quick Start](#quick-start)\n- [Key Features](#key-features)\n- [Utilities Overview](#utilities-overview)\n- [Advanced Examples](#advanced-examples)\n- [Installation](#installation)\n- [Resources](#resources)\n\n## Philosophy\n\nAt the core of Mochila's philosophy is the commitment to a **\"data last\" approach** in writing functions. This design choice enables easy composition of functions using our internal `pipe` utility.\n\nAdditionally, Mochila embraces **currying** when necessary, allowing functions to be conveniently partially applied. This flexibility enhances the overall usability of the toolkit.\n\n**Benefits:**\n- ✅ **Composable**: Chain operations naturally with `pipe()` and `flow()`\n- ✅ **Reusable**: Partial application for configurable function factories\n- ✅ **Type-Safe**: Full generic support with proper type inference\n- ✅ **Chainable**: Works seamlessly with function composition patterns\n\n```typescript\nimport { length, multiply, pipe } from 'mochila-ts';\n\nconst doubleLength = pipe(length, multiply(2));\n\ndoubleLength([1, 2, 3]); // 6\ndoubleLength('abc'); // 6\n```\n\n## Quick Start\n\n```typescript\nimport { pipe, filter, map, sort, ascending } from 'mochila-ts';\n\n// Compose utilities into a processing pipeline\nconst processNumbers = pipe(\n  filter((x: number) =\u003e x \u003e 0),\n  map((x: number) =\u003e x * 2),\n  sort(ascending)\n);\n\nprocessNumbers([-2, 1, 3, -1, 2]); // [2, 4, 6]\n\n// Partial application for reuse\nconst filterEven = filter((x: number) =\u003e x % 2 === 0);\nfilterEven([1, 2, 3, 4]); // [2, 4]\n```\n\n## Key Features\n\n### 🎯 Type-Safe Composition\n- Full TypeScript support with 95%+ type coverage\n- Type guards with type narrowing (`isArray`, `isString`, etc.)\n- Generic constraints maintain type safety in composition chains\n\n### ⚡ Advanced Utilities\n- **LRUCache**: Configurable caching with TTL and max size\n- **Debounce/Throttle**: Function rate-limiting utilities\n- **Deep Equality**: Circular reference protection with WeakMap\n- **Array Operations**: 34+ array manipulation utilities\n- **Object/String Manipulation**: Pick, omit, split, replace, and more\n\n### 🔧 Function Utilities\n- `pipe()`: Compose functions with full type inference (up to 9 overloads)\n- `flow()`: Function composition in reverse order\n- `protect()`: Safe function execution\n- `debounce()` \u0026 `throttle()`: Rate-limiting decorators\n\n```typescript\nimport { LRUCache } from 'mochila-ts';\n\nconst cache = LRUCache({\n  max: 100,\n  ttl: 1000 * 60 * 60 * 24, // 24 hours\n});\n\ncache.set('key', 'value');\ncache.get('key'); // 'value'\n```\n\n## Utilities Overview\n\n**79+ utilities** organized by category:\n\n| Category | Count | Examples |\n|----------|-------|----------|\n| Array | 34 | `append, at, chunkify` +31 more |\n| String | 10 | `capitalize, endsWith, join` +7 more |\n| Object | 7 | `keys, mapObject, omit` +4 more |\n| Function | 9 | `complement, constant, debounce` +6 more |\n| Utility | 7 | `castArray, clone, deepClone` +4 more |\n| Logic | 3 | `every, none, some` |\n| Number | 4 | `add, clamp, divide` +1 more |\n| Assertion | 3 | `assert, deepEqual, equal` |\n| Type Guard | 1 | `is` |\n\nAll utilities follow the **data-last curried pattern** for maximum composability. See the [full API documentation](https://jmlweb.github.io/mochila/modules.html) for detailed usage.\n\n## Advanced Examples\n\n### Complex Data Transformation Pipeline\n\n```typescript\nimport { pipe, filter, map, groupBy, mapObject, sort, descending } from 'mochila-ts';\n\ninterface User {\n  id: number;\n  name: string;\n  age: number;\n  active: boolean;\n}\n\nconst processUsers = pipe(\n  filter((u: User) =\u003e u.active),\n  map((u: User) =\u003e ({ ...u, ageGroup: Math.floor(u.age / 10) * 10 })),\n  groupBy((u: User \u0026 { ageGroup: number }) =\u003e u.ageGroup),\n  mapObject((users: (User \u0026 { ageGroup: number })[]) =\u003e users.length)\n);\n\nconst users = [\n  { id: 1, name: 'Alice', age: 28, active: true },\n  { id: 2, name: 'Bob', age: 35, active: false },\n  { id: 3, name: 'Charlie', age: 22, active: true },\n];\n\nprocessUsers(users); // { '20': 1, '30': 1 }\n```\n\n### Type-Safe Type Guards in Action\n\n```typescript\nimport { pipe, filter, map } from 'mochila-ts';\nimport { isString, isNumber } from 'mochila-ts';\n\nconst data: unknown[] = [1, 'hello', 2, 'world', null];\n\nconst processStrings = pipe(\n  filter(isString), // Narrows type to string[]\n  map((s: string) =\u003e s.toUpperCase()) // ✓ Type-safe\n);\n\nprocessStrings(data); // ['HELLO', 'WORLD']\n```\n\n### Caching with TTL\n\n```typescript\nimport { pipe, map, LRUCache } from 'mochila-ts';\n\nconst expensiveComputation = (n: number) =\u003e n * n;\n\nconst cache = LRUCache({\n  max: 50,\n  ttl: 5000, // 5 second TTL\n});\n\nconst cachedCompute = (n: number) =\u003e {\n  const cached = cache.get(String(n));\n  if (cached !== undefined) return cached;\n\n  const result = expensiveComputation(n);\n  cache.set(String(n), result);\n  return result;\n};\n\n// First call: computes\ncachedCompute(5); // 25\n\n// Second call: returns from cache\ncachedCompute(5); // 25 (cached)\n```\n\n## Installation\n\n**Requirements:**\n- Node.js 20+\n- pnpm 9+\n\n```bash\nnpm install mochila-ts\n# or\nyarn add mochila-ts\n# or\npnpm add mochila-ts\n```\n\nAll utilities are exposed as named exports:\n\n```typescript\nimport { pipe, filter, map } from 'mochila-ts';\n```\n\n## Resources\n\n- **[API Documentation](https://jmlweb.github.io/mochila/modules.html)** - Complete API reference with examples\n- **[Development Guide](./DEVELOPMENT.md)** - Architecture and contribution guidelines\n- **[GitHub Repository](https://github.com/jmlweb/mochila)** - Source code and issue tracker\n- **[NPM Package](https://www.npmjs.com/package/mochila-ts)** - Installation and package info\n\n---\n\nMade with ❤️ for TypeScript developers who value composition and type safety.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmlweb%2Fmochila","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjmlweb%2Fmochila","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmlweb%2Fmochila/lists"}