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

@slickgrid-universal/utils

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@slickgrid-universal/utils - npm Package Compare versions

Comparing version 5.0.0 to 5.2.0

35

dist/cjs/domUtils.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.windowScrollPosition = exports.insertAfterElement = exports.htmlEncodeWithPadding = exports.htmlEntityDecode = exports.htmlEncode = exports.findWidthOrDefault = exports.findFirstAttribute = exports.getStyleProp = exports.getInnerSize = exports.getOffset = exports.getOffsetRelativeToParent = exports.getHtmlStringOutput = exports.emptyElement = exports.destroyAllElementProps = exports.classNameToList = exports.createDomElement = exports.calculateAvailableSpace = void 0;
exports.calculateAvailableSpace = calculateAvailableSpace;
exports.createDomElement = createDomElement;
exports.classNameToList = classNameToList;
exports.destroyAllElementProps = destroyAllElementProps;
exports.emptyElement = emptyElement;
exports.getHtmlStringOutput = getHtmlStringOutput;
exports.getOffsetRelativeToParent = getOffsetRelativeToParent;
exports.getOffset = getOffset;
exports.getInnerSize = getInnerSize;
exports.getStyleProp = getStyleProp;
exports.findFirstAttribute = findFirstAttribute;
exports.findWidthOrDefault = findWidthOrDefault;
exports.htmlEncode = htmlEncode;
exports.htmlEntityDecode = htmlEntityDecode;
exports.htmlEncodeWithPadding = htmlEncodeWithPadding;
exports.insertAfterElement = insertAfterElement;
exports.windowScrollPosition = windowScrollPosition;
/** calculate available space for each side of the DOM element */

@@ -26,3 +42,2 @@ function calculateAvailableSpace(element) {

}
exports.calculateAvailableSpace = calculateAvailableSpace;
/**

@@ -60,3 +75,2 @@ * Create a DOM Element with any optional attributes or properties.

}
exports.createDomElement = createDomElement;
/**

@@ -72,3 +86,2 @@ * Accepts string containing the class or space-separated list of classes, and

}
exports.classNameToList = classNameToList;
/**

@@ -91,3 +104,2 @@ * Loop through all properties of an object and nullify any properties that are instanceof HTMLElement,

}
exports.destroyAllElementProps = destroyAllElementProps;
/**

@@ -103,3 +115,2 @@ * Empty a DOM element by removing all of its DOM element children leaving with an empty element (basically an empty shell)

}
exports.emptyElement = emptyElement;
/**

@@ -123,3 +134,2 @@ * From any input provided, return the HTML string (when a string is provided, it will be returned "as is" but when it's a number it will be converted to string)

}
exports.getHtmlStringOutput = getHtmlStringOutput;
/** Get offset of HTML element relative to a parent element */

@@ -139,3 +149,2 @@ function getOffsetRelativeToParent(parentElm, childElm) {

}
exports.getOffsetRelativeToParent = getOffsetRelativeToParent;
/** Get HTML element offset with pure JS */

@@ -160,3 +169,2 @@ function getOffset(elm) {

}
exports.getOffset = getOffset;
function getInnerSize(elm, type) {

@@ -175,3 +183,2 @@ let size = 0;

}
exports.getInnerSize = getInnerSize;
/** Get a DOM element style property value by calling getComputedStyle() on the element */

@@ -184,3 +191,2 @@ function getStyleProp(elm, property) {

}
exports.getStyleProp = getStyleProp;
function findFirstAttribute(inputElm, attributes) {

@@ -197,3 +203,2 @@ if (inputElm) {

}
exports.findFirstAttribute = findFirstAttribute;
/**

@@ -208,3 +213,2 @@ * Provide a width as a number or a string and find associated value in valid css style format or use default value when provided (or "auto" otherwise).

}
exports.findWidthOrDefault = findWidthOrDefault;
/**

@@ -228,3 +232,2 @@ * HTML encode using a plain <div>

}
exports.htmlEncode = htmlEncode;
/**

@@ -240,3 +243,2 @@ * Decode text into html entity

}
exports.htmlEntityDecode = htmlEntityDecode;
/**

@@ -257,3 +259,2 @@ * Encode string to html special char and add html space padding defined

}
exports.htmlEncodeWithPadding = htmlEncodeWithPadding;
/** insert an HTML Element after a target Element in the DOM */

@@ -263,3 +264,2 @@ function insertAfterElement(referenceNode, newNode) {

}
exports.insertAfterElement = insertAfterElement;
/**

@@ -275,3 +275,2 @@ * Get the Window Scroll top/left Position

}
exports.windowScrollPosition = windowScrollPosition;
//# sourceMappingURL=domUtils.js.map

@@ -15,3 +15,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.extend = void 0;
exports.extend = extend;
const hasOwn = Object.prototype.hasOwnProperty;

@@ -124,4 +124,3 @@ const toStr = Object.prototype.toString;

}
exports.extend = extend;
;
//# sourceMappingURL=nodeExtend.js.map

@@ -15,3 +15,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.stripTags = void 0;
exports.stripTags = stripTags;
const utils_1 = require("./utils");

@@ -176,3 +176,2 @@ const STATE_PLAINTEXT = Symbol('plaintext');

}
exports.stripTags = stripTags;
//# sourceMappingURL=stripTagsUtil.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.uniqueObjectArray = exports.uniqueArray = exports.toSnakeCase = exports.toSentenceCase = exports.toKebabCase = exports.toCamelCase = exports.titleCase = exports.setDeepValue = exports.removeAccentFromText = exports.parseBoolean = exports.isObjectEmpty = exports.isNumber = exports.hasData = exports.isPrimitiveOrHTML = exports.isPrimitiveValue = exports.isObject = exports.isDefinedNumber = exports.isDefined = exports.isEmptyObject = exports.getFunctionDetails = exports.emptyObject = exports.deepMerge = exports.deepCopy = exports.arrayRemoveItemByIndex = exports.addWhiteSpaces = exports.addToArrayWhenNotExists = void 0;
exports.addToArrayWhenNotExists = addToArrayWhenNotExists;
exports.addWhiteSpaces = addWhiteSpaces;
exports.arrayRemoveItemByIndex = arrayRemoveItemByIndex;
exports.deepCopy = deepCopy;
exports.deepMerge = deepMerge;
exports.emptyObject = emptyObject;
exports.getFunctionDetails = getFunctionDetails;
exports.isEmptyObject = isEmptyObject;
exports.isDefined = isDefined;
exports.isDefinedNumber = isDefinedNumber;
exports.isObject = isObject;
exports.isPrimitiveValue = isPrimitiveValue;
exports.isPrimitiveOrHTML = isPrimitiveOrHTML;
exports.isNumber = isNumber;
exports.isObjectEmpty = isObjectEmpty;
exports.parseBoolean = parseBoolean;
exports.removeAccentFromText = removeAccentFromText;
exports.setDeepValue = setDeepValue;
exports.titleCase = titleCase;
exports.toCamelCase = toCamelCase;
exports.toKebabCase = toKebabCase;
exports.toSentenceCase = toSentenceCase;
exports.toSnakeCase = toSnakeCase;
exports.uniqueArray = uniqueArray;
exports.uniqueObjectArray = uniqueObjectArray;
const nodeExtend_1 = require("./nodeExtend");

@@ -23,3 +47,2 @@ /**

}
exports.addToArrayWhenNotExists = addToArrayWhenNotExists;
/**

@@ -37,3 +60,2 @@ * Simple function that will return a string with the number of whitespaces asked, mostly used by the CSV export

}
exports.addWhiteSpaces = addWhiteSpaces;
/**

@@ -47,3 +69,2 @@ * Remove an item from the array by its index

}
exports.arrayRemoveItemByIndex = arrayRemoveItemByIndex;
/**

@@ -65,3 +86,2 @@ * @use `extend()` when possible.

}
exports.deepCopy = deepCopy;
/**

@@ -114,3 +134,2 @@ * Performs a deep merge of objects and returns new object, it does not modify the source object, objects (immutable) and merges arrays via concatenation.

}
exports.deepMerge = deepMerge;
/**

@@ -132,3 +151,2 @@ * Empty an object properties by looping through them all and deleting them

}
exports.emptyObject = emptyObject;
/**

@@ -170,3 +188,2 @@ * Get the function details (param & body) of a function.

}
exports.getFunctionDetails = getFunctionDetails;
/**

@@ -183,11 +200,8 @@ * Check if an object is empty

}
exports.isEmptyObject = isEmptyObject;
function isDefined(value) {
return value !== undefined && value !== null && value !== '';
}
exports.isDefined = isDefined;
function isDefinedNumber(value) {
return value !== null && !isNaN(value) && value !== '';
}
exports.isDefinedNumber = isDefinedNumber;
/**

@@ -201,3 +215,2 @@ * Simple object check.

}
exports.isObject = isObject;
/**

@@ -211,16 +224,6 @@ * Simple check to detect if the value is a primitive type

}
exports.isPrimitiveValue = isPrimitiveValue;
function isPrimitiveOrHTML(val) {
return val instanceof HTMLElement || val instanceof DocumentFragment || isPrimitiveValue(val);
}
exports.isPrimitiveOrHTML = isPrimitiveOrHTML;
/**
* Check if a value has any data (undefined, null or empty string will return False...)
* NOTE: a `false` boolean is consider as having data so it will return True
*/
function hasData(value) {
return value !== undefined && value !== null && value !== '';
}
exports.hasData = hasData;
/**
* Check if input value is a number, by default it won't be a strict checking

@@ -237,3 +240,2 @@ * but optionally we could check for strict equality, for example "3" in strict mode would return False but True when non-strict.

}
exports.isNumber = isNumber;
/** Check if an object is empty, it will also be considered empty when the input is null, undefined or isn't an object */

@@ -243,3 +245,2 @@ function isObjectEmpty(obj) {

}
exports.isObjectEmpty = isObjectEmpty;
/** Parse any input (bool, number, string) and return a boolean or False when not possible */

@@ -249,3 +250,2 @@ function parseBoolean(input) {

}
exports.parseBoolean = parseBoolean;
/**

@@ -261,3 +261,2 @@ * Remove any accents from a string by normalizing it

}
exports.removeAccentFromText = removeAccentFromText;
/** Set the object value of deeper node from a given dot (.) notation path (e.g.: "user.firstName") */

@@ -271,3 +270,3 @@ function setDeepValue(obj, path, value) {

if (obj && e !== undefined) {
setDeepValue((obj)[e] = (hasData(obj[e]) && (Array.isArray(obj[e]) || Object.prototype.toString.call((obj)[e]) === '[object Object]'))
setDeepValue((obj)[e] = (isDefined(obj[e]) && (Array.isArray(obj[e]) || Object.prototype.toString.call((obj)[e]) === '[object Object]'))
? (obj)[e]

@@ -281,3 +280,2 @@ : {}, path, value);

}
exports.setDeepValue = setDeepValue;
/**

@@ -300,3 +298,2 @@ * Title case (or capitalize) first char of a string, for example "hello world" will become "Hello world"

}
exports.titleCase = titleCase;
/**

@@ -319,3 +316,2 @@ * Converts a string to camel case (camelCase), for example "hello-world" (or "hellow world") will become "helloWorld"

}
exports.toCamelCase = toCamelCase;
/**

@@ -328,7 +324,6 @@ * Converts a string to kebab (hypen) case, for example "helloWorld" will become "hello-world"

if (typeof inputStr === 'string') {
return toCamelCase(inputStr).replace(/([A-Z])/g, '-$1').toLowerCase();
return toCamelCase(inputStr).replace(/([A-Z])|([-_])/g, '-$1').toLowerCase();
}
return inputStr;
}
exports.toKebabCase = toKebabCase;
/**

@@ -341,3 +336,3 @@ * Converts a camelCase or kebab-case string to a sentence case, for example "helloWorld" will become "Hello World" and "hello-world" will become "Hello world"

if (typeof inputStr === 'string') {
const result = inputStr.replace(/([A-Z])|(-)/g, ' $1').replace(/\s+/g, ' ').trim();
const result = inputStr.replace(/([A-Z])|([-_])/g, ' $1').replace(/\s+/g, ' ').trim();
return result.charAt(0).toUpperCase() + result.slice(1);

@@ -347,3 +342,2 @@ }

}
exports.toSentenceCase = toSentenceCase;
/**

@@ -360,3 +354,2 @@ * Converts a string from camelCase to snake_case (underscore) case

}
exports.toSnakeCase = toSnakeCase;
/**

@@ -375,3 +368,2 @@ * Takes an input array and makes sure the array has unique values by removing duplicates

}
exports.uniqueArray = uniqueArray;
/**

@@ -401,3 +393,2 @@ * Takes an input array of objects and makes sure the array has unique object values by removing duplicates

}
exports.uniqueObjectArray = uniqueObjectArray;
//# sourceMappingURL=utils.js.map

@@ -192,9 +192,2 @@ import { extend } from './nodeExtend';

/**
* Check if a value has any data (undefined, null or empty string will return False...)
* NOTE: a `false` boolean is consider as having data so it will return True
*/
export function hasData(value) {
return value !== undefined && value !== null && value !== '';
}
/**
* Check if input value is a number, by default it won't be a strict checking

@@ -237,3 +230,3 @@ * but optionally we could check for strict equality, for example "3" in strict mode would return False but True when non-strict.

if (obj && e !== undefined) {
setDeepValue((obj)[e] = (hasData(obj[e]) && (Array.isArray(obj[e]) || Object.prototype.toString.call((obj)[e]) === '[object Object]'))
setDeepValue((obj)[e] = (isDefined(obj[e]) && (Array.isArray(obj[e]) || Object.prototype.toString.call((obj)[e]) === '[object Object]'))
? (obj)[e]

@@ -288,3 +281,3 @@ : {}, path, value);

if (typeof inputStr === 'string') {
return toCamelCase(inputStr).replace(/([A-Z])/g, '-$1').toLowerCase();
return toCamelCase(inputStr).replace(/([A-Z])|([-_])/g, '-$1').toLowerCase();
}

@@ -300,3 +293,3 @@ return inputStr;

if (typeof inputStr === 'string') {
const result = inputStr.replace(/([A-Z])|(-)/g, ' $1').replace(/\s+/g, ' ').trim();
const result = inputStr.replace(/([A-Z])|([-_])/g, ' $1').replace(/\s+/g, ' ').trim();
return result.charAt(0).toUpperCase() + result.slice(1);

@@ -303,0 +296,0 @@ }

@@ -66,3 +66,3 @@ import type { AnyFunction } from './models/types';

*/
export declare function isObject(item: any): boolean;
export declare function isObject(item: any): item is object;
/**

@@ -76,7 +76,2 @@ * Simple check to detect if the value is a primitive type

/**
* Check if a value has any data (undefined, null or empty string will return False...)
* NOTE: a `false` boolean is consider as having data so it will return True
*/
export declare function hasData(value: any): boolean;
/**
* Check if input value is a number, by default it won't be a strict checking

@@ -87,3 +82,3 @@ * but optionally we could check for strict equality, for example "3" in strict mode would return False but True when non-strict.

*/
export declare function isNumber(value: any, strict?: boolean): boolean;
export declare function isNumber(value: any, strict?: boolean): value is number;
/** Check if an object is empty, it will also be considered empty when the input is null, undefined or isn't an object */

@@ -90,0 +85,0 @@ export declare function isObjectEmpty(obj: unknown): boolean;

{
"name": "@slickgrid-universal/utils",
"version": "5.0.0",
"version": "5.2.0",
"description": "Common set of small utilities",

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

],
"gitHead": "526fc83e33b1e6ea236082b1b4cb50be623f4569"
"gitHead": "d7de27ab3ac3c7e2d48302603ac76aaf794e66a2"
}

@@ -82,3 +82,3 @@ import type { HtmlElementPosition, InferDOMType } from './models/index';

*/
export function destroyAllElementProps(obj: any) {
export function destroyAllElementProps(obj: any): void {
if (typeof obj === 'object') {

@@ -126,3 +126,8 @@ Object.keys(obj).forEach(key => {

/** Get offset of HTML element relative to a parent element */
export function getOffsetRelativeToParent(parentElm: HTMLElement | null, childElm: HTMLElement | null) {
export function getOffsetRelativeToParent(parentElm: HTMLElement | null, childElm: HTMLElement | null): {
top: number;
right: number;
bottom: number;
left: number;
} | undefined {
if (!parentElm || !childElm) {

@@ -163,3 +168,3 @@ return undefined;

export function getInnerSize(elm: HTMLElement, type: 'height' | 'width') {
export function getInnerSize(elm: HTMLElement, type: 'height' | 'width'): number {
let size = 0;

@@ -180,3 +185,3 @@

/** Get a DOM element style property value by calling getComputedStyle() on the element */
export function getStyleProp(elm: HTMLElement, property: string) {
export function getStyleProp(elm: HTMLElement, property: string): string | null {
if (elm) {

@@ -258,3 +263,3 @@ return window.getComputedStyle(elm).getPropertyValue(property);

/** insert an HTML Element after a target Element in the DOM */
export function insertAfterElement(referenceNode: HTMLElement, newNode: HTMLElement) {
export function insertAfterElement(referenceNode: HTMLElement, newNode: HTMLElement): void {
referenceNode.parentNode?.insertBefore(newNode, referenceNode.nextSibling);

@@ -261,0 +266,0 @@ }

@@ -31,3 +31,3 @@ /**

export function stripTags(htmlText: string | number | boolean | HTMLElement, allowableTags?: string | string[], tagReplacement?: string) {
export function stripTags(htmlText: string | number | boolean | HTMLElement, allowableTags?: string | string[], tagReplacement?: string): string {

@@ -34,0 +34,0 @@ /** main init function that will be executed when calling the global function */

@@ -10,3 +10,3 @@ import type { AnyFunction } from './models/types';

*/
export function addToArrayWhenNotExists<T = any>(inputArray: T[], inputItem: T, itemIdPropName = 'id') {
export function addToArrayWhenNotExists<T = any>(inputArray: T[], inputItem: T, itemIdPropName = 'id'): void {
let arrayRowIndex = -1;

@@ -85,14 +85,14 @@ if (inputItem && typeof inputItem === 'object' && itemIdPropName in inputItem) {

// handling merging of two properties with equal names
if (typeof target[prop] !== 'object') {
target[prop] = source[prop];
if (typeof (target as any)[prop] !== 'object') {
(target as any)[prop] = (source as any)[prop];
} else {
if (typeof source[prop] !== 'object') {
target[prop] = source[prop];
if (typeof (source as any)[prop] !== 'object') {
(target as any)[prop] = (source as any)[prop];
} else {
if (target[prop].concat && source[prop].concat) {
if ((target as any)[prop].concat && (source as any)[prop].concat) {
// two arrays get concatenated
target[prop] = target[prop].concat(source[prop]);
(target as any)[prop] = (target as any)[prop].concat((source as any)[prop]);
} else {
// two objects get merged recursively
target[prop] = deepMerge(target[prop], source[prop]);
(target as any)[prop] = deepMerge((target as any)[prop], (source as any)[prop]);
}

@@ -103,3 +103,3 @@ }

// new properties get added to target
target[prop] = source[prop];
(target as any)[prop] = (source as any)[prop];
}

@@ -116,3 +116,3 @@ }

*/
export function emptyObject(obj: any) {
export function emptyObject(obj: any): any {
if (isObject(obj)) {

@@ -138,3 +138,7 @@ Object.keys(obj).forEach(key => {

*/
export function getFunctionDetails(fn: AnyFunction, addReturn = true) {
export function getFunctionDetails(fn: AnyFunction, addReturn = true): {
params: string[];
body: string;
isAsync: boolean;
} {
let isAsyncFn = false;

@@ -172,3 +176,3 @@

body: getFunctionBody(fn),
isAsync: isAsyncFn,
isAsync: isAsyncFn satisfies typeof isAsyncFn as boolean,
};

@@ -202,3 +206,3 @@ }

*/
export function isObject(item: any) {
export function isObject(item: any): item is object {
return item !== null && typeof item === 'object' && !Array.isArray(item) && !(item instanceof Date);

@@ -212,7 +216,7 @@ }

*/
export function isPrimitiveValue(val: any) {
export function isPrimitiveValue(val: any): boolean {
return typeof val === 'boolean' || typeof val === 'number' || typeof val === 'string' || val === null || val === undefined;
}
export function isPrimitiveOrHTML(val: any) {
export function isPrimitiveOrHTML(val: any): boolean {
return val instanceof HTMLElement || val instanceof DocumentFragment || isPrimitiveValue(val);

@@ -222,10 +226,2 @@ }

/**
* Check if a value has any data (undefined, null or empty string will return False...)
* NOTE: a `false` boolean is consider as having data so it will return True
*/
export function hasData(value: any): boolean {
return value !== undefined && value !== null && value !== '';
}
/**
* Check if input value is a number, by default it won't be a strict checking

@@ -236,3 +232,3 @@ * but optionally we could check for strict equality, for example "3" in strict mode would return False but True when non-strict.

*/
export function isNumber(value: any, strict = false) {
export function isNumber(value: any, strict = false): value is number {
if (strict) {

@@ -245,3 +241,3 @@ return (value === null || value === undefined || typeof value === 'string') ? false : !isNaN(value);

/** Check if an object is empty, it will also be considered empty when the input is null, undefined or isn't an object */
export function isObjectEmpty(obj: unknown) {
export function isObjectEmpty(obj: unknown): boolean {
return !obj || (obj && typeof obj === 'object' && Object.keys(obj).length === 0);

@@ -261,3 +257,3 @@ }

*/
export function removeAccentFromText(text: string, shouldLowerCase = false) {
export function removeAccentFromText(text: string, shouldLowerCase = false): string {
const normalizedText = (typeof text.normalize === 'function') ? text.normalize('NFD').replace(/[\u0300-\u036f]/g, '') : text;

@@ -268,3 +264,3 @@ return shouldLowerCase ? normalizedText.toLowerCase() : normalizedText;

/** Set the object value of deeper node from a given dot (.) notation path (e.g.: "user.firstName") */
export function setDeepValue<T = unknown>(obj: T, path: string | string[], value: any) {
export function setDeepValue<T = unknown>(obj: T, path: string | string[], value: any): void {
if (typeof path === 'string') {

@@ -278,3 +274,3 @@ path = path.split('.');

setDeepValue(
(obj)[e] = (hasData(obj[e]) && (Array.isArray(obj[e]) || Object.prototype.toString.call((obj)[e]) === '[object Object]'))
(obj)[e] = (isDefined(obj[e]) && (Array.isArray(obj[e]) || Object.prototype.toString.call((obj)[e]) === '[object Object]'))
? (obj)[e]

@@ -335,3 +331,3 @@ : {} as any,

if (typeof inputStr === 'string') {
return toCamelCase(inputStr).replace(/([A-Z])/g, '-$1').toLowerCase();
return toCamelCase(inputStr).replace(/([A-Z])|([-_])/g, '-$1').toLowerCase();
}

@@ -348,3 +344,3 @@ return inputStr;

if (typeof inputStr === 'string') {
const result = inputStr.replace(/([A-Z])|(-)/g, ' $1').replace(/\s+/g, ' ').trim();
const result = inputStr.replace(/([A-Z])|([-_])/g, ' $1').replace(/\s+/g, ' ').trim();
return result.charAt(0).toUpperCase() + result.slice(1);

@@ -351,0 +347,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc