npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@juanjo4u/utils

v1.0.2

Published

utilities that makes your code more readable

Downloads

4

Readme

utils

// to install just run yarn add @juanjo4u/utils

import { isParams } from "@juanjo4u/utils";

const a = {
    name: 'Juanjo',
    age: 27,
    date: new Date(),
    regex: new RegExp(),
    arr: [{ omg: 'OMG' }],
    obj: {
        wtf: 'WTF',
        last: {
            last: [{}]
        }
    }
}

const b = {
    name: 'Juanjo',
    age: 27,
    date: new Date(),
    regex: new RegExp(),
    arr: [{ omg: 'OMG' }],
    obj: {
        wtf: 'WTF',
        last: {
            last: [{}]
        }
    }
}

console.clear()
console.log("IS A === B ?: ", isParams(a).valuesEqualTo(b)) // it will return true cause it makes a deep comparison of the object
/*  
    YOU CAN PASS AS MANY ARGUMENTS AS YOU WANT TO VALIDATE 
    isParams return an object with functions that returns true or false 
*/

isParams(new Date()).instanceOf(Date) // true
isParams(new Date()).instanceOf(RegExp) // false

isParams(a.date).datesEqualTo(b.date) // true
b.date.setDate(b.date.getDate() - 1) // we update the date on object b to test it again
isParams(a.date).datesEqualTo(b.date) // false  cause now b.date has another date value

isParams('1', 1).valuesEqualTo(1) // false  it also makes a type comparison
isParams({},[]).valuesEqualTo([]) // false it makes a difference bettween Array and Object *** typeof recognize an Array as Object

isParams(b.arr).lengthEqualTo(a.arr) // true  is not needed to send length it takes it automatically, and also it gives you the length of string, array, or Object keys
b.arr.push(1) // we update the array to test if it return false
isParams(b.arr).lengthEqualTo(a.arr) // false

isParams('', 1, [],{}).typeEqualTo('array') // false  it compares the types of all params set on isParams as commented before it takes array and object as different type
// the args sent to typeEqualTo is the same as typeof I just added 'array' and a deep comparison bettween array and object

// objectType && arrayType validates if all paramas passed to isParams are object or array