Skip to content

Better object creation

Compare
Choose a tag to compare
@w3nl w3nl released this 09 Mar 08:49
· 385 commits to master since this release
1a26c3b
const addressSchema = {
    street: String,
    number: Number,
    postalCode: String,
    city: String,
    country: String,
};

const Address = Obj({ schema: addressSchema })

const myAddress = Address.create({
    street: 'Abc',
    number: 42,
    postalCode: '1234AB',
    city: 'Example',
    country: 'The Netherlands'
})

Now it returns an object, and you can call all methods on the object.
e.g.

myAddress.street // 'Abc'
myAddress.keys() // ['street', 'number', 'postalcode', 'city', 'country']