New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

datypes

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

datypes

Global Javascript Extended Types

latest
Source
npmnpm
Version
1.3.1
Version published
Weekly downloads
3
200%
Maintainers
1
Weekly downloads
 
Created
Source

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!

Keywords

types

FAQs

Package last updated on 25 Mar 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts