Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
@bitty/predicate
Advanced tools
@bitty/predicate
Predicate
and Refinement
types for TypeScript.
This library is published in the NPM registry and can be installed using any compatible package manager.
npm install @bitty/predicate --save
# For Yarn, use the command below.
yarn add @bitty/predicate
It exports Predicate
and Refinement
types.
Predicate
is a function that receives a value and returns a boolean.
import type { Predicate } from '@bitty/predicate';
function checkAll<T = unknown>(predicates: Predicate<T>[]): Predicate<T> {
return (value) => predicates.every((predicate) => predicate(value));
}
Refinement
is similar to Predicate
, but uses TypeScript is
type guard.
import { Refinement } from '@bitty/predicate';
const isNumber: Refinement<unknown, number> = (value) =>
Number.isFinite(value);
//=> Was typed as `(value: unknown) => value is number`.
const value: number | string = Math.random() > 0.5 ? 100 : 'A text.';
if (isNumber(value)) {
console.log(value.toFixed(2));
//=> Okay, because type of `value` was refined to `number`.
}
console.log(value.toFixed(2));
//=> Property 'toFixed' does not exist on type 'string | number'.
// Property 'toFixed' does not exist on type 'string'.
Released under MIT License.
FAQs
Predicate helper functions and types for TypeScript.
We found that @bitty/predicate demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.