https://github.com/tiaanduplessis/samesame
🖐 Simple, Lightweight type checking of multiple arguments 👀
https://github.com/tiaanduplessis/samesame
compare same-same type-check typeof
Last synced: 10 months ago
JSON representation
🖐 Simple, Lightweight type checking of multiple arguments 👀
- Host: GitHub
- URL: https://github.com/tiaanduplessis/samesame
- Owner: tiaanduplessis
- License: mit
- Created: 2017-04-16T20:51:04.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2019-06-02T22:41:45.000Z (about 7 years ago)
- Last Synced: 2025-06-30T17:53:58.933Z (12 months ago)
- Topics: compare, same-same, type-check, typeof
- Language: JavaScript
- Size: 212 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# samesame
[](https://npmjs.org/package/samesame)
[](https://npmjs.org/package/samesame)
[](https://github.com/RichardLitt/standard-readme)
[](https://npmjs.org/package/samesame)
[](http://makeapullrequest.com) [](https://greenkeeper.io/)
[](https://github.com/feross/standard)
[](https://travis-ci.org/tiaanduplessis/samesame)
> Simple, Lightweight type checking of multiple arguments
## Table of Contents
- [About](#about)
- [Install](#install)
- [Usage](#usage)
- [Contribute](#contribute)
- [License](#License)
## About
This module uses the `Object.prototype.toString()` method to provide better type checking and supports comparing the types of multiple values.
## Install
cdn:
```html
```
npm or yarn:
```sh
$ npm install --save samesame
# OR
$ yarn add samesame
```
## Usage
```js
const samesame = require('samesame')
samesame('They hate us', 'cause they ain\'t us') // true
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
```
The module exports a single `function` that can take multiple arguments and returns `boolean` value.
Supported type strings that can be passed as an argument are:
- `Array`
- `Object`
- `String`
- `Date`
- `RegExp`
- `Function`
- `Boolean`
- `Number`
- `Null`
- `Undefined`
## Contribute
1. Fork it and create your feature branch: git checkout -b my-new-feature
2. Commit your changes: git commit -am 'Add some feature'
3. Push to the branch: git push origin my-new-feature
4. Submit a pull request
## License
MIT