import { versioned } from "versioned-function";
// --- define our functions ---
const { matcher } = versioned({
"0.0.0": () => ({ crazy: "world" }),
"1.0.0": () => ({ yea: "nah" }),
"2.0.0": (name: string) => ({ hello: name }),
});
// export it out for others to use
export const MyFunction = matcher
// --- consumer ---
// here we pass in the version that we want
const oldFunction = MyFunction("0.0.0")
const latestFunction = MyFunction("1.0.0")
const nextFunction = MyFunction("2.0.0")
oldFunction() // { crazy: "world" }
latestFunction() // { yea: "nah" }
nextFunction("nick") // { hello: "nick" }
a simple function to handler multiple versions of the same function, eg for versioning sql queries
License
NWylynko/versioned-function
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
a simple function to handler multiple versions of the same function, eg for versioning sql queries
Resources
License
Stars
Watchers
Forks
Packages 0
No packages published