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

slash-updated

v1.0.0

Published

Enhanced path slash converter with advanced features - Convert Windows backslash paths to slash paths with additional utilities

Readme

slash-updated

npm version Build Status Coverage Status TypeScript License: MIT YouTube Buy Me a Coffee

Enhanced path slash converter with advanced features - Convert Windows backslash paths to slash paths with additional utilities

slash-updated is a powerful, zero-dependency TypeScript library that converts Windows backslash paths to forward slash paths with enhanced features and utilities. It's designed to be a drop-in replacement for the popular slash package while providing additional functionality.

🚀 Features

  • Zero dependencies - Truly minimal with only TypeScript as dev dependency
  • Ultra lightweight - Less than 3KB minified
  • Full TypeScript support - Built with TypeScript, includes complete type definitions
  • Enhanced functionality - More features than similar packages
  • Path validation - Validate paths with customizable rules
  • Path sanitization - Clean and sanitize paths automatically
  • Bulk operations - Process multiple paths efficiently
  • Detailed metadata - Get comprehensive information about path transformations
  • Cross-platform - Works on Windows, macOS, and Linux
  • CommonJS - Works with both old and modern Node.js projects
  • Extensive testing - Comprehensive test suite using Node.js built-in test runner
  • Modern codebase - Clean, readable, and maintainable code

📦 Installation

npm install slash-updated
yarn add slash-updated
pnpm add slash-updated

🔧 Usage

Basic Usage

import slash from "slash-updated";

// Basic conversion
slash("C:\\Users\\John\\Documents");
// → 'C:/Users/John/Documents'

slash("foo\\bar\\baz");
// → 'foo/bar/baz'

// Already forward slashes (no change)
slash("foo/bar/baz");
// → 'foo/bar/baz'

// Extended-length paths are preserved
slash("\\\\?\\C:\\very long path");
// → '\\\\?\\C:\\very long path'

Advanced Options

import slash from "slash-updated";

// Normalize with options
slash("  foo\\\\bar\\..\\baz\\  ", {
  trim: true, // Remove leading/trailing whitespace
  removeDuplicateSlashes: true, // Remove duplicate slashes
  resolveRelative: true, // Resolve ../ and ./
  removeTrailingSlash: true, // Remove trailing slash
});
// → 'foo/baz'

// Ensure trailing slash
slash("foo\\bar", { ensureTrailingSlash: true });
// → 'foo/bar/'

Path Metadata

import { slashWithMetadata } from "slash-updated";

const result = slashWithMetadata("C:\\Users\\John\\Documents");

console.log(result);
// {
//   path: 'C:/Users/John/Documents',
//   original: 'C:\\Users\\John\\Documents',
//   changed: true,
//   type: 'windows',
//   isAbsolute: true,
//   segments: ['C:', 'Users', 'John', 'Documents']
// }

Bulk Operations

import { slashBulk } from "slash-updated";

const paths = ["C:\\Users\\John", "D:\\Projects\\MyApp", "relative\\path"];

const results = slashBulk(paths, {
  includeMetadata: true,
  continueOnError: true,
  trim: true,
});

console.log(results);
// Array of PathResult objects

Path Validation

import { slashValidate } from "slash-updated";

const result = slashValidate(
  "C:\\Users\\John",
  {
    trim: true,
  },
  {
    allowEmpty: false,
    allowRelative: true,
    maxLength: 260,
  }
);

console.log(result);
// {
//   path: 'C:/Users/John',
//   isValid: true,
//   errors: []
// }

Path Sanitization

import { slashSanitize } from "slash-updated";

// Remove invalid characters and convert
slashSanitize('C:\\Users\\John<>:|"?*\\Documents');
// → 'C:/Users/John/Documents'

URL Paths

import { slashUrl, toUrlPath } from "slash-updated";

// Convert path-like URLs (preserves actual URLs)
slashUrl("path\\to\\resource");
// → 'path/to/resource'

slashUrl("https://example.com/already\\valid");
// → 'https://example.com/already\\valid' (unchanged)

// Convert to URL-suitable path
toUrlPath("path\\to\\resource");
// → '/path/to/resource'

Utility Functions

import {
  validatePath,
  isRelativePath,
  isExtendedLengthPath,
  detectPathType,
  sanitizePath,
} from "slash-updated";

// Validate path
const validation = validatePath("C:\\Users\\John", {
  allowEmpty: false,
  maxLength: 260,
});

// Check if path is relative
isRelativePath("./relative/path"); // → true
isRelativePath("C:\\absolute\\path"); // → false

// Check for extended-length path
isExtendedLengthPath("\\\\?\\C:\\long\\path"); // → true

// Detect path type
detectPathType("C:\\Windows\\path"); // → 'windows'
detectPathType("/unix/path"); // → 'posix'
detectPathType("mixed\\path/style"); // → 'mixed'
detectPathType("https://example.com"); // → 'url'

// Sanitize path
sanitizePath('file<>:"|?*name'); // → 'filename'

📚 API

slash(path, options?)

Convert Windows backslash paths to slash paths.

Parameters

  • path (string): The path to convert
  • options (NormalizeOptions): Optional normalization options

Returns

  • string: The converted path

Options

interface NormalizeOptions {
  trim?: boolean; // Remove leading/trailing whitespace
  removeDuplicateSlashes?: boolean; // Remove duplicate slashes
  resolveRelative?: boolean; // Resolve ../ and ./
  removeTrailingSlash?: boolean; // Remove trailing slash
  ensureTrailingSlash?: boolean; // Ensure trailing slash
}

slashWithMetadata(path, options?)

Convert path and return detailed metadata.

Returns

interface PathResult {
  path: string; // Converted path
  original: string; // Original path
  changed: boolean; // Whether path was changed
  type: "windows" | "posix" | "mixed" | "url";
  isAbsolute: boolean; // Whether path is absolute
  segments: string[]; // Path segments
}

slashBulk(paths, options?)

Process multiple paths at once.

Options

interface BulkOptions extends NormalizeOptions {
  continueOnError?: boolean; // Continue processing on error
  includeMetadata?: boolean; // Return metadata for each path
}

slashValidate(path, options?, validationOptions?)

Convert and validate path.

Validation Options

interface ValidationOptions {
  allowEmpty?: boolean; // Allow empty paths
  allowRelative?: boolean; // Allow relative paths
  maxLength?: number; // Maximum path length
  customValidator?: (path: string) => boolean; // Custom validation
}

Other Functions

  • slashSanitize(path, options?) - Convert and sanitize path
  • slashUrl(url, options?) - Convert URL-like paths
  • toUrlPath(path, options?) - Convert to URL-suitable path
  • validatePath(path, options?) - Validate path
  • isRelativePath(path) - Check if path is relative
  • isExtendedLengthPath(path) - Check for extended-length path
  • detectPathType(path) - Detect path type
  • sanitizePath(path) - Sanitize path

🆚 Comparison with Other Packages

| Feature | slash-updated | slash | upath | normalize-path | | ---------------------------- | ---------------- | ----------- | ----------- | -------------- | | Size | ~3KB | ~3KB | ~20KB | ~4KB | | Dependencies | 0 | 0 | 1 | 0 | | Dev Dependencies | 1 (TypeScript) | 7+ | 10+ | 5+ | | TypeScript | ✅ Built-in | ✅ Built-in | ✅ Built-in | ❌ External | | Basic conversion | ✅ | ✅ | ✅ | ✅ | | Path validation | ✅ | ❌ | ❌ | ❌ | | Path sanitization | ✅ | ❌ | ❌ | ❌ | | Bulk operations | ✅ | ❌ | ❌ | ❌ | | Detailed metadata | ✅ | ❌ | ❌ | ❌ | | URL path support | ✅ | ❌ | ❌ | ❌ | | Custom validation | ✅ | ❌ | ❌ | ❌ | | Path type detection | ✅ | ❌ | ❌ | ❌ | | Relative path resolution | ✅ | ❌ | ✅ | ✅ | | Trailing slash control | ✅ | ❌ | ❌ | ❌ | | Test Framework | Node.js built-in | Jest/Ava | Mocha | Jest | | Build Complexity | Minimal | Minimal | Complex | Minimal |

Why Choose slash-updated?

  1. Truly Zero Dependencies: Only TypeScript as dev dependency, no runtime dependencies
  2. More Features: Extensive functionality beyond basic conversion
  3. Better DX: Rich TypeScript support with detailed types
  4. Validation: Built-in path validation with customizable rules
  5. Flexibility: Multiple utility functions for different use cases
  6. Simplicity: Uses Node.js built-in test runner, no complex tooling
  7. Performance: Optimized for both single and bulk operations
  8. Modern: Built with modern JavaScript and TypeScript practices
  9. Lightweight: Minimal footprint with maximum functionality

🧪 Testing

npm test              # Run tests using Node.js built-in test runner

The package uses Node.js built-in test runner (available in Node.js 18+), eliminating the need for external testing frameworks like Jest or Mocha.

🛠️ Development

# Clone repository
git clone https://github.com/noorjsdivs/slash-updated.git
cd slash-updated

# Install dependencies
npm install

# Build
npm run build

# Run tests
npm test

# Lint
npm run lint

# Format code
npm run format

📋 Requirements

  • Node.js >= 18.0.0 (for Node.js built-in test runner)
  • TypeScript >= 5.0.0 (for TypeScript projects, dev only)

📝 License

MIT © ReactJS BD

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

🙏 Support

If you found this project helpful, please consider:

  • ⭐ Starring the repository
  • 🐛 Reporting issues
  • 💡 Suggesting new features
  • Buy me a coffee

📺 Learn More

Check out my YouTube channel for more programming content: ReactJS BD


Made with ❤️ by ReactJS BD