@koine/utils 1.0.26 → 1.0.29
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/{async.d.ts → Defer.d.ts} +5 -5
- package/{async.js → Defer.js} +2 -7
- package/{emitter.d.ts → Emitter.d.ts} +1 -0
- package/{emitter.js → Emitter.js} +1 -0
- package/accentSets.d.ts +16 -0
- package/accentSets.js +38 -0
- package/addOrReplaceAtIdx.d.ts +5 -0
- package/addOrReplaceAtIdx.js +19 -0
- package/arrayToLookup.d.ts +7 -0
- package/arrayToLookup.js +13 -0
- package/buildUrlQueryString.d.ts +12 -0
- package/buildUrlQueryString.js +24 -0
- package/changeUrlPath.d.ts +10 -0
- package/changeUrlPath.js +18 -0
- package/chunkByChunks.d.ts +7 -0
- package/chunkByChunks.js +37 -0
- package/chunkBySize.d.ts +6 -0
- package/chunkBySize.js +12 -0
- package/clamp.d.ts +8 -0
- package/clamp.js +10 -0
- package/clsx.d.ts +9 -0
- package/clsx.js +49 -0
- package/convertRange.d.ts +14 -0
- package/convertRange.js +16 -0
- package/cookie.d.ts +7 -26
- package/cookie.js +3 -221
- package/decode.d.ts +6 -0
- package/decode.js +10 -0
- package/encode.d.ts +6 -0
- package/encode.js +10 -0
- package/{cast.d.ts → ensureInt.d.ts} +3 -1
- package/{cast.js → ensureInt.js} +3 -4
- package/findDuplicatedIndexes.d.ts +5 -0
- package/findDuplicatedIndexes.js +14 -0
- package/getKeys.d.ts +9 -0
- package/getKeys.js +9 -0
- package/getNonce.d.ts +6 -0
- package/getNonce.js +9 -0
- package/getType.d.ts +22 -0
- package/getType.js +19 -0
- package/getUrlHashParams.d.ts +9 -0
- package/getUrlHashParams.js +16 -0
- package/getUrlHashPathname.d.ts +9 -0
- package/getUrlHashPathname.js +13 -0
- package/getUrlPathnameParts.d.ts +12 -0
- package/getUrlPathnameParts.js +20 -0
- package/getUrlQueryParams.d.ts +14 -0
- package/getUrlQueryParams.js +38 -0
- package/index.d.ts +107 -15
- package/index.js +108 -16
- package/isAnyObject.d.ts +8 -0
- package/isAnyObject.js +10 -0
- package/isArray.d.ts +7 -0
- package/isArray.js +10 -0
- package/isBlob.d.ts +7 -0
- package/isBlob.js +10 -0
- package/isBoolean.d.ts +7 -0
- package/isBoolean.js +10 -0
- package/isBrowser.d.ts +6 -0
- package/{ssr.js → isBrowser.js} +5 -2
- package/isDate.d.ts +7 -0
- package/isDate.js +10 -0
- package/isEmptyArray.d.ts +7 -0
- package/isEmptyArray.js +10 -0
- package/isEmptyObject.d.ts +9 -0
- package/isEmptyObject.js +10 -0
- package/isEmptyString.d.ts +7 -0
- package/isEmptyString.js +9 -0
- package/isError.d.ts +7 -0
- package/isError.js +10 -0
- package/isExternalUrl.d.ts +9 -0
- package/isExternalUrl.js +21 -0
- package/isFile.d.ts +7 -0
- package/isFile.js +10 -0
- package/isFloat.d.ts +7 -0
- package/isFloat.js +10 -0
- package/isFormData.d.ts +7 -0
- package/isFormData.js +10 -0
- package/isFullArray.d.ts +7 -0
- package/isFullArray.js +10 -0
- package/isFullObject.d.ts +8 -0
- package/isFullObject.js +10 -0
- package/isFullString.d.ts +7 -0
- package/isFullString.js +10 -0
- package/isFunction.d.ts +8 -0
- package/isFunction.js +9 -0
- package/{detect.d.ts → isIE.d.ts} +3 -4
- package/isIE.js +18 -0
- package/isInt.d.ts +7 -0
- package/isInt.js +10 -0
- package/isMap.d.ts +7 -0
- package/isMap.js +10 -0
- package/isMobile.d.ts +7 -0
- package/{detect.js → isMobile.js} +4 -15
- package/isNaNValue.d.ts +7 -0
- package/isNaNValue.js +10 -0
- package/isNegativeNumber.d.ts +7 -0
- package/isNegativeNumber.js +10 -0
- package/isNull.d.ts +7 -0
- package/isNull.js +10 -0
- package/isNullOrUndefined.d.ts +7 -0
- package/isNullOrUndefined.js +10 -0
- package/isNumber.d.ts +9 -0
- package/isNumber.js +12 -0
- package/isObject.d.ts +8 -0
- package/isObject.js +10 -0
- package/isObjectLike.d.ts +10 -0
- package/isObjectLike.js +12 -0
- package/isOneOf.d.ts +9 -0
- package/isOneOf.js +10 -0
- package/isPlainObject.d.ts +8 -0
- package/isPlainObject.js +13 -0
- package/isPositiveNumber.d.ts +7 -0
- package/isPositiveNumber.js +10 -0
- package/isPrimitive.d.ts +7 -0
- package/isPrimitive.js +20 -0
- package/isPromise.d.ts +7 -0
- package/isPromise.js +10 -0
- package/isRegExp.d.ts +7 -0
- package/isRegExp.js +10 -0
- package/isServer.d.ts +6 -0
- package/isServer.js +8 -0
- package/isSet.d.ts +7 -0
- package/isSet.js +10 -0
- package/isString.d.ts +7 -0
- package/isString.js +10 -0
- package/isSymbol.d.ts +7 -0
- package/isSymbol.js +10 -0
- package/isType.d.ts +11 -0
- package/isType.js +22 -0
- package/isUndefined.d.ts +7 -0
- package/isUndefined.js +10 -0
- package/isWeakMap.d.ts +7 -0
- package/isWeakMap.js +10 -0
- package/isWeakSet.d.ts +7 -0
- package/isWeakSet.js +10 -0
- package/location.d.ts +2 -145
- package/location.js +1 -299
- package/mapListBy.d.ts +7 -0
- package/mapListBy.js +14 -0
- package/{match-sorter.d.ts → matchSorter.d.ts} +1 -0
- package/{match-sorter.js → matchSorter.js} +2 -1
- package/mergeObjects.d.ts +7 -0
- package/{objects.js → mergeObjects.js} +2 -31
- package/mergeUrlQueryParams.d.ts +9 -0
- package/mergeUrlQueryParams.js +22 -0
- package/navigateToHashParams.d.ts +9 -0
- package/navigateToHashParams.js +22 -0
- package/navigateToMergedHashParams.d.ts +8 -0
- package/navigateToMergedHashParams.js +14 -0
- package/navigateToMergedParams.d.ts +9 -0
- package/navigateToMergedParams.js +14 -0
- package/navigateToParams.d.ts +10 -0
- package/navigateToParams.js +18 -0
- package/navigateWithoutUrlParam.d.ts +8 -0
- package/navigateWithoutUrlParam.js +19 -0
- package/node/{async.js → Defer.js} +3 -9
- package/node/{emitter.js → Emitter.js} +1 -0
- package/node/accentSets.js +41 -0
- package/node/addOrReplaceAtIdx.js +23 -0
- package/node/arrayToLookup.js +17 -0
- package/node/buildUrlQueryString.js +28 -0
- package/node/changeUrlPath.js +22 -0
- package/node/chunkByChunks.js +41 -0
- package/node/chunkBySize.js +16 -0
- package/node/clamp.js +14 -0
- package/node/clsx.js +53 -0
- package/node/convertRange.js +20 -0
- package/node/cookie.js +4 -227
- package/node/decode.js +14 -0
- package/node/encode.js +14 -0
- package/node/{cast.js → ensureInt.js} +4 -6
- package/node/findDuplicatedIndexes.js +18 -0
- package/node/getKeys.js +12 -0
- package/node/getNonce.js +13 -0
- package/node/getType.js +23 -0
- package/node/getUrlHashParams.js +20 -0
- package/node/getUrlHashPathname.js +17 -0
- package/node/getUrlPathnameParts.js +24 -0
- package/node/getUrlQueryParams.js +42 -0
- package/node/index.js +108 -16
- package/node/isAnyObject.js +14 -0
- package/node/isArray.js +14 -0
- package/node/isBlob.js +14 -0
- package/node/isBoolean.js +14 -0
- package/node/{ssr.js → isBrowser.js} +6 -3
- package/node/isDate.js +14 -0
- package/node/isEmptyArray.js +14 -0
- package/node/isEmptyObject.js +14 -0
- package/node/isEmptyString.js +13 -0
- package/node/isError.js +14 -0
- package/node/isExternalUrl.js +25 -0
- package/node/isFile.js +14 -0
- package/node/isFloat.js +14 -0
- package/node/isFormData.js +14 -0
- package/node/isFullArray.js +14 -0
- package/node/isFullObject.js +14 -0
- package/node/isFullString.js +14 -0
- package/node/isFunction.js +13 -0
- package/node/isIE.js +22 -0
- package/node/isInt.js +14 -0
- package/node/isMap.js +14 -0
- package/node/{detect.js → isMobile.js} +6 -18
- package/node/isNaNValue.js +14 -0
- package/node/isNegativeNumber.js +14 -0
- package/node/isNull.js +14 -0
- package/node/isNullOrUndefined.js +13 -0
- package/node/isNumber.js +16 -0
- package/node/isObject.js +14 -0
- package/node/isObjectLike.js +16 -0
- package/node/isOneOf.js +14 -0
- package/node/isPlainObject.js +17 -0
- package/node/isPositiveNumber.js +14 -0
- package/node/isPrimitive.js +24 -0
- package/node/isPromise.js +14 -0
- package/node/isRegExp.js +14 -0
- package/node/isServer.js +11 -0
- package/node/isSet.js +14 -0
- package/node/isString.js +14 -0
- package/node/isSymbol.js +14 -0
- package/node/isType.js +26 -0
- package/node/isUndefined.js +14 -0
- package/node/isWeakMap.js +14 -0
- package/node/isWeakSet.js +14 -0
- package/node/location.js +0 -321
- package/node/mapListBy.js +18 -0
- package/node/{match-sorter.js → matchSorter.js} +3 -2
- package/node/{objects.js → mergeObjects.js} +5 -36
- package/node/mergeUrlQueryParams.js +26 -0
- package/node/navigateToHashParams.js +26 -0
- package/node/navigateToMergedHashParams.js +18 -0
- package/node/navigateToMergedParams.js +18 -0
- package/node/navigateToParams.js +22 -0
- package/node/navigateWithoutUrlParam.js +23 -0
- package/node/normaliseUrl.js +18 -0
- package/node/normaliseUrlPathname.js +18 -0
- package/node/{analytics-google.js → pageview.js} +12 -10
- package/node/parseCookie.js +52 -0
- package/node/parseURL.js +24 -0
- package/node/randomInt.js +13 -0
- package/node/{misc.js → randomKey.js} +2 -0
- package/node/readCookie.js +38 -0
- package/node/redirectTo.js +19 -0
- package/node/removeAccents.js +19 -0
- package/node/removeCookie.js +19 -0
- package/node/removeDuplicatesByKey.js +25 -0
- package/node/removeDuplicatesComparing.js +14 -0
- package/node/removeIndexesFromArray.js +18 -0
- package/node/removeTrailingSlash.js +14 -0
- package/node/{math.js → roundTo.js} +3 -32
- package/node/serializeCookie.js +108 -0
- package/node/setCookie.js +61 -0
- package/node/shuffle.js +36 -0
- package/node/slugify.js +27 -0
- package/node/swapMap.js +18 -0
- package/node/{typography.js → titleCase.js} +3 -12
- package/node/toNumber.js +12 -0
- package/node/{colors.js → toRgba.js} +4 -0
- package/node/transformToUrlPathname.js +20 -0
- package/node/truncate.js +17 -0
- package/node/uid.js +4 -13
- package/node/updateLinkParams.js +18 -0
- package/node/updateUrlQueryParams.js +22 -0
- package/node/uuid.js +17 -0
- package/node/wait.js +13 -0
- package/node/whitelistObject.js +19 -0
- package/normaliseUrl.d.ts +10 -0
- package/normaliseUrl.js +14 -0
- package/normaliseUrlPathname.d.ts +10 -0
- package/normaliseUrlPathname.js +14 -0
- package/package.json +1 -1
- package/{analytics-google.d.ts → pageview.d.ts} +3 -0
- package/{analytics-google.js → pageview.js} +12 -10
- package/parseCookie.d.ts +11 -0
- package/parseCookie.js +48 -0
- package/parseURL.d.ts +17 -0
- package/parseURL.js +20 -0
- package/randomInt.d.ts +7 -0
- package/randomInt.js +9 -0
- package/{misc.d.ts → randomKey.d.ts} +2 -0
- package/{misc.js → randomKey.js} +2 -0
- package/readCookie.d.ts +3 -0
- package/readCookie.js +34 -0
- package/redirectTo.d.ts +9 -0
- package/redirectTo.js +15 -0
- package/removeAccents.d.ts +6 -0
- package/removeAccents.js +15 -0
- package/removeCookie.d.ts +10 -0
- package/removeCookie.js +15 -0
- package/removeDuplicatesByKey.d.ts +8 -0
- package/removeDuplicatesByKey.js +21 -0
- package/removeDuplicatesComparing.d.ts +5 -0
- package/removeDuplicatesComparing.js +10 -0
- package/removeIndexesFromArray.d.ts +5 -0
- package/removeIndexesFromArray.js +14 -0
- package/removeTrailingSlash.d.ts +7 -0
- package/removeTrailingSlash.js +10 -0
- package/roundTo.d.ts +8 -0
- package/{math.js → roundTo.js} +2 -28
- package/serializeCookie.d.ts +27 -0
- package/serializeCookie.js +104 -0
- package/setCookie.d.ts +10 -0
- package/setCookie.js +57 -0
- package/shuffle.d.ts +16 -0
- package/shuffle.js +32 -0
- package/{text.d.ts → slugify.d.ts} +2 -5
- package/slugify.js +23 -0
- package/swapMap.d.ts +7 -0
- package/swapMap.js +14 -0
- package/{typography.d.ts → titleCase.d.ts} +2 -4
- package/{typography.js → titleCase.js} +2 -10
- package/toNumber.d.ts +5 -0
- package/toNumber.js +8 -0
- package/{colors.d.ts → toRgba.d.ts} +4 -0
- package/{colors.js → toRgba.js} +4 -0
- package/transformToUrlPathname.d.ts +11 -0
- package/transformToUrlPathname.js +16 -0
- package/truncate.d.ts +7 -0
- package/truncate.js +13 -0
- package/uid.d.ts +3 -6
- package/uid.js +3 -11
- package/updateLinkParams.d.ts +10 -0
- package/updateLinkParams.js +14 -0
- package/updateUrlQueryParams.d.ts +9 -0
- package/updateUrlQueryParams.js +18 -0
- package/uuid.d.ts +8 -0
- package/uuid.js +13 -0
- package/wait.d.ts +7 -0
- package/wait.js +9 -0
- package/whitelistObject.d.ts +8 -0
- package/whitelistObject.js +15 -0
- package/arrays.d.ts +0 -41
- package/arrays.js +0 -153
- package/is.d.ts +0 -288
- package/is.js +0 -376
- package/math.d.ts +0 -28
- package/node/arrays.js +0 -166
- package/node/is.js +0 -417
- package/node/security.js +0 -29
- package/node/text.js +0 -70
- package/objects.d.ts +0 -22
- package/security.d.ts +0 -12
- package/security.js +0 -23
- package/ssr.d.ts +0 -2
- package/text.js +0 -65
package/isIE.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { isServer } from "./isServer";
|
|
2
|
+
/**
|
|
3
|
+
* @category detect
|
|
4
|
+
* @category is
|
|
5
|
+
* @see https://stackoverflow.com/a/21712356/12285349
|
|
6
|
+
*/
|
|
7
|
+
export function isIE(ssrValue) {
|
|
8
|
+
if (ssrValue === void 0) { ssrValue = true; }
|
|
9
|
+
if (isServer) {
|
|
10
|
+
return ssrValue;
|
|
11
|
+
}
|
|
12
|
+
var ua = window.navigator.userAgent;
|
|
13
|
+
if (ua.indexOf("MSIE ") > 0 || ua.indexOf("Trident/") > 0) {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
export default isIE;
|
package/isInt.d.ts
ADDED
package/isInt.js
ADDED
package/isMap.d.ts
ADDED
package/isMap.js
ADDED
package/isMobile.d.ts
ADDED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { isServer } from "./
|
|
1
|
+
import { isServer } from "./isServer";
|
|
2
2
|
/**
|
|
3
|
+
* @category detect
|
|
4
|
+
* @category is
|
|
3
5
|
* @see https://stackoverflow.com/a/3540295
|
|
4
6
|
*/
|
|
5
7
|
export function isMobile(ssrValue) {
|
|
@@ -11,17 +13,4 @@ export function isMobile(ssrValue) {
|
|
|
11
13
|
// return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent)
|
|
12
14
|
// || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(navigator.userAgent.substr(0,4)
|
|
13
15
|
}
|
|
14
|
-
|
|
15
|
-
* @see https://stackoverflow.com/a/21712356/12285349
|
|
16
|
-
*/
|
|
17
|
-
export function isIE(ssrValue) {
|
|
18
|
-
if (ssrValue === void 0) { ssrValue = true; }
|
|
19
|
-
if (isServer) {
|
|
20
|
-
return ssrValue;
|
|
21
|
-
}
|
|
22
|
-
var ua = window.navigator.userAgent;
|
|
23
|
-
if (ua.indexOf("MSIE ") > 0 || ua.indexOf("Trident/") > 0) {
|
|
24
|
-
return true;
|
|
25
|
-
}
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
16
|
+
export default isMobile;
|
package/isNaNValue.d.ts
ADDED
package/isNaNValue.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import getType from "./getType";
|
|
2
|
+
/**
|
|
3
|
+
* Returns whether the payload is literally the value `NaN` (it's `NaN` and also a `number`)
|
|
4
|
+
*
|
|
5
|
+
* @category is
|
|
6
|
+
*/
|
|
7
|
+
export function isNaNValue(payload) {
|
|
8
|
+
return getType(payload) === "Number" && isNaN(payload);
|
|
9
|
+
}
|
|
10
|
+
export default isNaNValue;
|
package/isNull.d.ts
ADDED
package/isNull.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import isNull from "./isNull";
|
|
2
|
+
import isOneOf from "./isOneOf";
|
|
3
|
+
import isUndefined from "./isUndefined";
|
|
4
|
+
/**
|
|
5
|
+
* Returns true whether the payload is null or undefined
|
|
6
|
+
*
|
|
7
|
+
* @category is
|
|
8
|
+
*/
|
|
9
|
+
export var isNullOrUndefined = isOneOf(isNull, isUndefined);
|
|
10
|
+
export default isNullOrUndefined;
|
package/isNumber.d.ts
ADDED
package/isNumber.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import getType from "./getType";
|
|
2
|
+
/**
|
|
3
|
+
* Returns whether the payload is a number (but not NaN)
|
|
4
|
+
*
|
|
5
|
+
* This will return `false` for `NaN`!!
|
|
6
|
+
*
|
|
7
|
+
* @category is
|
|
8
|
+
*/
|
|
9
|
+
export function isNumber(payload) {
|
|
10
|
+
return getType(payload) === "Number" && !isNaN(payload);
|
|
11
|
+
}
|
|
12
|
+
export default isNumber;
|
package/isObject.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type PlainObject } from "./getType";
|
|
2
|
+
/**
|
|
3
|
+
* Returns whether the payload is a plain JavaScript object (excluding special classes or objects with other prototypes)
|
|
4
|
+
*
|
|
5
|
+
* @category is
|
|
6
|
+
*/
|
|
7
|
+
export declare function isObject(payload: any): payload is PlainObject;
|
|
8
|
+
export default isObject;
|
package/isObject.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import isPlainObject from "./isPlainObject";
|
|
2
|
+
/**
|
|
3
|
+
* Returns whether the payload is a plain JavaScript object (excluding special classes or objects with other prototypes)
|
|
4
|
+
*
|
|
5
|
+
* @category is
|
|
6
|
+
*/
|
|
7
|
+
export function isObject(payload) {
|
|
8
|
+
return isPlainObject(payload);
|
|
9
|
+
}
|
|
10
|
+
export default isObject;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type PlainObject } from "./getType";
|
|
2
|
+
/**
|
|
3
|
+
* Returns whether the payload is an object like a type passed in < >
|
|
4
|
+
*
|
|
5
|
+
* Usage: isObjectLike<{id: any}>(payload) // will make sure it's an object and has an `id` prop.
|
|
6
|
+
*
|
|
7
|
+
* @category is
|
|
8
|
+
*/
|
|
9
|
+
export declare function isObjectLike<T extends PlainObject>(payload: any): payload is T;
|
|
10
|
+
export default isObjectLike;
|
package/isObjectLike.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import isAnyObject from "./isAnyObject";
|
|
2
|
+
/**
|
|
3
|
+
* Returns whether the payload is an object like a type passed in < >
|
|
4
|
+
*
|
|
5
|
+
* Usage: isObjectLike<{id: any}>(payload) // will make sure it's an object and has an `id` prop.
|
|
6
|
+
*
|
|
7
|
+
* @category is
|
|
8
|
+
*/
|
|
9
|
+
export function isObjectLike(payload) {
|
|
10
|
+
return isAnyObject(payload);
|
|
11
|
+
}
|
|
12
|
+
export default isObjectLike;
|
package/isOneOf.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type TypeGuard } from "./getType";
|
|
2
|
+
/**
|
|
3
|
+
* @category is
|
|
4
|
+
*/
|
|
5
|
+
export declare function isOneOf<A, B extends A, C extends A>(a: TypeGuard<A, B>, b: TypeGuard<A, C>): TypeGuard<A, B | C>;
|
|
6
|
+
export declare function isOneOf<A, B extends A, C extends A, D extends A>(a: TypeGuard<A, B>, b: TypeGuard<A, C>, c: TypeGuard<A, D>): TypeGuard<A, B | C | D>;
|
|
7
|
+
export declare function isOneOf<A, B extends A, C extends A, D extends A, E extends A>(a: TypeGuard<A, B>, b: TypeGuard<A, C>, c: TypeGuard<A, D>, d: TypeGuard<A, E>): TypeGuard<A, B | C | D | E>;
|
|
8
|
+
export declare function isOneOf<A, B extends A, C extends A, D extends A, E extends A, F extends A>(a: TypeGuard<A, B>, b: TypeGuard<A, C>, c: TypeGuard<A, D>, d: TypeGuard<A, E>, e: TypeGuard<A, F>): TypeGuard<A, B | C | D | E | F>;
|
|
9
|
+
export default isOneOf;
|
package/isOneOf.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type PlainObject } from "./getType";
|
|
2
|
+
/**
|
|
3
|
+
* Returns whether the payload is a plain JavaScript object (excluding special classes or objects with other prototypes)
|
|
4
|
+
*
|
|
5
|
+
* @category is
|
|
6
|
+
*/
|
|
7
|
+
export declare function isPlainObject(payload: any): payload is PlainObject;
|
|
8
|
+
export default isPlainObject;
|
package/isPlainObject.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import getType from "./getType";
|
|
2
|
+
/**
|
|
3
|
+
* Returns whether the payload is a plain JavaScript object (excluding special classes or objects with other prototypes)
|
|
4
|
+
*
|
|
5
|
+
* @category is
|
|
6
|
+
*/
|
|
7
|
+
export function isPlainObject(payload) {
|
|
8
|
+
if (getType(payload) !== "Object")
|
|
9
|
+
return false;
|
|
10
|
+
return (payload.constructor === Object &&
|
|
11
|
+
Object.getPrototypeOf(payload) === Object.prototype);
|
|
12
|
+
}
|
|
13
|
+
export default isPlainObject;
|
package/isPrimitive.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns whether the payload is a primitive type (eg. Boolean | Null | Undefined | Number | String | Symbol)
|
|
3
|
+
*
|
|
4
|
+
* @category is
|
|
5
|
+
*/
|
|
6
|
+
export declare function isPrimitive(payload: any): payload is boolean | null | undefined | number | string | symbol;
|
|
7
|
+
export default isPrimitive;
|
package/isPrimitive.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import isString from "./isString";
|
|
2
|
+
import isNull from "./isNull";
|
|
3
|
+
import isNumber from "./isNumber";
|
|
4
|
+
import isUndefined from "./isUndefined";
|
|
5
|
+
import isBoolean from "./isBoolean";
|
|
6
|
+
import isSymbol from "./isSymbol";
|
|
7
|
+
/**
|
|
8
|
+
* Returns whether the payload is a primitive type (eg. Boolean | Null | Undefined | Number | String | Symbol)
|
|
9
|
+
*
|
|
10
|
+
* @category is
|
|
11
|
+
*/
|
|
12
|
+
export function isPrimitive(payload) {
|
|
13
|
+
return (isBoolean(payload) ||
|
|
14
|
+
isNull(payload) ||
|
|
15
|
+
isUndefined(payload) ||
|
|
16
|
+
isNumber(payload) ||
|
|
17
|
+
isString(payload) ||
|
|
18
|
+
isSymbol(payload));
|
|
19
|
+
}
|
|
20
|
+
export default isPrimitive;
|
package/isPromise.d.ts
ADDED
package/isPromise.js
ADDED
package/isRegExp.d.ts
ADDED
package/isRegExp.js
ADDED
package/isServer.d.ts
ADDED
package/isServer.js
ADDED
package/isSet.d.ts
ADDED
package/isSet.js
ADDED
package/isString.d.ts
ADDED
package/isString.js
ADDED
package/isSymbol.d.ts
ADDED
package/isSymbol.js
ADDED
package/isType.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type AnyClass, type AnyFunction } from "./getType";
|
|
2
|
+
/**
|
|
3
|
+
* Does a generic check to check that the given payload is of a given type.
|
|
4
|
+
* In cases like Number, it will return true for NaN as NaN is a Number (thanks javascript!);
|
|
5
|
+
* It will, however, differentiate between object and null
|
|
6
|
+
*
|
|
7
|
+
* @category is
|
|
8
|
+
* @throws {TypeError} Will throw type error if type is an invalid type
|
|
9
|
+
*/
|
|
10
|
+
export declare function isType<T extends AnyFunction | AnyClass>(payload: any, type: T): payload is T;
|
|
11
|
+
export default isType;
|
package/isType.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import getType from "./getType";
|
|
2
|
+
/**
|
|
3
|
+
* Does a generic check to check that the given payload is of a given type.
|
|
4
|
+
* In cases like Number, it will return true for NaN as NaN is a Number (thanks javascript!);
|
|
5
|
+
* It will, however, differentiate between object and null
|
|
6
|
+
*
|
|
7
|
+
* @category is
|
|
8
|
+
* @throws {TypeError} Will throw type error if type is an invalid type
|
|
9
|
+
*/
|
|
10
|
+
export function isType(payload, type) {
|
|
11
|
+
if (!(type instanceof Function)) {
|
|
12
|
+
throw new TypeError("Type must be a function");
|
|
13
|
+
}
|
|
14
|
+
if (!Object.prototype.hasOwnProperty.call(type, "prototype")) {
|
|
15
|
+
throw new TypeError("Type is not a class");
|
|
16
|
+
}
|
|
17
|
+
// Classes usually have names (as functions usually have names)
|
|
18
|
+
var name = type.name;
|
|
19
|
+
return (getType(payload) === name ||
|
|
20
|
+
Boolean(payload && payload.constructor === type));
|
|
21
|
+
}
|
|
22
|
+
export default isType;
|
package/isUndefined.d.ts
ADDED
package/isUndefined.js
ADDED
package/isWeakMap.d.ts
ADDED
package/isWeakMap.js
ADDED
package/isWeakSet.d.ts
ADDED