dtox
Lightweight, extensible data transfer object (DTO) library for Node.js and browser environments.
Install
$ npm install dtox --save
Usage
const BaseDTO BaseListDTO fields = // Define user mappingconst USER_MAPPING = id: fields name: fields validated: fields roles: fields hasRoles: fields dateCreated: fields; // Define a DTO which represents a single user { superdata USER_MAPPING; } const user = id: 123 name: 'john_doe' validated: true groups: 'administrator' dateCreated: '1997-07-16T19:20:30Z'; console; // "Hello john_doe"console; // "User has roles" // Define a DTO which represents a list of users { superdata UserDTO; } const users = id: 123 name: 'john_doe' groups: 'owner' validated: true dateCreated: '1997-07-16T19:20:30Z' id: 124 name: 'jane_doe' groups: 'administrator' validated: false dateCreated: '2015-12-15T07:36:25Z' ; const userNames = users; console; // "john_doe, jane_doe" // or also possible:for const userName of users console; console; // will print the items in JSON form