
Research
Trivy Under Attack Again: Widespread GitHub Actions Tag Compromise Exposes CI/CD Secrets
Attackers compromised Trivy GitHub Actions by force-updating tags to deliver malware, exposing CI/CD secrets across affected pipelines.
@xylabs/assert
Advanced tools
Base functionality used throughout XY Labs TypeScript/JavaScript libraries
@xylabs/assert
Implementation of assertDefinedEx that handles all overloads.
function assertDefinedEx<T>(expr, messageFunc?): T;
Asserts that a value is defined (not undefined) and returns the value. Throws an error if the value is undefined.
T
The type of value to check
Expression to be evaluated for being defined
undefined | T
AssertExMessageFunc<T>
Function that returns a message for the error if expression is undefined
T
The value of the expression (guaranteed to be defined)
Error with the message returned by messageFunc
// Simple usage with a message function
const value = assertDefinedEx(possiblyUndefined, () => 'Value must be defined')
// Using with type narrowing
const config: Config | undefined = loadConfig()
const safeConfig = assertDefinedEx(config, () => 'Config failed to load')
// safeConfig is now type Config (not Config | undefined)
function assertDefinedEx<T, R>(expr, errorFunc?): T;
Asserts that a value is defined (not undefined) and returns the value. Throws a custom error if the value is undefined.
T
The type of value to check
R extends Error
The type of error to throw
Expression to be evaluated for being defined
undefined | T
AssertExErrorFunc<T, R>
Function that returns a custom error instance if expression is undefined
T
The value of the expression (guaranteed to be defined)
Custom error returned by errorFunc
// Using with a custom error
const user = assertDefinedEx(getUser(), () => new UserNotFoundError('User not found'))
function assertDefinedEx<T>(expr): T;
Asserts that a value is defined (not undefined) and returns the value. Throws an error if the value is undefined.
T
The type of value to check
Expression to be evaluated for being defined
undefined | T
T
The value of the expression (guaranteed to be defined)
Use overload with message function instead - passing a message will soon be required
Error with a generic message
function assertDefinedEx<T>(expr, message?): T;
Asserts that a value is defined (not undefined) and returns the value. Throws an error with the provided message if the value is undefined.
T
The type of value to check
Expression to be evaluated for being defined
undefined | T
string
Error message if expression is undefined
T
The value of the expression (guaranteed to be defined)
Replace string with () => string for consistency
Error with the provided message
Implementation of assertEx that handles all overloads.
function assertEx<T>(expr, messageFunc?): T;
Asserts that an expression is truthy and returns the value. Throws an error if the expression is falsy.
T
The type of value to check
Expression to be evaluated for truthiness
undefined | null | T
AssertExMessageFunc<T>
Function that returns a message for the error if expression is falsy
T
The value of the expression (guaranteed to be truthy)
Error with the message returned by messageFunc
// Simple usage with a message function
const value = assertEx(possiblyFalsy, () => 'Value must be truthy')
// Using with type narrowing
const config: Config | null = loadConfig()
const safeConfig = assertEx(config, () => 'Config failed to load')
// safeConfig is now type Config (not Config | null)
function assertEx<T, R>(expr, errorFunc?): T;
Asserts that an expression is truthy and returns the value. Throws a custom error if the expression is falsy.
T
The type of value to check
R extends Error
The type of error to throw
Expression to be evaluated for truthiness
undefined | null | T
AssertExErrorFunc<T, R>
Function that returns a custom error instance if expression is falsy
T
The value of the expression (guaranteed to be truthy)
Custom error returned by errorFunc
// Using with a custom error
const user = assertEx(getUser(), () => new UserNotFoundError('User not found'))
function assertEx<T>(expr): T;
Asserts that an expression is truthy and returns the value. Throws an error if the expression is falsy.
T
The type of value to check
Expression to be evaluated for truthiness
undefined | null | T
T
The value of the expression (guaranteed to be truthy)
Use overload with message function instead - passing a message will soon be required
Error with a generic message
function assertEx<T>(expr, message?): T;
Asserts that an expression is truthy and returns the value. Throws an error with the provided message if the expression is falsy.
T
The type of value to check
Expression to be evaluated for truthiness
undefined | null | T
string
Error message if expression is falsy
T
The value of the expression (guaranteed to be truthy)
Replace string with () => string for consistency
Error with the provided message
Part of sdk-js
See the LICENSE file for license details
FAQs
Base functionality used throughout XY Labs TypeScript/JavaScript libraries
The npm package @xylabs/assert receives a total of 436 weekly downloads. As such, @xylabs/assert popularity was classified as not popular.
We found that @xylabs/assert demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 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
Attackers compromised Trivy GitHub Actions by force-updating tags to deliver malware, exposing CI/CD secrets across affected pipelines.

Security News
ENISA’s new package manager advisory outlines the dependency security practices companies will need to demonstrate as the EU’s Cyber Resilience Act begins enforcing software supply chain requirements.

Research
/Security News
We identified over 20 additional malicious extensions, along with over 20 related sleeper extensions, some of which have already been weaponized.