Gets the current props configuration.
The current configuration.
Gets the value of a property using a dot-notation path. Applies any configured transformers and returns the fallback if the property does not exist.
The property value, the default value, or the global fallback.
If input validation fails.
const user = { name: 'Flavio Ever', profile: { age: 30 } };
props.getProp(user, 'profile.age'); // 30
props.getProp(user, 'profile.email', 'no-email'); // 'no-email'
Checks if a property exists using a dot-notation path. Applies any configured transformers.
True if the property exists, false otherwise.
If input validation fails.
const user = { name: 'Flavio Ever', profile: { age: 30 } };
props.hasProp(user, 'profile.bio'); // false
Removes a property using a dot-notation path. Applies any configured transformers.
The modified object.
If input validation fails.
const user = { name: 'Flavio Ever', profile: { age: 30, email: 'flavio@ever.com' } };
props.removeProp(user, 'profile.email');
Sets the value of a property using a dot-notation path. Applies any configured transformers.
The modified object.
If input validation fails.
const user = { name: 'Flavio Ever', profile: { age: 30 } };
props.setProp(user, 'profile.email', 'flavio@ever.com');
Configures the global props behavior.
The configuration to apply.
props.use<User>({
fallback: 'N/A',
transformers: { getProp: { name: value => value.trim() } }
});
Interface that defines all available props methods.
Example