{"id":44096508,"url":"https://github.com/cyberwombat/morphjs","last_synced_at":"2026-02-08T12:48:50.765Z","repository":{"id":67370062,"uuid":"68144584","full_name":"cyberwombat/morphjs","owner":"cyberwombat","description":"MorphJS transforms object literals into different structures/formats using a simple schema.","archived":false,"fork":false,"pushed_at":"2017-10-09T15:06:53.000Z","size":14,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-12T22:51:35.046Z","etag":null,"topics":["json","json-schema","mongodb","schema"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cyberwombat.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null}},"created_at":"2016-09-13T20:24:29.000Z","updated_at":"2017-12-02T21:17:53.000Z","dependencies_parsed_at":null,"dependency_job_id":"52fd509a-e0ed-4c41-aeb8-d980d8b555e8","html_url":"https://github.com/cyberwombat/morphjs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cyberwombat/morphjs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cyberwombat%2Fmorphjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cyberwombat%2Fmorphjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cyberwombat%2Fmorphjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cyberwombat%2Fmorphjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cyberwombat","download_url":"https://codeload.github.com/cyberwombat/morphjs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cyberwombat%2Fmorphjs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28482472,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T11:59:17.896Z","status":"ssl_error","status_checked_at":"2026-01-16T11:55:55.838Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["json","json-schema","mongodb","schema"],"created_at":"2026-02-08T12:48:50.190Z","updated_at":"2026-02-08T12:48:50.761Z","avatar_url":"https://github.com/cyberwombat.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Morph\n\nMorphJS transforms object literals into different structures using a simple schema such as formatting database results into a format suitable for an API output. \n\n### Install\n\n    npm i morphjs\n\n### Example\n\nOriginal input:\n\n    const input = {\n      _id: new objectID(),\n      code: '123',\n      items: [{\n        cost: 45,\n        name: 'An item'\n      }, {\n        cost: 10,\n        name: 'Another item'\n      }],\n      recipient: {\n        email: 'me@example.org',\n        first: 'Sponge',\n        last: 'Bob'\n      }\n    }\n\nTransformation schema:\n\n    const schema = {\n      id: '@_id',\n      company: 'My company',\n      email: '@recipient.email',\n      name: (doc) =\u003e {\n        return doc.recipient.first + ' ' +  doc.recipient.last\n      },\n      items: '@items',\n      count: '#items'\n    }\n\nApply:\n\n    const result = applyMask(input, schema)\n\nOutput:\n\n    const expected = {\n      id: '507f191e810c19729de860ea',\n      company: 'My company',\n      email: 'me@example.org',\n      name: 'Sponge Bob',\n      items: [{\n        cost: 45,\n        name: 'An item'\n      }, {\n        cost: 10,\n        name: 'Another item'\n      }],\n      count: 2\n    }    \n\n### Rules\n\n#### Path reference\nValues prefixed with `@` are used to traverse the input object. \n\nEx:\n\n    name: @recipient.name.first\n\nwill look for the name field in:\n\n````\n{\n    recipient: {\n        name: {\n            first: 'Sponge'\n        }\n    }\n}\n````\n\n#### Strings\nA quoted string will be used as is. \nEx: \n    \n    version: '1.0'\n\n#### Counts\nArray lengths count can be obtained by prefixing value with `@`.\n\nEx:\n\n    total: '@items'\n\n#### Functions\n\nIf more functionality is necessary you can also use a function. This function is given the input document as a parameter.\n\nEx:\n\n    name: doc =\u003e doc.recipient.first + ' ' +  doc.recipient.last\n\n#### Buffer, Dates and Mongo ObjectID\n\nIf a Buffer or Date instance or an Mongo ObjectID is provided it will be coerced into a string. \n\nEx:\n\n````\n// Input\n_id: new objectID('28d64ae8122ab883bbc167ef'),\n\n// Schema\nid: _id\n\n// Output\nid: '28d64ae8122ab883bbc167ef'\n````\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcyberwombat%2Fmorphjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcyberwombat%2Fmorphjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcyberwombat%2Fmorphjs/lists"}