UNPKG

@minionorg/share

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