Wrap a thing with a Type to filter out properties, while preserving the Id. A wrapped thing inherits the methods from the type it is wrapped with.
For a more advanced example using wrap() and unwrap() see <Type>.
thing.wrap([Type])
Argument | Arguments | Description |
---|---|---|
Type | str (optional) | Type’s name to wrap the thing with. If not given, the thing will be wrapped with its own type. |
A wrapped thing.
This code shows an example using wrap():
// Create a Type to return just an email field.
set_type('_Email', {email: 'str'});
// Store a thing
.joente = {
name: 'Jeroen van der Heijden',
email: 'jeroen@cesbit.com',
gender: 'male',
};
// Return the email field and Id (#)
.joente.wrap('_Email');
Example return value in JSON format
{
"#": 42,
"email": "jeroen@cesbit.com"
}