{"id":28220845,"url":"https://github.com/morulus/mark-props","last_synced_at":"2025-06-10T09:30:40.972Z","repository":{"id":57311368,"uuid":"112123137","full_name":"morulus/mark-props","owner":"morulus","description":"mark-props","archived":false,"fork":false,"pushed_at":"2018-03-28T14:09:27.000Z","size":45,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-05T04:36:03.243Z","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/morulus.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-11-26T22:50:51.000Z","updated_at":"2018-03-28T14:09:28.000Z","dependencies_parsed_at":"2022-09-10T21:13:32.239Z","dependency_job_id":null,"html_url":"https://github.com/morulus/mark-props","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morulus%2Fmark-props","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morulus%2Fmark-props/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morulus%2Fmark-props/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morulus%2Fmark-props/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/morulus","download_url":"https://codeload.github.com/morulus/mark-props/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morulus%2Fmark-props/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259047881,"owners_count":22797614,"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":[],"created_at":"2025-05-18T04:16:23.068Z","updated_at":"2025-06-10T09:30:40.921Z","avatar_url":"https://github.com/morulus.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"mark-props\n==\n\nWrap an object with [Proxy](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy) in such way, when any gotten property or a created property will have the information about the path of its getting.\n\nFor example:\n```js\nimport markProps, { getMarking } from 'mark-props';\nimport PropTypes from 'prop-types';\n\nconst MarkedPropTypes = markProps(PropTypes);\n\nconst propType = MarkedPropTypes.shape({\n  enabled: MarkedPropTypes.bool,\n}).isRequired;\n\n\nconsole.log(\n  getMarking(propType)\n);\n// Result will:\n// [\n//   {\n//     name: 'shape',\n//     type: 'function',\n//     args: [{\n//       enabled: ⨍ function() { ... }\n//     }]\n//   },\n//   {\n//     name: 'isRequired',\n//     type: 'function'\n//   }\n// ]\n\nconst [ firstArgOfShape ] = getMarking(propType)[0].args;\n\nconsole.log(\n  getMarking(firstArgOfShape)\n);\n// Result will:\n// [\n//   {\n//     name: 'bool',\n//     type: 'function'\n//   }\n// ]\n```\n\nThis tool created especially for [PropTypes](https://www.npmjs.com/package/prop-types) marking, but you can use it with any object.\n\n# Useful with babel\n\nUse  [babel-plugin-module-resolver](https://github.com/tleunen/babel-plugin-module-resolver) to wrap, for example, `prop-types` module globally:\n\n```js\n// marked-prop-types.js\nconst PropTypes = require('origin-prop-types');\nconst markProps = require('mark-props');\n\nmodule.exports = markProps(PropTypes);\n```\n\n```js\n// Babel configuration\n{\n  \"plugins\": [\n    [\n      require.resolve('babel-plugin-module-resolver'),\n      {\n        \"alias\": {\n          \"origin-prop-types\": require.resolve(\"prop-types\"),\n          \"prop-types\": require.resolve(\"./marked-prop-types.js\"),\n        }\n      }\n    ]\n  ]\n}\n```\n\nThus, all PropTypes in a project will be wrapped with `mark-props`.\n\n```js\nimport PropTypes from 'prop-types';\nimport { getMarking } from 'mark-props';\n\nconst propTypes = {\n  children: PropTypes.node.isRequired,\n};\n\ngetMarking(propTypes.children); // [{ name: 'node' }, { name: 'isRequired' }]\n\n```\n\nAuthor\n----\n\nVladimir Kalmykov \u003cvladimirmorulus@gmail.com\u003e\n\nLicense\n----\n\nMIT, 2017\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorulus%2Fmark-props","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmorulus%2Fmark-props","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorulus%2Fmark-props/lists"}