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 🙏

© 2025 – Pkg Stats / Ryan Hefner

is-has

v1.3.0

Published

Set of checking functions. No deps! Never throws errors!

Downloads

633

Readme

is-has

Release

Set of checking functions. No deps! Never throws errors!

Installation

npm i is-has

Functions

hasOwnProperty

declare function hasOwnProperty<T = object>(obj: T, key: keyof T): key is keyof T;
declare function hasOwnProperty(obj: any, key: any): key is keyof obj;

hasOwnProperty checks if obj has its own property. The result is fully compatible with Object.hasOwn.

import {hasOwnProperty} from 'is-has';

class Class1 {
  propA: string = 'propA';
  static propB: string = 'static propB';
  #propC: string = '#propC';
  static #propD: string = 'static #propD';

  get propC() {
    return this.#propC;
  }

  static get propD() {
    return this.#propD;
  }

  functionA() {
    return 'functionA';
  }

  static functionB() {
    return 'functionB';
  }
}

const classInstance = new Class1();

const obj = {
  propA: 'propA',
  get propB() {
    return 'propB';
  },
};

const arr = [1, '2', 3, 'aaa'];

hasOwnProperty(Class1, 'propA');     // false
hasOwnProperty(Class1, 'propB');     // true
hasOwnProperty(Class1, 'propC');     // false
hasOwnProperty(Class1, 'propD');     // true
hasOwnProperty(Class1, 'functionA'); // false
hasOwnProperty(Class1, 'functionB'); // true

hasOwnProperty(classInstance, 'propA');     // true
hasOwnProperty(classInstance, 'propB');     // false
hasOwnProperty(classInstance, 'propC');     // false
hasOwnProperty(classInstance, 'propD');     // false
hasOwnProperty(classInstance, 'functionA'); // false
hasOwnProperty(classInstance, 'functionB'); // false

hasOwnProperty(obj, 'propA'); // true
hasOwnProperty(obj, 'propB'); // true
hasOwnProperty(obj, 'propC'); // false
hasOwnProperty(obj, null);    // false

hasOwnProperty(arr, 0);         // true
hasOwnProperty(arr, 4);         // false
hasOwnProperty(arr, 'length');  // true
hasOwnProperty(arr, 'aaa');     // false
hasOwnProperty(arr, null);      // false
hasOwnProperty(arr, undefined); // false

hasOwnProperty('obj', 'propA');       // false
hasOwnProperty(123, 'propC');         // false
hasOwnProperty(null, null);           // false
hasOwnProperty(undefined, undefined); // false

isNumber

declare function isNumber(variable?: unknown): variable is number;

isNumber checks if a variable is a number.

  • Both Infinity and NaN are treated as non-numbers.
  • BigInt is a separate story in JS, so it's not treated as a number as well.
import {isNumber} from 'is-has';

isNumber(0);     // true
isNumber('0');   // false
isNumber('hi');  // false
isNumber(0 / 0); // false
isNumber(1 / 0); // false
isNumber(123n);  // false

isString

declare function isString(variable?: unknown): variable is string;

isString checks if variable is a string.

import {isString} from 'is-has';

isString(123);      // false
isString('Hello!'); // true