{"id":15686522,"url":"https://github.com/ljharb/mock-property","last_synced_at":"2025-09-25T01:31:04.559Z","repository":{"id":57687520,"uuid":"481827066","full_name":"ljharb/mock-property","owner":"ljharb","description":"Given an object and a property, replaces a property descriptor (or deletes it), and returns a thunk to restore it.","archived":false,"fork":false,"pushed_at":"2024-08-22T19:34:05.000Z","size":81,"stargazers_count":8,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-02T20:51:47.122Z","etag":null,"topics":["define","delete","descriptor","mock","object","property","test","testing","value"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ljharb.png","metadata":{"funding":{"github":["ljharb"],"patreon":null,"open_collective":null,"ko_fi":"ljharb","tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"polar":null,"buy_me_a_coffee":null,"thanks_dev":"ljharb","custom":null},"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","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":"2022-04-15T03:38:56.000Z","updated_at":"2024-08-22T19:34:08.000Z","dependencies_parsed_at":"2022-08-25T17:53:47.011Z","dependency_job_id":"664b104c-6429-47d3-8208-06d831540ef1","html_url":"https://github.com/ljharb/mock-property","commit_stats":{"total_commits":38,"total_committers":1,"mean_commits":38.0,"dds":0.0,"last_synced_commit":"c8f6ee4a0f1ca8e426789b6614ed983f82e66089"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ljharb%2Fmock-property","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ljharb%2Fmock-property/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ljharb%2Fmock-property/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ljharb%2Fmock-property/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ljharb","download_url":"https://codeload.github.com/ljharb/mock-property/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234143355,"owners_count":18786140,"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","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":["define","delete","descriptor","mock","object","property","test","testing","value"],"created_at":"2024-10-03T17:40:30.534Z","updated_at":"2025-09-25T01:30:59.292Z","avatar_url":"https://github.com/ljharb.png","language":"JavaScript","funding_links":["https://github.com/sponsors/ljharb","https://ko-fi.com/ljharb","https://thanks.dev/ljharb","https://tidelift.com/security"],"categories":[],"sub_categories":[],"readme":"# mock-property \u003csup\u003e[![Version Badge][npm-version-svg]][package-url]\u003c/sup\u003e\n\n[![github actions][actions-image]][actions-url]\n[![coverage][codecov-image]][codecov-url]\n[![dependency status][deps-svg]][deps-url]\n[![dev dependency status][dev-deps-svg]][dev-deps-url]\n[![License][license-image]][license-url]\n[![Downloads][downloads-image]][downloads-url]\n\n[![npm badge][npm-badge-png]][package-url]\n\nGiven an object and a property, replaces a property descriptor (or deletes it), and returns a thunk to restore it.\n\n## Example\n\n```js\nvar mockProperty = require('mock-property');\nvar assert = require('assert');\n\nvar i = 0;\nvar object = {\n\ta: 1,\n\tget b() {\n\t\ti += 1;\n\t\treturn 'b ' + i;\n\t}\n};\n\nassert.equal(object.a, 1);\nassert.equal(object.b, 'b 1');\nassert.equal(object.b, 'b 2');\n\nvar restoreA = mockProperty(object, 'a', { 'delete': true });\nassert.equal('a' in object, false);\n\nvar restoreB = mockProperty(object, 'b', { value: 42 });\nassert.equal(object.b, 42);\n\nrestoreA();\nassert.equal('a' in object, true);\n\nrestoreB();\nassert.equal(object.b, 'b 3');\n```\n\n## Tests\nSimply clone the repo, `npm install`, and run `npm test`\n\n## Security\n\nPlease email [@ljharb](https://github.com/ljharb) or see https://tidelift.com/security if you have a potential security vulnerability to report.\n\n[package-url]: https://npmjs.org/package/mock-property\n[npm-version-svg]: https://versionbadg.es/ljharb/mock-property.svg\n[deps-svg]: https://david-dm.org/ljharb/mock-property.svg\n[deps-url]: https://david-dm.org/ljharb/mock-property\n[dev-deps-svg]: https://david-dm.org/ljharb/mock-property/dev-status.svg\n[dev-deps-url]: https://david-dm.org/ljharb/mock-property#info=devDependencies\n[npm-badge-png]: https://nodei.co/npm/mock-property.png?downloads=true\u0026stars=true\n[license-image]: https://img.shields.io/npm/l/mock-property.svg\n[license-url]: LICENSE\n[downloads-image]: https://img.shields.io/npm/dm/mock-property.svg\n[downloads-url]: https://npm-stat.com/charts.html?package=mock-property\n[codecov-image]: https://codecov.io/gh/ljharb/mock-property/branch/main/graphs/badge.svg\n[codecov-url]: https://app.codecov.io/gh/ljharb/mock-property/\n[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/ljharb/mock-property\n[actions-url]: https://github.com/ljharb/mock-property/actions\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fljharb%2Fmock-property","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fljharb%2Fmock-property","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fljharb%2Fmock-property/lists"}