Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ranges-push

Package Overview
Dependencies
Maintainers
1
Versions
161
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ranges-push - npm Package Compare versions

Comparing version 6.2.0 to 6.2.1

6

dist/ranges-push.esm.js
/**
* @name ranges-push
* @fileoverview Gather string index ranges
* @version 6.2.0
* @version 6.2.1
* @author Roy Revelt, Codsen Ltd

@@ -10,3 +10,3 @@ * @license MIT

import{collWhitespace as y}from"string-collapse-leading-whitespace";var b={strictlyTwoElementsInRangeArrays:!1,progressFn:null};function m(i,r){if(!Array.isArray(i)||!i.length)return i;let t={...b,...r},e,l;if(t.strictlyTwoElementsInRangeArrays&&!i.every((o,g)=>!Array.isArray(o)||o.length!==2?(e=g,l=o.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, ${e}th range (${JSON.stringify(i[e],null,4)}) has not two but ${l} elements!`);if(!i.every((o,g)=>!Array.isArray(o)||!Number.isInteger(o[0])||o[0]<0||!Number.isInteger(o[1])||o[1]<0?(e=g,!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, ${e}th range (${JSON.stringify(i[e],null,4)}) does not consist of only natural numbers!`);let n=i.length**2,a=0;return Array.from(i).sort((o,g)=>(t.progressFn&&(a+=1,t.progressFn(Math.floor(a*100/n))),o[0]===g[0]?o[1]<g[1]?-1:o[1]>g[1]?1:0:o[0]<g[0]?-1:1))}var d="6.2.0";var c={mergeType:1,progressFn:null,joinRangesThatTouchEdges:!0};function f(i,r){function t(s){return!!s&&typeof s=="object"&&!Array.isArray(s)}if(!Array.isArray(i)||!i.length)return null;let e;if(r)if(t(r)){if(e={...c,...r},e.progressFn&&t(e.progressFn)&&!Object.keys(e.progressFn).length)e.progressFn=null;else if(e.progressFn&&typeof e.progressFn!="function")throw new Error(`ranges-merge: [THROW_ID_01] resolvedOpts.progressFn must be a function! It was given of a type: "${typeof e.progressFn}", equal to ${JSON.stringify(e.progressFn,null,4)}`);if(![1,2,"1","2"].includes(e.mergeType))throw new Error(`ranges-merge: [THROW_ID_02] resolvedOpts.mergeType was customised to a wrong thing! It was given of a type: "${typeof e.mergeType}", equal to ${JSON.stringify(e.mergeType,null,4)}`);if(typeof e.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 e.joinRangesThatTouchEdges}", equal to ${JSON.stringify(e.joinRangesThatTouchEdges,null,4)}`)}else throw new Error(`emlint: [THROW_ID_03] the second input argument must be a plain object. It was given as:
import{collWhitespace as y}from"string-collapse-leading-whitespace";var b={strictlyTwoElementsInRangeArrays:!1,progressFn:null};function m(i,r){if(!Array.isArray(i)||!i.length)return i;let t={...b,...r},e,l;if(t.strictlyTwoElementsInRangeArrays&&!i.every((o,g)=>!Array.isArray(o)||o.length!==2?(e=g,l=o.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, ${e}th range (${JSON.stringify(i[e],null,4)}) has not two but ${l} elements!`);if(!i.every((o,g)=>!Array.isArray(o)||!Number.isInteger(o[0])||o[0]<0||!Number.isInteger(o[1])||o[1]<0?(e=g,!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, ${e}th range (${JSON.stringify(i[e],null,4)}) does not consist of only natural numbers!`);let n=i.length**2,a=0;return Array.from(i).sort((o,g)=>(t.progressFn&&(a+=1,t.progressFn(Math.floor(a*100/n))),o[0]===g[0]?o[1]<g[1]?-1:o[1]>g[1]?1:0:o[0]<g[0]?-1:1))}var d="6.2.1";var c={mergeType:1,progressFn:null,joinRangesThatTouchEdges:!0};function f(i,r){function t(s){return!!s&&typeof s=="object"&&!Array.isArray(s)}if(!Array.isArray(i)||!i.length)return null;let e;if(r)if(t(r)){if(e={...c,...r},e.progressFn&&t(e.progressFn)&&!Object.keys(e.progressFn).length)e.progressFn=null;else if(e.progressFn&&typeof e.progressFn!="function")throw new Error(`ranges-merge: [THROW_ID_01] resolvedOpts.progressFn must be a function! It was given of a type: "${typeof e.progressFn}", equal to ${JSON.stringify(e.progressFn,null,4)}`);if(![1,2,"1","2"].includes(e.mergeType))throw new Error(`ranges-merge: [THROW_ID_02] resolvedOpts.mergeType was customised to a wrong thing! It was given of a type: "${typeof e.mergeType}", equal to ${JSON.stringify(e.mergeType,null,4)}`);if(typeof e.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 e.joinRangesThatTouchEdges}", equal to ${JSON.stringify(e.joinRangesThatTouchEdges,null,4)}`)}else throw new Error(`emlint: [THROW_ID_03] the second input argument must be a plain object. It was given as:
${JSON.stringify(r,null,4)} (type ${typeof r})`);else e={...c};let l=i.filter(s=>Array.isArray(s)).map(s=>[...s]).filter(s=>s[2]!==void 0||s[0]!==s[1]),n,a,o;e.progressFn?n=m(l,{progressFn:s=>{o=Math.floor(s/5),o!==a&&(a=o,e.progressFn(o))}}):n=m(l);let g=n.length-1;for(let s=g;s>0;s--)e.progressFn&&(o=Math.floor((1-s/g)*78)+21,o!==a&&o>a&&(a=o,e.progressFn(o))),(n[s][0]<=n[s-1][0]||!e.joinRangesThatTouchEdges&&n[s][0]<n[s-1][1]||e.joinRangesThatTouchEdges&&n[s][0]<=n[s-1][1])&&(n[s-1][0]=Math.min(n[s][0],n[s-1][0]),n[s-1][1]=Math.max(n[s][1],n[s-1][1]),n[s][2]!==void 0&&(n[s-1][0]>=n[s][0]||n[s-1][1]<=n[s][1])&&n[s-1][2]!==null&&(n[s][2]===null&&n[s-1][2]!==null?n[s-1][2]=null:n[s-1][2]!=null?+e.mergeType==2&&n[s-1][0]===n[s][0]?n[s-1][2]=n[s][2]:n[s-1][2]+=n[s][2]:n[s-1][2]=n[s][2]),n.splice(s,1),s=n.length);return n.length?n:null}var I=d;function u(i){return i!=null}function p(i){return Number.isInteger(i)&&i>=0}function h(i){return typeof i=="string"}var T={limitToBeAddedWhitespace:!1,limitLinebreaksCount:1,mergeType:1},$=class{constructor(r){let t={...T,...r};if(t.mergeType&&t.mergeType!==1&&t.mergeType!==2)if(h(t.mergeType)&&t.mergeType.trim()==="1")t.mergeType=1;else if(h(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=[]}ranges;opts;add(r,t,e){if(r==null&&t==null)return;if(u(r)&&!u(t)){if(Array.isArray(r)){if(r.length){if(r.some(a=>Array.isArray(a))){r.forEach(a=>{Array.isArray(a)&&this.add(...a)});return}r.length&&p(+r[0])&&p(+r[1])&&this.add(...r)}return}throw new TypeError(`ranges-push/Ranges/add(): [THROW_ID_12] the first input argument, "from" is set (${JSON.stringify(r,null,0)}) but second-one, "to" is not (${JSON.stringify(t,null,0)})`)}else if(!u(r)&&u(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(r,null,0)})`);let l=+r,n=+t;if(p(e)&&(e=String(e)),p(l)&&p(n)){if(u(e)&&!h(e)&&!p(e))throw new TypeError(`ranges-push/Ranges/add(): [THROW_ID_08] The third argument, the value to add, was given not as string but ${typeof e}, equal to:

@@ -17,3 +17,3 @@ ${JSON.stringify(e,null,4)}`);if(u(this.ranges)&&Array.isArray(this.last())&&l===this.last()[1]){if(this.last()[1]=n,this.last()[2],this.last()[2]!==null&&u(e)){let a=this.last()[2]&&this.last()[2].length&&(!this.opts||!this.opts.mergeType||this.opts.mergeType===1)?`${this.last()[2]}${e}`:e;this.opts.limitToBeAddedWhitespace&&(a=y(a,this.opts.limitLinebreaksCount)),h(a)&&!a.length||(this.last()[2]=a)}}else{this.ranges||(this.ranges=[]);let a=e!==void 0&&!(h(e)&&!e.length)?[l,n,e&&this.opts.limitToBeAddedWhitespace?y(e,this.opts.limitLinebreaksCount):e]:[l,n];this.ranges.push(a)}}else throw p(l)&&l>=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 n}" equal to: ${JSON.stringify(n,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 l}" equal to: ${JSON.stringify(l,null,4)}`)}push(r,t,e){this.add(r,t,e)}current(){return Array.isArray(this.ranges)&&this.ranges.length?(this.ranges=f(this.ranges,{mergeType:this.opts.mergeType}),this.ranges&&this.opts.limitToBeAddedWhitespace?this.ranges.map(r=>u(r[2])?[r[0],r[1],y(r[2],this.opts.limitLinebreaksCount)]:r):this.ranges):null}wipe(){this.ranges=[]}replace(r){if(Array.isArray(r)&&r.length)if(Array.isArray(r[0])&&p(r[0][0]))this.ranges=Array.from(r);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(r[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}};export{$ as Ranges,T as defaults,I as version};

* @fileoverview Sort string index ranges
* @version 5.1.0
* @version 5.1.1
* @author Roy Revelt, Codsen Ltd

@@ -20,0 +20,0 @@ * @license MIT

@@ -1,5 +0,5 @@

"use strict";/**
/**
* @name ranges-push
* @fileoverview Gather string index ranges
* @version 6.2.0
* @version 6.2.1
* @author Roy Revelt, Codsen Ltd

@@ -10,6 +10,6 @@ * @license MIT

var rangesPush=(()=>{var d=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames,w=Object.getOwnPropertySymbols;var D=Object.prototype.hasOwnProperty,J=Object.prototype.propertyIsEnumerable;var b=(r,n,o)=>n in r?d(r,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[n]=o,p=(r,n)=>{for(var o in n||(n={}))D.call(n,o)&&b(r,o,n[o]);if(w)for(var o of w(n))J.call(n,o)&&b(r,o,n[o]);return r};var _=(r,n)=>{for(var o in n)d(r,o,{get:n[o],enumerable:!0})},W=(r,n,o,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let g of x(n))!D.call(r,g)&&g!==o&&d(r,g,{get:()=>n[g],enumerable:!(s=I(n,g))||s.enumerable});return r};var j=r=>W(d({},"__esModule",{value:!0}),r);var R=(r,n,o)=>(b(r,typeof n!="symbol"?n+"":n,o),o);var k={};_(k,{Ranges:()=>E,defaults:()=>V,version:()=>H});function $(r,n=1){let o="\xA0";function s(e){return Array.from(e).reverse().join("")}function g(e,a,i){let l=i?`
"use strict";var rangesPush=(()=>{var d=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames,w=Object.getOwnPropertySymbols;var D=Object.prototype.hasOwnProperty,J=Object.prototype.propertyIsEnumerable;var b=(r,n,o)=>n in r?d(r,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[n]=o,p=(r,n)=>{for(var o in n||(n={}))D.call(n,o)&&b(r,o,n[o]);if(w)for(var o of w(n))J.call(n,o)&&b(r,o,n[o]);return r};var _=(r,n)=>{for(var o in n)d(r,o,{get:n[o],enumerable:!0})},W=(r,n,o,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let g of x(n))!D.call(r,g)&&g!==o&&d(r,g,{get:()=>n[g],enumerable:!(s=I(n,g))||s.enumerable});return r};var j=r=>W(d({},"__esModule",{value:!0}),r);var R=(r,n,o)=>(b(r,typeof n!="symbol"?n+"":n,o),o);var k={};_(k,{Ranges:()=>E,defaults:()=>V,version:()=>H});function $(r,n=1){let o="\xA0";function s(e){return Array.from(e).reverse().join("")}function g(e,a,i){let l=i?`
`:"\r",t=i?"\r":`
`;if(!e)return e;let O=0,y=0,c="";for(let u=0,v=e.length;u<v;u++)(e[u]===l||e[u]===t&&e[u-1]!==l)&&y++,`\r
`.includes(e[u])||e[u]===o?(O=0,e[u]===o?c+=e[u]:e[u]===l?y<=a&&(c+=e[u],e[u+1]===t&&(c+=e[u+1],u++)):e[u]===t&&(!e[u-1]||e[u-1]!==l)&&y<=a&&(c+=e[u])):(O++,!e[u+1]&&!y&&(c+=" "));return c}if(typeof r=="string"&&r.length){let e=1;typeof+n=="number"&&Number.isInteger(+n)&&+n>=0&&(e=+n);let a="",i="";if(!r.trim())a=r;else if(!r[0].trim()){for(let l=0,t=r.length;l<t;l++)if(r[l].trim()){a=r.slice(0,l);break}}if(r.trim()&&(r.slice(-1).trim()===""||r.slice(-1)===o)){for(let l=r.length;l--;)if(r[l].trim()){i=r.slice(l+1);break}}return`${g(a,e,!1)}${r.trim()}${s(g(s(i),e,!0))}`}return r}var F={strictlyTwoElementsInRangeArrays:!1,progressFn:null};function T(r,n){if(!Array.isArray(r)||!r.length)return r;let o=p(p({},F),n),s,g;if(o.strictlyTwoElementsInRangeArrays&&!r.every((i,l)=>!Array.isArray(i)||i.length!==2?(s=l,g=i.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, ${s}th range (${JSON.stringify(r[s],null,4)}) has not two but ${g} elements!`);if(!r.every((i,l)=>!Array.isArray(i)||!Number.isInteger(i[0])||i[0]<0||!Number.isInteger(i[1])||i[1]<0?(s=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, ${s}th range (${JSON.stringify(r[s],null,4)}) does not consist of only natural numbers!`);let e=r.length**2,a=0;return Array.from(r).sort((i,l)=>(o.progressFn&&(a+=1,o.progressFn(Math.floor(a*100/e))),i[0]===l[0]?i[1]<l[1]?-1:i[1]>l[1]?1:0:i[0]<l[0]?-1:1))}var A="6.2.0";var N={mergeType:1,progressFn:null,joinRangesThatTouchEdges:!0};function S(r,n){function o(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}if(!Array.isArray(r)||!r.length)return null;let s;if(n)if(o(n)){if(s=p(p({},N),n),s.progressFn&&o(s.progressFn)&&!Object.keys(s.progressFn).length)s.progressFn=null;else if(s.progressFn&&typeof s.progressFn!="function")throw new Error(`ranges-merge: [THROW_ID_01] resolvedOpts.progressFn must be a function! It was given of a type: "${typeof s.progressFn}", equal to ${JSON.stringify(s.progressFn,null,4)}`);if(![1,2,"1","2"].includes(s.mergeType))throw new Error(`ranges-merge: [THROW_ID_02] resolvedOpts.mergeType was customised to a wrong thing! It was given of a type: "${typeof s.mergeType}", equal to ${JSON.stringify(s.mergeType,null,4)}`);if(typeof s.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 s.joinRangesThatTouchEdges}", equal to ${JSON.stringify(s.joinRangesThatTouchEdges,null,4)}`)}else throw new Error(`emlint: [THROW_ID_03] the second input argument must be a plain object. It was given as:
`.includes(e[u])||e[u]===o?(O=0,e[u]===o?c+=e[u]:e[u]===l?y<=a&&(c+=e[u],e[u+1]===t&&(c+=e[u+1],u++)):e[u]===t&&(!e[u-1]||e[u-1]!==l)&&y<=a&&(c+=e[u])):(O++,!e[u+1]&&!y&&(c+=" "));return c}if(typeof r=="string"&&r.length){let e=1;typeof+n=="number"&&Number.isInteger(+n)&&+n>=0&&(e=+n);let a="",i="";if(!r.trim())a=r;else if(!r[0].trim()){for(let l=0,t=r.length;l<t;l++)if(r[l].trim()){a=r.slice(0,l);break}}if(r.trim()&&(r.slice(-1).trim()===""||r.slice(-1)===o)){for(let l=r.length;l--;)if(r[l].trim()){i=r.slice(l+1);break}}return`${g(a,e,!1)}${r.trim()}${s(g(s(i),e,!0))}`}return r}var F={strictlyTwoElementsInRangeArrays:!1,progressFn:null};function T(r,n){if(!Array.isArray(r)||!r.length)return r;let o=p(p({},F),n),s,g;if(o.strictlyTwoElementsInRangeArrays&&!r.every((i,l)=>!Array.isArray(i)||i.length!==2?(s=l,g=i.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, ${s}th range (${JSON.stringify(r[s],null,4)}) has not two but ${g} elements!`);if(!r.every((i,l)=>!Array.isArray(i)||!Number.isInteger(i[0])||i[0]<0||!Number.isInteger(i[1])||i[1]<0?(s=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, ${s}th range (${JSON.stringify(r[s],null,4)}) does not consist of only natural numbers!`);let e=r.length**2,a=0;return Array.from(r).sort((i,l)=>(o.progressFn&&(a+=1,o.progressFn(Math.floor(a*100/e))),i[0]===l[0]?i[1]<l[1]?-1:i[1]>l[1]?1:0:i[0]<l[0]?-1:1))}var A="6.2.1";var N={mergeType:1,progressFn:null,joinRangesThatTouchEdges:!0};function S(r,n){function o(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}if(!Array.isArray(r)||!r.length)return null;let s;if(n)if(o(n)){if(s=p(p({},N),n),s.progressFn&&o(s.progressFn)&&!Object.keys(s.progressFn).length)s.progressFn=null;else if(s.progressFn&&typeof s.progressFn!="function")throw new Error(`ranges-merge: [THROW_ID_01] resolvedOpts.progressFn must be a function! It was given of a type: "${typeof s.progressFn}", equal to ${JSON.stringify(s.progressFn,null,4)}`);if(![1,2,"1","2"].includes(s.mergeType))throw new Error(`ranges-merge: [THROW_ID_02] resolvedOpts.mergeType was customised to a wrong thing! It was given of a type: "${typeof s.mergeType}", equal to ${JSON.stringify(s.mergeType,null,4)}`);if(typeof s.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 s.joinRangesThatTouchEdges}", equal to ${JSON.stringify(s.joinRangesThatTouchEdges,null,4)}`)}else throw new Error(`emlint: [THROW_ID_03] the second input argument must be a plain object. It was given as:
${JSON.stringify(n,null,4)} (type ${typeof n})`);else s=p({},N);let g=r.filter(t=>Array.isArray(t)).map(t=>[...t]).filter(t=>t[2]!==void 0||t[0]!==t[1]),e,a,i;s.progressFn?e=T(g,{progressFn:t=>{i=Math.floor(t/5),i!==a&&(a=i,s.progressFn(i))}}):e=T(g);let l=e.length-1;for(let t=l;t>0;t--)s.progressFn&&(i=Math.floor((1-t/l)*78)+21,i!==a&&i>a&&(a=i,s.progressFn(i))),(e[t][0]<=e[t-1][0]||!s.joinRangesThatTouchEdges&&e[t][0]<e[t-1][1]||s.joinRangesThatTouchEdges&&e[t][0]<=e[t-1][1])&&(e[t-1][0]=Math.min(e[t][0],e[t-1][0]),e[t-1][1]=Math.max(e[t][1],e[t-1][1]),e[t][2]!==void 0&&(e[t-1][0]>=e[t][0]||e[t-1][1]<=e[t][1])&&e[t-1][2]!==null&&(e[t][2]===null&&e[t-1][2]!==null?e[t-1][2]=null:e[t-1][2]!=null?+s.mergeType==2&&e[t-1][0]===e[t][0]?e[t-1][2]=e[t][2]:e[t-1][2]+=e[t][2]:e[t-1][2]=e[t][2]),e.splice(t,1),t=e.length);return e.length?e:null}var H=A;function m(r){return r!=null}function h(r){return Number.isInteger(r)&&r>=0}function f(r){return typeof r=="string"}var V={limitToBeAddedWhitespace:!1,limitLinebreaksCount:1,mergeType:1},E=class{constructor(n){R(this,"ranges");R(this,"opts");let o=p(p({},V),n);if(o.mergeType&&o.mergeType!==1&&o.mergeType!==2)if(f(o.mergeType)&&o.mergeType.trim()==="1")o.mergeType=1;else if(f(o.mergeType)&&o.mergeType.trim()==="2")o.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 o.mergeType}", equal to ${JSON.stringify(o.mergeType,null,4)}`);this.opts=o,this.ranges=[]}add(n,o,s){if(n==null&&o==null)return;if(m(n)&&!m(o)){if(Array.isArray(n)){if(n.length){if(n.some(a=>Array.isArray(a))){n.forEach(a=>{Array.isArray(a)&&this.add(...a)});return}n.length&&h(+n[0])&&h(+n[1])&&this.add(...n)}return}throw new TypeError(`ranges-push/Ranges/add(): [THROW_ID_12] the first input argument, "from" is set (${JSON.stringify(n,null,0)}) but second-one, "to" is not (${JSON.stringify(o,null,0)})`)}else if(!m(n)&&m(o))throw new TypeError(`ranges-push/Ranges/add(): [THROW_ID_13] the second input argument, "to" is set (${JSON.stringify(o,null,0)}) but first-one, "from" is not (${JSON.stringify(n,null,0)})`);let g=+n,e=+o;if(h(s)&&(s=String(s)),h(g)&&h(e)){if(m(s)&&!f(s)&&!h(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:

@@ -20,3 +20,3 @@ ${JSON.stringify(s,null,4)}`);if(m(this.ranges)&&Array.isArray(this.last())&&g===this.last()[1]){if(this.last()[1]=e,this.last()[2],this.last()[2]!==null&&m(s)){let a=this.last()[2]&&this.last()[2].length&&(!this.opts||!this.opts.mergeType||this.opts.mergeType===1)?`${this.last()[2]}${s}`:s;this.opts.limitToBeAddedWhitespace&&(a=$(a,this.opts.limitLinebreaksCount)),f(a)&&!a.length||(this.last()[2]=a)}}else{this.ranges||(this.ranges=[]);let a=s!==void 0&&!(f(s)&&!s.length)?[g,e,s&&this.opts.limitToBeAddedWhitespace?$(s,this.opts.limitLinebreaksCount):s]:[g,e];this.ranges.push(a)}}else throw h(g)&&g>=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 e}" equal to: ${JSON.stringify(e,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 g}" equal to: ${JSON.stringify(g,null,4)}`)}push(n,o,s){this.add(n,o,s)}current(){return Array.isArray(this.ranges)&&this.ranges.length?(this.ranges=S(this.ranges,{mergeType:this.opts.mergeType}),this.ranges&&this.opts.limitToBeAddedWhitespace?this.ranges.map(n=>m(n[2])?[n[0],n[1],$(n[2],this.opts.limitLinebreaksCount)]:n):this.ranges):null}wipe(){this.ranges=[]}replace(n){if(Array.isArray(n)&&n.length)if(Array.isArray(n[0])&&h(n[0][0]))this.ranges=Array.from(n);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(n[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}};return j(k);})();

* @fileoverview Sort string index ranges
* @version 5.1.0
* @version 5.1.1
* @author Roy Revelt, Codsen Ltd

@@ -29,3 +29,3 @@ * @license MIT

* @fileoverview Collapse the leading and trailing whitespace of a string
* @version 6.1.0
* @version 6.1.1
* @author Roy Revelt, Codsen Ltd

@@ -32,0 +32,0 @@ * @license MIT

{
"name": "ranges-push",
"version": "6.2.0",
"version": "6.2.1",
"description": "Gather string index ranges",

@@ -17,3 +17,3 @@ "keywords": [

],
"homepage": "https://codsen.com/os/ranges-push/",
"homepage": "https://codsen.com/os/ranges-push",
"repository": {

@@ -73,5 +73,5 @@ "type": "git",

"dependencies": {
"string-collapse-leading-whitespace": "^6.1.0",
"string-trim-spaces-only": "^4.1.0"
"string-collapse-leading-whitespace": "^6.1.1",
"string-trim-spaces-only": "^4.1.1"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc