{"id":21417915,"url":"https://github.com/msg-systems/js-mockdata-registry","last_synced_at":"2025-08-09T17:04:12.955Z","repository":{"id":57283401,"uuid":"72414619","full_name":"msg-systems/js-mockdata-registry","owner":"msg-systems","description":"JavaScript registry for mockdata","archived":false,"fork":false,"pushed_at":"2016-10-31T11:21:40.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-15T23:57:11.374Z","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/msg-systems.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":"2016-10-31T07:52:39.000Z","updated_at":"2016-10-31T08:28:00.000Z","dependencies_parsed_at":"2022-09-11T15:21:40.408Z","dependency_job_id":null,"html_url":"https://github.com/msg-systems/js-mockdata-registry","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/msg-systems%2Fjs-mockdata-registry","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msg-systems%2Fjs-mockdata-registry/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msg-systems%2Fjs-mockdata-registry/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msg-systems%2Fjs-mockdata-registry/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/msg-systems","download_url":"https://codeload.github.com/msg-systems/js-mockdata-registry/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243918629,"owners_count":20368745,"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":"2024-11-22T19:18:07.526Z","updated_at":"2025-03-16T19:21:18.786Z","avatar_url":"https://github.com/msg-systems.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# js-mockdata-registry\n\nJavaScript registry or mockdata\n\n\u003cp/\u003e\n\u003cimg src=\"https://nodei.co/npm/js-mockdata-registry.png?downloads=true\u0026stars=true\" alt=\"\"/\u003e\n\n\u003cp/\u003e\n\u003cimg src=\"https://david-dm.org/msg-systems/js-mockdata-registry.png\" alt=\"\"/\u003e\n\n## Purpose\nThe `js-mockdata-registry` is a small registry for mockdata objects that should be references within other mockdata objects.\n\n## Getting started\n\nSimply add the `js-mockdata-registry` to your package.json file and use `npm install` for installation.\n\n```json\n\t\t\"devDependencies\": {\n\t\t    \"js-mockdata-registry\":        \"~1.0.0\"\n\t\t}\n```\n\nOnce it is installed you can `require` the module.\n\n```js\n\t\tlet mockdata = require('js-mockdata-registry')\n```\n\n## Usage\n\nThis chapter explains the basic usage of the registry.\n\n### Mockdata interface\n\n| Method | Description |\n| --- | --- | --- |\n| addObject (Object obj) | Adds the given object to the registry. The object must have the attribute `mark` with a unique value within the registry. The `mark`is consumed in the registration process. An error is throw if either the attribute `mark` is not exisiting or if its value is not unique |\n| hasObject (String mark) : Boolean | Checks the registry if an object with the given `mark` exists|\n| getObject (String mark) | Reads the desired registry entry for the given `mark`. Throws an error if the given mark is not existing in the registry. |\n| removeObject (String mark) | Removes the desired registry entry for the given `mark`. Throws an error if the given mark is not existing in the registry. |\n| log (Number depth) | Outputs the current registry using node's `util.inspect` function. The `depth` is handed over to the inspect function. |\n| resolve (Object resultObj, Object obj, String attrib) | This function resolves an object reference to an registry entry. The originial `obj` won't be changed during resolve. Instead the `resultObj` will be altered. For more details see the examples. |\n    \n\n### Example usage\n\n```js\n/* in order to add objects we have to instanciate the registry */\nlet mockdata = require('js-mockdata-registry')\n\n/* adding objects                                              */\nmockdata.registry.addObject({\n    mark: 'User.John',\n    firstname: 'John',\n    lastname: 'Doe'\n})\n\n/* reading objects                                             */\nmockdata.registry.getObject('User.John')\n\n/* resolving references                                        */\n// define the new object with a objectRef to an existing mark\nlet project = {\n\tdesc: 'first project',\n    supervisor: { objectRef: 'User.John' }\n}\n// clone the base object\nlet resolvedProject = Object.assign({}, project)\n// let the registry resolve the object reference \nmockdata.registry.resolve(resolvedProject, project, 'supervisor')\n\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsg-systems%2Fjs-mockdata-registry","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmsg-systems%2Fjs-mockdata-registry","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsg-systems%2Fjs-mockdata-registry/lists"}