@vanillaes/absurdum 2.0.6 → 2.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/README.md +3 -3
  2. package/index.d.ts +3 -3
  3. package/index.js +2 -0
  4. package/index.min.js +3 -3
  5. package/package.json +16 -17
  6. package/src/arrays/chunk.d.ts +5 -6
  7. package/src/arrays/chunk.js +6 -6
  8. package/src/arrays/compact.d.ts +4 -5
  9. package/src/arrays/compact.js +5 -6
  10. package/src/arrays/difference.d.ts +5 -6
  11. package/src/arrays/difference.js +6 -7
  12. package/src/arrays/drop.d.ts +5 -6
  13. package/src/arrays/drop.js +5 -6
  14. package/src/arrays/dropRight.d.ts +5 -6
  15. package/src/arrays/dropRight.js +5 -6
  16. package/src/arrays/fill.d.ts +6 -7
  17. package/src/arrays/fill.js +5 -6
  18. package/src/arrays/filter.d.ts +4 -5
  19. package/src/arrays/filter.js +5 -6
  20. package/src/arrays/find.d.ts +3 -4
  21. package/src/arrays/find.js +7 -6
  22. package/src/arrays/findIndex.d.ts +3 -4
  23. package/src/arrays/findIndex.js +3 -4
  24. package/src/arrays/findLastIndex.d.ts +3 -4
  25. package/src/arrays/findLastIndex.js +4 -5
  26. package/src/arrays/flat.d.ts +5 -6
  27. package/src/arrays/flat.js +5 -6
  28. package/src/arrays/frequency.d.ts +6 -5
  29. package/src/arrays/frequency.js +8 -7
  30. package/src/arrays/intersection.d.ts +5 -6
  31. package/src/arrays/intersection.js +7 -6
  32. package/src/arrays/map.d.ts +4 -5
  33. package/src/arrays/map.js +5 -6
  34. package/src/arrays/pull.d.ts +4 -5
  35. package/src/arrays/pull.js +5 -6
  36. package/src/arrays/take.d.ts +5 -6
  37. package/src/arrays/take.js +5 -6
  38. package/src/arrays/takeRight.d.ts +5 -6
  39. package/src/arrays/takeRight.js +5 -6
  40. package/src/arrays/union.d.ts +4 -5
  41. package/src/arrays/union.js +4 -5
  42. package/src/arrays/unique.d.ts +4 -5
  43. package/src/arrays/unique.js +4 -5
  44. package/src/arrays/unzip.d.ts +4 -5
  45. package/src/arrays/unzip.js +6 -5
  46. package/src/arrays/without.d.ts +4 -4
  47. package/src/arrays/without.js +5 -6
  48. package/src/arrays/xor.d.ts +4 -5
  49. package/src/arrays/xor.js +5 -6
  50. package/src/arrays/zip.d.ts +6 -7
  51. package/src/arrays/zip.js +7 -8
  52. package/src/objects/assign.d.ts +1 -3
  53. package/src/objects/assign.js +3 -3
  54. package/src/objects/at.d.ts +2 -4
  55. package/src/objects/at.js +3 -3
  56. package/src/objects/defaults.d.ts +1 -3
  57. package/src/objects/defaults.js +3 -3
  58. package/src/objects/defaultsDeep.d.ts +1 -3
  59. package/src/objects/defaultsDeep.js +3 -3
  60. package/src/objects/entries.d.ts +1 -3
  61. package/src/objects/entries.js +3 -3
  62. package/src/objects/filter.d.ts +3 -5
  63. package/src/objects/filter.js +2 -3
  64. package/src/objects/findKey.d.ts +2 -4
  65. package/src/objects/findKey.js +2 -3
  66. package/src/objects/findLastKey.d.ts +2 -4
  67. package/src/objects/findLastKey.js +2 -3
  68. package/src/objects/forIn.d.ts +3 -5
  69. package/src/objects/forIn.js +3 -4
  70. package/src/objects/fromEntries.d.ts +1 -3
  71. package/src/objects/fromEntries.js +3 -3
  72. package/src/objects/get.d.ts +1 -4
  73. package/src/objects/get.js +2 -3
  74. package/src/objects/has.d.ts +1 -4
  75. package/src/objects/has.js +3 -3
  76. package/src/objects/invert.d.ts +1 -3
  77. package/src/objects/invert.js +3 -3
  78. package/src/objects/mapKeys.d.ts +3 -5
  79. package/src/objects/mapKeys.js +2 -3
  80. package/src/objects/mapValues.d.ts +3 -5
  81. package/src/objects/mapValues.js +2 -3
  82. package/src/objects/merge.d.ts +1 -3
  83. package/src/objects/merge.js +3 -3
  84. package/src/objects/pick.d.ts +1 -3
  85. package/src/objects/pick.js +3 -3
  86. package/src/objects/result.d.ts +1 -4
  87. package/src/objects/result.js +2 -3
  88. package/src/objects/transform.d.ts +3 -5
  89. package/src/objects/transform.js +2 -3
  90. package/src/objects/values.d.ts +2 -4
  91. package/src/objects/values.js +3 -3
  92. package/src/strings/camelCase.d.ts +2 -4
  93. package/src/strings/camelCase.js +2 -4
  94. package/src/strings/chomp.d.ts +1 -4
  95. package/src/strings/chomp.js +1 -3
  96. package/src/strings/deburr.d.ts +2 -4
  97. package/src/strings/deburr.js +3 -4
  98. package/src/strings/endsWith.d.ts +1 -4
  99. package/src/strings/endsWith.js +3 -3
  100. package/src/strings/includes.d.ts +1 -3
  101. package/src/strings/includes.js +1 -3
  102. package/src/strings/kebabCase.d.ts +2 -4
  103. package/src/strings/kebabCase.js +2 -4
  104. package/src/strings/pad.d.ts +2 -6
  105. package/src/strings/pad.js +1 -3
  106. package/src/strings/padEnd.d.ts +2 -6
  107. package/src/strings/padEnd.js +2 -4
  108. package/src/strings/padStart.d.ts +2 -6
  109. package/src/strings/padStart.js +2 -4
  110. package/src/strings/pascalCase.d.ts +2 -4
  111. package/src/strings/pascalCase.js +2 -4
  112. package/src/strings/repeat.d.ts +1 -3
  113. package/src/strings/repeat.js +1 -3
  114. package/src/strings/reverse.d.ts +0 -2
  115. package/src/strings/reverse.js +1 -3
  116. package/src/strings/snakeCase.d.ts +2 -4
  117. package/src/strings/snakeCase.js +2 -4
  118. package/src/strings/startsWith.d.ts +0 -3
  119. package/src/strings/startsWith.js +3 -3
  120. package/src/strings/trimEnd.d.ts +3 -5
  121. package/src/strings/trimEnd.js +2 -4
  122. package/src/strings/trimStart.d.ts +3 -5
  123. package/src/strings/trimStart.js +2 -4
  124. package/src/strings/truncate.d.ts +9 -11
  125. package/src/strings/truncate.js +3 -5
  126. package/src/strings/words.d.ts +3 -7
  127. package/src/strings/words.js +3 -5
package/README.md CHANGED
@@ -9,9 +9,9 @@ functions and clear/readable modular source for tree shaking.
9
9
 
10
10
  <div align="center">
11
11
  <a href="https://github.com/vanillaes/absurdum/releases"><img src="https://badgen.net/github/tag/vanillaes/absurdum?cache-control=no-cache" alt="GitHub Release"></a>
12
- <a href="https://www.npmjs.com/package/@vanillaes/absurdum"><img src="https://badgen.net/npm/v/@vanillaes/absurdum?icon=npm" alt="NPM Version"></a>
13
- <a href="https://www.npmjs.com/package/@vanillaes/absurdum"><img src="https://badgen.net/npm/dm/@vanillaes/absurdum?icon=npm" alt="NPM Downloads"></a>
14
- <a href="https://bundlephobia.com/result?p=@vanillaes/absurdum"><img src="https://badgen.net/bundlephobia/minzip/@vanillaes/absurdum" alt="Bundlephobia"></a>
12
+ <a href="https://npmjs.com/package/@vanillaes/absurdum"><img src="https://badgen.net/npm/dw/@vanillaes/absurdum?icon=npm" alt="NPM Weekly Downloads"></a>
13
+ <a href="https://jsr.io/@vanillaes/absurdum"><img src="https://jsr.io/badges/@vanillaes/absurdum/weekly-downloads" alt="JSR Weekly Downloads"></a>
14
+ <a href="https://jsr.io/@vanillaes/absurdum"><img src="https://jsr.io/badges/@vanillaes/absurdum/score" alt="JSR Score"></a>
15
15
  <a href="https://github.com/vanillaes/absurdum/actions"><img src="https://github.com/vanillaes/absurdum/workflows/Latest/badge.svg" alt="Latest Status"></a>
16
16
  <a href="https://github.com/vanillaes/absurdum/actions"><img src="https://github.com/vanillaes/absurdum/workflows/Release/badge.svg" alt="Release Status"></a>
17
17
  </div>
package/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import * as arrays from "./src/arrays/index.js";
2
- import * as strings from "./src/strings/index.js";
3
- import * as objects from "./src/objects/index.js";
1
+ import * as arrays from './src/arrays/index.js';
2
+ import * as strings from './src/strings/index.js';
3
+ import * as objects from './src/objects/index.js';
4
4
  export { arrays, strings, objects };
package/index.js CHANGED
@@ -1,3 +1,5 @@
1
+ /* @ts-self-types="./index.d.ts" */
2
+
1
3
  import * as arrays from './src/arrays/index.js'
2
4
  import * as strings from './src/strings/index.js'
3
5
  import * as objects from './src/objects/index.js'
package/index.min.js CHANGED
@@ -1,3 +1,3 @@
1
- var c=Object.defineProperty;var Je=r=>c(r,"__esModule",{value:!0});var a=(r,e)=>{Je(r);for(var n in e)c(r,n,{get:e[n],enumerable:!0})};var K={};a(K,{chunk:()=>y,compact:()=>O,difference:()=>j,drop:()=>w,dropRight:()=>S,fill:()=>R,filter:()=>$,find:()=>C,findIndex:()=>E,findLastIndex:()=>A,flat:()=>x,frequency:()=>L,intersection:()=>_,map:()=>I,pull:()=>k,take:()=>U,takeRight:()=>M,union:()=>D,unique:()=>P,unzip:()=>z,without:()=>b,xor:()=>T,zip:()=>v});function y(r,e=1){let n=[];return r.reduce((t,u,f,s)=>(n.push(u),n.length===e&&(t.push(n),n=[]),n.length>0&&f===s.length-1&&t.push(n),t),[])}function O(r){return r.reduce((e,n)=>(n&&e.push(n),e),[])}function j(r,e){let n=new Set(e);return r.reduce((t,u)=>(n.has(u)||t.push(u),t),[])}function w(r,e=1){return r.reduce((n,t)=>e>0?(e--,n):(n.push(t),n),[])}function S(r,e=1){return r.reduce((n,t,u,f)=>e>0?(e--,n):(n.unshift(f[f.length-u-1]),n),[])}function R(r,e,n=0,t=r.length-1){return r.reduce((u,f,s)=>(s>=n&&s<=t?u.push(e):u.push(f),u),[])}function $(r,e){return r.reduce((n,t)=>(e(t)&&n.push(t),n),[])}function C(r,e,n){if(r.length!==0){if(typeof e!="function")throw TypeError("predicate must be a function");if(e.call(n,r[0]))return r[0];if(r.length!==1)return r.reduce((t,u,f)=>f===1?e.call(n,u)?u:void 0:!t&&e.call(n,u)?u:t)}}function E(r,e,n){if(r.length===0)return-1;if(typeof e!="function")throw TypeError("predicate must be a function");return r.reduce((t,u,f)=>t<0&&e.call(n,u)?f:t,-1)}function A(r,e,n){if(r.length===0)return-1;if(typeof e!="function")throw TypeError("predicate must be a function");return e.call(n,r[r.length-1])?r.length-1:r.length===1?-1:r.reduceRight((t,u,f)=>f===r.length-2?e.call(n,u)?f:-1:t<0&&e.call(n,u)?f:t)}function x(r,e=1){return r.reduce((n,t)=>(Array.isArray(t)&&e>0?n.push(...x(t,e-1)):n.push(t),n),[])}function L(r){return r.reduce((e,n)=>(e[n]=e[n]?++e[n]:1,e),{})}function _(...r){return[...new Set(arguments[0])].reduce((e,n)=>(r.slice(1).reduce((t,u,f)=>t&&!new Set(u).has(n)?!1:t,!0)&&e.push(n),e),[])}function I(r,e){return e?r.reduce((n,t)=>(n.push(e(t)),n),[]):r}function k(r,...e){let n=new Set(e);return r.reduce((t,u)=>(n.has(u)||t.push(u),t),[])}function M(r,e=1){let n=r.length-1-e;return r.reduce((t,u,f)=>(f>n&&t.push(u),t),[])}function U(r,e=1){return r.reduce((n,t,u)=>(u<e&&n.push(t),n),[])}function D(...r){return Array.from([...r].reduce((e,n)=>(Array.isArray(n)&&n.reduce((t,u)=>(e.add(u),t),""),e),new Set))}function P(r){return[...r.reduce((e,n)=>(e.add(n),e),new Set)]}function z(r){let e=new Array(r.reduce((n,t)=>t.length>n?t.length:n,0)).fill(void 0);return r.reduce((n,t,u)=>(e.reduce((f,s,o)=>(n[o]=n[o]||[],n[o].push(r[u][o]),null),null),n),[])}function b(r,...e){let n=new Set(e);return r.reduce((t,u)=>(n.has(u)||t.push(u),t),[])}function T(...r){if(r.length<2)return r.length===0?[]:r[0];let e=new Set,n=r.reduce((t,u)=>(u.reduce((s,o)=>(t.has(o)&&s.push(o),s),[]).forEach(s=>e.add(s)),u.forEach(s=>t.add(s)),t),new Set);return e.forEach(t=>n.delete(t)),[...n]}function v(r,e,n=(t,u)=>[t,u]){if(n&&typeof n!="function")throw TypeError("func must be a function");return r.length<=e.length?r.reduce((t,u,f)=>(t[f]=n(u,e[f]),t),[]):e.reduce((t,u,f)=>(t[f]=n(r[f],u),t),[])}var $e={};a($e,{camelCase:()=>q,chomp:()=>W,deburr:()=>N,endsWith:()=>G,includes:()=>H,kebabCase:()=>J,pad:()=>Y,padEnd:()=>F,padStart:()=>Q,pascalCase:()=>X,repeat:()=>B,reverse:()=>ee,snakeCase:()=>re,startsWith:()=>te,trimEnd:()=>ue,trimStart:()=>ne,truncate:()=>fe,words:()=>se});function q(r){let e=!0;return r.replace(/[\u2019']/,"").split(/[\u002D\u2014\-_\s]+/).reduce((t,u)=>(e&&u.length>0?(u=u.toLowerCase(),e=!1):u=u.charAt(0).toUpperCase()+u.slice(1).toLowerCase(),t+u),"")}function W(r,e){let n=r.split(""),t=!1;if(e===void 0)return n.reduceRight((u,f,s)=>{if(s===n.length-1){if(f===`
2
- `)return t=!0,u;if(f==="\r")return u}else if(t&&s===n.length-2&&f==="\r")return u;return f+u},"");if(e===""){let u=!0;return n.reduceRight((f,s,o)=>{if(u&&t&&s==="\r")return t=!1,f;if(u){if(s===`
3
- `)return t=!0,f;if(s==="\r")return u=!1,s+f}return s+f},"")}else{let u=n.length-e.length,f=!0,s="";return n.reduce((o,i,l)=>l>=u?(s=s+i,i!==e[l-u]&&(f=!1),l===n.length-1?f?o:o+s:o):o+i,"")}}function N(r){let e="",n=r.match(Fe);return n?e=n.reduce((t,u)=>u.length===1&&Object.prototype.hasOwnProperty.call(V,u)?t+V[u]:t+u,""):e=r,e.replace(Ye,"")}var Ye=/[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff\u1ab0-\u1aff\u1dc0-\u1dff]/g,Z="\xC0\xC1\xC2\xC3\xC4\xC5\xE0\xE1\xE2\xE3\xE4\xE5\xC7\xE7\xD0\xF0\xC8\xC9\xCA\xCB\xE8\xE9\xEA\xEB\xCC\xCD\xCE\xCF\xEC\xED\xEE\xEF\xD1\xF1\xD2\xD3\xD4\xD5\xD6\xD8\xF2\xF3\xF4\xF5\xF6\xF8\xD9\xDA\xDB\xDC\xF9\xFA\xFB\xFC\xDD\xFD\xFF\xC6\xE6\xDE\xFE\xDF\u0100\u0102\u0104\u0101\u0103\u0105\u0106\u0108\u010A\u010C\u0107\u0109\u010B\u010D\u010E\u0110\u010F\u0111\u0112\u0114\u0116\u0118\u011A\u0113\u0115\u0117\u0119\u011B\u011C\u011E\u0120\u0122\u011D\u011F\u0121\u0123\u0124\u0126\u0125\u0127\u0128\u012A\u012C\u012E\u0130\u0129\u012B\u012D\u012F\u0131\u0134\u0135\u0136\u0137\u0138\u0139\u013B\u013D\u013F\u0141\u013A\u013C\u013E\u0140\u0142\u0143\u0145\u0147\u014A\u0144\u0146\u0148\u014B\u014C\u014E\u0150\u014D\u014F\u0151\u0154\u0156\u0158\u0155\u0157\u0159\u015A\u015C\u015E\u0160\u015B\u015D\u015F\u0161\u0162\u0164\u0166\u0163\u0165\u0167\u0168\u016A\u016C\u016E\u0170\u0172\u0169\u016B\u016D\u016F\u0171\u0173\u0174\u0175\u0176\u0177\u0178\u0179\u017B\u017D\u017A\u017C\u017E\u0132\u0133\u0152\u0153\u0149\u017F",Fe=new RegExp("["+Z+"]|[^"+Z+"]+","g"),V={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"Ae",\u00E6:"ae",\u00DE:"Th",\u00FE:"th",\u00DF:"ss",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"IJ",\u0133:"ij",\u0152:"Oe",\u0153:"oe",\u0149:"'n",\u017F:"s"};function G(r,e=""){let n=(t,u,f,s)=>s[s.length-f-1]!==e[e.length-f-1]?(s=s.splice(0),!1):f===e.length-1?(s=s.splice(0),!0):t;return r.split("").reduce(n,null)}function H(r,e,n=0){if(r.length===0)return!1;let t=e.length,u=e.charAt(0);return n===0&&r.substring(0,t)===e?!0:r.split("").reduce((f,s,o)=>{if(o>=n){if(f)return f;if(s===u)return r.substring(o,o+t)===e}return!1},!1)}function J(r){let e=!0;return r.replace(/[\u2019']/,"").split(/[\u002D\u2014\-_\s]+/).reduce((n,t)=>t.length>0?e?(e=!1,t.toLowerCase()):n+"-"+t.toLowerCase():n,"")}function Y(r,e=0,n=" "){let t=r.length,u=e-t>0?Math.ceil((e-t)/2):0;return r.padStart(e-u,n).padEnd(e,n)}function F(r,e=0,n=" "){let t=r.length,u=e-r.length>0?e-r.length:0,f=0,s=[...r,...Array(u)],o=(i,l)=>t!==0?(i.push(l),t--,i):(i.push(n[f]),f=f+1<n.length?f+1:0,i);return s.reduce(o,[]).join("")}function Q(r,e=0,n=" "){let t=e-r.length>0?e-r.length:0,u=0,f=[...Array(t),...r],s=(o,i)=>t!==0?(o.push(n[u]),u=u+1<n.length?u+1:0,t--,o):(o.push(i),o);return f.reduce(s,[]).join("")}function X(r){return r.replace(/[\u2019']/,"").split(/[\u002D\u2014\-_\s]+/).reduce((n,t)=>n+t.charAt(0).toUpperCase()+t.slice(1).toLowerCase(),"")}function B(r,e=0){return r.length===0||e<1?"":new Array(e).fill("").reduce(n=>n+r,"")}function ee(r){return r.split("").reduce((e,n)=>n+e,"")}function re(r){let e=!0;return r.replace(/[\u2019']/,"").split(/[\u002D\u2014\-_\s]+/).reduce((n,t)=>t.length>0?e?(e=!1,t.toLowerCase()):n+"_"+t.toLowerCase():n,"")}function te(r,e){let n=r.split(""),t=(u,f,s,o)=>f!==e[s]?(n=o.splice(0),!1):s===e.length-1?(n=o.splice(0),!0):u;return n.reduce(t,null)}function ne(r,e=" "){let n=new Set([...e]),t=!0;return[...r].reduce((u,f)=>t?n.has(f)?u:(t=!1,u+f):u+f,"")}function ue(r,e=" "){let n=new Set([...e]),t=!0;return[...r].reduceRight((u,f)=>t?n.has(f)?u:(t=!1,f+u):f+u,"")}function fe(r,e){let n=30,t="...",u;if(e&&(e.length!==void 0&&(n=e.length),e.omission!==void 0&&(t=e.omission),e.separator!==void 0&&(u=e.separator)),n>=r.length)return r;let f=n-t.length;if(f<1)return t;let s=r.slice(0,f);if(u===void 0)return s+t;let o,i;if(typeof u=="string"?o=u:i=u,i){if(r.slice(f).search(i)){let l,d,m=s;for(i.global||(i=RegExp(i.source,i.flags+"g")),i.lastIndex=0,l=i.exec(m);l;)d=l.index,l=i.exec(m);s=s.slice(0,d===void 0?f:d)}}else if(r.indexOf(o,f)!==f){let l=s.lastIndexOf(o);l>-1&&(s=s.slice(0,l))}return s+t}function se(r,e){return e===void 0?r.match(jr)||[]:typeof e=="string"?r.match(new RegExp("[^"+e+"]+","g"))||[]:r.match(e)||[]}var oe="\\ud800-\\udfff",Qe="\\u0300-\\u036f",Xe="\\ufe20-\\ufe2f",Be="\\u20d0-\\u20ff",er="\\u1ab0-\\u1aff",rr="\\u1dc0-\\u1dff",tr=Qe+Xe+Be+er+rr,ie="\\u2700-\\u27bf",le="a-z\\xdf-\\xf6\\xf8-\\xff",nr="\\xac\\xb1\\xd7\\xf7",ur="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",fr="\\u2000-\\u206f",sr=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",pe="A-Z\\xc0-\\xd6\\xd8-\\xde",or="\\ufe0e\\ufe0f",de=nr+ur+fr+sr,ae="['\u2019]",xe=`[${de}]`,ir=`[${tr}]`,he="\\d",lr=`[${ie}]`,ge=`[${le}]`,me=`[^${oe}${de+he+ie+le+pe}]`,pr="\\ud83c[\\udffb-\\udfff]",dr=`(?:${ir}|${pr})`,ar=`[^${oe}]`,ce="(?:\\ud83c[\\udde6-\\uddff]){2}",ye="[\\ud800-\\udbff][\\udc00-\\udfff]",p=`[${pe}]`,xr="\\u200d",Oe=`(?:${ge}|${me})`,hr=`(?:${p}|${me})`,je=`(?:${ae}(?:d|ll|m|re|s|t|ve))?`,we=`(?:${ae}(?:D|LL|M|RE|S|T|VE))?`,Se=`${dr}?`,Re=`[${or}]?`,gr=`(?:${xr}(?:${[ar,ce,ye].join("|")})${Re+Se})*`,mr="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",cr="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",yr=Re+Se+gr,Or=`(?:${[lr,ce,ye].join("|")})${yr}`,jr=RegExp([`${p}?${ge}+${je}(?=${[xe,p,"$"].join("|")})`,`${hr}+${we}(?=${[xe,p+Oe,"$"].join("|")})`,`${p}?${Oe}+${je}`,`${p}+${we}`,cr,mr,`${he}+`,Or].join("|"),"g");var He={};a(He,{assign:()=>Ce,at:()=>Ee,defaults:()=>Ae,defaultsDeep:()=>Le,entries:()=>_e,filter:()=>Ie,findKey:()=>ke,findLastKey:()=>Ue,forIn:()=>Pe,fromEntries:()=>ze,get:()=>Te,has:()=>be,invert:()=>ve,mapKeys:()=>Ke,mapValues:()=>qe,merge:()=>We,pick:()=>Ne,result:()=>Ze,transform:()=>Ve,values:()=>Ge});function Ce(r,...e){return arguments.length<2?arguments.length===1?r:{}:[r,...e].reduce((t,u)=>(Object.keys(u).reduce((f,s)=>(t[s]=u[s],null),null),t),{})}function Ee(r,...e){if(e.length===0)return[];let n=[],t=u=>{u.reduce((f,s,o)=>(n[o]=String(s).replace(/\[(\w+)\]/g,".$1").split("."),null),null)};return Array.isArray(e[0])?t(e[0]):t(e),n.reduce((u,f)=>{let s=f.reduce((o,i)=>{if(typeof o!="undefined"&&Object.prototype.hasOwnProperty.call(o,i))return o[i]},r);return u.push(s),u},[])}function Ae(r,...e){return arguments.length<2?arguments.length===1?r:{}:[r,...e].reduce((t,u)=>(Object.keys(u).reduce((f,s)=>(typeof t[s]=="undefined"&&(t[s]=u[s]),null),null),t),{})}function Le(r,...e){return arguments.length<2?arguments.length===1?r:{}:[r,...e].reduce((t,u)=>h(t,u))}var h=(r,e)=>Array.isArray(e)?Array.isArray(r)?wr(r,e):r:Sr(r,e),wr=(r,e)=>{let n=[...r];return e.reduce((t,u,f)=>(typeof r[f]=="undefined"?n[f]=u:typeof u=="object"&&(n[f]=h(r[f],u)),null),null),n},Sr=(r,e)=>{let n={};if(typeof r=="object")Object.keys(r).reduce((t,u)=>(typeof n[u]=="undefined"&&(n[u]=r[u]),null),null);else return r;return Object.keys(e).reduce((t,u)=>(typeof e[u]!="object"||!r[u]?typeof n[u]=="undefined"&&(n[u]=e[u]):n[u]=h(r[u],e[u]),null),null),n};function _e(r){return Object.keys(r).reduce((e,n)=>(e.push([n,r[n]]),e),[])}function Ie(r,e){return typeof e!="function"?r:Object.keys(r).reduce((n,t)=>(e(r[t],t,r)===!0&&(n[t]=r[t]),n),{})}function ke(r,e=t=>t,n){let t=Object.keys(r);return typeof e=="function"?t.reduce((u,f)=>u||(e.call(n,r[f])?f:u),void 0):Array.isArray(e)?t.reduce((u,f)=>u||(r[f][e[0]]===e[1]?f:u),void 0):typeof e=="object"?t.reduce((u,f)=>u||(Me(r[f],e)?f:u),void 0):t.reduce((u,f)=>u||(r[f][e]?f:u),void 0)}var Me=(r,e)=>typeof r!=typeof e?!1:typeof r!="object"?r===e:Object.keys(e).reduce((n,t)=>{if(n)return n;if(Object.prototype.hasOwnProperty.call(r,t)!==Object.prototype.hasOwnProperty.call(e,t))return!1;if(typeof r[t]=="object"){if(!Me(r[t],e[t]))return!1}else if(typeof r[t]=="function"){if(typeof e[t]=="undefined"||String(r[t])!==String(e[t]))return!1}else if(r[t]!==e[t])return!1;return!0},!1);function Ue(r,e=t=>t,n){let t=Object.keys(r);return typeof e=="function"?t.reduceRight((u,f)=>u||(e.call(n,r[f])?f:u),void 0):Array.isArray(e)?t.reduceRight((u,f)=>u||(r[f][e[0]]===e[1]?f:u),void 0):typeof e=="object"?t.reduceRight((u,f)=>u||(De(r[f],e)?f:u),void 0):t.reduceRight((u,f)=>u||(r[f][e]?f:u),void 0)}var De=(r,e)=>typeof r!=typeof e?!1:typeof r!="object"?r===e:Object.keys(e).reduceRight((n,t)=>{if(n)return n;if(Object.prototype.hasOwnProperty.call(r,t)!==Object.prototype.hasOwnProperty.call(e,t))return!1;if(typeof r[t]=="object"){if(!De(r[t],e[t]))return!1}else if(typeof r[t]=="function"){if(typeof e[t]=="undefined"||String(r[t])!==String(e[t]))return!1}else if(r[t]!==e[t])return!1;return!0},!1);function Pe(r,e){let n=Object.getPrototypeOf(r),t=n?Object.keys(n):[];return Object.keys(r).reduce((u,f)=>(e(r[f],f,r),null),null),t.reduce((u,f)=>(e(n[f],f,r),null),null),r}function ze(r){return r.reduce((e,n)=>(e[n[0]]=n[1],e),{})}function be(r,e){if(typeof e=="undefined")return!1;let n;return Array.isArray(e)?n=e:n=String(e).replace(/\[(\w+)\]/g,".$1").split("."),n.reduce((t,u)=>{if(t!==void 0&&Object.prototype.hasOwnProperty.call(t,u))return t[u]},r)!==void 0}function Te(r,e,n){if(typeof e=="undefined")return;let t;Array.isArray(e)?t=e:t=String(e).replace(/\[(\w+)\]/g,".$1").split(".");let u=t.reduce((f,s)=>{if(f!==void 0&&Object.prototype.hasOwnProperty.call(f,s))return f[s]},r);return u!==void 0?u:n}function ve(r){return Object.keys(r).reduce((e,n)=>(e[r[n]]=n,e),{})}function Ke(r,e){return typeof e!="function"?r:Object.keys(r).reduce((n,t)=>({...n,[e(r[t],t,r)]:r[t]}),{})}function qe(r,e){return typeof e!="function"?r:Object.keys(r).reduce((n,t)=>({...n,[t]:e(r[t],t,r)}),{})}function We(r,...e){return arguments.length<2?arguments.length===1?r:{}:[r,...e].reduce((t,u)=>g(t,u))}var g=(r,e)=>Array.isArray(e)?Array.isArray(r)?Rr(r,e):e:$r(r,e),Rr=(r,e)=>{let n=r.slice();return e.reduce((t,u,f)=>(typeof n[f]=="undefined"?n[f]=u:typeof u=="object"?n[f]=g(r[f],u):r.indexOf(u)===-1&&n.push(u),null),null),n},$r=(r,e)=>{let n={};return typeof r=="object"&&Object.keys(r).reduce((t,u)=>(n[u]=r[u],null),null),Object.keys(e).reduce((t,u)=>(typeof e[u]!="object"||!r[u]?n[u]=e[u]:n[u]=g(r[u],e[u]),null),null),n};function Ne(r,...e){if(e.length===0)return{};let n=new Set;return Array.isArray(e[0])?e[0].forEach(t=>n.add(String(t))):e.forEach(t=>n.add(String(t))),Object.keys(r).reduce((t,u)=>(n.has(u)&&(t[u]=r[u]),t),{})}function Ze(r,e,n){if(typeof e=="undefined")return;let t;Array.isArray(e)?t=e:t=String(e).replace(/\[(\w+)\]/g,".$1").split(".");let u=t.reduce((f,s)=>{if(f!==void 0&&Object.prototype.hasOwnProperty.call(f,s))return typeof f[s]=="function"?f[s]():f[s]},r);return u!==void 0?u:typeof n=="function"?n():n}function Ve(r,e,n={}){return typeof e=="undefined"?r:Object.keys(r).reduce((t,u)=>(e(t,r[u],u,r),t),n)}function Ge(r){return Object.keys(r).reduce((e,n)=>(e.push(r[n]),e),[])}export{K as arrays,He as objects,$e as strings};
1
+ var Ve=Object.defineProperty;var x=(r,e)=>{for(var t in e)Ve(r,t,{get:e[t],enumerable:!0})};var q={};x(q,{chunk:()=>c,compact:()=>y,difference:()=>O,drop:()=>w,dropRight:()=>$,fill:()=>S,filter:()=>R,find:()=>C,findIndex:()=>E,findLastIndex:()=>A,flat:()=>a,frequency:()=>L,intersection:()=>_,map:()=>I,pull:()=>M,take:()=>k,takeRight:()=>U,union:()=>D,unique:()=>P,unzip:()=>T,without:()=>z,xor:()=>b,zip:()=>N});function c(r,e=1){let t=[];return r.reduce((n,u,f,o)=>(t.push(u),t.length===e&&(n.push(t),t=[]),t.length>0&&f===o.length-1&&n.push(t),n),[])}function y(r){return r.reduce((e,t)=>(t&&e.push(t),e),[])}function O(r,e){let t=new Set(e);return r.reduce((n,u)=>(t.has(u)||n.push(u),n),[])}function w(r,e=1){return r.reduce((t,n)=>e>0?(e--,t):(t.push(n),t),[])}function $(r,e=1){return r.reduce((t,n,u,f)=>e>0?(e--,t):(t.unshift(f[f.length-u-1]),t),[])}function S(r,e,t=0,n=r.length-1){return r.reduce((u,f,o)=>(o>=t&&o<=n?u.push(e):u.push(f),u),[])}function R(r,e){return r.reduce((t,n)=>(e(n)&&t.push(n),t),[])}function C(r,e,t){if(r.length===0)return;if(typeof e!="function")throw TypeError("predicate must be a function");return e.call(t,r[0])?r[0]:r.length===1?void 0:r.reduce((u,f,o)=>o===1?e.call(t,f)?f:void 0:!u&&e.call(t,f)?f:u,void 0)}function E(r,e,t){if(r.length===0)return-1;if(typeof e!="function")throw TypeError("predicate must be a function");return r.reduce((n,u,f)=>n<0&&e.call(t,u)?f:n,-1)}function A(r,e,t){if(r.length===0)return-1;if(typeof e!="function")throw TypeError("predicate must be a function");return e.call(t,r[r.length-1])?r.length-1:r.length===1?-1:r.reduceRight((n,u,f)=>f===r.length-2?e.call(t,u)?f:-1:n<0&&e.call(t,u)?f:n,-1)}function a(r,e=1){return r.reduce((t,n)=>(Array.isArray(n)&&e>0?t.push(...a(n,e-1)):t.push(n),t),[])}function L(r){return r.reduce((e,t)=>(e[t]=e[t]?e[t]+=1:1,e),{})}function _(...r){return[...new Set(arguments[0])].reduce((e,t)=>(r.slice(1).reduce((n,u,f)=>n&&!new Set(u).has(t)?!1:n,!0)&&e.push(t),e),[])}function I(r,e){return e?r.reduce((t,n)=>(t.push(e(n)),t),[]):r}function M(r,...e){let t=new Set(e);return r.reduce((n,u)=>(t.has(u)||n.push(u),n),[])}function U(r,e=1){let t=r.length-1-e;return r.reduce((n,u,f)=>(f>t&&n.push(u),n),[])}function k(r,e=1){return r.reduce((t,n,u)=>(u<e&&t.push(n),t),[])}function D(...r){return Array.from([...r].reduce((e,t)=>(Array.isArray(t)&&t.reduce((n,u)=>(e.add(u),n),""),e),new Set))}function P(r){return[...r.reduce((e,t)=>(e.add(t),e),new Set)]}function T(r){let e=new Array(r.reduce((t,n)=>n.length>t?n.length:t,0)).fill(void 0);return r.reduce((t,n,u)=>(e.reduce((f,o,i)=>(t[i]=t[i]||[],t[i].push(r[u][i]),null),null),t),[])}function z(r,...e){let t=new Set(e);return r.reduce((n,u)=>(t.has(u)||n.push(u),n),[])}function b(...r){if(r.length<2)return r.length===0?[]:r[0];let e=new Set,t=r.reduce((n,u)=>(u.reduce((o,i)=>(n.has(i)&&o.push(i),o),[]).forEach(o=>e.add(o)),u.forEach(o=>n.add(o)),n),new Set);return e.forEach(n=>t.delete(n)),[...t]}function N(r,e,t=(n,u)=>[n,u]){if(t&&typeof t!="function")throw TypeError("func must be a function");return r.length<=e.length?r.reduce((n,u,f)=>(n[f]=t(u,e[f]),n),[]):e.reduce((n,u,f)=>(n[f]=t(r[f],u),n),[])}var Re={};x(Re,{camelCase:()=>v,chomp:()=>K,deburr:()=>G,endsWith:()=>H,includes:()=>J,kebabCase:()=>V,pad:()=>Y,padEnd:()=>F,padStart:()=>Q,pascalCase:()=>X,repeat:()=>j,reverse:()=>B,snakeCase:()=>ee,startsWith:()=>re,trimEnd:()=>ne,trimStart:()=>te,truncate:()=>ue,words:()=>le});function v(r){let e=!0;return r.replace(/[\u2019']/,"").split(/[\u002D\u2014\-_\s]+/).reduce((n,u)=>(e&&u.length>0?(u=u.toLowerCase(),e=!1):u=u.charAt(0).toUpperCase()+u.slice(1).toLowerCase(),n+u),"")}function K(r,e){let t=r.split(""),n=!1;if(e===void 0)return t.reduceRight((u,f,o)=>{if(o===t.length-1){if(f===`
2
+ `)return n=!0,u;if(f==="\r")return u}else if(n&&o===t.length-2&&f==="\r")return u;return f+u},"");if(e===""){let u=!0;return t.reduceRight((f,o,i)=>{if(u&&n&&o==="\r")return n=!1,f;if(u){if(o===`
3
+ `)return n=!0,f;if(o==="\r")return u=!1,o+f}return o+f},"")}else{let u=t.length-e.length,f=!0,o="";return t.reduce((i,s,l)=>l>=u?(o=o+s,s!==e[l-u]&&(f=!1),l===t.length-1?f?i:i+o:i):i+s,"")}}function G(r){let e="",t=r.match(Fe);return t?e=t.reduce((n,u)=>u.length===1&&Object.prototype.hasOwnProperty.call(Z,u)?n+Z[u]:n+u,""):e=r,e.replace(Ye,"")}var Ye=/[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff\u1ab0-\u1aff\u1dc0-\u1dff]/g,W="\xC0\xC1\xC2\xC3\xC4\xC5\xE0\xE1\xE2\xE3\xE4\xE5\xC7\xE7\xD0\xF0\xC8\xC9\xCA\xCB\xE8\xE9\xEA\xEB\xCC\xCD\xCE\xCF\xEC\xED\xEE\xEF\xD1\xF1\xD2\xD3\xD4\xD5\xD6\xD8\xF2\xF3\xF4\xF5\xF6\xF8\xD9\xDA\xDB\xDC\xF9\xFA\xFB\xFC\xDD\xFD\xFF\xC6\xE6\xDE\xFE\xDF\u0100\u0102\u0104\u0101\u0103\u0105\u0106\u0108\u010A\u010C\u0107\u0109\u010B\u010D\u010E\u0110\u010F\u0111\u0112\u0114\u0116\u0118\u011A\u0113\u0115\u0117\u0119\u011B\u011C\u011E\u0120\u0122\u011D\u011F\u0121\u0123\u0124\u0126\u0125\u0127\u0128\u012A\u012C\u012E\u0130\u0129\u012B\u012D\u012F\u0131\u0134\u0135\u0136\u0137\u0138\u0139\u013B\u013D\u013F\u0141\u013A\u013C\u013E\u0140\u0142\u0143\u0145\u0147\u014A\u0144\u0146\u0148\u014B\u014C\u014E\u0150\u014D\u014F\u0151\u0154\u0156\u0158\u0155\u0157\u0159\u015A\u015C\u015E\u0160\u015B\u015D\u015F\u0161\u0162\u0164\u0166\u0163\u0165\u0167\u0168\u016A\u016C\u016E\u0170\u0172\u0169\u016B\u016D\u016F\u0171\u0173\u0174\u0175\u0176\u0177\u0178\u0179\u017B\u017D\u017A\u017C\u017E\u0132\u0133\u0152\u0153\u0149\u017F",Fe=new RegExp("["+W+"]|[^"+W+"]+","g"),Z={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"Ae",\u00E6:"ae",\u00DE:"Th",\u00FE:"th",\u00DF:"ss",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"IJ",\u0133:"ij",\u0152:"Oe",\u0153:"oe",\u0149:"'n",\u017F:"s"};function H(r,e=""){let t=(n,u,f,o)=>o[o.length-f-1]!==e[e.length-f-1]?(o=o.splice(0),!1):f===e.length-1?(o=o.splice(0),!0):n;return r.split("").reduce(t,null)}function J(r,e,t=0){if(r.length===0)return!1;let n=e.length,u=e.charAt(0);return t===0&&r.substring(0,n)===e?!0:r.split("").reduce((f,o,i)=>{if(i>=t){if(f)return f;if(o===u)return r.substring(i,i+n)===e}return!1},!1)}function V(r){let e=!0;return r.replace(/[\u2019']/,"").split(/[\u002D\u2014\-_\s]+/).reduce((t,n)=>n.length>0?e?(e=!1,n.toLowerCase()):t+"-"+n.toLowerCase():t,"")}function Y(r,e=0,t=" "){let n=r.length,u=e-n>0?Math.ceil((e-n)/2):0;return r.padStart(e-u,t).padEnd(e,t)}function F(r,e=0,t=" "){let n=r.length,u=e-r.length>0?e-r.length:0,f=0,o=[...r,...Array(u)],i=(s,l)=>n!==0?(s.push(l),n--,s):(s.push(t[f]),f=f+1<t.length?f+1:0,s);return o.reduce(i,[]).join("")}function Q(r,e=0,t=" "){let n=e-r.length>0?e-r.length:0,u=0,f=[...Array(n),...r],o=(i,s)=>n!==0?(i.push(t[u]),u=u+1<t.length?u+1:0,n--,i):(i.push(s),i);return f.reduce(o,[]).join("")}function X(r){return r.replace(/[\u2019']/,"").split(/[\u002D\u2014\-_\s]+/).reduce((t,n)=>t+n.charAt(0).toUpperCase()+n.slice(1).toLowerCase(),"")}function j(r,e=0){return r.length===0||e<1?"":new Array(e).fill("").reduce(t=>t+r,"")}function B(r){return r.split("").reduce((e,t)=>t+e,"")}function ee(r){let e=!0;return r.replace(/[\u2019']/,"").split(/[\u002D\u2014\-_\s]+/).reduce((t,n)=>n.length>0?e?(e=!1,n.toLowerCase()):t+"_"+n.toLowerCase():t,"")}function re(r,e){let t=r.split(""),n=(u,f,o,i)=>f!==e[o]?(t=i.splice(0),!1):o===e.length-1?(t=i.splice(0),!0):u;return t.reduce(n,null)}function te(r,e=" "){let t=new Set([...e]),n=!0;return[...r].reduce((u,f)=>n?t.has(f)?u:(n=!1,u+f):u+f,"")}function ne(r,e=" "){let t=new Set([...e]),n=!0;return[...r].reduceRight((u,f)=>n?t.has(f)?u:(n=!1,f+u):f+u,"")}function ue(r,e={}){let t=30,n="...",u;if(e&&(e?.length!==void 0&&(t=e.length),e?.omission!==void 0&&(n=e.omission),e?.separator!==void 0&&(u=e.separator)),t>=r.length)return r;let f=t-n.length;if(f<1)return n;let o=r.slice(0,f);if(u===void 0)return o+n;let i="",s;if(typeof u=="string"?i=u:s=u,s){if(r.slice(f).search(s)){let l,d,m=o;for(s.global||(s=RegExp(s.source,s.flags+"g")),s.lastIndex=0,l=s.exec(m);l;)d=l.index,l=s.exec(m);o=o.slice(0,d===void 0?f:d)}}else if(r.indexOf(i,f)!==f){let l=o.lastIndexOf(i);l>-1&&(o=o.slice(0,l))}return o+n}function le(r,e){return e===void 0?r.match(Or)||[]:typeof e=="string"?r.match(new RegExp("[^"+e+"]+","g"))||[]:r.match(e)||[]}var pe="\\ud800-\\udfff",Qe="\\u0300-\\u036f",Xe="\\ufe20-\\ufe2f",je="\\u20d0-\\u20ff",Be="\\u1ab0-\\u1aff",er="\\u1dc0-\\u1dff",rr=Qe+Xe+je+Be+er,de="\\u2700-\\u27bf",xe="a-z\\xdf-\\xf6\\xf8-\\xff",tr="\\xac\\xb1\\xd7\\xf7",nr="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",ur="\\u2000-\\u206f",fr=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",ae="A-Z\\xc0-\\xd6\\xd8-\\xde",or="\\ufe0e\\ufe0f",he=tr+nr+ur+fr,ge="['\u2019]",fe=`[${he}]`,ir=`[${rr}]`,me="\\d",sr=`[${de}]`,ce=`[${xe}]`,ye=`[^${pe}${he+me+de+xe+ae}]`,lr="\\ud83c[\\udffb-\\udfff]",pr=`(?:${ir}|${lr})`,dr=`[^${pe}]`,Oe="(?:\\ud83c[\\udde6-\\uddff]){2}",we="[\\ud800-\\udbff][\\udc00-\\udfff]",p=`[${ae}]`,xr="\\u200d",oe=`(?:${ce}|${ye})`,ar=`(?:${p}|${ye})`,ie=`(?:${ge}(?:d|ll|m|re|s|t|ve))?`,se=`(?:${ge}(?:D|LL|M|RE|S|T|VE))?`,$e=`${pr}?`,Se=`[${or}]?`,hr=`(?:${xr}(?:${[dr,Oe,we].join("|")})${Se+$e})*`,gr="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",mr="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",cr=Se+$e+hr,yr=`(?:${[sr,Oe,we].join("|")})${cr}`,Or=RegExp([`${p}?${ce}+${ie}(?=${[fe,p,"$"].join("|")})`,`${ar}+${se}(?=${[fe,p+oe,"$"].join("|")})`,`${p}?${oe}+${ie}`,`${p}+${se}`,mr,gr,`${me}+`,yr].join("|"),"g");var Je={};x(Je,{assign:()=>Ce,at:()=>Ee,defaults:()=>Ae,defaultsDeep:()=>Le,entries:()=>_e,filter:()=>Ie,findKey:()=>Me,findLastKey:()=>ke,forIn:()=>Pe,fromEntries:()=>Te,get:()=>be,has:()=>ze,invert:()=>Ne,mapKeys:()=>qe,mapValues:()=>ve,merge:()=>Ke,pick:()=>We,result:()=>Ze,transform:()=>Ge,values:()=>He});function Ce(r,...e){return arguments.length<2?arguments.length===1?r:{}:[r,...e].reduce((n,u)=>(Object.keys(u).reduce((f,o)=>(n[o]=u[o],null),null),n),{})}function Ee(r,...e){if(e.length===0)return[];let t=[],n=u=>{u.reduce((f,o,i)=>(t[i]=String(o).replace(/\[(\w+)\]/g,".$1").split("."),null),null)};return Array.isArray(e[0])?n(e[0]):n(e),t.reduce((u,f)=>{let o=f.reduce((i,s)=>{if(!(typeof i>"u")&&Object.prototype.hasOwnProperty.call(i,s))return i[s]},r);return u.push(o),u},[])}function Ae(r,...e){return arguments.length<2?arguments.length===1?r:{}:[r,...e].reduce((n,u)=>(Object.keys(u).reduce((f,o)=>(typeof n[o]>"u"&&(n[o]=u[o]),null),null),n),{})}function Le(r,...e){return arguments.length<2?arguments.length===1?r:{}:[r,...e].reduce((n,u)=>h(n,u))}var h=(r,e)=>Array.isArray(e)?Array.isArray(r)?wr(r,e):r:$r(r,e),wr=(r,e)=>{let t=[...r];return e.reduce((n,u,f)=>(typeof r[f]>"u"?t[f]=u:typeof u=="object"&&(t[f]=h(r[f],u)),null),null),t},$r=(r,e)=>{let t={};if(typeof r=="object")Object.keys(r).reduce((n,u)=>(typeof t[u]>"u"&&(t[u]=r[u]),null),null);else return r;return Object.keys(e).reduce((n,u)=>(typeof e[u]!="object"||!r[u]?typeof t[u]>"u"&&(t[u]=e[u]):t[u]=h(r[u],e[u]),null),null),t};function _e(r){return Object.keys(r).reduce((e,t)=>(e.push([t,r[t]]),e),[])}function Ie(r,e){return typeof e!="function"?r:Object.keys(r).reduce((t,n)=>(e(r[n],n,r)===!0&&(t[n]=r[n]),t),{})}function Me(r,e=n=>n,t){let n=Object.keys(r);return typeof e=="function"?n.reduce((u,f)=>u||(e.call(t,r[f])?f:u),void 0):Array.isArray(e)?n.reduce((u,f)=>u||(r[f][e[0]]===e[1]?f:u),void 0):typeof e=="object"?n.reduce((u,f)=>u||(Ue(r[f],e)?f:u),void 0):n.reduce((u,f)=>u||(r[f][e]?f:u),void 0)}var Ue=(r,e)=>typeof r!=typeof e?!1:typeof r!="object"?r===e:Object.keys(e).reduce((t,n)=>{if(t)return t;if(Object.prototype.hasOwnProperty.call(r,n)!==Object.prototype.hasOwnProperty.call(e,n))return!1;if(typeof r[n]=="object"){if(!Ue(r[n],e[n]))return!1}else if(typeof r[n]=="function"){if(typeof e[n]>"u"||String(r[n])!==String(e[n]))return!1}else if(r[n]!==e[n])return!1;return!0},!1);function ke(r,e=n=>n,t){let n=Object.keys(r);return typeof e=="function"?n.reduceRight((u,f)=>u||(e.call(t,r[f])?f:u),void 0):Array.isArray(e)?n.reduceRight((u,f)=>u||(r[f][e[0]]===e[1]?f:u),void 0):typeof e=="object"?n.reduceRight((u,f)=>u||(De(r[f],e)?f:u),void 0):n.reduceRight((u,f)=>u||(r[f][e]?f:u),void 0)}var De=(r,e)=>typeof r!=typeof e?!1:typeof r!="object"?r===e:Object.keys(e).reduceRight((t,n)=>{if(t)return t;if(Object.prototype.hasOwnProperty.call(r,n)!==Object.prototype.hasOwnProperty.call(e,n))return!1;if(typeof r[n]=="object"){if(!De(r[n],e[n]))return!1}else if(typeof r[n]=="function"){if(typeof e[n]>"u"||String(r[n])!==String(e[n]))return!1}else if(r[n]!==e[n])return!1;return!0},!1);function Pe(r,e){let t=Object.getPrototypeOf(r),n=t?Object.keys(t):[];return Object.keys(r).reduce((u,f)=>(e(r[f],f,r),null),null),n.reduce((u,f)=>(e(t[f],f,r),null),null),Object.setPrototypeOf(r,Object.prototype)}function Te(r){return r.reduce((e,t)=>(e[t[0]]=t[1],e),{})}function ze(r,e){if(typeof e>"u")return!1;let t;return Array.isArray(e)?t=e:t=String(e).replace(/\[(\w+)\]/g,".$1").split("."),t.reduce((n,u)=>{if(n!==void 0&&Object.prototype.hasOwnProperty.call(n,u))return n[u]},r)!==void 0}function be(r,e,t){if(typeof e>"u")return;let n;Array.isArray(e)?n=e:n=String(e).replace(/\[(\w+)\]/g,".$1").split(".");let u=n.reduce((f,o)=>{if(f!==void 0&&Object.prototype.hasOwnProperty.call(f,o))return f[o]},r);return u!==void 0?u:t}function Ne(r){return Object.keys(r).reduce((e,t)=>(e[r[t]]=t,e),{})}function qe(r,e){return typeof e!="function"?r:Object.keys(r).reduce((t,n)=>({...t,[e(r[n],n,r)]:r[n]}),{})}function ve(r,e){return typeof e!="function"?r:Object.keys(r).reduce((t,n)=>({...t,[n]:e(r[n],n,r)}),{})}function Ke(r,...e){return arguments.length<2?arguments.length===1?r:{}:[r,...e].reduce((n,u)=>g(n,u))}var g=(r,e)=>Array.isArray(e)?Array.isArray(r)?Sr(r,e):e:Rr(r,e),Sr=(r,e)=>{let t=r.slice();return e.reduce((n,u,f)=>(typeof t[f]>"u"?t[f]=u:typeof u=="object"?t[f]=g(r[f],u):r.indexOf(u)===-1&&t.push(u),null),null),t},Rr=(r,e)=>{let t={};return typeof r=="object"&&Object.keys(r).reduce((n,u)=>(t[u]=r[u],null),null),Object.keys(e).reduce((n,u)=>(typeof e[u]!="object"||!r[u]?t[u]=e[u]:t[u]=g(r[u],e[u]),null),null),t};function We(r,...e){if(e.length===0)return{};let t=new Set;return Array.isArray(e[0])?e[0].forEach(n=>t.add(String(n))):e.forEach(n=>t.add(String(n))),Object.keys(r).reduce((n,u)=>(t.has(u)&&(n[u]=r[u]),n),{})}function Ze(r,e,t){if(typeof e>"u")return;let n;Array.isArray(e)?n=e:n=String(e).replace(/\[(\w+)\]/g,".$1").split(".");let u=n.reduce((f,o)=>{if(f!==void 0&&Object.prototype.hasOwnProperty.call(f,o))return typeof f[o]=="function"?f[o]():f[o]},r);return u!==void 0?u:typeof t=="function"?t():t}function Ge(r,e,t={}){return typeof e>"u"?r:Object.keys(r).reduce((n,u)=>(e(n,r[u],u,r),n),t)}function He(r){return Object.keys(r).reduce((e,t)=>(e.push(r[t]),e),[])}export{q as arrays,Je as objects,Re as strings};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vanillaes/absurdum",
3
- "version": "2.0.6",
3
+ "version": "2.0.10",
4
4
  "description": "Absurdum - The Ridiculous Application of Reduce",
5
5
  "keywords": [
6
6
  "esm",
@@ -27,40 +27,39 @@
27
27
  "exports": {
28
28
  ".": {
29
29
  "import": "./index.js",
30
+ "types": "./index.d.ts",
30
31
  "browser": "./index.min.js"
31
32
  },
32
33
  "./arrays": {
33
- "import": "./src/arrays/index.js"
34
+ "import": "./src/arrays/index.js",
35
+ "types": "./src/arrays/index.d.ts",
36
+ "browser": "./src/arrays/index.min.js"
34
37
  },
35
38
  "./objects": {
36
- "import": "./src/objects/index.js"
39
+ "import": "./src/objects/index.js",
40
+ "types": "./src/objects/index.d.ts",
41
+ "browser": "./src/objects/index.min.js"
37
42
  },
38
43
  "./strings": {
39
- "import": "./src/strings/index.js"
44
+ "import": "./src/strings/index.js",
45
+ "types": "./src/strings/index.d.ts",
46
+ "browser": "./src/strings/index.min.js"
40
47
  }
41
48
  },
42
- "types": "index.d.ts",
43
49
  "scripts": {
44
50
  "test": "esmtk test",
45
51
  "lint": "esmtk lint",
46
- "type": "esmtk type index.js",
47
- "build": "npm run build:min && npm run build:docs && npm run build:typings",
48
- "build:docs": "node .config/docs.config.js",
49
- "build:min": "esmtk minify index.js index.min.js",
50
- "build:typings": "esmtk typings index.js",
51
- "clean": "npm run clean:docs && npm run clean:min && npm run clean:typings",
52
- "clean:docs": "esmtk clean --custom docs/**/*.md",
53
- "clean:min": "esmtk clean --minify",
54
- "clean:typings": "esmtk clean --typings",
52
+ "type": "esmtk type",
53
+ "build": "esmtk minify && esmtk typings && node .config/docs.config.js",
54
+ "clean": "esmtk clean --minify --typings",
55
55
  "preview": "esmtk preview",
56
56
  "preversion": "npm test && npm run lint && npm run type",
57
+ "version": "npm run clean && npm run build && git add -f **/*.d.ts **/*.min.js",
57
58
  "postversion": "git push --follow-tags"
58
59
  },
59
60
  "devDependencies": {
61
+ "@vanillaes/esmtk": "^2.5.0",
60
62
  "docdown": "github:evanplaice/docdown",
61
63
  "glob": "^7.2.0"
62
- },
63
- "dependencies": {
64
- "@vanillaes/esmtk": "^1.2.3"
65
64
  }
66
65
  }
@@ -1,13 +1,12 @@
1
1
  /**
2
2
  * Splits the input array up into an subset arrays of equal size
3
- *
4
- * @param {Array} array input array
5
- * @param {number} [size=1] size of each chunk
6
- * @returns {Array} array of chunk arrays
7
- *
3
+ * @template T
4
+ * @param {T[]} array input array
5
+ * @param {number} [size] size of each chunk (default 1)
6
+ * @returns {T[][]} array of chunk arrays
8
7
  * @example
9
8
  * const result = arrays.chunk([1, 2, 3, 4, 5], 2);
10
9
  * console.log(result);
11
10
  * > [[1, 2], [3, 4], [5]]
12
11
  */
13
- export function chunk(array: any[], size?: number): any[];
12
+ export function chunk<T>(array: T[], size?: number): T[][];
@@ -1,16 +1,18 @@
1
1
  /**
2
2
  * Splits the input array up into an subset arrays of equal size
3
- * @param {Array} array input array
3
+ * @template T
4
+ * @param {T[]} array input array
4
5
  * @param {number} [size] size of each chunk (default 1)
5
- * @returns {Array} array of chunk arrays
6
+ * @returns {T[][]} array of chunk arrays
6
7
  * @example
7
8
  * const result = arrays.chunk([1, 2, 3, 4, 5], 2);
8
9
  * console.log(result);
9
10
  * > [[1, 2], [3, 4], [5]]
10
11
  */
11
- function chunk (array, size = 1) {
12
+ export function chunk (array, size = 1) {
13
+ /** @type {T[]} */
12
14
  let chunk = []
13
- return array.reduce((acc, curr, idx, arr) => {
15
+ return array.reduce((/** @type {T[][]} */ acc, curr, idx, arr) => {
14
16
  chunk.push(curr)
15
17
  if (chunk.length === size) {
16
18
  acc.push(chunk)
@@ -22,5 +24,3 @@ function chunk (array, size = 1) {
22
24
  return acc
23
25
  }, [])
24
26
  }
25
-
26
- export { chunk }
@@ -1,12 +1,11 @@
1
1
  /**
2
2
  * Compact removes all falsy values `[false, null, 0, "", undefined, NaN]` from an array.
3
- *
4
- * @param {Array} array input array
5
- * @returns {Array} the input array w/ no falsy values
6
- *
3
+ * @template T
4
+ * @param {T[]} array input array
5
+ * @returns {T[]} the input array w/ no falsy values
7
6
  * @example
8
7
  * const result = arrays.compact([1, false, 2, null, 3, 0, 4, "", 5, undefined, 6, NaN]);
9
8
  * console.log(result);
10
9
  * > [1, 2, 3, 4, 5, 6]
11
10
  */
12
- export function compact(array: any[]): any[];
11
+ export function compact<T>(array: T[]): T[];
@@ -1,17 +1,16 @@
1
1
  /**
2
2
  * Compact removes all falsy values `[false, null, 0, "", undefined, NaN]` from an array.
3
- * @param {Array} array input array
4
- * @returns {Array} the input array w/ no falsy values
3
+ * @template T
4
+ * @param {T[]} array input array
5
+ * @returns {T[]} the input array w/ no falsy values
5
6
  * @example
6
7
  * const result = arrays.compact([1, false, 2, null, 3, 0, 4, "", 5, undefined, 6, NaN]);
7
8
  * console.log(result);
8
9
  * > [1, 2, 3, 4, 5, 6]
9
10
  */
10
- function compact (array) {
11
- return array.reduce((acc, curr) => {
11
+ export function compact (array) {
12
+ return array.reduce((/** @type {T[]} */ acc, curr) => {
12
13
  if (curr) { acc.push(curr) }
13
14
  return acc
14
15
  }, [])
15
16
  }
16
-
17
- export { compact }
@@ -1,13 +1,12 @@
1
1
  /**
2
2
  * Finds the difference of two arrays
3
- *
4
- * @param {Array} arrayA first input array
5
- * @param {Array} arrayB second input array
6
- * @returns {Array} an array containing the difference
7
- *
3
+ * @template T
4
+ * @param {T[]} arrayA first input array
5
+ * @param {T[]} arrayB second input array
6
+ * @returns {T[]} an array containing the difference
8
7
  * @example
9
8
  * const result = arrays.difference([2, 1], [2, 3]);
10
9
  * console.log(result);
11
10
  * > [1]
12
11
  */
13
- export function difference(arrayA: any[], arrayB: any[]): any[];
12
+ export function difference<T>(arrayA: T[], arrayB: T[]): T[];
@@ -1,22 +1,21 @@
1
1
  /**
2
2
  * Finds the difference of two arrays
3
- * @param {Array} arrayA first input array
4
- * @param {Array} arrayB second input array
5
- * @returns {Array} an array containing the difference
3
+ * @template T
4
+ * @param {T[]} arrayA first input array
5
+ * @param {T[]} arrayB second input array
6
+ * @returns {T[]} an array containing the difference
6
7
  * @example
7
8
  * const result = arrays.difference([2, 1], [2, 3]);
8
9
  * console.log(result);
9
10
  * > [1]
10
11
  */
11
- function difference (arrayA, arrayB) {
12
+ export function difference (arrayA, arrayB) {
12
13
  const uniqueValues = new Set(arrayB)
13
14
 
14
- return arrayA.reduce((acc, curr) => {
15
+ return arrayA.reduce((/** @type {T[]} */ acc, curr) => {
15
16
  if (!uniqueValues.has(curr)) {
16
17
  acc.push(curr)
17
18
  }
18
19
  return acc
19
20
  }, [])
20
21
  }
21
-
22
- export { difference }
@@ -1,13 +1,12 @@
1
1
  /**
2
2
  * Remove N items from the beginning of the input array
3
- *
4
- * @param {Array} array input array
5
- * @param {number} [count=1] number of items to drop
6
- * @returns {Array} input array sans the dropped items
7
- *
3
+ * @template T
4
+ * @param {T[]} array input array
5
+ * @param {number} [count] number of items to drop (default 1)
6
+ * @returns {T[]} input array sans the dropped items
8
7
  * @example
9
8
  * const result = arrays.drop([1, 2, 3], 2);
10
9
  * console.log(result);
11
10
  * > [3]
12
11
  */
13
- export function drop(array: any[], count?: number): any[];
12
+ export function drop<T>(array: T[], count?: number): T[];
@@ -1,15 +1,16 @@
1
1
  /**
2
2
  * Remove N items from the beginning of the input array
3
- * @param {Array} array input array
3
+ * @template T
4
+ * @param {T[]} array input array
4
5
  * @param {number} [count] number of items to drop (default 1)
5
- * @returns {Array} input array sans the dropped items
6
+ * @returns {T[]} input array sans the dropped items
6
7
  * @example
7
8
  * const result = arrays.drop([1, 2, 3], 2);
8
9
  * console.log(result);
9
10
  * > [3]
10
11
  */
11
- function drop (array, count = 1) {
12
- return array.reduce((acc, curr) => {
12
+ export function drop (array, count = 1) {
13
+ return array.reduce((/** @type {T[]} */ acc, curr) => {
13
14
  if (count > 0) {
14
15
  count--
15
16
  return acc
@@ -18,5 +19,3 @@ function drop (array, count = 1) {
18
19
  return acc
19
20
  }, [])
20
21
  }
21
-
22
- export { drop }
@@ -1,13 +1,12 @@
1
1
  /**
2
2
  * Remove N items from the end of the input array
3
- *
4
- * @param {Array} array input array
5
- * @param {number} [count=1] number of items to drop
6
- * @returns {Array} input array sans the dropped items
7
- *
3
+ * @template T
4
+ * @param {T[]} array input array
5
+ * @param {number} [count] number of items to drop (default 1)
6
+ * @returns {T[]} input array sans the dropped items
8
7
  * @example
9
8
  * const result = arrays.drop([1, 2, 3], 2);
10
9
  * console.log(result);
11
10
  * > [1]
12
11
  */
13
- export function dropRight(array: any[], count?: number): any[];
12
+ export function dropRight<T>(array: T[], count?: number): T[];
@@ -1,15 +1,16 @@
1
1
  /**
2
2
  * Remove N items from the end of the input array
3
- * @param {Array} array input array
3
+ * @template T
4
+ * @param {T[]} array input array
4
5
  * @param {number} [count] number of items to drop (default 1)
5
- * @returns {Array} input array sans the dropped items
6
+ * @returns {T[]} input array sans the dropped items
6
7
  * @example
7
8
  * const result = arrays.drop([1, 2, 3], 2);
8
9
  * console.log(result);
9
10
  * > [1]
10
11
  */
11
- function dropRight (array, count = 1) {
12
- return array.reduce((acc, _, idx, arr) => {
12
+ export function dropRight (array, count = 1) {
13
+ return array.reduce((/** @type {T[]} */ acc, _, idx, arr) => {
13
14
  if (count > 0) {
14
15
  count--
15
16
  return acc
@@ -18,5 +19,3 @@ function dropRight (array, count = 1) {
18
19
  return acc
19
20
  }, [])
20
21
  }
21
-
22
- export { dropRight }
@@ -1,15 +1,14 @@
1
1
  /**
2
2
  * Fills items in an array with a specified value. Optionally, one can start and/or end from a specific index.
3
- *
4
- * @param {Array} array input array
3
+ * @template T
4
+ * @param {T[]} array input array
5
5
  * @param {*} value value that fills the array
6
- * @param {number} [start=0] start index
7
- * @param {number} [end=array.length] end index
8
- * @returns {Array} input array filled w/ the value
9
- *
6
+ * @param {number} [start] start index (default 0)
7
+ * @param {number} [end] end index (default array.length)
8
+ * @returns {T[]} input array filled w/ the value
10
9
  * @example
11
10
  * const result = arrays.fill([1, 2, 3, 4], 'a', 1, 2);
12
11
  * console.log(result)
13
12
  * > [1, 'a', 'a', 4]
14
13
  */
15
- export function fill(array: any[], value: any, start?: number, end?: number): any[];
14
+ export function fill<T>(array: T[], value: any, start?: number, end?: number): T[];
@@ -2,18 +2,19 @@
2
2
 
3
3
  /**
4
4
  * Fills items in an array with a specified value. Optionally, one can start and/or end from a specific index.
5
- * @param {Array} array input array
5
+ * @template T
6
+ * @param {T[]} array input array
6
7
  * @param {*} value value that fills the array
7
8
  * @param {number} [start] start index (default 0)
8
9
  * @param {number} [end] end index (default array.length)
9
- * @returns {Array} input array filled w/ the value
10
+ * @returns {T[]} input array filled w/ the value
10
11
  * @example
11
12
  * const result = arrays.fill([1, 2, 3, 4], 'a', 1, 2);
12
13
  * console.log(result)
13
14
  * > [1, 'a', 'a', 4]
14
15
  */
15
- function fill (array, value, start = 0, end = array.length - 1) {
16
- return array.reduce((acc, curr, idx) => {
16
+ export function fill (array, value, start = 0, end = array.length - 1) {
17
+ return array.reduce((/** @type {T[]} */ acc, curr, idx) => {
17
18
  if (idx >= start && idx <= end) {
18
19
  acc.push(value)
19
20
  } else {
@@ -22,5 +23,3 @@ function fill (array, value, start = 0, end = array.length - 1) {
22
23
  return acc
23
24
  }, [])
24
25
  }
25
-
26
- export { fill }
@@ -1,13 +1,12 @@
1
1
  /**
2
2
  * Iterates over an array of values and only outputs values where `predicate is equal to true`.
3
- *
4
- * @param {Array} array input array
3
+ * @template T
4
+ * @param {T[]} array input array
5
5
  * @param {Function} predicate predicate function
6
- * @returns {Array} the input array w/ unwanted values removed
7
- *
6
+ * @returns {T[]} the input array w/ unwanted values removed
8
7
  * @example
9
8
  * const result = arrays.filter([1, 2, 3, 4], (x) => x % 2 === 0);
10
9
  * console.log(result)
11
10
  * > [ 2, 4 ]
12
11
  */
13
- export function filter(array: any[], predicate: Function): any[];
12
+ export function filter<T>(array: T[], predicate: Function): T[];
@@ -2,21 +2,20 @@
2
2
 
3
3
  /**
4
4
  * Iterates over an array of values and only outputs values where `predicate is equal to true`.
5
- * @param {Array} array input array
5
+ * @template T
6
+ * @param {T[]} array input array
6
7
  * @param {Function} predicate predicate function
7
- * @returns {Array} the input array w/ unwanted values removed
8
+ * @returns {T[]} the input array w/ unwanted values removed
8
9
  * @example
9
10
  * const result = arrays.filter([1, 2, 3, 4], (x) => x % 2 === 0);
10
11
  * console.log(result)
11
12
  * > [ 2, 4 ]
12
13
  */
13
- function filter (array, predicate) {
14
- return array.reduce((acc, curr) => {
14
+ export function filter (array, predicate) {
15
+ return array.reduce((/** @type {T[]} */ acc, curr) => {
15
16
  if (predicate(curr)) {
16
17
  acc.push(curr)
17
18
  }
18
19
  return acc
19
20
  }, [])
20
21
  }
21
-
22
- export { filter }
@@ -1,12 +1,11 @@
1
1
  /**
2
2
  * Find method returns the value of first element at which a provided function is true,
3
3
  * or undefined if no elements in the array satisfy the function.
4
- *
5
- * @param {Array} array input array
4
+ * @template T
5
+ * @param {T[]} array input array
6
6
  * @param {Function} predicate to be run against each element of the array
7
7
  * @param {*} [thisArg] this argument in the function
8
8
  * @returns {*} value of element that satisfied function.
9
- *
10
9
  * @example
11
10
  * const result = arrays.find([5, 12, 8, 130, 44], (x) => x > 10);
12
11
  * console.log(result);
@@ -16,4 +15,4 @@
16
15
  * console.log(result);
17
16
  * > 5
18
17
  */
19
- export function find(array: any[], predicate: Function, thisArg?: any): any;
18
+ export function find<T>(array: T[], predicate: Function, thisArg?: any): any;
@@ -3,7 +3,8 @@
3
3
  /**
4
4
  * Find method returns the value of first element at which a provided function is true,
5
5
  * or undefined if no elements in the array satisfy the function.
6
- * @param {Array} array input array
6
+ * @template T
7
+ * @param {T[]} array input array
7
8
  * @param {Function} predicate to be run against each element of the array
8
9
  * @param {*} [thisArg] this argument in the function
9
10
  * @returns {*} value of element that satisfied function.
@@ -16,17 +17,17 @@
16
17
  * console.log(result);
17
18
  * > 5
18
19
  */
19
- function find (array, predicate, thisArg) {
20
+ export function find (array, predicate, thisArg) {
20
21
  if (array.length === 0) return undefined
21
22
  if (typeof predicate !== 'function') { throw TypeError('predicate must be a function') }
22
23
  if (predicate.call(thisArg, array[0])) return array[0]
23
24
  if (array.length === 1) return undefined
24
25
 
25
- return array.reduce((res, cur, i) => {
26
+ const result = array.reduce((/** @type {T|undefined} */ res, cur, i) => {
26
27
  if (i === 1) return predicate.call(thisArg, cur) ? cur : undefined
27
28
  if (!res && predicate.call(thisArg, cur)) return cur
28
29
  return res
29
- })
30
- }
30
+ }, undefined)
31
31
 
32
- export { find }
32
+ return result
33
+ }
@@ -1,12 +1,11 @@
1
1
  /**
2
2
  * FindIndex method returns the value of First element at which a provided function is true,
3
3
  * or -1 if no elements in the array satisfy the function.
4
- *
5
- * @param {Array} array input array
4
+ * @template T
5
+ * @param {T[]} array input array
6
6
  * @param {Function} predicate to be run against each element of the array
7
7
  * @param {*} [thisArg] this argument in the function
8
8
  * @returns {*} value of element that satisfied function.
9
- *
10
9
  * @example
11
10
  * const result = arrays.findIndex([5, 12, 8, 130, 44], (x) => x < 10);
12
11
  * console.log(result);
@@ -16,4 +15,4 @@
16
15
  * console.log(result);
17
16
  * > 1
18
17
  */
19
- export function findIndex(array: any[], predicate: Function, thisArg?: any): any;
18
+ export function findIndex<T>(array: T[], predicate: Function, thisArg?: any): any;