@rarimo/shared
Version:
Utility functions, types and constants shared across Rarimo packages.
39 lines (38 loc) • 1.21 kB
JavaScript
export const hasOwn = (val, key)=>{
return Object.prototype.hasOwnProperty.call(val, key);
};
export const isArray = (val)=>{
return Array.isArray(val);
};
export const isOneElementArray = (val)=>{
return isArray(val) && val.length === 1;
};
// eslint-disable-next-line @typescript-eslint/ban-types
export const isFunction = (val)=>{
return typeof val === 'function';
};
export const isString = (val)=>{
return typeof val === 'string';
};
export const isObject = (val)=>{
return val !== null && typeof val === 'object';
};
export const isPlainObject = (val)=>{
return Object.prototype.toString.call(val) === '[object Object]';
};
export const isUndefined = (val)=>{
return typeof val === 'undefined';
};
export const toLowerCase = (val)=>{
var _val_toLowerCase;
return (_val_toLowerCase = val === null || val === void 0 ? void 0 : val.toLowerCase()) !== null && _val_toLowerCase !== void 0 ? _val_toLowerCase : '';
};
export const omit = (obj, keys)=>{
return Object.entries(obj).reduce((result, [key, value])=>{
if (!keys.includes(key)) {
result[key] = value;
}
return result;
}, {});
};
//# sourceMappingURL=general.js.map