Socket
Book a DemoInstallSign in
Socket

samesame

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

samesame

Simple, Lightweight type checking of multiple arguments

Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
8
166.67%
Maintainers
1
Weekly downloads
 
Created
Source

🖐 samesame 👀

Simple, Lightweight type checking of multiple arguments

Package version Downloads Standard Travis Build Standard Readme GitHub version Dependency CI License PRs Donate


Built with ❤︎ by Tiaan and contributors

Table of Contents

Table of Contents
  • About
  • Install
  • Usage
  • API
  • Contribute
  • License
  • About

    This module uses the Object.prototype.toString() method to provide better type checking and supports comparing the types of multiple values. It's just 580 Bytes in size all bundled up as a UMD module, minified & gzipped(PR to reduce this further would be awesome 🎉).

    same same

    Install

    cdn:

    <script src="https://unpkg.com/samesame/lib/samesame.min.js"></script>
    <!-- Or -->
    <script src="https://rawgit.com/tiaanduplessis/samesame/master/lib/samesame.min.js"></script>
    

    npm or yarn:

    $ npm install --save samesame
    # OR
    $ yarn add samesame
    

    Usage

    The module exports a single function that can take multiple arguments and returns boolean value.

    const samesame = require('samesame')
    
    samesame('They hate us', 'cause they ain\'t us')
    samesame({}, {}) // true
    samesame({}, 'Object') // true
    samesame({}, undefined) // false
    samesame('foo', 'bar', 'baz') // true
    samesame('Boolean', true, false) // true
    samesame([], 'Array') // true
    samesame(true, 5) // false
    samesame(/foo/, 'RegExp') // true
    samesame('Function', () => {}) // true
    
    

    Supported type strings that can be passed as an argument are:

    • Array
    • Object
    • String
    • Date
    • RegExp
    • Function
    • Boolean
    • Number
    • Null
    • Undefined

    Contribute

    Contributions are welcome. Please open up an issue or create PR if you would like to help out.

    Note: If editing the README, please conform to the standard-readme specification.

    License

    Licensed under the MIT License.

    Keywords

    type

    FAQs

    Package last updated on 16 Apr 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