You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

vite-plugin-proto-global

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-plugin-proto-global

Define JS prototypes as globals for entire project

1.0.4
latest
Source
npmnpm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

vite-plugin-proto-global

Extend JavaScript prototypes globally in your Vite project

Installation

npm i vite-plugin-proto-global -D
# or
yarn add vite-plugin-proto-global -D

Configuration

In your vite.config.js, configure the plugin with the prototypes you want to extend. For example:

// vite.config.js
import { defineConfig } from 'vite'
import { protoGlobalPlugin } from 'vite-plugin-proto-global'

export default defineConfig({
  plugins: [
      protoGlobalPlugin([
          {
              className: 'Array',
              methods: {
                  reverseNumbers: function() {
                    return this.sort((a, b) => b - a);
                },
              },
          },
          // ... other extensions
      ])
  ],
})

Usage

Once the plugin is configured, the extended prototypes can be used globally in your project. For example:

// example.js
const myArray = [1, 2, 3];
myArray.reverseNumbers(); // Use the custom method extended to Array's prototype

Support

If you have any questions or issues with the plugin, please submit an issue on the GitHub repository. Your support is appreciated, and if you find this plugin helpful, consider giving it a star. Thank you!

Keywords

vite

FAQs

Package last updated on 07 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts