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

ranges-apply

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-apply - npm Package Compare versions

Comparing version 7.0.8 to 7.0.9

4

dist/ranges-apply.esm.js
/**
* @name ranges-apply
* @fileoverview Take an array of string index ranges, delete/replace the string according to them
* @version 7.0.8
* @version 7.0.9
* @author Roy Revelt, Codsen Ltd

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

import{rMerge as b}from"ranges-merge";import w from"tiny-invariant";var m="7.0.8";var T=m;function _(s,n,r){let t=0,p=0;if(arguments.length===0)throw new Error("ranges-apply: [THROW_ID_01] inputs missing!");if(typeof s!="string")throw new TypeError(`ranges-apply: [THROW_ID_02] first input argument must be a string! Currently it's: ${typeof s}, equal to: ${JSON.stringify(s,null,4)}`);if(n&&!Array.isArray(n))throw new TypeError(`ranges-apply: [THROW_ID_03] second input argument must be an array (or null)! Currently it's: ${typeof n}, equal to: ${JSON.stringify(n,null,4)}`);if(r&&typeof r!="function")throw new TypeError(`ranges-apply: [THROW_ID_04] the third input argument must be a function (or falsey)! Currently it's: ${typeof r}, equal to: ${JSON.stringify(r,null,4)}`);if(!n||!n.filter(e=>e).length)return s;let i;Array.isArray(n)&&Number.isInteger(n[0])&&Number.isInteger(n[1])?i=[Array.from(n)]:i=Array.from(n);let f=i.length,c=0;i.filter(e=>e).forEach((e,a)=>{if(r&&(t=Math.floor(c/f*10),t!==p&&(p=t,r(t))),!Array.isArray(e))throw new TypeError(`ranges-apply: [THROW_ID_05] ranges array, second input arg., has ${a}th element not an array: ${JSON.stringify(e,null,4)}, which is ${typeof e}`);if(!Number.isInteger(e[0])){if(!Number.isInteger(+e[0])||+e[0]<0)throw new TypeError(`ranges-apply: [THROW_ID_06] ranges array, second input arg. has ${a}th element, array ${JSON.stringify(e,null,0)}. Its first element is not an integer, string index, but ${typeof e[0]}, equal to: ${JSON.stringify(e[0],null,4)}.`);i[a][0]=+i[a][0]}if(!Number.isInteger(e[1])){if(!Number.isInteger(+e[1])||+e[1]<0)throw new TypeError(`ranges-apply: [THROW_ID_07] ranges array, second input arg. has ${a}th element, array ${JSON.stringify(e,null,0)}. Its second element is not an integer, string index, but ${typeof e[1]}, equal to: ${JSON.stringify(e[1],null,4)}.`);i[a][1]=+i[a][1]}c+=1});let o=b(i,{progressFn:e=>{r&&(t=10+Math.floor(e/10),t!==p&&(p=t,r(t)))}});w(o);let u=o.length;if(u>0){let e=s.slice(o[u-1][1]);s=o.reduce((a,$,l,y)=>{r&&(t=20+Math.floor(l/u*80),t!==p&&(p=t,r(t)));let g=l===0?0:y[l-1][1],d=y[l][0];return`${a}${s.slice(g,d)}${y[l][2]||""}`},""),s+=e}return s}export{_ as rApply,T as version};
import{rMerge as b}from"ranges-merge";import w from"tiny-invariant";var m="7.0.9";var T=m;function _(s,n,r){let t=0,p=0;if(arguments.length===0)throw new Error("ranges-apply: [THROW_ID_01] inputs missing!");if(typeof s!="string")throw new TypeError(`ranges-apply: [THROW_ID_02] first input argument must be a string! Currently it's: ${typeof s}, equal to: ${JSON.stringify(s,null,4)}`);if(n&&!Array.isArray(n))throw new TypeError(`ranges-apply: [THROW_ID_03] second input argument must be an array (or null)! Currently it's: ${typeof n}, equal to: ${JSON.stringify(n,null,4)}`);if(r&&typeof r!="function")throw new TypeError(`ranges-apply: [THROW_ID_04] the third input argument must be a function (or falsey)! Currently it's: ${typeof r}, equal to: ${JSON.stringify(r,null,4)}`);if(!n?.filter(e=>e).length)return s;let i;Array.isArray(n)&&Number.isInteger(n[0])&&Number.isInteger(n[1])?i=[Array.from(n)]:i=Array.from(n);let f=i.length,c=0;i.filter(e=>e).forEach((e,a)=>{if(r&&(t=Math.floor(c/f*10),t!==p&&(p=t,r(t))),!Array.isArray(e))throw new TypeError(`ranges-apply: [THROW_ID_05] ranges array, second input arg., has ${a}th element not an array: ${JSON.stringify(e,null,4)}, which is ${typeof e}`);if(!Number.isInteger(e[0])){if(!Number.isInteger(+e[0])||+e[0]<0)throw new TypeError(`ranges-apply: [THROW_ID_06] ranges array, second input arg. has ${a}th element, array ${JSON.stringify(e,null,0)}. Its first element is not an integer, string index, but ${typeof e[0]}, equal to: ${JSON.stringify(e[0],null,4)}.`);i[a][0]=+i[a][0]}if(!Number.isInteger(e[1])){if(!Number.isInteger(+e[1])||+e[1]<0)throw new TypeError(`ranges-apply: [THROW_ID_07] ranges array, second input arg. has ${a}th element, array ${JSON.stringify(e,null,0)}. Its second element is not an integer, string index, but ${typeof e[1]}, equal to: ${JSON.stringify(e[1],null,4)}.`);i[a][1]=+i[a][1]}c+=1});let o=b(i,{progressFn:e=>{r&&(t=10+Math.floor(e/10),t!==p&&(p=t,r(t)))}});w(o);let u=o.length;if(u>0){let e=s.slice(o[u-1][1]);s=o.reduce((a,$,l,y)=>{r&&(t=20+Math.floor(l/u*80),t!==p&&(p=t,r(t)));let g=l===0?0:y[l-1][1],d=y[l][0];return`${a}${s.slice(g,d)}${y[l][2]||""}`},""),s+=e}return s}export{_ as rApply,T as version};
/**
* @name ranges-apply
* @fileoverview Take an array of string index ranges, delete/replace the string according to them
* @version 7.0.8
* @version 7.0.9
* @author Roy Revelt, Codsen Ltd

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

"use strict";var rangesApply=(()=>{var c=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames,w=Object.getOwnPropertySymbols;var v=Object.prototype.hasOwnProperty,R=Object.prototype.propertyIsEnumerable;var T=(s,t,o)=>t in s?c(s,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):s[t]=o,y=(s,t)=>{for(var o in t||(t={}))v.call(t,o)&&T(s,o,t[o]);if(w)for(var o of w(t))R.call(t,o)&&T(s,o,t[o]);return s};var j=(s,t)=>{for(var o in t)c(s,o,{get:t[o],enumerable:!0})},D=(s,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of N(t))!v.call(s,l)&&l!==o&&c(s,l,{get:()=>t[l],enumerable:!(n=_(t,l))||n.enumerable});return s};var A=s=>D(c({},"__esModule",{value:!0}),s);var F={};j(F,{rApply:()=>M,version:()=>W});var S={strictlyTwoElementsInRangeArrays:!1,progressFn:null};function d(s,t){if(!Array.isArray(s)||!s.length)return s;let o=y(y({},S),t),n,l;if(o.strictlyTwoElementsInRangeArrays&&!s.every((a,p)=>!Array.isArray(a)||a.length!==2?(n=p,l=a.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(s[n],null,4)}) has not two but ${l} elements!`);if(!s.every((a,p)=>!Array.isArray(a)||!Number.isInteger(a[0])||a[0]<0||!Number.isInteger(a[1])||a[1]<0?(n=p,!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(s[n],null,4)}) does not consist of only natural numbers!`);let r=s.length**2,u=0;return Array.from(s).sort((a,p)=>(o.progressFn&&(u+=1,o.progressFn(Math.floor(u*100/r))),a[0]===p[0]?a[1]<p[1]?-1:a[1]>p[1]?1:0:a[0]<p[0]?-1:1))}var b={mergeType:1,progressFn:null,joinRangesThatTouchEdges:!0};function $(s,t){function o(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}if(!Array.isArray(s)||!s.length)return null;let n;if(t)if(o(t)){if(n=y(y({},b),t),n.progressFn&&o(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:
${JSON.stringify(t,null,4)} (type ${typeof t})`);else n=y({},b);let l=s.filter(e=>Array.isArray(e)).map(e=>[...e]).filter(e=>e[2]!==void 0||e[0]!==e[1]),r,u,a;n.progressFn?r=d(l,{progressFn:e=>{a=Math.floor(e/5),a!==u&&(u=a,n.progressFn(a))}}):r=d(l);let p=r.length-1;for(let e=p;e>0;e--)n.progressFn&&(a=Math.floor((1-e/p)*78)+21,a!==u&&a>u&&(u=a,n.progressFn(a))),(r[e][0]<=r[e-1][0]||!n.joinRangesThatTouchEdges&&r[e][0]<r[e-1][1]||n.joinRangesThatTouchEdges&&r[e][0]<=r[e-1][1])&&(r[e-1][0]=Math.min(r[e][0],r[e-1][0]),r[e-1][1]=Math.max(r[e][1],r[e-1][1]),r[e][2]!==void 0&&(r[e-1][0]>=r[e][0]||r[e-1][1]<=r[e][1])&&r[e-1][2]!==null&&(r[e][2]===null&&r[e-1][2]!==null?r[e-1][2]=null:r[e-1][2]!=null?+n.mergeType==2&&r[e-1][0]===r[e][0]?r[e-1][2]=r[e][2]:r[e-1][2]+=r[e][2]:r[e-1][2]=r[e][2]),r.splice(e,1),e=r.length);return r.length?r:null}var H=!0,h="Invariant failed";function I(s,t){if(!s){if(H)throw new Error(h);var o=typeof t=="function"?t():t,n=o?"".concat(h,": ").concat(o):h;throw new Error(n)}}var E="7.0.8";var W=E;function M(s,t,o){let n=0,l=0;if(arguments.length===0)throw new Error("ranges-apply: [THROW_ID_01] inputs missing!");if(typeof s!="string")throw new TypeError(`ranges-apply: [THROW_ID_02] first input argument must be a string! Currently it's: ${typeof s}, equal to: ${JSON.stringify(s,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(o&&typeof o!="function")throw new TypeError(`ranges-apply: [THROW_ID_04] the third input argument must be a function (or falsey)! Currently it's: ${typeof o}, equal to: ${JSON.stringify(o,null,4)}`);if(!t||!t.filter(i=>i).length)return s;let r;Array.isArray(t)&&Number.isInteger(t[0])&&Number.isInteger(t[1])?r=[Array.from(t)]:r=Array.from(t);let u=r.length,a=0;r.filter(i=>i).forEach((i,g)=>{if(o&&(n=Math.floor(a/u*10),n!==l&&(l=n,o(n))),!Array.isArray(i))throw new TypeError(`ranges-apply: [THROW_ID_05] ranges array, second input arg., has ${g}th element not an array: ${JSON.stringify(i,null,4)}, which is ${typeof i}`);if(!Number.isInteger(i[0])){if(!Number.isInteger(+i[0])||+i[0]<0)throw new TypeError(`ranges-apply: [THROW_ID_06] ranges array, second input arg. has ${g}th element, array ${JSON.stringify(i,null,0)}. Its first element is not an integer, string index, but ${typeof i[0]}, equal to: ${JSON.stringify(i[0],null,4)}.`);r[g][0]=+r[g][0]}if(!Number.isInteger(i[1])){if(!Number.isInteger(+i[1])||+i[1]<0)throw new TypeError(`ranges-apply: [THROW_ID_07] ranges array, second input arg. has ${g}th element, array ${JSON.stringify(i,null,0)}. Its second element is not an integer, string index, but ${typeof i[1]}, equal to: ${JSON.stringify(i[1],null,4)}.`);r[g][1]=+r[g][1]}a+=1});let p=$(r,{progressFn:i=>{o&&(n=10+Math.floor(i/10),n!==l&&(l=n,o(n)))}});I(p);let e=p.length;if(e>0){let i=s.slice(p[e-1][1]);s=p.reduce((g,q,f,m)=>{o&&(n=20+Math.floor(f/e*80),n!==l&&(l=n,o(n)));let O=f===0?0:m[f-1][1],x=m[f][0];return`${g}${s.slice(O,x)}${m[f][2]||""}`},""),s+=i}return s}return A(F);})();
"use strict";var rangesApply=(()=>{var c=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames,w=Object.getOwnPropertySymbols;var v=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable;var T=(s,n,o)=>n in s?c(s,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):s[n]=o,y=(s,n)=>{for(var o in n||(n={}))v.call(n,o)&&T(s,o,n[o]);if(w)for(var o of w(n))j.call(n,o)&&T(s,o,n[o]);return s};var D=(s,n)=>{for(var o in n)c(s,o,{get:n[o],enumerable:!0})},R=(s,n,o,t)=>{if(n&&typeof n=="object"||typeof n=="function")for(let l of N(n))!v.call(s,l)&&l!==o&&c(s,l,{get:()=>n[l],enumerable:!(t=_(n,l))||t.enumerable});return s};var S=s=>R(c({},"__esModule",{value:!0}),s);var F={};D(F,{rApply:()=>M,version:()=>A});var H={strictlyTwoElementsInRangeArrays:!1,progressFn:null};function d(s,n){if(!Array.isArray(s)||!s.length)return s;let o=y(y({},H),n),t,l;if(o.strictlyTwoElementsInRangeArrays&&!s.every((a,p)=>!Array.isArray(a)||a.length!==2?(t=p,l=a.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, ${t}th range (${JSON.stringify(s[t],null,4)}) has not two but ${l} elements!`);if(!s.every((a,p)=>!Array.isArray(a)||!Number.isInteger(a[0])||a[0]<0||!Number.isInteger(a[1])||a[1]<0?(t=p,!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, ${t}th range (${JSON.stringify(s[t],null,4)}) does not consist of only natural numbers!`);let r=s.length**2,u=0;return Array.from(s).sort((a,p)=>(o.progressFn&&(u+=1,o.progressFn(Math.floor(u*100/r))),a[0]===p[0]?a[1]<p[1]?-1:a[1]>p[1]?1:0:a[0]<p[0]?-1:1))}var b={mergeType:1,progressFn:null,joinRangesThatTouchEdges:!0};function $(s,n){function o(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}if(!Array.isArray(s)||!s.length)return null;let t;if(n)if(o(n)){if(t=y(y({},b),n),t.progressFn&&o(t.progressFn)&&!Object.keys(t.progressFn).length)t.progressFn=null;else if(t.progressFn&&typeof t.progressFn!="function")throw new Error(`ranges-merge: [THROW_ID_01] opts.progressFn must be a function! It was given of a type: "${typeof t.progressFn}", equal to ${JSON.stringify(t.progressFn,null,4)}`);if(![1,2,"1","2"].includes(t.mergeType))throw new Error(`ranges-merge: [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)}`);if(typeof t.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 t.joinRangesThatTouchEdges}", equal to ${JSON.stringify(t.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 t=y({},b);let l=s.filter(e=>Array.isArray(e)).map(e=>[...e]).filter(e=>e[2]!==void 0||e[0]!==e[1]),r,u,a;t.progressFn?r=d(l,{progressFn:e=>{a=Math.floor(e/5),a!==u&&(u=a,t.progressFn(a))}}):r=d(l);let p=r.length-1;for(let e=p;e>0;e--)t.progressFn&&(a=Math.floor((1-e/p)*78)+21,a!==u&&a>u&&(u=a,t.progressFn(a))),(r[e][0]<=r[e-1][0]||!t.joinRangesThatTouchEdges&&r[e][0]<r[e-1][1]||t.joinRangesThatTouchEdges&&r[e][0]<=r[e-1][1])&&(r[e-1][0]=Math.min(r[e][0],r[e-1][0]),r[e-1][1]=Math.max(r[e][1],r[e-1][1]),r[e][2]!==void 0&&(r[e-1][0]>=r[e][0]||r[e-1][1]<=r[e][1])&&r[e-1][2]!==null&&(r[e][2]===null&&r[e-1][2]!==null?r[e-1][2]=null:r[e-1][2]!=null?+t.mergeType==2&&r[e-1][0]===r[e][0]?r[e-1][2]=r[e][2]:r[e-1][2]+=r[e][2]:r[e-1][2]=r[e][2]),r.splice(e,1),e=r.length);return r.length?r:null}var J=!0,h="Invariant failed";function I(s,n){if(!s){if(J)throw new Error(h);var o=typeof n=="function"?n():n,t=o?"".concat(h,": ").concat(o):h;throw new Error(t)}}var E="7.0.9";var A=E;function M(s,n,o){let t=0,l=0;if(arguments.length===0)throw new Error("ranges-apply: [THROW_ID_01] inputs missing!");if(typeof s!="string")throw new TypeError(`ranges-apply: [THROW_ID_02] first input argument must be a string! Currently it's: ${typeof s}, equal to: ${JSON.stringify(s,null,4)}`);if(n&&!Array.isArray(n))throw new TypeError(`ranges-apply: [THROW_ID_03] second input argument must be an array (or null)! Currently it's: ${typeof n}, equal to: ${JSON.stringify(n,null,4)}`);if(o&&typeof o!="function")throw new TypeError(`ranges-apply: [THROW_ID_04] the third input argument must be a function (or falsey)! Currently it's: ${typeof o}, equal to: ${JSON.stringify(o,null,4)}`);if(!(n!=null&&n.filter(i=>i).length))return s;let r;Array.isArray(n)&&Number.isInteger(n[0])&&Number.isInteger(n[1])?r=[Array.from(n)]:r=Array.from(n);let u=r.length,a=0;r.filter(i=>i).forEach((i,g)=>{if(o&&(t=Math.floor(a/u*10),t!==l&&(l=t,o(t))),!Array.isArray(i))throw new TypeError(`ranges-apply: [THROW_ID_05] ranges array, second input arg., has ${g}th element not an array: ${JSON.stringify(i,null,4)}, which is ${typeof i}`);if(!Number.isInteger(i[0])){if(!Number.isInteger(+i[0])||+i[0]<0)throw new TypeError(`ranges-apply: [THROW_ID_06] ranges array, second input arg. has ${g}th element, array ${JSON.stringify(i,null,0)}. Its first element is not an integer, string index, but ${typeof i[0]}, equal to: ${JSON.stringify(i[0],null,4)}.`);r[g][0]=+r[g][0]}if(!Number.isInteger(i[1])){if(!Number.isInteger(+i[1])||+i[1]<0)throw new TypeError(`ranges-apply: [THROW_ID_07] ranges array, second input arg. has ${g}th element, array ${JSON.stringify(i,null,0)}. Its second element is not an integer, string index, but ${typeof i[1]}, equal to: ${JSON.stringify(i[1],null,4)}.`);r[g][1]=+r[g][1]}a+=1});let p=$(r,{progressFn:i=>{o&&(t=10+Math.floor(i/10),t!==l&&(l=t,o(t)))}});I(p);let e=p.length;if(e>0){let i=s.slice(p[e-1][1]);s=p.reduce((g,q,f,m)=>{o&&(t=20+Math.floor(f/e*80),t!==l&&(l=t,o(t)));let O=f===0?0:m[f-1][1],x=m[f][0];return`${g}${s.slice(O,x)}${m[f][2]||""}`},""),s+=i}return s}return S(F);})();
/**
* @name ranges-sort
* @fileoverview Sort string index ranges
* @version 6.0.7
* @version 6.0.8
* @author Roy Revelt, Codsen Ltd

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

* @fileoverview Merge and sort string index ranges
* @version 9.0.8
* @version 9.0.9
* @author Roy Revelt, Codsen Ltd

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

{
"name": "ranges-apply",
"version": "7.0.8",
"version": "7.0.9",
"description": "Take an array of string index ranges, delete/replace the string according to them",

@@ -73,5 +73,5 @@ "keywords": [

"dependencies": {
"ranges-merge": "^9.0.8",
"ranges-merge": "^9.0.9",
"tiny-invariant": "^1.3.1"
}
}

@@ -39,3 +39,3 @@ <h1 align="center">ranges-apply</h1>

const oldString = `The quick brown fox jumps over the lazy dog.`;
const oldString = "The quick brown fox jumps over the lazy dog.";
const ranges = [

@@ -42,0 +42,0 @@ [4, 19, "bad grey wolf"],

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