0.0.4 • Published 10 months ago

@bitecraft/jswhere v0.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago
     _ ____  __        ___                   
    | / ___| \ \      / / |__   ___ _ __ ___ 
 _  | \___ \  \ \ /\ / /| '_ \ / _ \ '__/ _ \
| |_| |___) |  \ V  V / | | | |  __/ | |  __/
 \___/|____/    \_/\_/  |_| |_|\___|_|  \___|

JSWhere šŸ”

A lightweight and precise JavaScript library that detects the exact runtime environment of your application, including React Native, Expo, Vite, Next.js, NestJS, and more. šŸš€

License: MIT Node.js Version TypeScript

Table of Contents

• Overview
• Features
• Installation
• Usage
• Supported Environments • Development
• API Reference
• Contributing
• License

Overview šŸŽÆ

Runtime Environment Detector is a powerful utility that helps you identify the current JavaScript runtime environment your code is executing in. Whether you're running in Vite, React Native, Expo, or other environments, this library provides accurate detection.

Features ✨

  • šŸ” Accurate runtime environment detection
  • šŸŽÆ Type-safe implementation
  • šŸš€ Zero dependencies
  • šŸ’Ø Lightweight and fast
  • šŸ”Œ Easy integration
  • šŸ“¦ Tree-shakeable

Installation šŸ“¦

# Using npm
npm install @bitecraft/jswhere

# Using Bun
bun install @bitecraft/jswhere

# Using pnpm
pnpm install @bitecraft/jswhere

# Using yarn
yarn add @bitecraft/jswhere

Usage šŸš€

import { detectEnvironment } from '@bitecraft/jswhere';

const environment = detectEnvironment();
console.log(`Current runtime environment: ${environment}`);

Supported Environments āœ…

Current implementation status:

  • Vite
  • React Native
  • Expo
  • Next.js (Coming soon)
  • NestJS (Coming soon)
  • Browser (Coming soon)
  • Node.js (Coming soon)
  • Electron (Coming soon)
  • Remix (Coming soon)
  • Nuxt (Coming soon)
  • SvelteKit (Coming soon)
  • Deno (Coming soon)
  • Bun (Coming soon)

Development šŸ› ļø

Prerequisites

  • Node.js >= 14.0.0
  • TypeScript/Javascript knowledge

Setting Up Development Environment

  1. Clone the repository:
git clone https://github.com/BiteCraft/jswhere.git
cd jswhere
  1. Install dependencies:
npm install
  1. Start development
npm run dev

Building the Project

npm run build

API Reference šŸ“š

Main Function

function detectEnvironment(): RuntimeEnvironment

Returns one of the following types:

type RuntimeEnvironment =
  | "expo"
  | "react-native"
  | "vite"
  | "nextjs"
  | "nestjs"
  | "browser"
  | "node"
  | "electron"
  | "remix"
  | "nuxt"
  | "sveltekit"
  | "deno"
  | "bun"
  | "unknown";

Contributing šŸ¤

This project is currently a work in progress, and we welcome contributions! If you'd like to help, here are some ways you can contribute:

  1. Implement missing environment detectors
  2. Improve existing detectors
  3. Add tests
  4. Improve documentation

To contribute:

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/NewDetector)
  3. Commit your changes(git commit -m 'feat: add new environment detector')
  4. Push to the branch (git push origin feature/NewDetector)
  5. Open a Pull Request

License šŸ“„

This project is licensed under the MIT License - see the LICENSE file for details.


Made with ā¤ļø using TypeScript