@minionorg/share
Version:
2 lines (1 loc) • 1.88 kB
JavaScript
(function(s,r){typeof exports=="object"&&typeof module<"u"?r(exports):typeof define=="function"&&define.amd?define(["exports"],r):(s=typeof globalThis<"u"?globalThis:s||self,r(s.index={}))})(this,function(s){"use strict";var P=Object.defineProperty;var N=(s,r,i)=>r in s?P(s,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):s[r]=i;var a=(s,r,i)=>(N(s,typeof r!="symbol"?r+"":r,i),i);function r(e){return e.charAt(0).toUpperCase()+e.slice(1)}function i(e){if(!e)throw new SyntaxError("type is must");return function(t){return Object.prototype.toString.call(t)===`[object ${r(e)}]`}}const h=i("Function");class u{constructor(t,n="nextSuccessor"){a(this,"fn");a(this,"nextNode");a(this,"nextFlag");if(!h(t))throw new Error(`${t} is no a function`);this.fn=t,this.nextNode=null,this.nextFlag=n}after(t,n=this.nextFlag){const o=t instanceof u;return this.nextNode=o?t:new u(t,n)}start(...t){const n=this.fn.apply(this,t);return n===this.nextFlag?this.next.apply(this,t):n}next(){return this.nextNode&&this.nextNode.start.apply(this.nextNode,arguments)}}const x=i("Object"),d=function(e){return Object.getOwnPropertyNames(e).length===0?!0:"nextSuccessor"},y=function(e){return Object.keys(e).length===0};function f(e){if(!x(e))throw new Error(`${e} is no a object type`);const t=new u(d);return t.after(y),t.start(e)}function m(e){const t=/([^?=&]+)=([^&]*)/gi,n={};return e.replace(t,(o,c,l)=>{n[c]=l}),f(n)?"nextSuccessor":n}function g(e){const t=e.split("?")[1],n={},o=t&&t.split("&");return o&&o.reduce((c,l)=>{const p=l.split("=");return c[p[0]]=p[1],c},n),f(n)?"nextSuccessor":n}function w(e){const t=e.split("?")[1],n=new URLSearchParams(t),o={};for(const c of n)o[c[0]]=c[1];return f(o)?null:o}function S(e){const t=new u(m);return t.after(g).after(w),t.start(e)}s.default=S,Object.defineProperties(s,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});