![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Check types
$ npm install iftype --save
"use strict";
const iftype = require('iftype');
function CustomType(){
}
//----------------------------
// Check if type is 'string'
//----------------------------
iftype(123).is('string'); // => false
iftype(function foo(){}).is('string'); // => false
iftype(new CustomType()).is('string'); // => false
iftype(["foo", "bar"]).is('string'); // => false
iftype("bar").is('string'); // => true
iftype(null).is('string'); // => false
iftype(undefined).is('string'); // => false
//----------------------------
// Check if type is 'number'
//----------------------------
iftype(123).is('number'); // => true
iftype(function foo(){}).is('number'); // => false
iftype(new CustomType()).is('number'); // => false
iftype(["foo", "bar"]).is('number'); // => false
iftype("bar").is('number'); // => false
iftype(null).is('number'); // => false
iftype(undefined).is('number'); // => false
//----------------------------
// Check if type is 'object'
//----------------------------
iftype(123).is('object'); // => false
iftype(function foo(){}).is('object'); // => false
iftype(new CustomType()).is('object'); // => true
iftype(["foo", "bar"]).is('object'); // => true
iftype("bar").is('object'); // => false
iftype(null).is('object'); // => false
iftype(undefined).is('object'); // => false
//----------------------------
// Check if type is 'array'
//----------------------------
iftype(123).is('array'); // => false
iftype(function foo(){}).is('array'); // => false
iftype(new CustomType()).is('array'); // => false
iftype(["foo", "bar"]).is('array'); // => true
iftype("bar").is('array'); // => false
iftype(null).is('array'); // => false
iftype(undefined).is('array'); // => false
//----------------------------
// Check if type is 'function'
//----------------------------
iftype(123).is('function'); // => false
iftype(function foo(){}).is('function'); // => true
iftype(new CustomType()).is('function'); // => false
iftype(["foo", "bar"]).is('function'); // => false
iftype("bar").is('function'); // => false
iftype(null).is('function'); // => false
iftype(undefined).is('function'); // => false
//----------------------------
// Check if type is CustomType
//----------------------------
iftype(123).is(CustomType); // => false
iftype(function foo(){}).is(CustomType); // => false
iftype(new CustomType()).is(CustomType); // => true
iftype(["foo", "bar"]).is(CustomType); // => false
iftype("bar").is(CustomType); // => false
iftype(null).is(CustomType); // => false
iftype(undefined).is(CustomType); // => false
Signature | Description |
---|---|
iftype(val).is(type) | Check if type match. |
iftype(val).isString() | Check if string. |
iftype(val).isNumber() | Check if number. |
iftype(val).isObject() | Check if object. |
iftype(val).isArray() | Check if array. |
iftype.is(type, val) | Check if type match. |
iftype.isString(val) | Check if string. |
iftype.isNumber(val) | Check if number. |
iftype.isObject(val) | Check if object. |
iftype.isArray(val) | Check if array. |
This software is released under the MIT License.
FAQs
Check types
The npm package iftype receives a total of 4,344 weekly downloads. As such, iftype popularity was classified as popular.
We found that iftype demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.