# @skema/basic

> Basic types for skema

Latest version **1.0.40** (published 2020-05-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install @skema/basic
pnpm add @skema/basic
yarn add @skema/basic
bun add @skema/basic
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.40 |
| Published | 2020-05-05 |
| First published | 2018-01-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=4 |
| Dependencies | 1 |
| Unpacked size | 10.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 354 |
| Author | kaelzhang |
| Maintainers | kael |
| Keywords | skema, schema, type, primative, javascript, loose, strict |

## Links

- npm: https://www.npmjs.com/package/@skema/basic
- Repository: https://github.com/kaelzhang/skema
- Homepage: https://github.com/kaelzhang/skema#readme
- Issues: https://github.com/kaelzhang/skema/issues
- npm.io page: https://npm.io/package/@skema/basic

## Dependencies (1)

- [core-util-is](https://npm.io/package/core-util-is.md) ^1.0.2

## 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

- 1.0.40 (latest) — 2020-05-05
- 1.0.39 — 2020-05-05
- 1.0.36 — 2019-09-20
- 1.0.35 — 2019-09-20
- 1.0.34 — 2019-09-05
- 1.0.33 — 2019-07-17
- 1.0.32 — 2019-03-29
- 1.0.31 — 2019-03-29
- 1.0.30 — 2019-03-11
- 1.0.29 — 2019-03-11
- 1.0.28 — 2018-10-16
- 1.0.27 — 2018-10-16
- 1.0.26 — 2018-06-29
- 1.0.25 — 2018-06-29
- 1.0.24 — 2018-06-19
- … 23 more at https://npm.io/package/@skema/basic/versions

## README

# @skema/basic

[`skema`](https://github.com/kaelzhang/skema) type definitions for basic javascript types, including:

- `String` (`'string'`)
- `Number` (`'number'`)
- `Date` (`'date'`)
- `RegExp` (`'regexp'`)
- `Object` (`'object'`)
- `Function` (`'function'`)
- `Error` (`'error'`)
- `Symbol` (`'symbol'`)

## install

```sh
npm i @skema/basic
```

## `LOOSE`

The basic type definitions that it convert the properties of wrong values into the right ones if possible.

```js
import {defaults} from 'skema'
import {LOOSE} from '@skema/basic'

const {
  skema
} = defaults({
  types: LOOSE
})

const User = skema({
  id: Number,       // To use 'number' is also ok
  name: 'string'    // To use String is also ok
})

const user = User.from({
  id: '1',  // id will be converted to `1`
  name: 'Steve'
})

console.log(user)
// {
//   id: 1,
//   name: 'Steve'
// }

const Order = skema({
  id: String,
  createTime: Date
})

Order.from({
  id: '6352534847126241280',
  createTime: 'hahahaha'  // Oh, this date is gone too far!
})
// Error thrown
```

## `STRICT`

The very strict type definition, that it will throw if the given data doesn't match the type of the schema.

```js
import {defaults} from 'skema'
import {STRICT} from '@skema/basic'

const {
  skema
} = defaults({
  types: STRICT
})

const User = skema({
  id: Number,
  name: String
})

const user = User.from({
  // id must be a number
  id: '1',
  name: 'Steve'
})
// Error thrown
```

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