Skip to content

Repository files navigation

proto+

Proto+ (aka protoplus) is a multi-enviroment module that expands JavaScript's prototype definitions, as well as global helper functions and others.

Table of Contents

How to Import (ES6 module)

In browsers via HTML or JS:

Via HTML

<script
  src="https://rawcdn.githack.com/sophb-chan/protoplus/refs/heads/main/protoplus.mjs"
  type="module"
></script>

Via JS

(()=>{
  // import proto+

  const script = document.createElement('script');
  script.src = "https://rawcdn.githack.com/sophb-chan/protoplus/refs/heads/main/protoplus.mjs";
  script.type = "module";
  document.head.appendChild(script);
})();

In Node.js, Bun, or front-end frameworks like React/Next.js:

Install proto+ (if you haven't already):

npm install git+https://github.com/sophb-chan/protoplus.git

or alternatively, use yarn:

yarn add sophb-chan/protoplus

then add either one of these lines of code to the top of your script file:

import { protoplus } from 'protoplus';
import protoplus from 'protoplus';

How to Import (CommonJS/WebJS module)

In browsers via HTML or JS:

Via HTML

<script
  src="https://rawcdn.githack.com/sophb-chan/protoplus/refs/heads/main/protoplus.js"
></script>

Via JS

(()=>{
  // import proto+

  const script = document.createElement('script');
  script.src = "https://rawcdn.githack.com/sophb-chan/protoplus/refs/heads/main/protoplus.js";
  document.head.appendChild(script);
})();

In Node.js, Bun, or front-end frameworks like React/Next.js:

Install proto+ (if you haven't already):

npm install git+https://github.com/sophb-chan/protoplus.git

or alternatively, use yarn:

yarn add sophb-chan/protoplus

then add this line of code to the top of your script file:

const { protoplus } = require('protoplus');

Quick Start

After importing the script to your project, you can use protoplus.expand() to expand prototypes and others, and protoplus.contract() to restore them to their default/previous value. It's recommended to run protoplus.expand() after the import statement (if you're using proto+ in a browser and imported it via HTML, run protoplus.expand() at the top of your script file).

You can also use protoplus.expand({ skipClasses: true }) to only expand prototypes and global helpers.

About

A module that expands JavaScript's prototype definitions, global helpers and others.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages