{"_id":"mock-property","_rev":"305044","name":"mock-property","description":"Given an object and a property, replaces a property descriptor (or deletes it), and returns a thunk to restore it.","dist-tags":{"latest":"1.0.3"},"maintainers":[{"name":"ljharb","email":""}],"time":{"modified":"2024-02-17T15:43:34.000Z","created":"2022-04-16T21:44:26.297Z","1.0.3":"2023-10-21T05:41:24.136Z","1.0.2":"2023-10-11T23:19:58.045Z","1.0.1":"2023-10-11T23:19:37.030Z","1.0.0":"2022-04-16T21:44:26.297Z"},"users":{},"author":{"name":"Jordan Harband","email":"ljharb@gmail.com"},"repository":{"type":"git","url":"git+https://github.com/ljharb/mock-property.git"},"versions":{"1.0.3":{"name":"mock-property","version":"1.0.3","description":"Given an object and a property, replaces a property descriptor (or deletes it), and returns a thunk to restore it.","main":"index.js","exports":{".":"./index.js","./package.json":"./package.json"},"scripts":{"prepack":"npmignore --auto --commentLines=autogenerated","prepublish":"not-in-publish || npm run prepublishOnly","prepublishOnly":"safe-publish-latest","prelint":"evalmd README.md","lint":"eslint --ext=.js,.mjs .","pretest":"npm run lint","tests-only":"nyc tape 'test/**/*.js'","test":"npm run tests-only","posttest":"aud --production","version":"auto-changelog && git add CHANGELOG.md","postversion":"auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\""},"repository":{"type":"git","url":"git+https://github.com/ljharb/mock-property.git"},"keywords":["testing","mock","object","property","value","descriptor","test","delete","define"],"author":{"name":"Jordan Harband","email":"ljharb@gmail.com"},"funding":{"url":"https://github.com/sponsors/ljharb"},"license":"MIT","bugs":{"url":"https://github.com/ljharb/mock-property/issues"},"homepage":"https://github.com/ljharb/mock-property#readme","devDependencies":{"@ljharb/eslint-config":"^21.1.0","aud":"^2.0.3","auto-changelog":"^2.4.0","es-value-fixtures":"^1.4.2","eslint":"=8.8.0","evalmd":"^0.0.19","for-each":"^0.3.3","in-publish":"^2.0.1","npmignore":"^0.3.0","nyc":"^10.3.2","object-inspect":"^1.13.1","safe-publish-latest":"^2.0.0","tape":"^5.7.2"},"dependencies":{"define-data-property":"^1.1.1","functions-have-names":"^1.2.3","gopd":"^1.0.1","has-property-descriptors":"^1.0.0","hasown":"^2.0.0","isarray":"^2.0.5"},"engines":{"node":">= 0.4"},"testling":{"files":"test/index.js"},"auto-changelog":{"output":"CHANGELOG.md","template":"keepachangelog","unreleased":false,"commitLimit":false,"backfillLimit":false,"hideCredit":true},"publishConfig":{"ignore":[".github/workflows"]},"_id":"mock-property@1.0.3","gitHead":"e9535fc5f87baf5252f1ddb801560cec7f57fa42","_nodeVersion":"21.0.0","_npmVersion":"10.2.0","dist":{"shasum":"3e37c50a56609d548cabd56559fde3dd8767b10c","size":8465,"noattachment":false,"key":"/mock-property/-/mock-property-1.0.3.tgz","tarball":"http://name.csiicloud.com:7001/mock-property/download/mock-property-1.0.3.tgz"},"_npmUser":{"name":"ljharb","email":"ljharb@gmail.com"},"directories":{},"maintainers":[{"name":"ljharb","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mock-property_1.0.3_1697866883926_0.8203307067606296"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2023-10-21T05:41:24.136Z","publish_time":1697866884136,"_source_registry_name":"default","_cnpm_publish_time":1697866884136},"1.0.2":{"name":"mock-property","version":"1.0.2","description":"Given an object and a property, replaces a property descriptor (or deletes it), and returns a thunk to restore it.","main":"index.js","exports":{".":"./index.js","./package.json":"./package.json"},"scripts":{"prepack":"npmignore --auto --commentLines=autogenerated","prepublish":"not-in-publish || npm run prepublishOnly","prepublishOnly":"safe-publish-latest","prelint":"evalmd README.md","lint":"eslint --ext=.js,.mjs .","pretest":"npm run lint","tests-only":"nyc tape 'test/**/*.js'","test":"npm run tests-only","posttest":"aud --production","version":"auto-changelog && git add CHANGELOG.md","postversion":"auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\""},"repository":{"type":"git","url":"git+https://github.com/ljharb/mock-property.git"},"keywords":["testing","mock","object","property","value","descriptor","test","delete","define"],"author":{"name":"Jordan Harband","email":"ljharb@gmail.com"},"funding":{"url":"https://github.com/sponsors/ljharb"},"license":"MIT","bugs":{"url":"https://github.com/ljharb/mock-property/issues"},"homepage":"https://github.com/ljharb/mock-property#readme","devDependencies":{"@ljharb/eslint-config":"^21.1.0","aud":"^2.0.3","auto-changelog":"^2.4.0","es-value-fixtures":"^1.4.2","eslint":"=8.8.0","evalmd":"^0.0.19","for-each":"^0.3.3","in-publish":"^2.0.1","npmignore":"^0.3.0","nyc":"^10.3.2","object-inspect":"^1.12.3","safe-publish-latest":"^2.0.0","tape":"^5.7.1"},"dependencies":{"define-data-property":"^1.1.0","functions-have-names":"^1.2.3","gopd":"^1.0.1","has":"^1.0.3","has-property-descriptors":"^1.0.0","isarray":"^2.0.5"},"engines":{"node":">= 0.4"},"testling":{"files":"test/index.js"},"auto-changelog":{"output":"CHANGELOG.md","template":"keepachangelog","unreleased":false,"commitLimit":false,"backfillLimit":false,"hideCredit":true},"publishConfig":{"ignore":[".github/workflows"]},"_id":"mock-property@1.0.2","gitHead":"5ab9340d268cccecf41511be8841af9355cb3534","_nodeVersion":"20.8.0","_npmVersion":"10.1.0","dist":{"shasum":"82791adffeebbda94705a48cab267586d2e0508a","size":8218,"noattachment":false,"key":"/mock-property/-/mock-property-1.0.2.tgz","tarball":"http://name.csiicloud.com:7001/mock-property/download/mock-property-1.0.2.tgz"},"_npmUser":{"name":"ljharb","email":"ljharb@gmail.com"},"directories":{},"maintainers":[{"name":"ljharb","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mock-property_1.0.2_1697066397896_0.48424271132143293"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2023-10-11T23:19:58.045Z","publish_time":1697066398045,"_source_registry_name":"default","_cnpm_publish_time":1697066398045},"1.0.1":{"name":"mock-property","version":"1.0.1","description":"Given an object and a property, replaces a property descriptor (or deletes it), and returns a thunk to restore it.","main":"index.js","exports":{".":"./index.js","./package.json":"./package.json"},"scripts":{"prepack":"npmignore --auto --commentLines=autogenerated","prepublish":"not-in-publish || npm run prepublishOnly","prepublishOnly":"safe-publish-latest","prelint":"evalmd README.md","lint":"eslint --ext=.js,.mjs .","pretest":"npm run lint","tests-only":"nyc tape 'test/**/*.js'","test":"npm run tests-only","posttest":"aud --production","version":"auto-changelog && git add CHANGELOG.md","postversion":"auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\""},"repository":{"type":"git","url":"git+https://github.com/ljharb/mock-property.git"},"keywords":["testing","mock","object","property","value","descriptor","test","delete","define"],"author":{"name":"Jordan Harband","email":"ljharb@gmail.com"},"funding":{"url":"https://github.com/sponsors/ljharb"},"license":"MIT","bugs":{"url":"https://github.com/ljharb/mock-property/issues"},"homepage":"https://github.com/ljharb/mock-property#readme","devDependencies":{"@ljharb/eslint-config":"^21.1.0","aud":"^2.0.3","auto-changelog":"^2.4.0","es-value-fixtures":"^1.4.2","eslint":"=8.8.0","evalmd":"^0.0.19","for-each":"^0.3.3","in-publish":"^2.0.1","npmignore":"^0.3.0","nyc":"^10.3.2","object-inspect":"^1.12.3","safe-publish-latest":"^2.0.0","tape":"^5.7.1"},"dependencies":{"define-data-property":"^1.1.0","functions-have-names":"^1.2.3","gopd":"^1.0.1","has":"^1.0.3","has-property-descriptors":"^1.0.0","isarray":"^2.0.5"},"engines":{"node":">= 0.4"},"testling":{"files":"test/index.js"},"auto-changelog":{"output":"CHANGELOG.md","template":"keepachangelog","unreleased":false,"commitLimit":false,"backfillLimit":false,"hideCredit":true},"publishConfig":{"ignore":[".github/workflows"]},"_id":"mock-property@1.0.1","gitHead":"71931e8e7f50d028e98f5b62b17ab22201a790d1","_nodeVersion":"20.8.0","_npmVersion":"10.1.0","dist":{"shasum":"2cfed3b741856fdd510975c67e5216b0c1f8bdd3","size":211657,"noattachment":false,"key":"/mock-property/-/mock-property-1.0.1.tgz","tarball":"http://name.csiicloud.com:7001/mock-property/download/mock-property-1.0.1.tgz"},"_npmUser":{"name":"ljharb","email":"ljharb@gmail.com"},"directories":{},"maintainers":[{"name":"ljharb","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mock-property_1.0.1_1697066376817_0.9290062526638176"},"_hasShrinkwrap":false,"deprecated":"this version accidentally includes a testing HTML file - it works fine otherwise","_cnpmcore_publish_time":"2023-10-11T23:19:37.030Z","publish_time":1697066377030,"_source_registry_name":"default","_cnpm_publish_time":1697066377030},"1.0.0":{"name":"mock-property","version":"1.0.0","description":"Given an object and a property, replaces a property descriptor (or deletes it), and returns a thunk to restore it.","main":"index.js","exports":{".":"./index.js","./package.json":"./package.json"},"scripts":{"prepublish":"not-in-publish || npm run prepublishOnly","prepublishOnly":"safe-publish-latest","prelint":"evalmd README.md","lint":"eslint --ext=.js,.mjs .","pretest":"npm run lint","tests-only":"nyc tape 'test/**/*.js'","test":"npm run tests-only","posttest":"aud --production","version":"auto-changelog && git add CHANGELOG.md","postversion":"auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\""},"repository":{"type":"git","url":"git+https://github.com/ljharb/mock-property.git"},"keywords":["testing","mock","object","property","value","descriptor","test","delete","define"],"author":{"name":"Jordan Harband","email":"ljharb@gmail.com"},"funding":{"url":"https://github.com/sponsors/ljharb"},"license":"MIT","bugs":{"url":"https://github.com/ljharb/mock-property/issues"},"homepage":"https://github.com/ljharb/mock-property#readme","devDependencies":{"@ljharb/eslint-config":"^21.0.0","aud":"^2.0.0","auto-changelog":"^2.4.0","es-value-fixtures":"^1.2.1","eslint":"=8.8.0","evalmd":"^0.0.19","for-each":"^0.3.3","in-publish":"^2.0.1","nyc":"^10.3.2","object-inspect":"^1.12.0","safe-publish-latest":"^2.0.0","tape":"^5.5.3"},"dependencies":{"functions-have-names":"^1.2.2","has":"^1.0.3","has-property-descriptors":"^1.0.0","isarray":"^2.0.5"},"gitHead":"e373797d1483d6e8ac77aa703235167885dcee69","_id":"mock-property@1.0.0","_nodeVersion":"17.9.0","_npmVersion":"8.3.1","dist":{"shasum":"301518a59fb545312a407c8d1a861aba0357b4a6","size":6973,"noattachment":false,"key":"/mock-property/-/mock-property-1.0.0.tgz","tarball":"http://name.csiicloud.com:7001/mock-property/download/mock-property-1.0.0.tgz"},"_npmUser":{"name":"ljharb","email":"ljharb@gmail.com"},"directories":{},"maintainers":[{"name":"ljharb","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mock-property_1.0.0_1650145466168_0.5572703803874826"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-04-16T21:44:28.484Z","publish_time":1650145466297,"_cnpm_publish_time":1650145466297}},"readme":"# mock-property <sup>[![Version Badge][npm-version-svg]][package-url]</sup>\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&stars=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","_attachments":{},"homepage":"https://github.com/ljharb/mock-property#readme","bugs":{"url":"https://github.com/ljharb/mock-property/issues"},"license":"MIT"}