te-flow
Version:
A function pipeline of sorts to control flow.
1 lines • 13.1 kB
JavaScript
!function(t,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports["te-flow"]=r():t["te-flow"]=r()}(this,function(){return function(t){function r(e){if(n[e])return n[e].exports;var o=n[e]={i:e,l:!1,exports:{}};return t[e].call(o.exports,o,o.exports,r),o.l=!0,o.exports}var n={};return r.m=t,r.c=n,r.i=function(t){return t},r.d=function(t,n,e){r.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:e})},r.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(n,"a",n),n},r.o=function(t,r){return Object.prototype.hasOwnProperty.call(t,r)},r.p="",r(r.s=6)}([function(t,r,n){var e,o,i;!function(s,u){o=[r,n(0)],e=u,void 0!==(i="function"==typeof e?e.apply(r,o):e)&&(t.exports=i)}(0,function(r,n){"use strict";var n=function(t){var r=t.constructor;return r.prototype=t,r};n.extend=function(t,r){var e=Object.create(t.prototype);for(var o in r)e[o]=r[o];return n(e)},t.exports=n})},function(t,r){function n(t,r,n){switch(n.length){case 0:return t.call(r);case 1:return t.call(r,n[0]);case 2:return t.call(r,n[0],n[1]);case 3:return t.call(r,n[0],n[1],n[2])}return t.apply(r,n)}function e(t,r){for(var n=-1,e=Array(t);++n<t;)e[n]=r(n);return e}function o(t,r){var n=R(t)||g(t)?e(t.length,String):[],o=n.length,i=!!o;for(var s in t)!r&&!U.call(t,s)||i&&("length"==s||c(s,o))||n.push(s);return n}function i(t,r,n,e){return void 0===t||y(t,F[n])&&!U.call(e,n)?r:t}function s(t,r,n){var e=t[r];U.call(t,r)&&y(e,n)&&(void 0!==n||r in t)||(t[r]=n)}function u(t){if(!j(t))return h(t);var r=_(t),n=[];for(var e in t)("constructor"!=e||!r&&U.call(t,e))&&n.push(e);return n}function a(t,r){return r=K(void 0===r?t.length-1:r,0),function(){for(var e=arguments,o=-1,i=K(e.length-r,0),s=Array(i);++o<i;)s[o]=e[r+o];o=-1;for(var u=Array(r+1);++o<r;)u[o]=e[o];return u[r]=s,n(t,this,u)}}function f(t,r,n,e){n||(n={});for(var o=-1,i=r.length;++o<i;){var u=r[o],a=e?e(n[u],t[u],u,n,t):void 0;s(n,u,void 0===a?t[u]:a)}return n}function p(t){return a(function(r,n){var e=-1,o=n.length,i=o>1?n[o-1]:void 0,s=o>2?n[2]:void 0;for(i=t.length>3&&"function"==typeof i?(o--,i):void 0,s&&l(n[0],n[1],s)&&(i=o<3?void 0:i,o=1),r=Object(r);++e<o;){var u=n[e];u&&t(r,u,e,i)}return r})}function c(t,r){return!!(r=null==r?L:r)&&("number"==typeof t||x.test(t))&&t>-1&&t%1==0&&t<r}function l(t,r,n){if(!j(n))return!1;var e=typeof r;return!!("number"==e?v(n)&&c(r,n.length):"string"==e&&r in n)&&y(n[r],t)}function _(t){var r=t&&t.constructor;return t===("function"==typeof r&&r.prototype||F)}function h(t){var r=[];if(null!=t)for(var n in Object(t))r.push(n);return r}function y(t,r){return t===r||t!==t&&r!==r}function g(t){return d(t)&&U.call(t,"callee")&&(!z.call(t,"callee")||S.call(t)==T)}function v(t){return null!=t&&b(t.length)&&!A(t)}function d(t){return O(t)&&v(t)}function A(t){var r=j(t)?S.call(t):"";return r==k||r==w}function b(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=L}function j(t){var r=typeof t;return!!t&&("object"==r||"function"==r)}function O(t){return!!t&&"object"==typeof t}function m(t){return v(t)?o(t,!0):u(t)}var L=9007199254740991,T="[object Arguments]",k="[object Function]",w="[object GeneratorFunction]",x=/^(?:0|[1-9]\d*)$/,F=Object.prototype,U=F.hasOwnProperty,S=F.toString,z=F.propertyIsEnumerable,K=Math.max,R=Array.isArray,E=p(function(t,r,n,e){f(r,m(r),t,e)}),I=a(function(t){return t.push(void 0,i),n(E,void 0,t)});t.exports=I},function(t,r){function n(t){var r=e(t)?u.call(t):"";return r==o||r==i}function e(t){var r=typeof t;return!!t&&("object"==r||"function"==r)}var o="[object Function]",i="[object GeneratorFunction]",s=Object.prototype,u=s.toString;t.exports=n},function(t,r){function n(t){var r=typeof t;return!!t&&("object"==r||"function"==r)}t.exports=n},function(t,r,n){(function(r){function n(t,r){return null==t?void 0:t[r]}function e(t){var r=!1;if(null!=t&&"function"!=typeof t.toString)try{r=!!(t+"")}catch(t){}return r}function o(t){var r=-1,n=t?t.length:0;for(this.clear();++r<n;){var e=t[r];this.set(e[0],e[1])}}function i(){this.__data__=Z?Z(null):{}}function s(t){return this.has(t)&&delete this.__data__[t]}function u(t){var r=this.__data__;if(Z){var n=r[t];return n===R?void 0:n}return Q.call(r,t)?r[t]:void 0}function a(t){var r=this.__data__;return Z?void 0!==r[t]:Q.call(r,t)}function f(t,r){return this.__data__[t]=Z&&void 0===r?R:r,this}function p(t){var r=-1,n=t?t.length:0;for(this.clear();++r<n;){var e=t[r];this.set(e[0],e[1])}}function c(){this.__data__=[]}function l(t){var r=this.__data__,n=O(r,t);return!(n<0)&&(n==r.length-1?r.pop():X.call(r,n,1),!0)}function _(t){var r=this.__data__,n=O(r,t);return n<0?void 0:r[n][1]}function h(t){return O(this.__data__,t)>-1}function y(t,r){var n=this.__data__,e=O(n,t);return e<0?n.push([t,r]):n[e][1]=r,this}function g(t){var r=-1,n=t?t.length:0;for(this.clear();++r<n;){var e=t[r];this.set(e[0],e[1])}}function v(){this.__data__={hash:new o,map:new(Y||p),string:new o}}function d(t){return L(this,t).delete(t)}function A(t){return L(this,t).get(t)}function b(t){return L(this,t).has(t)}function j(t,r){return L(this,t).set(t,r),this}function O(t,r){for(var n=t.length;n--;)if(U(t[n][0],r))return n;return-1}function m(t){return!(!z(t)||w(t))&&(S(t)||e(t)?W:P).test(x(t))}function L(t,r){var n=t.__data__;return k(r)?n["string"==typeof r?"string":"hash"]:n.map}function T(t,r){var e=n(t,r);return m(e)?e:void 0}function k(t){var r=typeof t;return"string"==r||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==t:null===t}function w(t){return!!J&&J in t}function x(t){if(null!=t){try{return N.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function F(t,r){if("function"!=typeof t||r&&"function"!=typeof r)throw new TypeError(K);var n=function(){var e=arguments,o=r?r.apply(this,e):e[0],i=n.cache;if(i.has(o))return i.get(o);var s=t.apply(this,e);return n.cache=i.set(o,s),s};return n.cache=new(F.Cache||g),n}function U(t,r){return t===r||t!==t&&r!==r}function S(t){var r=z(t)?V.call(t):"";return r==E||r==I}function z(t){var r=typeof t;return!!t&&("object"==r||"function"==r)}var K="Expected a function",R="__lodash_hash_undefined__",E="[object Function]",I="[object GeneratorFunction]",$=/[\\^$.*+?()[\]{}|]/g,P=/^\[object .+?Constructor\]$/,C="object"==typeof r&&r&&r.Object===Object&&r,G="object"==typeof self&&self&&self.Object===Object&&self,M=C||G||Function("return this")(),q=Array.prototype,B=Function.prototype,D=Object.prototype,H=M["__core-js_shared__"],J=function(){var t=/[^.]+$/.exec(H&&H.keys&&H.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),N=B.toString,Q=D.hasOwnProperty,V=D.toString,W=RegExp("^"+N.call(Q).replace($,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),X=q.splice,Y=T(M,"Map"),Z=T(Object,"create");o.prototype.clear=i,o.prototype.delete=s,o.prototype.get=u,o.prototype.has=a,o.prototype.set=f,p.prototype.clear=c,p.prototype.delete=l,p.prototype.get=_,p.prototype.has=h,p.prototype.set=y,g.prototype.clear=v,g.prototype.delete=d,g.prototype.get=A,g.prototype.has=b,g.prototype.set=j,F.Cache=g,t.exports=F}).call(r,n(5))},function(t,r){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,r,n){"use strict";function e(t){return Array.isArray(t)?t:Array.from(t)}var o=n(2),i=n(3),s=n(4),u=n(1),a=n(0),f=a({constructor:function(t){var r=this;if(r._self=r,r.userOptions={},t){["initArgs","args","this","stream","objReturn","objKeep","flow","flatten","start","res","end"].forEach(function(n){r._L.isUdf(t[n])||(r.userOptions[n]=t[n])}),r._L.isUdf(t.memoize)||(r._memoize=t.memoize)}},invoke:function(){for(var t=this,r=new Array(arguments.length),n=0;n<r.length;++n)r[n]=arguments[n];if(t.args=r,t.argsToApply={_fnArgs:[]},!t.count){t.count=1;var e=t.checkOpts(t.args);t.args=e.args,t.argsToApply=e.argsToApply}t.first=t.args.length?t.args.shift():null,t.rest=t.args,t.firstIsFn=t._L.isFn(t.first),t.firstIsUdf=t._L.isUdf(t.first);var o=t.rest[t.rest.length-1];return!t._L.isUdf(o)&&o._fnArgs&&(t.argsToApply._fnArgs=t.rest.pop()._fnArgs),t.process()},checkOpts:function(t){var r=this,n=Object.keys(r.userOptions),e=t[0],o=!r._L.isFn(e)&&r._L.isObj(e),i=["_stream","_objReturn","_objKeep","_flow","_args","_flatten","_start","_res","_end","_option","_this"],s=!1;if(o){e=e._option?e._option:e;for(var u=Object.keys(e),a=0;a<u.length&&!s;a++)i.indexOf(u[a])!==-1&&(s=!0)}r.streamOpt=[];var f=function(t,n,o){return r._L.isUdf(r.userOptions[t])?r._L.isUdf(e[n])?o:e[n]:r.userOptions[t]};if(r.optList={_kill:f("kill","_kill",!1),_return:f("return","_return",!1),_stream:f("stream","_stream",!0),_objReturn:f("objReturn","_objReturn",!0),_objKeep:f("objKeep","_objKeep",!1),_flow:f("flow","_flow",!1),_flatten:f("flatten","_flatten",!1)},r.optStreamList={_start:f("start","_start",null),_res:f("res","_res",null),_end:f("end","_end",null)},o&&s||n.length){r.userOptions.this?r._this=r.userOptions.this:r._this=e._this?e._this:null;var p=function(t){return r._L.isFn(t)?t():Object.keys(t).reduce(function(n,e){var o=t[e];return n[e]=r._L.isFn(o)?o():t[e],n},{})};if(r.userOptions.initArgs||r.userOptions.args){var c=r.userOptions.args||r.userOptions.initArgs;r.applyArgs(p(c),!0)}else e._args?r.applyArgs(p(e._args),!0):e._initArgs&&r.applyArgs(p(e._initArgs),!0);r._memoize||(r._memoize=e._memoize!==!1),Object.keys(r.optStreamList).forEach(function(t){e[t]&&(r.streamOpt.push(t),null===r.optStreamList[t]&&(r.optStreamList[t]=e[t]))}),n.length||t.shift()}return{args:t,argsToApply:r.argsToApply}},applyOpts:function(t,r){var n=this,o=function t(r,o){var i=e(o),s=i[0],u=i.slice(1);if(void 0!==r)return n._L.isArr(r)||(r=[r]),void 0===s?r:t(s.apply(n._this,r),u)},i=function(t,r){var e=n._L.memoize(function(t){return o(t,r)}),i=n._memoize?e:o;return t.map(function(t){var e=i(t,r);if(!n._L.isUdf(e)&&e[0])return e[0]})},s=function(t,r){return n._L.isFn(r)?i(t,r):n._L.isObj(r)?i(t,Object.keys(r).map(function(t){return r[t]})):n._L.isArr(r)?i(t,r):void 0},u=function(t,r,e){return e=e.filter(function(t){return"_start"!==t&&"_res"!==t&&"_end"!==t?t:"_start"===t&&r._start?t:"_res"===t&&r._res?t:"_end"===t&&r._end?t:void 0}),e.reduce(function(t,r){return s(t,n.optStreamList[r])},t)},a=function(t,r,e){var o={_start:!1,_end:!1,_res:!1};return u.apply(n,[t,n._L.defaults(r,o),e])};return this.streamOpt.length?a(t,r,this.streamOpt):t},applyArgs:function(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=this,e=!1;if(void 0!==t){var o=function(t){if(n.optList._flow)n.argsToApply._fnArgs.push(t);else if(n.optList._objReturn&&n._L.isObj(t)){var r=n.optList._objKeep;r=e?!r:r,n.argsToApply._fnArgs=Object.keys(t).map(function(n){var e=void 0;return r&&(e={},e[n]=t[n]),r?e:t[n]})}else t=n._L.isArr(t)?t:[t],n.argsToApply._fnArgs=t};if(r)o(t);else{var i=function(t){return n._L.isUdf(t)||(t._this&&(n._this=t._this,delete t._this),n._L.isUdf(t._objKeep)||(e=!0,delete t._objKeep),t._kill===!0&&(n.optList._kill=!0,delete t._kill),t._return===!0&&(n.optList._return=!0,delete t._return)),t};o(function(){if(!n._L.isArr(t)){t=[i(t)];return n.applyOpts(t,{_res:!0})[0]}return n.applyOpts(i(t),{_res:!0})}()),n.argsToApply._fnArgs=n.optList._flatten?n._L.flatten(n.argsToApply._fnArgs):n.argsToApply._fnArgs,n.argsToApply._fnArgs=n.applyOpts(n.argsToApply._fnArgs,{_end:!0})}}},process:function(){var t=this;if(!t.optList._kill){if(t.optList._return){var r=t.rest[t.rest.length-1];return t._L.isObj(r)&&"return"===Object.keys(r)[0]?r.return.apply(t._this,t.argsToApply._fnArgs||[]):t.argsToApply._fnArgs||[]}if(t.firstIsFn){var n=Object.keys(t.argsToApply).length?t.first.apply(t._this,t.applyOpts(t.argsToApply._fnArgs,{_start:!0})):t.first.call(t._this);return t.applyArgs(n),Object.keys(t.argsToApply).length&&t.rest.push(t.argsToApply),t.invoke.apply(t,t.rest)}if(t._L.isObj(t.first)&&t.first.return){var e=t.first.return;return t._L.isFn(e)?e.apply(t._this,t.argsToApply._fnArgs||[]):e}return t._L.isObj(t.first)&&t.first._fnArgs?t.first._fnArgs.length?t.first._fnArgs:void 0:t.firstIsFn||t.firstIsUdf||null===t.first?t._L.isUdf(t.first)&&t.rest.length?(Object.keys(t.argsToApply).length&&t.rest.push(t.argsToApply),t.invoke.apply(t,t.rest)):t.rest.length?void 0:Object.keys(t.argsToApply).length?t.argsToApply._fnArgs:void 0:(t.applyArgs(t.first),Object.keys(t.argsToApply).length&&t.rest.push(t.argsToApply),t.invoke.apply(t,t.rest))}},_L:{flatten:function(t){return function t(r,n){for(var e=0;e<r.length;e++){var o=r[e];Array.isArray(o)?t(o,n):n.push(o)}return n}(t,[])},defaults:function(){for(var t=new Array(arguments.length),r=0;r<t.length;++r)t[r]=arguments[r];return u(t.shift(),t)},memoize:function(t){return s(t)},isFn:function(t){return o(t)},isObj:function(t){return i(t)},isArr:function(t){return Array.isArray(t)},isUdf:function(t){return void 0===t}}});t.exports=function(){for(var t=new Array(arguments.length),r=0;r<t.length;++r)t[r]=arguments[r];if(t.length){var n=new f(this);return n.invoke.apply(n._self,t)}}}])});