Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

require-extension-hooks

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

require-extension-hooks - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

26

index.js

@@ -11,2 +11,5 @@ const cache = {};

push(fn){
if (this._plugin && !fn){
fn = this._plugin;
}
this._extensions.forEach(ext => ext.push(fn));

@@ -16,2 +19,5 @@ return this;

shift(fn){
if (this._plugin && !fn){
fn = this._plugin;
}
this._extensions.forEach(ext => ext.shift(fn));

@@ -22,2 +28,5 @@ return this;

let args = arguments;
if (this._plugin && args.length < 3){
args[2] = this._plugin;
}
this._extensions.forEach(ext => ext.splice.apply(ext, args));

@@ -29,2 +38,19 @@ return this;

}
plugin(name, options){
if (typeof name === 'function'){
this._plugin = name;
}else{
try{
this._plugin = require('require-extension-hooks-' + name);
}catch(e){
this._plugin = require(name);
}
}
if (typeof this._plugin.configure === 'function'){
this._plugin.configure(options);
}
return this;
}
}

@@ -31,0 +57,0 @@

4

package.json
{
"name": "require-extension-hooks",
"version": "0.1.0",
"description": "Add hoks for js extension types",
"version": "0.2.0",
"description": "Add hooks for js extension types",
"main": "index.js",

@@ -6,0 +6,0 @@ "scripts": {

@@ -37,2 +37,6 @@ # require-extension-hooks

### hook.plugin(name | fn)
Loads a plugin. The plugin can either be a partial name (i.e. for *require-extension-hooks-vue* you can just type `hook.plugin('vue')`), the full name of a plugin (i.e. `hook.plugin('require-extension-hooks-vue')`) or a direct function (i.e. `hook.plugin(function(config){}`).
The plugin function does not automatically append the plugin to the hook queue, you also need to tell it what to do. i.e. `hook.plugin('vue').push()`.
### config

@@ -39,0 +43,0 @@ A hook function takes a config object as its only argument. This object contains the following options:

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc