@tonic-ui/utils
Advanced tools
Comparing version 1.4.0 to 1.5.0
@@ -5,29 +5,2 @@ 'use strict'; | ||
var isBlankString = function isBlankString(str) { | ||
if (typeof str !== 'string') { | ||
return false; | ||
} | ||
if (str.length === 0) { | ||
return true; | ||
} | ||
return isWhitespace(str); | ||
}; | ||
var isEmptyArray = function isEmptyArray(value) { | ||
return Array.isArray(value) && value.length === 0; | ||
}; | ||
var isEmptyObject = function isEmptyObject(value) { | ||
return !isNullOrUndefined(value) && Object.keys(value).length === 0 && value.constructor === Object; | ||
}; | ||
var isNullish = function isNullish(value) { | ||
return value === null || value === undefined; | ||
}; | ||
var isNullOrUndefined = isNullish; // alias of "isNullish" | ||
var isWhitespace = function isWhitespace(value) { | ||
// @see https://github.com/jonschlinkert/whitespace-regex | ||
// eslint-disable-next-line no-control-regex | ||
var whitespaceRegex = /^[\s\f\n\r\t\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u2028\u2029\u202f\u205f\u3000\ufeff\x09\x0a\x0b\x0c\x0d\x20\xa0]+$/; | ||
return typeof value === 'string' && whitespaceRegex.test(value); | ||
}; | ||
function ownKeys(object, enumerableOnly) { | ||
@@ -92,2 +65,35 @@ var keys = Object.keys(object); | ||
var isBlankString = function isBlankString(str) { | ||
if (typeof str !== 'string') { | ||
return false; | ||
} | ||
if (str.length === 0) { | ||
return true; | ||
} | ||
return isWhitespace(str); | ||
}; | ||
var isEmptyArray = function isEmptyArray(value) { | ||
return Array.isArray(value) && value.length === 0; | ||
}; | ||
var isEmptyObject = function isEmptyObject(value) { | ||
return !isNullOrUndefined(value) && Object.keys(value).length === 0 && value.constructor === Object; | ||
}; | ||
var isFunction = function isFunction(value) { | ||
return typeof value === 'function'; | ||
}; | ||
var isNullish = function isNullish(value) { | ||
return value === null || value === undefined; | ||
}; | ||
var isNullOrUndefined = isNullish; // alias of "isNullish" | ||
var isObject = function isObject(value) { | ||
return !isNullish(value) && (_typeof(value) === 'object' || typeof value === 'function') && !Array.isArray(value); | ||
}; | ||
var isWhitespace = function isWhitespace(value) { | ||
// @see https://github.com/jonschlinkert/whitespace-regex | ||
// eslint-disable-next-line no-control-regex | ||
var whitespaceRegex = /^[\s\f\n\r\t\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u2028\u2029\u202f\u205f\u3000\ufeff\x09\x0a\x0b\x0c\x0d\x20\xa0]+$/; | ||
return typeof value === 'string' && whitespaceRegex.test(value); | ||
}; | ||
var canUseDOM = function canUseDOM() { | ||
@@ -262,5 +268,2 @@ return !!(typeof window !== 'undefined' && window.document && window.document.createElement); | ||
}; | ||
var isFunction = function isFunction(value) { | ||
return typeof value === 'function'; | ||
}; | ||
var noop = function noop() {}; | ||
@@ -282,3 +285,3 @@ var once = function once(fn) { | ||
} | ||
return isFunction(valueOrFn) ? valueOrFn.apply(void 0, args) : valueOrFn; | ||
return typeof valueOrFn === 'function' ? valueOrFn.apply(void 0, args) : valueOrFn; | ||
}; | ||
@@ -422,2 +425,3 @@ var warnDeprecatedProps = function warnDeprecatedProps(props, options) { | ||
exports.isNullish = isNullish; | ||
exports.isObject = isObject; | ||
exports.isWhitespace = isWhitespace; | ||
@@ -424,0 +428,0 @@ exports.noop = noop; |
import { ensureBoolean, ensureArray, ensureString, ensureFiniteNumber } from 'ensure-type'; | ||
var isBlankString = function isBlankString(str) { | ||
if (typeof str !== 'string') { | ||
return false; | ||
} | ||
if (str.length === 0) { | ||
return true; | ||
} | ||
return isWhitespace(str); | ||
}; | ||
var isEmptyArray = function isEmptyArray(value) { | ||
return Array.isArray(value) && value.length === 0; | ||
}; | ||
var isEmptyObject = function isEmptyObject(value) { | ||
return !isNullOrUndefined(value) && Object.keys(value).length === 0 && value.constructor === Object; | ||
}; | ||
var isNullish = function isNullish(value) { | ||
return value === null || value === undefined; | ||
}; | ||
var isNullOrUndefined = isNullish; // alias of "isNullish" | ||
var isWhitespace = function isWhitespace(value) { | ||
// @see https://github.com/jonschlinkert/whitespace-regex | ||
// eslint-disable-next-line no-control-regex | ||
var whitespaceRegex = /^[\s\f\n\r\t\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u2028\u2029\u202f\u205f\u3000\ufeff\x09\x0a\x0b\x0c\x0d\x20\xa0]+$/; | ||
return typeof value === 'string' && whitespaceRegex.test(value); | ||
}; | ||
function ownKeys(object, enumerableOnly) { | ||
@@ -89,2 +62,35 @@ var keys = Object.keys(object); | ||
var isBlankString = function isBlankString(str) { | ||
if (typeof str !== 'string') { | ||
return false; | ||
} | ||
if (str.length === 0) { | ||
return true; | ||
} | ||
return isWhitespace(str); | ||
}; | ||
var isEmptyArray = function isEmptyArray(value) { | ||
return Array.isArray(value) && value.length === 0; | ||
}; | ||
var isEmptyObject = function isEmptyObject(value) { | ||
return !isNullOrUndefined(value) && Object.keys(value).length === 0 && value.constructor === Object; | ||
}; | ||
var isFunction = function isFunction(value) { | ||
return typeof value === 'function'; | ||
}; | ||
var isNullish = function isNullish(value) { | ||
return value === null || value === undefined; | ||
}; | ||
var isNullOrUndefined = isNullish; // alias of "isNullish" | ||
var isObject = function isObject(value) { | ||
return !isNullish(value) && (_typeof(value) === 'object' || typeof value === 'function') && !Array.isArray(value); | ||
}; | ||
var isWhitespace = function isWhitespace(value) { | ||
// @see https://github.com/jonschlinkert/whitespace-regex | ||
// eslint-disable-next-line no-control-regex | ||
var whitespaceRegex = /^[\s\f\n\r\t\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u2028\u2029\u202f\u205f\u3000\ufeff\x09\x0a\x0b\x0c\x0d\x20\xa0]+$/; | ||
return typeof value === 'string' && whitespaceRegex.test(value); | ||
}; | ||
var canUseDOM = function canUseDOM() { | ||
@@ -259,5 +265,2 @@ return !!(typeof window !== 'undefined' && window.document && window.document.createElement); | ||
}; | ||
var isFunction = function isFunction(value) { | ||
return typeof value === 'function'; | ||
}; | ||
var noop = function noop() {}; | ||
@@ -279,3 +282,3 @@ var once = function once(fn) { | ||
} | ||
return isFunction(valueOrFn) ? valueOrFn.apply(void 0, args) : valueOrFn; | ||
return typeof valueOrFn === 'function' ? valueOrFn.apply(void 0, args) : valueOrFn; | ||
}; | ||
@@ -393,2 +396,2 @@ var warnDeprecatedProps = function warnDeprecatedProps(props, options) { | ||
export { ariaAttr, callAll, callEventHandlers, canUseDOM, contains, createTransitionStyle, dataAttr, getActiveElement, getAllFocusable, getComputedStyle, getEnterTransitionProps, getEventWindow, getExitTransitionProps, getLeftmostOffset, getOwnerDocument, getOwnerWindow, getRelatedTarget, getTopmostOffset, isBlankString, isElement, isEmptyArray, isEmptyObject, isFunction, isHTMLElement, isNullOrUndefined, isNullish, isWhitespace, noop, normalizeKeyboardEventKey, once, reflow, runIfFn, transitionDuration, transitionEasing, warnDeprecatedProps, warnRemovedProps }; | ||
export { ariaAttr, callAll, callEventHandlers, canUseDOM, contains, createTransitionStyle, dataAttr, getActiveElement, getAllFocusable, getComputedStyle, getEnterTransitionProps, getEventWindow, getExitTransitionProps, getLeftmostOffset, getOwnerDocument, getOwnerWindow, getRelatedTarget, getTopmostOffset, isBlankString, isElement, isEmptyArray, isEmptyObject, isFunction, isHTMLElement, isNullOrUndefined, isNullish, isObject, isWhitespace, noop, normalizeKeyboardEventKey, once, reflow, runIfFn, transitionDuration, transitionEasing, warnDeprecatedProps, warnRemovedProps }; |
{ | ||
"name": "@tonic-ui/utils", | ||
"version": "1.4.0", | ||
"version": "1.5.0", | ||
"description": "Common utilities for various Tonic UI components and packages.", | ||
@@ -84,3 +84,3 @@ "main": "dist/index.cjs.js", | ||
], | ||
"gitHead": "a5c5da228fbfe18a73ef7765026b9c29dd83a350" | ||
"gitHead": "550b3782c1b690804c5e1c84195b1554524e0813" | ||
} |
39663
801