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

isdo

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

isdo

Simple, basic, but robust javascript utilities.

  • 0.0.2
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

isdo

A simple, basic, and robust set of utilities for javascript - inspired by, but not copied from, lodash.

Table of Contents

  1. Installation
  2. Examples
  3. Usage
  4. Roadmap

Installation

$ npm i -S isdo

Examples

const { is } = require('isdo');

let foo;
is.defined(foo); // => false
is.missing(foo); // => true

foo = null;
is.defined(foo) // => true
is.missing(foo) // => true

const arry = [];
is.array(arry); // => true
is.empty(arry); // => true

arry.push(1);
is.empty(arry); // => false

Usage

is

Extending is

You can add your own useful comparisons and checks by using is.extend.

type comparisons

presence checks

quality checks

truthy/falsey checks

extending with custom methods

is.all

presence checks

truthy/falsey checks

is.any

presence checks

truthy/falsey checks


is

is.array(target)

Returns

true if target is an array, otherwise false.

is.boolean(target)

Returns

true if target is a boolean, otherwise false.

is.float(target)

Returns

true if target is a float, otherwise false.

is.function(target)

Returns

true if target is a function, otherwise false.

is.integer(target)

Returns

true if target is an integer, otherwise false.

is.iterable(target)

Returns

true if target conforms to the iterable protocol, otherwise false.

is.map(target)

Returns

true if target is a map, otherwise false.

is.number(target)

Returns

true if target is a number (integer or float), otherwise false.

is.object(target)

Returns

true if target is a plain object, otherwise false.

is.set(target)

Returns

true if target is a set, otherwise false.

is.string(target)

Returns

true if target is a string, otherwise false.

is.defined(target)

Returns

true if target is NOT undefined, otherwise false.

is.missing(target)

Returns

true if target is either undefined or null, otherwise false.

is.notNull(target)

Returns

true if target is anything other than null, even undefined, otherwise false.

is.present(target)

Returns

true if target is both defined and not null, otherwise false.

is.blank(target)

Returns

true if target string is missing or has length < 1, otherwise false.

is.empty(target)

Returns

true if target's length < 1, otherwise false.

If target is an array or string, length = target.length, if target is a map or set, length = target.size, if target is an object, length = number of keys in target, otherwise length = 0.

is.true(target)

Returns

true if target is a string and is one of ["t", "true", "1"], or if target is a number and is > 0, or if target is a boolean and is true, otherwise returns false.

Ignores capitalization.

is.false(target)

Returns

true if target is a string and is one of ["f", "false", "0"], or if target is a number and is <= 0, or if target is a boolean and is false, otherwise returns false.

Ignores capitalization.

is.extend(source)

Transfers functions and nested functions from source to is.

Example

const moment = require('moment');
const isdo = require('is');

const is = isdo.is.extend({
  date: obj => moment.isDate(obj),
});

is.date('foo'); // => false
is.date(new Date()); // => true

is.all

is.all.defined(targets)

Returns

true if all targets are defined, otherwise false.

is.all.undefined(targets)

Returns

true if all targets are undefined, otherwise false.

is.all.present(targets)

Returns

true if all targets are neither null nor undefined, otherwise false.

is.all.missing(targets)

Returns

true if all targets are null or undefined, otherwise false.

is.all.true(targets)

Returns

true if all targets are truthy, otherwise false.

is.all.false(targets)

Returns

true if all targets are falsey, otherwise false.

is.any

is.any.defined(targets)

Returns

true if at least one of targets are defined, otherwise false.

is.any.undefined(targets)

Returns

true if at least one of targets are undefined, otherwise false.

is.any.present(targets)

Returns

true if at least one of targets are neither null nor undefined, otherwise false.

is.any.missing(targets)

Returns

true if at least one of targets are null or undefined, otherwise false.

is.any.true(targets)

Returns

true if at least one of targets are truthy, otherwise false.

is.any.false(targets)

Returns

true if at least one of targets are falsey, otherwise false.

Roadmap

  • is module for common comparisons and checks i/e undefined, null, object, etc
  • do module for common functions i/e merge, get, etc
  • Get feedback and iterate

FAQs

Package last updated on 07 Jul 2017

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