Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

grapnel

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grapnel - npm Package Compare versions

Comparing version
0.6.2
to
0.6.3
+1
-1
bower.json
{
"name": "grapnel",
"version": "0.6.2",
"version": "0.6.3",
"homepage": "https://github.com/bytecipher/grapnel",

@@ -5,0 +5,0 @@ "authors": [

@@ -7,3 +7,3 @@ /****

* @link http://bytecipher.io
* @version 0.6.2
* @version 0.6.3
*

@@ -13,2 +13,2 @@ * Released under MIT License. See LICENSE.txt or http://opensource.org/licenses/MIT

!function(a){function b(b){"use strict";var c=this;return this.events={},this.state=null,this.options=b||{},this.options.env=this.options.env||(0===Object.keys(a).length&&process&&process.browser!==!0?"server":"client"),this.options.mode=this.options.mode||("server"!==this.options.env&&this.options.pushState&&a.history&&a.history.pushState?"pushState":"hashchange"),this.version="0.6.2","function"==typeof a.addEventListener&&(a.addEventListener("hashchange",function(){c.trigger("hashchange")}),a.addEventListener("popstate",function(a){return c.state&&null===c.state.previousState?!1:void c.trigger("navigate")})),this}function c(a,b){this.stack=c.constructor.globalStack.slice(0),this.router=a,this.runCallback=!0,this.callbackRan=!1,this.propagateEvent=!0,this.value=a.path();for(var d in b)this[d]=b[d];return this}function d(a){this.route=a,this.keys=[],this.regex=b.regexRoute(a,this.keys)}b.regexRoute=function(a,b,c,d){return a instanceof RegExp?a:(a instanceof Array&&(a="("+a.join("|")+")"),a=a.concat(d?"":"/?").replace(/\/\(/g,"(?:/").replace(/\+/g,"__plus__").replace(/(\/)?(\.)?:(\w+)(?:(\(.*?\)))?(\?)?/g,function(a,c,d,e,f,g){return b.push({name:e,optional:!!g}),c=c||"",""+(g?"":c)+"(?:"+(g?c:"")+(d||"")+(f||d&&"([^/.]+?)"||"([^/]+?)")+")"+(g||"")}).replace(/([\/.])/g,"\\$1").replace(/__plus__/g,"(.+)").replace(/\*/g,"(.*)"),new RegExp("^"+a+"$",c?"":"i"))},b._forEach=function(a,b){return"function"==typeof Array.prototype.forEach?Array.prototype.forEach.call(a,b):function(a,b){for(var c=0,d=this.length;d>c;++c)a.call(b,this[c],c,this)}.call(a,b)},b.prototype.get=b.prototype.add=function(a){var b=this,e=Array.prototype.slice.call(arguments,1,-1),f=Array.prototype.slice.call(arguments,-1)[0],g=new d(a),h=function(){var d=g.parse(b.path());if(d.match){var h={route:a,params:d.params,req:d,regex:d.match},i=new c(b,h).enqueue(e.concat(f));if(b.trigger("match",i,d),!i.runCallback)return b;if(i.previousState=b.state,b.state=i,i.parent()&&i.parent().propagateEvent===!1)return i.propagateEvent=!1,b;i.callback()}return b},i="pushState"!==b.options.mode&&"server"!==b.options.env?"hashchange":"navigate";return h().on(i,h)},b.prototype.trigger=function(a){var c=this,d=Array.prototype.slice.call(arguments,1);return this.events[a]&&b._forEach(this.events[a],function(a){a.apply(c,d)}),this},b.prototype.on=b.prototype.bind=function(a,c){var d=this,e=a.split(" ");return b._forEach(e,function(a){d.events[a]?d.events[a].push(c):d.events[a]=[c]}),this},b.prototype.once=function(a,b){var c=!1;return this.on(a,function(){return c?!1:(c=!0,b.apply(this,arguments),b=null,!0)})},b.prototype.context=function(a){var b=this,c=Array.prototype.slice.call(arguments,1);return function(){var d=arguments[0],e=arguments.length>2?Array.prototype.slice.call(arguments,1,-1):[],f=Array.prototype.slice.call(arguments,-1)[0],g="/"!==a.slice(-1)&&"/"!==d&&""!==d?a+"/":a,h="/"!==d.substr(0,1)?d:d.substr(1),i=g+h;return b.add.apply(b,[i].concat(c).concat(e).concat([f]))}},b.prototype.navigate=function(a){return this.path(a).trigger("navigate")},b.prototype.path=function(b){var c,d=this;return"string"==typeof b?("pushState"===d.options.mode?(c=d.options.root?d.options.root+b:b,a.history.pushState({},null,c)):a.location?a.location.hash=(d.options.hashBang?"!":"")+b:a._pathname=b||"",this):"undefined"==typeof b?c="pushState"===d.options.mode?a.location.pathname.replace(d.options.root,""):"pushState"!==d.options.mode&&a.location?a.location.hash?a.location.hash.split(d.options.hashBang?"#!":"#")[1]:"":a._pathname||"":b===!1?("pushState"===d.options.mode?a.history.pushState({},null,d.options.root||"/"):a.location&&(a.location.hash=d.options.hashBang?"!":""),d):void 0},b.listen=function(){var a,c;return arguments[0]&&arguments[1]?(a=arguments[0],c=arguments[1]):c=arguments[0],function(){for(var a in c)this.add.call(this,a,c[a]);return this}.call(new b(a||{}))},c.constructor.globalStack=[],c.prototype.preventDefault=function(){this.runCallback=!1},c.prototype.stopPropagation=function(){this.propagateEvent=!1},c.prototype.parent=function(){var a=!(!this.previousState||!this.previousState.value||this.previousState.value!=this.value);return a?this.previousState:!1},c.prototype.callback=function(){this.callbackRan=!0,this.timeStamp=Date.now(),this.next()},c.prototype.enqueue=function(a,b){for(var c=Array.isArray(a)?b<a.length?a.reverse():a:[a];c.length;)this.stack.splice(b||this.stack.length+1,0,c.shift());return this},c.prototype.next=function(){var a=this;return this.stack.shift().call(this.router,this.req,this,function(){a.next.call(a)})},d.prototype.parse=function(a){var c=a.match(this.regex),d=this,e={params:{},keys:this.keys,matches:(c||[]).slice(1),match:c};return b._forEach(e.matches,function(a,b){var c=d.keys[b]&&d.keys[b].name?d.keys[b].name:b;e.params[c]=a?decodeURIComponent(a):void 0}),e},b.CallStack=c,b.Request=d,"function"!=typeof a.define||a.define.amd.grapnel?"object"==typeof module&&"object"==typeof module.exports?module.exports=exports=b:a.Grapnel=b:a.define(function(c,d,e){return a.define.amd.grapnel=!0,b})}.call({},"object"==typeof window?window:this);
!function(a){function b(b){"use strict";var c=this;return this.events={},this.state=null,this.options=b||{},this.options.env=this.options.env||(0===Object.keys(a).length&&process&&process.browser!==!0?"server":"client"),this.options.mode=this.options.mode||("server"!==this.options.env&&this.options.pushState&&a.history&&a.history.pushState?"pushState":"hashchange"),this.version="0.6.3","function"==typeof a.addEventListener&&(a.addEventListener("hashchange",function(){c.trigger("hashchange")}),a.addEventListener("popstate",function(a){return c.state&&null===c.state.previousState?!1:void c.trigger("navigate")})),this}function c(a,b){this.stack=c.global.slice(0),this.router=a,this.runCallback=!0,this.callbackRan=!1,this.propagateEvent=!0,this.value=a.path();for(var d in b)this[d]=b[d];return this}function d(a){this.route=a,this.keys=[],this.regex=b.regexRoute(a,this.keys)}b.regexRoute=function(a,b,c,d){return a instanceof RegExp?a:(a instanceof Array&&(a="("+a.join("|")+")"),a=a.concat(d?"":"/?").replace(/\/\(/g,"(?:/").replace(/\+/g,"__plus__").replace(/(\/)?(\.)?:(\w+)(?:(\(.*?\)))?(\?)?/g,function(a,c,d,e,f,g){return b.push({name:e,optional:!!g}),c=c||"",""+(g?"":c)+"(?:"+(g?c:"")+(d||"")+(f||d&&"([^/.]+?)"||"([^/]+?)")+")"+(g||"")}).replace(/([\/.])/g,"\\$1").replace(/__plus__/g,"(.+)").replace(/\*/g,"(.*)"),new RegExp("^"+a+"$",c?"":"i"))},b._forEach=function(a,b){return"function"==typeof Array.prototype.forEach?Array.prototype.forEach.call(a,b):function(a,b){for(var c=0,d=this.length;d>c;++c)a.call(b,this[c],c,this)}.call(a,b)},b.prototype.get=b.prototype.add=function(a){var b=this,e=Array.prototype.slice.call(arguments,1,-1),f=Array.prototype.slice.call(arguments,-1)[0],g=new d(a),h=function(){var d=g.parse(b.path());if(d.match){var h={route:a,params:d.params,req:d,regex:d.match},i=new c(b,h).enqueue(e.concat(f));if(b.trigger("match",i,d),!i.runCallback)return b;if(i.previousState=b.state,b.state=i,i.parent()&&i.parent().propagateEvent===!1)return i.propagateEvent=!1,b;i.callback()}return b},i="pushState"!==b.options.mode&&"server"!==b.options.env?"hashchange":"navigate";return h().on(i,h)},b.prototype.trigger=function(a){var c=this,d=Array.prototype.slice.call(arguments,1);return this.events[a]&&b._forEach(this.events[a],function(a){a.apply(c,d)}),this},b.prototype.on=b.prototype.bind=function(a,c){var d=this,e=a.split(" ");return b._forEach(e,function(a){d.events[a]?d.events[a].push(c):d.events[a]=[c]}),this},b.prototype.once=function(a,b){var c=!1;return this.on(a,function(){return c?!1:(c=!0,b.apply(this,arguments),b=null,!0)})},b.prototype.context=function(a){var b=this,c=Array.prototype.slice.call(arguments,1);return function(){var d=arguments[0],e=arguments.length>2?Array.prototype.slice.call(arguments,1,-1):[],f=Array.prototype.slice.call(arguments,-1)[0],g="/"!==a.slice(-1)&&"/"!==d&&""!==d?a+"/":a,h="/"!==d.substr(0,1)?d:d.substr(1),i=g+h;return b.add.apply(b,[i].concat(c).concat(e).concat([f]))}},b.prototype.navigate=function(a){return this.path(a).trigger("navigate")},b.prototype.path=function(b){var c,d=this;return"string"==typeof b?("pushState"===d.options.mode?(c=d.options.root?d.options.root+b:b,a.history.pushState({},null,c)):a.location?a.location.hash=(d.options.hashBang?"!":"")+b:a._pathname=b||"",this):"undefined"==typeof b?c="pushState"===d.options.mode?a.location.pathname.replace(d.options.root,""):"pushState"!==d.options.mode&&a.location?a.location.hash?a.location.hash.split(d.options.hashBang?"#!":"#")[1]:"":a._pathname||"":b===!1?("pushState"===d.options.mode?a.history.pushState({},null,d.options.root||"/"):a.location&&(a.location.hash=d.options.hashBang?"!":""),d):void 0},b.listen=function(){var a,c;return arguments[0]&&arguments[1]?(a=arguments[0],c=arguments[1]):c=arguments[0],function(){for(var a in c)this.add.call(this,a,c[a]);return this}.call(new b(a||{}))},c.global=[],c.prototype.preventDefault=function(){this.runCallback=!1},c.prototype.stopPropagation=function(){this.propagateEvent=!1},c.prototype.parent=function(){var a=!(!this.previousState||!this.previousState.value||this.previousState.value!=this.value);return a?this.previousState:!1},c.prototype.callback=function(){this.callbackRan=!0,this.timeStamp=Date.now(),this.next()},c.prototype.enqueue=function(a,b){for(var c=Array.isArray(a)?b<a.length?a.reverse():a:[a];c.length;)this.stack.splice(b||this.stack.length+1,0,c.shift());return this},c.prototype.next=function(){var a=this;return this.stack.shift().call(this.router,this.req,this,function(){a.next.call(a)})},d.prototype.parse=function(a){var c=a.match(this.regex),d=this,e={params:{},keys:this.keys,matches:(c||[]).slice(1),match:c};return b._forEach(e.matches,function(a,b){var c=d.keys[b]&&d.keys[b].name?d.keys[b].name:b;e.params[c]=a?decodeURIComponent(a):void 0}),e},b.CallStack=c,b.Request=d,"function"!=typeof a.define||a.define.amd.grapnel?"object"==typeof module&&"object"==typeof module.exports?module.exports=exports=b:a.Grapnel=b:a.define(function(c,d,e){return a.define.amd.grapnel=!0,b})}.call({},"object"==typeof window?window:this);
{
"name": "grapnel",
"version": "0.6.2",
"version": "0.6.3",
"description": "The smallest JavaScript Router with PushState & Named Parameter support",

@@ -5,0 +5,0 @@ "main": "src/grapnel.js",

@@ -7,3 +7,3 @@ /****

* @link http://bytecipher.io
* @version 0.6.2
* @version 0.6.3
*

@@ -24,3 +24,3 @@ * Released under MIT License. See LICENSE.txt or http://opensource.org/licenses/MIT

this.options.mode = this.options.mode || (!!(this.options.env !== 'server' && this.options.pushState && root.history && root.history.pushState) ? 'pushState' : 'hashchange');
this.version = '0.6.2'; // Version
this.version = '0.6.3'; // Version

@@ -101,35 +101,35 @@ if ('function' === typeof root.addEventListener) {

var invoke = function RouteHandler() {
// Build request parameters
var req = request.parse(self.path());
// Check if matches are found
if (req.match) {
// Match found
var extra = {
route: route,
params: req.params,
req: req,
regex: req.match
};
// Create call stack -- add middleware first, then handler
var stack = new CallStack(self, extra).enqueue(middleware.concat(handler));
// Trigger main event
self.trigger('match', stack, req);
// Continue?
if (!stack.runCallback) return self;
// Previous state becomes current state
stack.previousState = self.state;
// Save new state
self.state = stack;
// Prevent this handler from being called if parent handler in stack has instructed not to propagate any more events
if (stack.parent() && stack.parent().propagateEvent === false) {
stack.propagateEvent = false;
return self;
}
// Call handler
stack.callback();
// Build request parameters
var req = request.parse(self.path());
// Check if matches are found
if (req.match) {
// Match found
var extra = {
route: route,
params: req.params,
req: req,
regex: req.match
};
// Create call stack -- add middleware first, then handler
var stack = new CallStack(self, extra).enqueue(middleware.concat(handler));
// Trigger main event
self.trigger('match', stack, req);
// Continue?
if (!stack.runCallback) return self;
// Previous state becomes current state
stack.previousState = self.state;
// Save new state
self.state = stack;
// Prevent this handler from being called if parent handler in stack has instructed not to propagate any more events
if (stack.parent() && stack.parent().propagateEvent === false) {
stack.propagateEvent = false;
return self;
}
// Returns self
return self;
// Call handler
stack.callback();
}
// Event name
// Returns self
return self;
};
// Event name
var eventName = (self.options.mode !== 'pushState' && self.options.env !== 'server') ? 'hashchange' : 'navigate';

@@ -298,3 +298,3 @@ // Invoke when route is defined, and once again when app navigates

function CallStack(router, extendObj) {
this.stack = CallStack.constructor.globalStack.slice(0);
this.stack = CallStack.global.slice(0);
this.router = router;

@@ -324,3 +324,3 @@ this.runCallback = true;

// This allows global middleware
CallStack.constructor.globalStack = [];
CallStack.global = [];
/**

@@ -327,0 +327,0 @@ * Prevent a callback from being called