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

patrun

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

patrun - npm Package Compare versions

Comparing version 7.1.0 to 7.2.1

114

dist/lib/matchers.js
"use strict";
/* Copyright (c) 2020 Richard Rodger, MIT License */
/* $lab:coverage:off$ */
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, privateMap) {
if (!privateMap.has(receiver)) {
throw new TypeError("attempted to get private field on non-instance");
}
return privateMap.get(receiver);
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _and, _or, _nil, _err, _mgt, _mgte, _mlt, _mlte, _meq;
var _IntervalMatcher_and, _IntervalMatcher_or, _IntervalMatcher_nil, _IntervalMatcher_err, _IntervalMatcher_mgt, _IntervalMatcher_mgte, _IntervalMatcher_mlt, _IntervalMatcher_mlte, _IntervalMatcher_meq;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -19,3 +18,3 @@ exports.IntervalMatcher = exports.GexMatcher = void 0;

if ('string' === typeof fix && fix.match(/[*?]/)) {
let gex = gex_1.Gex(fix);
let gex = (0, gex_1.Gex)(fix);
return {

@@ -73,15 +72,15 @@ kind: 'gex',

this.kind = 'interval';
_and.set(this, (lhs, rhs) => function and(x) {
_IntervalMatcher_and.set(this, (lhs, rhs) => function and(x) {
return lhs(x) && rhs(x);
});
_or.set(this, (lhs, rhs) => function or(x) {
_IntervalMatcher_or.set(this, (lhs, rhs) => function or(x) {
return lhs(x) || rhs(x);
});
_nil.set(this, (n) => function nil(x) { return false; });
_err.set(this, (n) => function err(x) { return false; });
_mgt.set(this, (n) => function gt(x) { return x > n; });
_mgte.set(this, (n) => function gte(x) { return x >= n; });
_mlt.set(this, (n) => function lt(x) { return x < n; });
_mlte.set(this, (n) => function lte(x) { return x <= n; });
_meq.set(this, (n) => function eq(x) { return x === n; });
_IntervalMatcher_nil.set(this, (n) => function nil(x) { return false; });
_IntervalMatcher_err.set(this, (n) => function err(x) { return false; });
_IntervalMatcher_mgt.set(this, (n) => function gt(x) { return x > n; });
_IntervalMatcher_mgte.set(this, (n) => function gte(x) { return x >= n; });
_IntervalMatcher_mlt.set(this, (n) => function lt(x) { return x < n; });
_IntervalMatcher_mlte.set(this, (n) => function lte(x) { return x <= n; });
_IntervalMatcher_meq.set(this, (n) => function eq(x) { return x === n; });
}

@@ -99,30 +98,33 @@ make(key, fix) {

let os1 = IntervalMatcher.normop(m[8]) || IntervalMatcher.normop(m[10]);
let o0 = '=' === os0 ? __classPrivateFieldGet(this, _meq) :
'<' === os0 ? __classPrivateFieldGet(this, _mlt) :
')' === os0 ? __classPrivateFieldGet(this, _mlt) :
'<=' === os0 ? __classPrivateFieldGet(this, _mlte) :
']' === os0 ? __classPrivateFieldGet(this, _mlte) :
'>' === os0 ? __classPrivateFieldGet(this, _mgt) :
'(' === os0 ? __classPrivateFieldGet(this, _mgt) :
'>=' === os0 ? __classPrivateFieldGet(this, _mgte) :
'[' === os0 ? __classPrivateFieldGet(this, _mgte) : __classPrivateFieldGet(this, _err);
let o0 = '=' === os0 ? __classPrivateFieldGet(this, _IntervalMatcher_meq, "f") :
'<' === os0 ? __classPrivateFieldGet(this, _IntervalMatcher_mlt, "f") :
')' === os0 ? __classPrivateFieldGet(this, _IntervalMatcher_mlt, "f") :
'<=' === os0 ? __classPrivateFieldGet(this, _IntervalMatcher_mlte, "f") :
']' === os0 ? __classPrivateFieldGet(this, _IntervalMatcher_mlte, "f") :
'>' === os0 ? __classPrivateFieldGet(this, _IntervalMatcher_mgt, "f") :
'(' === os0 ? __classPrivateFieldGet(this, _IntervalMatcher_mgt, "f") :
'>=' === os0 ? __classPrivateFieldGet(this, _IntervalMatcher_mgte, "f") :
'[' === os0 ? __classPrivateFieldGet(this, _IntervalMatcher_mgte, "f") :
__classPrivateFieldGet(this, _IntervalMatcher_err, "f");
let n0 = Number(m[2]);
let n1 = null == m[9] ? NaN : Number(m[9]);
let jos = m[7];
let jo = null == jos ? __classPrivateFieldGet(this, _or) :
'&' === jos.substring(0, 1) ? __classPrivateFieldGet(this, _and) :
',' === jos.substring(0, 1) ? __classPrivateFieldGet(this, _and) : __classPrivateFieldGet(this, _or);
let jo = null == jos ? __classPrivateFieldGet(this, _IntervalMatcher_or, "f") :
'&' === jos.substring(0, 1) ? __classPrivateFieldGet(this, _IntervalMatcher_and, "f") :
',' === jos.substring(0, 1) ? __classPrivateFieldGet(this, _IntervalMatcher_and, "f") :
__classPrivateFieldGet(this, _IntervalMatcher_or, "f");
if ('..' === jos) {
jo = __classPrivateFieldGet(this, _and);
o0 = __classPrivateFieldGet(this, _err) === o0 ? __classPrivateFieldGet(this, _mgte) : o0;
jo = __classPrivateFieldGet(this, _IntervalMatcher_and, "f");
o0 = __classPrivateFieldGet(this, _IntervalMatcher_err, "f") === o0 ? __classPrivateFieldGet(this, _IntervalMatcher_mgte, "f") : o0;
os1 = '' === os1 ? '<=' : os1;
}
let o1 = null == os1 ? __classPrivateFieldGet(this, _nil) :
'=' === os1 ? __classPrivateFieldGet(this, _meq) :
'<' === os1 ? __classPrivateFieldGet(this, _mlt) :
')' === os1 ? __classPrivateFieldGet(this, _mlt) :
'<=' === os1 ? __classPrivateFieldGet(this, _mlte) :
']' === os1 ? __classPrivateFieldGet(this, _mlte) :
'>' === os1 ? __classPrivateFieldGet(this, _mgt) :
'>=' === os1 ? __classPrivateFieldGet(this, _mgte) : __classPrivateFieldGet(this, _err);
let o1 = null == os1 ? __classPrivateFieldGet(this, _IntervalMatcher_nil, "f") :
'=' === os1 ? __classPrivateFieldGet(this, _IntervalMatcher_meq, "f") :
'<' === os1 ? __classPrivateFieldGet(this, _IntervalMatcher_mlt, "f") :
')' === os1 ? __classPrivateFieldGet(this, _IntervalMatcher_mlt, "f") :
'<=' === os1 ? __classPrivateFieldGet(this, _IntervalMatcher_mlte, "f") :
']' === os1 ? __classPrivateFieldGet(this, _IntervalMatcher_mlte, "f") :
'>' === os1 ? __classPrivateFieldGet(this, _IntervalMatcher_mgt, "f") :
'>=' === os1 ? __classPrivateFieldGet(this, _IntervalMatcher_mgte, "f") :
__classPrivateFieldGet(this, _IntervalMatcher_err, "f");
// merge ops if same number

@@ -132,14 +134,14 @@ if (n0 === n1) {

n1 = NaN;
o1 = __classPrivateFieldGet(this, _nil);
o1 = __classPrivateFieldGet(this, _IntervalMatcher_nil, "f");
if (os1.includes('<')) {
o0 = __classPrivateFieldGet(this, _mlte);
o0 = __classPrivateFieldGet(this, _IntervalMatcher_mlte, "f");
}
else if (os1.includes('>')) {
o0 = __classPrivateFieldGet(this, _mgte);
o0 = __classPrivateFieldGet(this, _IntervalMatcher_mgte, "f");
}
else if (os1.includes('=')) {
o0 = __classPrivateFieldGet(this, _meq);
o0 = __classPrivateFieldGet(this, _IntervalMatcher_meq, "f");
}
else {
o0 = __classPrivateFieldGet(this, _err);
o0 = __classPrivateFieldGet(this, _IntervalMatcher_err, "f");
}

@@ -149,11 +151,11 @@ }

n1 = NaN;
o1 = __classPrivateFieldGet(this, _nil);
o1 = __classPrivateFieldGet(this, _IntervalMatcher_nil, "f");
if (os0.includes('<')) {
o0 = __classPrivateFieldGet(this, _mlte);
o0 = __classPrivateFieldGet(this, _IntervalMatcher_mlte, "f");
}
else if (os0.includes('>')) {
o0 = __classPrivateFieldGet(this, _mgte);
o0 = __classPrivateFieldGet(this, _IntervalMatcher_mgte, "f");
}
else {
o0 = __classPrivateFieldGet(this, _err);
o0 = __classPrivateFieldGet(this, _IntervalMatcher_err, "f");
}

@@ -164,15 +166,15 @@ }

// if one sided interval, add the other side out to infinity
if (__classPrivateFieldGet(this, _err) !== o0) {
if (__classPrivateFieldGet(this, _nil) === o1) {
if (__classPrivateFieldGet(this, _mlt) === o0 || __classPrivateFieldGet(this, _mlte) === o0) {
if (__classPrivateFieldGet(this, _IntervalMatcher_err, "f") !== o0) {
if (__classPrivateFieldGet(this, _IntervalMatcher_nil, "f") === o1) {
if (__classPrivateFieldGet(this, _IntervalMatcher_mlt, "f") === o0 || __classPrivateFieldGet(this, _IntervalMatcher_mlte, "f") === o0) {
o1 = o0;
n1 = n0;
o0 = __classPrivateFieldGet(this, _mgte);
o0 = __classPrivateFieldGet(this, _IntervalMatcher_mgte, "f");
n0 = Number.NEGATIVE_INFINITY;
jo = __classPrivateFieldGet(this, _and);
jo = __classPrivateFieldGet(this, _IntervalMatcher_and, "f");
}
else if (__classPrivateFieldGet(this, _mgt) === o0 || __classPrivateFieldGet(this, _mgte) === o0) {
o1 = __classPrivateFieldGet(this, _mlte);
else if (__classPrivateFieldGet(this, _IntervalMatcher_mgt, "f") === o0 || __classPrivateFieldGet(this, _IntervalMatcher_mgte, "f") === o0) {
o1 = __classPrivateFieldGet(this, _IntervalMatcher_mlte, "f");
n1 = Number.POSITIVE_INFINITY;
jo = __classPrivateFieldGet(this, _and);
jo = __classPrivateFieldGet(this, _IntervalMatcher_and, "f");
}

@@ -393,3 +395,3 @@ // else this.meq ok as is

exports.IntervalMatcher = IntervalMatcher;
_and = new WeakMap(), _or = new WeakMap(), _nil = new WeakMap(), _err = new WeakMap(), _mgt = new WeakMap(), _mgte = new WeakMap(), _mlt = new WeakMap(), _mlte = new WeakMap(), _meq = new WeakMap();
_IntervalMatcher_and = new WeakMap(), _IntervalMatcher_or = new WeakMap(), _IntervalMatcher_nil = new WeakMap(), _IntervalMatcher_err = new WeakMap(), _IntervalMatcher_mgt = new WeakMap(), _IntervalMatcher_mgte = new WeakMap(), _IntervalMatcher_mlt = new WeakMap(), _IntervalMatcher_mlte = new WeakMap(), _IntervalMatcher_meq = new WeakMap();
// == sames as =, <= same as =<

@@ -396,0 +398,0 @@ IntervalMatcher.normop = (op) => null == op ? null :

@@ -1,1 +0,5 @@

export {};
import { Gex } from 'gex';
declare function Patrun(custom: any): any;
declare function make(custom: any): any;
export default make;
export { Patrun, Gex };
"use strict";
/* Copyright (c) 2013-2020 Richard Rodger, MIT License */
Object.defineProperty(exports, "__esModule", { value: true });
exports.Gex = exports.Patrun = void 0;
// TODO: matchers should accept string[] of key names - only operate on these keys
// TODO: expose walk as method for general purpose
const gex_1 = require("gex");
Object.defineProperty(exports, "Gex", { enumerable: true, get: function () { return gex_1.Gex; } });
const matchers_1 = require("./lib/matchers");
module.exports = function (custom) {
return new Patrun(custom);
};
function Patrun(custom) {

@@ -256,3 +255,3 @@ custom = custom || {};

var key = keymap.k;
var gexval = gex_1.Gex(pat ? (null == pat[key] ? (exact ? null : '*') : pat[key]) : '*');
var gexval = (0, gex_1.Gex)(pat ? (null == pat[key] ? (exact ? null : '*') : pat[key]) : '*');
var itermatch = { ...match };

@@ -370,3 +369,3 @@ var itermissing = { ...missing };

self.toJSON = function (indent) {
return JSON.stringify(top, function (key, val) {
return JSON.stringify(top, function (_key, val) {
if ('function' === typeof val)

@@ -379,2 +378,10 @@ return '[Function]';

}
exports.Patrun = Patrun;
function make(custom) {
return new Patrun(custom);
}
if ('undefined' !== typeof module) {
module.exports = make;
}
exports.default = make;
//# sourceMappingURL=patrun.js.map

@@ -1,1 +0,1 @@

!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).Patrun=e()}}((function(){var e={exports:{}};(function(t){(function(){!function(n){"object"==typeof e.exports?e.exports=n():("undefined"!=typeof window?window:void 0!==t?t:"undefined"!=typeof self?self:this).Gex=n()}((function(){var e={};Object.defineProperty(e,"__esModule",{value:!0}),e.Gex=void 0;class t{constructor(e){this.desc="",this.gexmap={},(Array.isArray(e)?e:[e]).forEach(e=>{this.gexmap[e]=this.re(this.clean(e))})}dodgy(e){return null==e||Number.isNaN(e)}clean(e){let t=""+e;return this.dodgy(e)?"":t}match(e){e=""+e;let t=!1,n=Object.keys(this.gexmap);for(let r=0;r<n.length&&!t;r++)t=!!this.gexmap[n[r]].exec(e);return t}on(e){if(null==e)return null;let t=typeof e;if("string"===t||"number"===t||"boolean"===t||e instanceof Date||e instanceof RegExp)return this.match(e)?e:null;if(Array.isArray(e)){let t=[];for(let n=0;n<e.length;n++)!this.dodgy(e[n])&&this.match(e[n])&&t.push(e[n]);return t}{let t={};for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&this.match(n)&&(t[n]=e[n]);return t}}esc(e){let t=this.clean(e);return(t=t.replace(/\*/g,"**")).replace(/\?/g,"*?")}escregexp(e){return e?(""+e).replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"):""}re(e){if(""===e||e)return e="^"+(e=(e=(e=(e=(e=this.escregexp(e)).replace(/\\\*/g,"[\\s\\S]*")).replace(/\\\?/g,"[\\s\\S]")).replace(/\[\\s\\S\]\*\[\\s\\S\]\*/g,"\\*")).replace(/\[\\s\\S\]\*\[\\s\\S\]/g,"\\?"))+"$",new RegExp(e);{let e=Object.keys(this.gexmap);return 1==e.length?this.gexmap[e[0]]:{...this.gexmap}}}toString(){let e=this.desc;return""!=e?e:this.desc="Gex["+Object.keys(this.gexmap)+"]"}inspect(){return this.toString()}}return e.Gex=function(e){return new t(e)},e}))}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{}),e=e.exports;var t,n,r,i,s,l,o,u,a,f={},h=this&&this.__classPrivateFieldGet||function(e,t){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return t.get(e)};Object.defineProperty(f,"__esModule",{value:!0}),f.IntervalMatcher=f.GexMatcher=void 0,f.GexMatcher=class{constructor(){}make(t,n){if("string"==typeof n&&n.match(/[*?]/)){let t=e.Gex(n);return{kind:"gex",match:e=>null!=t.on(e),fix:n,meta:{},same(e){return null!=e&&e.kind===this.kind&&e.fix===this.fix}}}}scan(e,t){let n=e.filter(e=>"*"===e.fix).length>0;return{complete:n,sound:n,gaps:[],overs:[],why:"no-star"}}};const p=new RegExp(["^/s*","(=*[<>/(/[]?=*)?/s*([-+0-9a-fA-FeEoOxX]+(/.([0-9a-fA-FeEoOxX]+))?)([/)/]]?)(/s*(,|&+|/|+|/./.)/s*(=*[<>]?=*)/s*([-+.0-9a-fA-FeEoOxX]+)/s*([/)/]]?))?/s*$"].join("").replace(/\//g,"\\"));class c{constructor(){this.kind="interval",t.set(this,(e,t)=>function(n){return e(n)&&t(n)}),n.set(this,(e,t)=>function(n){return e(n)||t(n)}),r.set(this,e=>function(e){return!1}),i.set(this,e=>function(e){return!1}),s.set(this,e=>function(t){return t>e}),l.set(this,e=>function(t){return t>=e}),o.set(this,e=>function(t){return t<e}),u.set(this,e=>function(t){return t<=e}),a.set(this,e=>function(t){return t===e})}make(e,f){if("string"==typeof f&&f.match(/[=<>.[()\]]/)){let e=f.match(p),d={jo:"and",o0:"err",n0:NaN,o1:"err",n1:NaN},g=e=>!1;if(null!=e){let p=c.normop(e[1])||c.normop(e[5]),m=c.normop(e[8])||c.normop(e[10]),v=h(this,"="===p?a:"<"===p||")"===p?o:"<="===p||"]"===p?u:">"===p||"("===p?s:">="===p||"["===p?l:i),k=Number(e[2]),y=null==e[9]?NaN:Number(e[9]),x=e[7],N=null==x?h(this,n):"&"===x.substring(0,1)||","===x.substring(0,1)?h(this,t):h(this,n);".."===x&&(N=h(this,t),v=h(this,i)===v?h(this,l):v,m=""===m?"<=":m);let w=h(this,null==m?r:"="===m?a:"<"===m||")"===m?o:"<="===m||"]"===m?u:">"===m?s:">="===m?l:i);if(k===y&&("="===p&&null!=m?(y=NaN,w=h(this,r),v=m.includes("<")?h(this,u):m.includes(">")?h(this,l):m.includes("=")?h(this,a):h(this,i)):"="===m&&null!=p&&(y=NaN,w=h(this,r),v=p.includes("<")?h(this,u):p.includes(">")?h(this,l):h(this,i))),h(this,i)!==v&&h(this,r)===w&&(h(this,o)===v||h(this,u)===v?(w=v,y=k,v=h(this,l),k=Number.NEGATIVE_INFINITY,N=h(this,t)):h(this,s)!==v&&h(this,l)!==v||(w=h(this,u),y=Number.POSITIVE_INFINITY,N=h(this,t))),!isNaN(y)&&y<k){let e=w,t=y;y=k,k=t,".."!==x&&(w=v,v=e)}let b=v(k),O=w(y),j=N(b,O);return{kind:"interval",fix:f,meta:d={jo:j.name,o0:b.name,n0:k,o1:O.name,n1:y},match:g=e=>{let t=!1,n=parseFloat(e);return isNaN(n)||(t=j(n)),t},same(e){return null!=e&&e.kind===this.kind&&e.meta.jo===this.meta.jo&&e.meta.o0===this.meta.o0&&e.meta.n0===this.meta.n0&&e.meta.o1===this.meta.o1&&e.meta.n1===this.meta.n1}}}}}scan(e,t){let n={complete:!1,sound:!1,gaps:[],overs:[],lower:null,upper:null},r=Number.NEGATIVE_INFINITY,i=Number.POSITIVE_INFINITY,s=this.half_intervals(e);s.reduce((e,t)=>{let n="eq"===t.o,i="lt"===t.o,s="lte"===t.o,l="gt"===t.o,o="gte"===t.o,u=t.n;if(null==e.lower){let i={n:r,o:"gte"};e.lower=i,e.upper=t,r==u&&o||(l||o?e.gaps.push([i,{n:u,o:l?"lte":"lt",m:0}]):n&&e.gaps.push([i,{n:u,o:"lte",m:1}]))}else{let r="eq"===e.upper.o,a="lt"===e.upper.o,f="lte"===e.upper.o,h=(e.upper.o,e.upper.o,e.upper.n),p=e.upper;u===h?a&&(o||n)||(f||r)&&l||(r||a||f)&&e.gaps.push([{n:h,o:r||f?"gt":"gte",m:2,d:{u:p,h:t}},{n:u,o:n||o?"lt":"lte",m:3}]):h<u?i||s||(r||a||f)&&e.gaps.push([{n:h,o:r||f?"gt":"gte",m:4},{n:u,o:n||o?"lt":"lte",m:5}]):e.overs.push([{n:u,o:n||o?"gte":"gt",m:10},{n:h,o:r||f?"lte":"lt",m:11}]),e.upper=t}return e},n);let l=0<s.length&&s[s.length-1];return l&&i!==l.n&&"gt"!==l.o&&"gte"!==l.o&&n.gaps.push([{n:l.n,o:"eq"===l.o||"lte"===l.o?"gt":"gte",m:6},{n:i,o:"lte",m:7}]),n.complete=0===n.gaps.length,n.sound=0===n.overs.length,n}half_intervals(e){let t=[];for(let r of e)t.push([{n:r.meta.n0,o:r.meta.o0},{n:r.meta.n1,o:r.meta.o1}]);var n=["lt","lte","eq","gte","gt"];return t.map(e=>[isNaN(e[0].n)||null==e[0].n?null:e[0],isNaN(e[1].n)||null==e[1].n?null:e[1]].filter(e=>null!=e)).sort((e,t)=>{if(e[0].n<t[0].n)return-1;if(t[0].n<e[0].n)return 1;var r=n.indexOf(e[0].o),i=n.indexOf(t[0].o);if(r<i)return-1;if(i<r)return 1;if(e[1].n<t[1].n)return-1;if(t[1].n<e[1].n)return 1;var s=n.indexOf(e[1].o),l=n.indexOf(t[1].o);return s<l?-1:l<s?1:0}).reduce((e,t)=>e.concat(...t),[])}}f.IntervalMatcher=c,t=new WeakMap,n=new WeakMap,r=new WeakMap,i=new WeakMap,s=new WeakMap,l=new WeakMap,o=new WeakMap,u=new WeakMap,a=new WeakMap,c.normop=e=>null==e?null:((e.match(/([<>\(\)\[\]])/)||[])[1]||"")+((e.match(/(=)/)||[])[1]||"");var d={};function g(t){var n={},r={};let i=[];return(t=t||{}).gex&&i.push(new f.GexMatcher),t.interval&&i.push(new f.IntervalMatcher),n.top=function(){return r},n.add=function(e,s){e={...e};var l="function"==typeof t?t.call(n,e,s):null,o=Object.keys(e).filter(t=>null!=e[t]).sort();o.forEach((function(t){e[t]=String(e[t])}));for(var u,a=r,f=0;f<o.length;f++){var h=o[f],p=e[h];let t=i.reduce((e,t)=>e||t.make(h,p),void 0);if((u=a.v)&&h==a.k)if(t){var c=(g=a.g=a.g||{})[h]=g[h]||[];a=(t=c.find(e=>e.same(t))||(c.push(t),t)).keymap||(t.keymap={})}else a=u[p]||(u[p]={});else if(a.k)if(h<a.k){var d=a.s;g=a.g,a.s={k:a.k,v:a.v},d&&(a.s.s=d),g&&(a.s.g=g),a.g&&(a.g={}),a.k=h,a.v={},t?(c=(g=a.g=a.g||{})[h]=g[h]||[],a=(t=c.find(e=>e.same(t))||(c.push(t),t)).keymap||(t.keymap={})):a=a.v[p]={}}else a=a.s||(a.s={}),f--;else if(a.k=h,a.v={},t){var g;c=(g=a.g=a.g||{})[h]=g[h]||[];a=(t=c.find(e=>e.same(t))||(c.push(t),t)).keymap||(t.keymap={})}else a=a.v[p]={}}return void 0!==s&&a&&(a.d=s,l&&(a.f="function"==typeof l?l:l.find,a.r="function"==typeof l.remove?l.remove:void 0)),n},n.findexact=function(e){return n.find(e,!0)},n.find=function(e,t,i){if(null==e)return null;var s=r,l=void 0===r.d?null:r.d,o=r.f,u=null,a=[],f={},h=Object.keys(e).length,p=[];void 0!==r.d&&p.push(r.d);do{if(u=s.k,s.v){var c=e[u],d=s.v[c];if(!d&&s.g&&s.g[u])for(var g=s.g[u],m=0;m<g.length;m++)if(g[m].match(c)){d=g[m].keymap;break}d?(f[u]=!0,s.s&&a.push(s.s),l=void 0===d.d?t?null:l:d.d,i&&void 0!==d.d&&p.push(d.d),o=d.f,s=d):s=s.s}else s=null;null==s&&0<a.length&&(null==l||i&&!t)&&(s=a.pop())}while(s);return t?Object.keys(f).length!==h&&(l=null):null==l&&void 0!==r.d&&(l=r.d),o&&(l=o.call(n,e,l)),i?p:l},n.remove=function(e){var t,n=r,i=null,s=[];do{if(t=n.k,n.v||n.g){if(n.v){var l=n.v[e[t]];l&&s.push({km:n,v:e[t]})}if(null==l&&n.g){let r=n.g[t]||[];for(let i=0;i<r.length;i++)if(r[i].fix===e[t]){s.push({km:n,v:e[t],mv:r[i]}),l=r[i].keymap;break}}l?(i=l.d,n=l):n=n.s}else n=null}while(n);if(void 0!==i){var o=s[s.length-1];if(o&&o.km&&o.km.v){var u=o.km.v[o.v]||o.mv&&o.mv.keymap;!u||u.r&&!u.r(e,u.d)||delete u.d}}},n.list=function(t,n){t=t||{};var i=[];return r.d&&i.push({match:{},data:r.d,find:r.f}),function r(i,s,l,o){if(i.v){var u,a=i.k,f=e.Gex(t?null==t[a]?n?null:"*":t[a]:"*"),h={...s},p={...l};for(var c in i.v)if(c===t[a]||!n&&null==t[a]||f.on(c)){var d={...h};d[a]=c;var g={...p};delete g[a],u=i.v[c],0===Object.keys(g).length&&u&&u.d&&o.push({match:d,data:u.d,find:u.f}),u&&null!=u.v&&r(u,{...d},{...g},o)}(u=i.s)&&r(u,{...h},{...p},o)}}(r,{},{...t},i),i},n.toString=function(e,t){var n=!0===e||!!t,i="function"==typeof e?e:function(e){return"function"==typeof e?"<"+e.name+">":"<"+e+">"};function s(e,t){for(var n=0;n<t;n++)e.push(" ")}var l=[],o=[];return function e(t,n,r,o){var u;if(void 0!==t.d&&(n.push(" "+i(t.d)),l.push(o.join(", ")+" -> "+i(t.d))),t.k&&(n.push("\n"),s(n,r),n.push(t.k+":")),(t.v||t.s||t.g)&&r++,t.v)for(var a=Object.keys(t.v).sort(),f=0;f<a.length;f++){var h=a[f];n.push("\n"),s(n,r),n.push(h+" ->"),(u=o.slice()).push(t.k+"="+h),e(t.v[h],n,r+1,u)}if(t.g)for(a=Object.keys(t.g).sort(),f=0;f<a.length;f++)for(var p=t.g[a[f]],c=0;c<p.length;c++){var d=p[c];n.push("\n"),s(n,r),n.push(d.fix+" ~>"),(u=o.slice()).push(t.k+"~"+d.fix),e(d.keymap,n,r+1,u)}t.s&&(n.push("\n"),s(n,r),n.push("|"),u=o.slice(),e(t.s,n,r+1,u))}(r,o,0,[]),n?o.join(""):l.join("\n")},n.inspect=n.toString,n.toJSON=function(e){return JSON.stringify(r,(function(e,t){return"function"==typeof t?"[Function]":t}),e)},n}return Object.defineProperty(d,"__esModule",{value:!0}),d=function(e){return new g(e)}}));
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).Patrun=e()}}((function(){var e={exports:{}};(function(t){(function(){!function(n){"object"==typeof e.exports?e.exports=n():("undefined"!=typeof window?window:void 0!==t?t:"undefined"!=typeof self?self:this).Gex=n()}((function(){var e={};Object.defineProperty(e,"__esModule",{value:!0}),e.Gex=void 0;class t{constructor(e){this.desc="",this.gexmap={},(Array.isArray(e)?e:[e]).forEach(e=>{this.gexmap[e]=this.re(this.clean(e))})}dodgy(e){return null==e||Number.isNaN(e)}clean(e){let t=""+e;return this.dodgy(e)?"":t}match(e){e=""+e;let t=!1,n=Object.keys(this.gexmap);for(let r=0;r<n.length&&!t;r++)t=!!this.gexmap[n[r]].exec(e);return t}on(e){if(null==e)return null;let t=typeof e;if("string"===t||"number"===t||"boolean"===t||e instanceof Date||e instanceof RegExp)return this.match(e)?e:null;if(Array.isArray(e)){let t=[];for(let n=0;n<e.length;n++)!this.dodgy(e[n])&&this.match(e[n])&&t.push(e[n]);return t}{let t={};for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&this.match(n)&&(t[n]=e[n]);return t}}esc(e){let t=this.clean(e);return(t=t.replace(/\*/g,"**")).replace(/\?/g,"*?")}escregexp(e){return e?(""+e).replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"):""}re(e){if(""===e||e)return e="^"+(e=(e=(e=(e=(e=this.escregexp(e)).replace(/\\\*/g,"[\\s\\S]*")).replace(/\\\?/g,"[\\s\\S]")).replace(/\[\\s\\S\]\*\[\\s\\S\]\*/g,"\\*")).replace(/\[\\s\\S\]\*\[\\s\\S\]/g,"\\?"))+"$",new RegExp(e);{let e=Object.keys(this.gexmap);return 1==e.length?this.gexmap[e[0]]:{...this.gexmap}}}toString(){let e=this.desc;return""!=e?e:this.desc="Gex["+Object.keys(this.gexmap)+"]"}inspect(){return this.toString()}}return e.Gex=function(e){return new t(e)},e}))}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{}),e=e.exports;var t,n,r,i,s,o,l,u,a,f={},p=this&&this.__classPrivateFieldGet||function(e,t,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(e):r?r.value:t.get(e)};Object.defineProperty(f,"__esModule",{value:!0}),f.IntervalMatcher=f.GexMatcher=void 0,f.GexMatcher=class{constructor(){}make(t,n){if("string"==typeof n&&n.match(/[*?]/)){let t=(0,e.Gex)(n);return{kind:"gex",match:e=>null!=t.on(e),fix:n,meta:{},same(e){return null!=e&&e.kind===this.kind&&e.fix===this.fix}}}}scan(e,t){let n=e.filter(e=>"*"===e.fix).length>0;return{complete:n,sound:n,gaps:[],overs:[],why:"no-star"}}};const h=new RegExp(["^/s*","(=*[<>/(/[]?=*)?/s*([-+0-9a-fA-FeEoOxX]+(/.([0-9a-fA-FeEoOxX]+))?)([/)/]]?)(/s*(,|&+|/|+|/./.)/s*(=*[<>]?=*)/s*([-+.0-9a-fA-FeEoOxX]+)/s*([/)/]]?))?/s*$"].join("").replace(/\//g,"\\"));class c{constructor(){this.kind="interval",t.set(this,(e,t)=>function(n){return e(n)&&t(n)}),n.set(this,(e,t)=>function(n){return e(n)||t(n)}),r.set(this,e=>function(e){return!1}),i.set(this,e=>function(e){return!1}),s.set(this,e=>function(t){return t>e}),o.set(this,e=>function(t){return t>=e}),l.set(this,e=>function(t){return t<e}),u.set(this,e=>function(t){return t<=e}),a.set(this,e=>function(t){return t===e})}make(e,f){if("string"==typeof f&&f.match(/[=<>.[()\]]/)){let e=f.match(h),d={jo:"and",o0:"err",n0:NaN,o1:"err",n1:NaN},g=e=>!1;if(null!=e){let h=c.normop(e[1])||c.normop(e[5]),m=c.normop(e[8])||c.normop(e[10]),v=p(this,"="===h?a:"<"===h||")"===h?l:"<="===h||"]"===h?u:">"===h||"("===h?s:">="===h||"["===h?o:i,"f"),k=Number(e[2]),x=null==e[9]?NaN:Number(e[9]),y=e[7],w=null==y?p(this,n,"f"):"&"===y.substring(0,1)||","===y.substring(0,1)?p(this,t,"f"):p(this,n,"f");".."===y&&(w=p(this,t,"f"),v=p(this,i,"f")===v?p(this,o,"f"):v,m=""===m?"<=":m);let N=p(this,null==m?r:"="===m?a:"<"===m||")"===m?l:"<="===m||"]"===m?u:">"===m?s:">="===m?o:i,"f");if(k===x&&("="===h&&null!=m?(x=NaN,N=p(this,r,"f"),v=m.includes("<")?p(this,u,"f"):m.includes(">")?p(this,o,"f"):m.includes("=")?p(this,a,"f"):p(this,i,"f")):"="===m&&null!=h&&(x=NaN,N=p(this,r,"f"),v=h.includes("<")?p(this,u,"f"):h.includes(">")?p(this,o,"f"):p(this,i,"f"))),p(this,i,"f")!==v&&p(this,r,"f")===N&&(p(this,l,"f")===v||p(this,u,"f")===v?(N=v,x=k,v=p(this,o,"f"),k=Number.NEGATIVE_INFINITY,w=p(this,t,"f")):p(this,s,"f")!==v&&p(this,o,"f")!==v||(N=p(this,u,"f"),x=Number.POSITIVE_INFINITY,w=p(this,t,"f"))),!isNaN(x)&&x<k){let e=N,t=x;x=k,k=t,".."!==y&&(N=v,v=e)}let b=v(k),O=N(x),j=w(b,O);return{kind:"interval",fix:f,meta:d={jo:j.name,o0:b.name,n0:k,o1:O.name,n1:x},match:g=e=>{let t=!1,n=parseFloat(e);return isNaN(n)||(t=j(n)),t},same(e){return null!=e&&e.kind===this.kind&&e.meta.jo===this.meta.jo&&e.meta.o0===this.meta.o0&&e.meta.n0===this.meta.n0&&e.meta.o1===this.meta.o1&&e.meta.n1===this.meta.n1}}}}}scan(e,t){let n={complete:!1,sound:!1,gaps:[],overs:[],lower:null,upper:null},r=Number.NEGATIVE_INFINITY,i=Number.POSITIVE_INFINITY,s=this.half_intervals(e);s.reduce((e,t)=>{let n="eq"===t.o,i="lt"===t.o,s="lte"===t.o,o="gt"===t.o,l="gte"===t.o,u=t.n;if(null==e.lower){let i={n:r,o:"gte"};e.lower=i,e.upper=t,r==u&&l||(o||l?e.gaps.push([i,{n:u,o:o?"lte":"lt",m:0}]):n&&e.gaps.push([i,{n:u,o:"lte",m:1}]))}else{let r="eq"===e.upper.o,a="lt"===e.upper.o,f="lte"===e.upper.o,p=(e.upper.o,e.upper.o,e.upper.n),h=e.upper;u===p?a&&(l||n)||(f||r)&&o||(r||a||f)&&e.gaps.push([{n:p,o:r||f?"gt":"gte",m:2,d:{u:h,h:t}},{n:u,o:n||l?"lt":"lte",m:3}]):p<u?i||s||(r||a||f)&&e.gaps.push([{n:p,o:r||f?"gt":"gte",m:4},{n:u,o:n||l?"lt":"lte",m:5}]):e.overs.push([{n:u,o:n||l?"gte":"gt",m:10},{n:p,o:r||f?"lte":"lt",m:11}]),e.upper=t}return e},n);let o=0<s.length&&s[s.length-1];return o&&i!==o.n&&"gt"!==o.o&&"gte"!==o.o&&n.gaps.push([{n:o.n,o:"eq"===o.o||"lte"===o.o?"gt":"gte",m:6},{n:i,o:"lte",m:7}]),n.complete=0===n.gaps.length,n.sound=0===n.overs.length,n}half_intervals(e){let t=[];for(let r of e)t.push([{n:r.meta.n0,o:r.meta.o0},{n:r.meta.n1,o:r.meta.o1}]);var n=["lt","lte","eq","gte","gt"];return t.map(e=>[isNaN(e[0].n)||null==e[0].n?null:e[0],isNaN(e[1].n)||null==e[1].n?null:e[1]].filter(e=>null!=e)).sort((e,t)=>{if(e[0].n<t[0].n)return-1;if(t[0].n<e[0].n)return 1;var r=n.indexOf(e[0].o),i=n.indexOf(t[0].o);if(r<i)return-1;if(i<r)return 1;if(e[1].n<t[1].n)return-1;if(t[1].n<e[1].n)return 1;var s=n.indexOf(e[1].o),o=n.indexOf(t[1].o);return s<o?-1:o<s?1:0}).reduce((e,t)=>e.concat(...t),[])}}f.IntervalMatcher=c,t=new WeakMap,n=new WeakMap,r=new WeakMap,i=new WeakMap,s=new WeakMap,o=new WeakMap,l=new WeakMap,u=new WeakMap,a=new WeakMap,c.normop=e=>null==e?null:((e.match(/([<>\(\)\[\]])/)||[])[1]||"")+((e.match(/(=)/)||[])[1]||"");var d={exports:{}};function g(t){var n={},r={};let i=[];return(t=t||{}).gex&&i.push(new f.GexMatcher),t.interval&&i.push(new f.IntervalMatcher),n.top=function(){return r},n.add=function(e,s){e={...e};var o="function"==typeof t?t.call(n,e,s):null,l=Object.keys(e).filter(t=>null!=e[t]).sort();l.forEach((function(t){e[t]=String(e[t])}));for(var u,a=r,f=0;f<l.length;f++){var p=l[f],h=e[p];let t=i.reduce((e,t)=>e||t.make(p,h),void 0);if((u=a.v)&&p==a.k)if(t){var c=(g=a.g=a.g||{})[p]=g[p]||[];a=(t=c.find(e=>e.same(t))||(c.push(t),t)).keymap||(t.keymap={})}else a=u[h]||(u[h]={});else if(a.k)if(p<a.k){var d=a.s;g=a.g,a.s={k:a.k,v:a.v},d&&(a.s.s=d),g&&(a.s.g=g),a.g&&(a.g={}),a.k=p,a.v={},t?(c=(g=a.g=a.g||{})[p]=g[p]||[],a=(t=c.find(e=>e.same(t))||(c.push(t),t)).keymap||(t.keymap={})):a=a.v[h]={}}else a=a.s||(a.s={}),f--;else if(a.k=p,a.v={},t){var g;c=(g=a.g=a.g||{})[p]=g[p]||[];a=(t=c.find(e=>e.same(t))||(c.push(t),t)).keymap||(t.keymap={})}else a=a.v[h]={}}return void 0!==s&&a&&(a.d=s,o&&(a.f="function"==typeof o?o:o.find,a.r="function"==typeof o.remove?o.remove:void 0)),n},n.findexact=function(e){return n.find(e,!0)},n.find=function(e,t,i){if(null==e)return null;var s=r,o=void 0===r.d?null:r.d,l=r.f,u=null,a=[],f={},p=Object.keys(e).length,h=[];void 0!==r.d&&h.push(r.d);do{if(u=s.k,s.v){var c=e[u],d=s.v[c];if(!d&&s.g&&s.g[u])for(var g=s.g[u],m=0;m<g.length;m++)if(g[m].match(c)){d=g[m].keymap;break}d?(f[u]=!0,s.s&&a.push(s.s),o=void 0===d.d?t?null:o:d.d,i&&void 0!==d.d&&h.push(d.d),l=d.f,s=d):s=s.s}else s=null;null==s&&0<a.length&&(null==o||i&&!t)&&(s=a.pop())}while(s);return t?Object.keys(f).length!==p&&(o=null):null==o&&void 0!==r.d&&(o=r.d),l&&(o=l.call(n,e,o)),i?h:o},n.remove=function(e){var t,n=r,i=null,s=[];do{if(t=n.k,n.v||n.g){if(n.v){var o=n.v[e[t]];o&&s.push({km:n,v:e[t]})}if(null==o&&n.g){let r=n.g[t]||[];for(let i=0;i<r.length;i++)if(r[i].fix===e[t]){s.push({km:n,v:e[t],mv:r[i]}),o=r[i].keymap;break}}o?(i=o.d,n=o):n=n.s}else n=null}while(n);if(void 0!==i){var l=s[s.length-1];if(l&&l.km&&l.km.v){var u=l.km.v[l.v]||l.mv&&l.mv.keymap;!u||u.r&&!u.r(e,u.d)||delete u.d}}},n.list=function(t,n){t=t||{};var i=[];return r.d&&i.push({match:{},data:r.d,find:r.f}),function r(i,s,o,l){if(i.v){var u,a=i.k,f=(0,e.Gex)(t?null==t[a]?n?null:"*":t[a]:"*"),p={...s},h={...o};for(var c in i.v)if(c===t[a]||!n&&null==t[a]||f.on(c)){var d={...p};d[a]=c;var g={...h};delete g[a],u=i.v[c],0===Object.keys(g).length&&u&&u.d&&l.push({match:d,data:u.d,find:u.f}),u&&null!=u.v&&r(u,{...d},{...g},l)}(u=i.s)&&r(u,{...p},{...h},l)}}(r,{},{...t},i),i},n.toString=function(e,t){var n=!0===e||!!t,i="function"==typeof e?e:function(e){return"function"==typeof e?"<"+e.name+">":"<"+e+">"};function s(e,t){for(var n=0;n<t;n++)e.push(" ")}var o=[],l=[];return function e(t,n,r,l){var u;if(void 0!==t.d&&(n.push(" "+i(t.d)),o.push(l.join(", ")+" -> "+i(t.d))),t.k&&(n.push("\n"),s(n,r),n.push(t.k+":")),(t.v||t.s||t.g)&&r++,t.v)for(var a=Object.keys(t.v).sort(),f=0;f<a.length;f++){var p=a[f];n.push("\n"),s(n,r),n.push(p+" ->"),(u=l.slice()).push(t.k+"="+p),e(t.v[p],n,r+1,u)}if(t.g)for(a=Object.keys(t.g).sort(),f=0;f<a.length;f++)for(var h=t.g[a[f]],c=0;c<h.length;c++){var d=h[c];n.push("\n"),s(n,r),n.push(d.fix+" ~>"),(u=l.slice()).push(t.k+"~"+d.fix),e(d.keymap,n,r+1,u)}t.s&&(n.push("\n"),s(n,r),n.push("|"),u=l.slice(),e(t.s,n,r+1,u))}(r,l,0,[]),n?l.join(""):o.join("\n")},n.inspect=n.toString,n.toJSON=function(e){return JSON.stringify(r,(function(e,t){return"function"==typeof t?"[Function]":t}),e)},n}function m(e){return new g(e)}return Object.defineProperty(d.exports,"__esModule",{value:!0}),d.exports.Gex=d.exports.Patrun=void 0,Object.defineProperty(d.exports,"Gex",{enumerable:!0,get:function(){return e.Gex}}),d.exports.Patrun=g,d.exports=m,d.exports.default=m,d=d.exports}));
{
"name": "patrun",
"version": "7.1.0",
"version": "7.2.1",
"main": "dist/patrun.js",

@@ -32,3 +32,3 @@ "browser": "dist/patrun.min.js",

"repo-publish": "npm run clean && npm i && npm run repo-publish-quick",
"repo-publish-quick": "npm run prettier && npm run build && npm run test && npm run test-web && npm run repo-tag && npm publish --registry http://registry.npmjs.org "
"repo-publish-quick": "npm run prettier && npm run build && npm run test && npm run test-web && npm run repo-tag && npm publish --registry https://registry.npmjs.org "
},

@@ -48,15 +48,16 @@ "license": "MIT",

"devDependencies": {
"@hapi/code": "^8.0.3",
"@hapi/lab": "^24.1.1",
"@hapi/code": "^9.0.1",
"@hapi/lab": "^25.0.1",
"@types/node": "^18.0.0",
"benchmark": "^2.1.4",
"coveralls": "^3.1.0",
"browserify": "^17.0.0",
"coveralls": "^3.1.1",
"hapi-lab-shim": "0.0.2",
"jsonic": "^1.0.1",
"lab-transform-typescript": "^3.0.1",
"prettier": "^2.2.1",
"serve": "^11.3.2",
"browserify": "^17.0.0",
"prettier": "^2.7.1",
"serve": "^13.0.2",
"tinyify": "^3.0.0",
"typescript": "^4.2.4"
"typescript": "^4.7.4"
}
}

@@ -16,6 +16,2 @@ /* Copyright (c) 2013-2020 Richard Rodger, MIT License */

module.exports = function (custom: any) {
return new (Patrun as any)(custom)
}
function Patrun(custom: any) {

@@ -482,3 +478,3 @@ custom = custom || {}

top,
function (key: any, val: any) {
function (_key: any, val: any) {
if ('function' === typeof val) return '[Function]'

@@ -493,1 +489,13 @@ return val

}
function make(custom: any) {
return new (Patrun as any)(custom)
}
if ('undefined' !== typeof module) {
module.exports = make
}
export default make
export { Patrun, Gex }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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