Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
[![Build Status](https://travis-ci.org/functional-jslib/fjl-is.png)](https://travis-ci.org/functional-jslib/fjl-is) [![GitHub version](https://badge.fury.io/gh/functional-jslib%2Ffjl-is.svg)](http://badge.fury.io/gh/functional-jslib%2Ffjl-is) [![NPM ver
Is
type checkers (isType
, isBoolean
etc.). All type checkers return a boolean indicating if passed in value
matches given type or not.
npm install fjl-is
oryarn add fjl-is
// Es6/2015
import {isNumber, isType} from 'fjl-is';
// CommonJs
const {isNumber, isType} = require('fjl-is');
import {isType, isNumber} from 'fjl-is';
// Filter an array by your type
[...].filter(isType(MyType)) // Filtering using `isType`'s curriable nature
// Checking with constructor name and/or actual constructor
isType('Array', []) === true; // Uses `(value).constructor.name` behind the scenes via `fjl-typeof` module.
isType(Array, []) === true; // ""
// Check for true `Number` (not `NaN` being reported as `Number`).
isNumber(0 / 0) === `false` // `0 / 0` is `NaN`
// Check for `string`
isString('') === `true`
// etc..
Note: All checkers are strict; E.g., they do not check for instance-of/inheritance except for isFunction
(this
one uses instanceof
(more useful)) and isArray
(which is actually just Array.isArray
).
isType (Type, value) (curried)
Type
- A type's name or the Type constructor itself.value
- Value to check.Boolean
_isType (Type, value) (un-curried)
Same is isType
but un-curried.
isArray (value)
Returns a boolean indicating whether value matches type or not.
isBoolean (value)
""
isFunction (value)
""
isNumber (value)
""
isObject (value)
""
isString (value)
""
isset (value)
Returns a boolean indicating whether value is not null
and not undefined
or not; E.g. useful for places where
you need explicit not null
and not undefined
values (like when allowing 0
or empty string but not allowing null
or undefined
from a function/statement).
Needed some stronger type-checking for javascript that didn't do any of the older hacks (Object.prototype.toString.call)
and worked for all values and types (including null
, undefined
, and NaN
); Example:
// Old hack etc.
const isType = (Type, x) => {
if (x === null || Type === 'Null') {
return 'Null';
}
else if (x === undefined || Type === 'Undefined') {
return 'Undefined';
}
const typeName = (Type instanceof Function) ? Type.name : Type,
typeDump = Object.prototype.toString.call(x), // === "[object Number]" // part of
foundTypeName = typeDump.substring(8, typeDump.length - 1);
return (foundTypeName === 'Number' && isNaN(Number)) ?
'NaN' === typeName : foundTypeName === typeName;
};
// Note: Old hack from above is still pretty good though it is even easier to get a constructor's `name` property
(x).constructor.name // which runs behind the scenes in the code below (after it's behind the scenes null checks and all..)
// New way (`typeOf` comes from `fjl-typeof` which does the type name getting part from above in a more modern way
const isType = (type, obj) => typeOf(obj) === (isFunction(type) ? type.name : type);
BSD 3 Clause
FAQs
[![Build Status](https://travis-ci.org/functional-jslib/fjl-is.png)](https://travis-ci.org/functional-jslib/fjl-is) [![GitHub version](https://badge.fury.io/gh/functional-jslib%2Ffjl-is.svg)](http://badge.fury.io/gh/functional-jslib%2Ffjl-is) [![NPM ver
We found that fjl-is 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.