fpes
Version:
Functional Programming for EcmaScript(Javascript)
1 lines • 3.26 kB
JavaScript
var maybe;maybe=function(){var n={575:function(n){n.exports=function(n,t){if(!(n instanceof t))throw new TypeError("Cannot call a class as a function")}},913:function(n){function t(n,t){for(var e=0;e<t.length;e++){var r=t[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}n.exports=function(n,e,r){return e&&t(n.prototype,e),r&&t(n,r),n}},318:function(n){n.exports=function(n){return n&&n.__esModule?n:{default:n}}},646:function(n,t,e){"use strict";var r=e(318),u=r(e(575)),a=r(e(913));function o(n){return n instanceof f}function i(n){return n===c}var f=function(){function n(t){(0,u.default)(this,n),this.ref=t}return(0,a.default)(n,[{key:"of",value:function(t){return function(n){return null==n}(t)||i(t)?c:new n(t)}},{key:"fromFalsy",value:function(n){return n?this.of(n):c}},{key:"fromPredicate",value:function(n,t){var e=this;return arguments.length>1?n(t)?this.of(t):c:function(t){return e.fromPredicate(n,t)}}},{key:"isNull",value:function(){return!1}},{key:"isPresent",value:function(){return!0}},{key:"unwrap",value:function(){return this.ref}},{key:"toString",value:function(){return"Some(".concat(JSON.stringify(this.ref),")")}},{key:"toList",value:function(){return[this.ref]}},{key:"empty",value:function(){return c}},{key:"zero",value:function(){return c}},{key:"or",value:function(n){return this}},{key:"orDo",value:function(n){return this}},{key:"letDo",value:function(n){return this.then(n)}},{key:"then",value:function(n){return this.of(this.flatMap(n))}},{key:"flatMap",value:function(n){return n(this.ref)}},{key:"join",value:function(){var n=this.ref;return o(n)?n.join():this}},{key:"reduce",value:function(n,t){return n(t,this.ref)}},{key:"filter",value:function(n){return n(this.ref)?this.of(this.ref):c}},{key:"ap",value:function(n){var t=this;return n.chain((function(n){return t.map(n)}))}},{key:"chainRec",value:function(n,t){var e,r=t;do{r=(e=n((function(n){return{value:n,done:!1}}),(function(n){return{value:n,done:!0}}),r).unwrap()).value}while(!e.done);return this.of(e.value)}},{key:"equals",value:function(n){return o(n)&&n.unwrap()===this.ref}}]),n}(),c=Object.assign(new f,{isNull:function(){return!0},isPresent:function(){return!1},unwrap:function(){return null},toString:function(){return"None"},toList:function(){return[]},or:function(n){return this.of(n)},orDo:function(n){return this.of(n())},letDo:function(n){return this},join:function(){return c},reduce:function(n,t){return t},filter:function(){return c},ap:function(n){return c},equals:function(n){return i(n)}}),l={just:"of",chain:"flatMap",bind:"then",map:"then",alt:"or",extend:"letDo",extract:"unwrap","fantasy-land/of":"of","fantasy-land/empty":"empty","fantasy-land/zero":"zero","fantasy-land/extract":"extract","fantasy-land/equals":"equals","fantasy-land/map":"map","fantasy-land/ap":"ap","fantasy-land/alt":"alt","fantasy-land/chain":"chain","fantasy-land/join":"join","fantasy-land/extend":"extend","fantasy-land/reduce":"reduce","fantasy-land/filter":"filter"};Object.keys(l).forEach((function(n){f.prototype[n]=f.prototype[l[n]]}));var s=new f({});n.exports=s}},t={};return function e(r){if(t[r])return t[r].exports;var u=t[r]={exports:{}};return n[r](u,u.exports,e),u.exports}(646)}();