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

@slimio/is

v2.0.0

Published

SlimIO is (JavaScript Primitives & Objects type checker)

Downloads

1,909

Readme

SlimIO IS

version Maintenance MIT size build

Node.js JavaScript Type checker (Primitives, Objects, etc..)

Package heavily inspired by @sindresorhus/is. This package aims to work on Node.js (no browser support).

Why

  • Focus on type checking (no fancy feature).
  • Focus on Node.js support.
  • Come with a TypeScript definition (which works).
  • Is concerned about being stable.

Requirements

Getting Started

This package is available in the Node Package Repository and can be easily installed with npm or yarn.

$ npm i @slimio/is
# or
$ yarn add @slimio/is

Usage example

const { strictEqual } = require("assert");
const is = require("@slimio/is");

strictEqual(is.bool(true), true);
strictEqual(is.string("hello"), true);
strictEqual(is.map(new Map()), true);
strictEqual(is.func(() => {}), true);

The is const namespace is a Plain JavaScript Object with a lot of exported methods (check the below API Documentation).

API

All methods can be called as follow: is.{methodName}. All methods return a boolean value.

Primitives

| method | example | | --- | --- | | string | is.string("hello") | | number | is.number(10) | | boolean | is.boolean(true) | | bool | is.bool(false) | | symbol | is.symbol(Symbol("foo")) | | undefined | is.undefined(undefined) | | bigint | is.bigint(50n) | | nullValue | is.nullValue(null) | | nullOrUndefined | is.nullOrUndefined(null) | | primitive | is.primitive("hello") |

is.null is not available because of a name restriction.

Objects

| method | example | | --- | --- | | promise | is.promise(new Promise()) | | classObject | is.classObject(new Class{}) | | array | is.array([]) | | object | is.object({}) | | plainObject | is.plainObject(Object.create(null)) | | set | is.set(new Set()) | | map | is.map(new Map()) | | weakMap | is.weakMap(new WeakMap()) | | weakSet | is.weakSet(new WeakSet()) | | error | is.error(new Error("ooppss!")) | | date | is.date(new Date()) | | regExp | is.regExp(/^hello world$/) | | buffer | is.buffer(Buffer.from("hello")) |

is.class is not available because of a name restriction.

Functions & Iterators

| method | example | | --- | --- | | func | is.func(new Function()) | | generatorFunction | N/A | | asyncFunction | is.asyncFunction(async function() {}) | | boundFunction | is.boundFunction((function(){}).bind(null)) | | iterable | is.iterable([1, 2]) | | asyncIterable | N/A | | generator | N/A |

is.function has been reduced to is.func because of a name restriction.

Typed Arrays

| method | example | | --- | --- | | typedArray | is.typedArray(new int8Array()) | | int8Array | is.int8Array(new int8Array()) | | uint8Array | is.uint8Array(new uint8Array()) | | uint8ClampedArray | is.uint8ClampedArray(new uint8ClampedArray()) | | int16Array | is.int16Array(new int16Array()) | | uint16Array | is.uint16Array(new uint16Array()) | | int32Array | is.int32Array(new int32Array()) | | uint32Array | is.uint32Array(new uint32Array()) | | float32Array | is.float32Array(new float32Array()) | | float64Array | is.float64Array(new float64Array()) | | arrayBuffer | is.arrayBuffer(new ArrayBuffer()) | | sharedArrayBuffer | is.sharedArrayBuffer(new SharedArrayBuffer()) | | dataView | is.dataView(new DataView(new ArrayBuffer(8))) |

Misc

| method | example | | --- | --- | | nan | is.nan(Number("booom!")) | | integer | is.integer(5 / 10) | | directInstanceOf | is.directInstanceOf(Object, {}) | | truthy | is.truthy(true) | | falsy | is.falsy("") | | emptyString | is.emptyString("") |

Dependencies

This project have no dependencies.

License

MIT