wrap

Wrap a thing with a another Type to filter out properties, while preserving the ID.

For a more advanced example using wrap() and unwrap() see <Type>.

Function

thing.wrap(Type)

Arguments

Argument Arguments Description
Type str Type’s name to wrap the thing with.

Return value

A wrapped thing.

Example

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@transceptor.technology',
    gender: 'male',
};

// Return the email field and ID (#)
.joente.wrap('_Email');

Example return value in JSON format

{
    "#": 42,
    "email": "jeroen@transceptor.technology"
}