{"id":21522191,"url":"https://github.com/greguz/mutent-array","last_synced_at":"2026-01-26T03:31:33.497Z","repository":{"id":91913566,"uuid":"317170185","full_name":"greguz/mutent-array","owner":"greguz","description":"Simple array adapter for mutent","archived":false,"fork":false,"pushed_at":"2024-08-08T15:17:41.000Z","size":55,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-09T11:31:50.922Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/greguz.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}},"created_at":"2020-11-30T09:17:39.000Z","updated_at":"2024-08-08T15:17:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"263118ea-7038-4420-a218-32ec6c2ac4db","html_url":"https://github.com/greguz/mutent-array","commit_stats":{"total_commits":18,"total_committers":1,"mean_commits":18.0,"dds":0.0,"last_synced_commit":"aaadc0258e35977cfbb319ade04daddcc479e677"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/greguz/mutent-array","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/greguz%2Fmutent-array","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/greguz%2Fmutent-array/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/greguz%2Fmutent-array/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/greguz%2Fmutent-array/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/greguz","download_url":"https://codeload.github.com/greguz/mutent-array/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/greguz%2Fmutent-array/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28765895,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-26T03:19:35.311Z","status":"ssl_error","status_checked_at":"2026-01-26T03:19:13.815Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2024-11-24T01:09:33.414Z","updated_at":"2026-01-26T03:31:33.482Z","avatar_url":"https://github.com/greguz.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mutent-array\n\n[![npm](https://img.shields.io/npm/v/mutent-array)](https://www.npmjs.com/package/mutent-array)\n[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n[![ci](https://github.com/greguz/mutent-array/actions/workflows/ci.yaml/badge.svg?branch=master)](https://github.com/greguz/mutent-array/actions/workflows/ci.yaml)\n[![Coverage Status](https://coveralls.io/repos/github/greguz/mutent-array/badge.svg?branch=master)](https://coveralls.io/github/greguz/mutent-array?branch=master)\n\nSimple in memory (array) Adapter for [Mutent](https://github.com/greguz/mutent).\n\n## Features\n\n- MongoDB-like queries (see [mql-match](https://github.com/greguz/mql-match) for more info)\n- Raw predicate function support (for maximum freedom)\n- Lost-update detection and recovery\n- Lost-delete detection\n- Source array access with `raw` property\n- Native TypeScript support \n\n## API\n\n### `new ArrayAdapter([options])`\n\nClass constructor.\n\n- `[options]: \u003cObject\u003e`\n  - `[items]: \u003cIterable\u003e` Initialize the internal array. Accepts any **sync** iterable. If It's an array, It will be used directly (adapter will change the array).\n  - `[onLostUpdate]: \u003cString\u003e` See [`onLostUpdate`](#onlostupdate) chapter.\n  - `[onLostDelete]: \u003cString\u003e` See [`onLostUpdate`](#onlostdelete) chapter.\n\n### `ArrayAdapter::raw`\n\nReturns (property) the raw array used internally by the Adapter.\n\n## Unwrap options\n\n### `onLostUpdate`\n\nConfigures the action to do when a lost-update is detected.\n\nA lost-update occours when someone is referencing a particular item inside the array to update, but that item is not present during the actual write.\n\nCan be `\"ERROR\"`, `\"IGNORE\"`, or `\"CREATE\"`:\n- `\"ERROR\"`: Throws an error.\n- `\"IGNORE\"`: Do nothing.\n- `\"CREATE\"`: Create the item instead.\n\nThis option can be specified both from the `ArrayAdapter` constructor, or as unwrap option (takes the precedence).\n\nDefaults to `\"ERROR\"`.\n\n### `onLostDelete`\n\nConfigures the action to do when a lost-delete is detected.\n\nA lost-delete with the same condition of a lost-update, but within a delete request.\n\nCan be `\"ERROR\"` or `\"IGNORE\"`.\n- `\"ERROR\"`: Throws an error.\n- `\"IGNORE\"`: Do nothing.\n\nThis option can be specified both from the `ArrayAdapter` constructor, or as unwrap option (takes the precedence).\n\nDefaults to `\"IGNORE\"`.\n\n## Example\n\n```javascript\nimport { Store } from 'mutent'\nimport ArrayAdapter from 'mutent-array'\n\nconst db = new Store({\n  adapter: new ArrayAdapter({\n    items: [\n      { id: 0, name: 'Piccolo', power: 329 },\n      { id: 1, name: 'Krillin', power: 206 },\n      { id: 2, name: 'Turtle', power: 0.001 },\n      { id: 3, name: 'Bubbles', power: 1000 },\n      { id: 4, name: 'Vegeta', power: 18000 }\n    ],\n    onLostUpdate: 'ERROR',\n    onLostDelete: 'IGNORE'\n  })\n})\n\n// 5\nconsole.log(db.raw.length)\n\nconst strong = await db.filter({ power: { $gte: 1000 } })\n  .unwrap()\n\n// Bubbles and Vegeta\nconsole.log(strong)\n\nawait db.find({ name: 'Krillin' })\n  .delete()\n  .consume()\n\n// 4\nconsole.log(db.raw.length)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgreguz%2Fmutent-array","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgreguz%2Fmutent-array","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgreguz%2Fmutent-array/lists"}