New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

if-const

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

if-const - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

2

package.json
{
"name": "if-const",
"version": "1.1.1",
"version": "1.1.2",
"sideEffects": false,

@@ -5,0 +5,0 @@ "description": "Executes blocks of code depending on thruthness of the value, while also making the value accessible to the block",

@@ -11,7 +11,61 @@ export type Falsy = null | undefined | false | 0 | '';

type IfConst<U = Falsy> = {
/**
* Remembers the value to check later with a comparator
*
* @param value - the value to lazily check later
* @returns a function that accepts two checking branches
*/
<T>(value: T): {
/**
* Checks if the value is truthy for current comparator.
* If it is, then the callback is executed.
*
* If a callback returns a value,
* it will be passed on as the return value of the whole function.
*
* The function will return `undefined` otherwise.
*
* @param f - a callback to execute if comparator yields true
* @returns value returned from f, or `undefined`
*/
<R>(f: F<T, R, U>): R | undefined
/**
* Checks if the value is truthy for current comporator.
* One of the two callbacks is executed based on the result.
*
* If a callback returns a value,
* it will be passed on as the return value of the whole function.
*
* @param f - a callback to execute if comparator yields true
* @param elf - a callback to execute if comparator yields false
* @returns value returned from f or elf
*/
<R>(f: F<T, R, U>, elf: ELF<T, R, U>): R;
}
/**
* Checks if the value is truthy for current comparator.
* If it is, then the callback is executed.
*
* If a callback returns a value,
* it will be passed on as the return value of the whole function.
*
* The function will return `undefined` otherwise.
*
* @param value - the value to check against the comparator
* @param f - a callback to execute if comparator yields true
* @returns value returned from f, or `undefined`
*/
<T, R>(value: T, f: F<T, R, U>): R | undefined;
/**
* Checks if the value is truthy for current comporator.
* One of the two callbacks is executed based on the result.
*
* If a callback returns a value,
* it will be passed on as the return value of the whole function.
*
* @param value - the value to check against the comparator
* @param f - a callback to execute if comparator yields true
* @param elf - a callback to execute if comparator yields false
* @returns value returned from f or elf
*/
<T, R>(value: T, f: F<T, R, U>, elf: ELF<T, R, U>): R;

@@ -34,4 +88,25 @@ <T, R>(value: T, f?: F<T, R, U>, elf?: ELF<T, R, U>): R | undefined;

export const ifConst: IfConst & {
/**
* Changes the default comparator
* to one that checks if the input is not equal (`!==`)
* to the passed value.
*
* Serves as a way to type-safely inject a new comparator into the `ifConst` function.
*
* @param value - the value to negatively check against
* @returns IfConst - with the new comparator in-place
*/
not<U>(value: U): IfConst<U>;
/**
* Changes the default comparator
* to one that checks if the passed function yields true
* for the current input.
*
* Serves as a way to type-safely inject a new comparator into the `ifConst` function.
*
* @param comparator - the function to use as a new comparator
* @returns IfConst - with the new comparator in-place
*/
compare<U>(comparator: Comparator): IfConst<U>;
not<U>(value: U): IfConst<U>;
} = _ifConst.bind({ check: defaultComp }) as any;

@@ -38,0 +113,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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