🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

js-plugin

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-plugin - npm Package Compare versions

Comparing version
1.0.9
to
1.1.0
+1
-1
package.json
{
"name": "js-plugin",
"version": "1.0.9",
"version": "1.1.0",
"repository": "rekit/js-plugin",

@@ -5,0 +5,0 @@ "main": "plugin.js",

+19
-21

@@ -6,12 +6,10 @@ var _plugins = [];

// Only support debug mode on browser and node, not web workers.
var isBrowser =
typeof window !== "undefined" && typeof window.document !== "undefined";
var isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
var isNode =
typeof process !== "undefined" &&
process.versions != null &&
process.versions.node != null;
typeof process !== 'undefined' && process.versions != null && process.versions.node != null;
var isDebug = (isBrowser && document.location.search.includes('JS_PLUGIN_DEBUG'))
|| (isNode && process.env && process.env.JS_PLUGIN_DEBUG);
var isDebug =
(isBrowser && document.location.search.includes('JS_PLUGIN_DEBUG')) ||
(isNode && process.env && process.env.JS_PLUGIN_DEBUG);

@@ -25,3 +23,3 @@ function _isFunc(o) {

for (var i = 0; i < arr.length; i++) {
if (!obj.hasOwnProperty || !obj.hasOwnProperty(arr[i])) return undefined;
if (!(arr[i] in obj)) return undefined;
obj = obj[arr[i]];

@@ -35,3 +33,3 @@ }

for (var i = 0; i < arr.length; i++) {
if (!obj.hasOwnProperty || !obj.hasOwnProperty(arr[i])) return false;
if (!(arr[i] in obj)) return undefined;
obj = obj[arr[i]];

@@ -44,3 +42,3 @@ }

config: {},
register: function(p) {
register: function (p) {
if (!p.name) {

@@ -69,3 +67,3 @@ console.log('Every plugin should have a name.');

unregister: function(name) {
unregister: function (name) {
var p = _byName[name];

@@ -86,7 +84,7 @@ if (!p) throw new Error('Plugin "' + name + '" does\'t exist.');

getPlugin: function(name) {
getPlugin: function (name) {
return _byName[name];
},
getPlugins: function(prop) {
getPlugins: function (prop) {
if (!prop) {

@@ -96,6 +94,6 @@ prop = '.';

if (!_cache[prop]) {
_cache[prop] = _plugins.filter(p => {
if (p.deps && p.deps.some(dep => !_byName[dep])) {
_cache[prop] = _plugins.filter((p) => {
if (p.deps && p.deps.some((dep) => !_byName[dep])) {
// If deps not exist, then not load it.
const notExistDeps = p.deps.filter(dep => !_byName[dep]);
const notExistDeps = p.deps.filter((dep) => !_byName[dep]);
console.log(

@@ -112,3 +110,3 @@ `Plugin ${p.name} is not loaded because its deps do not exist: ${notExistDeps}.`

processRawPlugins: function(callback) {
processRawPlugins: function (callback) {
// This method allows to process _plugins so that it could

@@ -120,3 +118,3 @@ // do some unified pre-process before application starts.

invoke: function(prop) {
invoke: function (prop) {
var args = Array.prototype.slice.call(arguments, 1);

@@ -130,4 +128,4 @@ if (!prop) throw new Error('Invoke on plugin should have prop argument');

var obj = arr.join('.');
return this.getPlugins(prop).map(function(p) {
return this.getPlugins(prop).map(function (p) {
var method = _get(p, prop);

@@ -149,3 +147,3 @@ if (!_isFunc(method) || noCall) return method;

},
sort: function(arr, sortProp) {
sort: function (arr, sortProp) {
// A helper method to sort an array according to 'order' (or by sortProp) property of the array element.

@@ -152,0 +150,0 @@ sortProp = sortProp || 'order';