Skip to content

Commit

Permalink
Update v1.0.4
Browse files Browse the repository at this point in the history
- Small performance improved
- Small changes & bugfixes
- Create FUNDING.yml for sponsors
  • Loading branch information
KivixEletric committed Jan 18, 2023
1 parent 76a2ff8 commit 3c6818c
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 36 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: [KivixEletric]
2 changes: 1 addition & 1 deletion .github/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<h1 align="center">That is</h1>

<div align="center">
<a href='./LICENSE' title='MIT License'><img src='https://img.shields.io/badge/license-MIT-purple.svg?style=for-the-badge'></a>
<a href='../LICENSE' title='MIT License'><img src='https://img.shields.io/badge/license-MIT-purple.svg?style=for-the-badge'></a>
<img src='https://img.shields.io/badge/Maintained-yes-green.svg?style=for-the-badge'>
</div>

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ npm install @kivixeletric/that-is

To use the library in your project is very simple, see the example below:

```js
```js
var is = require('@kivixeletric/that-is')

// Number Type
Expand Down
8 changes: 4 additions & 4 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
declare type TypesList =
declare type types =
'defined' | 'def' | 'decimal' |
'bigint' | 'infinite' | 'element' |
'elem' | 'Object' | 'Obj' |
Expand All @@ -10,11 +10,11 @@ declare type TypesList =

declare module '@kivixeletric/that-is' {
interface Types {
type(type: TypesList, ...value: unknown[]): boolean
a(type: TypesList, ...value: unknown[]): boolean
type(type: types, ...value: unknown[]): boolean
a(type: types, ...value: unknown[]): boolean

equal(value: unknown, other: unknown): boolean
divisible(value: number, number: number): boolean
equal(value: unknown, other: unknown): boolean

defined(...value: unknown[]): boolean
def(...value: unknown[]): boolean
Expand Down
48 changes: 24 additions & 24 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
(function (factory) {
var web = typeof window != 'undefined'
var node = typeof module != 'undefined' && module.exports
var web = typeof window != 'undefined'
var data = factory()

if (web) window.is = data
if (node) module.exports = data
if (web) window.is = data
})

(function(){
var is = {}

function BulkCheck(fn) {
function every(fn) {
return function (...values) {
if (values.length == 0) return false;
return values.every(v => fn(v))
Expand All @@ -31,61 +31,61 @@
return value === other
}

is.defined = is.def = BulkCheck(value => {
is.defined = is.def = every(value => {
return is.Obj(value) && !!Object.entries(value)[0] || typeof value !== 'undefined'
})

is.number = is.num = is.int = BulkCheck(value => {
is.number = is.num = is.int = every(value => {
return typeof value == 'number'
})

is.function = is.fn = BulkCheck(value => {
is.function = is.fn = every(value => {
return typeof value == 'function'
})

is.string = is.str = BulkCheck(value => {
is.string = is.str = every(value => {
return typeof value == 'string'
})

is.boolean = is.bool = BulkCheck(value => {
is.boolean = is.bool = every(value => {
return typeof value == 'boolean'
})

is.bigint = BulkCheck(value => {
is.bigint = every(value => {
return typeof value == 'bigint'
})

is.symbol = BulkCheck(value => {
is.symbol = every(value => {
return typeof value == 'symbol'
})

is.Object = is.Obj = BulkCheck(value => {
is.Object = is.Obj = every(value => {
return typeof value == 'object'
})

is.object = is.obj = BulkCheck(value => {
return is.Obj(value) && value.toString().includes('Object')
is.object = is.obj = every(value => {
return value.toString().includes('Object')
})

is.array = is.arr = every(Array.isArray || (value => {
return value.toString().includes('Array')
}))

is.regexp = every(value => {
return value.toString().includes('RegExp')
})

is.element = is.elem = BulkCheck(value => {
is.element = is.elem = every(value => {
return !!value?.nodeType
})

is.decimal = BulkCheck(value => {
is.decimal = every(value => {
return is.num(value) && (value % 1) != 0
})

is.array = is.arr = BulkCheck(Array.isArray || (value => {
return value.toString().includes('Array')
}))

is.infinite = BulkCheck(value => {
is.infinite = every(value => {
return value === Infinity || value === -Infinity
})

is.regexp = BulkCheck(value => {
return value.toString().includes('RegExp')
})

return is
})
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
{
"name": "@kivixeletric/that-is",
"version": "1.0.3",
"version": "1.0.4",
"main": "./index.js",
"description": "A library for checking multiple or single value types",
"description": "A JavaScript library that checks whether the value is of a specific type",
"author": "KivixEletric",
"license": "MIT",
"keywords": [
"util",
"type",
"test",
"check"
"typescript-support",
"javascript",
"type-checker",
"type-checks",
"type-check"
],
"homepage": "https://github.com/KivixEletric/That-is#readme",
"repository": {
Expand Down

0 comments on commit 3c6818c

Please sign in to comment.