UNPKG

@techmely/utils

Version:

Collection of helpful JavaScript / TypeScript utils

738 lines (735 loc) 13.8 kB
/*! * @techmely/utils * Copyright(c) 2021-2024 Techmely <techmely.creation@gmail.com> * MIT Licensed */ import { toPointsArray } from "./chunk-K6M6HKMZ.mjs"; import { transitionEnd } from "./chunk-7LWOZUOT.mjs"; import { unique } from "./chunk-SD2OWPU3.mjs"; import { uniqueObj } from "./chunk-2L3J6ASP.mjs"; import { sortData } from "./chunk-OJ2OEZLM.mjs"; import { suffixAmPm } from "./chunk-UUJODKXP.mjs"; import { sum } from "./chunk-IQS6LUAQ.mjs"; import { take } from "./chunk-YU5BU36G.mjs"; import { timeSpan } from "./chunk-XMQRWOZD.mjs"; import { removeUndefObj } from "./chunk-ECEHVK2Z.mjs"; import { requestIdleCallback } from "./chunk-EGLTIJ7I.mjs"; import { shuffle } from "./chunk-GX5GO4OX.mjs"; import { singleton } from "./chunk-DF3BMFR2.mjs"; import { sleep } from "./chunk-5E7YTXU6.mjs"; import { slugify } from "./chunk-V5S6W27S.mjs"; import { snake2camel } from "./chunk-UKE3NRJI.mjs"; import { SortDirection, sortByDate } from "./chunk-B4MTGXQK.mjs"; import { PTimeOut } from "./chunk-UH6ILUD3.mjs"; import { pick } from "./chunk-LISAF2IG.mjs"; import { emailRegex, escapedSpaceCharactersRegex, isValidEmail, isValidUrl, isValidVnPhone, multilineCommentsRegex, singlelineCommentsRegex, urlRegex, vietnamPhoneRegex } from "./chunk-434SPO5N.mjs"; import { remove } from "./chunk-PV6QAYU5.mjs"; import { removeEmptyObj } from "./chunk-AHJQKIU3.mjs"; import { objectEntries } from "./chunk-XRVKEXCW.mjs"; import { objectKeys } from "./chunk-AZIIBNWM.mjs"; import { PCancelable } from "./chunk-B7TSSNOV.mjs"; import { PDefer } from "./chunk-SNLJUQXC.mjs"; import { clearDelay, createDelay, delay, rangeDelay } from "./chunk-TUCI763A.mjs"; import { PQueue } from "./chunk-L6C6CSGY.mjs"; import { minusPrecision } from "./chunk-VASC4HIS.mjs"; import { plusPrecision } from "./chunk-QB25LJDN.mjs"; import { roundPrecision } from "./chunk-TWL7W7CR.mjs"; import { dividePrecision } from "./chunk-NNNPJRRQ.mjs"; import { timesPrecision } from "./chunk-I7ZFDSJ2.mjs"; import { createOperationPrecision } from "./chunk-ITZVOK4F.mjs"; import { float2FixedPrecision } from "./chunk-JJ7DTBTN.mjs"; import { digitLengthPrecision } from "./chunk-HHTSEVTB.mjs"; import { stripPrecision } from "./chunk-GPTFO2E2.mjs"; import { minMax } from "./chunk-L2PFIAP4.mjs"; import { MutexLock } from "./chunk-UPKLAT4W.mjs"; import { nextEvent } from "./chunk-EFYVR3QV.mjs"; import { nextFrame } from "./chunk-2KXXJOOL.mjs"; import { nextIdle } from "./chunk-GY3YPSOS.mjs"; import { noop } from "./chunk-NMEOFDUE.mjs"; import { normalize } from "./chunk-RL3NMFXB.mjs"; import { checkBoundaryPrecision, enableBoundaryCheckingPrecision } from "./chunk-AD7ANKJD.mjs"; import { isToday } from "./chunk-7RNI7YAB.mjs"; import { isUndefined } from "./chunk-446UTKLG.mjs"; import { isWindows } from "./chunk-5JHXLW6K.mjs"; import { mapObject } from "./chunk-I567ENOF.mjs"; import { mergeDeep } from "./chunk-I4LETBPG.mjs"; import { isRegExp } from "./chunk-4EDBAMFG.mjs"; import { isSameDay } from "./chunk-VLQNMI7A.mjs"; import { isSameMonth } from "./chunk-KBPCYPID.mjs"; import { isServer } from "./chunk-ZVWX56RU.mjs"; import { isSet } from "./chunk-K5RQWX27.mjs"; import { isStream } from "./chunk-CJN4MLVU.mjs"; import { isSymbol } from "./chunk-L6CTUTRJ.mjs"; import { isNotNull } from "./chunk-MCZYMIGI.mjs"; import { isNotNullish } from "./chunk-DHTXH2FH.mjs"; import { isPngImage } from "./chunk-2JLNLQSO.mjs"; import { isPrimitive } from "./chunk-3ZYTSFQA.mjs"; import { isPromise } from "./chunk-3RVJBS2G.mjs"; import { isLinux } from "./chunk-4AVLKCBJ.mjs"; import { isMacOS } from "./chunk-GFJ3RA6L.mjs"; import { isMobile } from "./chunk-N74X6HSJ.mjs"; import "./chunk-BPJKMILL.mjs"; import { isNodeProd } from "./chunk-NQ25JWMJ.mjs"; import { isNodeTest } from "./chunk-7SNG4BBL.mjs"; import { globProcess } from "./chunk-JR6SYPCS.mjs"; import { isNotEmpties } from "./chunk-4MKTSO3L.mjs"; import { isNotEmpty } from "./chunk-YZ4U7P47.mjs"; import { isEmpties } from "./chunk-EUKTPEGX.mjs"; import { isEmpty } from "./chunk-TL3CTVEM.mjs"; import { isString } from "./chunk-J6NLSENU.mjs"; import { isObject } from "./chunk-MGQF5GXR.mjs"; import { isEmptyArr } from "./chunk-4P7NQXMR.mjs"; import { hexColor, isHex } from "./chunk-ZBLADP34.mjs"; import { isIOS } from "./chunk-VEEOOKX5.mjs"; import { isKeyOf } from "./chunk-U7JSBNDZ.mjs"; import { isBase64 } from "./chunk-ADZLH2AM.mjs"; import { isBoolean } from "./chunk-L4CWR3DY.mjs"; import { botFullPattern, botPatterns, botRegPattern, createIsBot, createIsBotFromList, isBot, isBotMatch, isBotMatches, isBotNaive, isBotPattern, isBotPatterns } from "./chunk-ABY5NUYO.mjs"; import { isBrowser } from "./chunk-AJMQPQGJ.mjs"; import { toBoolean } from "./chunk-FYOM22JR.mjs"; import { isCrawler } from "./chunk-YCPSVRUV.mjs"; import { isDefined } from "./chunk-WTO2SOQI.mjs"; import { HTTP_ACCEPTED, HTTP_ALREADY_REPORTED, HTTP_BAD_GATEWAY, HTTP_BAD_REQUEST, HTTP_CF_A_TIMEOUT_OCCURRED, HTTP_CF_CONNECTION_TIMED_OUT, HTTP_CF_INVALID_SSL_CERTIFICATE, HTTP_CF_ORIGIN_IS_UNREACHABLE, HTTP_CF_RAILGUN_ERROR, HTTP_CF_SSL_HANDSHAKE_FAILED, HTTP_CF_UNKNOWN, HTTP_CF_WEB_SERVER_IS_DOWN, HTTP_CONFLICT, HTTP_CONTINUE, HTTP_CREATED, HTTP_EARLY_HINTS, HTTP_EXPECTATION_FAILED, HTTP_FAILED_DEPENDENCY, HTTP_FORBIDDEN, HTTP_FOUND, HTTP_GATEWAY_TIMEOUT, HTTP_GONE, HTTP_IM_USED, HTTP_INSUFFICIENT_STORAGE, HTTP_INTERNAL_SERVER_ERROR, HTTP_I_AM_A_TEAPOT, HTTP_LENGTH_REQUIRED, HTTP_LOCKED, HTTP_LOOP_DETECTED, HTTP_METHOD_NOT_ALLOWED, HTTP_MISDIRECTED_REQUEST, HTTP_MOVED_PERMANENTLY, HTTP_MULTIPLE_CHOICES, HTTP_MULTI_STATUS, HTTP_NETWORK_AUTHENTICATION_REQUIRED, HTTP_NON_AUTHORITATIVE_INFORMATION, HTTP_NOT_ACCEPTABLE, HTTP_NOT_EXTENDED, HTTP_NOT_FOUND, HTTP_NOT_IMPLEMENTED, HTTP_NOT_MODIFIED, HTTP_NO_CONTENT, HTTP_OK, HTTP_PARTIAL_CONTENT, HTTP_PAYMENT_REQUIRED, HTTP_PERMANENTLY_REDIRECT, HTTP_PRECONDITION_FAILED, HTTP_PRECONDITION_REQUIRED, HTTP_PROCESSING, HTTP_PROXY_AUTHENTICATION_REQUIRED, HTTP_REQUESTED_RANGE_NOT_SATISFIABLE, HTTP_REQUEST_ENTITY_TOO_LARGE, HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE, HTTP_REQUEST_TIMEOUT, HTTP_REQUEST_URI_TOO_LONG, HTTP_RESERVED, HTTP_RESERVED_FOR_WEBDAV_ADVANCED_COLLECTIONS_EXPIRED_PROPOSAL, HTTP_RESET_CONTENT, HTTP_SEE_OTHER, HTTP_SERVICE_UNAVAILABLE, HTTP_SWITCHING_PROTOCOLS, HTTP_TEMPORARY_REDIRECT, HTTP_TOO_MANY_REQUESTS, HTTP_UNAUTHORIZED, HTTP_UNAVAILABLE_FOR_LEGAL_REASONS, HTTP_UNPROCESSABLE_ENTITY, HTTP_UNSUPPORTED_MEDIA_TYPE, HTTP_UPGRADE_REQUIRED, HTTP_USE_PROXY, HTTP_VARIANT_ALSO_NEGOTIATES_EXPERIMENTAL, HTTP_VERSION_NOT_SUPPORTED } from "./chunk-6YXDMBVT.mjs"; import { hyphenate } from "./chunk-3RTWP525.mjs"; import { intToBuffer } from "./chunk-F5FDBZ5W.mjs"; import { intToHex } from "./chunk-KQOFR6X4.mjs"; import { invariant } from "./chunk-JBXZG2HJ.mjs"; import { isAndroid } from "./chunk-RL7C4MZC.mjs"; import { isArray } from "./chunk-UGDKU24C.mjs"; import { MimeType, getMimeTypeFromExtension, mimeTable } from "./chunk-Z33GKF6Y.mjs"; import { getQuarter } from "./chunk-X62GE6Y4.mjs"; import { getRandomInt } from "./chunk-MBFX3DT4.mjs"; import { getRandomIntInclusive } from "./chunk-KVP5GDHR.mjs"; import { getRandomString } from "./chunk-4YHBCUNG.mjs"; import { getStrokeRadius } from "./chunk-O7RVNCAV.mjs"; import { lerp } from "./chunk-Z7KOBSTB.mjs"; import { groupBy } from "./chunk-UORG5W7K.mjs"; import { formatNumber } from "./chunk-UMAN6QVD.mjs"; import { fromStringToPrimitives } from "./chunk-22YUQLUT.mjs"; import { generateSample } from "./chunk-VEWDIB3S.mjs"; import { findDuplicates } from "./chunk-RZ4N4IKK.mjs"; import { findLastIndex } from "./chunk-R4AZFFAM.mjs"; import { firstUniqueArr } from "./chunk-ELMDNR3O.mjs"; import { firstUniqueChar } from "./chunk-MLZBN5YM.mjs"; import { formatBytes } from "./chunk-C36ZM6TB.mjs"; import { formatLot10Volume } from "./chunk-WPWSPGVV.mjs"; import { isNumber } from "./chunk-N7YWL7WT.mjs"; import { cutString } from "./chunk-FRXTB2WY.mjs"; import { deleteProps } from "./chunk-WV22BDCF.mjs"; import { downloadByData } from "./chunk-GFO5EIK4.mjs"; import { emitter } from "./chunk-AFZ5ZVXP.mjs"; import { envShims } from "./chunk-UIBCAP7L.mjs"; import { escapeRegExp } from "./chunk-MRRY4CXB.mjs"; import { cancelIdleCallback } from "./chunk-U6YF3C6K.mjs"; import { capitalizeFirst } from "./chunk-VL3JTQ64.mjs"; import { chunk } from "./chunk-3M6YMVFA.mjs"; import { clamp } from "./chunk-AN6UV2MK.mjs"; import { convertHrTime } from "./chunk-55S7JK54.mjs"; import { CookieService, listenCookieChange, parseCookie, serializeCookie } from "./chunk-SRX3LJCV.mjs"; import { isDate } from "./chunk-FPXUBAA6.mjs"; import { alphaHex } from "./chunk-GN6UMWX2.mjs"; import { percentToHex } from "./chunk-2FGIY4B7.mjs"; import { createCachedImport } from "./chunk-Y4RJODPZ.mjs"; import { callOrReturn } from "./chunk-KLSEBSCQ.mjs"; import { isFunction } from "./chunk-XD2YO3MV.mjs"; import { camel2SnakeObject } from "./chunk-OK36IAWH.mjs"; import { camel2snake } from "./chunk-ZWU7NON2.mjs"; import { camelize } from "./chunk-WJD6PW62.mjs"; import { cacheStringFunction } from "./chunk-2Z727VLZ.mjs"; import "./chunk-NYLAFCGV.mjs"; export { CookieService, HTTP_ACCEPTED, HTTP_ALREADY_REPORTED, HTTP_BAD_GATEWAY, HTTP_BAD_REQUEST, HTTP_CF_A_TIMEOUT_OCCURRED, HTTP_CF_CONNECTION_TIMED_OUT, HTTP_CF_INVALID_SSL_CERTIFICATE, HTTP_CF_ORIGIN_IS_UNREACHABLE, HTTP_CF_RAILGUN_ERROR, HTTP_CF_SSL_HANDSHAKE_FAILED, HTTP_CF_UNKNOWN, HTTP_CF_WEB_SERVER_IS_DOWN, HTTP_CONFLICT, HTTP_CONTINUE, HTTP_CREATED, HTTP_EARLY_HINTS, HTTP_EXPECTATION_FAILED, HTTP_FAILED_DEPENDENCY, HTTP_FORBIDDEN, HTTP_FOUND, HTTP_GATEWAY_TIMEOUT, HTTP_GONE, HTTP_IM_USED, HTTP_INSUFFICIENT_STORAGE, HTTP_INTERNAL_SERVER_ERROR, HTTP_I_AM_A_TEAPOT, HTTP_LENGTH_REQUIRED, HTTP_LOCKED, HTTP_LOOP_DETECTED, HTTP_METHOD_NOT_ALLOWED, HTTP_MISDIRECTED_REQUEST, HTTP_MOVED_PERMANENTLY, HTTP_MULTIPLE_CHOICES, HTTP_MULTI_STATUS, HTTP_NETWORK_AUTHENTICATION_REQUIRED, HTTP_NON_AUTHORITATIVE_INFORMATION, HTTP_NOT_ACCEPTABLE, HTTP_NOT_EXTENDED, HTTP_NOT_FOUND, HTTP_NOT_IMPLEMENTED, HTTP_NOT_MODIFIED, HTTP_NO_CONTENT, HTTP_OK, HTTP_PARTIAL_CONTENT, HTTP_PAYMENT_REQUIRED, HTTP_PERMANENTLY_REDIRECT, HTTP_PRECONDITION_FAILED, HTTP_PRECONDITION_REQUIRED, HTTP_PROCESSING, HTTP_PROXY_AUTHENTICATION_REQUIRED, HTTP_REQUESTED_RANGE_NOT_SATISFIABLE, HTTP_REQUEST_ENTITY_TOO_LARGE, HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE, HTTP_REQUEST_TIMEOUT, HTTP_REQUEST_URI_TOO_LONG, HTTP_RESERVED, HTTP_RESERVED_FOR_WEBDAV_ADVANCED_COLLECTIONS_EXPIRED_PROPOSAL, HTTP_RESET_CONTENT, HTTP_SEE_OTHER, HTTP_SERVICE_UNAVAILABLE, HTTP_SWITCHING_PROTOCOLS, HTTP_TEMPORARY_REDIRECT, HTTP_TOO_MANY_REQUESTS, HTTP_UNAUTHORIZED, HTTP_UNAVAILABLE_FOR_LEGAL_REASONS, HTTP_UNPROCESSABLE_ENTITY, HTTP_UNSUPPORTED_MEDIA_TYPE, HTTP_UPGRADE_REQUIRED, HTTP_USE_PROXY, HTTP_VARIANT_ALSO_NEGOTIATES_EXPERIMENTAL, HTTP_VERSION_NOT_SUPPORTED, MimeType, MutexLock, PCancelable, PDefer, PQueue, PTimeOut, SortDirection, alphaHex, botFullPattern, botPatterns, botRegPattern, cacheStringFunction, callOrReturn, camel2SnakeObject, camel2snake, camelize, cancelIdleCallback, capitalizeFirst, checkBoundaryPrecision, chunk, clamp, clearDelay, convertHrTime, createCachedImport, createDelay, createIsBot, createIsBotFromList, createOperationPrecision, cutString, delay, deleteProps, digitLengthPrecision, dividePrecision, downloadByData, emailRegex, emitter, enableBoundaryCheckingPrecision, envShims, escapeRegExp, escapedSpaceCharactersRegex, findDuplicates, findLastIndex, firstUniqueArr, firstUniqueChar, float2FixedPrecision, formatBytes, formatLot10Volume, formatNumber, fromStringToPrimitives, generateSample, getMimeTypeFromExtension, getQuarter, getRandomInt, getRandomIntInclusive, getRandomString, getStrokeRadius, globProcess, groupBy, hexColor, hyphenate, intToBuffer, intToHex, invariant, isAndroid, isArray, isBase64, isBoolean, isBot, isBotMatch, isBotMatches, isBotNaive, isBotPattern, isBotPatterns, isBrowser, isCrawler, isDate, isDefined, isEmpties, isEmpty, isEmptyArr, isFunction, isHex, isIOS, isKeyOf, isLinux, isMacOS, isMobile, isNodeProd, isNodeTest, isNotEmpties, isNotEmpty, isNotNull, isNotNullish, isNumber, isObject, isPngImage, isPrimitive, isPromise, isRegExp, isSameDay, isSameMonth, isServer, isSet, isStream, isString, isSymbol, isToday, isUndefined, isValidEmail, isValidUrl, isValidVnPhone, isWindows, lerp, listenCookieChange, mapObject, mergeDeep, mimeTable, minMax, minusPrecision, multilineCommentsRegex, nextEvent, nextFrame, nextIdle, noop, normalize, objectEntries, objectKeys, parseCookie, percentToHex, pick, plusPrecision, rangeDelay, remove, removeEmptyObj, removeUndefObj, requestIdleCallback, roundPrecision, serializeCookie, shuffle, singlelineCommentsRegex, singleton, sleep, slugify, snake2camel, sortByDate, sortData, stripPrecision, suffixAmPm, sum, take, timeSpan, timesPrecision, toBoolean, toPointsArray, transitionEnd, unique, uniqueObj, urlRegex, vietnamPhoneRegex };