Giter VIP home page Giter VIP logo

is-js's Introduction

is.js

Installing

Cloning: git clone https://github.com/scottrabin/is-js.git is-js

NPM: npm install is-js

Usage

Basic type checking
is.string(s) Determines if the argument is a string
is.number(n) Determines if the argument is a number
is.bool(b) Determines if the argument is a boolean (true or false)
is.fn(f) Determines if the argument is a function
is.array(a) Determines if the argument is an array
is.object(o) Determines if the argument is an object. Since nearly all Javascript types inherit from Object, this will most likely return true for anything but numbers, strings, booleans, and null/undefined. This function can be used to determine if arbitrary properties can be set on the given object.
is.regex(r) Determines if the argument is a regular expression object
is.element(e) Determines if the argument is an HTMLElement. Does not return true for window or document.
Specialized type checking
is.numeric(n) Determines if the argument is a number-like value; numbers (i.e. values that return true from is.number(n)) will return true, as well as any string representation of a number. See the test page for is.numeric to see what strings are accepted as numeric.
is.hash(h) Determines if the argument is a hash, or key/value pair object that is not an Array, function, or user-defined object.
Collection properties
is.inside(collection, value) Determines if the specified value is contained within the given collection. If collection is an array, is.inside will check to see if value is an element in the array. If collection is an object, is.inside will check if any property directly on the object is equal to the specified value.
is.set(variable) Determines if the specified variable is undefined or null.
is.empty(collection) Determines if the specified collection is empty, or is otherwise falsy. If collection is an array, is.empty checks that the array has no elements. If collection is an object, is.empty checks that the object has no properties declared directly on the object. If collection is neither an array or object, is.empty checks if the given value is falsy; this includes null, false, and empty strings.

Testing

See the unit tests page at scottrabin.com/is-js/test.html.

License

is.js is released under the MIT License. See MIT-LICENSE.txt for more details.

is-js's People

Contributors

scottrabin avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.