diff --git a/docs/curry/chain.mdx b/docs/curry/chain.mdx index a6a46f0b..db82f82a 100644 --- a/docs/curry/chain.mdx +++ b/docs/curry/chain.mdx @@ -45,3 +45,13 @@ const getUpperName = _.chain(getName, upperCase) getUpperName(gods[0]) // => 'RA' gods.map(getUpperName) // => ['RA', 'ZEUS', 'LOKI'] ``` + +### Search terms + +- Often called `compose`, `pipe`, or `flow` + +### Popular use cases + +- **Function composition**: Chain together multiple transformations, applying the result of each function as the input to the next. For example, first add a value, then multiply the result. +- **Data pipeline creation**: Build complex data transformation pipelines where each function modifies the data in sequence, improving readability and modularity. +- **Middleware processing**: Apply a series of middleware functions where the output of one is passed as input to the next, common in frameworks or request handling. diff --git a/docs/curry/compose.mdx b/docs/curry/compose.mdx index 066919e1..4e99cf43 100644 --- a/docs/curry/compose.mdx +++ b/docs/curry/compose.mdx @@ -36,3 +36,14 @@ const decomposed = useZero(objectize(increment(increment(_.returnArg('num'))))) decomposed() // => 2 ``` + +### Search terms + +- Often called `composeFunctions`, `chain`, or `pipeline` + +### Popular use cases + +- Combining multiple transformation functions into a single function to process data sequentially. +- Creating middleware stacks where each function modifies data and passes it to the next one. +- Building reusable and composable utility functions by composing different operations in a modular way. +- Simplifying complex logic by breaking it into smaller, maintainable pieces that are composed together. diff --git a/docs/curry/debounce.mdx b/docs/curry/debounce.mdx index a84fb827..448832e6 100644 --- a/docs/curry/debounce.mdx +++ b/docs/curry/debounce.mdx @@ -86,3 +86,14 @@ setTimeout(() => { myDebouncedFunc.isPending() // => false }, 100) ``` + +### Search terms + +- Often called `debounce`, `debouncedFunc`, or `throttleDebounce` + +### Popular use cases + +- Delaying execution of expensive operations, such as API requests or calculations, until a user has stopped interacting with the interface. +- Controlling the frequency of function execution, particularly for user inputs like typing, scrolling, or resizing events. +- Reducing the number of times a heavy computation or UI update is triggered in response to frequent actions. +- Ensuring that a function is called after a pause in actions, with methods to cancel, check status, or force execution. diff --git a/docs/curry/flip.mdx b/docs/curry/flip.mdx index 403e6ec6..78d54b05 100644 --- a/docs/curry/flip.mdx +++ b/docs/curry/flip.mdx @@ -18,3 +18,14 @@ _.flip(subtract)(1, 2) // => 1 ``` Note that functions with more than two arguments are not supported. + +### Search terms + +- Often called `flipArgs`, `reverseArgs`, or `swapParams` + +### Popular use cases + +- Reversing the order of the first two arguments in a function, making it easier to work with curried or partial applications. +- Adapting functions to match the argument order expected by other higher-order functions or utilities. +- Swapping arguments for improved readability in specific contexts, especially in functional programming. +- Simplifying complex function compositions by adjusting the argument order dynamically. diff --git a/docs/curry/memo.mdx b/docs/curry/memo.mdx index 67bbff50..f4eca580 100644 --- a/docs/curry/memo.mdx +++ b/docs/curry/memo.mdx @@ -62,3 +62,14 @@ const beta = timestamp({ group: 'beta' }) now === later // => true beta === now // => false ``` + +### Search terms + +- Often called `memoize`, `cacheFunction`, or `remember` + +### Popular use cases + +- Optimizing performance by caching the results of expensive computations and reusing them when the same inputs occur. +- Reducing redundant calculations in recursive functions, such as those for generating Fibonacci sequences or factorials. +- Enhancing API efficiency by storing and reusing responses within a specified time window, preventing unnecessary calls. +- Controlling cache expiration using TTL (time-to-live) to ensure stale data is eventually recalculated or refetched. diff --git a/docs/curry/once.mdx b/docs/curry/once.mdx index 76175f60..78e69c5f 100644 --- a/docs/curry/once.mdx +++ b/docs/curry/once.mdx @@ -30,3 +30,14 @@ once.reset(fn) fn() // 0.3 fn() // 0.3 ``` + +### Search terms + +- Often called `once`, `runOnce`, or `singleCall` + +### Popular use cases + +- Ensuring that a function executes only a single time, regardless of how many times it is invoked. +- Protecting sensitive or resource-heavy operations by restricting their execution to just one successful call. +- Managing initialization logic, such as setting up global state or event listeners, so they only occur once. +- Offering the ability to reset the function, allowing the operation to be executed again if needed, without repeated execution by default. diff --git a/docs/curry/partial.mdx b/docs/curry/partial.mdx index ec124d19..ece1f088 100644 --- a/docs/curry/partial.mdx +++ b/docs/curry/partial.mdx @@ -16,3 +16,14 @@ const addFive = _.partial(add, 5) addFive(2) // => 7 ``` + +### Search terms + +- Often called `partial`, `partialApply`, or `preFillArgs` + +### Popular use cases + +- Pre-filling some arguments of a function, creating a new function with fewer parameters for easier reuse. +- Simplifying complex operations by partially applying constant values, reducing the need for repetitive code. +- Adapting functions with multiple parameters for use in situations where fewer arguments are passed over time. +- Streamlining callback creation in scenarios where only a subset of the original function's arguments is known upfront. diff --git a/docs/curry/partob.mdx b/docs/curry/partob.mdx index 21d597cb..4ed6a420 100644 --- a/docs/curry/partob.mdx +++ b/docs/curry/partob.mdx @@ -16,3 +16,14 @@ const addFive = _.partob(add, { a: 5 }) addFive({ b: 2 }) // => 7 ``` + +### Search terms + +- Often called `partialObject`, `partob`, or `partialProps` + +### Popular use cases + +- Partially applying default properties or options to a function that accepts a single object argument, reducing code repetition. +- Creating specialized versions of object-based functions by pre-filling certain properties while allowing others to be supplied later. +- Simplifying configuration-heavy functions by breaking them down into smaller steps, where each step completes the object with additional fields. +- Reducing verbosity when working with functions that rely heavily on object destructuring by providing default values upfront. diff --git a/docs/curry/proxied.mdx b/docs/curry/proxied.mdx index e1446af5..7bd956f1 100644 --- a/docs/curry/proxied.mdx +++ b/docs/curry/proxied.mdx @@ -27,3 +27,14 @@ person.name // => Joe person.size // => 20 person.getLocation() // => here ``` + +### Search terms + +- Often called `proxied`, `dynamicProxy`, or `propertyInterceptor` + +### Popular use cases + +- Dynamically transforming or computing the values of object properties based on their names when accessed. +- Creating virtual objects that derive values on-the-fly, avoiding the need for pre-defined properties. +- Implementing flexible APIs where property access triggers custom logic or data retrieval, based on the property name. +- Simplifying code by allowing properties to be accessed without explicitly defining them, with logic applied during access. diff --git a/docs/curry/throttle.mdx b/docs/curry/throttle.mdx index 3691013e..8467e836 100644 --- a/docs/curry/throttle.mdx +++ b/docs/curry/throttle.mdx @@ -62,3 +62,14 @@ Source Invocations: x - - - - - - - - - - - - x - - - - - - - - - - - - - x - - ``` In this diagram, 'x' represents function invocations, and '-' represents time passing. + +### Search terms + +- Often called `throttle`, `limitCalls`, or `rateLimit` + +### Popular use cases + +- Limiting the frequency of function calls in response to rapidly occurring events like scrolling, resizing, or key presses. +- Ensuring a function is not executed more than once within a specified time interval to optimize performance. +- Delaying execution of repeated function calls but allowing a final trailing call to execute after the last event in some cases. +- Useful for scenarios like logging, network requests, or animation triggers that shouldn't be triggered too frequently.