{"id":21082305,"url":"https://github.com/olsonpm/madonna-map","last_synced_at":"2025-06-24T01:09:45.817Z","repository":{"id":80606424,"uuid":"60146476","full_name":"olsonpm/madonna-map","owner":"olsonpm","description":null,"archived":false,"fork":false,"pushed_at":"2016-08-01T18:12:35.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-07T21:02:23.661Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/olsonpm.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}},"created_at":"2016-06-01T04:55:48.000Z","updated_at":"2016-06-01T04:56:47.000Z","dependencies_parsed_at":null,"dependency_job_id":"bf72f594-f96a-458f-a303-7c12e6c55eea","html_url":"https://github.com/olsonpm/madonna-map","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/olsonpm/madonna-map","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olsonpm%2Fmadonna-map","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olsonpm%2Fmadonna-map/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olsonpm%2Fmadonna-map/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olsonpm%2Fmadonna-map/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/olsonpm","download_url":"https://codeload.github.com/olsonpm/madonna-map/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olsonpm%2Fmadonna-map/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261584235,"owners_count":23180675,"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-19T20:13:37.439Z","updated_at":"2025-06-24T01:09:45.795Z","avatar_url":"https://github.com/olsonpm.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Madonna Map\nCreates a function that validates its arguments via\n[madonna-fp](https://github.com/olsonpm/madonna-fp) before mapping them to\nsomething else.  I created this to validate raw json then map it through a\nclass or constructor.  Note `madonna-map` only allows you to map top-level\nproperties.  Allowing otherwise would create for unnecessarily complex code.\n\n**Tested against**\n - node 0.10.0 for the (default) es5 version\n - node 6.0.0 for es6 @ `require('madonna-map/es6')`\n\n\u003c!-- START doctoc generated TOC please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --\u003e\n## Table of Contents\n\n - [Examples](#examples)\n - [API](#api)\n\n\u003c!-- END doctoc generated TOC please keep comment here to allow auto update --\u003e\n\n## Examples\n```js\nconst madonnaMap = require('madonna-map');\n\n// creates a function requiring the argument 'name' and maps its value to uppercase\nlet mapperFn = madonnaMap.createMapper({\n  marg: { name: ['require', 'isLadenString'] }\n  , argMap: { name: fp.toUpper }\n});\n\nmapperFn({ name: 'phil' });\n// returns\n// { name: 'PHIL' }\n\n\nmapperFn({ name: {} });\n// throws an error\n// Invalid Input: The following arguments didn't pass their criterion\n// invalid arguments and values: {\n//   \"name\": {}\n// }\n// failed criterion per argument: {\n//   \"name\": {\n//     \"flags\": [\n//       \"isLadenString\"\n//     ]\n//   }\n// }\n\n\n// don't mismatch the argMap property names with those declared in marg\nmapperFn = madonnaMap.createMapper({\n  marg: { name: ['require', 'isLadenString'] }\n  , argMap: { notName: fp.toUpper }\n});\n// throws an error\n// Invalid Input: argMap can only contain keys present in schema.\n// invalid keys: notName\n// keys allowed: name\n\n\n// a slightly larger example\nmapperFn = madonnaMap.createMapper({\n  marg: {\n    name: ['require', 'isLadenString']\n    , age: { betweenI: [0, 120] }\n  }\n  , argMap: { name: fp.toUpper }\n});\n\nmapperFn({\n  name: 'phil'\n  , age: 28\n});\n// returns\n// { name: 'PHIL', age: 28 }\n```\n\n## API\n`require('madonna-map').createMapper`\n - Takes the following arguments\n   - **marg**: `require` `isLadenPlainObject`\n     - marg stands for 'madonna-fp argument'.  It is passed to madonna-fp which\n       is used to validate the arguments in calls to the returned function.\n   - **argMap**: `require` `isLadenPlainObject`\n     - This object can only contain keys found in **marg** and their values\n       must be functions.  Valid input will pass through these functions\n       and returned.  Not all properties in **marg** have to be mapped.\n - Returns a function that validates its input against **marg**.  Any properties\n   in **argMap** will pass through their mappers.  All validated arguments will\n   be returned.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folsonpm%2Fmadonna-map","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Folsonpm%2Fmadonna-map","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folsonpm%2Fmadonna-map/lists"}