1.3.1 • Published 1 year ago

datypes v1.3.1

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

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

Types

  • $object
  • $Array
  • $string
  • $number

I gave them some methods which I use too often

Installation

npm install datypes

Or

yarn add datypes

Get Started

First we have to initialize global function $

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

import initTypes from "datypes"

initTypes()

Now We can define variables

Let's do

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

So what can we actually do?

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

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

Also array method .readonly()

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

$ArrayLength

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 (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 and check yourself!

1.2.3

1 year ago

1.3.1

1 year ago

1.3.0

1 year ago

1.2.2

1 year ago

1.2.1

1 year ago

1.2.0

1 year ago

1.1.9

1 year ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago