
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
causality-error
Advanced tools
Go-like errors.Is
utility for JavaScript/TypeScript.
# npm
npm install causality-error
# yarn
yarn add causality-error
# pnpm
pnpm add causality-error
import { is } from 'causality-error';
// Example 1: Check if an error is an instance of a specific constructor
try {
JSON.parse('invalid json');
} catch (err) {
if (is(err, SyntaxError)) {
console.log('Caught a SyntaxError');
}
}
// Example 2: Check for a specific error instance
const specificError = new Error('specific error');
const wrappedError = new Error('wrapper', { cause: specificError });
if (is(wrappedError, specificError)) {
console.log('Found the specific error in the cause chain');
}
// Example 3: Check using a predicate function
const fsError = Object.assign(new Error('file not found'), { code: 'ENOENT' });
const wrappedFsError = new Error('operation failed', { cause: fsError });
if (is(wrappedFsError, e => (e as any).code === 'ENOENT')) {
console.log('Found a file not found error');
}
// Example 4: Works with AggregateError
const aggregateError = new AggregateError(
[new TypeError('bad type'), new RangeError('bad range')],
'multiple errors'
);
if (is(aggregateError, RangeError)) {
console.log('Found a RangeError in the aggregate error');
}
is(err, target)
Checks if err
matches target
anywhere in its cause chain.
err: unknown
- The error to checktarget: unknown | ErrorCtor | ErrorPredicate
- The target to match against, which can be:
instanceof
)boolean
- true
if the error matches the target, false
otherwiseMIT
FAQs
Go-like errors.Is utility for JavaScript/TypeScript
The npm package causality-error receives a total of 2 weekly downloads. As such, causality-error popularity was classified as not popular.
We found that causality-error demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.