Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
@thi.ng/checks
Advanced tools
@thi.ng/checks is a utility library for various type checks and predicates in JavaScript. It provides a wide range of functions to check types, values, and conditions, making it easier to validate data and ensure code correctness.
Type Checks
This feature allows you to check the type of a given value. The `isString` function checks if the value is a string, and the `isNumber` function checks if the value is a number.
const { isString, isNumber } = require('@thi.ng/checks');
console.log(isString('hello')); // true
console.log(isNumber(123)); // true
console.log(isNumber('123')); // false
Array Checks
This feature provides functions to check if a value is an array and if an array is empty. The `isArray` function checks if the value is an array, and the `isEmptyArray` function checks if the array is empty.
const { isArray, isEmptyArray } = require('@thi.ng/checks');
console.log(isArray([1, 2, 3])); // true
console.log(isEmptyArray([])); // true
console.log(isEmptyArray([1])); // false
Object Checks
This feature includes functions to check if a value is an object and if an object is empty. The `isObject` function checks if the value is an object, and the `isEmptyObject` function checks if the object is empty.
const { isObject, isEmptyObject } = require('@thi.ng/checks');
console.log(isObject({ a: 1 })); // true
console.log(isEmptyObject({})); // true
console.log(isEmptyObject({ a: 1 })); // false
Function Checks
This feature provides a function to check if a value is a function. The `isFunction` function checks if the value is a function.
const { isFunction } = require('@thi.ng/checks');
console.log(isFunction(function() {})); // true
console.log(isFunction(() => {})); // true
console.log(isFunction(123)); // false
String Checks
This feature includes functions to check if a value is a string and if a string is empty. The `isString` function checks if the value is a string, and the `isEmptyString` function checks if the string is empty.
const { isString, isEmptyString } = require('@thi.ng/checks');
console.log(isString('hello')); // true
console.log(isEmptyString('')); // true
console.log(isEmptyString('hello')); // false
Lodash is a modern JavaScript utility library delivering modularity, performance, and extras. It provides a wide range of utility functions for common programming tasks, including type checks, which are similar to those provided by @thi.ng/checks.
Ramda is a practical functional library for JavaScript programmers. It provides utility functions for functional programming, including type checks and predicates, similar to @thi.ng/checks.
Validator is a library for string validation and sanitization. While it focuses more on string validation, it also provides some type-checking functions similar to those in @thi.ng/checks.
Check-types is a library for checking types and conditions in JavaScript. It provides a similar range of type-checking functions as @thi.ng/checks, making it a good alternative.
This project is part of the @thi.ng/umbrella monorepo.
Collection of 70+ type, feature & value checks.
STABLE - used in production
Search or submit any issues for this package
yarn add @thi.ng/checks
ES module import:
<script type="module" src="https://cdn.skypack.dev/@thi.ng/checks"></script>
For Node.js REPL:
# with flag only for < v16
node --experimental-repl-await
> const checks = await import("@thi.ng/checks");
Package sizes (gzipped, pre-treeshake): ESM: 1.72 KB
TODO
If this project contributes to an academic publication, please cite it as:
@misc{thing-checks,
title = "@thi.ng/checks",
author = "Karsten Schmidt and others",
note = "https://thi.ng/checks",
year = 2016
}
© 2016 - 2022 Karsten Schmidt // Apache Software License 2.0
FAQs
Collection of 70+ type, feature & value checks
The npm package @thi.ng/checks receives a total of 129,118 weekly downloads. As such, @thi.ng/checks popularity was classified as popular.
We found that @thi.ng/checks demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.