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

@aziontech/unenv-preset

v1.0.0

Published

Azion Unenv preset.

Downloads

343

Readme

Azion Unenv Preset

A preset configuration for unenv that provides polyfills and environment compatibility for Azion Edge Runtime.

Table of Contents

Installation

Install the package using npm or yarn:

npm install azion

or

yarn add azion

Usage

The preset can be used with unenv to provide compatibility between Node.js and Azion Edge Runtime environments:

import { preset } from '@aziontech/unenv-preset';
// Use with unenv
export default {
  preset: preset,
};

Features

Node.js Polyfills

This preset provides polyfills for common Node.js APIs to ensure compatibility when running code in the Azion Edge Runtime environment. The following modules are polyfilled:

  • crypto - Complete cryptographic functionality including hashing, encryption, and UUID generation
  • events - Event handling through events/events.js
  • http - HTTP client functionality via stream-http
  • module - Basic module system compatibility (limited functionality)
  • stream - Stream implementations via stream-browserify
  • string_decoder - String decoding utilities
  • url - URL parsing and formatting
  • util - Utility functions
  • timers - Timer functions via timers-browserify
  • vm - Virtual Machine functionality via vm-browserify
  • zlib - Compression functionality via browserify-zlib

Example using crypto polyfill:

import { createHash, randomUUID } from '@aziontech/unenv-preset/polyfills/node/crypto';

// Create a hash
const hash = createHash('sha256');
hash.update('some data');
console.log(hash.digest('hex'));

// Generate a UUID
const uuid = randomUUID();

File System Polyfills

The preset includes comprehensive file system polyfills that mirror Node.js's fs module functionality. These polyfills work with an in-memory file system when running in the Edge Runtime.

Basic File Operations

import { readFileSync, writeFileSync } from '@aziontech/unenv-preset/polyfills/node/fs';

// Read a file
const content = readFileSync('/path/to/file.txt', 'utf8');

// Write to a file
writeFileSync('/path/to/new-file.txt', 'Hello World', 'utf8');

Directory Operations

import { readdirSync, mkdirSync } from '@aziontech/unenv-preset/polyfills/node/fs';

// List directory contents
const files = readdirSync('/path/to/dir');

// Create a directory
mkdirSync('/path/to/new-dir');

File Stats and Information

import { statSync, existsSync } from '@aziontech/unenv-preset/polyfills/node/fs';

// Check if file exists
if (existsSync('/path/to/file.txt')) {
  // Get file stats
  const stats = statSync('/path/to/file.txt');
  console.log(`File size: ${stats.size}`);
  console.log(`Is directory: ${stats.isDirectory()}`);
  console.log(`Is file: ${stats.isFile()}`);
}

File Descriptors

import { openSync, closeSync, readSync } from '@aziontech/unenv-preset/polyfills/node/fs';

// Open file and get file descriptor
const fd = openSync('/path/to/file.txt', 'r');

// Read from file descriptor
const buffer = Buffer.alloc(1024);
readSync(fd, buffer, 0, 1024, 0);

// Close file descriptor
closeSync(fd);

Global Polyfills

The preset also provides polyfills for Node.js global variables and objects:

  • __dirname - Current directory name
  • __filename - Current file name
  • process - Process information and environment (including env variables)
  • performance - Performance timing functionality
  • navigator - Browser-compatible navigator object

The preset also handles injection of these globals through the unenv configuration:

import { preset } from '@aziontech/unenv-preset';

// Preset configuration automatically injects globals
export default {
  inject: {
    __dirname: preset.inject.__dirname,
    __filename: preset.inject.__filename,
    process: preset.inject.process,
    performance: preset.inject.performance,
    navigator: preset.inject.navigator,
  },
};

API Reference

getFileContent

Decodes file content and returns it as either a Buffer or string.

Parameters:

  • file - The file object containing content in base64 format
  • returnBuffer - (Optional) Boolean to determine return type (default: true)
    • true returns Buffer
    • false returns string

Returns:

  • Buffer | string - The decoded file content

Example:

const fileBuffer = getFileContent(file); // returns Buffer
const fileString = getFileContent(file, false); // returns string

closeSync

Synchronously closes the file descriptor.

Parameters:

  • fd - The file descriptor to close.

Example:

closeSync(fd);

openSync

Synchronously opens a file.

Parameters:

  • path - The path to the file.
  • flags - The opening mode (e.g., 'r', 'w').
  • mode - (Optional) The file mode.

Returns:

  • number - The file descriptor.

Example:

const fd = openSync('/path/to/file.txt', 'r');

statSync

Synchronously retrieves the fs.Stats for the specified path.

Parameters:

  • path - The path to the file or directory.
  • options - (Optional) Options for the stat call.

Returns:

  • fs.Stats - The stats object for the file or directory.

Example:

const stats = statSync('/path/to/file.txt');

readFileSync

Synchronously reads the entire contents of a file.

Parameters:

  • path - The path to the file.
  • options - (Optional) Options for reading the file.

Returns:

  • string | Buffer - The contents of the file.

Example:

const content = readFileSync('/path/to/file.txt', 'utf8');

readdirSync

Synchronously reads the contents of a directory.

Parameters:

  • path - The path to the directory.
  • options - (Optional) Options for reading the directory.

Returns:

  • string[] - An array of file names in the directory.

Example:

const files = readdirSync('/path/to/dir');

Contributing

Contributions are welcome! Please read our contributing guidelines for details on our code of conduct and the process for submitting pull requests.