rubico
Version:
[a]synchronous functional programming
9 lines (7 loc) • 1.53 kB
JavaScript
/**
* rubico v2.6.2
* https://github.com/a-synchronous/rubico
* (c) 2019-2024 Richard Tong
* rubico may be freely distributed under the MIT license.
*/
!function(n,t){"object"==typeof module?module.exports=t:"function"==typeof define?define((()=>t)):n.maxBy=t}("object"==typeof globalThis?globalThis:this,function(){"use strict";const n=Symbol.for("placeholder"),t=function(t,e,o,r){return e==n?((n,t,e)=>function(o){return n(o,t,e)})(t,o,r):o==n?((n,t,e)=>function(o){return n(t,o,e)})(t,e,r):((n,t,e)=>function(o){return n(t,e,o)})(t,e,o)},e=Array.isArray,o=/[.|[|\]]+/,r=function(n,t){const e=new Map,o=function(o){if(e.has(o))return e.get(o);const r=n(o);return e.set(o,r),e.size>t&&e.clear(),r};return o.cache=e,o}((function(n){const t=n.length-1,e="["==n[0],r="]"==n[t];return e&&r?n.slice(1,t).split(o):e?n.slice(1).split(o):r?n.slice(0,t).split(o):n.split(o)}),500),u=function(n,t){const o=(n=>e(n)?n:"string"==typeof n?r(n):[n])(t),u=o.length;let i=-1,c=n;for(;++i<u;)if(c=c[o[i]],null==c)return;return c},i=function(n,t,e){const o=null==n?void 0:u(n,t);return void 0===o?"function"==typeof e?e(n):e:o},c=function(o,r){const u=o.length,c="string"==typeof(f=r)||"number"==typeof f||e(f)?t(i,n,f,l):null!=(p=f)&&"function"==typeof p.then?f.then(t(i,n,l,s)):i(f,l,s);var f,l,s,p;let a=0,h=o[a];for(;++a<u;){const n=o[a];c(n)>c(h)&&(h=n)}return h};return function(...t){return t.length>1?c(...t):(e=c,o=n,r=t[0],o==n?((n,t)=>function(e){return n(e,t)})(e,r):((n,t)=>function(e){return n(t,e)})(e,o));var e,o,r}}());