# datypes

> Global Javascript Extended Types

Latest version **1.3.1** (published 2023-03-25) · ISC license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.1 |
| Published | 2023-03-25 |
| First published | 2023-02-25 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 31.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Dann |
| Maintainers | seadann |
| Keywords | types, objects, number, array, methods |

## Links

- npm: https://www.npmjs.com/package/datypes
- Repository: https://github.com/DannZzz/datypes
- Homepage: https://github.com/DannZzz/datypes#readme
- Issues: https://github.com/DannZzz/datypes/issues
- npm.io page: https://npm.io/package/datypes

## Dependencies (1)

- [anytool](https://npm.io/package/anytool.md) ^1.0.2

## Alternatives

- [random-seedable](https://npm.io/package/random-seedable.md) — 27.9K weekly downloads
- [n2words](https://npm.io/package/n2words.md) — 22.2K weekly downloads
- [@stdlib/math-base-special-factorialln](https://npm.io/package/@stdlib/math-base-special-factorialln.md) — 5.7K weekly downloads
- [@stdlib/math-base-special-abs2](https://npm.io/package/@stdlib/math-base-special-abs2.md) — 1.7K weekly downloads
- [commons-math-interpolation](https://npm.io/package/commons-math-interpolation.md) — 1.4K weekly downloads

## Recent versions

- 1.3.1 (latest) — 2023-03-25
- 1.3.0 — 2023-03-25
- 1.2.3 — 2023-03-21
- 1.2.2 — 2023-03-05
- 1.2.1 — 2023-03-05
- 1.2.0 — 2023-03-01
- 1.1.9 — 2023-03-01
- 1.1.8 — 2023-03-01
- 1.1.7 — 2023-02-27
- 1.1.6 — 2023-02-27
- 1.1.5 — 2023-02-27
- 1.1.4 — 2023-02-27
- 1.1.3 — 2023-02-27
- 1.1.2 — 2023-02-27
- 1.1.1 — 2023-02-27
- … 4 more at https://npm.io/package/datypes/versions

## README

# Da Daaam (Global Javascript Extended Types)

I don't even know, are there packages better

Just wanted to write mine, own

Soooo..

# [Check Last Update](#changelog)

# Types

- $object
- $Array
- $string
- $number

I gave them some methods which I use too often

# Installation

```sh
npm install datypes
```

Or

```sh
yarn add datypes
```

# Get Started

First we have to initialize global function $

**You have to run this function in your main file only once**

```ts
import initTypes from "datypes"

initTypes()
```

Now We can define variables

**Let's do**

```ts
const person = $({
  name: "Dann",
  age: 18,
  hobbies: $(["_", "_"]),
})
```

So what can we actually do?

```ts
person.$empty() // false
person.$forEach((value, key) => console.log(`${key} : `, value))
const cloneWithoutRefs = person.$clone()
person.$hasSome("age", "hobbies", "girlfriend") // true
person.$hasAll("age", "hobbies", "girlfriend") // false

person.hobbies.remove(0) // ["_"] removes it's element
person.hobbies.log() // logs value
```

Types now are global

```ts
let age: $number
let person: $object<MyInterface>
```

Also array method **.readonly()**

```ts
const arr = $([1, 2, 3]) // type - number[]
const readonlyArr = arr.readonly() // type - readonly number[]
```

# $ArrayLength

```ts
const numbers = $.$ArrayLength(5, (i) => i) // [0, 1, 2, 3, 4]

const randomDigits = $.$ArrayLength(4, () => $.randomNumber(0, 9)) // [4, 6, 7, 1]
```

# Changelog

v1.3.0

- Removed static methodes from $number, $string, $object and $Array
- Added new static methods for global function $
  - is$number (whether or not value is an instance of $number)
  - is$string (whether or not value is an instance of $string)
  - is$object (whether or not value is an instance of $object)
  - is$Array (whether or not value is an instance of $Array)
  - randomNumber (returns random number between a range)
  - [$ArrayLength](#arraylength) (returns an $Array with spec. length by custom map)

v1.2.3

- New methods for Arrays (includesAny, includesAll, compute)
- New methods for Strings (includesAny, includesAll, capitalizeFirst)

## It's not All!

[Install](#installation) and check yourself!

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