{"id":16326674,"url":"https://github.com/chrisyip/defp.js","last_synced_at":"2025-08-20T02:08:51.852Z","repository":{"id":57211820,"uuid":"86544449","full_name":"chrisyip/defp.js","owner":"chrisyip","description":"Define object properties in an easier way","archived":false,"fork":false,"pushed_at":"2017-03-29T15:00:41.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-01T12:06:10.093Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chrisyip.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-29T06:06:40.000Z","updated_at":"2017-03-29T14:56:39.000Z","dependencies_parsed_at":"2022-08-30T15:31:22.677Z","dependency_job_id":null,"html_url":"https://github.com/chrisyip/defp.js","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/chrisyip/defp.js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisyip%2Fdefp.js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisyip%2Fdefp.js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisyip%2Fdefp.js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisyip%2Fdefp.js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chrisyip","download_url":"https://codeload.github.com/chrisyip/defp.js/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisyip%2Fdefp.js/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268207442,"owners_count":24213011,"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-01T02:00:08.611Z","response_time":67,"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":[],"created_at":"2024-10-10T23:09:15.472Z","updated_at":"2025-08-01T10:35:28.525Z","avatar_url":"https://github.com/chrisyip.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# defp.js\n\n[![NPM version][npm-image]][npm-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Travis CI][travis-image]][travis-url] [![codecov][codecov-image]][codecov-url]\n\nDefine object properties in an easier way. Inspired by [prr](https://github.com/rvagg/prr).\n\n## Install\n\n```\nnpm i defp\n```\n\n## Requirements\n\n- `defp` written in ES2015, use transpiler when needed\n- Add `Object.assign` polyfill if it's not available\n\n## Usage\n\n```js\nconst defp = require('defp')\n\ndefp(TARGET_OBJECT, KEY, [VALUE, [DESCRIPTOR_OPTIONS]])\n```\n\n```js\ndefp(obj, 'foo', 'baz')\n```\n\nEquals to:\n\n```js\nObject.defineProperty(obj, 'foo', {\n  configurable: false,\n  enumerable: false,\n  writable: false,\n  value: 'baz'\n})\n```\n\n### Descriptor options\n\n```js\ndefp(obj, 'foo', 'baz', 'cew')\n// c === configurable\n// e === enumerable\n// w === writable\n\ndefp(obj, 'foo', {\n  configurable: true,\n  enumerable: true,\n  writable: true,\n  value: 'baz'\n})\n```\n\nEquals:\n\n```js\nObject.defineProperty(obj, 'foo', {\n  configurable: true,\n  enumerable: true,\n  writable: true,\n  value: 'baz'\n})\n```\n\n`getter` and `setter`:\n\n```js\ndefp(obj, 'foo', {\n  get () { return this._foo },\n  set (val) { this._foo = val }\n})\n```\n\nOverriding descriptor options for special key:\n\n```js\ndefp(obj, {\n  privateVar: {\n    enumerable: false,\n    value: 'privateVar'\n  },\n\n  publicVar: 'publicVar'\n}, 'ew')\n```\n\nNote:\n\n- If `VALUE` contains one of these keys: `get`, `set`, `value`, `enumerable`, `configurable`, `defp` will treat `VALUE` as a descriptor.\n\n[npm-url]: https://npmjs.org/package/defp\n[npm-image]: http://img.shields.io/npm/v/defp.svg?style=flat-square\n[daviddm-url]: https://david-dm.org/chrisyip/defp.js\n[daviddm-image]: http://img.shields.io/david/chrisyip/defp.js.svg?style=flat-square\n[travis-url]: https://travis-ci.org/chrisyip/defp.js\n[travis-image]: http://img.shields.io/travis/chrisyip/defp.js.svg?style=flat-square\n[codecov-url]: https://codecov.io/gh/chrisyip/defp.js\n[codecov-image]: https://img.shields.io/codecov/c/github/chrisyip/defp.js.svg?style=flat-square\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrisyip%2Fdefp.js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchrisyip%2Fdefp.js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrisyip%2Fdefp.js/lists"}