Creating Point-Free Helper Functions
You'll learn how to build reusable utility functions that enable point-free transformations across your codebase.
Point-free style becomes truly powerful when you have the right helper functions at your disposal. Instead of writing one-off wrappers every time, you can create general-purpose utilities that extract common patterns and make point-free code more readable and maintainable.
Common Helper Functions
pluck extracts a specific property from each object in an array:
const pluck = (property) => (object) => object[property];
const users = [
{ name: 'Alice', age: 30 },
{ name: 'Bob', age: 25 }
];
const names = users.map(pluck('name'));
// ['Alice', 'Bob']
prop is similar but designed for single objects:
const prop = (key) => (obj) => obj[key];
const getName = prop('name');
getName({ name: 'Charlie' }); // 'Charlie'
invoke calls a method on an object:
const invoke = (method) => (object) => object[method]();
const strings = ['hello', 'world'];
const uppercased = strings.map(invoke('toUpperCase'));
// ['HELLO', 'WORLD']
Why Build These Helpers?
Think of these helpers as building blocks—like having a well-stocked toolbox. Rather than manually creating a function every time you need to extract a property or call a method, you reach for a proven utility. They make your transformations more declarative and your intent clearer.
These curried helpers are specifically designed to work seamlessly with composition and point-free style, taking one argument at configuration time and returning a function ready to process data.
Key Takeaway: Helper functions like pluck, prop, and invoke eliminate repetitive wrapper code and provide a consistent, point-free interface for common transformations.