
Product
Introducing PHP and Composer Support in Socket
Socket now supports PHP with full Composer and Packagist integration, enabling developers to search packages, generate SBOMs, and protect their PHP dependencies from supply chain threats.
legible type checking "micro library"
$ npm install is-a
var is = require('is-a');
var StringOrRegExp = [is.STRING, is.REGEXP];
var thing1 = /mischief/;
console.log(is(thing1).a.String); //false
console.log(is(thing1).not.a.Number); //true
console.log(is(thing1).an.Array); //false
console.log(is(thing1).a.RegExp); //true
console.log(is(thing1).a(StringOrRegExp)); //true
console.log(is(thing1).a.Primitive); //false
console.log(is(thing1).a.CoreObject); //true
console.log(is(thing1).not.a.JsonBasicType); //true
console.log(is(thing1).a.BuiltinType); //true
var thing2 = "mayhem";
console.log(is(thing2).a.String); //true
console.log(is(thing2).not.a.Number); //true
console.log(is(thing2).an.Array); //false
console.log(is(thing2).a.RegExp); //false
console.log(is(thing2).a(StringOrRegExp)); //true
console.log(is(thing2).a.Primitive); //true
console.log(is(thing2).a.CoreObject); //true
console.log(is(thing2).not.a.JsonBasicType); //false
console.log(is(thing2).a.BuiltinType); //true
var myType = is.ARRAY;
console.log(myType.is.a.String); //false
console.log(myType.is.not.a.Number); //true
console.log(myType.is.an.Array); //true
console.log(myType.is.a.RegExp); //false
console.log(myType.is.a(StringOrRegExp)); //false
console.log(myType.is.a.Primitive); //false
console.log(myType.is.a.CoreObject); //true
console.log(myType.is.not.a.JsonBasicType); //false
console.log(myType.is.a.BuiltinType); //true
this is the complete list of tests. .a, .an, and .is are optional, is(x).not... is the same as !is(x)...
is(x).Argumentsis(x).an.Arrayis(x).a.Booleanis(x).a.Dateis(x).a.Functionis(x).a.Mathis(x).Nullis(x).a.Numberis(x).an.Objectis(x).a.RegExpis(x).a.Stringis(x).Undefinedis(x).not.Argumentsis(x).not.an.Arrayis(x).not.a.Booleanis(x).not.a.Dateis(x).not.a.Functionis(x).not.a.Mathis(x).not.Nullis(x).not.a.Numberis(x).not.an.Objectis(x).not.a.RegExpis(x).not.a.Stringis(x).not.Undefinedgeneral types are
BuiltinType: one of (Arguments, Array, Boolean, Date, Function, Math, Null, Number, Object, RegExp, String, Undefined)JsonBasicType: one of (Array, Boolean, Null, Number, Object, String, Undefined)CoreObject: one of (Array, Boolean, Date, Function, Math, Number, RegExp, String)Primitive: one of (Boolean, Null, Number, String, Undefined)general types can be tested for just like simple types
is(x).a.BuiltinTypeis(x).a.JsonBasicTypeis(x).a.CoreObjectis(x).a.Primitiveis(x).a([is.STRING, is.ARRAY]).not still works
is(x).not.a.BuiltinTypeis(x).not.a.JsonBasicTypeis(x).not.a.CoreObjectis(x).not.a.Primitiveis(x).not.a([is.STRING, is.ARRAY])builtin types can be tested too
is.ARRAY.a.JsonBasicTypeis.REGEXP.a([is.STRING, is.ARRAY])var is = require('is-a');
var thing1 = /mischief/;
console.log(is(thing1).toString()); // "RegExp"
console.log(is(thing1).toType()); // "[object RegExp]"
FAQs
type checking "micro library"
The npm package is-a receives a total of 2 weekly downloads. As such, is-a popularity was classified as not popular.
We found that is-a 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.

Product
Socket now supports PHP with full Composer and Packagist integration, enabling developers to search packages, generate SBOMs, and protect their PHP dependencies from supply chain threats.

Security News
An AI agent is merging PRs into major OSS projects and cold-emailing maintainers to drum up more work.

Research
/Security News
Chrome extension CL Suite by @CLMasters neutralizes 2FA for Facebook and Meta Business accounts while exfiltrating Business Manager contact and analytics data.