# otfunc

> A JavaScript library to describe the overrided function and strong type arguments.

Latest version **0.1.4** (published 2019-08-03) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install otfunc
pnpm add otfunc
yarn add otfunc
bun add otfunc
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.4 |
| Published | 2019-08-03 |
| First published | 2019-07-07 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 32.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | langyo |
| Maintainers | langyo |
| Keywords | javascript, functional, override, type, typing |

## Links

- npm: https://www.npmjs.com/package/otfunc
- Repository: https://github.com/langyo/otfunc
- Issues: https://github.com/langyo/otfunc/issues
- npm.io page: https://npm.io/package/otfunc

## Dependencies (4)

- [jest](https://npm.io/package/jest.md) ^24.8.0
- [@babel/core](https://npm.io/package/@babel/core.md) ^7.5.5
- [@babel/preset-env](https://npm.io/package/@babel/preset-env.md) ^7.5.5
- [@babel/plugin-proposal-class-properties](https://npm.io/package/@babel/plugin-proposal-class-properties.md) ^7.5.5

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 0.1.4 (latest) — 2019-08-03
- 0.1.3 — 2019-08-03
- 0.1.2 — 2019-07-15
- 0.1.1 — 2019-07-08
- 0.1.0 — 2019-07-07

## README

# otfunc

（全称 Override and strong Type FUNCtions）

这是一个用于为 JavaScript 开发的工具库，用于实现运行时的函数重载与强类型推断。

## 例子

```javascript
const { override, strongly, Types } = require(otfunc;

const func = override([
  // 演示最基本的函数重载。
  () => console.log("无类型推断，无参数"),

  (a, b) => console.log("无类型推断，有两个参数：", a, b),

  // 演示带有类型限定的一部分函数重载。
  strongly([], () => console.log("带类型推断，无参数")),

  strongly(
    [Number, String],
    (n, s) => console.log("带类型推断，参数为数字", n, "与字符串", s)
  ),
  
  strongly(
    [[Number]],
    arr => console.log("带类型推断，传入一个数字数组：", arr)
  ),

  strongly(
    [{
      name: String,
      score: Number
    }],
    obj => console.log("带类型推断，传入一个鸭子类型的对象，限定了传入的参数对应的对象必须包含哪些键、类型必须为什么：", obj)
  ),

  strongly(
    [[BigInt, Number], [["!", String]]],
    (num, notString) => console.log(
      "带类型推断，",
      "第一个参数既可以是普通数字，也可以是内置的大数类型：", num,
      "第二个参数则保证不是字符串：", notString
    )
  ),

  strongly(
    [[[BigInt], [Number]]],
    numbers => console.log("带类型推断，这次为复合类型，允许你传入一个数字数组或一个大数数组：", numbers)
  )
]);
```

---
_Source: https://npm.io/package/otfunc · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
