@koine/utils 2.0.0-beta.13 → 2.0.0-beta.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Defer.d.ts +0 -14
- package/Defer.js +11 -0
- package/Emitter.d.ts +0 -20
- package/Emitter.js +20 -0
- package/accentSets.d.ts +0 -14
- package/accentSets.js +30 -0
- package/addOrReplaceAtIdx.d.ts +0 -7
- package/addOrReplaceAtIdx.js +16 -0
- package/areEqual.d.ts +0 -15
- package/areEqual.js +55 -0
- package/arrayOfAll.d.ts +0 -25
- package/arrayOfAll.js +6 -0
- package/arraySum.d.ts +0 -6
- package/arraySum.js +4 -0
- package/arrayToLookup.d.ts +0 -5
- package/arrayToLookup.js +8 -0
- package/buildUrlQueryString.d.ts +1 -10
- package/buildUrlQueryString.js +21 -0
- package/capitalize.d.ts +0 -7
- package/capitalize.js +6 -0
- package/changeUrlPath.d.ts +0 -8
- package/changeUrlPath.js +10 -0
- package/chunkByChunks.d.ts +0 -5
- package/chunkByChunks.js +32 -0
- package/chunkBySize.d.ts +0 -4
- package/chunkBySize.js +8 -0
- package/cjs/Defer.d.ts +6 -0
- package/cjs/Defer.js +15 -0
- package/cjs/Emitter.d.ts +7 -0
- package/cjs/Emitter.js +24 -0
- package/cjs/accentSets.d.ts +3 -0
- package/cjs/accentSets.js +33 -0
- package/cjs/addOrReplaceAtIdx.d.ts +2 -0
- package/cjs/addOrReplaceAtIdx.js +20 -0
- package/cjs/areEqual.d.ts +4 -0
- package/cjs/areEqual.js +59 -0
- package/cjs/arrayOfAll.d.ts +2 -0
- package/cjs/arrayOfAll.js +10 -0
- package/cjs/arraySum.d.ts +2 -0
- package/cjs/arraySum.js +8 -0
- package/cjs/arrayToLookup.d.ts +2 -0
- package/cjs/arrayToLookup.js +12 -0
- package/cjs/buildUrlQueryString.d.ts +3 -0
- package/cjs/buildUrlQueryString.js +25 -0
- package/cjs/capitalize.d.ts +2 -0
- package/cjs/capitalize.js +10 -0
- package/cjs/changeUrlPath.d.ts +2 -0
- package/cjs/changeUrlPath.js +14 -0
- package/cjs/chunkByChunks.d.ts +2 -0
- package/cjs/chunkByChunks.js +36 -0
- package/cjs/chunkBySize.d.ts +2 -0
- package/cjs/chunkBySize.js +12 -0
- package/cjs/clamp.d.ts +2 -0
- package/cjs/clamp.js +8 -0
- package/cjs/clsx.d.ts +6 -0
- package/cjs/clsx.js +44 -0
- package/cjs/convertRange.d.ts +2 -0
- package/cjs/convertRange.js +8 -0
- package/cjs/cookie.d.ts +18 -0
- package/cjs/cookie.js +4 -0
- package/cjs/createPalette.d.ts +10 -0
- package/cjs/createPalette.js +16 -0
- package/cjs/debounce.d.ts +2 -0
- package/cjs/debounce.js +26 -0
- package/cjs/debouncePromise.d.ts +11 -0
- package/cjs/debouncePromise.js +69 -0
- package/cjs/debounceRaf.d.ts +2 -0
- package/cjs/debounceRaf.js +21 -0
- package/cjs/decode.d.ts +2 -0
- package/cjs/decode.js +10 -0
- package/cjs/encode.d.ts +2 -0
- package/cjs/encode.js +10 -0
- package/cjs/ensureInt.d.ts +2 -0
- package/cjs/ensureInt.js +8 -0
- package/cjs/env.d.ts +0 -0
- package/cjs/env.js +1 -0
- package/cjs/errorToString.d.ts +2 -0
- package/cjs/errorToString.js +9 -0
- package/cjs/findDuplicatedIndexes.d.ts +2 -0
- package/cjs/findDuplicatedIndexes.js +15 -0
- package/cjs/forin.d.ts +2 -0
- package/cjs/forin.js +10 -0
- package/cjs/gbToBytes.d.ts +2 -0
- package/cjs/gbToBytes.js +6 -0
- package/cjs/getEmptyArray.d.ts +2 -0
- package/cjs/getEmptyArray.js +12 -0
- package/cjs/getKeys.d.ts +2 -0
- package/cjs/getKeys.js +5 -0
- package/cjs/getMediaQueryWidthResolvers.d.ts +10 -0
- package/cjs/getMediaQueryWidthResolvers.js +44 -0
- package/cjs/getMediaQueryWidthTailwindScreens.d.ts +5 -0
- package/cjs/getMediaQueryWidthTailwindScreens.js +31 -0
- package/cjs/getNonce.d.ts +2 -0
- package/cjs/getNonce.js +9 -0
- package/cjs/getParamAmong.d.ts +2 -0
- package/cjs/getParamAmong.js +11 -0
- package/cjs/getParamAsInt.d.ts +2 -0
- package/cjs/getParamAsInt.js +14 -0
- package/cjs/getParamAsString.d.ts +2 -0
- package/cjs/getParamAsString.js +9 -0
- package/cjs/getType.d.ts +7 -0
- package/cjs/getType.js +8 -0
- package/cjs/getUrlHashParams.d.ts +3 -0
- package/cjs/getUrlHashParams.js +14 -0
- package/cjs/getUrlHashPathname.d.ts +2 -0
- package/cjs/getUrlHashPathname.js +10 -0
- package/cjs/getUrlPathnameParts.d.ts +2 -0
- package/cjs/getUrlPathnameParts.js +14 -0
- package/cjs/getUrlQueryParams.d.ts +3 -0
- package/cjs/getUrlQueryParams.js +29 -0
- package/cjs/imgEmptyPixel.d.ts +2 -0
- package/cjs/imgEmptyPixel.js +5 -0
- package/{index.mjs → cjs/index.d.ts} +9 -7
- package/cjs/index.js +265 -0
- package/cjs/invariant.d.ts +2 -0
- package/cjs/invariant.js +21 -0
- package/cjs/isAnyObject.d.ts +3 -0
- package/cjs/isAnyObject.js +9 -0
- package/cjs/isArray.d.ts +2 -0
- package/cjs/isArray.js +9 -0
- package/cjs/isBlob.d.ts +2 -0
- package/cjs/isBlob.js +9 -0
- package/cjs/isBoolean.d.ts +2 -0
- package/cjs/isBoolean.js +9 -0
- package/cjs/isBrowser.d.ts +2 -0
- package/cjs/isBrowser.js +5 -0
- package/cjs/isBrowserNow.d.ts +2 -0
- package/cjs/isBrowserNow.js +7 -0
- package/cjs/isDate.d.ts +2 -0
- package/cjs/isDate.js +9 -0
- package/cjs/isEmptyArray.d.ts +2 -0
- package/cjs/isEmptyArray.js +9 -0
- package/cjs/isEmptyObject.d.ts +4 -0
- package/cjs/isEmptyObject.js +9 -0
- package/cjs/isEmptyString.d.ts +2 -0
- package/cjs/isEmptyString.js +8 -0
- package/cjs/isError.d.ts +2 -0
- package/cjs/isError.js +9 -0
- package/cjs/isExternalUrl.d.ts +2 -0
- package/cjs/isExternalUrl.js +16 -0
- package/cjs/isFile.d.ts +2 -0
- package/cjs/isFile.js +9 -0
- package/cjs/isFloat.d.ts +2 -0
- package/cjs/isFloat.js +9 -0
- package/cjs/isFormData.d.ts +2 -0
- package/cjs/isFormData.js +9 -0
- package/cjs/isFullArray.d.ts +2 -0
- package/cjs/isFullArray.js +9 -0
- package/cjs/isFullObject.d.ts +3 -0
- package/cjs/isFullObject.js +9 -0
- package/cjs/isFullString.d.ts +2 -0
- package/cjs/isFullString.js +9 -0
- package/cjs/isFunction.d.ts +3 -0
- package/cjs/isFunction.js +8 -0
- package/cjs/isInt.d.ts +2 -0
- package/cjs/isInt.js +9 -0
- package/cjs/isMap.d.ts +2 -0
- package/cjs/isMap.js +9 -0
- package/cjs/isNaNValue.d.ts +2 -0
- package/cjs/isNaNValue.js +9 -0
- package/cjs/isNegativeNumber.d.ts +2 -0
- package/cjs/isNegativeNumber.js +9 -0
- package/cjs/isNull.d.ts +2 -0
- package/cjs/isNull.js +9 -0
- package/cjs/isNullOrUndefined.d.ts +2 -0
- package/cjs/isNullOrUndefined.js +8 -0
- package/cjs/isNumber.d.ts +2 -0
- package/cjs/isNumber.js +9 -0
- package/cjs/isObject.d.ts +3 -0
- package/cjs/isObject.js +9 -0
- package/cjs/isObjectLike.d.ts +3 -0
- package/cjs/isObjectLike.js +9 -0
- package/cjs/isOneOf.d.ts +6 -0
- package/cjs/isOneOf.js +14 -0
- package/cjs/isPlainObject.d.ts +3 -0
- package/cjs/isPlainObject.js +12 -0
- package/cjs/isPositiveNumber.d.ts +2 -0
- package/cjs/isPositiveNumber.js +9 -0
- package/cjs/isPrimitive.d.ts +2 -0
- package/cjs/isPrimitive.js +19 -0
- package/cjs/isPromise.d.ts +2 -0
- package/cjs/isPromise.js +9 -0
- package/cjs/isRegExp.d.ts +2 -0
- package/cjs/isRegExp.js +9 -0
- package/cjs/isServer.d.ts +2 -0
- package/cjs/isServer.js +6 -0
- package/cjs/isServerNow.d.ts +2 -0
- package/cjs/isServerNow.js +7 -0
- package/cjs/isSet.d.ts +2 -0
- package/cjs/isSet.js +9 -0
- package/cjs/isString.d.ts +2 -0
- package/cjs/isString.js +9 -0
- package/cjs/isSymbol.d.ts +2 -0
- package/cjs/isSymbol.js +9 -0
- package/cjs/isType.d.ts +3 -0
- package/cjs/isType.js +17 -0
- package/cjs/isUndefined.d.ts +2 -0
- package/cjs/isUndefined.js +9 -0
- package/cjs/isWeakMap.d.ts +2 -0
- package/cjs/isWeakMap.js +9 -0
- package/cjs/isWeakSet.d.ts +2 -0
- package/cjs/isWeakSet.js +9 -0
- package/cjs/kbToBytes.d.ts +2 -0
- package/cjs/kbToBytes.js +6 -0
- package/cjs/location.d.ts +1 -0
- package/cjs/location.js +2 -0
- package/cjs/lowercase.d.ts +2 -0
- package/cjs/lowercase.js +8 -0
- package/cjs/mapListBy.d.ts +2 -0
- package/cjs/mapListBy.js +13 -0
- package/cjs/matchSorter.d.ts +54 -0
- package/cjs/matchSorter.js +259 -0
- package/cjs/mbToBytes.d.ts +2 -0
- package/cjs/mbToBytes.js +6 -0
- package/cjs/mergeObjects.d.ts +1 -0
- package/cjs/mergeObjects.js +37 -0
- package/cjs/mergeUrlQueryParams.d.ts +3 -0
- package/cjs/mergeUrlQueryParams.js +20 -0
- package/cjs/moveSortableArrayItemByKey.d.ts +2 -0
- package/cjs/moveSortableArrayItemByKey.js +14 -0
- package/cjs/noop.d.ts +2 -0
- package/cjs/noop.js +6 -0
- package/cjs/normaliseUrl.d.ts +2 -0
- package/cjs/normaliseUrl.js +10 -0
- package/cjs/normaliseUrlPathname.d.ts +2 -0
- package/cjs/normaliseUrlPathname.js +10 -0
- package/cjs/objectOmit.d.ts +2 -0
- package/cjs/objectOmit.js +14 -0
- package/cjs/objectPick.d.ts +2 -0
- package/cjs/objectPick.js +13 -0
- package/cjs/package.json +6 -0
- package/cjs/parseCookie.d.ts +3 -0
- package/cjs/parseCookie.js +38 -0
- package/cjs/parseURL.d.ts +11 -0
- package/cjs/parseURL.js +18 -0
- package/cjs/quaranteneProps.d.ts +7 -0
- package/cjs/quaranteneProps.js +20 -0
- package/cjs/randomInt.d.ts +2 -0
- package/cjs/randomInt.js +8 -0
- package/cjs/randomKey.d.ts +2 -0
- package/cjs/randomKey.js +9 -0
- package/cjs/readCookie.d.ts +3 -0
- package/cjs/readCookie.js +38 -0
- package/cjs/removeAccents.d.ts +3 -0
- package/cjs/removeAccents.js +16 -0
- package/cjs/removeCookie.d.ts +3 -0
- package/cjs/removeCookie.js +12 -0
- package/cjs/removeDuplicates.d.ts +0 -0
- package/cjs/removeDuplicates.js +1 -0
- package/cjs/removeDuplicatesByKey.d.ts +2 -0
- package/cjs/removeDuplicatesByKey.js +18 -0
- package/cjs/removeDuplicatesComparing.d.ts +2 -0
- package/cjs/removeDuplicatesComparing.js +11 -0
- package/cjs/removeIndexesFromArray.d.ts +2 -0
- package/cjs/removeIndexesFromArray.js +14 -0
- package/cjs/removeTrailingSlash.d.ts +2 -0
- package/cjs/removeTrailingSlash.js +9 -0
- package/cjs/removeUrlQueryParams.d.ts +2 -0
- package/cjs/removeUrlQueryParams.js +19 -0
- package/cjs/render.d.ts +13 -0
- package/cjs/render.js +123 -0
- package/cjs/roundTo.d.ts +2 -0
- package/cjs/roundTo.js +16 -0
- package/cjs/serializeCookie.d.ts +3 -0
- package/cjs/serializeCookie.js +74 -0
- package/cjs/setCookie.d.ts +3 -0
- package/cjs/setCookie.js +47 -0
- package/cjs/shuffle.d.ts +2 -0
- package/cjs/shuffle.js +22 -0
- package/cjs/slugify.d.ts +2 -0
- package/cjs/slugify.js +18 -0
- package/cjs/split.d.ts +3 -0
- package/cjs/split.js +8 -0
- package/cjs/swapMap.d.ts +2 -0
- package/cjs/swapMap.js +13 -0
- package/cjs/throttle.d.ts +2 -0
- package/cjs/throttle.js +24 -0
- package/cjs/titleCase.d.ts +2 -0
- package/cjs/titleCase.js +10 -0
- package/cjs/toNumber.d.ts +2 -0
- package/cjs/toNumber.js +9 -0
- package/cjs/toRgba.d.ts +2 -0
- package/cjs/toRgba.js +13 -0
- package/cjs/transformToUrlPathname.d.ts +2 -0
- package/cjs/transformToUrlPathname.js +11 -0
- package/cjs/truncate.d.ts +2 -0
- package/cjs/truncate.js +12 -0
- package/cjs/tryUntil.d.ts +2 -0
- package/cjs/tryUntil.js +19 -0
- package/cjs/types.d.ts +10 -0
- package/cjs/types.js +2 -0
- package/cjs/uid.d.ts +2 -0
- package/cjs/uid.js +11 -0
- package/cjs/updateLinkParams.d.ts +3 -0
- package/cjs/updateLinkParams.js +11 -0
- package/cjs/updateUrlQueryParams.d.ts +3 -0
- package/cjs/updateUrlQueryParams.js +16 -0
- package/cjs/uppercase.d.ts +2 -0
- package/cjs/uppercase.js +8 -0
- package/cjs/uuid.d.ts +2 -0
- package/cjs/uuid.js +11 -0
- package/cjs/uuidNumeric.d.ts +2 -0
- package/cjs/uuidNumeric.js +6 -0
- package/cjs/wait.d.ts +2 -0
- package/cjs/wait.js +8 -0
- package/cjs/without.d.ts +0 -0
- package/cjs/without.js +1 -0
- package/clamp.d.ts +0 -6
- package/clamp.js +4 -0
- package/clsx.d.ts +0 -7
- package/clsx.js +40 -0
- package/convertRange.d.ts +0 -14
- package/convertRange.js +4 -0
- package/cookie.d.ts +0 -48
- package/cookie.js +1 -0
- package/createPalette.d.ts +0 -12
- package/createPalette.js +12 -0
- package/debounce.d.ts +0 -6
- package/debounce.js +22 -0
- package/debouncePromise.d.ts +0 -18
- package/debouncePromise.js +65 -0
- package/debounceRaf.d.ts +0 -7
- package/debounceRaf.js +17 -0
- package/decode.d.ts +0 -4
- package/decode.js +6 -0
- package/encode.d.ts +0 -4
- package/encode.js +6 -0
- package/ensureInt.d.ts +0 -5
- package/ensureInt.js +4 -0
- package/env.js +1 -0
- package/errorToString.d.ts +0 -6
- package/errorToString.js +5 -0
- package/findDuplicatedIndexes.d.ts +0 -3
- package/findDuplicatedIndexes.js +11 -0
- package/forin.d.ts +0 -6
- package/forin.js +6 -0
- package/gbToBytes.d.ts +0 -5
- package/gbToBytes.js +2 -0
- package/getEmptyArray.d.ts +0 -6
- package/getEmptyArray.js +8 -0
- package/getKeys.d.ts +0 -8
- package/getKeys.js +2 -0
- package/getMediaQueryWidthResolvers.d.ts +0 -6
- package/getMediaQueryWidthResolvers.js +40 -0
- package/getMediaQueryWidthTailwindScreens.d.ts +1 -5
- package/getMediaQueryWidthTailwindScreens.js +27 -0
- package/getNonce.d.ts +0 -4
- package/getNonce.js +5 -0
- package/getParamAmong.d.ts +0 -11
- package/getParamAmong.js +7 -0
- package/getParamAsInt.d.ts +0 -10
- package/getParamAsInt.js +10 -0
- package/getParamAsString.d.ts +0 -9
- package/getParamAsString.js +5 -0
- package/getType.d.ts +0 -12
- package/getType.js +4 -0
- package/getUrlHashParams.d.ts +1 -7
- package/getUrlHashParams.js +10 -0
- package/getUrlHashPathname.d.ts +0 -7
- package/getUrlHashPathname.js +6 -0
- package/getUrlPathnameParts.d.ts +0 -10
- package/getUrlPathnameParts.js +10 -0
- package/getUrlQueryParams.d.ts +1 -11
- package/getUrlQueryParams.js +25 -0
- package/imgEmptyPixel.d.ts +0 -5
- package/imgEmptyPixel.js +2 -0
- package/index.d.ts +133 -136
- package/index.js +130 -0
- package/invariant.d.ts +0 -17
- package/invariant.js +17 -0
- package/isAnyObject.d.ts +1 -6
- package/isAnyObject.js +5 -0
- package/isArray.d.ts +0 -5
- package/isArray.js +5 -0
- package/isBlob.d.ts +0 -5
- package/isBlob.js +5 -0
- package/isBoolean.d.ts +0 -5
- package/isBoolean.js +5 -0
- package/isBrowser.d.ts +0 -4
- package/isBrowser.js +2 -0
- package/isBrowserNow.d.ts +0 -4
- package/isBrowserNow.js +3 -0
- package/isDate.d.ts +0 -5
- package/isDate.js +5 -0
- package/isEmptyArray.d.ts +0 -5
- package/isEmptyArray.js +5 -0
- package/isEmptyObject.d.ts +0 -5
- package/isEmptyObject.js +5 -0
- package/isEmptyString.d.ts +0 -5
- package/isEmptyString.js +4 -0
- package/isError.d.ts +0 -5
- package/isError.js +5 -0
- package/isExternalUrl.d.ts +0 -7
- package/isExternalUrl.js +12 -0
- package/isFile.d.ts +0 -5
- package/isFile.js +5 -0
- package/isFloat.d.ts +0 -5
- package/isFloat.js +5 -0
- package/isFormData.d.ts +0 -5
- package/isFormData.js +5 -0
- package/isFullArray.d.ts +0 -5
- package/isFullArray.js +5 -0
- package/isFullObject.d.ts +1 -6
- package/isFullObject.js +5 -0
- package/isFullString.d.ts +0 -5
- package/isFullString.js +5 -0
- package/isFunction.d.ts +1 -6
- package/isFunction.js +4 -0
- package/isInt.d.ts +0 -5
- package/isInt.js +5 -0
- package/isMap.d.ts +0 -5
- package/isMap.js +5 -0
- package/isNaNValue.d.ts +0 -5
- package/isNaNValue.js +5 -0
- package/isNegativeNumber.d.ts +0 -5
- package/isNegativeNumber.js +5 -0
- package/isNull.d.ts +0 -5
- package/isNull.js +5 -0
- package/isNullOrUndefined.d.ts +0 -5
- package/isNullOrUndefined.js +5 -0
- package/isNumber.d.ts +0 -7
- package/isNumber.js +5 -0
- package/isObject.d.ts +1 -6
- package/isObject.js +5 -0
- package/isObjectLike.d.ts +1 -8
- package/isObjectLike.js +5 -0
- package/isOneOf.d.ts +1 -4
- package/isOneOf.js +10 -0
- package/isPlainObject.d.ts +1 -6
- package/isPlainObject.js +8 -0
- package/isPositiveNumber.d.ts +0 -5
- package/isPositiveNumber.js +5 -0
- package/isPrimitive.d.ts +0 -5
- package/isPrimitive.js +15 -0
- package/isPromise.d.ts +0 -5
- package/isPromise.js +5 -0
- package/isRegExp.d.ts +0 -5
- package/isRegExp.js +5 -0
- package/isServer.d.ts +0 -4
- package/isServer.js +3 -0
- package/isServerNow.d.ts +0 -4
- package/isServerNow.js +3 -0
- package/isSet.d.ts +0 -5
- package/isSet.js +5 -0
- package/isString.d.ts +0 -5
- package/isString.js +5 -0
- package/isSymbol.d.ts +0 -5
- package/isSymbol.js +5 -0
- package/isType.d.ts +1 -9
- package/isType.js +13 -0
- package/isUndefined.d.ts +0 -5
- package/isUndefined.js +5 -0
- package/isWeakMap.d.ts +0 -5
- package/isWeakMap.js +5 -0
- package/isWeakSet.d.ts +0 -5
- package/isWeakSet.js +5 -0
- package/kbToBytes.d.ts +0 -5
- package/kbToBytes.js +2 -0
- package/location.d.ts +0 -3
- package/location.js +1 -0
- package/lowercase.d.ts +0 -5
- package/lowercase.js +4 -0
- package/mapListBy.d.ts +0 -5
- package/mapListBy.js +9 -0
- package/matchSorter.d.ts +0 -7
- package/matchSorter.js +255 -0
- package/mbToBytes.d.ts +0 -5
- package/mbToBytes.js +2 -0
- package/mergeObjects.d.ts +0 -6
- package/mergeObjects.js +33 -0
- package/mergeUrlQueryParams.d.ts +1 -6
- package/mergeUrlQueryParams.js +16 -0
- package/moveSortableArrayItemByKey.d.ts +0 -7
- package/moveSortableArrayItemByKey.js +10 -0
- package/noop.d.ts +0 -5
- package/noop.js +2 -0
- package/normaliseUrl.d.ts +0 -9
- package/normaliseUrl.js +6 -0
- package/normaliseUrlPathname.d.ts +0 -8
- package/normaliseUrlPathname.js +6 -0
- package/objectOmit.d.ts +0 -9
- package/objectOmit.js +10 -0
- package/objectPick.d.ts +0 -6
- package/objectPick.js +9 -0
- package/package.json +568 -6
- package/parseCookie.d.ts +1 -9
- package/parseCookie.js +34 -0
- package/parseURL.d.ts +0 -6
- package/parseURL.js +14 -0
- package/quaranteneProps.d.ts +0 -15
- package/quaranteneProps.js +16 -0
- package/randomInt.d.ts +0 -5
- package/randomInt.js +4 -0
- package/randomKey.d.ts +0 -6
- package/randomKey.js +5 -0
- package/readCookie.d.ts +0 -5
- package/{readCookie.mjs → readCookie.js} +8 -7
- package/removeAccents.d.ts +1 -4
- package/removeAccents.js +12 -0
- package/removeCookie.d.ts +1 -4
- package/removeCookie.js +8 -0
- package/removeDuplicates.js +1 -0
- package/removeDuplicatesByKey.d.ts +0 -6
- package/removeDuplicatesByKey.js +14 -0
- package/removeDuplicatesComparing.d.ts +0 -3
- package/removeDuplicatesComparing.js +7 -0
- package/removeIndexesFromArray.d.ts +0 -3
- package/removeIndexesFromArray.js +10 -0
- package/removeTrailingSlash.d.ts +0 -5
- package/removeTrailingSlash.js +5 -0
- package/removeUrlQueryParams.d.ts +0 -5
- package/removeUrlQueryParams.js +15 -0
- package/render.d.ts +0 -40
- package/render.js +119 -0
- package/roundTo.d.ts +0 -6
- package/roundTo.js +12 -0
- package/serializeCookie.d.ts +1 -21
- package/{serializeCookie.mjs → serializeCookie.js} +9 -33
- package/setCookie.d.ts +1 -4
- package/setCookie.js +43 -0
- package/shuffle.d.ts +0 -15
- package/shuffle.js +18 -0
- package/slugify.d.ts +0 -10
- package/slugify.js +14 -0
- package/split.d.ts +0 -4
- package/split.js +4 -0
- package/swapMap.d.ts +0 -5
- package/swapMap.js +9 -0
- package/throttle.d.ts +0 -7
- package/throttle.js +20 -0
- package/titleCase.d.ts +0 -6
- package/titleCase.js +6 -0
- package/toNumber.d.ts +0 -3
- package/toNumber.js +5 -0
- package/toRgba.d.ts +0 -3
- package/toRgba.js +9 -0
- package/transformToUrlPathname.d.ts +0 -9
- package/transformToUrlPathname.js +7 -0
- package/truncate.d.ts +0 -5
- package/truncate.js +8 -0
- package/tryUntil.d.ts +0 -9
- package/tryUntil.js +15 -0
- package/types.d.ts +0 -18
- package/types.js +1 -0
- package/uid.d.ts +0 -5
- package/uid.js +7 -0
- package/updateLinkParams.d.ts +1 -8
- package/updateLinkParams.js +7 -0
- package/updateUrlQueryParams.d.ts +1 -6
- package/updateUrlQueryParams.js +12 -0
- package/uppercase.d.ts +0 -6
- package/uppercase.js +4 -0
- package/uuid.d.ts +0 -6
- package/uuid.js +7 -0
- package/uuidNumeric.d.ts +0 -4
- package/uuidNumeric.js +2 -0
- package/wait.d.ts +0 -5
- package/wait.js +4 -0
- package/without.js +1 -0
- package/Defer.mjs +0 -27
- package/Emitter.mjs +0 -37
- package/README.md +0 -47
- package/accentSets.mjs +0 -123
- package/addOrReplaceAtIdx.mjs +0 -26
- package/areEqual.mjs +0 -71
- package/arrayOfAll.mjs +0 -26
- package/arraySum.mjs +0 -7
- package/arrayToLookup.mjs +0 -11
- package/buildUrlQueryString.mjs +0 -28
- package/capitalize.mjs +0 -11
- package/changeUrlPath.mjs +0 -17
- package/chunkByChunks.mjs +0 -34
- package/chunkBySize.mjs +0 -11
- package/clamp.mjs +0 -9
- package/clsx.mjs +0 -48
- package/convertRange.mjs +0 -17
- package/cookie.mjs +0 -15
- package/createPalette.mjs +0 -32
- package/debounce.mjs +0 -21
- package/debouncePromise.mjs +0 -79
- package/debounceRaf.mjs +0 -22
- package/decode.mjs +0 -9
- package/encode.mjs +0 -9
- package/ensureInt.mjs +0 -6
- package/env.mjs +0 -2
- package/errorToString.mjs +0 -8
- package/findDuplicatedIndexes.mjs +0 -13
- package/forin.mjs +0 -11
- package/gbToBytes.mjs +0 -6
- package/getEmptyArray.mjs +0 -15
- package/getKeys.mjs +0 -9
- package/getMediaQueryWidthResolvers.mjs +0 -67
- package/getMediaQueryWidthTailwindScreens.mjs +0 -36
- package/getNonce.mjs +0 -8
- package/getParamAmong.mjs +0 -16
- package/getParamAsInt.mjs +0 -18
- package/getParamAsString.mjs +0 -13
- package/getType.mjs +0 -14
- package/getUrlHashParams.mjs +0 -14
- package/getUrlHashPathname.mjs +0 -11
- package/getUrlPathnameParts.mjs +0 -15
- package/getUrlQueryParams.mjs +0 -26
- package/imgEmptyPixel.mjs +0 -6
- package/invariant.mjs +0 -32
- package/isAnyObject.mjs +0 -9
- package/isArray.mjs +0 -9
- package/isBlob.mjs +0 -9
- package/isBoolean.mjs +0 -9
- package/isBrowser.mjs +0 -5
- package/isBrowserNow.mjs +0 -6
- package/isDate.mjs +0 -9
- package/isEmptyArray.mjs +0 -9
- package/isEmptyObject.mjs +0 -9
- package/isEmptyString.mjs +0 -8
- package/isError.mjs +0 -9
- package/isExternalUrl.mjs +0 -19
- package/isFile.mjs +0 -9
- package/isFloat.mjs +0 -9
- package/isFormData.mjs +0 -9
- package/isFullArray.mjs +0 -9
- package/isFullObject.mjs +0 -9
- package/isFullString.mjs +0 -9
- package/isFunction.mjs +0 -8
- package/isInt.mjs +0 -9
- package/isMap.mjs +0 -9
- package/isNaNValue.mjs +0 -9
- package/isNegativeNumber.mjs +0 -9
- package/isNull.mjs +0 -9
- package/isNullOrUndefined.mjs +0 -9
- package/isNumber.mjs +0 -11
- package/isObject.mjs +0 -9
- package/isObjectLike.mjs +0 -11
- package/isOneOf.mjs +0 -4
- package/isPlainObject.mjs +0 -10
- package/isPositiveNumber.mjs +0 -9
- package/isPrimitive.mjs +0 -14
- package/isPromise.mjs +0 -9
- package/isRegExp.mjs +0 -9
- package/isServer.mjs +0 -7
- package/isServerNow.mjs +0 -6
- package/isSet.mjs +0 -9
- package/isString.mjs +0 -9
- package/isSymbol.mjs +0 -9
- package/isType.mjs +0 -20
- package/isUndefined.mjs +0 -9
- package/isWeakMap.mjs +0 -9
- package/isWeakSet.mjs +0 -9
- package/kbToBytes.mjs +0 -6
- package/location.mjs +0 -3
- package/lowercase.mjs +0 -6
- package/mapListBy.mjs +0 -11
- package/matchSorter.mjs +0 -352
- package/mbToBytes.mjs +0 -6
- package/mergeObjects.mjs +0 -34
- package/mergeUrlQueryParams.mjs +0 -17
- package/moveSortableArrayItemByKey.mjs +0 -17
- package/noop.mjs +0 -6
- package/normaliseUrl.mjs +0 -13
- package/normaliseUrlPathname.mjs +0 -12
- package/objectOmit.mjs +0 -17
- package/objectPick.mjs +0 -14
- package/parseCookie.mjs +0 -44
- package/parseURL.mjs +0 -19
- package/quaranteneProps.mjs +0 -31
- package/randomInt.mjs +0 -8
- package/randomKey.mjs +0 -10
- package/removeAccents.mjs +0 -12
- package/removeCookie.mjs +0 -12
- package/removeDuplicates.mjs +0 -12
- package/removeDuplicatesByKey.mjs +0 -18
- package/removeDuplicatesComparing.mjs +0 -9
- package/removeIndexesFromArray.mjs +0 -13
- package/removeTrailingSlash.mjs +0 -8
- package/removeUrlQueryParams.mjs +0 -18
- package/render.mjs +0 -111
- package/roundTo.mjs +0 -32
- package/setCookie.mjs +0 -51
- package/shuffle.mjs +0 -33
- package/slugify.mjs +0 -26
- package/split.mjs +0 -7
- package/swapMap.mjs +0 -12
- package/throttle.mjs +0 -20
- package/titleCase.mjs +0 -7
- package/toNumber.mjs +0 -7
- package/toRgba.mjs +0 -14
- package/transformToUrlPathname.mjs +0 -13
- package/truncate.mjs +0 -6
- package/tryUntil.mjs +0 -27
- package/types.mjs +0 -2
- package/uid.mjs +0 -10
- package/updateLinkParams.mjs +0 -13
- package/updateUrlQueryParams.mjs +0 -13
- package/uppercase.mjs +0 -7
- package/uuid.mjs +0 -10
- package/uuidNumeric.mjs +0 -5
- package/wait.mjs +0 -6
- package/without.mjs +0 -54
package/randomInt.d.ts
CHANGED
package/randomInt.js
ADDED
package/randomKey.d.ts
CHANGED
package/randomKey.js
ADDED
package/readCookie.d.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Read cookie
|
|
3
|
-
*
|
|
4
|
-
* @category cookie
|
|
5
|
-
*/
|
|
6
1
|
export declare function readCookie<T extends Record<string, unknown> = Record<string, string>>(name?: null): T;
|
|
7
2
|
export declare function readCookie<T extends Record<string, unknown> = Record<string, string>, N extends keyof T = keyof T>(name: N): T[N];
|
|
8
3
|
export default readCookie;
|
|
@@ -11,18 +11,19 @@ export function readCookie(name) {
|
|
|
11
11
|
}
|
|
12
12
|
return name ? "" : {};
|
|
13
13
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
for(
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
var cookies = document.cookie ? document.cookie.split("; ") : [];
|
|
15
|
+
var all = {};
|
|
16
|
+
for (var i = 0; i < cookies.length; i++) {
|
|
17
|
+
var parts = cookies[i].split("=");
|
|
18
|
+
var value = parts.slice(1).join("=");
|
|
19
19
|
try {
|
|
20
|
-
|
|
20
|
+
var found = decodeURIComponent(parts[0]);
|
|
21
21
|
all[found] = converterRead(value);
|
|
22
22
|
if (name === found) {
|
|
23
23
|
break;
|
|
24
24
|
}
|
|
25
|
-
}
|
|
25
|
+
}
|
|
26
|
+
catch (e) {
|
|
26
27
|
if (process.env["NODE_ENV"] !== "production") {
|
|
27
28
|
console.warn("[@koine/utils:readCookie] failed to decode", value);
|
|
28
29
|
}
|
package/removeAccents.d.ts
CHANGED
package/removeAccents.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { accentsSets } from "./accentSets.js";
|
|
2
|
+
export function removeAccents(text, sets) {
|
|
3
|
+
if (text === void 0) { text = ""; }
|
|
4
|
+
if (sets === void 0) { sets = accentsSets; }
|
|
5
|
+
var len = sets.length;
|
|
6
|
+
while (len--) {
|
|
7
|
+
var _a = sets[len], to = _a[0], from = _a[1];
|
|
8
|
+
text = text.replace(new RegExp("[".concat(from, "]"), "gi"), to);
|
|
9
|
+
}
|
|
10
|
+
return text;
|
|
11
|
+
}
|
|
12
|
+
export default removeAccents;
|
package/removeCookie.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { type CookieAttributesClient } from "./cookie";
|
|
2
|
-
/**
|
|
3
|
-
* @category cookie
|
|
4
|
-
*/
|
|
1
|
+
import { type CookieAttributesClient } from "./cookie.js";
|
|
5
2
|
export declare function removeCookie(name: string, attributes?: CookieAttributesClient): void;
|
|
6
3
|
export default removeCookie;
|
package/removeCookie.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
import { defaultAttributesClient } from "./cookie.js";
|
|
3
|
+
import { setCookie } from "./setCookie.js";
|
|
4
|
+
export function removeCookie(name, attributes) {
|
|
5
|
+
if (attributes === void 0) { attributes = {}; }
|
|
6
|
+
setCookie(name, "", __assign(__assign(__assign({}, defaultAttributesClient), attributes), { expires: -1 }));
|
|
7
|
+
}
|
|
8
|
+
export default removeCookie;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Remove duplicated array objects, equality is determined by a strict (`===`)
|
|
3
|
-
* comparison of each object's given key
|
|
4
|
-
*
|
|
5
|
-
* @category array
|
|
6
|
-
*/
|
|
7
1
|
export declare function removeDuplicatesByKey<T extends Record<string | number | symbol, any>>(array: T[] | undefined, key: keyof T): T[];
|
|
8
2
|
export default removeDuplicatesByKey;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function removeDuplicatesByKey(array, key) {
|
|
2
|
+
if (array === void 0) { array = []; }
|
|
3
|
+
var keysMap = {};
|
|
4
|
+
var output = [];
|
|
5
|
+
for (var i = 0; i < array.length; i++) {
|
|
6
|
+
var item = array[i];
|
|
7
|
+
if (!keysMap[item[key]]) {
|
|
8
|
+
output.push(item);
|
|
9
|
+
keysMap[item[key]] = true;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return output;
|
|
13
|
+
}
|
|
14
|
+
export default removeDuplicatesByKey;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { findDuplicatedIndexes } from "./findDuplicatedIndexes.js";
|
|
2
|
+
import { removeIndexesFromArray } from "./removeIndexesFromArray.js";
|
|
3
|
+
export function removeDuplicatesComparing(from, to) {
|
|
4
|
+
var indexes = findDuplicatedIndexes(from);
|
|
5
|
+
return removeIndexesFromArray(to, indexes);
|
|
6
|
+
}
|
|
7
|
+
export default removeDuplicatesComparing;
|
package/removeTrailingSlash.d.ts
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import buildUrlQueryString from "./buildUrlQueryString.js";
|
|
2
|
+
import getUrlQueryParams from "./getUrlQueryParams.js";
|
|
3
|
+
export function removeUrlQueryParams(url, paramsToRemove) {
|
|
4
|
+
if (paramsToRemove === void 0) { paramsToRemove = []; }
|
|
5
|
+
var parts = url.split("?");
|
|
6
|
+
var allParams = getUrlQueryParams(url);
|
|
7
|
+
var params = {};
|
|
8
|
+
for (var key in allParams) {
|
|
9
|
+
if (!paramsToRemove.includes(key)) {
|
|
10
|
+
params[key] = allParams[key];
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return parts[0] + buildUrlQueryString(params);
|
|
14
|
+
}
|
|
15
|
+
export default removeUrlQueryParams;
|
package/render.d.ts
CHANGED
|
@@ -8,46 +8,6 @@ type DefinitionExtended = {
|
|
|
8
8
|
type Definitions = {
|
|
9
9
|
[key: string]: DefinitionExtended;
|
|
10
10
|
} & DefinitionExtended;
|
|
11
|
-
/**
|
|
12
|
-
* Returned render function
|
|
13
|
-
*/
|
|
14
11
|
type RenderFunction = (data: object) => string;
|
|
15
|
-
/**
|
|
16
|
-
* Render template (adapted from doT.js)
|
|
17
|
-
*
|
|
18
|
-
* The data made available to the template is always on the `data` key, e.g.:
|
|
19
|
-
* `renderer({ myVal: "xx" })`
|
|
20
|
-
* ... will be accessible on
|
|
21
|
-
* `<%= data.myVal %>`
|
|
22
|
-
*
|
|
23
|
-
* The default delimiters are customised to work without conflicts with Blade and Twig:
|
|
24
|
-
* ```
|
|
25
|
-
* <% %> for evaluation
|
|
26
|
-
* <%= %> for interpolation
|
|
27
|
-
* <%? %> for conditionals
|
|
28
|
-
* <%~ %> for array iteration
|
|
29
|
-
* <%# %> for compile-time evaluation/includes and partials
|
|
30
|
-
* <%## #%> for compile-time defines
|
|
31
|
-
*
|
|
32
|
-
* Unsupported:
|
|
33
|
-
* <%! %> for interpolation with encoding
|
|
34
|
-
* ```
|
|
35
|
-
*
|
|
36
|
-
* @category impl
|
|
37
|
-
* @example
|
|
38
|
-
*
|
|
39
|
-
* ```ts
|
|
40
|
-
* import { render } from "...";
|
|
41
|
-
*
|
|
42
|
-
* const data = { name: "XYZ" };
|
|
43
|
-
* const tpl = `Hello <%= data.name %>`;
|
|
44
|
-
* const renderer = render(tpl);
|
|
45
|
-
*
|
|
46
|
-
* console.log(renderer(data)); // outputs 'Hello XYZ'
|
|
47
|
-
* ```
|
|
48
|
-
*
|
|
49
|
-
* @borrows [olado/doT by Laura Doktorova](https://github.com/olado/doT)
|
|
50
|
-
* @see https://olado.github.io/doT/index.html
|
|
51
|
-
*/
|
|
52
12
|
export declare const render: (tmpl: string, def?: Definitions) => RenderFunction;
|
|
53
13
|
export default render;
|
package/render.js
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
var varname = "data";
|
|
2
|
+
var evaluate = /<%([\s\S]+?(\}?)+)%>/g;
|
|
3
|
+
var interpolate = /<%=([\s\S]+?)%>/g;
|
|
4
|
+
var conditional = /<%\?(\?)?\s*([\s\S]*?)\s*%>/g;
|
|
5
|
+
var iterate = /<%~\s*(?:%>|([\s\S]+?)\s*:\s*([\w$]+)\s*(?::\s*([\w$]+))?\s*%>)/g;
|
|
6
|
+
var use = /<%#([\s\S]+?)%>/g;
|
|
7
|
+
var useParams = /(^|[^\w$])def(?:\.|\[['"])([\w$.]+)(?:['"]\])?\s*:\s*([\w$.]+|"[^"]+"|'[^']+'|\{[^}]+\})/g;
|
|
8
|
+
var define = /<%##\s*([\w.$]+)\s*(:|=)([\s\S]+?)#%>/g;
|
|
9
|
+
var defineParams = /^\s*([\w$]+):([\s\S]+)/;
|
|
10
|
+
var start = "'+(";
|
|
11
|
+
var end = ")+'";
|
|
12
|
+
var skip = /$^/;
|
|
13
|
+
var resolveDefs = function (block, def) {
|
|
14
|
+
return (typeof block === "string" ? block : block.toString())
|
|
15
|
+
.replace(define || skip, function (_, code, assign, value) {
|
|
16
|
+
if (code.indexOf("def.") === 0) {
|
|
17
|
+
code = code.substring(4);
|
|
18
|
+
}
|
|
19
|
+
if (!(code in def)) {
|
|
20
|
+
if (assign === ":") {
|
|
21
|
+
value.replace(defineParams, function (_, param, v) {
|
|
22
|
+
def[code] = { arg: param, text: v };
|
|
23
|
+
});
|
|
24
|
+
if (!(code in def))
|
|
25
|
+
def[code] = value;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
new Function("def", "def['" + code + "']=" + value)(def);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return "";
|
|
32
|
+
})
|
|
33
|
+
.replace(use || skip, function (_, code) {
|
|
34
|
+
code = code.replace(useParams, function (_, s, d, param) {
|
|
35
|
+
if (def[d] && def[d].arg && param) {
|
|
36
|
+
var rw = (d + ":" + param).replace(/'|\\/g, "_");
|
|
37
|
+
def.__exp = def.__exp || {};
|
|
38
|
+
def.__exp[rw] = def[d].text.replace(new RegExp("(^|[^\\w$])" + def[d].arg + "([^\\w$])", "g"), "$1" + param + "$2");
|
|
39
|
+
return s + "def.__exp['" + rw + "']";
|
|
40
|
+
}
|
|
41
|
+
return s;
|
|
42
|
+
});
|
|
43
|
+
var v = new Function("def", "return " + code)(def);
|
|
44
|
+
return v ? resolveDefs(v, def) : v;
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
var unescape = function (code) {
|
|
48
|
+
return code.replace(/\\('|\\)/g, "$1").replace(/[\r\t\n]/g, " ");
|
|
49
|
+
};
|
|
50
|
+
export var render = function (tmpl, def) {
|
|
51
|
+
var sid = 0;
|
|
52
|
+
var indv;
|
|
53
|
+
var str = use || define ? resolveDefs(tmpl, def || {}) : tmpl;
|
|
54
|
+
str = ("var X='" +
|
|
55
|
+
str
|
|
56
|
+
.replace(/(^|\r|\n)\t* +| +\t*(\r|\n|$)/g, " ")
|
|
57
|
+
.replace(/\r|\n|\t|\/\*[\s\S]*?\*\//g, "")
|
|
58
|
+
.replace(/'|\\/g, "\\$&")
|
|
59
|
+
.replace(interpolate || skip, function (_, code) { return start + unescape(code) + end; })
|
|
60
|
+
.replace(conditional || skip, function (_, elseCase, code) {
|
|
61
|
+
return elseCase
|
|
62
|
+
? code
|
|
63
|
+
? "';}else if(" + unescape(code) + "){X+='"
|
|
64
|
+
: "';}else{X+='"
|
|
65
|
+
: code
|
|
66
|
+
? "';if(" + unescape(code) + "){X+='"
|
|
67
|
+
: "';}X+='";
|
|
68
|
+
})
|
|
69
|
+
.replace(iterate || skip, function (_, arr, vName, iName) {
|
|
70
|
+
if (!arr)
|
|
71
|
+
return "';} } X+='";
|
|
72
|
+
sid++;
|
|
73
|
+
indv = iName || "i" + sid;
|
|
74
|
+
arr = unescape(arr);
|
|
75
|
+
return ("';var arr" +
|
|
76
|
+
sid +
|
|
77
|
+
"=" +
|
|
78
|
+
arr +
|
|
79
|
+
";if(arr" +
|
|
80
|
+
sid +
|
|
81
|
+
"){var " +
|
|
82
|
+
vName +
|
|
83
|
+
"," +
|
|
84
|
+
indv +
|
|
85
|
+
"=-1,l" +
|
|
86
|
+
sid +
|
|
87
|
+
"=arr" +
|
|
88
|
+
sid +
|
|
89
|
+
".length-1;while(" +
|
|
90
|
+
indv +
|
|
91
|
+
"<l" +
|
|
92
|
+
sid +
|
|
93
|
+
"){" +
|
|
94
|
+
vName +
|
|
95
|
+
"=arr" +
|
|
96
|
+
sid +
|
|
97
|
+
"[" +
|
|
98
|
+
indv +
|
|
99
|
+
"+=1];X+='");
|
|
100
|
+
})
|
|
101
|
+
.replace(evaluate || skip, function (_, code) { return "';" + unescape(code) + "X+='"; }) +
|
|
102
|
+
"';return X;")
|
|
103
|
+
.replace(/\n/g, "\\n")
|
|
104
|
+
.replace(/\t/g, "\\t")
|
|
105
|
+
.replace(/\r/g, "\\r")
|
|
106
|
+
.replace(/(\s|;|\}|^|\{)X\+='';/g, "$1")
|
|
107
|
+
.replace(/\+''/g, "");
|
|
108
|
+
try {
|
|
109
|
+
return new Function(varname, str);
|
|
110
|
+
}
|
|
111
|
+
catch (e) {
|
|
112
|
+
if (process.env["NODE_ENV"] !== "production") {
|
|
113
|
+
console.log("Could not create a template function: " + str);
|
|
114
|
+
throw e;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return function () { return ""; };
|
|
118
|
+
};
|
|
119
|
+
export default render;
|
package/roundTo.d.ts
CHANGED
package/roundTo.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function roundTo(num, decimals) {
|
|
2
|
+
if (decimals === void 0) { decimals = 2; }
|
|
3
|
+
if (isFinite(num) && !isNaN(num)) {
|
|
4
|
+
var multiplicator = Math.pow(10, decimals);
|
|
5
|
+
return Math.round(num * multiplicator) / multiplicator + "";
|
|
6
|
+
}
|
|
7
|
+
if (process.env["NODE_ENV"] !== "production") {
|
|
8
|
+
console.warn("[@koine/utils] math:roundTo -> given not a finite number as first arg");
|
|
9
|
+
}
|
|
10
|
+
return "";
|
|
11
|
+
}
|
|
12
|
+
export default roundTo;
|
package/serializeCookie.d.ts
CHANGED
|
@@ -1,23 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
* @module
|
|
3
|
-
*
|
|
4
|
-
* @category cookie
|
|
5
|
-
*
|
|
6
|
-
* All cookie related code is inspired and adapted from:
|
|
7
|
-
* - [js-cookie](https://github.com/js-cookie/js-cookie)
|
|
8
|
-
* - [cookie](https://github.com/jshttp/cookie)
|
|
9
|
-
*/
|
|
10
|
-
import { type CookieAttributesServer } from "./cookie";
|
|
11
|
-
/**
|
|
12
|
-
* Serialize data into a cookie header.
|
|
13
|
-
*
|
|
14
|
-
* Serialize the a name value pair into a cookie string suitable for
|
|
15
|
-
* http headers. An optional attributes object specified cookie parameters.
|
|
16
|
-
*
|
|
17
|
-
* serialize('foo', 'bar', { httpOnly: true })
|
|
18
|
-
* => "foo=bar; httpOnly"
|
|
19
|
-
*
|
|
20
|
-
* @category cookie
|
|
21
|
-
*/
|
|
1
|
+
import { type CookieAttributesServer } from "./cookie.js";
|
|
22
2
|
export declare function serializeCookie(name: string, val: string, attributes?: CookieAttributesServer): string;
|
|
23
3
|
export default serializeCookie;
|
|
@@ -1,34 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* - [cookie](https://github.com/jshttp/cookie)
|
|
9
|
-
*/ import { isNumber } from "./isNumber";
|
|
10
|
-
/**
|
|
11
|
-
* RegExp to match field-content in RFC 7230 sec 3.2
|
|
12
|
-
*
|
|
13
|
-
* field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]
|
|
14
|
-
* field-vchar = VCHAR / obs-text
|
|
15
|
-
* obs-text = %x80-FF
|
|
16
|
-
*/ // eslint-disable-next-line no-control-regex
|
|
17
|
-
const fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
|
|
18
|
-
/**
|
|
19
|
-
* Serialize data into a cookie header.
|
|
20
|
-
*
|
|
21
|
-
* Serialize the a name value pair into a cookie string suitable for
|
|
22
|
-
* http headers. An optional attributes object specified cookie parameters.
|
|
23
|
-
*
|
|
24
|
-
* serialize('foo', 'bar', { httpOnly: true })
|
|
25
|
-
* => "foo=bar; httpOnly"
|
|
26
|
-
*
|
|
27
|
-
* @category cookie
|
|
28
|
-
*/ export function serializeCookie(name, val, attributes = {}) {
|
|
29
|
-
const { encode = encodeURIComponent, domain, path, httpOnly, secure, sameSite } = attributes;
|
|
30
|
-
let { maxAge, expires } = attributes;
|
|
31
|
-
const value = encode(val);
|
|
1
|
+
import { isNumber } from "./isNumber.js";
|
|
2
|
+
var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
|
|
3
|
+
export function serializeCookie(name, val, attributes) {
|
|
4
|
+
if (attributes === void 0) { attributes = {}; }
|
|
5
|
+
var _a = attributes.encode, encode = _a === void 0 ? encodeURIComponent : _a, domain = attributes.domain, path = attributes.path, httpOnly = attributes.httpOnly, secure = attributes.secure, sameSite = attributes.sameSite;
|
|
6
|
+
var maxAge = attributes.maxAge, expires = attributes.expires;
|
|
7
|
+
var value = encode(val);
|
|
32
8
|
if (process.env["NODE_ENV"] !== "production") {
|
|
33
9
|
if (!fieldContentRegExp.test(name)) {
|
|
34
10
|
throw new TypeError("argument name is invalid");
|
|
@@ -40,7 +16,7 @@ const fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
|
|
|
40
16
|
throw new TypeError("argument val is invalid");
|
|
41
17
|
}
|
|
42
18
|
}
|
|
43
|
-
|
|
19
|
+
var str = name + "=" + value;
|
|
44
20
|
if (null != maxAge) {
|
|
45
21
|
maxAge = maxAge - 0;
|
|
46
22
|
if (isNaN(maxAge) || !isFinite(maxAge)) {
|
|
@@ -77,7 +53,7 @@ const fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
|
|
|
77
53
|
str += "; Secure";
|
|
78
54
|
}
|
|
79
55
|
if (sameSite) {
|
|
80
|
-
switch(sameSite.toLowerCase()){
|
|
56
|
+
switch (sameSite.toLowerCase()) {
|
|
81
57
|
case "lax":
|
|
82
58
|
str += "; SameSite=Lax";
|
|
83
59
|
break;
|
package/setCookie.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { type CookieAttributesClient } from "./cookie";
|
|
2
|
-
/**
|
|
3
|
-
* @category cookie
|
|
4
|
-
*/
|
|
1
|
+
import { type CookieAttributesClient } from "./cookie.js";
|
|
5
2
|
export declare function setCookie<T extends string = string>(name: string, value: string | T, attributes?: CookieAttributesClient): string | undefined;
|
|
6
3
|
export default setCookie;
|
package/setCookie.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { __assign, __rest } from "tslib";
|
|
2
|
+
import { defaultAttributesClient } from "./cookie.js";
|
|
3
|
+
import isNumber from "./isNumber.js";
|
|
4
|
+
import isUndefined from "./isUndefined.js";
|
|
5
|
+
function converterWrite(value) {
|
|
6
|
+
return encodeURIComponent(value).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g, decodeURIComponent);
|
|
7
|
+
}
|
|
8
|
+
export function setCookie(name, value, attributes) {
|
|
9
|
+
if (attributes === void 0) { attributes = {}; }
|
|
10
|
+
var expires = attributes.expires, restAttrs = __rest(attributes, ["expires"]);
|
|
11
|
+
var cleanedAttrs = __assign(__assign({ expires: "" }, defaultAttributesClient), restAttrs);
|
|
12
|
+
if (isUndefined(document)) {
|
|
13
|
+
if (process.env["NODE_ENV"] !== "production") {
|
|
14
|
+
console.warn("[@koine/utils:setCookie] document is undefined");
|
|
15
|
+
}
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
if (isNumber(expires)) {
|
|
19
|
+
expires = new Date(Date.now() + expires * 864e5);
|
|
20
|
+
}
|
|
21
|
+
if (expires) {
|
|
22
|
+
cleanedAttrs.expires = expires.toUTCString();
|
|
23
|
+
}
|
|
24
|
+
name = encodeURIComponent(name)
|
|
25
|
+
.replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent)
|
|
26
|
+
.replace(/[()]/g, escape);
|
|
27
|
+
var stringifiedAttributes = "";
|
|
28
|
+
for (var name_1 in attributes) {
|
|
29
|
+
var attrName = name_1;
|
|
30
|
+
if (!attributes[attrName]) {
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
stringifiedAttributes += "; " + attrName;
|
|
34
|
+
if (attributes[attrName] === true) {
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
stringifiedAttributes +=
|
|
38
|
+
"=" + String(attributes[attrName]).split(";")[0];
|
|
39
|
+
}
|
|
40
|
+
return (document.cookie =
|
|
41
|
+
name + "=" + converterWrite(value) + stringifiedAttributes);
|
|
42
|
+
}
|
|
43
|
+
export default setCookie;
|
package/shuffle.d.ts
CHANGED
|
@@ -1,17 +1,2 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates an array of shuffled values, using a version of the
|
|
3
|
-
* [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
|
|
4
|
-
*
|
|
5
|
-
* @category array
|
|
6
|
-
* @borrows [lodash.shuffle](https://github.com/lodash/lodash/blob/master/shuffle.js)
|
|
7
|
-
* @example
|
|
8
|
-
* ```ts
|
|
9
|
-
* shuffle([1, 2, 3, 4])
|
|
10
|
-
* // => [4, 1, 3, 2]
|
|
11
|
-
* ```
|
|
12
|
-
*
|
|
13
|
-
* @param array The array to shuffle.
|
|
14
|
-
* @returns The new shuffled array.
|
|
15
|
-
*/
|
|
16
1
|
export declare function shuffle<T>(array: T[]): T[];
|
|
17
2
|
export default shuffle;
|
package/shuffle.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { __spreadArray } from "tslib";
|
|
2
|
+
export function shuffle(array) {
|
|
3
|
+
var length = array == null ? 0 : array.length;
|
|
4
|
+
if (!length) {
|
|
5
|
+
return [];
|
|
6
|
+
}
|
|
7
|
+
var index = -1;
|
|
8
|
+
var lastIndex = length - 1;
|
|
9
|
+
var result = __spreadArray([], array, true);
|
|
10
|
+
while (++index < length) {
|
|
11
|
+
var rand = index + Math.floor(Math.random() * (lastIndex - index + 1));
|
|
12
|
+
var value = result[rand];
|
|
13
|
+
result[rand] = result[index];
|
|
14
|
+
result[index] = value;
|
|
15
|
+
}
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
18
|
+
export default shuffle;
|
package/slugify.d.ts
CHANGED
|
@@ -1,12 +1,2 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Slugify a text
|
|
3
|
-
*
|
|
4
|
-
* - replaces the accented letters
|
|
5
|
-
* - replaces the punctuation with dashes
|
|
6
|
-
*
|
|
7
|
-
* @category text
|
|
8
|
-
*
|
|
9
|
-
* @borrows [mathewbyrne's gist](https://gist.github.com/mathewbyrne/1280286#gistcomment-3498021)
|
|
10
|
-
*/
|
|
11
1
|
export declare function slugify(text: string, separator?: string): string;
|
|
12
2
|
export default slugify;
|
package/slugify.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { accentsSets } from "./accentSets.js";
|
|
2
|
+
import { removeAccents } from "./removeAccents.js";
|
|
3
|
+
export function slugify(text, separator) {
|
|
4
|
+
if (separator === void 0) { separator = "-"; }
|
|
5
|
+
return removeAccents(text.toString().toLowerCase().trim(), accentsSets.concat([["-", "[·/_,:;']"]]))
|
|
6
|
+
.replace(/\s+/g, "-")
|
|
7
|
+
.replace(/&/g, "-and-")
|
|
8
|
+
.replace(/[^\w-]+/g, "")
|
|
9
|
+
.replace(/--+/g, "-")
|
|
10
|
+
.replace(/^-+/, "")
|
|
11
|
+
.replace(/-+$/, "")
|
|
12
|
+
.replace(/-/g, separator);
|
|
13
|
+
}
|
|
14
|
+
export default slugify;
|
package/split.d.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
1
|
export type Split<S extends string, D extends string> = string extends S ? string[] : S extends "" ? [] : S extends `${infer T}${D}${infer U}` ? [T, ...Split<U, D>] : [S];
|
|
2
|
-
/**
|
|
3
|
-
* @category native
|
|
4
|
-
* @category text
|
|
5
|
-
*/
|
|
6
2
|
export declare function split<T extends string, D extends string>(str: T, delimiter: D): Split<T, D>;
|
|
7
3
|
export default split;
|
package/split.js
ADDED
package/swapMap.d.ts
CHANGED
package/swapMap.js
ADDED
package/throttle.d.ts
CHANGED
|
@@ -1,9 +1,2 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/**
|
|
3
|
-
* Throttle function (e.g. for resize / scroll handlers)
|
|
4
|
-
*
|
|
5
|
-
* @category function
|
|
6
|
-
* @borrows [Mobius1/Rangeable](https://github.com/Mobius1/Rangeable/)
|
|
7
|
-
*/
|
|
8
1
|
export declare function throttle<TFn extends Function, TContext>(fn: TFn, limit: number, context?: TContext): (this: TContext, ...args: any[]) => NodeJS.Timeout | undefined;
|
|
9
2
|
export default throttle;
|