Proto+ (aka protoplus) is a multi-enviroment module that expands JavaScript's prototype definitions, as well as global helper functions and others.
<script
src="https://rawcdn.githack.com/sophb-chan/protoplus/refs/heads/main/protoplus.mjs"
type="module"
></script>(()=>{
// 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);
})();Install proto+ (if you haven't already):
npm install git+https://github.com/sophb-chan/protoplus.gitor alternatively, use yarn:
yarn add sophb-chan/protoplusthen add either one of these lines of code to the top of your script file:
import { protoplus } from 'protoplus';
import protoplus from 'protoplus';<script
src="https://rawcdn.githack.com/sophb-chan/protoplus/refs/heads/main/protoplus.js"
></script>(()=>{
// 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);
})();Install proto+ (if you haven't already):
npm install git+https://github.com/sophb-chan/protoplus.gitor alternatively, use yarn:
yarn add sophb-chan/protoplusthen add this line of code to the top of your script file:
const { protoplus } = require('protoplus');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.