Comparing version 0.0.37 to 0.0.38
@@ -1,2 +0,2 @@ | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((n=n||self).data={})}(this,function(n){"use strict";function t(n){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(n){return typeof n}:function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n})(n)}function r(n,t,r){return t in n?Object.defineProperty(n,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[t]=r,n}function e(n,t){var r=Object.keys(n);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(n);t&&(e=e.filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable})),r.push.apply(r,e)}return r}function u(n){for(var t=1;t<arguments.length;t++){var u=null!=arguments[t]?arguments[t]:{};t%2?e(Object(u),!0).forEach(function(t){r(n,t,u[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(u)):e(Object(u)).forEach(function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(u,t))})}return n}function i(n,t){return function(n){if(Array.isArray(n))return n}(n)||function(n,t){if(!(Symbol.iterator in Object(n)||"[object Arguments]"===Object.prototype.toString.call(n)))return;var r=[],e=!0,u=!1,i=void 0;try{for(var o,c=n[Symbol.iterator]();!(e=(o=c.next()).done)&&(r.push(o.value),!t||r.length!==t);e=!0);}catch(n){u=!0,i=n}finally{try{e||null==c.return||c.return()}finally{if(u)throw i}}return r}(n,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var o=function(n){for(var t=arguments.length,r=new Array(t>1?t-1:0),e=1;e<t;e++)r[e-1]=arguments[e];if(0==r.length)throw new Error("You must provide an initial value and a non-empty spread of functions.");return r.reduce(function(n,t){return t(n)},n)},c=function(n){return function(t){return n.reduce(function(n,e){return Object.assign(n,r({},e,t))},{})}},a=function(n,t){return n>0?function(n,t){return Array(n).fill(t)}(n,t).join(""):""};function f(n,t){var r=Object(t)===t,e=null==t,u=r&&Array.isArray(t),i=r&&!u,o=r&&"function"==typeof t,c=!r,a=i&&t.type&&t.tag,f=a&&"value"in t,s=a&&!f;return n({notPrimative:r,isPrimative:c,isString:"string"==typeof t,isNil:e,isArray:u,isObject:i,isPojo:i&&"Object"==t.constructor.name,isDate:i&&t instanceof Date,isError:i&&t instanceof Error,value:t,isFunction:o,isStag:a,valueStag:f,emptyStag:s})}var s=function(n){return f(function n(t){return function(r){var e=r.value,u=r.isPojo,c=r.isObject,s=r.isArray,l=r.isDate,p=r.isError,g=r.valueStag,v=r.emptyStag,y=r.isString,h=r.isFunction,d=a(t,""),m=a(t-1,""),b=a(t+1,"");return g?e.type+"."+e.tag+"("+(void 0===e.value?"":f(n(t+1),e.value))+(t>0?""+m:"")+d+")":v?e.type+"."+e.tag+"()":u?0==Object.keys(e).length?"{}":o(e,Object.entries,function(r){return r.map(function(r){var e=i(r,2),u=e[0],o=e[1];return b+'"'+u+'":'+f(n(t+1),o).replace(""+b,"")})},function(n){return d+"{"+n+d+"}"}):s?"0"==e.length?"[]":d+"["+d+d+e.map(function(r){return f(n(t+1),r)}).join(", ")+d+"]":l?"new "+e.constructor.name+'("'+e.toISOString()+'")':p?"new "+e.constructor.name+'("'+e.message+'")':h?e+"":c?"new "+e.constructor.name+"()":y?JSON.stringify(e):""+e}}(0),n)};function l(){return s(this)}function p(n){return n.type}function g(n){return n.tag}var v=r({toString:l,inspect:l},Symbol.for("nodejs.util.inspect.custom"),l);function y(n,t,r){return Object.assign(Object.create(v),{type:n,tag:t,value:r})}function h(n,t){return Object.assign(Object.create(v),{type:n,tag:t})}var d=function(n){return n.reduce(function(n,t){var e=i(t,2);return u({},n,r({},e[0],e[1]))},{})},m=["ExtraTags","MissingTags","InstanceNull","InstanceWrongType","InstanceShapeInvalid","VisitorNotAFunction","NotAType","TagsShapeInvalid"].reduce(function(n,t){return n[t]=function(r){return y(n.type,t,r)},n.tags.push(t),n},{type:"StaticSumTypeError",tags:[],specs:{}});function b(n){return n.tags}var O={ExtraTags:function(n){return["Your tag function must have exactly the same"," keys as the type: "+n.T.type+". ","The following tags should not have been present:",n.extraKeys.join(", ")].join(" ")},MissingTags:function(n){return["Your tag function must have exactly the same","keys as the type: "+n.T.type+". The following keys were","missing:",n.missingKeys.join(", ")].join(" ")},InstanceNull:function(n){return"Null is not a valid member of the type "+n.T.type},InstanceWrongType:function(n){return[s(n.x)+" is not a valid member of the type",n.T.type,"which expects the following tags",b(n.T).join(" | ")].join(" ")},InstanceShapeInvalid:function(n){return[s(n.x),"is not a valid Member of the type:",n.T.type+". ","Please review the definition of "+n.T.type].join(" ")},VisitorNotAFunction:function(n){return n.context+" expected a visitor function but instead received "+s(n.visitor)},NotAType:function(n){return n.context+" expected a Type ({ type: string, tags: string[] }) but received "+s(n.T)},TagsShapeInvalid:function(n,t){return"fold("+p(n)+") tags provided were not the right shape. Expected { [tag]: f } but received "+s(t)}};function S(n){var r=n();return N("fold",r),function(n){!function(n,r){if(null==r||Array.isArray(r)||"object"!==t(r)){var e=T.TagsShapeInvalid(n,r);return w(e)}}(r,n);var e=Object.keys(n),u=b(r),i=[[e,r],[u,n]].map(function(n){var t=n[0],r=n[1];return t.filter(function(n){return!(n in r)})}),o=i[0],c=i[1];return c.length>0?w(T.MissingTags({T:r,tags:n,missingKeys:c})):o.length>0?w(T.ExtraTags({T:r,tags:n,extraKeys:o})):function(t){return P(r,n,t)&&n[g(t)](t.value)}}}var j=function(n){return(t=O,function(n){return t[n.tag](n.value)})(n);var t};function w(n){throw new Error(g(n)+": "+j(n))}var T=m;function N(n,t){if(null==t||!(null!=t&&"string"==typeof t.type&&Array.isArray(t.tags)&&"specs"in t))return w(T.NotAType({context:n,T:t}))}function A(n){if("function"!=typeof n.visitor)return w(T.VisitorNotAFunction({context:n.context,visitor:n.visitor}))}function x(n,t){if(null==t||p(t)!=n.type||!b(n).includes(g(t)))return w(T.InstanceShapeInvalid({x:t,T:n}))}function P(n,t,r){return null==r?w(T.InstanceNull({T:n,tags:t,x:r})):p(r)!==n.type?w(T.InstanceWrongType({T:n,tags:t,x:r})):!!b(n).includes(g(r))||w(T.InstanceShapeInvalid({T:n,tags:t,x:r}))}function I(n){return S(function(){return n})}var E=function(n){var t=I(n);return function(r){var e=t(r);return function(t){x(n,t);var r=e(t);return n[g(t)](r)}}},Y=function(n){var t=I(n);return function(r){var e=t(r);return function(t){if(P(n,r,t),"value"in t){var u=e(t);return P(n,r,u)&&u}return t}}},W=function(n,t){return u({type:n,specs:{},tags:t},d(t.map(function(t){return[t,function(){return arguments.length?y(n,t,arguments.length<=0?void 0:arguments[0]):h(n,t)}]})))};function $(n){return W(n,["Y","N"])}var K=$("stags.Either"),B=function(n){var t=I(n),e=n.specs["stags/bifunctor"],u=e.left,i=e.right;return function(n,e){var o;return t((r(o={},u,n),r(o,i,e),o))}},M=function(n){return N("bifold",n),B(n)},D=function(n){return N("bimap",n),function(n){var t=E(n),e=n.specs["stags/bifunctor"],u=e.left,i=e.right;return function(n,e){var o;return t((r(o={},u,n),r(o,i,e),o))}}(n)},k=function(n){return N("getOr",n),function(t){return function(r){return x(n,r),function(n){return function(t){return B(n)(function(){return t},function(n){return n})}}(n)(t)(r)}}},F=function(n){return N("concatWith",n),function(t){return A({context:"concatWith",visitor:t}),function(r){return x(n,r),function(e){return x(n,e),function(n){return function(t){return function(r){return function(e){var u=n.specs["stags/bifunctor"],i=u.left,o=u.right;return g(r)==i?r:g(e)==i?e:n[o](t(r.value)(e.value))}}}}(n)(t)(r)(e)}}}},_=function(n){var t=n.left,r=n.right;return function(n){return n.specs["stags/bifunctor"]={left:t,right:r},n.left=function(r){return n[t](r)},n.right=function(t){return n[r](t)},n.bifold=M(n),n.bimap=D(n),n.getOr=k(n),n.getWith=function(n){return function(t,r){return M(n)(function(){return t},function(n){return r(n)})}}(n),n.tagBy=function(n){return I(n),function(t,r){return function(e){return A({context:"tagBy",visitor:r}),r(e)?n.right(e):n.left(t)}}}(n),n.encase=function(n){return function(t){return function(r){try{return n.right(t(r))}catch(t){return n.left(t)}}}}(n),n.toBoolean=function(n){return n.bifold(function(){return!1},function(){return!0})}(n),n.fromNullable=function(n){return function(t){return null==t?n.left(t):n.right(t)}}(n),n.all=function(n){return function(t){var r=t.filter(function(t){return!n.toBoolean(t)});return r.length>0?n.left(r.map(function(n){return n.value})):n.right(t.map(n.getOr(null)))}}(n),n.any=function(n){return function(t){return t.some(n.toBoolean)?n.right(t.filter(n.toBoolean).map(n.getOr(null))):t.find(function(t){return!n.toBoolean(t)})}}(n),n.concatWith=F(n),n}};function J(n){if(n.specs["stags/decorated"])return n;var t=c(b(n)),e=E(n),i=Y(n),o=I(n);return b(n).forEach(function(c){n["is"+c]=n["is"+c]||function(t){return x(n,t),g(t)===c},n["map"+c]=n["map"+c]||function(n){return e(u({},t(function(n){return n}),r({},c,n)))},n["get"+c+"Or"]=n["get"+c+"Or"]||function(n){return o(u({},t(function(){return n}),r({},c,function(n){return n})))},n["get"+c+"With"]=n["get"+c+"With"]||function(n,e){return o(u({},t(function(){return n}),r({},c,function(n){return e(n)})))},n["chain"+c]=n["chain"+c]||function(n){return function(e){return i(u({},t(function(){return e}),r({},c,n)))(e)}},n["assert"+c]=n["assert"+c]||o(u({},t(K.N),r({},c,K.Y))),n[c.toLowerCase()+"s"]=n[c+"s"]||function(t){return t.reduce(function(t,r){return t.concat(n["is"+c](r)?[r.value]:[])},[])}}),n.fold=n.fold||o,n.mapAll=n.mapAll||e,n.chainAll=n.chainAll||i,n.specs["stags/decorated"]=!0,n}var q=function(n){return o($(n),J,_({left:"N",right:"Y"}),(t="Y",function(n){return n.specs["stags/functor"]=t,n.of=n[t],n.map=function(e){return A({context:"map",visitor:e}),E(n)(u({},c(n.tags)(function(n){return n}),r({},t,e)))},n}),function(n){return function(t){t.specs["stags/monad"]=n,t.of=t[n];var e=Y(t);return t.chain=function(i){return A({context:"chain",visitor:i}),function(o){return e(u({},c(t.tags)(function(n){return t[g(o)](n)}),r({},n,function(n){return i(n)})))(o)}},t}}("Y"));var t},L=function(n,t){return J(W(n,t))},R=q("stags.Either"),C=R.Y,V=R.N,z=R.bifold,H=R.getOr,Q=R.getWith,Z=R.bimap,G=R.map,U=R.mapY,X=R.mapN,nn=R.assertY,tn=R.assertN,rn=R.chainN,en=R.chainY,un=R.tagBy,on=R.chain,cn=R.toBoolean,an=R.encase,fn=R.fromNullable,sn=R.all,ln=R.any,pn=R.isY,gn=R.isN,vn=R.ys,yn=R.ns,hn=R.concatWith;mn.SKIP={},mn.lift=function(){var n=arguments[0];return On(Array.prototype.slice.call(arguments,1)).map(function(t){return n.apply(void 0,t)})},mn.scan=function(n,t,r){var e=r.map(function(r){var e=n(t,r);return e!==mn.SKIP&&(t=e),e});return e(t),e},mn.merge=On,mn.combine=bn,mn.scanMerge=function(n,t){var r=n.map(function(n){return n[0]}),e=bn(function(){var e=arguments[arguments.length-1];return r.forEach(function(r,u){e.indexOf(r)>-1&&(t=n[u][1](t,r()))}),t},r);return e(t),e},mn["fantasy-land/of"]=mn;var dn=!1;function mn(n){var t,r=[],e=[];function u(t){return arguments.length&&t!==mn.SKIP&&(n=t,Sn(u)&&(u.changing(),u.state="active",r.forEach(function(t,r){t(e[r](n))}))),n}return u.constructor=mn,u.state=arguments.length&&n!==mn.SKIP?"active":"pending",u.parents=[],u.changing=function(){Sn(u)&&(u.state="changing"),r.forEach(function(n){n.changing()})},u.map=function(t,i){var o="active"===u.state&&i!==mn.SKIP?mn(t(n)):mn();return o.parents.push(u),r.push(o),e.push(t),o},u.toJSON=function(){return null!=n&&"function"==typeof n.toJSON?n.toJSON():n},u["fantasy-land/map"]=u.map,u["fantasy-land/ap"]=function(n){return bn(function(n,t){return n()(t())},[n,u])},u.unregisterChild=function(n){var t=r.indexOf(n);-1!==t&&(r.splice(t,1),e.splice(t,1))},Object.defineProperty(u,"end",{get:function(){return t||((t=mn()).map(function(n){return!0===n&&(u.parents.forEach(function(n){n.unregisterChild(u)}),u.state="ended",u.parents.length=r.length=e.length=0),n}),t)}}),u}function bn(n,t){var r=t.every(function(n){if(n.constructor!==mn)throw new Error("Ensure that each item passed to stream.combine/stream.merge/lift is a stream");return"active"===n.state}),e=r?mn(n.apply(null,t.concat([t]))):mn(),u=[],i=t.map(function(i){return i.map(function(o){return u.push(i),(r||t.every(function(n){return"pending"!==n.state}))&&(r=!0,e(n.apply(null,t.concat([u]))),u=[]),o},mn.SKIP)}),o=e.end.map(function(n){!0===n&&(i.forEach(function(n){n.end(!0)}),o.end(!0))});return e}function On(n){return bn(function(){return n.map(function(n){return n()})},n)}function Sn(n){return"pending"===n.state||"active"===n.state||"changing"===n.state}Object.defineProperty(mn,"HALT",{get:function(){return dn||console.log("HALT is deprecated and has been renamed to SKIP"),dn=!0,mn.SKIP}});var jn=function(n){return function(t){var r={},e=r,u=mn();return t.map(function(t){return e!==r&&n(t,e)||(e=t,u(t)),null}),u}},wn=function(n){return function(t){var r,e=mn();return t.map(function(t){return clearTimeout(r),r=setTimeout(function(){return e(t)},n),null}),e}},Tn=function(n){return jn(function(n,t){return n===t})(n)},Nn=function(n){return function(t){return Tn(t.map(n))}},An=mn,xn=Object.freeze({__proto__:null,dropRepeatsWith:jn,interval:function(n){var t=mn(),r=setInterval(function(){return t(Date.now())},n);return t.end.map(function(){return clearInterval(r)}),t(Date.now()),t},afterSilence:wn,dropRepeats:Tn,watch:Nn,filter:function(n){return function(t){var r=mn();return t.map(function(t){return n(t)?r(t):null}),r}},map:function(n){return function(t){return t.map(n)}},decide:function(n){return function(t){var r=mn();return t.map(n(r)),r}},async:function(n){return function(t){var r=mn();return t.map(function(t){return n(t).then(r)}),r}},decideLatest:function(n){return function(t){var r,e=mn();return t.map(function(t){var u=r={};return n(function(n){u==r&&e(n)})(t),null}),e}},funnel:function(n){var t=mn();return n.map(function(n){return n.map(function(n){return setTimeout(t,0,n)})}),t},sink:function(n){var t=mn();return t.map(n),t},source:function(n){var t=mn();return n.map(t),t},scan:function(n){return function(t){return function(r){return mn.scan(t,n,r)}}},of:An,merge:function(n){return mn.merge(n)},log:function(n){return Object.entries(n).forEach(function(n){var t=i(n,2),r=t[0];return t[1].map(function(n){return console.log(r,n)})})},session:function(){var n=[];return{of:function(){var t=mn.apply(void 0,arguments);return n.push(t),t},end:function(){n.map(function(n){return n.end(!0)})}}},default:mn}),Pn=void 0,In=function(n){return function(t){var r=[];return n(function(n){return r.push(n),n})(t),r}},En=function(n){return function(t){return function(r){return n(r)?t(r):r}}},Yn=function(n){return function(t){return function(r){return t(n(r))}}},Wn=function(n){return function(t){return function(r){return n(r)(t)(r)}}},$n=function(){for(var n=arguments.length,t=new Array(n),r=0;r<n;r++)t[r]=arguments[r];return function(n){return function(r){return t.reduce(function(t,r){return r(n)(t)},r)}}},Kn=function(n){return function(t){return n.reduceRight(function(n,t){return t(n)},t)}},Bn=function(){return function(n){return n}},Mn=function(n){return function(t){return Array.isArray(t)?t.flatMap(function(t){var r=n(t);return r===Pn?[]:[r]}):Object.keys(t).reduce(function(e,i){var o=n(t[i]);return o===Pn?e:u({},e,r({},i,o))},{})}},Dn=function(n){return function(t){return function(r){return function(e){var i=null==e?/^\d+$/.test(t)?[]:{}:Array.isArray(e)?e.slice():u({},e),o=null==i[t]?n:i[t],c=r(o);return c===Pn?(delete i[t],i):(i[t]=c,i)}}}}(void 0);var kn=function n(t){var r,e=t.path,u=void 0===e?[]:e;function i(){for(var n=arguments.length,t=new Array(n),e=0;e<n;e++)t[e]=arguments[e];r=r||Kn(u);var i=0==t.length,o=!i&&"function"==typeof t[0];return i?In(r):r(o?t[0]:function(){return t[0]})}function o(){return i.toString()}i.path=u,i.delete=Pn,i.drop=Pn,i.filter=function(t){return n({path:u.concat(En(t))})},Object.defineProperty(i,"values",{get:function(){return n({path:u.concat(Mn)})}}),Object.defineProperty(i,"zero",{get:function(){return n({path:u.concat(Bn)})}}),i.union=function(){return n({path:u.concat($n.apply(void 0,arguments))})},i.insertQuery=function(t){return n({path:u.concat(t)})},i.flatMap=function(t){return n({path:u.concat(Wn(t))})},i.map=function(t){return n({path:u.concat(Yn(t))})};var c=new Proxy(i,{get:function(n,t){var r="string"==typeof t&&/^\$\d+$/.test(t)?t.slice(1):t;return r==Symbol.toPrimitive?o:"string"==typeof r?"$"==r?i.insertQuery:r.startsWith("$")?i[r.slice(1)]:c.$(Dn(r)):i[r]}});return c.toString=Function.prototype.toString.bind(i),c}({path:[],select:In});n.$=kn,n.Either=R,n.N=V,n.StaticSumTypeError=m,n.Y=C,n.Z=function n(t){var r,e=t.stream,u=t.query,i=void 0===u?kn:u,o=t.read,c=void 0===o?function(){return e()}:o,a=t.write,f=void 0===a?function(n){return e(n(e()))}:a,s=t.notify,l=void 0===s?function(n){return Nn(i())(e).map(n)}:s,p=An(),g=An();p.deleted=g;var v=!1,y=function(n){return v=!0,f(i(n)),r=p(i()(c())[0])},h=function(){return[c()].map(i()).map(function(n){return n.length?r=n[0]:r}).shift()};l(function(){v||p(h()),v=!1});function d(t){var r=t(i);return n({stream:e,read:c,write:f,query:r})}var m={delete:function(){var n=h();f(i(i.$delete)),g(n)},deleted:g,stream:p,query:d,throttled:function(n){return wn(n)(Tn(p))},filter:function(n){return d(function(t){return t.$filter(n)})},flatMap:function(n){return d(function(t){return t.$flatMap(n)})},get values(){return d(function(n){return n.$values})}};return new Proxy(function(){for(var n=arguments.length,t=new Array(n),r=0;r<n;r++)t[r]=arguments[r];return t.length?"function"==typeof t[0]?y.apply(void 0,t):y(function(){return t[0]}):h()},{get:function(n,t){var r="string"==typeof t&&/^\$\d+$/.test(t)?t.slice(1):t;return r==Symbol.toPrimitive?toString:"string"==typeof r?"$"==r?d:r.startsWith("$")?m[r.slice(1)]:d(function(n){return n[r]}):m[r]}})},n.all=sn,n.any=ln,n.assertN=tn,n.assertY=nn,n.bifold=z,n.bimap=Z,n.boundToString=l,n.chain=on,n.chainAll=Y,n.chainN=rn,n.chainY=en,n.concatWith=hn,n.decorate=J,n.either=q,n.emptyInstance=h,n.encase=an,n.encaseNil=function(n){return function(){try{var t=n.apply(void 0,arguments);if(null==t)throw new TypeError("Nil Result in encased function:"+n.toString());return y("stags.Either","Y",t)}catch(t){return y("stags.Either","N",t)}}},n.errMessage=j,n.fold=I,n.fromNullable=fn,n.getOr=H,n.getTags=b,n.getWith=Q,n.isN=gn,n.isY=pn,n.map=G,n.mapAll=E,n.mapN=X,n.mapY=U,n.maybe=function(n){return o(n,q,function(n){var t=n.N;return n.N=function(){return t()},n.specs["stags/maybe"]=!0,n})},n.ns=yn,n.otherwise=c,n.pipe=function(){for(var n=arguments.length,t=new Array(n),r=0;r<n;r++)t[r]=arguments[r];if(0==t.length)throw new Error("You must provide a non-empty spread of functions.");return function(n){return o.apply(void 0,[n].concat(t))}},n.query=kn,n.run=o,n.stream=xn,n.tagBy=un,n.tagName=g,n.tags=L,n.toBoolean=cn,n.toJSON=function(n){return f(function n(t){var r=t.value,e=t.isPojo,u=t.isArray,i=t.valueStag,o=t.emptyStag;return i?f(n,r.value):o?null:e?d(Object.entries(r).map(function(t){return f(n,t)})):u?r.map(function(t){return f(n,t)}):r},n)},n.toString=s,n.type=L,n.typeName=p,n.valueInstance=y,n.ys=vn,Object.defineProperty(n,"__esModule",{value:!0})}); | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((n=n||self).attain={})}(this,function(n){"use strict";function t(n){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(n){return typeof n}:function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n})(n)}function r(n,t,r){return t in n?Object.defineProperty(n,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[t]=r,n}function e(n,t){var r=Object.keys(n);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(n);t&&(e=e.filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable})),r.push.apply(r,e)}return r}function u(n){for(var t=1;t<arguments.length;t++){var u=null!=arguments[t]?arguments[t]:{};t%2?e(Object(u),!0).forEach(function(t){r(n,t,u[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(u)):e(Object(u)).forEach(function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(u,t))})}return n}function i(n,t){return function(n){if(Array.isArray(n))return n}(n)||function(n,t){if(!(Symbol.iterator in Object(n)||"[object Arguments]"===Object.prototype.toString.call(n)))return;var r=[],e=!0,u=!1,i=void 0;try{for(var o,c=n[Symbol.iterator]();!(e=(o=c.next()).done)&&(r.push(o.value),!t||r.length!==t);e=!0);}catch(n){u=!0,i=n}finally{try{e||null==c.return||c.return()}finally{if(u)throw i}}return r}(n,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var o=function(n){for(var t=arguments.length,r=new Array(t>1?t-1:0),e=1;e<t;e++)r[e-1]=arguments[e];if(0==r.length)throw new Error("You must provide an initial value and a non-empty spread of functions.");return r.reduce(function(n,t){return t(n)},n)},c=function(n){return function(t){return n.reduce(function(n,e){return Object.assign(n,r({},e,t))},{})}},a=function(n,t){return n>0?function(n,t){return Array(n).fill(t)}(n,t).join(""):""};function f(n,t){var r=Object(t)===t,e=null==t,u=r&&Array.isArray(t),i=r&&!u,o=r&&"function"==typeof t,c=!r,a=i&&t.type&&t.tag,f=a&&"value"in t,s=a&&!f;return n({notPrimative:r,isPrimative:c,isString:"string"==typeof t,isNil:e,isArray:u,isObject:i,isPojo:i&&"Object"==t.constructor.name,isDate:i&&t instanceof Date,isError:i&&t instanceof Error,value:t,isFunction:o,isStag:a,valueStag:f,emptyStag:s})}var s=function(n){return f(function n(t){return function(r){var e=r.value,u=r.isPojo,c=r.isObject,s=r.isArray,l=r.isDate,p=r.isError,g=r.valueStag,v=r.emptyStag,y=r.isString,h=r.isFunction,d=a(t,""),m=a(t-1,""),b=a(t+1,"");return g?e.type+"."+e.tag+"("+(void 0===e.value?"":f(n(t+1),e.value))+(t>0?""+m:"")+d+")":v?e.type+"."+e.tag+"()":u?0==Object.keys(e).length?"{}":o(e,Object.entries,function(r){return r.map(function(r){var e=i(r,2),u=e[0],o=e[1];return b+'"'+u+'":'+f(n(t+1),o).replace(""+b,"")})},function(n){return d+"{"+n+d+"}"}):s?"0"==e.length?"[]":d+"["+d+d+e.map(function(r){return f(n(t+1),r)}).join(", ")+d+"]":l?"new "+e.constructor.name+'("'+e.toISOString()+'")':p?"new "+e.constructor.name+'("'+e.message+'")':h?e+"":c?"new "+e.constructor.name+"()":y?JSON.stringify(e):""+e}}(0),n)};function l(){return s(this)}function p(n){return n.type}function g(n){return n.tag}var v=r({toString:l,inspect:l},Symbol.for("nodejs.util.inspect.custom"),l);function y(n,t,r){return Object.assign(Object.create(v),{type:n,tag:t,value:r})}function h(n,t){return Object.assign(Object.create(v),{type:n,tag:t})}var d=function(n){return n.reduce(function(n,t){var e=i(t,2);return u({},n,r({},e[0],e[1]))},{})},m=["ExtraTags","MissingTags","InstanceNull","InstanceWrongType","InstanceShapeInvalid","VisitorNotAFunction","NotAType","TagsShapeInvalid"].reduce(function(n,t){return n[t]=function(r){return y(n.type,t,r)},n.tags.push(t),n},{type:"StaticSumTypeError",tags:[],specs:{}});function b(n){return n.tags}var O={ExtraTags:function(n){return["Your tag function must have exactly the same"," keys as the type: "+n.T.type+". ","The following tags should not have been present:",n.extraKeys.join(", ")].join(" ")},MissingTags:function(n){return["Your tag function must have exactly the same","keys as the type: "+n.T.type+". The following keys were","missing:",n.missingKeys.join(", ")].join(" ")},InstanceNull:function(n){return"Null is not a valid member of the type "+n.T.type},InstanceWrongType:function(n){return[s(n.x)+" is not a valid member of the type",n.T.type,"which expects the following tags",b(n.T).join(" | ")].join(" ")},InstanceShapeInvalid:function(n){return[s(n.x),"is not a valid Member of the type:",n.T.type+". ","Please review the definition of "+n.T.type].join(" ")},VisitorNotAFunction:function(n){return n.context+" expected a visitor function but instead received "+s(n.visitor)},NotAType:function(n){return n.context+" expected a Type ({ type: string, tags: string[] }) but received "+s(n.T)},TagsShapeInvalid:function(n,t){return"fold("+p(n)+") tags provided were not the right shape. Expected { [tag]: f } but received "+s(t)}};function S(n){var r=n();return N("fold",r),function(n){!function(n,r){if(null==r||Array.isArray(r)||"object"!==t(r)){var e=T.TagsShapeInvalid(n,r);return w(e)}}(r,n);var e=Object.keys(n),u=b(r),i=[[e,r],[u,n]].map(function(n){var t=n[0],r=n[1];return t.filter(function(n){return!(n in r)})}),o=i[0],c=i[1];return c.length>0?w(T.MissingTags({T:r,tags:n,missingKeys:c})):o.length>0?w(T.ExtraTags({T:r,tags:n,extraKeys:o})):function(t){return P(r,n,t)&&n[g(t)](t.value)}}}var j=function(n){return(t=O,function(n){return t[n.tag](n.value)})(n);var t};function w(n){throw new Error(g(n)+": "+j(n))}var T=m;function N(n,t){if(null==t||!(null!=t&&"string"==typeof t.type&&Array.isArray(t.tags)&&"specs"in t))return w(T.NotAType({context:n,T:t}))}function A(n){if("function"!=typeof n.visitor)return w(T.VisitorNotAFunction({context:n.context,visitor:n.visitor}))}function x(n,t){if(null==t||p(t)!=n.type||!b(n).includes(g(t)))return w(T.InstanceShapeInvalid({x:t,T:n}))}function P(n,t,r){return null==r?w(T.InstanceNull({T:n,tags:t,x:r})):p(r)!==n.type?w(T.InstanceWrongType({T:n,tags:t,x:r})):!!b(n).includes(g(r))||w(T.InstanceShapeInvalid({T:n,tags:t,x:r}))}function I(n){return S(function(){return n})}var E=function(n){var t=I(n);return function(r){var e=t(r);return function(t){x(n,t);var r=e(t);return n[g(t)](r)}}},Y=function(n){var t=I(n);return function(r){var e=t(r);return function(t){if(P(n,r,t),"value"in t){var u=e(t);return P(n,r,u)&&u}return t}}},W=function(n,t){return u({type:n,specs:{},tags:t},d(t.map(function(t){return[t,function(){return arguments.length?y(n,t,arguments.length<=0?void 0:arguments[0]):h(n,t)}]})))};function $(n){return W(n,["Y","N"])}var K=$("stags.Either"),B=function(n){var t=I(n),e=n.specs["stags/bifunctor"],u=e.left,i=e.right;return function(n,e){var o;return t((r(o={},u,n),r(o,i,e),o))}},M=function(n){return N("bifold",n),B(n)},D=function(n){return N("bimap",n),function(n){var t=E(n),e=n.specs["stags/bifunctor"],u=e.left,i=e.right;return function(n,e){var o;return t((r(o={},u,n),r(o,i,e),o))}}(n)},k=function(n){return N("getOr",n),function(t){return function(r){return x(n,r),function(n){return function(t){return B(n)(function(){return t},function(n){return n})}}(n)(t)(r)}}},F=function(n){return N("concatWith",n),function(t){return A({context:"concatWith",visitor:t}),function(r){return x(n,r),function(e){return x(n,e),function(n){return function(t){return function(r){return function(e){var u=n.specs["stags/bifunctor"],i=u.left,o=u.right;return g(r)==i?r:g(e)==i?e:n[o](t(r.value)(e.value))}}}}(n)(t)(r)(e)}}}},_=function(n){var t=n.left,r=n.right;return function(n){return n.specs["stags/bifunctor"]={left:t,right:r},n.left=function(r){return n[t](r)},n.right=function(t){return n[r](t)},n.bifold=M(n),n.bimap=D(n),n.getOr=k(n),n.getWith=function(n){return function(t,r){return M(n)(function(){return t},function(n){return r(n)})}}(n),n.tagBy=function(n){return I(n),function(t,r){return function(e){return A({context:"tagBy",visitor:r}),r(e)?n.right(e):n.left(t)}}}(n),n.encase=function(n){return function(t){return function(r){try{return n.right(t(r))}catch(t){return n.left(t)}}}}(n),n.toBoolean=function(n){return n.bifold(function(){return!1},function(){return!0})}(n),n.fromNullable=function(n){return function(t){return null==t?n.left(t):n.right(t)}}(n),n.all=function(n){return function(t){var r=t.filter(function(t){return!n.toBoolean(t)});return r.length>0?n.left(r.map(function(n){return n.value})):n.right(t.map(n.getOr(null)))}}(n),n.any=function(n){return function(t){return t.some(n.toBoolean)?n.right(t.filter(n.toBoolean).map(n.getOr(null))):t.find(function(t){return!n.toBoolean(t)})}}(n),n.concatWith=F(n),n}};function J(n){if(n.specs["stags/decorated"])return n;var t=c(b(n)),e=E(n),i=Y(n),o=I(n);return b(n).forEach(function(c){n["is"+c]=n["is"+c]||function(t){return x(n,t),g(t)===c},n["map"+c]=n["map"+c]||function(n){return e(u({},t(function(n){return n}),r({},c,n)))},n["get"+c+"Or"]=n["get"+c+"Or"]||function(n){return o(u({},t(function(){return n}),r({},c,function(n){return n})))},n["get"+c+"With"]=n["get"+c+"With"]||function(n,e){return o(u({},t(function(){return n}),r({},c,function(n){return e(n)})))},n["chain"+c]=n["chain"+c]||function(n){return function(e){return i(u({},t(function(){return e}),r({},c,n)))(e)}},n["assert"+c]=n["assert"+c]||o(u({},t(K.N),r({},c,K.Y))),n[c.toLowerCase()+"s"]=n[c+"s"]||function(t){return t.reduce(function(t,r){return t.concat(n["is"+c](r)?[r.value]:[])},[])}}),n.fold=n.fold||o,n.mapAll=n.mapAll||e,n.chainAll=n.chainAll||i,n.specs["stags/decorated"]=!0,n}var q=function(n){return o($(n),J,_({left:"N",right:"Y"}),(t="Y",function(n){return n.specs["stags/functor"]=t,n.of=n[t],n.map=function(e){return A({context:"map",visitor:e}),E(n)(u({},c(n.tags)(function(n){return n}),r({},t,e)))},n}),function(n){return function(t){t.specs["stags/monad"]=n,t.of=t[n];var e=Y(t);return t.chain=function(i){return A({context:"chain",visitor:i}),function(o){return e(u({},c(t.tags)(function(n){return t[g(o)](n)}),r({},n,function(n){return i(n)})))(o)}},t}}("Y"));var t},L=function(n,t){return J(W(n,t))},R=q("stags.Either"),C=R.Y,V=R.N,z=R.bifold,H=R.getOr,Q=R.getWith,Z=R.bimap,G=R.map,U=R.mapY,X=R.mapN,nn=R.assertY,tn=R.assertN,rn=R.chainN,en=R.chainY,un=R.tagBy,on=R.chain,cn=R.toBoolean,an=R.encase,fn=R.fromNullable,sn=R.all,ln=R.any,pn=R.isY,gn=R.isN,vn=R.ys,yn=R.ns,hn=R.concatWith;mn.SKIP={},mn.lift=function(){var n=arguments[0];return On(Array.prototype.slice.call(arguments,1)).map(function(t){return n.apply(void 0,t)})},mn.scan=function(n,t,r){var e=r.map(function(r){var e=n(t,r);return e!==mn.SKIP&&(t=e),e});return e(t),e},mn.merge=On,mn.combine=bn,mn.scanMerge=function(n,t){var r=n.map(function(n){return n[0]}),e=bn(function(){var e=arguments[arguments.length-1];return r.forEach(function(r,u){e.indexOf(r)>-1&&(t=n[u][1](t,r()))}),t},r);return e(t),e},mn["fantasy-land/of"]=mn;var dn=!1;function mn(n){var t,r=[],e=[];function u(t){return arguments.length&&t!==mn.SKIP&&(n=t,Sn(u)&&(u.changing(),u.state="active",r.forEach(function(t,r){t(e[r](n))}))),n}return u.constructor=mn,u.state=arguments.length&&n!==mn.SKIP?"active":"pending",u.parents=[],u.changing=function(){Sn(u)&&(u.state="changing"),r.forEach(function(n){n.changing()})},u.map=function(t,i){var o="active"===u.state&&i!==mn.SKIP?mn(t(n)):mn();return o.parents.push(u),r.push(o),e.push(t),o},u.toJSON=function(){return null!=n&&"function"==typeof n.toJSON?n.toJSON():n},u["fantasy-land/map"]=u.map,u["fantasy-land/ap"]=function(n){return bn(function(n,t){return n()(t())},[n,u])},u.unregisterChild=function(n){var t=r.indexOf(n);-1!==t&&(r.splice(t,1),e.splice(t,1))},Object.defineProperty(u,"end",{get:function(){return t||((t=mn()).map(function(n){return!0===n&&(u.parents.forEach(function(n){n.unregisterChild(u)}),u.state="ended",u.parents.length=r.length=e.length=0),n}),t)}}),u}function bn(n,t){var r=t.every(function(n){if(n.constructor!==mn)throw new Error("Ensure that each item passed to stream.combine/stream.merge/lift is a stream");return"active"===n.state}),e=r?mn(n.apply(null,t.concat([t]))):mn(),u=[],i=t.map(function(i){return i.map(function(o){return u.push(i),(r||t.every(function(n){return"pending"!==n.state}))&&(r=!0,e(n.apply(null,t.concat([u]))),u=[]),o},mn.SKIP)}),o=e.end.map(function(n){!0===n&&(i.forEach(function(n){n.end(!0)}),o.end(!0))});return e}function On(n){return bn(function(){return n.map(function(n){return n()})},n)}function Sn(n){return"pending"===n.state||"active"===n.state||"changing"===n.state}Object.defineProperty(mn,"HALT",{get:function(){return dn||console.log("HALT is deprecated and has been renamed to SKIP"),dn=!0,mn.SKIP}});var jn=function(n){return function(t){var r={},e=r,u=mn();return t.map(function(t){return e!==r&&n(t,e)||(e=t,u(t)),null}),u}},wn=function(n){return function(t){var r,e=mn();return t.map(function(t){return clearTimeout(r),r=setTimeout(function(){return e(t)},n),null}),e}},Tn=function(n){return jn(function(n,t){return n===t})(n)},Nn=function(n){return function(t){return Tn(t.map(n))}},An=mn,xn=Object.freeze({__proto__:null,dropRepeatsWith:jn,interval:function(n){var t=mn(),r=setInterval(function(){return t(Date.now())},n);return t.end.map(function(){return clearInterval(r)}),t(Date.now()),t},afterSilence:wn,dropRepeats:Tn,watch:Nn,filter:function(n){return function(t){var r=mn();return t.map(function(t){return n(t)?r(t):null}),r}},map:function(n){return function(t){return t.map(n)}},decide:function(n){return function(t){var r=mn();return t.map(n(r)),r}},async:function(n){return function(t){var r=mn();return t.map(function(t){return n(t).then(r)}),r}},decideLatest:function(n){return function(t){var r,e=mn();return t.map(function(t){var u=r={};return n(function(n){u==r&&e(n)})(t),null}),e}},funnel:function(n){var t=mn();return n.map(function(n){return n.map(function(n){return setTimeout(t,0,n)})}),t},sink:function(n){var t=mn();return t.map(n),t},source:function(n){var t=mn();return n.map(t),t},scan:function(n){return function(t){return function(r){return mn.scan(t,n,r)}}},of:An,merge:function(n){return mn.merge(n)},log:function(n){return Object.entries(n).forEach(function(n){var t=i(n,2),r=t[0];return t[1].map(function(n){return console.log(r,n)})})},session:function(){var n=[];return{of:function(){var t=mn.apply(void 0,arguments);return n.push(t),t},end:function(){n.map(function(n){return n.end(!0)})}}},default:mn}),Pn=void 0,In=function(n){return function(t){var r=[];return n(function(n){return r.push(n),n})(t),r}},En=function(n){return function(t){return function(r){return n(r)?t(r):r}}},Yn=function(n){return function(t){return function(r){return t(n(r))}}},Wn=function(n){return function(t){return function(r){return n(r)(t)(r)}}},$n=function(){for(var n=arguments.length,t=new Array(n),r=0;r<n;r++)t[r]=arguments[r];return function(n){return function(r){return t.reduce(function(t,r){return r(n)(t)},r)}}},Kn=function(n){return function(t){return n.reduceRight(function(n,t){return t(n)},t)}},Bn=function(){return function(n){return n}},Mn=function(n){return function(t){return Array.isArray(t)?t.flatMap(function(t){var r=n(t);return r===Pn?[]:[r]}):Object.keys(t).reduce(function(e,i){var o=n(t[i]);return o===Pn?e:u({},e,r({},i,o))},{})}},Dn=function(n){return function(t){return function(r){return function(e){var i=null==e?/^\d+$/.test(t)?[]:{}:Array.isArray(e)?e.slice():u({},e),o=null==i[t]?n:i[t],c=r(o);return c===Pn?(delete i[t],i):(i[t]=c,i)}}}}(void 0);var kn=function n(t){var r,e=t.path,u=void 0===e?[]:e;function i(){for(var n=arguments.length,t=new Array(n),e=0;e<n;e++)t[e]=arguments[e];r=r||Kn(u);var i=0==t.length,o=!i&&"function"==typeof t[0];return i?In(r):r(o?t[0]:function(){return t[0]})}function o(){return i.toString()}i.path=u,i.delete=Pn,i.drop=Pn,i.filter=function(t){return n({path:u.concat(En(t))})},Object.defineProperty(i,"values",{get:function(){return n({path:u.concat(Mn)})}}),Object.defineProperty(i,"zero",{get:function(){return n({path:u.concat(Bn)})}}),i.union=function(){return n({path:u.concat($n.apply(void 0,arguments))})},i.insertQuery=function(t){return n({path:u.concat(t)})},i.flatMap=function(t){return n({path:u.concat(Wn(t))})},i.map=function(t){return n({path:u.concat(Yn(t))})};var c=new Proxy(i,{get:function(n,t){var r="string"==typeof t&&/^\$\d+$/.test(t)?t.slice(1):t;return r==Symbol.toPrimitive?o:"string"==typeof r?"$"==r?i.insertQuery:r.startsWith("$")?i[r.slice(1)]:c.$(Dn(r)):i[r]}});return c.toString=Function.prototype.toString.bind(i),c}({path:[],select:In});n.$=kn,n.Either=R,n.N=V,n.StaticSumTypeError=m,n.Y=C,n.Z=function n(t){var r,e=t.stream,u=t.query,i=void 0===u?kn:u,o=t.read,c=void 0===o?function(){return e()}:o,a=t.write,f=void 0===a?function(n){return e(n(e()))}:a,s=t.notify,l=void 0===s?function(n){return Nn(i())(e).map(n)}:s,p=An(),g=An();p.deleted=g;var v=!1,y=function(n){return v=!0,f(i(n)),r=p(i()(c())[0])},h=function(){return[c()].map(i()).map(function(n){return n.length?r=n[0]:r}).shift()};l(function(){v||p(h()),v=!1});function d(t){var r=t(i);return n({stream:e,read:c,write:f,query:r})}var m={delete:function(){var n=h();f(i(i.$delete)),g(n)},deleted:g,stream:p,query:d,throttled:function(n){return wn(n)(Tn(p))},filter:function(n){return d(function(t){return t.$filter(n)})},flatMap:function(n){return d(function(t){return t.$flatMap(n)})},get values(){return d(function(n){return n.$values})}};return new Proxy(function(){for(var n=arguments.length,t=new Array(n),r=0;r<n;r++)t[r]=arguments[r];return t.length?"function"==typeof t[0]?y.apply(void 0,t):y(function(){return t[0]}):h()},{get:function(n,t){var r="string"==typeof t&&/^\$\d+$/.test(t)?t.slice(1):t;return r==Symbol.toPrimitive?toString:"string"==typeof r?"$"==r?d:r.startsWith("$")?m[r.slice(1)]:d(function(n){return n[r]}):m[r]}})},n.all=sn,n.any=ln,n.assertN=tn,n.assertY=nn,n.bifold=z,n.bimap=Z,n.boundToString=l,n.chain=on,n.chainAll=Y,n.chainN=rn,n.chainY=en,n.concatWith=hn,n.decorate=J,n.either=q,n.emptyInstance=h,n.encase=an,n.encaseNil=function(n){return function(){try{var t=n.apply(void 0,arguments);if(null==t)throw new TypeError("Nil Result in encased function:"+n.toString());return y("stags.Either","Y",t)}catch(t){return y("stags.Either","N",t)}}},n.errMessage=j,n.fold=I,n.fromNullable=fn,n.getOr=H,n.getTags=b,n.getWith=Q,n.isN=gn,n.isY=pn,n.map=G,n.mapAll=E,n.mapN=X,n.mapY=U,n.maybe=function(n){return o(n,q,function(n){var t=n.N;return n.N=function(){return t()},n.specs["stags/maybe"]=!0,n})},n.ns=yn,n.otherwise=c,n.pipe=function(){for(var n=arguments.length,t=new Array(n),r=0;r<n;r++)t[r]=arguments[r];if(0==t.length)throw new Error("You must provide a non-empty spread of functions.");return function(n){return o.apply(void 0,[n].concat(t))}},n.query=kn,n.run=o,n.stream=xn,n.tagBy=un,n.tagName=g,n.tags=L,n.toBoolean=cn,n.toJSON=function(n){return f(function n(t){var r=t.value,e=t.isPojo,u=t.isArray,i=t.valueStag,o=t.emptyStag;return i?f(n,r.value):o?null:e?d(Object.entries(r).map(function(t){return f(n,t)})):u?r.map(function(t){return f(n,t)}):r},n)},n.toString=s,n.type=L,n.typeName=p,n.valueInstance=y,n.ys=vn,Object.defineProperty(n,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=attain.min.js.map |
@@ -55,5 +55,5 @@ import { css } from './lib/view.js' | ||
links: [{ | ||
name: 'attain-view', | ||
type: 'module', | ||
url: window.location.origin+'/lib/view.js' | ||
name: 'attain', | ||
type: 'script', | ||
url: 'https://unpkg.com/attain' | ||
}], | ||
@@ -60,0 +60,0 @@ theme: 'material' |
{ | ||
"name": "attain", | ||
"version": "0.0.37", | ||
"version": "0.0.38", | ||
"description": "A library for modelling and accessing data.", | ||
@@ -5,0 +5,0 @@ "main": "dist/attain.min.js", |
@@ -5,3 +5,4 @@ import config from './rollup.template.js' | ||
input: './lib/index.js', | ||
file: './dist/attain.min.js' | ||
file: './dist/attain.min.js', | ||
name: 'attain' | ||
}) |
@@ -5,3 +5,3 @@ import babel from 'rollup-plugin-babel' | ||
export default ({ input, file }) => ({ | ||
export default ({ input, name, file }) => ({ | ||
input, | ||
@@ -16,5 +16,5 @@ plugins: [ | ||
format: 'umd', | ||
name: 'data', | ||
name, | ||
sourcemap: 'external' | ||
}, | ||
}) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1129557