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

@sebgroup/frontend-tools

Package Overview
Dependencies
Maintainers
4
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sebgroup/frontend-tools - npm Package Compare versions

Comparing version 2.1.1 to 2.2.0

downloadFile/downloadFile.d.ts

2

checkStringLength/checkStringLength.js

@@ -13,3 +13,3 @@ 'use strict';

function checkStringLength(value, min, max) {
return value && (value.length >= min && value.length <= max);
return value && value.length >= min && value.length <= max;
}

@@ -16,0 +16,0 @@

@@ -10,3 +10,5 @@ 'use strict';

class CookieStorage {
get length() { return this.keys().length; }
get length() {
return this.keys().length;
}
/**

@@ -21,3 +23,5 @@ * Retrieve an item from the stored cookie

}
return decodeURIComponent(document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*" + encodeURIComponent(key).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=\\s*([^;]*).*$)|^.*$"), "$1")) || null;
return (decodeURIComponent(document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*" +
encodeURIComponent(key).replace(/[\-\.\+\*]/g, "\\$&") +
"\\s*\\=\\s*([^;]*).*$)|^.*$"), "$1")) || null);
}

@@ -41,3 +45,5 @@ /**

}
if (options.maxAge && typeof options.maxAge === "number" && options.maxAge !== Infinity) {
if (options.maxAge &&
typeof options.maxAge === "number" &&
options.maxAge !== Infinity) {
maxAge = `; Max-age=${options.maxAge}`;

@@ -69,3 +75,5 @@ }

}
return (new RegExp("(?:^|;\\s*)" + encodeURIComponent(key).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=")).test(document.cookie);
return new RegExp("(?:^|;\\s*)" +
encodeURIComponent(key).replace(/[\-\.\+\*]/g, "\\$&") +
"\\s*\\=").test(document.cookie);
}

@@ -87,3 +95,5 @@ clear() {

keys() {
const aKeys = document.cookie.replace(/((?:^|\s*;)[^\=]+)(?=;|$)|^\s*|\s*(?:\=[^;]*)?(?:\1|$)/g, "").split(/\s*(?:\=[^;]*)?;\s*/);
const aKeys = document.cookie
.replace(/((?:^|\s*;)[^\=]+)(?=;|$)|^\s*|\s*(?:\=[^;]*)?(?:\1|$)/g, "")
.split(/\s*(?:\=[^;]*)?;\s*/);
for (let nLen = aKeys.length, nIdx = 0; nIdx < nLen; nIdx++) {

@@ -90,0 +100,0 @@ aKeys[nIdx] = decodeURIComponent(aKeys[nIdx]);

@@ -16,3 +16,3 @@ 'use strict';

if (range) {
console.warn("The range argument has been depracated. The range \"day\" will be used instead. \nTo compare units less than day use firstDate.getTime() - secondDate.getTime() to get milliseconds");
console.warn('The range argument has been depracated. The range "day" will be used instead. \nTo compare units less than day use firstDate.getTime() - secondDate.getTime() to get milliseconds');
}

@@ -19,0 +19,0 @@ if (!isValidDate.isValidDate(firstDate) || !isValidDate.isValidDate(secondDate)) {

@@ -11,9 +11,12 @@ 'use strict';

function deepCopy(obj, hash = new WeakMap()) {
if (Object(obj) !== obj) { // Primitive type
if (Object(obj) !== obj) {
// Primitive type
return obj;
}
else if (obj instanceof Set) { // Setter
else if (obj instanceof Set) {
// Setter
return new Set(obj);
}
else if (hash.has(obj)) { // Cyclic reference
else if (hash.has(obj)) {
// Cyclic reference
return hash.get(obj);

@@ -23,6 +26,8 @@ }

let result = Object.create(null);
if (obj instanceof Date) { // Date object
if (obj instanceof Date) {
// Date object
result = new Date(obj.getTime());
}
else if (obj instanceof RegExp) { // Regular expression
else if (obj instanceof RegExp) {
// Regular expression
result = new RegExp(obj.source, obj.flags);

@@ -34,6 +39,9 @@ }

hash.set(obj, result);
if (obj instanceof Map) { // Map object
if (obj instanceof Map) {
// Map object
Array.from(obj, ([key, val]) => result.set(key, deepCopy(val, hash)));
}
return Object.assign(result, ...Object.keys(obj).map((key) => ({ [key]: deepCopy(obj[key], hash) })));
return Object.assign(result, ...Object.keys(obj).map((key) => ({
[key]: deepCopy(obj[key], hash),
})));
}

@@ -46,4 +54,5 @@ }

function isSymbol(x) {
return typeof x === "symbol" ||
typeof x === "object" && Object.prototype.toString.call(x) === "[object Symbol]";
return (typeof x === "symbol" ||
(typeof x === "object" &&
Object.prototype.toString.call(x) === "[object Symbol]"));
}

@@ -50,0 +59,0 @@

@@ -9,3 +9,3 @@ /**

function checkStringLength(value, min, max) {
return value && (value.length >= min && value.length <= max);
return value && value.length >= min && value.length <= max;
}

@@ -12,0 +12,0 @@

@@ -6,3 +6,5 @@ /**

class CookieStorage {
get length() { return this.keys().length; }
get length() {
return this.keys().length;
}
/**

@@ -17,3 +19,5 @@ * Retrieve an item from the stored cookie

}
return decodeURIComponent(document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*" + encodeURIComponent(key).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=\\s*([^;]*).*$)|^.*$"), "$1")) || null;
return (decodeURIComponent(document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*" +
encodeURIComponent(key).replace(/[\-\.\+\*]/g, "\\$&") +
"\\s*\\=\\s*([^;]*).*$)|^.*$"), "$1")) || null);
}

@@ -37,3 +41,5 @@ /**

}
if (options.maxAge && typeof options.maxAge === "number" && options.maxAge !== Infinity) {
if (options.maxAge &&
typeof options.maxAge === "number" &&
options.maxAge !== Infinity) {
maxAge = `; Max-age=${options.maxAge}`;

@@ -65,3 +71,5 @@ }

}
return (new RegExp("(?:^|;\\s*)" + encodeURIComponent(key).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=")).test(document.cookie);
return new RegExp("(?:^|;\\s*)" +
encodeURIComponent(key).replace(/[\-\.\+\*]/g, "\\$&") +
"\\s*\\=").test(document.cookie);
}

@@ -83,3 +91,5 @@ clear() {

keys() {
const aKeys = document.cookie.replace(/((?:^|\s*;)[^\=]+)(?=;|$)|^\s*|\s*(?:\=[^;]*)?(?:\1|$)/g, "").split(/\s*(?:\=[^;]*)?;\s*/);
const aKeys = document.cookie
.replace(/((?:^|\s*;)[^\=]+)(?=;|$)|^\s*|\s*(?:\=[^;]*)?(?:\1|$)/g, "")
.split(/\s*(?:\=[^;]*)?;\s*/);
for (let nLen = aKeys.length, nIdx = 0; nIdx < nLen; nIdx++) {

@@ -86,0 +96,0 @@ aKeys[nIdx] = decodeURIComponent(aKeys[nIdx]);

@@ -12,3 +12,3 @@ import { isValidDate } from '../isValidDate/isValidDate.js';

if (range) {
console.warn("The range argument has been depracated. The range \"day\" will be used instead. \nTo compare units less than day use firstDate.getTime() - secondDate.getTime() to get milliseconds");
console.warn('The range argument has been depracated. The range "day" will be used instead. \nTo compare units less than day use firstDate.getTime() - secondDate.getTime() to get milliseconds');
}

@@ -15,0 +15,0 @@ if (!isValidDate(firstDate) || !isValidDate(secondDate)) {

@@ -7,9 +7,12 @@ /**

function deepCopy(obj, hash = new WeakMap()) {
if (Object(obj) !== obj) { // Primitive type
if (Object(obj) !== obj) {
// Primitive type
return obj;
}
else if (obj instanceof Set) { // Setter
else if (obj instanceof Set) {
// Setter
return new Set(obj);
}
else if (hash.has(obj)) { // Cyclic reference
else if (hash.has(obj)) {
// Cyclic reference
return hash.get(obj);

@@ -19,6 +22,8 @@ }

let result = Object.create(null);
if (obj instanceof Date) { // Date object
if (obj instanceof Date) {
// Date object
result = new Date(obj.getTime());
}
else if (obj instanceof RegExp) { // Regular expression
else if (obj instanceof RegExp) {
// Regular expression
result = new RegExp(obj.source, obj.flags);

@@ -30,6 +35,9 @@ }

hash.set(obj, result);
if (obj instanceof Map) { // Map object
if (obj instanceof Map) {
// Map object
Array.from(obj, ([key, val]) => result.set(key, deepCopy(val, hash)));
}
return Object.assign(result, ...Object.keys(obj).map((key) => ({ [key]: deepCopy(obj[key], hash) })));
return Object.assign(result, ...Object.keys(obj).map((key) => ({
[key]: deepCopy(obj[key], hash),
})));
}

@@ -42,4 +50,5 @@ }

function isSymbol(x) {
return typeof x === "symbol" ||
typeof x === "object" && Object.prototype.toString.call(x) === "[object Symbol]";
return (typeof x === "symbol" ||
(typeof x === "object" &&
Object.prototype.toString.call(x) === "[object Symbol]"));
}

@@ -46,0 +55,0 @@

@@ -35,3 +35,7 @@ import { isEmpty } from '../isEmpty/isEmpty.js';

addValidation(fields, type, specs) {
if (fields && fields instanceof Array && type && typeof type === "string" && this.isValidType(type)) {
if (fields &&
fields instanceof Array &&
type &&
typeof type === "string" &&
this.isValidType(type)) {
if (fields.length) {

@@ -66,3 +70,7 @@ fields.map((field) => {

addCustomValidation(errorFields, validator) {
if (errorFields && errorFields instanceof Array && errorFields.length && validator && validator instanceof Function) {
if (errorFields &&
errorFields instanceof Array &&
errorFields.length &&
validator &&
validator instanceof Function) {
this.customValidators.push({ errorFields, validator });

@@ -108,3 +116,5 @@ }

customValidator.errorFields.map((field) => {
if (this.formObject.has(field) && !this.getError(field) && customValidatorError) {
if (this.formObject.has(field) &&
!this.getError(field) &&
customValidatorError) {
this.formObjectErrors[field] = customValidatorError;

@@ -132,11 +142,23 @@ }

switch (type) {
case "required": return empty ? { errorCode: "empty" } : null;
case "isDate": return valid ? null : { errorCode: "invalidDate" };
case "required":
return empty ? { errorCode: "empty" } : null;
case "isDate":
return valid ? null : { errorCode: "invalidDate" };
case "dateRange":
if (valid) {
if (specs.minDate) {
fieldError = isDateBefore(date, specs.minDate) ? { errorCode: "beforeMinDate", specs: { minDate: specs.minDate } } : null;
fieldError = isDateBefore(date, specs.minDate)
? {
errorCode: "beforeMinDate",
specs: { minDate: specs.minDate },
}
: null;
}
if (!fieldError && specs.maxDate) {
fieldError = isDateAfter(date, specs.maxDate) ? { errorCode: "afterMaxDate", specs: { maxDate: specs.maxDate } } : null;
fieldError = isDateAfter(date, specs.maxDate)
? {
errorCode: "afterMaxDate",
specs: { maxDate: specs.maxDate },
}
: null;
}

@@ -151,6 +173,18 @@ return fieldError;

if (specs.minLength) {
fieldError = value.length < specs.minLength ? { errorCode: "lessThanMinLength", specs: { minLength: specs.minLength } } : null;
fieldError =
value.length < specs.minLength
? {
errorCode: "lessThanMinLength",
specs: { minLength: specs.minLength },
}
: null;
}
if (!fieldError && specs.maxLength) {
fieldError = value.length > specs.maxLength ? { errorCode: "moreThanMaxLength", specs: { maxLength: specs.maxLength } } : null;
fieldError =
value.length > specs.maxLength
? {
errorCode: "moreThanMaxLength",
specs: { maxLength: specs.maxLength },
}
: null;
}

@@ -165,6 +199,18 @@ return fieldError;

if (specs.minValue) {
fieldError = value < specs.minValue ? { errorCode: "lessThanMinValue", specs: { minValue: specs.minValue } } : null;
fieldError =
value < specs.minValue
? {
errorCode: "lessThanMinValue",
specs: { minValue: specs.minValue },
}
: null;
}
if (!fieldError && specs.maxValue) {
fieldError = value > specs.maxValue ? { errorCode: "moreThanMaxValue", specs: { maxValue: specs.maxValue } } : null;
fieldError =
value > specs.maxValue
? {
errorCode: "moreThanMaxValue",
specs: { maxValue: specs.maxValue },
}
: null;
}

@@ -176,5 +222,12 @@ return fieldError;

}
case "validEmail": return isEmail(value) ? null : { errorCode: "invalidEmail" };
case "strongPassword": return isStrongPassword(value) ? null : { errorCode: "weakPassword" };
case "isPhoneNumber": return isPhoneNumber(value) ? null : { errorCode: "invalidPhoneNumber" };
case "validEmail":
return isEmail(value) ? null : { errorCode: "invalidEmail" };
case "strongPassword":
return isStrongPassword(value)
? null
: { errorCode: "weakPassword" };
case "isPhoneNumber":
return isPhoneNumber(value)
? null
: { errorCode: "invalidPhoneNumber" };
}

@@ -181,0 +234,0 @@ }

@@ -20,3 +20,5 @@ /**

}
match = match[2] ? [match[1], match[2]] : [navigator.appName, navigator.appVersion, "-?"];
match = match[2]
? [match[1], match[2]]
: [navigator.appName, navigator.appVersion, "-?"];
temp = userAgent.match(/version\/(\d+)/i);

@@ -23,0 +25,0 @@ if (temp != null) {

@@ -8,2 +8,3 @@ export * from "./arrayToObject";

export * from "./deepCopy";
export * from "./downloadFile";
export * from "./formatDate";

@@ -10,0 +11,0 @@ export * from "./FormValidator";

@@ -8,2 +8,3 @@ export { arrayToObject } from './arrayToObject/arrayToObject.js';

export { deepCopy } from './deepCopy/deepCopy.js';
export { FileType, downloadFile } from './downloadFile/downloadFile.js';
export { formatDate } from './formatDate/formatDate.js';

@@ -10,0 +11,0 @@ export { FormValidator } from './FormValidator/FormValidator.js';

@@ -6,3 +6,4 @@ /**

function isBrowserChrome() {
return !!window.chrome && (!!window.chrome.webstore || !!window.chrome.runtime);
return (!!window.chrome &&
(!!window.chrome.webstore || !!window.chrome.runtime));
}

@@ -9,0 +10,0 @@

@@ -6,3 +6,5 @@ /**

function isBrowserOpera() {
return (!!window.opr && !!window.opr.addons) || !!window.opera || navigator.userAgent.indexOf(" OPR/") >= 0;
return ((!!window.opr && !!window.opr.addons) ||
!!window.opera ||
navigator.userAgent.indexOf(" OPR/") >= 0);
}

@@ -9,0 +11,0 @@

@@ -6,4 +6,6 @@ /**

function isBrowserSafari() {
return /constructor/i.test(window.HTMLElement) ||
((p) => p.toString() === "[object SafariRemoteNotification]")(!window["safari"] || (typeof window.safari !== "undefined" && window.safari.pushNotification));
return (/constructor/i.test(window.HTMLElement) ||
((p) => p.toString() === "[object SafariRemoteNotification]")(!window["safari"] ||
(typeof window.safari !== "undefined" &&
window.safari.pushNotification)));
}

@@ -10,0 +12,0 @@

@@ -14,3 +14,3 @@ import { isValidDate } from '../isValidDate/isValidDate.js';

else {
return a.getFullYear() > b.getFullYear() || a.getMonth() > b.getMonth() || a.getDate() > b.getDate();
return a.setHours(0, 0, 0).valueOf() > b.setHours(0, 0, 0).valueOf();
}

@@ -17,0 +17,0 @@ }

@@ -14,3 +14,5 @@ import { isValidDate } from '../isValidDate/isValidDate.js';

else {
return a.getFullYear() < b.getFullYear() || a.getMonth() < b.getMonth() || a.getDate() < b.getDate();
return (a.getFullYear() < b.getFullYear() ||
a.getMonth() < b.getMonth() ||
a.getDate() < b.getDate());
}

@@ -17,0 +19,0 @@ }

@@ -7,15 +7,19 @@ /**

function isEmpty(value) {
if (value === undefined || value === null) { // undefined or null
if (value === undefined || value === null) {
// undefined or null
return true;
}
else if (value instanceof Date) { // Date object behave different from normal objects
else if (value instanceof Date) {
// Date object behave different from normal objects
return false;
}
else if ((value instanceof Function)) {
else if (value instanceof Function) {
return false;
}
else if ((value instanceof Object) && !(value instanceof Array)) { // Object, not an array
else if (value instanceof Object && !(value instanceof Array)) {
// Object, not an array
return Object.keys(value).length < 1;
}
else if (value.length < 1) { // Array or string
else if (value.length < 1) {
// Array or string
return true;

@@ -22,0 +26,0 @@ }

@@ -7,3 +7,3 @@ /**

function isPrimitive(value) {
return (value !== Object(value));
return value !== Object(value);
}

@@ -10,0 +10,0 @@

@@ -21,3 +21,5 @@ /**

}
rangeName = rangeName.charAt(0).toUpperCase() + rangeName.substr(1, rangeName.length - 1);
rangeName =
rangeName.charAt(0).toUpperCase() +
rangeName.substr(1, rangeName.length - 1);
const getAccessor = `get${rangeName}`;

@@ -24,0 +26,0 @@ const currentValue = from[getAccessor] ? from[getAccessor]() : null;

@@ -7,3 +7,3 @@ /**

function randomId(seed) {
return seed + String((Math.random() * 1000) + (new Date()).getTime());
return seed + String(Math.random() * 1000 + new Date().getTime());
}

@@ -10,0 +10,0 @@

@@ -15,6 +15,9 @@ import { CookieStorage } from '../CookieStorage/CookieStorage.js';

break;
default: this.handler = localStorage;
default:
this.handler = localStorage;
}
}
get length() { return this.keys().length; }
get length() {
return this.keys().length;
}
setItem(key, value) {

@@ -21,0 +24,0 @@ this.handler.setItem(key, value);

@@ -18,3 +18,5 @@ /**

if ((options === null || options === void 0 ? void 0 : options.showDecimals) !== false) {
cents = Number((val - Math.floor(val)).toFixed((options === null || options === void 0 ? void 0 : options.numOfDecimals) || 2).replace("0.", ""));
cents = Number((val - Math.floor(val))
.toFixed((options === null || options === void 0 ? void 0 : options.numOfDecimals) || 2)
.replace("0.", ""));
}

@@ -25,3 +27,3 @@ }

list.map((item, index) => {
if (((list.length - (index + 1)) || 1) % 3 === 0) {
if ((list.length - (index + 1) || 1) % 3 === 0) {
newList.push(item);

@@ -35,3 +37,3 @@ newList.push((options === null || options === void 0 ? void 0 : options.separator) || ",");

amount = newList.join("");
return amount + (cents ? `${(options === null || options === void 0 ? void 0 : options.decimalSymbol) || "."}${cents}` : "");
return (amount + (cents ? `${(options === null || options === void 0 ? void 0 : options.decimalSymbol) || "."}${cents}` : ""));
};

@@ -38,0 +40,0 @@ if (typeof value === "number") {

@@ -1,2 +0,10 @@

export declare type DateComponents = [number, number, number?, number?, number?, number?, number?];
export declare type DateComponents = [
number,
number,
number?,
number?,
number?,
number?,
number?
];
/**

@@ -3,0 +11,0 @@ * Retrives a date object based on various inputs

@@ -15,7 +15,7 @@ import { isValidDate } from '../isValidDate/isValidDate.js';

switch (true) {
case !value: return null;
case value instanceof Date:
{
return isValidDate(value) ? value : null;
}
case !value:
return null;
case value instanceof Date: {
return isValidDate(value) ? value : null;
}
case typeof value === "string":

@@ -26,7 +26,11 @@ case typeof value === "number": {

}
case typeof value === "object" && Array.isArray(value) && value.length > 1: {
const newDate = new Date(...value);
return isValidDate(newDate) ? newDate : null;
}
default: return null;
case typeof value === "object" &&
Array.isArray(value) &&
value.length > 1:
{
const newDate = new Date(...value);
return isValidDate(newDate) ? newDate : null;
}
default:
return null;
}

@@ -33,0 +37,0 @@ }

@@ -10,3 +10,5 @@ /**

const className = "overflow-hidden";
const body = document.getElementsByTagName("body").item(0);
const body = document
.getElementsByTagName("body")
.item(0);
if (toggle !== undefined) {

@@ -13,0 +15,0 @@ if (toggle && !body.classList.contains(className)) {

@@ -10,3 +10,7 @@ /**

if (date && date instanceof Date && !!date.toLocaleDateString) {
return date.toLocaleDateString(locales, { year: "numeric", month: "long", day: "numeric" });
return date.toLocaleDateString(locales, {
year: "numeric",
month: "long",
day: "numeric",
});
}

@@ -13,0 +17,0 @@ else {

@@ -39,3 +39,7 @@ 'use strict';

addValidation(fields, type, specs) {
if (fields && fields instanceof Array && type && typeof type === "string" && this.isValidType(type)) {
if (fields &&
fields instanceof Array &&
type &&
typeof type === "string" &&
this.isValidType(type)) {
if (fields.length) {

@@ -70,3 +74,7 @@ fields.map((field) => {

addCustomValidation(errorFields, validator) {
if (errorFields && errorFields instanceof Array && errorFields.length && validator && validator instanceof Function) {
if (errorFields &&
errorFields instanceof Array &&
errorFields.length &&
validator &&
validator instanceof Function) {
this.customValidators.push({ errorFields, validator });

@@ -112,3 +120,5 @@ }

customValidator.errorFields.map((field) => {
if (this.formObject.has(field) && !this.getError(field) && customValidatorError) {
if (this.formObject.has(field) &&
!this.getError(field) &&
customValidatorError) {
this.formObjectErrors[field] = customValidatorError;

@@ -136,11 +146,23 @@ }

switch (type) {
case "required": return empty ? { errorCode: "empty" } : null;
case "isDate": return valid ? null : { errorCode: "invalidDate" };
case "required":
return empty ? { errorCode: "empty" } : null;
case "isDate":
return valid ? null : { errorCode: "invalidDate" };
case "dateRange":
if (valid) {
if (specs.minDate) {
fieldError = isDateBefore.isDateBefore(date, specs.minDate) ? { errorCode: "beforeMinDate", specs: { minDate: specs.minDate } } : null;
fieldError = isDateBefore.isDateBefore(date, specs.minDate)
? {
errorCode: "beforeMinDate",
specs: { minDate: specs.minDate },
}
: null;
}
if (!fieldError && specs.maxDate) {
fieldError = isDateAfter.isDateAfter(date, specs.maxDate) ? { errorCode: "afterMaxDate", specs: { maxDate: specs.maxDate } } : null;
fieldError = isDateAfter.isDateAfter(date, specs.maxDate)
? {
errorCode: "afterMaxDate",
specs: { maxDate: specs.maxDate },
}
: null;
}

@@ -155,6 +177,18 @@ return fieldError;

if (specs.minLength) {
fieldError = value.length < specs.minLength ? { errorCode: "lessThanMinLength", specs: { minLength: specs.minLength } } : null;
fieldError =
value.length < specs.minLength
? {
errorCode: "lessThanMinLength",
specs: { minLength: specs.minLength },
}
: null;
}
if (!fieldError && specs.maxLength) {
fieldError = value.length > specs.maxLength ? { errorCode: "moreThanMaxLength", specs: { maxLength: specs.maxLength } } : null;
fieldError =
value.length > specs.maxLength
? {
errorCode: "moreThanMaxLength",
specs: { maxLength: specs.maxLength },
}
: null;
}

@@ -169,6 +203,18 @@ return fieldError;

if (specs.minValue) {
fieldError = value < specs.minValue ? { errorCode: "lessThanMinValue", specs: { minValue: specs.minValue } } : null;
fieldError =
value < specs.minValue
? {
errorCode: "lessThanMinValue",
specs: { minValue: specs.minValue },
}
: null;
}
if (!fieldError && specs.maxValue) {
fieldError = value > specs.maxValue ? { errorCode: "moreThanMaxValue", specs: { maxValue: specs.maxValue } } : null;
fieldError =
value > specs.maxValue
? {
errorCode: "moreThanMaxValue",
specs: { maxValue: specs.maxValue },
}
: null;
}

@@ -180,5 +226,12 @@ return fieldError;

}
case "validEmail": return isEmail.isEmail(value) ? null : { errorCode: "invalidEmail" };
case "strongPassword": return isStrongPassword.isStrongPassword(value) ? null : { errorCode: "weakPassword" };
case "isPhoneNumber": return isPhoneNumber.isPhoneNumber(value) ? null : { errorCode: "invalidPhoneNumber" };
case "validEmail":
return isEmail.isEmail(value) ? null : { errorCode: "invalidEmail" };
case "strongPassword":
return isStrongPassword.isStrongPassword(value)
? null
: { errorCode: "weakPassword" };
case "isPhoneNumber":
return isPhoneNumber.isPhoneNumber(value)
? null
: { errorCode: "invalidPhoneNumber" };
}

@@ -185,0 +238,0 @@ }

@@ -24,3 +24,5 @@ 'use strict';

}
match = match[2] ? [match[1], match[2]] : [navigator.appName, navigator.appVersion, "-?"];
match = match[2]
? [match[1], match[2]]
: [navigator.appName, navigator.appVersion, "-?"];
temp = userAgent.match(/version\/(\d+)/i);

@@ -27,0 +29,0 @@ if (temp != null) {

@@ -8,2 +8,3 @@ export * from "./arrayToObject";

export * from "./deepCopy";
export * from "./downloadFile";
export * from "./formatDate";

@@ -10,0 +11,0 @@ export * from "./FormValidator";

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

var deepCopy = require('./deepCopy/deepCopy.js');
var downloadFile = require('./downloadFile/downloadFile.js');
var formatDate = require('./formatDate/formatDate.js');

@@ -51,2 +52,7 @@ var FormValidator = require('./FormValidator/FormValidator.js');

exports.deepCopy = deepCopy.deepCopy;
Object.defineProperty(exports, 'FileType', {
enumerable: true,
get: function () { return downloadFile.FileType; }
});
exports.downloadFile = downloadFile.downloadFile;
exports.formatDate = formatDate.formatDate;

@@ -53,0 +59,0 @@ exports.FormValidator = FormValidator.FormValidator;

@@ -10,3 +10,4 @@ 'use strict';

function isBrowserChrome() {
return !!window.chrome && (!!window.chrome.webstore || !!window.chrome.runtime);
return (!!window.chrome &&
(!!window.chrome.webstore || !!window.chrome.runtime));
}

@@ -13,0 +14,0 @@

@@ -10,3 +10,5 @@ 'use strict';

function isBrowserOpera() {
return (!!window.opr && !!window.opr.addons) || !!window.opera || navigator.userAgent.indexOf(" OPR/") >= 0;
return ((!!window.opr && !!window.opr.addons) ||
!!window.opera ||
navigator.userAgent.indexOf(" OPR/") >= 0);
}

@@ -13,0 +15,0 @@

@@ -10,4 +10,6 @@ 'use strict';

function isBrowserSafari() {
return /constructor/i.test(window.HTMLElement) ||
((p) => p.toString() === "[object SafariRemoteNotification]")(!window["safari"] || (typeof window.safari !== "undefined" && window.safari.pushNotification));
return (/constructor/i.test(window.HTMLElement) ||
((p) => p.toString() === "[object SafariRemoteNotification]")(!window["safari"] ||
(typeof window.safari !== "undefined" &&
window.safari.pushNotification)));
}

@@ -14,0 +16,0 @@

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

else {
return a.getFullYear() > b.getFullYear() || a.getMonth() > b.getMonth() || a.getDate() > b.getDate();
return a.setHours(0, 0, 0).valueOf() > b.setHours(0, 0, 0).valueOf();
}

@@ -21,0 +21,0 @@ }

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

else {
return a.getFullYear() < b.getFullYear() || a.getMonth() < b.getMonth() || a.getDate() < b.getDate();
return (a.getFullYear() < b.getFullYear() ||
a.getMonth() < b.getMonth() ||
a.getDate() < b.getDate());
}

@@ -21,0 +23,0 @@ }

@@ -11,15 +11,19 @@ 'use strict';

function isEmpty(value) {
if (value === undefined || value === null) { // undefined or null
if (value === undefined || value === null) {
// undefined or null
return true;
}
else if (value instanceof Date) { // Date object behave different from normal objects
else if (value instanceof Date) {
// Date object behave different from normal objects
return false;
}
else if ((value instanceof Function)) {
else if (value instanceof Function) {
return false;
}
else if ((value instanceof Object) && !(value instanceof Array)) { // Object, not an array
else if (value instanceof Object && !(value instanceof Array)) {
// Object, not an array
return Object.keys(value).length < 1;
}
else if (value.length < 1) { // Array or string
else if (value.length < 1) {
// Array or string
return true;

@@ -26,0 +30,0 @@ }

@@ -11,3 +11,3 @@ 'use strict';

function isPrimitive(value) {
return (value !== Object(value));
return value !== Object(value);
}

@@ -14,0 +14,0 @@

@@ -25,3 +25,5 @@ 'use strict';

}
rangeName = rangeName.charAt(0).toUpperCase() + rangeName.substr(1, rangeName.length - 1);
rangeName =
rangeName.charAt(0).toUpperCase() +
rangeName.substr(1, rangeName.length - 1);
const getAccessor = `get${rangeName}`;

@@ -28,0 +30,0 @@ const currentValue = from[getAccessor] ? from[getAccessor]() : null;

{
"name": "@sebgroup/frontend-tools",
"version": "2.1.1",
"version": "2.2.0",
"description": "A set of frontend tools",

@@ -5,0 +5,0 @@ "author": "sebgroup",

@@ -11,3 +11,3 @@ 'use strict';

function randomId(seed) {
return seed + String((Math.random() * 1000) + (new Date()).getTime());
return seed + String(Math.random() * 1000 + new Date().getTime());
}

@@ -14,0 +14,0 @@

@@ -8,3 +8,2 @@ [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)

# **Frontend tools**

@@ -11,0 +10,0 @@

@@ -19,6 +19,9 @@ 'use strict';

break;
default: this.handler = localStorage;
default:
this.handler = localStorage;
}
}
get length() { return this.keys().length; }
get length() {
return this.keys().length;
}
setItem(key, value) {

@@ -25,0 +28,0 @@ this.handler.setItem(key, value);

@@ -22,3 +22,5 @@ 'use strict';

if ((options === null || options === void 0 ? void 0 : options.showDecimals) !== false) {
cents = Number((val - Math.floor(val)).toFixed((options === null || options === void 0 ? void 0 : options.numOfDecimals) || 2).replace("0.", ""));
cents = Number((val - Math.floor(val))
.toFixed((options === null || options === void 0 ? void 0 : options.numOfDecimals) || 2)
.replace("0.", ""));
}

@@ -29,3 +31,3 @@ }

list.map((item, index) => {
if (((list.length - (index + 1)) || 1) % 3 === 0) {
if ((list.length - (index + 1) || 1) % 3 === 0) {
newList.push(item);

@@ -39,3 +41,3 @@ newList.push((options === null || options === void 0 ? void 0 : options.separator) || ",");

amount = newList.join("");
return amount + (cents ? `${(options === null || options === void 0 ? void 0 : options.decimalSymbol) || "."}${cents}` : "");
return (amount + (cents ? `${(options === null || options === void 0 ? void 0 : options.decimalSymbol) || "."}${cents}` : ""));
};

@@ -42,0 +44,0 @@ if (typeof value === "number") {

@@ -1,2 +0,10 @@

export declare type DateComponents = [number, number, number?, number?, number?, number?, number?];
export declare type DateComponents = [
number,
number,
number?,
number?,
number?,
number?,
number?
];
/**

@@ -3,0 +11,0 @@ * Retrives a date object based on various inputs

@@ -19,7 +19,7 @@ 'use strict';

switch (true) {
case !value: return null;
case value instanceof Date:
{
return isValidDate.isValidDate(value) ? value : null;
}
case !value:
return null;
case value instanceof Date: {
return isValidDate.isValidDate(value) ? value : null;
}
case typeof value === "string":

@@ -30,7 +30,11 @@ case typeof value === "number": {

}
case typeof value === "object" && Array.isArray(value) && value.length > 1: {
const newDate = new Date(...value);
return isValidDate.isValidDate(newDate) ? newDate : null;
}
default: return null;
case typeof value === "object" &&
Array.isArray(value) &&
value.length > 1:
{
const newDate = new Date(...value);
return isValidDate.isValidDate(newDate) ? newDate : null;
}
default:
return null;
}

@@ -37,0 +41,0 @@ }

@@ -14,3 +14,5 @@ 'use strict';

const className = "overflow-hidden";
const body = document.getElementsByTagName("body").item(0);
const body = document
.getElementsByTagName("body")
.item(0);
if (toggle !== undefined) {

@@ -17,0 +19,0 @@ if (toggle && !body.classList.contains(className)) {

@@ -14,3 +14,7 @@ 'use strict';

if (date && date instanceof Date && !!date.toLocaleDateString) {
return date.toLocaleDateString(locales, { year: "numeric", month: "long", day: "numeric" });
return date.toLocaleDateString(locales, {
year: "numeric",
month: "long",
day: "numeric",
});
}

@@ -17,0 +21,0 @@ else {

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

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

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

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

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

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