ranges-sort 6.2.1 → 6.2.2

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/CHANGELOG.md CHANGED
@@ -3,6 +3,20 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 6.2.2 (2026-09-01)
7
+
8
+ ### Bug Fixes
9
+
10
+ - align range input and output types ([1a13db6](https://github.com/codsen/codsen/commit/1a13db665fe2f9e77c6b5fd509980c87e5a57baf))
11
+ - complete range sort progress reporting ([19d66bf](https://github.com/codsen/codsen/commit/19d66bfcc4a479ff31591b5ee06f08d832b58f12))
12
+ - preserve tied range insertion order ([63b3fa3](https://github.com/codsen/codsen/commit/63b3fa313cd9ca822189371eac868d93cf770195))
13
+ - reject malformed range members ([2daef3c](https://github.com/codsen/codsen/commit/2daef3c051a9aeff1f388f5d96ecb837310644be))
14
+ - validate range sort options ([ce2de21](https://github.com/codsen/codsen/commit/ce2de21fa5d890b2505f69221e7e959f8c241a5f))
15
+
16
+ ### Performance Improvements
17
+
18
+ - streamline range sorting ([63782fd](https://github.com/codsen/codsen/commit/63782fd52bb77483a602a95fb2ced2d3caa824c7))
19
+
6
20
  ## 6.2.1 (2026-08-22)
7
21
 
8
22
  ### Performance Improvements
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * @name ranges-sort
3
3
  * @fileoverview Sort string index ranges
4
- * @version 6.2.1
4
+ * @version 6.2.2
5
5
  * @author Roy Revelt
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/ranges-sort/}
8
8
  */
9
9
 
10
- import{formatDiagnosticValue as u}from"codsen-utils";var l="6.2.1";var f=l,m={strictlyTwoElementsInRangeArrays:!1,progressFn:null};function h(t,p){if(!Array.isArray(t)||!t.length)return t;let n={...m,...p},s,o;if(n.strictlyTwoElementsInRangeArrays&&!t.every((e,r)=>!Array.isArray(e)||e.length!==2?(s=r,o=e.length,!1):!0))throw new TypeError(`ranges-sort/rSort(): [THROW_ID_01] The first argument should be an array and must consist of arrays which are natural number indexes representing TWO string index ranges. However, ${s}th range (${u(t[s],4)}) has not two but ${o} elements!`);if(!t.every((e,r)=>!Array.isArray(e)||!Number.isInteger(e[0])||e[0]<0||!Number.isInteger(e[1])||e[1]<0?(s=r,!1):!0))throw new TypeError(`ranges-sort/rSort(): [THROW_ID_02] The first argument should be an array and must consist of arrays which are natural number indexes representing string index ranges. However, ${s}th range (${u(t[s],4)}) does not consist of only natural numbers!`);let c=t.length**2,i=0;return Array.from(t).sort((e,r)=>(n.progressFn&&(i+=1,n.progressFn(Math.floor(i*100/c))),e[0]===r[0]?e[1]<r[1]?-1:e[1]>r[1]?1:0:e[0]<r[0]?-1:1))}export{m as defaults,h as rSort,f as version};
10
+ import{formatDiagnosticValue as c,isPlainObject as h}from"codsen-utils";var f="6.2.2";var v=f,g={strictlyTwoElementsInRangeArrays:!1,progressFn:null};function b(t,s){let u,o=0;for(;o<t.length;){let n=o+1;for(;n<t.length&&t[o][0]===t[n][0]&&t[o][1]===t[n][1];)n+=1;if(n-o>1){u||(u=new Map(s.map((p,e)=>[p,e])));let i=u,l=t.slice(o,n).sort((p,e)=>i.get(p)-i.get(e));t.splice(o,l.length,...l)}o=n}return t}function I(t,s){if(!Array.isArray(t)||!t.length)return t;let u=s===void 0?!0:h(s);if(s!==void 0&&u&&s?.strictlyTwoElementsInRangeArrays===!0)for(let e=0;e<t.length;e+=1){let r=t[e];if(!Array.isArray(r)||r.length!==2)throw new TypeError(`ranges-sort/rSort(): [THROW_ID_01] The first argument should be an array and must consist of arrays which are natural number indexes representing TWO string index ranges. However, range at index ${e} (${c(r,4)}) is ${Array.isArray(r)?`an array with ${r.length} elements`:"not an array"}!`);if(!Number.isInteger(r[0])||r[0]<0||!Number.isInteger(r[1])||r[1]<0)throw new TypeError(`ranges-sort/rSort(): [THROW_ID_02] The first argument should be an array and must consist of arrays which are natural number indexes representing string index ranges. However, range at index ${e} (${c(r,4)}) does not consist of only natural numbers!`)}else for(let e=0;e<t.length;e+=1){let r=t[e];if(!Array.isArray(r)||!Number.isInteger(r[0])||r[0]<0||!Number.isInteger(r[1])||r[1]<0)throw new TypeError(`ranges-sort/rSort(): [THROW_ID_02] The first argument should be an array and must consist of arrays which are natural number indexes representing string index ranges. However, range at index ${e} (${c(r,4)}) does not consist of only natural numbers!`)}if(s!==void 0&&!u)throw new TypeError(`ranges-sort/rSort(): [THROW_ID_03] The second argument must be a plain options object; received ${c(s,4)} (type ${typeof s})!`);let n=g.progressFn;if(s!==void 0){let e=s.strictlyTwoElementsInRangeArrays;if(e!==void 0&&typeof e!="boolean")throw new TypeError(`ranges-sort/rSort(): [THROW_ID_04] opts.strictlyTwoElementsInRangeArrays must be a boolean; received ${c(e,4)} (type ${typeof e})!`);if(n=s.progressFn??g.progressFn,n!==!1&&n!==null&&typeof n!="function")throw new TypeError(`ranges-sort/rSort(): [THROW_ID_05] opts.progressFn must be a function, false, null, or undefined; received ${c(n,4)} (type ${typeof n})!`)}let i,l;if(n){let e=t.length**2,r=0,m;l=a=>{a!==m&&(m=a,n(a))},i=Array.from(t).sort((a,d)=>(r+=1,l?.(Math.min(99,Math.floor(r*100/e))),a[0]===d[0]?a[1]<d[1]?-1:a[1]>d[1]?1:0:a[0]<d[0]?-1:1))}else i=Array.from(t).sort((e,r)=>e[0]===r[0]?e[1]<r[1]?-1:e[1]>r[1]?1:0:e[0]<r[0]?-1:1);let p=i.length>10?b(i,t):i;return l?.(100),p}export{g as defaults,I as rSort,v as version};
@@ -1,17 +1,25 @@
1
1
  /**
2
2
  * @name ranges-sort
3
3
  * @fileoverview Sort string index ranges
4
- * @version 6.2.1
4
+ * @version 6.2.2
5
5
  * @author Roy Revelt
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/ranges-sort/}
8
8
  */
9
9
 
10
- "use strict";var rangesSort=(()=>{var y=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames,x=Object.getOwnPropertySymbols;var S=Object.prototype.hasOwnProperty,B=Object.prototype.propertyIsEnumerable;var C=(t,n,e)=>n in t?y(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e,b=(t,n)=>{for(var e in n||(n={}))S.call(n,e)&&C(t,e,n[e]);if(x)for(var e of x(n))B.call(n,e)&&C(t,e,n[e]);return t};var E=(t,n)=>{for(var e in n)y(t,e,{get:n[e],enumerable:!0})},P=(t,n,e,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of M(n))!S.call(t,o)&&o!==e&&y(t,o,{get:()=>n[o],enumerable:!(i=T(n,o))||i.enumerable});return t};var F=t=>P(y({},"__esModule",{value:!0}),t);var Q={};E(Q,{defaults:()=>I,rSort:()=>V,version:()=>_});function L(){let t=[],n=0,e=!1;return{append(i){return e?!1:n+i.length>1999?(t.push("\u2026"),n+=1,e=!0,!1):(t.push(i),n+=i.length,!0)},result(){return t.join("")},stopped(){return e}}}function U(t){return"\\u".concat(t.toString(16).padStart(4,"0"))}function m(t,n){if(t.append('"')){for(let e=0;e<n.length&&!t.stopped();e+=1){let i=n.charCodeAt(e);i===34?t.append('\\"'):i===92?t.append("\\\\"):i===8?t.append("\\b"):i===9?t.append("\\t"):i===10?t.append("\\n"):i===12?t.append("\\f"):i===13?t.append("\\r"):i<32||i===8232||i===8233||i>=55296&&i<=57343?t.append(U(i)):t.append(n[e])}t.append('"')}}function N(t){return t.get&&t.set?"[Getter/Setter]":t.get?"[Getter]":t.set?"[Setter]":"[Accessor]"}function j(t,n){t.append("Symbol(");let e=String(n);e.length>8&&m(t,e.slice(7,-1)),t.append(")")}function k(t,n){typeof n=="symbol"?j(t,n):m(t,String(n))}function v(t,n=0){let e=L(),i=n===4?4:0,o=new WeakSet,h=0;function g(r){i&&e.append(" ".repeat(r*i))}function l(r,s){r&&e.append(","),i&&(e.append("\n"),g(s+1))}function f(r,s,u){i&&s&&(e.append("\n"),g(u)),e.append(r)}function A(r,s){Object.prototype.hasOwnProperty.call(r,"value")?w(r.value,s):e.append(N(r))}function $(r,s){let u;try{u=Reflect.getOwnPropertyDescriptor(r,"length")}catch(c){e.append("[Uninspectable]");return}let a=u==null?void 0:u.value;if(!Number.isSafeInteger(a)||a<0){e.append("[Uninspectable]");return}e.append("[");let p=!1;for(let c=0;c<a&&!e.stopped();c+=1){if(l(p,s),p=!0,h>=50){e.append("[MaxEntries]");break}h+=1;let d;try{d=Reflect.getOwnPropertyDescriptor(r,String(c))}catch(z){e.append("[Uninspectable]");continue}d!=null&&d.enumerable?A(d,s+1):e.append("[Empty]")}f("]",p,s)}function W(r,s){let u;try{u=Reflect.ownKeys(r)}catch(p){e.append("[Uninspectable]");return}e.append("{");let a=!1;for(let p of u){if(e.stopped())break;if(h>=50){l(a,s),a=!0,m(e,"\u2026"),e.append(i?": ":":"),e.append("[MaxEntries]");break}h+=1;let c;try{c=Reflect.getOwnPropertyDescriptor(r,p)}catch(d){l(a,s),a=!0,k(e,p),e.append(i?": ":":"),e.append("[Uninspectable]");continue}c!=null&&c.enumerable&&(l(a,s),a=!0,k(e,p),e.append(i?": ":":"),A(c,s+1))}f("}",a,s)}function R(r,s){if(o.has(r)){e.append("[Circular]");return}if(s>=5){e.append("[MaxDepth]");return}let u;try{u=Array.isArray(r)}catch(a){e.append("[Uninspectable]");return}o.add(r);try{u?$(r,s):W(r,s)}finally{o.delete(r)}}function w(r,s){r===null?e.append("null"):typeof r=="string"?m(e,r):typeof r=="number"?e.append(Object.is(r,-0)?"-0":String(r)):typeof r=="boolean"?e.append(r?"true":"false"):typeof r>"u"?e.append("undefined"):typeof r=="bigint"?e.append("".concat(r,"n")):typeof r=="symbol"?j(e,r):typeof r=="function"?e.append("[Function]"):R(r,s)}try{return w(t,0),e.result()}catch(r){return"[Uninspectable]"}}var Z=new Set([..."\u060B$\u20BC\u17DB\xA5\u20A1\u20B1\xA3\u20AC\xA2\u20B9\uFDFC\u20AA\u20A9\u20AD\u20A8\u20AE\u20A6\u20BD\u20AB\u0E3F\u20A9\u20BA\u20B4","$U","$b","B/.","BZ$","Br","Bs","C$","CHF","Ft","Gs","J$","KM","K\u010D","L","MT","NT$","P","Q","R","R$","RD$","RM","Rp","S","S/.","TT$","Z$","kn","kr","lei","z\u0142","\u0192","\u0414\u0438\u043D.","\u0434\u0435\u043D","\u043B\u0432","\u062F.\u0625","Lek"]);var O,q=(O=Object.getOwnPropertyDescriptor(RegExp.prototype,"source"))==null?void 0:O.get;var J=Date.prototype.getTime;var D="6.2.1";var _=D,I={strictlyTwoElementsInRangeArrays:!1,progressFn:null};function V(t,n){if(!Array.isArray(t)||!t.length)return t;let e=b(b({},I),n),i,o;if(e.strictlyTwoElementsInRangeArrays&&!t.every((l,f)=>!Array.isArray(l)||l.length!==2?(i=f,o=l.length,!1):!0))throw new TypeError("ranges-sort/rSort(): [THROW_ID_01] The first argument should be an array and must consist of arrays which are natural number indexes representing TWO string index ranges. However, ".concat(i,"th range (").concat(v(t[i],4),") has not two but ").concat(o," elements!"));if(!t.every((l,f)=>!Array.isArray(l)||!Number.isInteger(l[0])||l[0]<0||!Number.isInteger(l[1])||l[1]<0?(i=f,!1):!0))throw new TypeError("ranges-sort/rSort(): [THROW_ID_02] The first argument should be an array and must consist of arrays which are natural number indexes representing string index ranges. However, ".concat(i,"th range (").concat(v(t[i],4),") does not consist of only natural numbers!"));let h=t.length**2,g=0;return Array.from(t).sort((l,f)=>(e.progressFn&&(g+=1,e.progressFn(Math.floor(g*100/h))),l[0]===f[0]?l[1]<f[1]?-1:l[1]>f[1]?1:0:l[0]<f[0]?-1:1))}return F(Q);})();
10
+ "use strict";var rangesSort=(()=>{var x=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var F=Object.prototype.hasOwnProperty;var B=(e,t)=>{for(var _ in t)x(e,_,{get:t[_],enumerable:!0})},N=(e,t,_,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of M(t))!F.call(e,s)&&s!==_&&x(e,s,{get:()=>t[s],enumerable:!(r=P(t,s))||r.enumerable});return e};var L=e=>N(x({},"__esModule",{value:!0}),e);var Y={};B(Y,{defaults:()=>k,rSort:()=>Z,version:()=>G});function z(){let e=[],t=0,_=!1;return{append(r){return _?!1:t+r.length>1999?(e.push("\u2026"),t+=1,_=!0,!1):(e.push(r),t+=r.length,!0)},result(){return e.join("")},stopped(){return _}}}function U(e){return"\\u".concat(e.toString(16).padStart(4,"0"))}function A(e,t){if(e.append('"')){for(let _=0;_<t.length&&!e.stopped();_+=1){let r=t.charCodeAt(_);r===34?e.append('\\"'):r===92?e.append("\\\\"):r===8?e.append("\\b"):r===9?e.append("\\t"):r===10?e.append("\\n"):r===12?e.append("\\f"):r===13?e.append("\\r"):r<32||r===8232||r===8233||r>=55296&&r<=57343?e.append(U(r)):e.append(t[_])}e.append('"')}}function H(e){return e.get&&e.set?"[Getter/Setter]":e.get?"[Getter]":e.set?"[Setter]":"[Accessor]"}function C(e,t){e.append("Symbol(");let _=String(t);_.length>8&&A(e,_.slice(7,-1)),e.append(")")}function O(e,t){typeof t=="symbol"?C(e,t):A(e,String(t))}function m(e,t=0){let _=z(),r=t===4?4:0,s=new WeakSet,u=0;function a(n){r&&_.append(" ".repeat(n*r))}function p(n,o){n&&_.append(","),r&&(_.append("\n"),a(o+1))}function g(n,o,c){r&&o&&(_.append("\n"),a(c)),_.append(n)}function l(n,o){Object.prototype.hasOwnProperty.call(n,"value")?b(n.value,o):_.append(H(n))}function i(n,o){let c;try{c=Reflect.getOwnPropertyDescriptor(n,"length")}catch(d){_.append("[Uninspectable]");return}let f=c==null?void 0:c.value;if(!Number.isSafeInteger(f)||f<0){_.append("[Uninspectable]");return}_.append("[");let y=!1;for(let d=0;d<f&&!_.stopped();d+=1){if(p(y,o),y=!0,u>=50){_.append("[MaxEntries]");break}u+=1;let v;try{v=Reflect.getOwnPropertyDescriptor(n,String(d))}catch(X){_.append("[Uninspectable]");continue}v!=null&&v.enumerable?l(v,o+1):_.append("[Empty]")}g("]",y,o)}function w(n,o){let c;try{c=Reflect.ownKeys(n)}catch(y){_.append("[Uninspectable]");return}_.append("{");let f=!1;for(let y of c){if(_.stopped())break;if(u>=50){p(f,o),f=!0,A(_,"\u2026"),_.append(r?": ":":"),_.append("[MaxEntries]");break}u+=1;let d;try{d=Reflect.getOwnPropertyDescriptor(n,y)}catch(v){p(f,o),f=!0,O(_,y),_.append(r?": ":":"),_.append("[Uninspectable]");continue}d!=null&&d.enumerable&&(p(f,o),f=!0,O(_,y),_.append(r?": ":":"),l(d,o+1))}g("}",f,o)}function h(n,o){if(s.has(n)){_.append("[Circular]");return}if(o>=5){_.append("[MaxDepth]");return}let c;try{c=Array.isArray(n)}catch(f){_.append("[Uninspectable]");return}s.add(n);try{c?i(n,o):w(n,o)}finally{s.delete(n)}}function b(n,o){n===null?_.append("null"):typeof n=="string"?A(_,n):typeof n=="number"?_.append(Object.is(n,-0)?"-0":String(n)):typeof n=="boolean"?_.append(n?"true":"false"):typeof n>"u"?_.append("undefined"):typeof n=="bigint"?_.append("".concat(n,"n")):typeof n=="symbol"?C(_,n):typeof n=="function"?_.append("[Function]"):h(n,o)}try{return b(e,0),_.result()}catch(n){return"[Uninspectable]"}}var q=["_16_0_a_0_4_0_5_m_1_u_1_cp_4_b_e_4_7_0_1_0_3l_4_1_1_2_3_1_0_6_0_1_2_1_0_1_j_1_2a_1_3u_8_4l_1_11_2_0_","6_14_1z_q_4_3_19_16_z_1_1_2q_1_0_f_1_7_1_a_2_2_0_g_0_1_t_t_2g_b_0_o_w_9_1_4_0_5_l_4_0_9_0_3_0_n_o_7_","a_5_n_1_6_g_15_1m_1h_3_0_i_0_7_9_f_f_4_7_2_1_2_l_1_6_1_0_3_3_3_0_g_0_d_1_1_2_e_1_a_0_8_5_4_1_2_l_1_6","_1_1_1_1_1_1_v_3_1_0_j_2_g_8_1_2_1_l_1_6_1_1_1_4_3_0_i_0_f_1_n_0_b_7_2_1_2_l_1_6_1_1_1_4_3_0_u_1_1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","2p_36_6pp_3_1_6_1_1_1_82_f_0_t_2_2_0_e_3_8_az_1s4_2y_5_c_3_8_7_9_4me_2c_1_1y_1_1_2_0_2_1_2_3_1_b_1_0","_1_6_1_1s_1_3_2_7_1_6_1_r_1_3_1_4_1_0_3_6_1_9f_2_o_1_o_1_u_1_o_1_u_1_o_1_u_1_o_1_u_1_o_1_7_1f8_u_6_5","_79_1p_42_18_a_6_g_0_8x_t_i_17_dg_r_6c_t_2_0_5r_u_1_2_1_1_1_6_2_4_9_1_68_6_1_3_1_1_1_e_1_5g_1n_1v_7_","0_xg_3_1_q_1_1_1_0_2_0_1_9_1_3_1_0_1_0_6_0_4_0_1_0_1_0_1_2_1_1_1_0_2_0_1_0_1_0_1_0_1_0_1_1_1_0_2_3_1","_6_1_3_1_3_1_0_1_9_1_g_5_2_1_4_1_g_3es_wyn_w_3dp_2_4gd_2_5rk_f_h9_1wi_f1_15u_3t6_5_6jt"].join(""),j=q.slice(1).split("_"),V=[],S=127;for(let e=0;e<j.length;e+=2){let t=S+1+Number.parseInt(j[e],36),_=t+Number.parseInt(j[e+1],36);V.push([t,_]),S=_}var ne=new Set([..."\u060B$\u20BC\u17DB\xA5\u20A1\u20B1\xA3\u20AC\xA2\u20B9\uFDFC\u20AA\u20A9\u20AD\u20A8\u20AE\u20A6\u20BD\u20AB\u0E3F\u20A9\u20BA\u20B4","$U","$b","B/.","BZ$","Br","Bs","C$","CHF","Ft","Gs","J$","KM","K\u010D","L","MT","NT$","P","Q","R","R$","RD$","RM","Rp","S","S/.","TT$","Z$","kn","kr","lei","z\u0142","\u0192","\u0414\u0438\u043D.","\u0434\u0435\u043D","\u043B\u0432","\u062F.\u0625","Lek"]);var T=Function.prototype.toString,K=T.call(Object);var ie=Map.prototype.entries,se=Set.prototype.values;var D,le=(D=Object.getOwnPropertyDescriptor(ArrayBuffer.prototype,"byteLength"))==null?void 0:D.get,R,oe=(R=Object.getOwnPropertyDescriptor(RegExp.prototype,"flags"))==null?void 0:R.get,I,ue=(I=Object.getOwnPropertyDescriptor(RegExp.prototype,"global"))==null?void 0:I.get,$,ae=($=Object.getOwnPropertyDescriptor(RegExp.prototype,"source"))==null?void 0:$.get,ce=RegExp.prototype.test;function E(e){var r;if(e==null||typeof e!="object")return!1;let t=Object.getPrototypeOf(e);if(t===null||t===Object.prototype)return!0;let _=Object.getOwnPropertyDescriptor(t,"constructor");return!_||!("value"in _)||typeof _.value!="function"?!1:((r=Object.getOwnPropertyDescriptor(_.value,"prototype"))==null?void 0:r.value)===t&&T.call(_.value)===K}var fe=Date.prototype.getTime;var W="6.2.2";var G=W,k={strictlyTwoElementsInRangeArrays:!1,progressFn:null};function J(e,t){let _,r=0;for(;r<e.length;){let s=r+1;for(;s<e.length&&e[r][0]===e[s][0]&&e[r][1]===e[s][1];)s+=1;if(s-r>1){_||(_=new Map(t.map((p,g)=>[p,g])));let u=_,a=e.slice(r,s).sort((p,g)=>u.get(p)-u.get(g));e.splice(r,a.length,...a)}r=s}return e}function Z(e,t){var g;if(!Array.isArray(e)||!e.length)return e;let _=t===void 0?!0:E(t);if(t!==void 0&&_&&(t==null?void 0:t.strictlyTwoElementsInRangeArrays)===!0)for(let l=0;l<e.length;l+=1){let i=e[l];if(!Array.isArray(i)||i.length!==2)throw new TypeError("ranges-sort/rSort(): [THROW_ID_01] The first argument should be an array and must consist of arrays which are natural number indexes representing TWO string index ranges. However, range at index ".concat(l," (").concat(m(i,4),") is ").concat(Array.isArray(i)?"an array with ".concat(i.length," elements"):"not an array","!"));if(!Number.isInteger(i[0])||i[0]<0||!Number.isInteger(i[1])||i[1]<0)throw new TypeError("ranges-sort/rSort(): [THROW_ID_02] The first argument should be an array and must consist of arrays which are natural number indexes representing string index ranges. However, range at index ".concat(l," (").concat(m(i,4),") does not consist of only natural numbers!"))}else for(let l=0;l<e.length;l+=1){let i=e[l];if(!Array.isArray(i)||!Number.isInteger(i[0])||i[0]<0||!Number.isInteger(i[1])||i[1]<0)throw new TypeError("ranges-sort/rSort(): [THROW_ID_02] The first argument should be an array and must consist of arrays which are natural number indexes representing string index ranges. However, range at index ".concat(l," (").concat(m(i,4),") does not consist of only natural numbers!"))}if(t!==void 0&&!_)throw new TypeError("ranges-sort/rSort(): [THROW_ID_03] The second argument must be a plain options object; received ".concat(m(t,4)," (type ").concat(typeof t,")!"));let s=k.progressFn;if(t!==void 0){let l=t.strictlyTwoElementsInRangeArrays;if(l!==void 0&&typeof l!="boolean")throw new TypeError("ranges-sort/rSort(): [THROW_ID_04] opts.strictlyTwoElementsInRangeArrays must be a boolean; received ".concat(m(l,4)," (type ").concat(typeof l,")!"));if(s=(g=t.progressFn)!=null?g:k.progressFn,s!==!1&&s!==null&&typeof s!="function")throw new TypeError("ranges-sort/rSort(): [THROW_ID_05] opts.progressFn must be a function, false, null, or undefined; received ".concat(m(s,4)," (type ").concat(typeof s,")!"))}let u,a;if(s){let l=e.length**2,i=0,w;a=h=>{h!==w&&(w=h,s(h))},u=Array.from(e).sort((h,b)=>(i+=1,a==null||a(Math.min(99,Math.floor(i*100/l))),h[0]===b[0]?h[1]<b[1]?-1:h[1]>b[1]?1:0:h[0]<b[0]?-1:1))}else u=Array.from(e).sort((l,i)=>l[0]===i[0]?l[1]<i[1]?-1:l[1]>i[1]?1:0:l[0]<i[0]?-1:1);let p=u.length>10?J(u,e):u;return a==null||a(100),p}return L(Y);})();
11
+ /**
12
+ * @name codsen-format-diagnostic-value
13
+ * @fileoverview Safely format untrusted JavaScript values for diagnostics
14
+ * @version 1.1.0
15
+ * @author Roy Revelt
16
+ * @license MIT
17
+ * {@link https://codsen.com/os/codsen-format-diagnostic-value/}
18
+ */
11
19
  /**
12
20
  * @name codsen-utils
13
21
  * @fileoverview Various utility functions
14
- * @version 1.9.0
22
+ * @version 1.10.0
15
23
  * @author Roy Revelt
16
24
  * @license MIT
17
25
  * {@link https://codsen.com/os/codsen-utils/}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ranges-sort",
3
- "version": "6.2.1",
3
+ "version": "6.2.2",
4
4
  "description": "Sort string index ranges",
5
5
  "keywords": ["array", "indexes", "ranges", "sort", "string"],
6
6
  "homepage": "https://codsen.com/os/ranges-sort",
@@ -58,7 +58,7 @@
58
58
  }
59
59
  },
60
60
  "dependencies": {
61
- "codsen-utils": "^1.9.0"
61
+ "codsen-utils": "^1.10.0"
62
62
  },
63
63
  "engines": {
64
64
  "node": ">=18.20.8"
package/types/index.d.ts CHANGED
@@ -1,12 +1,20 @@
1
1
  type Range =
2
2
  | [from: number, to: number]
3
- | [from: number, to: number, whatToInsert: string | null | undefined];
3
+ | [
4
+ from: number,
5
+ to: number,
6
+ whatToInsert: string | number | null | undefined,
7
+ ];
4
8
  type Ranges = Range[] | null;
5
9
  declare const version: string;
6
10
  type ProgressFn = (percentageDone: number) => void;
7
11
  interface Opts {
8
12
  strictlyTwoElementsInRangeArrays: boolean;
9
- progressFn: undefined | null | ProgressFn;
13
+ /**
14
+ * Reports best-effort integer progress for successful nonempty sorts. The
15
+ * final call is 100. Empty inputs and validation failures do not call it.
16
+ */
17
+ progressFn: false | undefined | null | ProgressFn;
10
18
  }
11
19
  declare const defaults: Opts;
12
20
  declare function rSort(