# @types/spected

> TypeScript definitions for spected

Latest version **0.7.4** (published 2023-11-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install @types/spected
pnpm add @types/spected
yarn add @types/spected
bun add @types/spected
```

## Health

**Score 45/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high maintenance score; popular repo; extremely popular.

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

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.7.4 |
| Published | 2023-11-21 |
| First published | 2019-01-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 51450 |
| Maintainers | types |

## Links

- npm: https://www.npmjs.com/package/@types/spected
- Repository: https://github.com/DefinitelyTyped/DefinitelyTyped
- Homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/spected
- npm.io page: https://npm.io/package/@types/spected

## Recent versions

- 0.7.4 (latest) — 2023-11-21
- 0.7.0 (ts2.8) — 2019-01-23
- 0.26.0 (ts2.1) — 2019-01-14
- 0.7.3 — 2023-11-07
- 0.7.2 — 2023-10-18
- 0.7.1 — 2023-09-25

## README

# Installation
> `npm install --save @types/spected`

# Summary
This package contains type definitions for spected (https://github.com/25th-floor/spected).

# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/spected.
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/spected/index.d.ts)
````ts
declare function spected<ROOTINPUT, SPEC extends SpecValue<ROOTINPUT, ROOTINPUT> = SpecValue<ROOTINPUT, ROOTINPUT>>(
    spec: SPEC,
    input: ROOTINPUT,
): Result<ROOTINPUT, SPEC>;

type Predicate<INPUT, ROOTINPUT> = (value: INPUT, inputs: ROOTINPUT) => boolean;

type ErrorMsg<INPUT> =
    | (string | number | boolean | symbol | null | undefined | object)
    | ((value: INPUT, field: string) => any);

export type Spec<INPUT, ROOTINPUT = any> = [Predicate<INPUT, ROOTINPUT>, ErrorMsg<INPUT>];

export type SpecArray<INPUT, ROOTINPUT = any> = Array<Spec<INPUT, ROOTINPUT>>;

export type SpecFunction<INPUT, ROOTINPUT = any> = [INPUT] extends [ReadonlyArray<infer U>]
    ? (value: INPUT) => ReadonlyArray<SpecArray<U, ROOTINPUT>>
    : [INPUT] extends [object] ? (value: INPUT) => SpecObject<INPUT, ROOTINPUT>
    : (value: INPUT) => SpecArray<INPUT, ROOTINPUT>;

export type SpecObject<INPUT, ROOTINPUT = any> = Partial<{ [key in keyof INPUT]: SpecValue<INPUT[key], ROOTINPUT> }>;

export type SpecValue<INPUT, ROOTINPUT = any> = [INPUT] extends [readonly any[]]
    ? SpecArray<INPUT, ROOTINPUT> | SpecFunction<INPUT, ROOTINPUT>
    : [INPUT] extends [object]
        ? SpecArray<INPUT, ROOTINPUT> | SpecFunction<INPUT, ROOTINPUT> | SpecObject<INPUT, ROOTINPUT>
    : SpecArray<INPUT, ROOTINPUT> | SpecFunction<INPUT, ROOTINPUT>;

export type Result<INPUT, SPEC> = { [key in keyof INPUT]: true | any[] | Result<INPUT[key], any> };

export default spected;

````

### Additional Details
 * Last updated: Mon, 20 Nov 2023 23:36:24 GMT
 * Dependencies: none

# Credits
These definitions were written by [Benjamin Makus](https://github.com/benneq).

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