New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@slimio/is

Package Overview
Dependencies
Maintainers
5
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@slimio/is

SlimIO is (JavaScript Primitives & Objects type checker)

  • 1.5.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
191
decreased by-52.01%
Maintainers
5
Weekly downloads
 
Created
Source

SlimIO IS

version Maintenance MIT size Known Vulnerabilities dep Greenkeeper badge Build Status

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

  • Node.js v10 or higher.

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

methodexample
stringis.string("hello")
numberis.number(10)
booleanis.boolean(true)
boolis.bool(false)
symbolis.symbol(Symbol("foo"))
undefinedis.undefined(undefined)
bigintis.bigint(50n)
nullValueis.nullValue(null)
nullOrUndefinedis.nullOrUndefined(null)
primitiveis.primitive("hello")

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

Objects

methodexample
promiseis.promise(new Promise())
classObjectis.classObject(new Class{})
arrayis.array([])
objectis.object({})
plainObjectis.plainObject(Object.create(null))
setis.set(new Set())
mapis.map(new Map())
weakMapis.weakMap(new WeakMap())
weakSetis.weakSet(new WeakSet())
erroris.error(new Error("ooppss!"))
dateis.date(new Date())
regExpis.regExp(/^hello world$/)
bufferis.buffer(Buffer.from("hello"))

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

Functions & Iterators

methodexample
funcis.func(new Function())
generatorFunctionN/A
asyncFunctionis.asyncFunction(async function() {})
boundFunctionis.boundFunction((function(){}).bind(null))
iterableis.iterable([1, 2])
asyncIterableN/A
generatorN/A

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

Typed Arrays

methodexample
typedArrayis.typedArray(new int8Array())
int8Arrayis.int8Array(new int8Array())
uint8Arrayis.uint8Array(new uint8Array())
uint8ClampedArrayis.uint8ClampedArray(new uint8ClampedArray())
int16Arrayis.int16Array(new int16Array())
uint16Arrayis.uint16Array(new uint16Array())
int32Arrayis.int32Array(new int32Array())
uint32Arrayis.uint32Array(new uint32Array())
float32Arrayis.float32Array(new float32Array())
float64Arrayis.float64Array(new float64Array())
arrayBufferis.arrayBuffer(new ArrayBuffer())
sharedArrayBufferis.sharedArrayBuffer(new SharedArrayBuffer())
dataViewis.dataView(new DataView(new ArrayBuffer(8)))

Misc

methodexample
nanis.nan(Number("booom!"))
integeris.integer(5 / 10)
directInstanceOfis.directInstanceOf(Object, {})
truthyis.truthy(true)
falsyis.falsy("")
emptyStringis.emptyString("")

Dependencies

This project have no dependencies.

License

MIT

Keywords

FAQs

Package last updated on 11 Jun 2019

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc