Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
Web Security TippsNew manual calculation setting in Google Sheets(21.09.2026 um 20:54 Uhr)
Videos & KonferenzenTechquickie: The Steam Frame Shouldn't Work - Here's Why It Does(21.09.2026 um 21:17 Uhr)
Sichere ProgrammierungHow to Build a Production-Ready iOS App With AI-Generated Code(21.09.2026 um 21:00 Uhr)
Sichere ProgrammierungAfriex Integrations: Sandbox, Idempotency, and Webhook Simulation(21.09.2026 um 21:50 Uhr)
Sichere ProgrammierungBridging Local and Cloud Databases for Centralized Data Management(21.09.2026 um 21:51 Uhr)
Web Security TippsNew manual calculation setting in Google Sheets(21.09.2026 um 20:54 Uhr)
Videos & KonferenzenTechquickie: The Steam Frame Shouldn't Work - Here's Why It Does(21.09.2026 um 21:17 Uhr)
Sichere ProgrammierungHow to Build a Production-Ready iOS App With AI-Generated Code(21.09.2026 um 21:00 Uhr)
Sichere ProgrammierungAfriex Integrations: Sandbox, Idempotency, and Webhook Simulation(21.09.2026 um 21:50 Uhr)
Sichere ProgrammierungBridging Local and Cloud Databases for Centralized Data Management(21.09.2026 um 21:51 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

Mapstronaut: A Flexible Object-Mapping Library for JS/TS

Hey everyone! I'm a senior developer with nearly 20 years of experience, but I'm pretty new to the open-source world. I wanted to share the story of my first major library. Why Mapstronaut? After 5 years of intensive…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

Hey everyone!



I'm a senior developer with nearly 20 years of experience, but I'm pretty new to the open-source world. I wanted to share the story of my first major library.






Why Mapstronaut?



After 5 years of intensive development in TypeScript, I switched jobs about a year ago and found myself deep in the Java ecosystem. I had my preconceptions, but I have to admit: with modern frameworks and libraries, the developer experience is excellent.



One library, in particular, became a daily tool for me: MapStruct. It's a fantastic code generator for mapping one object to another. When I found myself working on Node.js or React projects again, I really missed its power and simplicity. I looked for an open-source equivalent in the JavaScript/TS world, but nothing quite fit my needs.



So, I decided to build it myself.






Introducing Mapstronaut 👨‍🚀



Mapstronaut is a powerful and flexible object mapping library for JavaScript and TypeScript.



Here are some of its key features:




  • Simple, easy-to-understand declarative mapping with transformers, filters, and error handling.

  • Advanced source/target property selectors using JSONPath and dot-prop.

  • Auto-mapping available: maps values present in both the source and target without explicit declaration.

  • Can perform asynchronous transformations and mappings in parallel.

  • Very high test coverage.

  • Comprehensive documentation.






How it works



Let's start with a basic mapping. Imagine you have a complex source object and need to create a simpler DTO.




const source = {
spacecraft: {
name: "Apollo 11",
crew: ["Neil Armstrong", "Buzz Aldrin", "Michael Collins"],
},
mission: {
year: 1969,
destination: "Moon",
},
};

const structure = [
{ source: "spacecraft.name", target: "vesselName" },
{ source: "mission.destination", target: "target" },
{ source: "spacecraft.crew[0]", target: "firstManOnTheMoon" },
];

const result = mapObject(structure, source);

/*
result is:
{
"vesselName": "Apollo 11",
"target": "Moon",
"firstManOnTheMoon": "Neil Armstrong"
}
*/







But Mapstronaut can do much more. Here is an example of a more advanced set of rules:




const structure = [
{
source: "mission.budget",
target: "budgetBillions",
// Use a custom function to transform values
transform: (budget) => Math.round((budget / 1e9) * 10) / 10,
},
// Use JSONPath to slice an array
{ source: "crew[0:2]", target: "crew.firstTwo" },
// Use JSONPath to filter an array
{ source: "crew[?(@.age >= 30)]", target: "crew.senior" },
// Add a constant value to the output
{ constant: "NASA", target: "agency" }
];






Beyond these examples, Mapstronaut is also fully async-ready. This allows you to perform complex operations, like fetching data from an API in the middle of a transformation. All async operations can be run in parallel for maximum performance. You can find detailed examples for this and more in the documentation.



The project is open source under the MIT license.



You can check out the code and documentation here:



https://github.com/jprevo/mapstronaut



I'd love to hear your feedback. What do you use for object mapping in your projects? Are there any features you'd find useful?



Feel free to open an issue or a PR on GitHub.



Thanks for reading!

Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Mapstronaut: A Flexible Object-Mapping Library for JS/TS

Thematisch verwandte Begriffe: Mapstronaut, Flexible, ObjectMapping, Library · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-94497 | jshERP through 3.6 fails to validate object ownership in by-id info, upd…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick