
Security News
CVE Volume Surges Past 48,000 in 2025 as WordPress Plugin Ecosystem Drives Growth
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.
options-curry
Advanced tools
Curry a function's default options.
Since working with TypeScript I've moved to mostly having functions that only accepts 1 options argument as then the args get named, order of args doesn't matter, and you can add new options without breaking the API.
Sometimes it's nice to compose a new function with default values set. This lib does that.
npm i options-curry --save
yarn add options-curry
import { withDefaults } from 'options-curry';
// Create function with an options object
function fn({ foo, bar }: { foo: string; bar: string }) {
return { foo, bar };
}
// Compose new function where options are pre-set
const fnWithDefaults = withDefaults(fn, {
foo: 'foo',
});
// `foo`-key is now optional in `fnWithDefaults`
console.log(fnWithDefaults({ bar: 'bar' })); // ➡️ { foo: 'foo', bar: 'bar' }
console.log(fnWithDefaults({ bar: 'bar', foo: 'x' })); // ➡️ ️{ foo: 'x', bar: 'bar' }
// We can compose a new function from our function with defaults
const composedFn = withDefaults(fnWithDefaults, { bar: 'bar' });
console.log(composedFn({})); // ➡️ `{ foo: 'foo', bar: 'bar' }`
import { withDefaults } from 'options-curry';
// Create function with an options object
function fn({ foo, bar }: { foo: string; bar: string }) {
return { foo, bar };
}
// Compose new function where options are pre-set
const fnWithDefaults = withDefaults(fn, {
foo: 'foo',
});
// Input arguments are typed
fnWithDefaults({
bar: 1, // ❌ Error "Type 'number' is not assignable to type 'string'"
});
// ReturnType is typed
const ret = fnWithDefaults({ bar: 'x' });
console.log(ret.nope); // ❌ Error: "Property 'nope' does not exist on type '{ foo: string; bar: string; }"
(This project was bootstrapped with TSDX.)
Below is a list of commands you will probably find useful.
yarn startRuns the project in development/watch mode. Your project will be rebuilt upon changes. TSDX has a special logger for you convenience. Error messages are pretty printed and formatted for compatibility VS Code's Problems tab.
yarn buildBundles the package to the dist folder.
The package is optimized and bundled with Rollup into multiple formats (CommonJS, UMD, and ES Module).
yarn testRuns the test watcher (Jest) in an interactive mode. By default, runs tests related to files changed since the last commit.
FAQs
TypeScript Options-object Currying
We found that options-curry demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.

Security News
Socket CEO Feross Aboukhadijeh joins Insecure Agents to discuss CVE remediation and why supply chain attacks require a different security approach.

Security News
Tailwind Labs laid off 75% of its engineering team after revenue dropped 80%, as LLMs redirect traffic away from documentation where developers discover paid products.