Gathering detailed insights and metrics for @phun-ky/typeof
Gathering detailed insights and metrics for @phun-ky/typeof
Gathering detailed insights and metrics for @phun-ky/typeof
Gathering detailed insights and metrics for @phun-ky/typeof
A set of JavaScript helper functions to check for types
npm install @phun-ky/typeof
Typescript
Module System
Min. Node Version
Node Version
NPM Version
99.2
Supply Chain
99.5
Quality
93
Maintenance
100
Vulnerability
100
License
TypeScript (83.46%)
JavaScript (16.54%)
Total Downloads
253,684
Last Day
5,305
Last Week
49,933
Last Month
193,919
Last Year
253,684
MIT License
2 Stars
88 Commits
1 Watchers
2 Branches
1 Contributors
Updated on Jun 23, 2025
Minified
Minified + Gzipped
Latest Version
1.2.19
Package Id
@phun-ky/typeof@1.2.19
Unpacked Size
41.10 kB
Size
8.45 kB
File Count
6
NPM Version
10.9.2
Node Version
22.16.0
Published on
Jun 23, 2025
Cumulative downloads
Total Downloads
Last Day
51.4%
5,305
Compared to previous day
Last Week
6.6%
49,933
Compared to previous week
Last Month
236.1%
193,919
Compared to previous month
Last Year
0%
253,684
Compared to previous year
32
A set of JavaScript helper functions to check for types.
1npm i --save @phun-ky/typeof
Either import and run the required functions:
1import { isString } from '@phun-ky/typeof'; 2 3isString('asd'); // true;
1function isBoolean(variable): boolean;
Defined in: main.ts:42
Checks if the given variable is a boolean.
Parameter | Type | Description |
---|---|---|
variable | unknown | The variable to check. |
boolean
True if the variable is a boolean, false otherwise.
1function isBuiltInConstructor(value): boolean;
Defined in: main.ts:232
Checks if a given value is a built-in JavaScript constructor.
This function verifies whether the provided value is a function and matches
one of JavaScript's built-in constructors, such as Object
, Array
, Function
, etc.
Parameter | Type | Description |
---|---|---|
value | unknown | The value to check. |
boolean
true
if the value is a built-in constructor, otherwise false
.
1console.log(isBuiltInConstructor(Object)); // Output: true
2console.log(isBuiltInConstructor(Array)); // Output: true
3console.log(isBuiltInConstructor(class MyClass {})); // Output: false
4console.log(isBuiltInConstructor(() => {})); // Output: false
5console.log(isBuiltInConstructor(123)); // Output: false
1function isClass(value): boolean;
Defined in: main.ts:199
Checks if a given value is a class constructor.
This function determines whether the provided value is a class by verifying if it is a function and checking its prototype descriptor. Class constructors always have a non-writeable prototype, while regular functions do not.
Will always return false on built in constructors like Date
or Array
.
Parameter | Type | Description |
---|---|---|
value | unknown | The value to check. |
boolean
true
if the value is a class constructor, otherwise false
.
1class MyClass {}
2console.log(isClass(MyClass)); // Output: true
3
4function regularFunction() {}
5console.log(isClass(regularFunction)); // Output: false
6
7console.log(isClass(() => {})); // Output: false
8console.log(isClass(null)); // Output: false
1function isInstanceOfUnknownClass(value): boolean;
Defined in: main.ts:283
Checks if a given value is an instance of a non-standard (unknown) class.
This function determines whether the provided value is an object and has a prototype
that is neither Object.prototype
(standard object) nor null
(no prototype).
It helps differentiate between instances of custom classes and plain objects.
Parameter | Type | Description |
---|---|---|
value | unknown | The value to check. |
boolean
true
if the value is an instance of a non-standard class, otherwise false
.
1class MyClass {} 2console.log(isInstanceOfUnknownClass(new MyClass())); // Output: true 3console.log(isInstanceOfUnknownClass({})); // Output: false 4console.log(isInstanceOfUnknownClass(Object.create(null))); // Output: false 5console.log(isInstanceOfUnknownClass([])); // Output: true
1function isNotBoolean(variable): boolean;
Defined in: main.ts:51
Checks if the given variable is not a boolean.
Parameter | Type | Description |
---|---|---|
variable | unknown | The variable to check. |
boolean
True if the variable is not a boolean, false otherwise.
1function isNotNumber(variable): boolean;
Defined in: main.ts:34
Checks if the given variable is not a number.
Parameter | Type | Description |
---|---|---|
variable | unknown | The variable to check. |
boolean
True if the variable is not a number, false otherwise.
1function isNotString(variable): boolean;
Defined in: main.ts:17
Checks if the given variable is not a string.
Parameter | Type | Description |
---|---|---|
variable | unknown | The variable to check. |
boolean
True if the variable is not a string, false otherwise.
1function isNotUndefined(variable): boolean;
Defined in: main.ts:69
Checks if the given variable is not undefined.
Parameter | Type | Description |
---|---|---|
variable | unknown | The variable to check. |
boolean
True if the variable is not undefined, false otherwise.
1function isNumber(variable): boolean;
Defined in: main.ts:25
Checks if the given variable is a number.
Parameter | Type | Description |
---|---|---|
variable | unknown | The variable to check. |
boolean
True if the variable is a number, false otherwise.
1function isObjectLoose(value): boolean;
Defined in: main.ts:169
Checks if a given value is an object or a function.
This function verifies whether the provided value is of type 'object'
or 'function'
while ensuring that null
is excluded.
Parameter | Type | Description |
---|---|---|
value | unknown | The value to check. |
boolean
true
if the value is an object or function, otherwise false
.
1console.log(isObjectLoose({})); // Output: true
2console.log(isObjectLoose([])); // Output: true
3console.log(isObjectLoose(() => {})); // Output: true
4console.log(isObjectLoose(null)); // Output: false
5console.log(isObjectLoose(42)); // Output: false
isObjectLoose({})
→ true
isObjectLoose([])
→ true
isObjectLoose(() => {})
→ true
isObjectLoose(null)
→ false
isObjectStrict
when you need a strict check for plain objects.isObjectLoose
if you need to check if a value is an object-like structure, including functions.Feature | Strict Check (isObjectStrict ) | Loose Check (isObjectLoose ) |
---|---|---|
Recognizes plain objects | ✅ Yes | ✅ Yes |
Recognizes functions | ❌ No | ✅ Yes |
Recognizes arrays | ❌ No | ✅ Yes |
Recognizes Object.create(null) objects | ✅ Yes | ✅ Yes |
Recognizes class instances | ❌ No | ✅ Yes |
Recognizes DOM elements | ❌ No | ✅ Yes |
Complexity | 🔴 High | 🟢 Low |
1function isObjectStrict(value): boolean;
Defined in: main.ts:105
Checks if a given value is a plain object.
A plain object is an object created by the {}
syntax, Object.create(null)
,
or using new Object()
. This function ensures that the value is an object
and does not have an unusual prototype chain.
Parameter | Type | Description |
---|---|---|
value | unknown | The value to check. |
boolean
true
if the value is a plain object, otherwise false
.
1console.log(isObjectStrict({})); // Output: true
2console.log(isObjectStrict(Object.create(null))); // Output: true
3console.log(isObjectStrict([])); // Output: false
4console.log(isObjectStrict(new Date())); // Output: false
5console.log(isObjectStrict(null)); // Output: false
{}
, new Object()
, Object.create(null)
, etc.).isObjectStrict({})
→ true
isObjectStrict([])
→ false
isObjectStrict(() => {})
→ false
isObjectStrict(Object.create(null))
→ true
isObjectStrict
when you need a strict check for plain objects.isObjectLoose
if you need to check if a value is an object-like structure, including functions.1function isString(variable): boolean;
Defined in: main.ts:8
Checks if the given variable is a string.
Parameter | Type | Description |
---|---|---|
variable | unknown | The variable to check. |
boolean
True if the variable is a string, false otherwise.
1function isUndefined(variable): boolean;
Defined in: main.ts:60
Checks if the given variable is undefined.
Parameter | Type | Description |
---|---|---|
variable | unknown | The variable to check. |
boolean
True if the variable is undefined, false otherwise.
1// Build 2$ npm run build 3// Run dev 4$ npm run dev 5// Test 6$ npm test
Want to contribute? Please read the CONTRIBUTING.md and CODE_OF_CONDUCT.md
This project is licensed under the MIT License - see the LICENSE file for details.
See the CHANGELOG.md for details on the latest updates.
I'm an Open Source evangelist, creating stuff that does not exist yet to help get rid of secondary activities and to enhance systems already in place, be it documentation or web sites.
The sponsorship is an unique opportunity to alleviate more hours for me to maintain my projects, create new ones and contribute to the large community we're all part of :)
Support me on GitHub Sponsors.
p.s. Ukraine is still under brutal Russian invasion. A lot of Ukrainian people are hurt, without shelter and need help. You can help in various ways, for instance, directly helping refugees, spreading awareness, putting pressure on your local government or companies. You can also support Ukraine by donating e.g. to Red Cross, Ukraine humanitarian organisation or donate Ambulances for Ukraine.
No vulnerabilities found.
No security vulnerabilities found.