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

@resourcexjs/core

v1.1.0

Published

ResourceX Core - Resource management layer

Readme

@resourcexjs/core

Core data structures for ResourceX.

Note: For most use cases, use the main resourcexjs package. This package is for advanced usage.

Installation

npm install @resourcexjs/core
# or
bun add @resourcexjs/core

What's Inside

Core building blocks - pure data structures:

  • RXL (Locator) - Resource locator string parser
  • RXM (Manifest) - Resource metadata
  • RXC (Content) - Stream-based content
  • RXR (Resource) - Complete resource type
  • Errors - Error hierarchy

API

RXL - Resource Locator

Parse resource locator strings. Format: [domain/path/]name[.type][@version]

import { parseRXL } from "@resourcexjs/core";

const rxl = parseRXL("deepractice.ai/sean/[email protected]");

rxl.domain; // "deepractice.ai"
rxl.path; // "sean"
rxl.name; // "assistant"
rxl.type; // "prompt"
rxl.version; // "1.0.0"
rxl.toString(); // "deepractice.ai/sean/[email protected]"

Minimal locator:

parseRXL("[email protected]");
// → domain: "localhost", path: undefined, name: "name", type: "text", version: "1.0.0"

RXM - Resource Manifest

Create and validate resource metadata:

import { createRXM } from "@resourcexjs/core";

const manifest = createRXM({
  domain: "deepractice.ai",
  path: "sean", // optional
  name: "assistant",
  type: "prompt",
  version: "1.0.0",
  description: "Optional description", // optional
  tags: ["optional", "tags"], // optional
});

manifest.toLocator(); // → "deepractice.ai/sean/[email protected]"
manifest.toJSON(); // → plain object

Required fields: name, type, version

Optional fields: domain (default: "localhost"), path, description, tags

RXC - Resource Content

Archive-based content (internally tar.gz), supports single or multi-file resources:

import { createRXC } from "@resourcexjs/core";

// Single file
const content = await createRXC({ content: "Hello, World!" });

// Multiple files
const content = await createRXC({
  "index.ts": "export default 1",
  "styles.css": "body {}",
});

// Nested directories
const content = await createRXC({
  "src/index.ts": "main code",
  "src/utils/helper.ts": "helper code",
});

// From existing tar.gz archive (for deserialization)
const content = await createRXC({ archive: tarGzBuffer });

// Read files
const buffer = await content.file("content"); // → Buffer
const buffer = await content.file("src/index.ts"); // → Buffer
const files = await content.files(); // → Map<string, Buffer>
const archiveBuffer = await content.buffer(); // → raw tar.gz Buffer
const stream = content.stream; // → ReadableStream (tar.gz)

RXR - Resource

Complete resource object (pure interface):

import type { RXR } from "@resourcexjs/core";

interface RXR {
  locator: RXL;
  manifest: RXM;
  content: RXC;
}

// Create from literals
const rxr: RXR = { locator, manifest, content };

RXR is a pure DTO (Data Transfer Object) - no factory function needed.

Error Handling

import { ResourceXError, LocatorError, ManifestError, ContentError } from "@resourcexjs/core";

try {
  parseRXL("invalid-locator");
} catch (error) {
  if (error instanceof LocatorError) {
    console.error("Invalid locator format");
  }
}

try {
  createRXM({ name: "test" }); // Missing required fields
} catch (error) {
  if (error instanceof ManifestError) {
    console.error("Invalid manifest");
  }
}

try {
  await content.text();
  await content.text(); // Second consumption
} catch (error) {
  if (error instanceof ContentError) {
    console.error("Content already consumed");
  }
}

Error Hierarchy

ResourceXError (base)
├── LocatorError
├── ManifestError
└── ContentError

Examples

Complete Resource Creation

import { parseRXL, createRXM, createRXC } from "@resourcexjs/core";
import type { RXR } from "@resourcexjs/core";

// Create manifest
const manifest = createRXM({
  domain: "deepractice.ai",
  name: "assistant",
  type: "prompt",
  version: "1.0.0",
});

// Create locator from manifest
const locator = parseRXL(manifest.toLocator());

// Create content (single file)
const content = await createRXC({ content: "You are a helpful assistant." });

// Assemble RXR
const rxr: RXR = {
  locator,
  manifest,
  content,
};

Multi-file Resource

import { createRXC } from "@resourcexjs/core";

// Create multi-file content
const content = await createRXC({
  "prompt.md": "# System Prompt\nYou are...",
  "config.json": '{"temperature": 0.7}',
});

// Read individual files
const promptBuffer = await content.file("prompt.md");
const configBuffer = await content.file("config.json");

// Read all files
const allFiles = await content.files();
for (const [path, buffer] of allFiles) {
  console.log(path, buffer.toString());
}

Manifest Serialization

const manifest = createRXM({
  name: "assistant",
  type: "prompt",
  version: "1.0.0",
});

// To JSON (for storage)
const json = manifest.toJSON();
/*
{
  "domain": "localhost",
  "name": "assistant",
  "type": "prompt",
  "version": "1.0.0"
}
*/

// To locator string
const locator = manifest.toLocator();
// "localhost/[email protected]"

Related Packages

This package provides only data structures. For full functionality:

Type Safety

All types are fully typed with TypeScript:

import type { RXL, RXM, RXC, RXR } from "@resourcexjs/core";

const locator: RXL = parseRXL("...");
const manifest: RXM = createRXM({ ... });
const content: RXC = createRXC("...");
const resource: RXR = { locator, manifest, content };

License

MIT