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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@stayradiated/pkg

v5.8.0

Published

Utils for creating, building and testing NPM packages

Downloads

17

Readme

PKG

My scripts for writing typescript code.

Installation

npm install --save-dev @stayradiated/pkg

Recommended Scripts

Copy the following into your package.json.

"scripts": {
  "build": "pkg-build",
  "lint": "pkg-lint",
  "tidy": "pkg-tidy",
  "test": "pkg-test",
  "precommit": "pkg-precommit"
}

Type declarations

If you need to use a 3rd party library that doesn't have typescript support, you can provide your own type declarations.

There are some strict rules you need to follow for this to work:

  1. You must only mock one dependency per file.
  2. You must place the file inside the ./src/types/ folder.
  3. The filename must be the same as the dependency name.
  4. The extension must be .d.ts.

For example, if you are providing types for file-exists, the types must be saved in ./src/types/file-exists.d.ts.

Providing Typescript types for a project written in JS

If you are manually adding types for a non-typescript project, you must keep your types in the root of your project, in a file named types.d.ts.

@stayradiated/package will not use the typescript compiler if your package.json contains the value: "types": "types.d.ts".

Lifecycle Test Helpers

AVA does not support "before all" or "after all" functions, because it runs everything in parallel.

Package has got your back though. If you need to setup/teardown a database, then this is for you.

Please note, that if you run AVA in watch mode, the "after all" function will not be called until you exit AVA.

Before All

Create a file called testHelpers/beforeAll.js in the root of your project, and it will be executed before the tests begin.

After All

Create a file called testHelpers/afterAll.js in the root of your project, and it will be executed after the tests finish.

It will be called regardless of whether the tests passed or failed.

Different Folder Structure

srcPath

If your code is kept in a folder that isn't src then you can change the path by adding the following to your package.json

"srcPath": "lib",

distPath

Would you like your compiled code to be in a folder that isn't named dist?

"distPath": "public"

testsPath

Tests must be defined inside the srcPath, and by default match any files that end in .spec.js.

"testsPath": "**/*.test.js",