csv-sort 6.1.10 → 6.1.12
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.
- package/README.md +13 -16
- package/dist/csv-sort.esm.js +3 -3
- package/dist/csv-sort.umd.js +19 -19
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -1,28 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
<h1 align="center">csv-sort</h1>
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
<p align="center">Sort double-entry bookkeeping CSV from internet banking</p>
|
|
4
4
|
|
|
5
|
-
<
|
|
6
|
-
<a href="https://www.npmjs.com/package/csv-sort" rel="nofollow noreferrer noopener">
|
|
7
|
-
<img src="https://img.shields.io/badge/-npm-blue?style=flat-square" alt="page on npm">
|
|
8
|
-
</a>
|
|
5
|
+
<p align="center">
|
|
9
6
|
<a href="https://codsen.com/os/csv-sort" rel="nofollow noreferrer noopener">
|
|
10
7
|
<img src="https://img.shields.io/badge/-codsen-blue?style=flat-square" alt="page on codsen.com">
|
|
11
8
|
</a>
|
|
9
|
+
<a href="https://www.npmjs.com/package/csv-sort" rel="nofollow noreferrer noopener">
|
|
10
|
+
<img src="https://img.shields.io/badge/-npm-blue?style=flat-square" alt="page on npm">
|
|
11
|
+
</a>
|
|
12
12
|
<a href="https://github.com/codsen/codsen/tree/main/packages/csv-sort" rel="nofollow noreferrer noopener">
|
|
13
13
|
<img src="https://img.shields.io/badge/-github-blue?style=flat-square" alt="page on github">
|
|
14
14
|
</a>
|
|
15
15
|
<a href="https://npmcharts.com/compare/csv-sort?interval=30" rel="nofollow noreferrer noopener" target="_blank">
|
|
16
16
|
<img src="https://img.shields.io/npm/dm/csv-sort.svg?style=flat-square" alt="Downloads per month">
|
|
17
17
|
</a>
|
|
18
|
-
<a href="https://
|
|
19
|
-
<img src="https://img.shields.io/badge/
|
|
20
|
-
</a>
|
|
21
|
-
<img src="https://img.shields.io/badge/licence-MIT-brightgreen.svg?style=flat-square" alt="MIT License">
|
|
22
|
-
<a href="https://liberamanifesto.com" rel="nofollow noreferrer noopener" target="_blank">
|
|
23
|
-
<img src="https://img.shields.io/badge/libera-manifesto-lightgrey.svg?style=flat-square" alt="libera manifesto">
|
|
18
|
+
<a href="https://codsen.com/os/csv-sort/changelog" rel="nofollow noreferrer noopener">
|
|
19
|
+
<img src="https://img.shields.io/badge/changelog-here-brightgreen?style=flat-square" alt="changelog">
|
|
24
20
|
</a>
|
|
25
|
-
|
|
21
|
+
<img src="https://img.shields.io/badge/licence-MIT-brightgreen.svg?style=flat-square" alt="MIT Licence">
|
|
22
|
+
</p>
|
|
26
23
|
|
|
27
24
|
## Install
|
|
28
25
|
|
|
@@ -76,10 +73,10 @@ To report bugs or request features or assistance, [raise an issue](https://githu
|
|
|
76
73
|
|
|
77
74
|
## Licence
|
|
78
75
|
|
|
79
|
-
MIT License
|
|
76
|
+
MIT License.
|
|
80
77
|
|
|
81
|
-
Copyright
|
|
78
|
+
Copyright © 2010-2022 Roy Revelt and other contributors.
|
|
82
79
|
|
|
83
80
|
List of [currency signs](https://github.com/bengourley/currency-symbol-map) - Copyright © 2017 Ben Gourley - see its [BSD-2-Clause disclaimer](https://opensource.org/licenses/BSD-2-Clause)
|
|
84
81
|
|
|
85
|
-
<img src="https://codsen.com/images/png-codsen-ok.png" width="98" alt="ok" align="center"> <img src="https://codsen.com/images/png-codsen-1.png" width="148" alt="codsen" align="center"> <img src="https://codsen.com/images/png-codsen-star-small.png" width="32" alt="star" align="center">
|
|
82
|
+
<p align="center"><img src="https://codsen.com/images/png-codsen-ok.png" width="98" alt="ok" align="center"> <img src="https://codsen.com/images/png-codsen-1.png" width="148" alt="codsen" align="center"> <img src="https://codsen.com/images/png-codsen-star-small.png" width="32" alt="star" align="center"></p>
|
package/dist/csv-sort.esm.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name csv-sort
|
|
3
3
|
* @fileoverview Sort double-entry bookkeeping CSV from internet banking
|
|
4
|
-
* @version 6.1.
|
|
4
|
+
* @version 6.1.12
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/csv-sort/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import B from"lodash.pull";import{splitEasy as O}from"csv-split-easy";import R from"currency.js";function E(i){return typeof i=="number"&&!isNaN(i)?!0:(i=(i||"").toString().trim(),i?!isNaN(+i):!1)}var N=["\u062F.\u0625","\u060B","L","\u058F","\u0192","Kz","$","\u0192","\u20BC","KM","\u09F3","\u043B\u0432",".\u062F.\u0628","FBu","$b","R$","\u0E3F","Nu.","P","p.","BZ$","FC","CHF","\xA5","\u20A1","\u20B1","K\u010D","Fdj","kr","RD$","\u062F\u062C","kr","Nfk","Br","\u039E","\u20AC","\u20BE","\u20B5","GH\u20B5","D","FG","Q","L","kn","G","Ft","Rp","\u20AA","\u20B9","\u0639.\u062F","\uFDFC","kr","J$","JD","\xA5","KSh","\u043B\u0432","\u17DB","CF","\u20A9","\u20A9","KD","\u043B\u0432","\u20AD","\u20A8","M","\u0141","Lt","Ls","LD","MAD","lei","Ar","\u0434\u0435\u043D","K","\u20AE","MOP$","UM","\u20A8","Rf","MK","RM","MT","\u20A6","C$","kr","\u20A8","\uFDFC","B/.","S/.","K","\u20B1","\u20A8","z\u0142","Gs","\uFDFC","\uFFE5","lei","\u0414\u0438\u043D.","\u20BD","R\u20A3","\uFDFC","\u20A8","\u062C.\u0633.","kr","\xA3","Le","S","Db","E","\u0E3F","SM","T","\u062F.\u062A","T$","\u20A4","\u20BA","TT$","NT$","TSh","\u20B4","USh","$U","\u043B\u0432","Bs","\u20AB","VT","WS$","FCFA","\u0243","CFA","\u20A3","\uFDFC","R","Z$"];function f(i){return E(i)||N.some(b=>E(i.replace(b,"").replace(/[,.]/g,"")))?"numeric":i.trim()?"text":"empty"}var T="6.1.
|
|
11
|
-
${JSON.stringify(i,null,4)}`);if(!i.trim())return{res:[[""]],msgContent:b,msgType:C};let n=O(i),s=[],d=!1,S=!0,
|
|
10
|
+
import B from"lodash.pull";import{splitEasy as O}from"csv-split-easy";import R from"currency.js";function E(i){return typeof i=="number"&&!isNaN(i)?!0:(i=(i||"").toString().trim(),i?!isNaN(+i):!1)}var N=["\u062F.\u0625","\u060B","L","\u058F","\u0192","Kz","$","\u0192","\u20BC","KM","\u09F3","\u043B\u0432",".\u062F.\u0628","FBu","$b","R$","\u0E3F","Nu.","P","p.","BZ$","FC","CHF","\xA5","\u20A1","\u20B1","K\u010D","Fdj","kr","RD$","\u062F\u062C","kr","Nfk","Br","\u039E","\u20AC","\u20BE","\u20B5","GH\u20B5","D","FG","Q","L","kn","G","Ft","Rp","\u20AA","\u20B9","\u0639.\u062F","\uFDFC","kr","J$","JD","\xA5","KSh","\u043B\u0432","\u17DB","CF","\u20A9","\u20A9","KD","\u043B\u0432","\u20AD","\u20A8","M","\u0141","Lt","Ls","LD","MAD","lei","Ar","\u0434\u0435\u043D","K","\u20AE","MOP$","UM","\u20A8","Rf","MK","RM","MT","\u20A6","C$","kr","\u20A8","\uFDFC","B/.","S/.","K","\u20B1","\u20A8","z\u0142","Gs","\uFDFC","\uFFE5","lei","\u0414\u0438\u043D.","\u20BD","R\u20A3","\uFDFC","\u20A8","\u062C.\u0633.","kr","\xA3","Le","S","Db","E","\u0E3F","SM","T","\u062F.\u062A","T$","\u20A4","\u20BA","TT$","NT$","TSh","\u20B4","USh","$U","\u043B\u0432","Bs","\u20AB","VT","WS$","FCFA","\u0243","CFA","\u20A3","\uFDFC","R","Z$"];function f(i){return E(i)||N.some(b=>E(i.replace(b,"").replace(/[,.]/g,"")))?"numeric":i.trim()?"text":"empty"}var T="6.1.12";var K=T;function _(i){let b=null,C=null;if(typeof i!="string")throw new TypeError(`csv-sort/csvSort(): [THROW_ID_01] The input is of a wrong type! We accept either string of array of arrays. We got instead: ${typeof i}, equal to:
|
|
11
|
+
${JSON.stringify(i,null,4)}`);if(!i.trim())return{res:[[""]],msgContent:b,msgType:C};let n=O(i),s=[],d=!1,S=!0,x=[],r=null;for(let t=n.length-1;t>=0;t--)if(s.length){t===0&&(d=n[t].every(l=>f(l)==="text"||f(l)==="empty")),!d&&s.length!==n[t].length&&(S=!1);let e=null;for(let l=0,p=n[t].length;l<p;l++)if(e===null&&f(n[t][l].trim())==="empty"&&(e=l),e!==null&&f(n[t][l].trim())!=="empty"&&(e=null),f(n[t][l].trim())!==s[l]&&!d){let a=f(n[t][l].trim());if(Array.isArray(s[l]))s[l].includes(a)||s[l].push(f(n[t][l].trim()));else if(s[l]!==a){let u=s[l];s[l]=[],s[l].push(u),s[l].push(a)}}r!==null&&e!==null&&e>r&&(!d||d&&t!==0)&&(r=e)}else if(n[t].length!==1||n[t][0]!=="")for(let e=0,l=n[t].length;e<l;e++)s.push(f(n[t][e].trim())),r===null&&f(n[t][e].trim())==="empty"&&(r=e),r!==null&&f(n[t][e].trim())!=="empty"&&(r=null);r||(r=s.length);let w=0;for(let t=0,e=s.length;t<e&&s[t]==="empty";t++)w=t;w!==0&&(n=n.map(t=>t.slice(w+1,r)),s=s.slice(w+1,r));let V=[],m;s.forEach((t,e)=>{t==="numeric"&&V.push(e)});let k=d?1:0;if(V.length===1)m=V[0];else{if(V.length===0)throw new Error('csv-sort/csvSort(): [THROW_ID_03] Your CSV file does not contain numeric-only columns and computer was not able to detect the "Balance" column!');{let t=Array.from(V),e=[];for(let l=0,p=t.length;l<p;l++){let a=t[l],u,g=!0,y,h=!0;for(let c=k,I=n.length;c<I&&(g&&(u==null?u=n[c][a]:u===n[c][a]?(e.push(a),g=!1):u=n[c][a]),h&&(y==null?y=n[c][a]:n[c][a]!==y&&(h=!1)),!!g);c++);h&&x.push(a)}if(t=B(t,...e),t.length===1)m=t[0];else if(t.length===0)throw new Error(`csv-sort/csvSort(): [THROW_ID_04] The computer can't find the "Balance" column! It saw some numeric-only columns, but they all seem to have certain rows with the same values as rows right below/above them!`)}}if(!m)throw new Error("csv-sort/csvSort(): [THROW_ID_05] Sadly computer couldn't find its way in this CSV and had to stop working on it.");let D=B(Array.from(s.reduce((t,e,l)=>((typeof e=="string"&&e==="numeric"||Array.isArray(e)&&e.includes("numeric"))&&t.push(l),t),[])),m,...x),o=[];o.push(n[n.length-1].slice(0,r));let $=[],v=d?1:0;for(let t=n.length-2;t>=v;t--)for(let e=n.length-2;e>=v;e--)if(!$.includes(e)){let l=!1;for(let p=0,a=D.length;p<a;p++){let u=null;n[e][D[p]]!==""&&(u=R(n[e][D[p]]));let g=null;n[e][m]!==""&&(g=R(n[e][m]));let y=null;o[0][m]!==""&&(y=R(o[0][m]).format());let h=null;o[o.length-1][D[p]]!==""&&(h=R(o[o.length-1][D[p]]).format());let c=null;if(o[o.length-1][m]!==""&&(c=R(o[o.length-1][m])),u&&g.add(u).format()===y){o.unshift(n[e].slice(0,r)),$.push(e),l=!0;break}else if(u&&g.subtract(u).format()===y){o.unshift(n[e].slice(0,r)),$.push(e),l=!0;break}else if(h&&c.add(h).format()===g.format()){o.push(n[e].slice(0,r)),$.push(e),l=!0;break}else if(h&&c.subtract(h).format()===g.format()){o.push(n[e].slice(0,r)),$.push(e),l=!0;break}}if(l){l=!1;break}}return d&&(S&&n[0].length>s.length&&(n[0].length=s.length),o.unshift(n[0].slice(0,r))),n.length-(d?2:1)!==$.length&&(b="Not all rows were recognised!",C="alert"),{res:o,msgContent:b,msgType:C}}export{f as findType,E as isNumeric,_ as sort,K as version};
|
package/dist/csv-sort.umd.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name csv-sort
|
|
3
3
|
* @fileoverview Sort double-entry bookkeeping CSV from internet banking
|
|
4
|
-
* @version 6.1.
|
|
4
|
+
* @version 6.1.12
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/csv-sort/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
"use strict";var csvSort=(()=>{var xe=Object.create;var x=Object.defineProperty;var Ve=Object.getOwnPropertyDescriptor;var Ce=Object.getOwnPropertyNames,z=Object.getOwnPropertySymbols,Fe=Object.getPrototypeOf,Y=Object.prototype.hasOwnProperty,_e=Object.prototype.propertyIsEnumerable;var W=(e,
|
|
11
|
-
${JSON.stringify(
|
|
10
|
+
"use strict";var csvSort=(()=>{var xe=Object.create;var x=Object.defineProperty;var Ve=Object.getOwnPropertyDescriptor;var Ce=Object.getOwnPropertyNames,z=Object.getOwnPropertySymbols,Fe=Object.getPrototypeOf,Y=Object.prototype.hasOwnProperty,_e=Object.prototype.propertyIsEnumerable;var W=(e,t,s)=>t in e?x(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,b=(e,t)=>{for(var s in t||(t={}))Y.call(t,s)&&W(e,s,t[s]);if(z)for(var s of z(t))_e.call(t,s)&&W(e,s,t[s]);return e};var J=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),je=(e,t)=>{for(var s in t)x(e,s,{get:t[s],enumerable:!0})},Z=(e,t,s,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Ce(t))!Y.call(e,a)&&a!==s&&x(e,a,{get:()=>t[a],enumerable:!(n=Ve(t,a))||n.enumerable});return e};var k=(e,t,s)=>(s=e!=null?xe(Fe(e)):{},Z(t||!e||!e.__esModule?x(s,"default",{value:e,enumerable:!0}):s,e)),We=e=>Z(x({},"__esModule",{value:!0}),e);var H=(e,t,s)=>(W(e,typeof t!="symbol"?t+"":t,s),s);var re=J((Jr,ee)=>{function Je(e,t,s){switch(s.length){case 0:return e.call(t);case 1:return e.call(t,s[0]);case 2:return e.call(t,s[0],s[1]);case 3:return e.call(t,s[0],s[1],s[2])}return e.apply(t,s)}function ke(e,t){for(var s=-1,n=e?e.length:0,a=Array(n);++s<n;)a[s]=t(e[s],s,e);return a}function He(e,t,s,n){for(var a=e.length,r=s+(n?1:-1);n?r--:++r<a;)if(t(e[r],r,e))return r;return-1}function Me(e,t,s){if(t!==t)return He(e,qe,s);for(var n=s-1,a=e.length;++n<a;)if(e[n]===t)return n;return-1}function Be(e,t,s,n){for(var a=s-1,r=e.length;++a<r;)if(n(e[a],t))return a;return-1}function qe(e){return e!==e}function Pe(e){return function(t){return e(t)}}var Ue=Array.prototype,Q=Ue.splice,X=Math.max;function Ke(e,t,s,n){var a=n?Be:Me,r=-1,i=t.length,u=e;for(e===t&&(t=Ge(t)),s&&(u=ke(e,Pe(s)));++r<i;)for(var l=0,o=t[r],f=s?s(o):o;(l=a(u,f,l,n))>-1;)u!==e&&Q.call(u,l,1),Q.call(e,l,1);return e}function Le(e,t){return t=X(t===void 0?e.length-1:t,0),function(){for(var s=arguments,n=-1,a=X(s.length-t,0),r=Array(a);++n<a;)r[n]=s[t+n];n=-1;for(var i=Array(t+1);++n<t;)i[n]=s[n];return i[t]=r,Je(e,this,i)}}function Ge(e,t){var s=-1,n=e.length;for(t||(t=Array(n));++s<n;)t[s]=e[s];return t}var ze=Le(Ye);function Ye(e,t){return e&&e.length&&t&&t.length?Ke(e,t):e}ee.exports=ze});var Oe=J((Xr,Re)=>{var tr=1/0,nr="[object Symbol]",sr=/^\s+|\s+$/g,U="\\ud800-\\udfff",pe="\\u0300-\\u036f\\ufe20-\\ufe23",he="\\u20d0-\\u20f0",me="\\ufe0e\\ufe0f",or="["+U+"]",q="["+pe+he+"]",P="\\ud83c[\\udffb-\\udfff]",ir="(?:"+q+"|"+P+")",ye="[^"+U+"]",de="(?:\\ud83c[\\udde6-\\uddff]){2}",be="[\\ud800-\\udbff][\\udc00-\\udfff]",$e="\\u200d",Te=ir+"?",we="["+me+"]?",lr="(?:"+$e+"(?:"+[ye,de,be].join("|")+")"+we+Te+")*",ar=we+Te+lr,ur="(?:"+[ye+q+"?",q,de,be,or].join("|")+")",fr=RegExp(P+"(?="+P+")|"+ur+ar,"g"),gr=RegExp("["+$e+U+pe+he+me+"]"),cr=typeof global=="object"&&global&&global.Object===Object&&global,pr=typeof self=="object"&&self&&self.Object===Object&&self,hr=cr||pr||Function("return this")();function mr(e){return e.split("")}function yr(e,t,s,n){for(var a=e.length,r=s+(n?1:-1);n?r--:++r<a;)if(t(e[r],r,e))return r;return-1}function ve(e,t,s){if(t!==t)return yr(e,dr,s);for(var n=s-1,a=e.length;++n<a;)if(e[n]===t)return n;return-1}function dr(e){return e!==e}function br(e,t){for(var s=-1,n=e.length;++s<n&&ve(t,e[s],0)>-1;);return s}function $r(e,t){for(var s=e.length;s--&&ve(t,e[s],0)>-1;);return s}function Tr(e){return gr.test(e)}function ue(e){return Tr(e)?wr(e):mr(e)}function wr(e){return e.match(fr)||[]}var vr=Object.prototype,Sr=vr.toString,fe=hr.Symbol,ge=fe?fe.prototype:void 0,ce=ge?ge.toString:void 0;function Rr(e,t,s){var n=-1,a=e.length;t<0&&(t=-t>a?0:a+t),s=s>a?a:s,s<0&&(s+=a),a=t>s?0:s-t>>>0,t>>>=0;for(var r=Array(a);++n<a;)r[n]=e[n+t];return r}function Se(e){if(typeof e=="string")return e;if(Nr(e))return ce?ce.call(e):"";var t=e+"";return t=="0"&&1/e==-tr?"-0":t}function Or(e,t,s){var n=e.length;return s=s===void 0?n:s,!t&&s>=n?e:Rr(e,t,s)}function Er(e){return!!e&&typeof e=="object"}function Nr(e){return typeof e=="symbol"||Er(e)&&Sr.call(e)==nr}function Dr(e){return e==null?"":Se(e)}function Ir(e,t,s){if(e=Dr(e),e&&(s||t===void 0))return e.replace(sr,"");if(!e||!(t=Se(t)))return e;var n=ue(e),a=ue(t),r=br(n,a),i=$r(n,a)+1;return Or(n,r,i).join("")}Re.exports=Ir});var De=J((K,L)=>{(function(e,t){typeof K=="object"&&typeof L<"u"?L.exports=t():typeof define=="function"&&define.amd?define(t):(e=e||self,e.currency=t())})(K,function(){function e(r,i){if(!(this instanceof e))return new e(r,i);i=Object.assign({},s,i);var u=Math.pow(10,i.precision);this.intValue=r=t(r,i),this.value=r/u,i.increment=i.increment||1/u,i.groups=i.useVedic?a:n,this.s=i,this.p=u}function t(r,i){var u=2<arguments.length&&arguments[2]!==void 0?arguments[2]:!0,l=i.decimal,o=i.errorOnInvalid,f=i.fromCents,g=Math.pow(10,i.precision),y=r instanceof e;if(y&&f)return r.intValue;if(typeof r=="number"||y)l=y?r.value:r;else if(typeof r=="string")o=new RegExp("[^-\\d"+l+"]","g"),l=new RegExp("\\"+l,"g"),l=(l=r.replace(/\((.*)\)/,"-$1").replace(o,"").replace(l,"."))||0;else{if(o)throw Error("Invalid Input");l=0}return f||(l=(l*g).toFixed(4)),u?Math.round(l):l}var s={symbol:"$",separator:",",decimal:".",errorOnInvalid:!1,precision:2,pattern:"!#",negativePattern:"-!#",format:function(r,i){var u=i.pattern,l=i.negativePattern,o=i.symbol,f=i.separator,g=i.decimal;i=i.groups;var y=(""+r).replace(/^-/,"").split("."),m=y[0];return y=y[1],(0<=r.value?u:l).replace("!",o).replace("#",m.replace(i,"$1"+f)+(y?g+y:""))},fromCents:!1},n=/(\d)(?=(\d{3})+\b)/g,a=/(\d)(?=(\d\d)+\d\b)/g;return e.prototype={add:function(r){var i=this.s,u=this.p;return e((this.intValue+t(r,i))/(i.fromCents?1:u),i)},subtract:function(r){var i=this.s,u=this.p;return e((this.intValue-t(r,i))/(i.fromCents?1:u),i)},multiply:function(r){var i=this.s;return e(this.intValue*r/(i.fromCents?1:Math.pow(10,i.precision)),i)},divide:function(r){var i=this.s;return e(this.intValue/t(r,i,!1),i)},distribute:function(r){var i=this.intValue,u=this.p,l=this.s,o=[],f=Math[0<=i?"floor":"ceil"](i/r),g=Math.abs(i-f*r);for(u=l.fromCents?1:u;r!==0;r--){var y=e(f/u,l);0<g--&&(y=y[0<=i?"add":"subtract"](1/u)),o.push(y)}return o},dollars:function(){return~~this.value},cents:function(){return~~(this.intValue%this.p)},format:function(r){var i=this.s;return typeof r=="function"?r(this,i):i.format(this,Object.assign({},i,r))},toString:function(){var r=this.s,i=r.increment;return(Math.round(this.intValue/this.p/i)*i).toFixed(r.precision)},toJSON:function(){return this.value}},e})});var jr={};je(jr,{findType:()=>w,isNumeric:()=>j,sort:()=>_r,version:()=>Fr});var G=k(re(),1);var Ze={strictlyTwoElementsInRangeArrays:!1,progressFn:null};function M(e,t){if(!Array.isArray(e)||!e.length)return e;let s=b(b({},Ze),t),n,a;if(s.strictlyTwoElementsInRangeArrays&&!e.every((u,l)=>!Array.isArray(u)||u.length!==2?(n=l,a=u.length,!1):!0))throw new TypeError(`ranges-sort: [THROW_ID_03] The first argument should be an array and must consist of arrays which are natural number indexes representing TWO string index ranges. However, ${n}th range (${JSON.stringify(e[n],null,4)}) has not two but ${a} elements!`);if(!e.every((u,l)=>!Array.isArray(u)||!Number.isInteger(u[0])||u[0]<0||!Number.isInteger(u[1])||u[1]<0?(n=l,!1):!0))throw new TypeError(`ranges-sort: [THROW_ID_04] The first argument should be an array and must consist of arrays which are natural number indexes representing string index ranges. However, ${n}th range (${JSON.stringify(e[n],null,4)}) does not consist of only natural numbers!`);let r=e.length**2,i=0;return Array.from(e).sort((u,l)=>(s.progressFn&&(i+=1,s.progressFn(Math.floor(i*100/r))),u[0]===l[0]?u[1]<l[1]?-1:u[1]>l[1]?1:0:u[0]<l[0]?-1:1))}var te={mergeType:1,progressFn:null,joinRangesThatTouchEdges:!0};function ne(e,t){function s(o){return!!o&&typeof o=="object"&&!Array.isArray(o)}if(!Array.isArray(e)||!e.length)return null;let n;if(t)if(s(t)){if(n=b(b({},te),t),n.progressFn&&s(n.progressFn)&&!Object.keys(n.progressFn).length)n.progressFn=null;else if(n.progressFn&&typeof n.progressFn!="function")throw new Error(`ranges-merge: [THROW_ID_01] opts.progressFn must be a function! It was given of a type: "${typeof n.progressFn}", equal to ${JSON.stringify(n.progressFn,null,4)}`);if(![1,2,"1","2"].includes(n.mergeType))throw new Error(`ranges-merge: [THROW_ID_02] opts.mergeType was customised to a wrong thing! It was given of a type: "${typeof n.mergeType}", equal to ${JSON.stringify(n.mergeType,null,4)}`);if(typeof n.joinRangesThatTouchEdges!="boolean")throw new Error(`ranges-merge: [THROW_ID_04] opts.joinRangesThatTouchEdges was customised to a wrong thing! It was given of a type: "${typeof n.joinRangesThatTouchEdges}", equal to ${JSON.stringify(n.joinRangesThatTouchEdges,null,4)}`)}else throw new Error(`emlint: [THROW_ID_03] the second input argument must be a plain object. It was given as:
|
|
11
|
+
${JSON.stringify(t,null,4)} (type ${typeof t})`);else n=b({},te);let a=e.filter(o=>Array.isArray(o)).map(o=>[...o]).filter(o=>o[2]!==void 0||o[0]!==o[1]),r,i,u;n.progressFn?r=M(a,{progressFn:o=>{u=Math.floor(o/5),u!==i&&(i=u,n.progressFn(u))}}):r=M(a);let l=r.length-1;for(let o=l;o>0;o--)n.progressFn&&(u=Math.floor((1-o/l)*78)+21,u!==i&&u>i&&(i=u,n.progressFn(u))),(r[o][0]<=r[o-1][0]||!n.joinRangesThatTouchEdges&&r[o][0]<r[o-1][1]||n.joinRangesThatTouchEdges&&r[o][0]<=r[o-1][1])&&(r[o-1][0]=Math.min(r[o][0],r[o-1][0]),r[o-1][1]=Math.max(r[o][1],r[o-1][1]),r[o][2]!==void 0&&(r[o-1][0]>=r[o][0]||r[o-1][1]<=r[o][1])&&r[o-1][2]!==null&&(r[o][2]===null&&r[o-1][2]!==null?r[o-1][2]=null:r[o-1][2]!=null?+n.mergeType==2&&r[o-1][0]===r[o][0]?r[o-1][2]=r[o][2]:r[o-1][2]+=r[o][2]:r[o-1][2]=r[o][2]),r.splice(o,1),o=r.length);return r.length?r:null}var Qe=!0,B="Invariant failed";function se(e,t){if(!e){if(Qe)throw new Error(B);var s=typeof t=="function"?t():t,n=s?"".concat(B,": ").concat(s):B;throw new Error(n)}}function oe(e,t,s){let n=0,a=0;if(arguments.length===0)throw new Error("ranges-apply: [THROW_ID_01] inputs missing!");if(typeof e!="string")throw new TypeError(`ranges-apply: [THROW_ID_02] first input argument must be a string! Currently it's: ${typeof e}, equal to: ${JSON.stringify(e,null,4)}`);if(t&&!Array.isArray(t))throw new TypeError(`ranges-apply: [THROW_ID_03] second input argument must be an array (or null)! Currently it's: ${typeof t}, equal to: ${JSON.stringify(t,null,4)}`);if(s&&typeof s!="function")throw new TypeError(`ranges-apply: [THROW_ID_04] the third input argument must be a function (or falsey)! Currently it's: ${typeof s}, equal to: ${JSON.stringify(s,null,4)}`);if(!t||!t.filter(f=>f).length)return e;let r;Array.isArray(t)&&Number.isInteger(t[0])&&Number.isInteger(t[1])?r=[Array.from(t)]:r=Array.from(t);let i=r.length,u=0;r.filter(f=>f).forEach((f,g)=>{if(s&&(n=Math.floor(u/i*10),n!==a&&(a=n,s(n))),!Array.isArray(f))throw new TypeError(`ranges-apply: [THROW_ID_05] ranges array, second input arg., has ${g}th element not an array: ${JSON.stringify(f,null,4)}, which is ${typeof f}`);if(!Number.isInteger(f[0])){if(!Number.isInteger(+f[0])||+f[0]<0)throw new TypeError(`ranges-apply: [THROW_ID_06] ranges array, second input arg. has ${g}th element, array ${JSON.stringify(f,null,0)}. Its first element is not an integer, string index, but ${typeof f[0]}, equal to: ${JSON.stringify(f[0],null,4)}.`);r[g][0]=+r[g][0]}if(!Number.isInteger(f[1])){if(!Number.isInteger(+f[1])||+f[1]<0)throw new TypeError(`ranges-apply: [THROW_ID_07] ranges array, second input arg. has ${g}th element, array ${JSON.stringify(f,null,0)}. Its second element is not an integer, string index, but ${typeof f[1]}, equal to: ${JSON.stringify(f[1],null,4)}.`);r[g][1]=+r[g][1]}u+=1});let l=ne(r,{progressFn:f=>{s&&(n=10+Math.floor(f/10),n!==a&&(a=n,s(n)))}});se(l);let o=l.length;if(o>0){let f=e.slice(l[o-1][1]);e=l.reduce((g,y,m,d)=>{s&&(n=20+Math.floor(m/o*80),n!==a&&(a=n,s(n)));let E=m===0?0:d[m-1][1],F=d[m][0];return`${g}${e.slice(E,F)}${d[m][2]||""}`},""),e+=f}return e}function _(e,t=1){let s="\xA0";function n(r){return Array.from(r).reverse().join("")}function a(r,i,u){let l=u?`
|
|
12
12
|
`:"\r",o=u?"\r":`
|
|
13
|
-
`;if(!
|
|
14
|
-
`.includes(
|
|
15
|
-
${JSON.stringify(
|
|
16
|
-
${JSON.stringify(s,null,4)}`);if(N(this.ranges)&&Array.isArray(this.last())&&n===this.last()[1]){if(this.last()[1]=a,this.last()[2],this.last()[2]!==null&&N(s)){let i=this.last()[2]&&this.last()[2].length&&(!((
|
|
17
|
-
${JSON.stringify(e,null,4)}`);if(
|
|
18
|
-
${JSON.stringify(
|
|
19
|
-
${JSON.stringify(
|
|
20
|
-
`||e[o]==="\r"){if(!n){if(n=o,!i&&e[o-1]!=='"'){let g=e.slice(s,o);g.trim()!==""&&(u=!1),a.push(C(g,{removeThousandSeparatorsFromNumbers:l.removeThousandSeparatorsFromNumbers,padSingleDecimalPlaceNumbers:l.padSingleDecimalPlaceNumbers,forceUKStyle:l.forceUKStyle}))}u?a.length=0:
|
|
21
|
-
${JSON.stringify(e,null,4)}`);if(!e.trim())return{res:[[""]],msgContent:
|
|
13
|
+
`;if(!r)return r;let f=0,g=0,y="";for(let m=0,d=r.length;m<d;m++)(r[m]===l||r[m]===o&&r[m-1]!==l)&&g++,`\r
|
|
14
|
+
`.includes(r[m])||r[m]===s?(f=0,r[m]===s?y+=r[m]:r[m]===l?g<=i&&(y+=r[m],r[m+1]===o&&(y+=r[m+1],m++)):r[m]===o&&(r==null?void 0:r[m-1])!==l&&g<=i&&(y+=r[m])):(f++,!r[m+1]&&!g&&(y+=" "));return y}if(typeof e=="string"&&e.length){let r=1;typeof+t=="number"&&Number.isInteger(+t)&&+t>=0&&(r=+t);let i="",u="";if(!e.trim())i=e;else if(!e[0].trim()){for(let l=0,o=e.length;l<o;l++)if(e[l].trim()){i=e.slice(0,l);break}}if(e.trim()&&(e.slice(-1).trim()===""||e.slice(-1)===s)){for(let l=e.length;l--;)if(e[l].trim()){u=e.slice(l+1);break}}return`${a(i,r,!1)}${e.trim()}${n(a(n(u),r,!0))}`}return e}var Xe={strictlyTwoElementsInRangeArrays:!1,progressFn:null};function ie(e,t){if(!Array.isArray(e)||!e.length)return e;let s=b(b({},Xe),t),n,a;if(s.strictlyTwoElementsInRangeArrays&&!e.every((u,l)=>!Array.isArray(u)||u.length!==2?(n=l,a=u.length,!1):!0))throw new TypeError(`ranges-sort: [THROW_ID_03] The first argument should be an array and must consist of arrays which are natural number indexes representing TWO string index ranges. However, ${n}th range (${JSON.stringify(e[n],null,4)}) has not two but ${a} elements!`);if(!e.every((u,l)=>!Array.isArray(u)||!Number.isInteger(u[0])||u[0]<0||!Number.isInteger(u[1])||u[1]<0?(n=l,!1):!0))throw new TypeError(`ranges-sort: [THROW_ID_04] The first argument should be an array and must consist of arrays which are natural number indexes representing string index ranges. However, ${n}th range (${JSON.stringify(e[n],null,4)}) does not consist of only natural numbers!`);let r=e.length**2,i=0;return Array.from(e).sort((u,l)=>(s.progressFn&&(i+=1,s.progressFn(Math.floor(i*100/r))),u[0]===l[0]?u[1]<l[1]?-1:u[1]>l[1]?1:0:u[0]<l[0]?-1:1))}var le={mergeType:1,progressFn:null,joinRangesThatTouchEdges:!0};function er(e,t){function s(o){return!!o&&typeof o=="object"&&!Array.isArray(o)}if(!Array.isArray(e)||!e.length)return null;let n;if(t)if(s(t)){if(n=b(b({},le),t),n.progressFn&&s(n.progressFn)&&!Object.keys(n.progressFn).length)n.progressFn=null;else if(n.progressFn&&typeof n.progressFn!="function")throw new Error(`ranges-merge: [THROW_ID_01] resolvedOpts.progressFn must be a function! It was given of a type: "${typeof n.progressFn}", equal to ${JSON.stringify(n.progressFn,null,4)}`);if(![1,2,"1","2"].includes(n.mergeType))throw new Error(`ranges-merge: [THROW_ID_02] resolvedOpts.mergeType was customised to a wrong thing! It was given of a type: "${typeof n.mergeType}", equal to ${JSON.stringify(n.mergeType,null,4)}`);if(typeof n.joinRangesThatTouchEdges!="boolean")throw new Error(`ranges-merge: [THROW_ID_04] resolvedOpts.joinRangesThatTouchEdges was customised to a wrong thing! It was given of a type: "${typeof n.joinRangesThatTouchEdges}", equal to ${JSON.stringify(n.joinRangesThatTouchEdges,null,4)}`)}else throw new Error(`emlint: [THROW_ID_03] the second input argument must be a plain object. It was given as:
|
|
15
|
+
${JSON.stringify(t,null,4)} (type ${typeof t})`);else n=b({},le);let a=e.filter(o=>Array.isArray(o)).map(o=>[...o]).filter(o=>o[2]!==void 0||o[0]!==o[1]),r,i,u;n.progressFn?r=ie(a,{progressFn:o=>{u=Math.floor(o/5),u!==i&&(i=u,n.progressFn(u))}}):r=ie(a);let l=r.length-1;for(let o=l;o>0;o--)n.progressFn&&(u=Math.floor((1-o/l)*78)+21,u!==i&&u>i&&(i=u,n.progressFn(u))),(r[o][0]<=r[o-1][0]||!n.joinRangesThatTouchEdges&&r[o][0]<r[o-1][1]||n.joinRangesThatTouchEdges&&r[o][0]<=r[o-1][1])&&(r[o-1][0]=Math.min(r[o][0],r[o-1][0]),r[o-1][1]=Math.max(r[o][1],r[o-1][1]),r[o][2]!==void 0&&(r[o-1][0]>=r[o][0]||r[o-1][1]<=r[o][1])&&r[o-1][2]!==null&&(r[o][2]===null&&r[o-1][2]!==null?r[o-1][2]=null:r[o-1][2]!=null?+n.mergeType==2&&r[o-1][0]===r[o][0]?r[o-1][2]=r[o][2]:r[o-1][2]+=r[o][2]:r[o-1][2]=r[o][2]),r.splice(o,1),o=r.length);return r.length?r:null}function N(e){return e!=null}function D(e){return Number.isInteger(e)&&e>=0}function V(e){return typeof e=="string"}var rr={limitToBeAddedWhitespace:!1,limitLinebreaksCount:1,mergeType:1},ae=class{constructor(e){H(this,"ranges");H(this,"opts");let t=b(b({},rr),e);if(t.mergeType&&t.mergeType!==1&&t.mergeType!==2)if(V(t.mergeType)&&t.mergeType.trim()==="1")t.mergeType=1;else if(V(t.mergeType)&&t.mergeType.trim()==="2")t.mergeType=2;else throw new Error(`ranges-push: [THROW_ID_02] opts.mergeType was customised to a wrong thing! It was given of a type: "${typeof t.mergeType}", equal to ${JSON.stringify(t.mergeType,null,4)}`);this.opts=t,this.ranges=[]}add(e,t,s){var r;if(e==null&&t==null)return;if(N(e)&&!N(t)){if(Array.isArray(e)){if(e.length){if(e.some(i=>Array.isArray(i))){e.forEach(i=>{Array.isArray(i)&&this.add(...i)});return}e.length&&D(+e[0])&&D(+e[1])&&this.add(...e)}return}throw new TypeError(`ranges-push/Ranges/add(): [THROW_ID_12] the first input argument, "from" is set (${JSON.stringify(e,null,0)}) but second-one, "to" is not (${JSON.stringify(t,null,0)})`)}else if(!N(e)&&N(t))throw new TypeError(`ranges-push/Ranges/add(): [THROW_ID_13] the second input argument, "to" is set (${JSON.stringify(t,null,0)}) but first-one, "from" is not (${JSON.stringify(e,null,0)})`);let n=+e,a=+t;if(D(s)&&(s=String(s)),D(n)&&D(a)){if(N(s)&&!V(s)&&!D(s))throw new TypeError(`ranges-push/Ranges/add(): [THROW_ID_08] The third argument, the value to add, was given not as string but ${typeof s}, equal to:
|
|
16
|
+
${JSON.stringify(s,null,4)}`);if(N(this.ranges)&&Array.isArray(this.last())&&n===this.last()[1]){if(this.last()[1]=a,this.last()[2],this.last()[2]!==null&&N(s)){let i=this.last()[2]&&this.last()[2].length&&(!((r=this.opts)!=null&&r.mergeType)||this.opts.mergeType===1)?`${this.last()[2]}${s}`:s;this.opts.limitToBeAddedWhitespace&&(i=_(i,this.opts.limitLinebreaksCount)),V(i)&&!i.length||(this.last()[2]=i)}}else{this.ranges||(this.ranges=[]);let i=s!==void 0&&!(V(s)&&!s.length)?[n,a,s&&this.opts.limitToBeAddedWhitespace?_(s,this.opts.limitLinebreaksCount):s]:[n,a];this.ranges.push(i)}}else throw D(n)&&n>=0?new TypeError(`ranges-push/Ranges/add(): [THROW_ID_10] "to" value, the second input argument, must be a natural number or zero! Currently it's of a type "${typeof a}" equal to: ${JSON.stringify(a,null,4)}`):new TypeError(`ranges-push/Ranges/add(): [THROW_ID_09] "from" value, the first input argument, must be a natural number or zero! Currently it's of a type "${typeof n}" equal to: ${JSON.stringify(n,null,4)}`)}push(e,t,s){this.add(e,t,s)}current(){return Array.isArray(this.ranges)&&this.ranges.length?(this.ranges=er(this.ranges,{mergeType:this.opts.mergeType}),this.ranges&&this.opts.limitToBeAddedWhitespace?this.ranges.map(e=>N(e[2])?[e[0],e[1],_(e[2],this.opts.limitLinebreaksCount)]:e):this.ranges):null}wipe(){this.ranges=[]}replace(e){if(Array.isArray(e)&&e.length)if(Array.isArray(e[0])&&D(e[0][0]))this.ranges=Array.from(e);else throw new Error(`ranges-push/Ranges/replace(): [THROW_ID_11] Single range was given but we expected array of arrays! The first element, ${JSON.stringify(e[0],null,4)} should be an array and its first element should be an integer, a string index.`);else this.ranges=[]}last(){return Array.isArray(this.ranges)&&this.ranges.length?this.ranges[this.ranges.length-1]:null}};var Ee=k(Oe(),1);var Ar={removeThousandSeparatorsFromNumbers:!0,padSingleDecimalPlaceNumbers:!0,forceUKStyle:!1};function C(e,t){let s=!0,n=[".",",","'"," "],a;if(typeof e!="string")throw new TypeError(`string-remove-thousand-separators/remSep(): [THROW_ID_01] Input must be string! Currently it's: ${typeof e}, equal to:
|
|
17
|
+
${JSON.stringify(e,null,4)}`);if(t&&typeof t!="object")throw new TypeError(`string-remove-thousand-separators/remSep(): [THROW_ID_02] Options object must be a plain object! Currently it's: ${typeof t}, equal to:
|
|
18
|
+
${JSON.stringify(t,null,4)}`);let r=b(b({},Ar),t),i=(0,Ee.default)(e.trim(),'"');if(i==="")return i;if(+e>0&&+e<1)return e;let u=new ae;for(let l=0,o=i.length;l<o;l++){if(r.removeThousandSeparatorsFromNumbers&&i[l].trim()===""&&u.add(l,l+1),r.removeThousandSeparatorsFromNumbers&&i[l]==="'"&&(u.add(l,l+1),i[l+1]==="'")){s=!1;break}if(n.includes(i[l])){if(i[l+1]!==void 0&&/^\d$/.test(i[l+1]))if(i[l+2]!==void 0)if(/^\d$/.test(i[l+2]))if(i[l+3]!==void 0)if(/^\d$/.test(i[l+3])){if(i[l+4]!==void 0&&/^\d$/.test(i[l+4])){s=!1;break}else if(r.removeThousandSeparatorsFromNumbers&&u.add(l,l+1),!a)a=i[l];else if(i[l]!==a){s=!1;break}}else{s=!1;break}else r.removeThousandSeparatorsFromNumbers&&r.forceUKStyle&&i[l]===","&&u.add(l,l+1,".");else{s=!1;break}else r.forceUKStyle&&i[l]===","&&u.add(l,l+1,"."),r.padSingleDecimalPlaceNumbers&&u.add(l+2,l+2,"0")}else if(!/^\d$/.test(i[l])){s=!1;break}}return s&&u.current()?oe(i,u.current()):i}var xr={removeThousandSeparatorsFromNumbers:!0,padSingleDecimalPlaceNumbers:!0,forceUKStyle:!1};function Ne(e,t){let s=0,n=0,a=[],r=[],i=!1,u=!0;if(t&&typeof t!="object")throw new Error(`csv-split-easy/split(): [THROW_ID_02] Options object must be a plain object! Currently it's of a type ${typeof t} equal to:
|
|
19
|
+
${JSON.stringify(t,null,4)}`);let l=b(b({},xr),t);if(typeof e!="string")throw new TypeError(`csv-split-easy/split(): [THROW_ID_04] input must be string! Currently it's: ${typeof e}, equal to: ${JSON.stringify(e,null,4)}`);if(e==="")return[[""]];e=e.trim();for(let o=0,f=e.length;o<f;o++){if(u&&e[o]!=='"'&&e[o]!==","&&e[o].trim()!==""&&(u=!1),e[o]==='"')if(i&&e[o+1]==='"')o+=1;else if(i){i=!1;let g=e.slice(s,o);g.trim()!==""&&(u=!1);let y=/""/.test(g)?g.replace(/""/g,'"'):C(g,{removeThousandSeparatorsFromNumbers:l.removeThousandSeparatorsFromNumbers,padSingleDecimalPlaceNumbers:l.padSingleDecimalPlaceNumbers,forceUKStyle:l.forceUKStyle});a.push(y)}else i=!0,s=o+1;else if(!i&&e[o]===","){if(e[o-1]!=='"'&&!i){let g=e.slice(s,o);g.trim()!==""&&(u=!1),a.push(C(g,{removeThousandSeparatorsFromNumbers:l.removeThousandSeparatorsFromNumbers,padSingleDecimalPlaceNumbers:l.padSingleDecimalPlaceNumbers,forceUKStyle:l.forceUKStyle}))}s=o+1,n&&(n=0)}else if(e[o]===`
|
|
20
|
+
`||e[o]==="\r"){if(!n){if(n=o,!i&&e[o-1]!=='"'){let g=e.slice(s,o);g.trim()!==""&&(u=!1),a.push(C(g,{removeThousandSeparatorsFromNumbers:l.removeThousandSeparatorsFromNumbers,padSingleDecimalPlaceNumbers:l.padSingleDecimalPlaceNumbers,forceUKStyle:l.forceUKStyle}))}u?a.length=0:r.push(a),u=!0,a=[]}s=o+1}else n&&(n=0,s=o);if(o+1===f){if(e[o]!=='"'){let g=e.slice(s,o+1);g.trim()&&(u=!1),a.push(C(g,{removeThousandSeparatorsFromNumbers:l.removeThousandSeparatorsFromNumbers,padSingleDecimalPlaceNumbers:l.padSingleDecimalPlaceNumbers,forceUKStyle:l.forceUKStyle}))}u?a=[]:r.push(a),u=!0}}return r.length===0?[[""]]:r}var A=k(De(),1);function j(e){return typeof e=="number"&&!isNaN(e)?!0:(e=(e||"").toString().trim(),e?!isNaN(+e):!1)}var Vr=["\u062F.\u0625","\u060B","L","\u058F","\u0192","Kz","$","\u0192","\u20BC","KM","\u09F3","\u043B\u0432",".\u062F.\u0628","FBu","$b","R$","\u0E3F","Nu.","P","p.","BZ$","FC","CHF","\xA5","\u20A1","\u20B1","K\u010D","Fdj","kr","RD$","\u062F\u062C","kr","Nfk","Br","\u039E","\u20AC","\u20BE","\u20B5","GH\u20B5","D","FG","Q","L","kn","G","Ft","Rp","\u20AA","\u20B9","\u0639.\u062F","\uFDFC","kr","J$","JD","\xA5","KSh","\u043B\u0432","\u17DB","CF","\u20A9","\u20A9","KD","\u043B\u0432","\u20AD","\u20A8","M","\u0141","Lt","Ls","LD","MAD","lei","Ar","\u0434\u0435\u043D","K","\u20AE","MOP$","UM","\u20A8","Rf","MK","RM","MT","\u20A6","C$","kr","\u20A8","\uFDFC","B/.","S/.","K","\u20B1","\u20A8","z\u0142","Gs","\uFDFC","\uFFE5","lei","\u0414\u0438\u043D.","\u20BD","R\u20A3","\uFDFC","\u20A8","\u062C.\u0633.","kr","\xA3","Le","S","Db","E","\u0E3F","SM","T","\u062F.\u062A","T$","\u20A4","\u20BA","TT$","NT$","TSh","\u20B4","USh","$U","\u043B\u0432","Bs","\u20AB","VT","WS$","FCFA","\u0243","CFA","\u20A3","\uFDFC","R","Z$"];function w(e){return j(e)||Vr.some(t=>j(e.replace(t,"").replace(/[,.]/g,"")))?"numeric":e.trim()?"text":"empty"}var Ie="6.1.12";var Fr=Ie;function _r(e){let t=null,s=null;if(typeof e!="string")throw new TypeError(`csv-sort/csvSort(): [THROW_ID_01] The input is of a wrong type! We accept either string of array of arrays. We got instead: ${typeof e}, equal to:
|
|
21
|
+
${JSON.stringify(e,null,4)}`);if(!e.trim())return{res:[[""]],msgContent:t,msgType:s};let n=Ne(e),a=[],r=!1,i=!0,u=[],l=null;for(let p=n.length-1;p>=0;p--)if(a.length){p===0&&(r=n[p].every(h=>w(h)==="text"||w(h)==="empty")),!r&&a.length!==n[p].length&&(i=!1);let c=null;for(let h=0,S=n[p].length;h<S;h++)if(c===null&&w(n[p][h].trim())==="empty"&&(c=h),c!==null&&w(n[p][h].trim())!=="empty"&&(c=null),w(n[p][h].trim())!==a[h]&&!r){let $=w(n[p][h].trim());if(Array.isArray(a[h]))a[h].includes($)||a[h].push(w(n[p][h].trim()));else if(a[h]!==$){let T=a[h];a[h]=[],a[h].push(T),a[h].push($)}}l!==null&&c!==null&&c>l&&(!r||r&&p!==0)&&(l=c)}else if(n[p].length!==1||n[p][0]!=="")for(let c=0,h=n[p].length;c<h;c++)a.push(w(n[p][c].trim())),l===null&&w(n[p][c].trim())==="empty"&&(l=c),l!==null&&w(n[p][c].trim())!=="empty"&&(l=null);l||(l=a.length);let o=0;for(let p=0,c=a.length;p<c&&a[p]==="empty";p++)o=p;o!==0&&(n=n.map(p=>p.slice(o+1,l)),a=a.slice(o+1,l));let f=[],g;a.forEach((p,c)=>{p==="numeric"&&f.push(c)});let y=r?1:0;if(f.length===1)g=f[0];else{if(f.length===0)throw new Error('csv-sort/csvSort(): [THROW_ID_03] Your CSV file does not contain numeric-only columns and computer was not able to detect the "Balance" column!');{let p=Array.from(f),c=[];for(let h=0,S=p.length;h<S;h++){let $=p[h],T,R=!0,I,O=!0;for(let v=y,Ae=n.length;v<Ae&&(R&&(T==null?T=n[v][$]:T===n[v][$]?(c.push($),R=!1):T=n[v][$]),O&&(I==null?I=n[v][$]:n[v][$]!==I&&(O=!1)),!!R);v++);O&&u.push($)}if(p=(0,G.default)(p,...c),p.length===1)g=p[0];else if(p.length===0)throw new Error(`csv-sort/csvSort(): [THROW_ID_04] The computer can't find the "Balance" column! It saw some numeric-only columns, but they all seem to have certain rows with the same values as rows right below/above them!`)}}if(!g)throw new Error("csv-sort/csvSort(): [THROW_ID_05] Sadly computer couldn't find its way in this CSV and had to stop working on it.");let m=(0,G.default)(Array.from(a.reduce((p,c,h)=>((typeof c=="string"&&c==="numeric"||Array.isArray(c)&&c.includes("numeric"))&&p.push(h),p),[])),g,...u),d=[];d.push(n[n.length-1].slice(0,l));let E=[],F=r?1:0;for(let p=n.length-2;p>=F;p--)for(let c=n.length-2;c>=F;c--)if(!E.includes(c)){let h=!1;for(let S=0,$=m.length;S<$;S++){let T=null;n[c][m[S]]!==""&&(T=(0,A.default)(n[c][m[S]]));let R=null;n[c][g]!==""&&(R=(0,A.default)(n[c][g]));let I=null;d[0][g]!==""&&(I=(0,A.default)(d[0][g]).format());let O=null;d[d.length-1][m[S]]!==""&&(O=(0,A.default)(d[d.length-1][m[S]]).format());let v=null;if(d[d.length-1][g]!==""&&(v=(0,A.default)(d[d.length-1][g])),T&&R.add(T).format()===I){d.unshift(n[c].slice(0,l)),E.push(c),h=!0;break}else if(T&&R.subtract(T).format()===I){d.unshift(n[c].slice(0,l)),E.push(c),h=!0;break}else if(O&&v.add(O).format()===R.format()){d.push(n[c].slice(0,l)),E.push(c),h=!0;break}else if(O&&v.subtract(O).format()===R.format()){d.push(n[c].slice(0,l)),E.push(c),h=!0;break}}if(h){h=!1;break}}return r&&(i&&n[0].length>a.length&&(n[0].length=a.length),d.unshift(n[0].slice(0,l))),n.length-(r?2:1)!==E.length&&(t="Not all rows were recognised!",s="alert"),{res:d,msgContent:t,msgType:s}}return We(jr);})();
|
|
22
22
|
/**
|
|
23
23
|
* @name csv-split-easy
|
|
24
24
|
* @fileoverview Splits the CSV string into array of arrays, each representing a row of columns
|
|
25
|
-
* @version 6.1.
|
|
25
|
+
* @version 6.1.12
|
|
26
26
|
* @author Roy Revelt, Codsen Ltd
|
|
27
27
|
* @license MIT
|
|
28
28
|
* {@link https://codsen.com/os/csv-split-easy/}
|
|
@@ -30,7 +30,7 @@ ${JSON.stringify(e,null,4)}`);if(!e.trim())return{res:[[""]],msgContent:r,msgTyp
|
|
|
30
30
|
/**
|
|
31
31
|
* @name ranges-apply
|
|
32
32
|
* @fileoverview Take an array of string index ranges, delete/replace the string according to them
|
|
33
|
-
* @version 6.2.
|
|
33
|
+
* @version 6.2.12
|
|
34
34
|
* @author Roy Revelt, Codsen Ltd
|
|
35
35
|
* @license MIT
|
|
36
36
|
* {@link https://codsen.com/os/ranges-apply/}
|
|
@@ -38,7 +38,7 @@ ${JSON.stringify(e,null,4)}`);if(!e.trim())return{res:[[""]],msgContent:r,msgTyp
|
|
|
38
38
|
/**
|
|
39
39
|
* @name ranges-merge
|
|
40
40
|
* @fileoverview Merge and sort string index ranges
|
|
41
|
-
* @version 8.2.
|
|
41
|
+
* @version 8.2.7
|
|
42
42
|
* @author Roy Revelt, Codsen Ltd
|
|
43
43
|
* @license MIT
|
|
44
44
|
* {@link https://codsen.com/os/ranges-merge/}
|
|
@@ -46,7 +46,7 @@ ${JSON.stringify(e,null,4)}`);if(!e.trim())return{res:[[""]],msgContent:r,msgTyp
|
|
|
46
46
|
/**
|
|
47
47
|
* @name ranges-push
|
|
48
48
|
* @fileoverview Gather string index ranges
|
|
49
|
-
* @version 6.2.
|
|
49
|
+
* @version 6.2.7
|
|
50
50
|
* @author Roy Revelt, Codsen Ltd
|
|
51
51
|
* @license MIT
|
|
52
52
|
* {@link https://codsen.com/os/ranges-push/}
|
|
@@ -54,7 +54,7 @@ ${JSON.stringify(e,null,4)}`);if(!e.trim())return{res:[[""]],msgContent:r,msgTyp
|
|
|
54
54
|
/**
|
|
55
55
|
* @name ranges-sort
|
|
56
56
|
* @fileoverview Sort string index ranges
|
|
57
|
-
* @version 5.1.
|
|
57
|
+
* @version 5.1.6
|
|
58
58
|
* @author Roy Revelt, Codsen Ltd
|
|
59
59
|
* @license MIT
|
|
60
60
|
* {@link https://codsen.com/os/ranges-sort/}
|
|
@@ -62,7 +62,7 @@ ${JSON.stringify(e,null,4)}`);if(!e.trim())return{res:[[""]],msgContent:r,msgTyp
|
|
|
62
62
|
/**
|
|
63
63
|
* @name string-collapse-leading-whitespace
|
|
64
64
|
* @fileoverview Collapse the leading and trailing whitespace of a string
|
|
65
|
-
* @version 6.1.
|
|
65
|
+
* @version 6.1.7
|
|
66
66
|
* @author Roy Revelt, Codsen Ltd
|
|
67
67
|
* @license MIT
|
|
68
68
|
* {@link https://codsen.com/os/string-collapse-leading-whitespace/}
|
|
@@ -70,7 +70,7 @@ ${JSON.stringify(e,null,4)}`);if(!e.trim())return{res:[[""]],msgContent:r,msgTyp
|
|
|
70
70
|
/**
|
|
71
71
|
* @name string-remove-thousand-separators
|
|
72
72
|
* @fileoverview Detects and removes thousand separators (dot/comma/quote/space) from string-type digits
|
|
73
|
-
* @version 6.2.
|
|
73
|
+
* @version 6.2.12
|
|
74
74
|
* @author Roy Revelt, Codsen Ltd
|
|
75
75
|
* @license MIT
|
|
76
76
|
* {@link https://codsen.com/os/string-remove-thousand-separators/}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "csv-sort",
|
|
3
|
-
"version": "6.1.
|
|
3
|
+
"version": "6.1.12",
|
|
4
4
|
"description": "Sort double-entry bookkeeping CSV from internet banking",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"accountancy",
|
|
@@ -40,6 +40,8 @@
|
|
|
40
40
|
"types": "types/index.d.ts",
|
|
41
41
|
"scripts": {
|
|
42
42
|
"build": "node '../../ops/scripts/esbuild.js' && yarn run dts",
|
|
43
|
+
"cjs-off": "exit 0",
|
|
44
|
+
"cjs-on": "exit 0",
|
|
43
45
|
"dev": "DEV=true node '../../ops/scripts/esbuild.js' && yarn run dts",
|
|
44
46
|
"devtest": "c8 yarn run unit && yarn run examples && yarn run lint",
|
|
45
47
|
"dts": "rollup -c && yarn run prettier 'types/index.d.ts' --write",
|
|
@@ -74,7 +76,7 @@
|
|
|
74
76
|
}
|
|
75
77
|
},
|
|
76
78
|
"dependencies": {
|
|
77
|
-
"csv-split-easy": "^6.1.
|
|
79
|
+
"csv-split-easy": "^6.1.12",
|
|
78
80
|
"currency.js": "^2.0.4",
|
|
79
81
|
"lodash.pull": "^4.1.0"
|
|
80
82
|
},
|