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

ac-storage

v0.17.0

Published

```bash pnpm add ac-storage ```

Readme

AC-Storage

Install

pnpm add ac-storage

Example

import { ACStorage, StorageAccess } from 'ac-storage';

const storage = new ACStorage('./store');
storage.register({
  'auth' : {
    'default.json' : StorageAccess.JSON(),
  },
  'cache' : {
    'last_access.txt' : StorageAccess.Text(),
  }
});

const authAC = await storage.accessAsJSON('auth:default.json');
authAC.setOne('id', 'user');

const lastAccessAC = await storage.accessAsText('cache:last_access.txt');
lastAccessAC.write('20250607');

await storage.commit();

API

ACStorage

Storage instance that manages file access with access control.

Constructor

new ACStorage(basePath: string, options?: {
  cacheName?: string;
  noCache?: boolean;
})

Methods

register(tree: AccessTree): void
Register file access permissions. Must be called before accessing files.

File Access Methods

create(identifier: string, accessType: string): Promise<Accessor>
Create a new file. Throws error if file already exists.

createAsJSON(identifier: string): Promise<IJSONAccessor>
Create a new JSON file.

createAsText(identifier: string): Promise<ITextAccessor>
Create a new text file.

createAsBinary(identifier: string): Promise<IBinaryAccessor>
Create a new binary file.

open(identifier: string, accessType: string): Promise<Accessor>
Open an existing file. Throws error if file does not exist.

openAsJSON(identifier: string): Promise<IJSONAccessor>
Open an existing JSON file.

openAsText(identifier: string): Promise<ITextAccessor>
Open an existing text file.

openAsBinary(identifier: string): Promise<IBinaryAccessor>
Open an existing binary file.

access(identifier: string, accessType: string): Promise<Accessor>
Access a file - creates if missing, opens if exists (default behavior).

accessAsJSON(identifier: string): Promise<IJSONAccessor>
Access a JSON file.

accessAsText(identifier: string): Promise<ITextAccessor>
Access a text file.

accessAsBinary(identifier: string): Promise<IBinaryAccessor>
Access a binary file.

Access Methods Comparison

| Method | Creates if Missing | Loads if Exists | Error if Missing | Error if Exists | |--------|-------------------|-----------------|------------------|-----------------| | create() | ✅ | ❌ | N/A | ✅ | | open() | ❌ | ✅ | ✅ | N/A | | access() | ✅ | ✅ | ❌ | ❌ |

Example:

// Create only - throws if file already exists
const config = await storage.createAsJSON('config.json');

// Open only - throws if file doesn't exist  
const existing = await storage.openAsJSON('config.json');

// Access - creates if missing, loads if exists
const flexible = await storage.accessAsJSON('config.json');

File Operations

copy(oldIdentifier: string, newIdentifier: string): Promise<void>
Copy a file from old identifier to new identifier.

move(oldIdentifier: string, newIdentifier: string): Promise<void>
Move a file from old identifier to new identifier.

Memory Management

drop(identifier: string): Promise<void>
Delete and unload a specific file from memory. Does not commit changes.

dropDir(identifier: string): Promise<void>
Delete and unload all files under the specified directory. Does not commit changes.

dropAll(): Promise<void>
Delete and unload all files. Does not commit changes.

release(identifier: string): Promise<void>
Commit changes and unload a file from memory. File remains on disk.

releaseDir(identifier: string): Promise<void>
Commit and unload all files under the specified directory. Files remain on disk.

releaseAll(): Promise<void>
Commit and unload all files from memory. Files remain on disk.

commit(identifier?: string): Promise<void>
Commit changes to the filesystem. If identifier is provided, commits that file and its dependencies.

commitAll(): Promise<void>
Commit all changes to the filesystem.

Operations Comparison

| Operation | Commits Changes | Removes from Memory | Deletes File | |-----------|----------------|---------------------|--------------| | commit() | ✅ | ❌ | ❌ | | release() | ✅ | ✅ | ❌ | | drop() | ❌ | ✅ | ✅ |

Example:

// Commit only - save changes but keep in memory
await storage.commit('config.json');

// Release - save and unload from memory (file persists)
await storage.release('config.json');

// Drop - delete file and unload (changes lost)
await storage.drop('temp.json');

subStorage(identifier: string): IACSubStorage
Create a sub-storage scoped to a specific directory prefix.

addAccessEvent(customId: string, event: AccessorEvent): void
Register a custom accessor type for handling custom file formats.

addListener(event: 'access' | 'destroy', listener: Function): void
Add event listeners for file access and destroy events.