Socket
Socket
Sign inDemoInstall

@thi.ng/checks

Package Overview
Dependencies
Maintainers
1
Versions
164
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@thi.ng/checks - npm Package Compare versions

Comparing version 3.4.11 to 3.4.12

2

CHANGELOG.md
# Change Log
- **Last updated**: 2023-12-09T19:12:03Z
- **Last updated**: 2023-12-11T10:07:09Z
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)

@@ -5,0 +5,0 @@

@@ -1,1 +0,4 @@

export const existsAndNotNull = (x) => x != null;
const existsAndNotNull = (x) => x != null;
export {
existsAndNotNull
};

@@ -1,1 +0,4 @@

export const exists = (t) => t !== undefined;
const exists = (t) => t !== void 0;
export {
exists
};

@@ -1,1 +0,4 @@

export const hasBigInt = () => typeof BigInt === "function";
const hasBigInt = () => typeof BigInt === "function";
export {
hasBigInt
};

@@ -1,1 +0,4 @@

export const hasCrypto = () => typeof window !== "undefined" && window["crypto"] !== undefined;
const hasCrypto = () => typeof window !== "undefined" && window["crypto"] !== void 0;
export {
hasCrypto
};

@@ -1,1 +0,4 @@

export const hasMaxLength = (len, x) => x != null && x.length <= len;
const hasMaxLength = (len, x) => x != null && x.length <= len;
export {
hasMaxLength
};

@@ -1,1 +0,4 @@

export const hasMinLength = (len, x) => x != null && x.length >= len;
const hasMinLength = (len, x) => x != null && x.length >= len;
export {
hasMinLength
};
import { isFunction } from "./is-function.js";
export const hasPerformance = () => typeof performance !== "undefined" && isFunction(performance.now);
const hasPerformance = () => typeof performance !== "undefined" && isFunction(performance.now);
export {
hasPerformance
};

@@ -1,4 +0,4 @@

export const hasWASM = () => (typeof window !== "undefined" &&
typeof window["WebAssembly"] !== "undefined") ||
(typeof global !== "undefined" &&
typeof global["WebAssembly"] !== "undefined");
const hasWASM = () => typeof window !== "undefined" && typeof window["WebAssembly"] !== "undefined" || typeof global !== "undefined" && typeof global["WebAssembly"] !== "undefined";
export {
hasWASM
};

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

export const hasWebGL = () => {
try {
document.createElement("canvas").getContext("webgl");
return true;
}
catch (e) {
return false;
}
const hasWebGL = () => {
try {
document.createElement("canvas").getContext("webgl");
return true;
} catch (e) {
return false;
}
};
export {
hasWebGL
};

@@ -1,1 +0,4 @@

export const hasWebSocket = () => typeof WebSocket !== "undefined";
const hasWebSocket = () => typeof WebSocket !== "undefined";
export {
hasWebSocket
};

@@ -1,1 +0,4 @@

export const implementsFunction = (x, fn) => x != null && typeof x[fn] === "function";
const implementsFunction = (x, fn) => x != null && typeof x[fn] === "function";
export {
implementsFunction
};

@@ -1,3 +0,8 @@

export const isAlpha = (x) => /^[a-z]+$/i.test(x);
export const isAlphaNum = (x) => /^[a-z0-9]+$/i.test(x);
export const isNumeric = (x) => /^[0-9]+$/.test(x);
const isAlpha = (x) => /^[a-z]+$/i.test(x);
const isAlphaNum = (x) => /^[a-z0-9]+$/i.test(x);
const isNumeric = (x) => /^[0-9]+$/.test(x);
export {
isAlpha,
isAlphaNum,
isNumeric
};

@@ -1,1 +0,4 @@

export const isArray = Array.isArray;
const isArray = Array.isArray;
export {
isArray
};

@@ -1,1 +0,4 @@

export const isArrayLike = (x) => x != null && typeof x !== "function" && x.length !== undefined;
const isArrayLike = (x) => x != null && typeof x !== "function" && x.length !== void 0;
export {
isArrayLike
};

@@ -1,12 +0,6 @@

/**
* Returns true iff all chars are in ASCII range [0x00 .. 0x7f]
*
* @param x -
*/
export const isASCII = (x) => /^[\x00-\x7f]+$/.test(x);
/**
* Returns true iff all chars are in printable ASCII range [0x20 .. 0x7e]
*
* @param x -
*/
export const isPrintableASCII = (x) => /^[\x20-\x7e]+$/.test(x);
const isASCII = (x) => /^[\x00-\x7f]+$/.test(x);
const isPrintableASCII = (x) => /^[\x20-\x7e]+$/.test(x);
export {
isASCII,
isPrintableASCII
};

@@ -1,1 +0,4 @@

export const isAsyncIterable = (x) => x != null && typeof x[Symbol.asyncIterator] === "function";
const isAsyncIterable = (x) => x != null && typeof x[Symbol.asyncIterator] === "function";
export {
isAsyncIterable
};

@@ -1,1 +0,4 @@

export const isBigInt = (x) => typeof x === "bigint";
const isBigInt = (x) => typeof x === "bigint";
export {
isBigInt
};

@@ -1,1 +0,4 @@

export const isBlob = (x) => x instanceof Blob;
const isBlob = (x) => x instanceof Blob;
export {
isBlob
};

@@ -1,1 +0,4 @@

export const isBoolean = (x) => typeof x === "boolean";
const isBoolean = (x) => typeof x === "boolean";
export {
isBoolean
};

@@ -1,1 +0,4 @@

export const isChrome = () => typeof window !== "undefined" && !!window["chrome"];
const isChrome = () => typeof window !== "undefined" && !!window["chrome"];
export {
isChrome
};

@@ -1,1 +0,4 @@

export const isDataURL = (x) => /^data:.+\/(.+);base64,/.test(x);
const isDataURL = (x) => /^data:.+\/(.+);base64,/.test(x);
export {
isDataURL
};

@@ -1,1 +0,4 @@

export const isDate = (x) => x instanceof Date;
const isDate = (x) => x instanceof Date;
export {
isDate
};

@@ -1,1 +0,4 @@

export const isEven = (x) => x % 2 === 0;
const isEven = (x) => x % 2 === 0;
export {
isEven
};

@@ -1,1 +0,4 @@

export const isFalse = (x) => x === false;
const isFalse = (x) => x === false;
export {
isFalse
};

@@ -1,1 +0,4 @@

export const isFile = (x) => x instanceof File;
const isFile = (x) => x instanceof File;
export {
isFile
};

@@ -1,1 +0,4 @@

export const isFirefox = () => typeof window !== "undefined" && !!window["InstallTrigger"];
const isFirefox = () => typeof window !== "undefined" && !!window["InstallTrigger"];
export {
isFirefox
};
const RE = /^(?:[-+]?(?:[0-9]+))?(?:\.[0-9]*)?(?:[eE][\+\-]?(?:[0-9]+))?$/;
export const isFloatString = (x) => x.length > 0 && RE.test(x);
const isFloatString = (x) => x.length > 0 && RE.test(x);
export {
isFloatString
};

@@ -1,1 +0,4 @@

export const isFunction = (x) => typeof x === "function";
const isFunction = (x) => typeof x === "function";
export {
isFunction
};
import { implementsFunction } from "./implements-function.js";
import { isIterable } from "./is-iterable.js";
/**
* Returns true if `x` is an instantiated ES6 generator (i.e. it
* {@link isIterable} and {@link implementsFunction} `next`).
*
* @param x
*/
export const isGenerator = (x) => isIterable(x) && implementsFunction(x, "next");
const isGenerator = (x) => isIterable(x) && implementsFunction(x, "next");
export {
isGenerator
};
import { isString } from "./is-string.js";
const RE = /^#([a-f0-9]{3}|[a-f0-9]{4}(?:[a-f0-9]{2}){0,2})$/i;
export const isHexColor = (x) => isString(x) && RE.test(x);
const isHexColor = (x) => isString(x) && RE.test(x);
export {
isHexColor
};

@@ -1,1 +0,4 @@

export const isHex = (x) => /^[a-f0-9]+$/i.test(x);
const isHex = (x) => /^[a-f0-9]+$/i.test(x);
export {
isHex
};

@@ -1,3 +0,4 @@

export const isIE = () => typeof document !== "undefined" &&
(typeof document["documentMode"] !== "undefined" ||
navigator.userAgent.indexOf("MSIE") > 0);
const isIE = () => typeof document !== "undefined" && (typeof document["documentMode"] !== "undefined" || navigator.userAgent.indexOf("MSIE") > 0);
export {
isIE
};

@@ -1,1 +0,4 @@

export const isInRange = (min, max, x) => x >= min && x <= max;
const isInRange = (min, max, x) => x >= min && x <= max;
export {
isInRange
};
const RE = /^(?:[-+]?(?:0|[1-9][0-9]*))$/;
export const isIntString = (x) => RE.test(x);
const isIntString = (x) => RE.test(x);
export {
isIntString
};

@@ -1,1 +0,4 @@

export const isInt32 = (x) => typeof x === "number" && (x | 0) === x;
const isInt32 = (x) => typeof x === "number" && (x | 0) === x;
export {
isInt32
};

@@ -1,1 +0,4 @@

export const isIterable = (x) => x != null && typeof x[Symbol.iterator] === "function";
const isIterable = (x) => x != null && typeof x[Symbol.iterator] === "function";
export {
isIterable
};

@@ -1,1 +0,4 @@

export const isMap = (x) => x instanceof Map;
const isMap = (x) => x instanceof Map;
export {
isMap
};

@@ -1,2 +0,6 @@

export const isMobile = () => typeof navigator !== "undefined" &&
/mobile|tablet|ip(ad|hone|od)|android|silk|crios/i.test(navigator.userAgent);
const isMobile = () => typeof navigator !== "undefined" && /mobile|tablet|ip(ad|hone|od)|android|silk|crios/i.test(
navigator.userAgent
);
export {
isMobile
};

@@ -1,1 +0,4 @@

export const isNaN = (x) => x !== x;
const isNaN = (x) => x !== x;
export {
isNaN
};

@@ -1,1 +0,4 @@

export const isNegative = (x) => typeof x === "number" && x < 0;
const isNegative = (x) => typeof x === "number" && x < 0;
export {
isNegative
};

@@ -1,5 +0,4 @@

/**
* Checks if x is null or undefined.
*
*/
export const isNil = (x) => x == null;
const isNil = (x) => x == null;
export {
isNil
};

@@ -1,3 +0,4 @@

export const isNode = () => typeof process === "object" &&
typeof process.versions === "object" &&
typeof process.versions.node !== "undefined";
const isNode = () => typeof process === "object" && typeof process.versions === "object" && typeof process.versions.node !== "undefined";
export {
isNode
};

@@ -1,3 +0,4 @@

export const isNotStringAndIterable = (x) => x != null &&
typeof x !== "string" &&
typeof x[Symbol.iterator] === "function";
const isNotStringAndIterable = (x) => x != null && typeof x !== "string" && typeof x[Symbol.iterator] === "function";
export {
isNotStringAndIterable
};

@@ -1,1 +0,4 @@

export const isNull = (x) => x === null;
const isNull = (x) => x === null;
export {
isNull
};

@@ -1,1 +0,4 @@

export const isNumber = (x) => typeof x === "number";
const isNumber = (x) => typeof x === "number";
export {
isNumber
};

@@ -1,14 +0,6 @@

/**
* Returns true if given string contains only digits, and optionally, a sign
* prefix.
*
* @param x -
*/
export const isNumericInt = (x) => /^[-+]?\d+$/.test(x);
/**
* Returns true if given string only contains an integer or floating point
* number, optionally in scientific notiation (e.g. `-123.45e-6`).
*
* @param x -
*/
export const isNumericFloat = (x) => /^[-+]?\d*\.?\d+(e[-+]?\d+)?$/i.test(x);
const isNumericInt = (x) => /^[-+]?\d+$/.test(x);
const isNumericFloat = (x) => /^[-+]?\d*\.?\d+(e[-+]?\d+)?$/i.test(x);
export {
isNumericFloat,
isNumericInt
};

@@ -1,1 +0,4 @@

export const isObject = (x) => x !== null && typeof x === "object";
const isObject = (x) => x !== null && typeof x === "object";
export {
isObject
};

@@ -1,1 +0,4 @@

export const isOdd = (x) => x % 2 !== 0;
const isOdd = (x) => x % 2 !== 0;
export {
isOdd
};
const OBJP = Object.getPrototypeOf;
/**
* Similar to {@link isObject}, but also checks if prototype is that of
* `Object` (or `null`).
*
* @param x -
*/
export const isPlainObject = (x) => {
let p;
return (x != null &&
typeof x === "object" &&
((p = OBJP(x)) === null || OBJP(p) === null));
const isPlainObject = (x) => {
let p;
return x != null && typeof x === "object" && ((p = OBJP(x)) === null || OBJP(p) === null);
};
export {
isPlainObject
};

@@ -1,1 +0,4 @@

export const isPositive = (x) => typeof x === "number" && x > 0;
const isPositive = (x) => typeof x === "number" && x > 0;
export {
isPositive
};

@@ -1,9 +0,7 @@

/**
* Returns true if `x` is a string, number or boolean.
*
* @param x -
*/
export const isPrimitive = (x) => {
const t = typeof x;
return t === "string" || t === "number" || t === "boolean";
const isPrimitive = (x) => {
const t = typeof x;
return t === "string" || t === "number" || t === "boolean";
};
export {
isPrimitive
};

@@ -1,1 +0,4 @@

export const isPromise = (x) => x instanceof Promise;
const isPromise = (x) => x instanceof Promise;
export {
isPromise
};
import { implementsFunction } from "./implements-function.js";
export const isPromiseLike = (x) => x instanceof Promise ||
(implementsFunction(x, "then") && implementsFunction(x, "catch"));
const isPromiseLike = (x) => x instanceof Promise || implementsFunction(x, "then") && implementsFunction(x, "catch");
export {
isPromiseLike
};
import { isArray } from "./is-array.js";
import { isString } from "./is-string.js";
const ILLEGAL_KEYS = new Set(["__proto__", "prototype", "constructor"]);
/**
* Returns true, if given `x` is an illegal object key as per
* {@link ILLEGAL_KEYS}.
*
* @see {@link isProtoPath} for more details
*
* @param x -
*/
export const isIllegalKey = (x) => ILLEGAL_KEYS.has(x);
/**
* Returns true if given `path` contains any {@link ILLEGAL_KEYS}, i.e. could be
* used to poison the prototype chain of an object.
*
* @remarks
* If given an array, each item is considered a single sub-path property and
* will be checked as is. If given a string it will be split using "." as
* delimiter and each item checked as is (same way array paths are handled).
*
* Original discussion here, implementation updated to be more encompassing:
* https://github.com/thi-ng/umbrella/pull/273
*
* @param path -
*/
export const isProtoPath = (path) => isArray(path)
? path.some(isIllegalKey)
: isString(path)
? path.indexOf(".") !== -1
? path.split(".").some(isIllegalKey)
: isIllegalKey(path)
: false;
const ILLEGAL_KEYS = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
const isIllegalKey = (x) => ILLEGAL_KEYS.has(x);
const isProtoPath = (path) => isArray(path) ? path.some(isIllegalKey) : isString(path) ? path.indexOf(".") !== -1 ? path.split(".").some(isIllegalKey) : isIllegalKey(path) : false;
export {
isIllegalKey,
isProtoPath
};

@@ -1,1 +0,4 @@

export const isRegExp = (x) => x instanceof RegExp;
const isRegExp = (x) => x instanceof RegExp;
export {
isRegExp
};
import { isChrome } from "./is-chrome.js";
export const isSafari = () => typeof navigator !== "undefined" &&
/Safari/.test(navigator.userAgent) &&
!isChrome();
const isSafari = () => typeof navigator !== "undefined" && /Safari/.test(navigator.userAgent) && !isChrome();
export {
isSafari
};

@@ -1,1 +0,4 @@

export const isSet = (x) => x instanceof Set;
const isSet = (x) => x instanceof Set;
export {
isSet
};

@@ -1,1 +0,4 @@

export const isString = (x) => typeof x === "string";
const isString = (x) => typeof x === "string";
export {
isString
};

@@ -1,1 +0,4 @@

export const isSymbol = (x) => typeof x === "symbol";
const isSymbol = (x) => typeof x === "symbol";
export {
isSymbol
};

@@ -1,8 +0,4 @@

/**
* On Firefox `TouchEvent` is undefined if the hardware doesn't support touch.
* Therefore this predicate checks for that first before verifying if `e` is
* indeed a `TouchEvent`.
*
* @param e
*/
export const isTouchEvent = (e) => typeof TouchEvent !== "undefined" && e instanceof TouchEvent;
const isTouchEvent = (e) => typeof TouchEvent !== "undefined" && e instanceof TouchEvent;
export {
isTouchEvent
};

@@ -1,4 +0,4 @@

export const isTransferable = (x) => x instanceof ArrayBuffer ||
(typeof SharedArrayBuffer !== "undefined" &&
x instanceof SharedArrayBuffer) ||
(typeof MessagePort !== "undefined" && x instanceof MessagePort);
const isTransferable = (x) => x instanceof ArrayBuffer || typeof SharedArrayBuffer !== "undefined" && x instanceof SharedArrayBuffer || typeof MessagePort !== "undefined" && x instanceof MessagePort;
export {
isTransferable
};

@@ -1,1 +0,4 @@

export const isTrue = (x) => x === true;
const isTrue = (x) => x === true;
export {
isTrue
};

@@ -1,10 +0,4 @@

export const isTypedArray = (x) => !!x &&
(x instanceof Float32Array ||
x instanceof Float64Array ||
x instanceof Uint32Array ||
x instanceof Int32Array ||
x instanceof Uint8Array ||
x instanceof Int8Array ||
x instanceof Uint16Array ||
x instanceof Int16Array ||
x instanceof Uint8ClampedArray);
const isTypedArray = (x) => !!x && (x instanceof Float32Array || x instanceof Float64Array || x instanceof Uint32Array || x instanceof Int32Array || x instanceof Uint8Array || x instanceof Int8Array || x instanceof Uint16Array || x instanceof Int16Array || x instanceof Uint8ClampedArray);
export {
isTypedArray
};

@@ -1,1 +0,4 @@

export const isUint32 = (x) => typeof x === "number" && x >>> 0 === x;
const isUint32 = (x) => typeof x === "number" && x >>> 0 === x;
export {
isUint32
};

@@ -1,1 +0,4 @@

export const isUndefined = (x) => x === undefined;
const isUndefined = (x) => x === void 0;
export {
isUndefined
};
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) => RE.test(x);
const isUUID = (x) => RE.test(x);
export {
isUUID
};
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) => RE.test(x);
const isUUIDv4 = (x) => RE.test(x);
export {
isUUIDv4
};

@@ -1,1 +0,4 @@

export const isZero = (x) => x === 0;
const isZero = (x) => x === 0;
export {
isZero
};
{
"name": "@thi.ng/checks",
"version": "3.4.11",
"version": "3.4.12",
"description": "Collection of 70+ type, feature & value checks",

@@ -31,3 +31,5 @@ "type": "module",

"scripts": {
"build": "yarn clean && tsc --declaration",
"build": "yarn build:esbuild && yarn build:decl",
"build:decl": "tsc --declaration --emitDeclarationOnly",
"build:esbuild": "esbuild --format=esm --platform=neutral --target=es2022 --tsconfig=tsconfig.json --outdir=. src/**/*.ts",
"clean": "rimraf --glob '*.js' '*.d.ts' '*.map' doc",

@@ -46,2 +48,3 @@ "doc": "typedoc --excludePrivate --excludeInternal --out doc src/index.ts",

"@types/node": "^20.10.2",
"esbuild": "^0.19.8",
"rimraf": "^5.0.5",

@@ -282,3 +285,3 @@ "tools": "^0.0.1",

},
"gitHead": "25f2ac8ff795a432a930119661b364d4d93b59a0\n"
"gitHead": "5e7bafedfc3d53bc131469a28de31dd8e5b4a3ff\n"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc