sequelize
Version:
Sequelize is a promise-based Node.js ORM tool for Postgres, MySQL, MariaDB, SQLite, Microsoft SQL Server, Amazon Redshift and Snowflake’s Data Cloud. It features solid transaction support, relations, eager and lazy loading, read replication and more.
25 lines (23 loc) • 561 B
JavaScript
;
/**
* Wraps a constructor to not need the `new` keyword using a proxy.
* Only used for data types.
*
* @param {Function} Class The class instance to wrap as invocable.
* @returns {Proxy} Wrapped class instance.
* @private
*/
function classToInvokable(Class) {
return new Proxy(Class, {
apply(Target, thisArg, args) {
return new Target(...args);
},
construct(Target, args) {
return new Target(...args);
},
get(target, p) {
return target[p];
}
});
}
exports.classToInvokable = classToInvokable;