-
-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(checks): update all as arrow fns
- Loading branch information
1 parent
3038a84
commit b70a3e1
Showing
51 changed files
with
152 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export function existsAndNotNull(x: any) { | ||
return x != null; | ||
} | ||
export const existsAndNotNull = | ||
(x: any) => x != null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export function exists(x: any) { | ||
return x !== undefined; | ||
} | ||
export const exists = | ||
(x: any) => x !== undefined; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export function hasCrypto() { | ||
return typeof window !== "undefined" && window["crypto"] !== undefined; | ||
} | ||
export const hasCrypto = | ||
() => typeof window !== "undefined" && window["crypto"] !== undefined; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export function hasMaxLength(len: number, x: ArrayLike<any>) { | ||
return x != null && x.length <= len; | ||
} | ||
export const hasMaxLength = | ||
(len: number, x: ArrayLike<any>) => | ||
x != null && x.length <= len; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export function hasMinLength(len: number, x: ArrayLike<any>) { | ||
return x != null && x.length >= len; | ||
} | ||
export const hasMinLength = | ||
(len: number, x: ArrayLike<any>) => | ||
x != null && x.length >= len; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
import { isFunction } from "./is-function"; | ||
|
||
export function hasPerformance() { | ||
return typeof performance !== 'undefined' && isFunction(performance.now); | ||
} | ||
export const hasPerformance = | ||
() => typeof performance !== 'undefined' && isFunction(performance.now); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export function hasWASM() { | ||
return (typeof window !== "undefined" && typeof window["WebAssembly"] !== "undefined") || | ||
export const hasWASM = | ||
() => | ||
(typeof window !== "undefined" && typeof window["WebAssembly"] !== "undefined") || | ||
(typeof global !== "undefined" && typeof global["WebAssembly"] !== "undefined"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
export function hasWebGL() { | ||
try { | ||
document.createElement("canvas").getContext("webgl"); | ||
return true; | ||
} catch (e) { | ||
return false; | ||
} | ||
} | ||
export const hasWebGL = | ||
() => { | ||
try { | ||
document.createElement("canvas").getContext("webgl"); | ||
return true; | ||
} catch (e) { | ||
return false; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export function hasWebSocket() { | ||
return typeof WebSocket !== "undefined"; | ||
} | ||
export const hasWebSocket = | ||
() => typeof WebSocket !== "undefined"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export function implementsFunction(x: any, fn: string | symbol) { | ||
return x != null && typeof x[fn] === "function"; | ||
} | ||
export const implementsFunction = | ||
(x: any, fn: string | symbol) => | ||
x != null && typeof x[fn] === "function"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export function isArrayLike(x: any): x is ArrayLike<any> { | ||
return (x != null && typeof x !== "function" && x.length !== undefined); | ||
} | ||
export const isArrayLike = | ||
(x: any): x is ArrayLike<any> => | ||
(x != null && typeof x !== "function" && x.length !== undefined); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export function isBlob(x: any): x is Blob { | ||
return x instanceof Blob; | ||
} | ||
export const isBlob = | ||
(x: any): x is Blob => x instanceof Blob; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export function isBoolean(x: any): x is boolean { | ||
return typeof x === "boolean"; | ||
} | ||
export const isBoolean = | ||
(x: any): x is boolean => typeof x === "boolean"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export function isChrome() { | ||
return typeof window !== "undefined" && !!window["chrome"]; | ||
} | ||
export const isChrome = | ||
() => typeof window !== "undefined" && !!window["chrome"]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export function isDate(x: any): x is Date { | ||
return x instanceof Date; | ||
} | ||
export const isDate = | ||
(x: any): x is Date => x instanceof Date; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export function isEven(x: number) { | ||
return (x % 2) === 0; | ||
} | ||
export const isEven = | ||
(x: number) => (x % 2) === 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export function isFalse(x: any): x is false { | ||
return x === false; | ||
} | ||
export const isFalse = | ||
(x: any): x is false => x === false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export function isFile(x: any): x is File { | ||
return x instanceof File; | ||
} | ||
export const isFile = | ||
(x: any): x is File => x instanceof File; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export function isFirefox() { | ||
return typeof window !== "undefined" && !!window["InstallTrigger"]; | ||
} | ||
export const isFirefox = | ||
() => typeof window !== "undefined" && !!window["InstallTrigger"]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export function isFunction(x: any): x is Function { | ||
return typeof x === "function"; | ||
} | ||
export const isFunction = | ||
(x: any): x is Function => typeof x === "function"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export function isIE() { | ||
return typeof document !== "undefined" && | ||
export const isIE = | ||
() => | ||
typeof document !== "undefined" && | ||
(typeof document["documentMode"] !== "undefined" || | ||
navigator.userAgent.indexOf("MSIE") > 0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export function isInRange(min: number, max: number, x: number) { | ||
return x >= min && x <= max; | ||
} | ||
export const isInRange = | ||
(min: number, max: number, x: number) => | ||
x >= min && x <= max; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export function isInt32(x: any): x is number { | ||
return typeof x === "number" && (x | 0) === x; | ||
} | ||
export const isInt32 = | ||
(x: any): x is number => | ||
typeof x === "number" && (x | 0) === x; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export function isIterable(x: any): x is Iterable<any> { | ||
return x != null && typeof x[Symbol.iterator] === "function"; | ||
} | ||
export const isIterable = | ||
(x: any): x is Iterable<any> => | ||
x != null && typeof x[Symbol.iterator] === "function"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export function isMap(x: any): x is Map<any, any> { | ||
return x instanceof Map; | ||
} | ||
export const isMap = | ||
(x: any): x is Map<any, any> => x instanceof Map; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export function isMobile() { | ||
return typeof navigator !== "undefined" && | ||
export const isMobile = | ||
() => | ||
typeof navigator !== "undefined" && | ||
/mobile|tablet|ip(ad|hone|od)|android|silk/i.test(navigator.userAgent) && | ||
!/crios/i.test(navigator.userAgent); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export function isNaN(x: any) { | ||
return x !== x; | ||
} | ||
export const isNaN = | ||
(x: any) => x !== x; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export function isNegative(x: any): x is number { | ||
return typeof x === "number" && x < 0; | ||
} | ||
export const isNegative = | ||
(x: any): x is number => | ||
typeof x === "number" && x < 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
declare var process: any; | ||
|
||
export function isNode() { | ||
if (typeof process === "object") { | ||
if (typeof process.versions === "object") { | ||
if (typeof process.versions.node !== "undefined") { | ||
return true; | ||
export const isNode = | ||
() => { | ||
if (typeof process === "object") { | ||
if (typeof process.versions === "object") { | ||
if (typeof process.versions.node !== "undefined") { | ||
return true; | ||
} | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
return false; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export function isNotStringAndIterable(x: any): x is Iterable<any> { | ||
return x != null && | ||
export const isNotStringAndIterable = | ||
(x: any): x is Iterable<any> => | ||
x != null && | ||
typeof x !== "string" && | ||
typeof x[Symbol.iterator] === "function"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export function isNull(x: any): x is null { | ||
return x === null; | ||
} | ||
export const isNull = | ||
(x: any): x is null => x === null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export function isNumber(x: any): x is number { | ||
return typeof x === "number"; | ||
} | ||
export const isNumber = | ||
(x: any): x is number => typeof x === "number"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export function isObject(x: any): x is Object { | ||
return x !== null && typeof x === "object"; | ||
} | ||
export const isObject = | ||
(x: any): x is Object => | ||
x !== null && typeof x === "object"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export function isOdd(x: number) { | ||
return (x % 2) !== 0; | ||
} | ||
export const isOdd = | ||
(x: number) => (x % 2) !== 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export function isPosititve(x: any): x is number { | ||
return typeof x === "number" && x > 0; | ||
} | ||
export const isPosititve = | ||
(x: any): x is number => typeof x === "number" && x > 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export function isPromise(x: any): x is Promise<any> { | ||
return x instanceof Promise; | ||
} | ||
export const isPromise = | ||
(x: any): x is Promise<any> => x instanceof Promise; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { implementsFunction } from "./implements-function"; | ||
|
||
export function isPromiseLike(x: any): x is Promise<any> { | ||
return x instanceof Promise || | ||
export const isPromiseLike = | ||
(x: any): x is Promise<any> => | ||
x instanceof Promise || | ||
(implementsFunction(x, "then") && implementsFunction(x, "catch")); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export function isRegExp(x: any): x is RegExp { | ||
return x instanceof RegExp; | ||
} | ||
export const isRegExp = | ||
(x: any): x is RegExp => x instanceof RegExp; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
import { isChrome } from "./is-chrome"; | ||
|
||
export function isSafari() { | ||
return typeof navigator !== "undefined" && /Safari/.test(navigator.userAgent) && !isChrome(); | ||
} | ||
export const isSafari = | ||
() => | ||
typeof navigator !== "undefined" && | ||
/Safari/.test(navigator.userAgent) && | ||
!isChrome(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export function isSet(x: any): x is Set<any> { | ||
return x instanceof Set; | ||
} | ||
export const isSet = | ||
(x: any): x is Set<any> => x instanceof Set; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export function isString(x: any): x is string { | ||
return typeof x === "string"; | ||
} | ||
export const isString = | ||
(x: any): x is string => typeof x === "string"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export function isSymbol(x: any): x is Symbol { | ||
return typeof x === "symbol"; | ||
} | ||
export const isSymbol = | ||
(x: any): x is Symbol => typeof x === "symbol"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
declare var SharedArrayBuffer: any; | ||
|
||
export function isTransferable(x: any) { | ||
return x instanceof ArrayBuffer || | ||
export const isTransferable = | ||
(x: any) => | ||
x instanceof ArrayBuffer || | ||
(typeof SharedArrayBuffer !== "undefined" && x instanceof SharedArrayBuffer) || | ||
(typeof MessagePort !== "undefined" && x instanceof MessagePort); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export function isTrue(x: any): x is boolean { | ||
return x === true; | ||
} | ||
export const isTrue = | ||
(x: any): x is boolean => x === true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
export function isTypedArray(x: any): x is ArrayLike<number> { | ||
return x && (x.constructor === Float32Array || | ||
x.constructor === Uint32Array || | ||
x.constructor === Uint8Array || | ||
x.constructor === Uint8ClampedArray || | ||
x.constructor === Int8Array || | ||
x.constructor === Uint16Array || | ||
x.constructor === Int16Array || | ||
x.constructor === Int32Array || | ||
x.constructor === Float64Array); | ||
} | ||
export const isTypedArray = | ||
(x: any): x is ArrayLike<number> => | ||
x && (x.constructor === Float32Array || | ||
x.constructor === Uint32Array || | ||
x.constructor === Uint8Array || | ||
x.constructor === Uint8ClampedArray || | ||
x.constructor === Int8Array || | ||
x.constructor === Uint16Array || | ||
x.constructor === Int16Array || | ||
x.constructor === Int32Array || | ||
x.constructor === Float64Array); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export function isUint32(x: any): x is number { | ||
return typeof x === "number" && (x >>> 0) === x; | ||
} | ||
export const isUint32 = | ||
(x: any): x is number => | ||
typeof x === "number" && (x >>> 0) === x; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export function isUndefined(x: any): x is undefined { | ||
return x === undefined; | ||
} | ||
export const isUndefined = | ||
(x: any): x is undefined => x === undefined; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export function isUUID(x: string) { | ||
return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(x); | ||
} | ||
const RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i; | ||
|
||
export const isUUID = | ||
(x: string) => RE.test(x); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export function isUUIDv4(x: string) { | ||
return /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(x); | ||
} | ||
const RE = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i; | ||
|
||
export const isUUIDv4 = | ||
(x: string) => RE.test(x); |
Oops, something went wrong.