Releases: seasonedcc/composable-functions
v2.5.1
What's Changed
Full Changelog: v2.5.0...v2.5.1
v2.5.0
What's Changed
- feat: Add async capabilities for the trace function by @gustavoguichard in #116
Full Changelog: v2.4.0...v2.5.0
v2.4.0
What's Changed
The zod peer dependency is now gone. This is a backwards compatible change since we still use a subtype of zod parsers and will keep tracking zod interface as our de-facto standard. However, this opens the possibility of adaptors for other libraries as well.
Full Changelog: v2.3.0...v2.4.0
v2.3.0 - "Conditional `pipe`" and `mdf` alias ✂️
New Features
- We now export
mdf
alias formakeDomainFunction
so your compositions will look less verbose by @gustavoguichard in #111 - Improved
branch
method to act like conditionalpipe
by @gustavoguichard in #112
You can now conditionally pipe
by returning null
from a branch
, e.g:
// Check out the new `mdf` alias!
import { mdf, branch } from 'domain-functions'
import z from 'zod'
const a = mdf()(Math.random)
const b = mdf(z.number())(String)
// This function will only pipe to `b` if the output of `a` is greater than 0.5
const df = branch(a, output => output > 0.5 ? b : null)
// ^? DomainFunction<number | string>
The branch
method will keep working as always if you return other domain functions from it:
import { mdf, branch } from 'domain-functions'
const a = mdf()(Math.random)
const b = mdf()(() => 'high')
const c = mdf()(() => 'low')
const df = branch(a, output => output > 0.5 ? b : c)
// ^? DomainFunction<'high' | 'low'>
Other changes
- Expose and add JSDocs to
safeResult
to allow people to build their own combinators by @gustavoguichard in #110
Full Changelog: v2.0.0...v2.3.0
v2.2.0 - Rollback @decs/typeschema 😅
What's Changed
In version 2.1.0 we released the possibility of using domain-functions with other schema validation libraries through @decs/typeschema but we missed a breaking change due to optional peerDependencies on typeschema that would require bundler configuration changes or installing a bunch of peerDependencies on each project.
We are rolling back indeterminately.
domain-functions v2 🎉
🔥 Breaking changes
- Removed the
qs
dependency so someinputRessolvers
might return different results for a few edge cases. - Removed
errorMessagesForSchema
, it seems to be used only inremix-forms
. We will move this code there. - Removed deprecated types
List
andListToResultData
, check #101
😎 New feature
- The bundle size was reduced from 37.9kB (11.4kB gzipped) to 5.7kB (1.8kB gzipped) 🧙🏿♂️.
collectSequence
combinator. It is a sequential version of collect and uses the input object keys' order to determine the sequence of functions to be called.- DX improvement: JSDocs with inline documentation of every public method #90
🧹 Housekeeping
- Use a
test-prelude
to keep test imports in a central location, also upgrade our std library version used for testing. - We've updated our Remix example with newer remix versions and domain-functions conventions. #93
- We simplified the implementation of some combinators #89 and #87
Full Changelog: v1.8.0...v2.0.0
v1.8.0 - 'branch' for conditional compositions 🔀
Updates
We just introduced a new branch
combinator. Check it out in the README, you'll love it!
The branch
function makes it easy to express more complex conditions in your compositions. It accepts 1 domain function and a predicate function that should return another domain function. You can use the output of the first function to make some conditional check and decide between the next possible domain function to run. It works sequentially like pipe
.
const prelude = makeDomainFunction()(() => ({ total: 2, next: 'multiply' }))
const sum = makeDomainFunction(z.object({ total: z.number() }))(n => n + 1)
const multiply = makeDomainFunction(z.object({ total: z.number() }))(n => n * 2)
const df = branch(prelude, output => output.next === 'multiply' ? multiply : sum)
// ^? DomainFunction<number>
What's Changed
- Branch 🔀 combinator by @gustavoguichard in #82
- Bug fix 🐞: Remove prettify to avoid circular bug by @gustavoguichard in #83
Full Changelog: v1.7.1...v1.8.0
v1.7.1
What's Changed
- Split tests and assert inferred types with more precision by @gustavoguichard in #72
- Update Zod to 3.21.4 #73 by @faramos in #74
New Contributors 🎉
Full Changelog: v1.7.0...v1.7.1