Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Easy and reliable type detection
Supported by joinbox.com, your swiss node.js & javascript agency :rocket:
For a version supporting older browsers and node version please use ee-types version < 3.0.0.
Compatible with node 10+ (--experimental-modules
flag) and browsers supporting es modules.
node
import types from 'ee-types';
Be aware that the different object types like Maps, Promises and so on are not
detected as objects but as their respective type. If you need to detect them as
objects please use the types.someObject()
method instead of the types.object()
method.
Explicitly test for a type.
types.array([]) // true
Get the type of some variable
types(/[a-z]+/gi) // regexp
Since many of the types defined by javascript are just special objects that also can be treated as normal objects ee-types has a bunch of methods that allow you to handle that correctly.
For example, Map
is an object, or a custom class where you
define a getter that returns a specific name for your object:
const X = class {
get [Symbol.toStringTag]() {
return 'AQL query';;
}
};
console.log(Object.prototype.toString.call(new X()));
// prints: [object AQL Query]
types.object({}); // true
types.object(new Map()); // false
// be aware that if you are not explicitly testing
// for an object any object will be treated as one
types({}) // 'object'
types(new Map()) // 'object'
types.someObject({}); // true
types.someObject(new Map()); // false
types(new Map()) // 'object'
var types = require('ee-types');
types.string('nope'); // true
types.strign(new String('yeah')); // true
types(2) // number
types([]]) // array
types(new Array()]) // array
types(new Int8Array()]) // int8Array
types.promise(Promise.all()) // true
FAQs
Reliable & easy Js & ES Type detection
The npm package ee-types receives a total of 3,223 weekly downloads. As such, ee-types popularity was classified as popular.
We found that ee-types demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.