ranges-iterate 3.0.10 → 3.0.11
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/LICENSE +1 -1
- package/README.md +2 -6
- package/dist/ranges-iterate.esm.js +2 -2
- package/dist/ranges-iterate.umd.js +2 -2
- package/package.json +6 -4
- package/types/index.d.ts +11 -4
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2010-
|
|
3
|
+
Copyright (c) 2010-2022 Roy Revelt and other contributors
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
6
|
a copy of this software and associated documentation files (the
|
package/README.md
CHANGED
|
@@ -26,14 +26,12 @@
|
|
|
26
26
|
|
|
27
27
|
## Install
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
The latest version is **ESM only**: Node 12+ is needed to use it and it must be `import`ed instead of `require`d. If your project is not on ESM yet and you want to use `require`, use an older version of this program, `2.1.0`.
|
|
30
30
|
|
|
31
31
|
```bash
|
|
32
32
|
npm i ranges-iterate
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
If you need a legacy version which works with `require`, use version 2.1.0
|
|
36
|
-
|
|
37
35
|
## Quick Take
|
|
38
36
|
|
|
39
37
|
```js
|
|
@@ -73,8 +71,6 @@ To report bugs or request features or assistance, [raise an issue](https://githu
|
|
|
73
71
|
|
|
74
72
|
MIT License
|
|
75
73
|
|
|
76
|
-
Copyright (c) 2010-
|
|
77
|
-
|
|
74
|
+
Copyright (c) 2010-2022 Roy Revelt and other contributors
|
|
78
75
|
|
|
79
76
|
<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">
|
|
80
|
-
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name ranges-iterate
|
|
3
3
|
* @fileoverview Iterate a string and any changes within given string index ranges
|
|
4
|
-
* @version 3.0.
|
|
4
|
+
* @version 3.0.11
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/ranges-iterate/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
var c="3.0.
|
|
10
|
+
var c="3.0.11";var f=c;function b(t,o,n,a=0){if(typeof t!="string")throw new TypeError(`ranges-iterate: [THROW_ID_01] Input string must be a string! It was given as ${typeof t}, equal to: ${JSON.stringify(t,null,0)}`);if(!t.length)throw new TypeError("ranges-iterate: [THROW_ID_02] Input string must be non-empty!");if(o&&!Array.isArray(o))throw new TypeError(`ranges-iterate: [THROW_ID_03] Input ranges must be an array, consisting of zero or more arrays! Currently its type is: ${typeof o}, equal to: ${JSON.stringify(o,null,0)}`);if(n){if(typeof n!="function")throw new TypeError(`ranges-iterate: [THROW_ID_05] The calllback function (third input argument) must be a function. It was given as: ${typeof n}, equal to: ${JSON.stringify(n,null,0)}`)}else throw new TypeError("ranges-iterate: [THROW_ID_04] You should provide a callback function as third input argument!");if(o===null||!o.length)for(let e=0;e<t.length;e++)n({i:e,val:t[e]});else{let e=Array.from(o),i=a,r=a;if(r<e[0][0])for(;r<e[0][0]&&t[r];r++,i++)n({i:r,val:t[r]});e[0][0]<=i&&e.forEach((s,u)=>{if(s[2])for(let l=0,p=s[2].length;l<p;l++)n({i:r,val:s[2][l]}),r+=1;for(;i<s[1];)i+=1;let $=t.length;for(e[u+1]&&($=e[u+1][0]);i<$;r++,i++)n({i:r,val:t[i]})})}}export{b as rIterate,f as version};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name ranges-iterate
|
|
3
3
|
* @fileoverview Iterate a string and any changes within given string index ranges
|
|
4
|
-
* @version 3.0.
|
|
4
|
+
* @version 3.0.11
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/ranges-iterate/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
var rangesIterate=(()=>{var
|
|
10
|
+
var rangesIterate=(()=>{var u=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var b=e=>u(e,"__esModule",{value:!0});var y=(e,t)=>{for(var r in t)u(e,r,{get:t[r],enumerable:!0})},x=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of g(t))!f.call(e,n)&&(r||n!=="default")&&u(e,n,{get:()=>t[n],enumerable:!(s=m(t,n))||s.enumerable});return e};var I=(e=>(t,r)=>e&&e.get(t)||(r=x(b({}),t,1),e&&e.set(t,r),r))(typeof WeakMap!="undefined"?new WeakMap:0);var v={};y(v,{rIterate:()=>E,version:()=>D});var p="3.0.11";var D=p;function E(e,t,r,s=0){if(typeof e!="string")throw new TypeError(`ranges-iterate: [THROW_ID_01] Input string must be a string! It was given as ${typeof e}, equal to: ${JSON.stringify(e,null,0)}`);if(!e.length)throw new TypeError("ranges-iterate: [THROW_ID_02] Input string must be non-empty!");if(t&&!Array.isArray(t))throw new TypeError(`ranges-iterate: [THROW_ID_03] Input ranges must be an array, consisting of zero or more arrays! Currently its type is: ${typeof t}, equal to: ${JSON.stringify(t,null,0)}`);if(r){if(typeof r!="function")throw new TypeError(`ranges-iterate: [THROW_ID_05] The calllback function (third input argument) must be a function. It was given as: ${typeof r}, equal to: ${JSON.stringify(r,null,0)}`)}else throw new TypeError("ranges-iterate: [THROW_ID_04] You should provide a callback function as third input argument!");if(t===null||!t.length)for(let n=0;n<e.length;n++)r({i:n,val:e[n]});else{let n=Array.from(t),i=s,o=s;if(o<n[0][0])for(;o<n[0][0]&&e[o];o++,i++)r({i:o,val:e[o]});n[0][0]<=i&&n.forEach((l,$)=>{if(l[2])for(let a=0,d=l[2].length;a<d;a++)r({i:o,val:l[2][a]}),o+=1;for(;i<l[1];)i+=1;let c=e.length;for(n[$+1]&&(c=n[$+1][0]);i<c;o++,i++)r({i:o,val:e[i]})})}}return I(v);})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ranges-iterate",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.11",
|
|
4
4
|
"description": "Iterate a string and any changes within given string index ranges",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"array",
|
|
@@ -35,13 +35,15 @@
|
|
|
35
35
|
"scripts": {
|
|
36
36
|
"build": "node '../../ops/scripts/esbuild.js' && yarn run dts",
|
|
37
37
|
"dev": "DEV=true node '../../ops/scripts/esbuild.js' && yarn run dts",
|
|
38
|
-
"dts": "rollup -c",
|
|
38
|
+
"dts": "rollup -c && yarn run prettier 'types/index.d.ts' --write",
|
|
39
39
|
"examples": "node '../../ops/scripts/run-examples.js'",
|
|
40
40
|
"lect": "node '../../ops/lect/lect.js'",
|
|
41
41
|
"letspublish": "yarn publish || :",
|
|
42
42
|
"lint": "eslint . --fix",
|
|
43
43
|
"perf": "node perf/check.js",
|
|
44
44
|
"prepare": "echo 'ready'",
|
|
45
|
+
"prettier": "prettier",
|
|
46
|
+
"prettier:format": "prettier --write '**/*.{ts,tsx,md}' --no-error-on-unmatched-pattern",
|
|
45
47
|
"pretest": "yarn run lect && yarn run build",
|
|
46
48
|
"test": "c8 yarn run unit && yarn run examples && yarn run lint",
|
|
47
49
|
"unit": "uvu test"
|
|
@@ -64,7 +66,7 @@
|
|
|
64
66
|
}
|
|
65
67
|
},
|
|
66
68
|
"devDependencies": {
|
|
67
|
-
"ranges-apply": "^6.0.
|
|
68
|
-
"ranges-merge": "^8.0.
|
|
69
|
+
"ranges-apply": "^6.0.11",
|
|
70
|
+
"ranges-merge": "^8.0.11"
|
|
69
71
|
}
|
|
70
72
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
declare type Range =
|
|
1
|
+
declare type Range =
|
|
2
|
+
| [from: number, to: number]
|
|
3
|
+
| [from: number, to: number, whatToInsert: string | null | undefined];
|
|
2
4
|
declare type Ranges = Range[] | null;
|
|
3
5
|
|
|
4
6
|
declare const version: string;
|
|
5
7
|
interface Obj {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
i: number;
|
|
9
|
+
val: any;
|
|
8
10
|
}
|
|
9
11
|
declare type Callback = (obj: Obj) => void;
|
|
10
|
-
declare function rIterate(
|
|
12
|
+
declare function rIterate(
|
|
13
|
+
str: string,
|
|
14
|
+
originalRanges: Ranges,
|
|
15
|
+
cb: Callback,
|
|
16
|
+
offset?: number
|
|
17
|
+
): void;
|
|
11
18
|
|
|
12
19
|
export { rIterate, version };
|