DEV Community

Cover image for I published my first deno package
Christian Bewernitz
Christian Bewernitz

Posted on

I published my first deno package

Cover Image by Cmglee - Own work, CC BY-SA 3.0

What was it like to do that?

It was so much fun compared to all previous experiences of publishing a (typescript or javascript) package.

What made it really easy for me to get up to speed with deno:

Of course the experience to "just execute typescript" without having to first research the "currently best way to transpile the code in this use case", is just mind blowing again and again.

Instead of picking from tons of tools, I was regularly visiting the deno manual.
Even when I didn't expect something to be provided out of the box, regular searching pointed me to it.

Deno comes with a test runner and provides basic assertions that can also take care of collecting coverage data.
It also comes with a linter and a (code and docs and code in docs) formatter and there is more.

But the most fun part was publish the package:

  1. I claimed the library name. (I didn't need to create an account for that!)
  2. I followed the instructions to add webhook to my github repository
  3. I created a release on GitHub. This is the step that needs to be repeated to publish a new version.

(Did you know that the versions on https://deno.land/x are immutable and can not be dropped?)

So what package and why?

Thx for asking ;)

I recently analysed npm packages that are still using an insecure version of another library I'm maintaining, to judge if it makes sense to provide an upgrade PR. Since there are over 2000 dependents on all older versions, and at that point in time over 60 on the versions I care about, I needed to prioritize the packages. So I can first provide update the PRs that have a reasonable impact on reducing the usage and have a good chance of being merged.

I still have that idea "Maybe I just didn't use the correct search terms?", because I couldn't find any existing/similar library. If you know about something comparable please let me know.

GitHub logo karfau / scor

Calculate scores for numeric values or items, and get the "total score" (aka "arithmetic mean" or "weighted arithmetic mean") from multiple scores.

latest version of scor package on deno.land

scor

Calculate scores for numeric values or items, and get the "total score" (aka arithmetic mean or weighted arithmetic mean) from multiple scores.

Usage

Imagine you

  • have a long list of items to work on, and you want to prioritize them
  • want to show the most relevant items to a user before showing more

For example, let's look at npm packages. Possible criteria are:

  • number of maintainers
  • number of dependencies (direct/transient)
  • time since last published version
  • version (major < 1?) / dist-tags
  • weekly downloads
  • source code repo attributes (e.g. GitHub stars/forks)
  • quality?
  • ...?

The different relevant values come in very different "shapes". Once all the data is gathered per package, depending on the use case the different values are more or less relevant.

import {
  createToMean,
  distributeWeights,
  scorForItems,
} from "https://deno.land/x/scor/scor.ts";
import { getPackagesData } from "./npm.ts";
const packages = await getPackagesData()
Enter fullscreen mode Exit fullscreen mode

It was developed using TDD, so the coverage is 100%.

To use it in your deno code you can import it like this:

import {scor} from "https://deno.land/x/scor@v1.0.0/scor.ts";
Enter fullscreen mode Exit fullscreen mode

Make sure to use the latest version:
latest version of scor

I'm quite happy about the existing documentation (the readme and doc comments), so I won't repeat it here.

I'm really curious to see if it's understandable, so please let me know.

What' the name about?

Well, I checked for suitable names that are still available as an (unscoped) npm package.

So, are you going to publish it to npm?

Maybe, it's currently the last thing on my short list of todos.

First I want to collect some feedback, to see if it's worth the additional effort. If you think it is, feel free to create PR.

Top comments (1)

Collapse
 
jcs224 profile image
Joe Sweeney

I had a similar experience publishing packages for Deno. It's nice to not have to deal with NPM or go through a huge rigamarole just to release new code.