{"id":20910895,"url":"https://github.com/wufe/mapper","last_synced_at":"2025-05-13T07:31:57.234Z","repository":{"id":95573037,"uuid":"118187690","full_name":"wufe/mapper","owner":"wufe","description":"Object to object mapper in Typescript - Inspired by Automapper","archived":false,"fork":false,"pushed_at":"2019-05-25T14:37:00.000Z","size":63,"stargazers_count":28,"open_issues_count":1,"forks_count":3,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-11-11T21:02:01.301Z","etag":null,"topics":["mapper","object-to-object","typescript"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/wufe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2018-01-19T22:53:12.000Z","updated_at":"2024-02-08T03:09:49.000Z","dependencies_parsed_at":"2023-07-22T18:00:49.679Z","dependency_job_id":null,"html_url":"https://github.com/wufe/mapper","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wufe%2Fmapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wufe%2Fmapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wufe%2Fmapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wufe%2Fmapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wufe","download_url":"https://codeload.github.com/wufe/mapper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225188633,"owners_count":17435108,"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":["mapper","object-to-object","typescript"],"created_at":"2024-11-18T14:18:19.094Z","updated_at":"2024-11-18T14:18:19.935Z","avatar_url":"https://github.com/wufe.png","language":"TypeScript","readme":"# Mapper - Object to object mapper in Typescript\n\n**Inspired by [Automapper](https://github.com/automapper/automapper)**\n\n**Warning**: This is *NOT* a complete reimplementation of Automapper.  \n\n## What is this\n\nThis library provides an API to map an object into another object, following previously set rules.  \nIt is designed with **redux**'s reducers in mind, so it is a perfect fit when used as application's state incremental modifier.  \nIt provides **immutability**, nested mapping capabilities and higly customizable configuration interfaces.  \n\nSupports:\n+ Immutability\n+ Nested mapping\n+ Redudant mapping\n+ Override of pre-existing rules to behave differently in runtime (edge cases)\n+ Array mapping\n\n***\n\n## How to\n\n### Getting started\n\n**Install**\n\n\u003e `yarn add @wufe/mapper`  \n\nor  \n\n\u003e `npm i --save @wufe/mapper`\n\n***\n\n**Configuration**\n\nEach map ruleset requires a mapping signature, to be able to identify object types at runtime.  \n\n**Create a mapper and instantiate your first map ruleset**  \nSyntax:  \n`mapper.createMap\u003cS, D\u003e(signature: MapSignature, destination: { new(): D })`\n\n```typescript\nconst mapper = new Mapper();\nconst sourceDestinationSignature: MapSignature = {\n    source: Symbol('SourceClass'),\n    destination: Symbol('DestinationClass')\n};\nmapper.createMap\u003cSourceClass, DestinationClass\u003e(sourceDestinationSignature, DestinationClass);\n```\n\n**To apply the mapping**  \nSyntax:  \n`mapper.map\u003cS, D\u003e(signature: MapSignature, source: S)`\n\n```typescript\nconst sourceObject = new SourceClass();\nsourceObject.a = 'a';\nconst destinationObject = mapper.map\u003cSourceClass, DestinationClass\u003e(sourceDestinationSignature, sourceObject);\n// destinationObject.a is now 'a'\n```\n\n***\n\n### Map creation without signature\n\nIt is possible to create a map rule set without a signature, using the `mapTo` decorator.  \n\nSyntax:\n```typescript\n@mapTo(Destination)\nclass Source {}\n```\n\nExample:  \n```typescript\nimport { Mapper } from '@wufe/mapper';\n\nclass Destination {\n    class Destination {\n    destGreeting: string;\n    constructor() {\n        this.destGreeting = 'destination';\n    }\n}\n\n@mapTo(Destination)\nclass Source {\n    sourceGreeting: string;\n    constructor() {\n        this.sourceGreeting = 'source';\n    }\n}\n\nconst mapper = new Mapper();\nmapper.createMap\u003cSource, Destination\u003e(Source)\n    .forMember(\"destGreeting\", opt =\u003e opt.mapFrom(src =\u003e src.sourceGreeting));\n\nconst sourceEntity = new Source();\n\nconst destinationEntity = mapper.map\u003cSource, Destination\u003e(sourceEntity);\n```\n\n***\n\n### Examples\n\nMore examples are available in the [tests](https://github.com/Wufe/mapper/tree/master/src/tests) folder.\n\n***\n\n## Documentation\n\nCheck the documentation in the [wiki](https://github.com/Wufe/mapper/wiki).","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwufe%2Fmapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwufe%2Fmapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwufe%2Fmapper/lists"}