npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@svgfwjs/err

v1.0.0

Published

[ [README на русском](README_ru.md) ]

Downloads

2

Readme

[ README на русском ]

JS Error with reduced Stack Trace

V8 JavaScript engine introduced stack trace into Error objects and gave ability to manipulate it with Error.captureStackTrace() static method. This gives opportunity for developing own API and libraries which has functions that throws Errors to cut off parts of the stack trace which points to the API/library and make focus on code that used its functions wrong.

This package of my personal framework provides function that creates and returns an Error instance and reduces the stack trace to function that throws that Error instance. It's part of my personal framework as core component that is used in other packages, however, You may use it in Your code or projects.

Usage

npm i @svgfwjs/err

Syntax

err('Error Message.', callerFunction, ErrorType, optionsOrFileName, lineNumber)
  • callerFunction is the function that throws an error which is used for stack trace reduction
  • ErrorType is the type of error that was chosen to be thrown.

It should be any of Error objects that exists in JavaScript or it may be own custom Error.

  • optionsOrFileName - this argument is being passed to Error constructor alongside with 'Error Message.'. It can be object that has cause property/key or string that is path to the file.
  • lineNumber is the number of the line in the file (which also is being passed to Error constructor)

The thing is: file name and line number parameters/arguments are mostly usable in certain web browsers. Node and other alike runtime enviroments doesn't use those parameters/arguments.

All parameters/arguments are optional, just like in Error constructor.

Back-end

import { err } from '@svgfwjs/err'

function yourCoolFunction() {
    if ( somethingIncorrect )
        throw err('You did it wrong!', yourCoolFunction)
}

yourCoolFunction()
// Will result as following:
// yourCoolFunction()
// ^
// 
// Error: You did it wrong!
//     at file:///.../yourCoolScript.js:8:1

Front-end

<script src="https://svg.moe/js/err.js"></script>
<script>
function yourCoolFunction() {
    if ( somethingIncorrect )
        throw svgfwjs.err('You did it wrong!', yourCoolFunction)
}

yourCoolFunction()
// Will result as following:
// Uncaught Error: You did it wrong!
//     at index.html:13:1
</script>

As bundle-able module

import err from '@svgfwjs/err'