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

margins-stash-core

v0.2.0

Published

Shared Margins stash logic: config-dir resolution, the file→stash binding store with its trust rule, and the stash create/update recovery matrix.

Downloads

334

Readme

margins-stash-core

Shared internals of the Margins stash — a one-off, single-document workspace for review.

Two programs publish stashes: the margins CLI and the Margins Light daemon that backs the desktop app's Share button. They must reach the same stash from the same file, so the parts where they could silently disagree live here rather than twice:

  • Config directory resolution. MARGINS_CONFIG_DIR, then an existing $XDG_CONFIG_HOME/margins/, then the platform default. Two copies of this walk would eventually look in different places, and the symptom would be a daemon reporting "no API key" on a machine where margins auth plainly works.
  • The binding store. Which stash a file is bound to, the project-versus-global store choice, the trust rule for a binding this machine did not write, and the symlink guard on both.
  • The create/update recovery matrix. What a 403, a 404, a 405 and a 409 each mean for a bound file, and which of them may safely create a fresh stash.

It prompts nothing and prints nothing. Every outcome is a return value, and the two callers word it for their own user.

Install

npm install margins-stash-core

Use

import {
  createFetchStashHttp,
  resolveCredential,
  upsertStash,
  buildStashReviewUrl,
} from 'margins-stash-core'

const cred = resolveCredential()
if (!cred.ok) throw new Error(cred.problem) // NO_API_KEY | SESSION_ONLY

const result = await upsertStash({
  http: createFetchStashHttp({ serverUrl: cred.serverUrl, apiKey: cred.apiKey }),
  content: markdown,
  filePath: '/abs/path/to/notes.md', // omit for stdin: nothing to bind
  title: 'Notes',
  parentSha: lastKnownHead, // the server answers 409 rather than overwriting
})

if (!result.ok) {
  // UNAUTHORIZED | KEY_ROLE | OLD_SERVER | CONFLICT | SLUG_CONFLICT
  //   | VALIDATION | SERVER | NETWORK
  return handle(result.failure)
}
console.log(buildStashReviewUrl(cred.serverUrl, result.slug))

result.rebound means the bound stash was gone, foreign, or untrusted and a new one was created: the previous link is dead, and reboundReason says which of the three happened.

Publishing a stash needs an API key with the edit role. A margins auth login session is deliberately not accepted — see resolveCredential.

Licence

MIT