knex/lib/util/is.js
Bogdan Chadkin 6f817a3b6e
Avoid lodash typecheks (#4056)
* Avoid lodash typecheks

Lodash is quite big project. Even with direct imports it loads [tons](https://github.com/knex/knex/pull/3804) of
code and still bloats node_modules. Especially since lodash mostly used
as a polyfill for modern features.

In this diff I attempted to reduce lodash usage by replacing type checks
with `typeof` operator which might be sufficient.

Also replaced lodash/isObject with custom simplified utility which does not
consider functions as objects and allows to simplify code in one place.
2020-10-05 21:29:39 +03:00

24 lines
551 B
JavaScript

exports.isString = function isString(value) {
return typeof value === 'string';
};
exports.isNumber = function isNumber(value) {
return typeof value === 'number';
};
exports.isBoolean = function isBoolean(value) {
return typeof value === 'boolean';
};
exports.isUndefined = function isUndefined(value) {
return typeof value === 'undefined';
};
exports.isObject = function isObject(value) {
return typeof value === 'object' && value !== null;
};
exports.isFunction = function isFunction(value) {
return typeof value === 'function';
};