New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

@tonic-ui/utils

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tonic-ui/utils - npm Package Compare versions

Comparing version

to
2.1.0

'use strict';
function _iterableToArrayLimit(r, l) {
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
if (null != t) {
var e,
n,
i,
u,
a = [],
f = !0,
o = !1;
try {
if (i = (t = t.call(r)).next, 0 === l) {
if (Object(t) !== t) return;
f = !1;
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
} catch (r) {
o = !0, n = r;
} finally {
try {
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
} finally {
if (o) throw n;
}
}
return a;
}
}
function ownKeys(e, r) {

@@ -61,7 +88,51 @@ var t = Object.keys(e);

}
function _slicedToArray(arr, i) {
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
}
function _toConsumableArray(arr) {
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
}
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
}
function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
function _iterableToArray(iter) {
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
}
function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
exports.arrayLikeToArray = _arrayLikeToArray;
exports.arrayWithHoles = _arrayWithHoles;
exports.arrayWithoutHoles = _arrayWithoutHoles;
exports.defineProperty = _defineProperty;
exports.iterableToArray = _iterableToArray;
exports.iterableToArrayLimit = _iterableToArrayLimit;
exports.nonIterableRest = _nonIterableRest;
exports.nonIterableSpread = _nonIterableSpread;
exports.objectSpread2 = _objectSpread2;
exports.slicedToArray = _slicedToArray;
exports.toConsumableArray = _toConsumableArray;
exports.toPrimitive = _toPrimitive;
exports.toPropertyKey = _toPropertyKey;
exports.typeof = _typeof;
exports.unsupportedIterableToArray = _unsupportedIterableToArray;

@@ -31,2 +31,11 @@ 'use strict';

};
// https://github.com/sindresorhus/is-plain-obj/blob/main/index.js
var isPlainObject = function isPlainObject(value) {
if (_rollupPluginBabelHelpers.typeof(value) !== 'object' || value === null) {
return false;
}
var prototype = Object.getPrototypeOf(value);
return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in value) && !(Symbol.iterator in value);
};
var isWhitespace = function isWhitespace(value) {

@@ -46,2 +55,3 @@ // @see https://github.com/jonschlinkert/whitespace-regex

exports.isObject = isObject;
exports.isPlainObject = isPlainObject;
exports.isWhitespace = isWhitespace;

@@ -18,2 +18,3 @@ 'use strict';

exports.isObject = assertion.isObject;
exports.isPlainObject = assertion.isPlainObject;
exports.isWhitespace = assertion.isWhitespace;

@@ -39,2 +40,3 @@ exports.canUseDOM = dom.canUseDOM;

exports.dataAttr = shared.dataAttr;
exports.merge = shared.merge;
exports.noop = shared.noop;

@@ -41,0 +43,0 @@ exports.once = shared.once;

'use strict';
var _rollupPluginBabelHelpers = require('./_virtual/_rollupPluginBabelHelpers.js');
var ensureType = require('ensure-type');
var assertion = require('./assertion.js');

@@ -18,2 +20,32 @@ var _joinWords = function _joinWords(words) {

};
var _deepClone = function _deepClone(source) {
var seen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new WeakMap();
// Use a `WeakMap` to track objects and detect circular references.
// If the object has been cloned before, return the cached cloned version.
if (seen.has(source)) {
return seen.get(source);
}
if (Array.isArray(source)) {
var clonedArray = [];
seen.set(source, clonedArray);
for (var i = 0; i < source.length; ++i) {
clonedArray[i] = _deepClone(source[i], seen);
}
return clonedArray;
}
if (assertion.isPlainObject(source)) {
var clonedObject = {};
seen.set(source, clonedObject);
for (var _i = 0, _Object$entries = Object.entries(source); _i < _Object$entries.length; _i++) {
var _Object$entries$_i = _rollupPluginBabelHelpers.slicedToArray(_Object$entries[_i], 2),
key = _Object$entries$_i[0],
value = _Object$entries$_i[1];
clonedObject[key] = _deepClone(value, seen);
}
return clonedObject;
}
// For primitive values and other types, return as is
return source;
};
var ariaAttr = function ariaAttr(condition) {

@@ -49,2 +81,36 @@ return ensureType.ensureBoolean(condition) ? true : undefined;

};
var merge = function merge(target, source) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
clone: true
};
// Merge arrays
if (Array.isArray(target) && Array.isArray(source)) {
var output = options.clone ? _rollupPluginBabelHelpers.toConsumableArray(target) : target;
source.forEach(function (item, index) {
if (assertion.isPlainObject(item) && assertion.isPlainObject(output[index])) {
output[index] = merge(output[index], item, options);
} else {
output[index] = options.clone ? _deepClone(item) : item;
}
});
return output;
}
// Merge plain objects
if (assertion.isPlainObject(target) && assertion.isPlainObject(source)) {
var _output = options.clone ? _rollupPluginBabelHelpers.objectSpread2({}, target) : target;
for (var _i2 = 0, _Object$entries2 = Object.entries(source); _i2 < _Object$entries2.length; _i2++) {
var _Object$entries2$_i = _rollupPluginBabelHelpers.slicedToArray(_Object$entries2[_i2], 2),
key = _Object$entries2$_i[0],
value = _Object$entries2$_i[1];
if (assertion.isPlainObject(value) && Object.prototype.hasOwnProperty.call(_output, key) && assertion.isPlainObject(_output[key])) {
_output[key] = merge(_output[key], value, options);
} else {
_output[key] = options.clone ? _deepClone(value) : value;
}
}
return _output;
}
return options.clone ? _deepClone(source) : source;
};
var noop = function noop() {};

@@ -118,2 +184,3 @@ var once = function once(fn) {

exports.dataAttr = dataAttr;
exports.merge = merge;
exports.noop = noop;

@@ -120,0 +187,0 @@ exports.once = once;

@@ -0,1 +1,28 @@

function _iterableToArrayLimit(r, l) {
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
if (null != t) {
var e,
n,
i,
u,
a = [],
f = !0,
o = !1;
try {
if (i = (t = t.call(r)).next, 0 === l) {
if (Object(t) !== t) return;
f = !1;
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
} catch (r) {
o = !0, n = r;
} finally {
try {
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
} finally {
if (o) throw n;
}
}
return a;
}
}
function ownKeys(e, r) {

@@ -59,3 +86,37 @@ var t = Object.keys(e);

}
function _slicedToArray(arr, i) {
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
}
function _toConsumableArray(arr) {
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
}
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
}
function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
function _iterableToArray(iter) {
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
}
function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
export { _defineProperty as defineProperty, _objectSpread2 as objectSpread2, _toPrimitive as toPrimitive, _toPropertyKey as toPropertyKey, _typeof as typeof };
export { _arrayLikeToArray as arrayLikeToArray, _arrayWithHoles as arrayWithHoles, _arrayWithoutHoles as arrayWithoutHoles, _defineProperty as defineProperty, _iterableToArray as iterableToArray, _iterableToArrayLimit as iterableToArrayLimit, _nonIterableRest as nonIterableRest, _nonIterableSpread as nonIterableSpread, _objectSpread2 as objectSpread2, _slicedToArray as slicedToArray, _toConsumableArray as toConsumableArray, _toPrimitive as toPrimitive, _toPropertyKey as toPropertyKey, _typeof as typeof, _unsupportedIterableToArray as unsupportedIterableToArray };

@@ -29,2 +29,11 @@ import { typeof as _typeof } from './_virtual/_rollupPluginBabelHelpers.js';

};
// https://github.com/sindresorhus/is-plain-obj/blob/main/index.js
var isPlainObject = function isPlainObject(value) {
if (_typeof(value) !== 'object' || value === null) {
return false;
}
var prototype = Object.getPrototypeOf(value);
return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in value) && !(Symbol.iterator in value);
};
var isWhitespace = function isWhitespace(value) {

@@ -37,2 +46,2 @@ // @see https://github.com/jonschlinkert/whitespace-regex

export { isBlankString, isEmptyArray, isEmptyObject, isFunction, isNullOrUndefined, isNullish, isObject, isWhitespace };
export { isBlankString, isEmptyArray, isEmptyObject, isFunction, isNullOrUndefined, isNullish, isObject, isPlainObject, isWhitespace };

@@ -1,5 +0,5 @@

export { isBlankString, isEmptyArray, isEmptyObject, isFunction, isNullOrUndefined, isNullish, isObject, isWhitespace } from './assertion.js';
export { isBlankString, isEmptyArray, isEmptyObject, isFunction, isNullOrUndefined, isNullish, isObject, isPlainObject, isWhitespace } from './assertion.js';
export { canUseDOM, contains, getActiveElement, getComputedStyle, getEventWindow, getLeftmostOffset, getOwnerDocument, getOwnerWindow, getRelatedTarget, getTopmostOffset, isElement, isHTMLElement, normalizeKeyboardEventKey, reflow } from './dom.js';
export { getAllFocusable } from './dom-query.js';
export { ariaAttr, callAll, callEventHandlers, dataAttr, noop, once, runIfFn, warnDeprecatedProps, warnRemovedProps } from './shared.js';
export { ariaAttr, callAll, callEventHandlers, dataAttr, merge, noop, once, runIfFn, warnDeprecatedProps, warnRemovedProps } from './shared.js';
export { createTransitionStyle, getEnterTransitionProps, getExitTransitionProps, transitionDuration, transitionEasing } from './transition.js';

@@ -0,2 +1,4 @@

import { toConsumableArray as _toConsumableArray, objectSpread2 as _objectSpread2, slicedToArray as _slicedToArray } from './_virtual/_rollupPluginBabelHelpers.js';
import { ensureBoolean, ensureArray, ensureString } from 'ensure-type';
import { isPlainObject } from './assertion.js';

@@ -16,2 +18,32 @@ var _joinWords = function _joinWords(words) {

};
var _deepClone = function _deepClone(source) {
var seen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new WeakMap();
// Use a `WeakMap` to track objects and detect circular references.
// If the object has been cloned before, return the cached cloned version.
if (seen.has(source)) {
return seen.get(source);
}
if (Array.isArray(source)) {
var clonedArray = [];
seen.set(source, clonedArray);
for (var i = 0; i < source.length; ++i) {
clonedArray[i] = _deepClone(source[i], seen);
}
return clonedArray;
}
if (isPlainObject(source)) {
var clonedObject = {};
seen.set(source, clonedObject);
for (var _i = 0, _Object$entries = Object.entries(source); _i < _Object$entries.length; _i++) {
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
key = _Object$entries$_i[0],
value = _Object$entries$_i[1];
clonedObject[key] = _deepClone(value, seen);
}
return clonedObject;
}
// For primitive values and other types, return as is
return source;
};
var ariaAttr = function ariaAttr(condition) {

@@ -47,2 +79,36 @@ return ensureBoolean(condition) ? true : undefined;

};
var merge = function merge(target, source) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
clone: true
};
// Merge arrays
if (Array.isArray(target) && Array.isArray(source)) {
var output = options.clone ? _toConsumableArray(target) : target;
source.forEach(function (item, index) {
if (isPlainObject(item) && isPlainObject(output[index])) {
output[index] = merge(output[index], item, options);
} else {
output[index] = options.clone ? _deepClone(item) : item;
}
});
return output;
}
// Merge plain objects
if (isPlainObject(target) && isPlainObject(source)) {
var _output = options.clone ? _objectSpread2({}, target) : target;
for (var _i2 = 0, _Object$entries2 = Object.entries(source); _i2 < _Object$entries2.length; _i2++) {
var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i2], 2),
key = _Object$entries2$_i[0],
value = _Object$entries2$_i[1];
if (isPlainObject(value) && Object.prototype.hasOwnProperty.call(_output, key) && isPlainObject(_output[key])) {
_output[key] = merge(_output[key], value, options);
} else {
_output[key] = options.clone ? _deepClone(value) : value;
}
}
return _output;
}
return options.clone ? _deepClone(source) : source;
};
var noop = function noop() {};

@@ -112,2 +178,2 @@ var once = function once(fn) {

export { ariaAttr, callAll, callEventHandlers, dataAttr, noop, once, runIfFn, warnDeprecatedProps, warnRemovedProps };
export { ariaAttr, callAll, callEventHandlers, dataAttr, merge, noop, once, runIfFn, warnDeprecatedProps, warnRemovedProps };
{
"name": "@tonic-ui/utils",
"version": "2.0.1",
"version": "2.1.0",
"description": "Common utilities for various Tonic UI components and packages.",

@@ -84,3 +84,3 @@ "main": "dist/cjs/index.js",

],
"gitHead": "f021669ef2bf6539938d24e94fd15c2cd6b3152c"
"gitHead": "848cc51dbe22087b5eff8eeff7d1c9c7ad6b0a1b"
}