The Persona class represents an individual with various attributes like age, occupation, and custom properties. It's the fundamental building block of the SDK.
Basic Usage
Create personas directly with the constructor:
1// Direct instantiation2const persona = new Persona('John Doe', {3 age: 30,4 occupation: 'Engineer',5 sex: 'male',6 income: 750007});8
9// Access properties10console.log(persona.name); // 'John Doe'11console.log(persona.age); // 3012console.log(persona.occupation); // 'Engineer'
Builder Pattern
Use the fluent builder API for more readable code:
1const persona = PersonaBuilder.create()2 .setName('Jane Smith')3 .setAge(25)4 .setOccupation('Designer')5 .setSex('female')6 .setCustom('skills', ['UI/UX', 'Prototyping'])7 .build();
💡 Pro Tip
The builder pattern allows you to chain methods and provides better IntelliSense support in your IDE. It also validates inputs as you build.