versioned-function
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

versioned-function

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" }

Readme

Keywords

none

Package Sidebar

Install

npm i versioned-function

Weekly Downloads

1

Version

1.1.0

License

MIT

Unpacked Size

9.05 kB

Total Files

12

Last publish

Collaborators

  • nwylynko