BlueprintJS
What does it do?
If you work with a lot of generic objects ({}
) in your code and you want to give special behavior to some or all of them, then BlueprintJS is the right tool for you.
Creating a Blueprint
var User = ;
User
Blueprint
Using the var someObjectIHaveInMyProject = name: "Robert" lastName: "Baratheon"; var user = someObjectIHaveInMyProject; // Now you get the "fullName" method for free. Bargain!console; // Robert Baratheon user; console; // Robert Downey Jr.
user
blueprintObject into a plain object
Transforming the var userPlainObject = blueprint; // Note that the fullName method is now a property with a value that is the// result of that methodconsole; // Robert Downey Jr.
Casting a list of objects
var listOfObjects = name:"John" lastName: "Blue" name:"Mary" lastName: "Red" name:"Richard" lastName: "Green" name:"Michael" lastName: "Gray" name:"Agatha" lastName: "Orange"; // blueprint.cast(Blueprint, object_or_list_of_objects)var listOfUsers = blueprint; console; // Mary Red
init
method
The special var Car = ; // The object is created and the "init()" method is calledvar car = ; console; // BMW
Working with NodeJS
// Just require the package and you are setvar blueprint = ; var Car = ; var car = brand:"bmw"; console;// outputs: Is the car expensive? true
That's it. Any feedback will be appreciated.