ranges-iterate 3.0.7 → 3.0.10

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 CHANGED
@@ -38,6 +38,7 @@ If you need a legacy version which works with `require`, use version 2.1.0
38
38
 
39
39
  ```js
40
40
  import { strict as assert } from "assert";
41
+
41
42
  import { rIterate } from "ranges-iterate";
42
43
 
43
44
  // Ranges in the following example "punches out" a "hole" from `a` to `g`
@@ -62,7 +63,7 @@ assert.deepEqual(gathered, [
62
63
 
63
64
  ## Documentation
64
65
 
65
- Please [visit codsen.com](https://codsen.com/os/ranges-iterate/) for a full description of the API and examples.
66
+ Please [visit codsen.com](https://codsen.com/os/ranges-iterate/) for a full description of the API.
66
67
 
67
68
  ## Contributing
68
69
 
@@ -74,4 +75,6 @@ MIT License
74
75
 
75
76
  Copyright (c) 2010-2021 Roy Revelt and other contributors
76
77
 
78
+
77
79
  <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,81 +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.7
4
+ * @version 3.0.10
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 version$1 = "3.0.7";
11
-
12
- const version = version$1;
13
- function rIterate(str, originalRanges, cb, offset = 0) {
14
- if (typeof str !== "string") {
15
- throw new TypeError(`ranges-iterate: [THROW_ID_01] Input string must be a string! It was given as ${typeof str}, equal to: ${JSON.stringify(str, null, 0)}`);
16
- }
17
- else if (!str.length) {
18
- throw new TypeError(`ranges-iterate: [THROW_ID_02] Input string must be non-empty!`);
19
- }
20
- if (originalRanges && !Array.isArray(originalRanges)) {
21
- 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 originalRanges}, equal to: ${JSON.stringify(originalRanges, null, 0)}`);
22
- }
23
- if (!cb) {
24
- throw new TypeError(`ranges-iterate: [THROW_ID_04] You should provide a callback function as third input argument!`);
25
- }
26
- else if (typeof cb !== "function") {
27
- throw new TypeError(`ranges-iterate: [THROW_ID_05] The calllback function (third input argument) must be a function. It was given as: ${typeof cb}, equal to: ${JSON.stringify(cb, null, 0)}`);
28
- }
29
- if (originalRanges === null || !originalRanges.length) {
30
- for (let i = 0; i < str.length; i++) {
31
- cb({
32
- i,
33
- val: str[i],
34
- });
35
- }
36
- }
37
- else {
38
- const ranges = Array.from(originalRanges);
39
- let currentIdx = offset;
40
- let finalIdx = offset;
41
- if (finalIdx < ranges[0][0]) {
42
- for (; finalIdx < ranges[0][0]; finalIdx++, currentIdx++) {
43
- if (!str[finalIdx]) {
44
- break;
45
- }
46
- cb({
47
- i: finalIdx,
48
- val: str[finalIdx],
49
- });
50
- }
51
- }
52
- if (ranges[0][0] <= currentIdx) {
53
- ranges.forEach((rangeArr, rangeArrIdx) => {
54
- if (rangeArr[2]) {
55
- for (let y = 0, len = rangeArr[2].length; y < len; y++) {
56
- cb({
57
- i: finalIdx,
58
- val: rangeArr[2][y],
59
- });
60
- finalIdx += 1;
61
- }
62
- }
63
- while (currentIdx < rangeArr[1]) {
64
- currentIdx += 1;
65
- }
66
- let loopUntil = str.length;
67
- if (ranges[rangeArrIdx + 1]) {
68
- loopUntil = ranges[rangeArrIdx + 1][0];
69
- }
70
- for (; currentIdx < loopUntil; finalIdx++, currentIdx++) {
71
- cb({
72
- i: finalIdx,
73
- val: str[currentIdx],
74
- });
75
- }
76
- });
77
- }
78
- }
79
- }
80
-
81
- export { rIterate, version };
10
+ var c="3.0.10";var f=c;function b(n,o,t,u=0){if(typeof n!="string")throw new TypeError(`ranges-iterate: [THROW_ID_01] Input string must be a string! It was given as ${typeof n}, equal to: ${JSON.stringify(n,null,0)}`);if(!n.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(t){if(typeof t!="function")throw new TypeError(`ranges-iterate: [THROW_ID_05] The calllback function (third input argument) must be a function. It was given as: ${typeof t}, equal to: ${JSON.stringify(t,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<n.length;e++)t({i:e,val:n[e]});else{let e=Array.from(o),l=u,r=u;if(r<e[0][0])for(;r<e[0][0]&&n[r];r++,l++)t({i:r,val:n[r]});e[0][0]<=l&&e.forEach((s,a)=>{if(s[2])for(let i=0,d=s[2].length;i<d;i++)t({i:r,val:s[2][i]}),r+=1;for(;l<s[1];)l+=1;let $=n.length;for(e[a+1]&&($=e[a+1][0]);l<$;r++,l++)t({i:r,val:n[l]})})}}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.7
4
+ * @version 3.0.10
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
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).rangesIterate={})}(this,(function(e){"use strict";e.rIterate=function(e,t,r,n=0){if("string"!=typeof e)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)throw new TypeError("ranges-iterate: [THROW_ID_04] You should provide a callback function as third input argument!");if("function"!=typeof r)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)}`);if(null!==t&&t.length){const i=Array.from(t);let o=n,a=n;if(a<i[0][0])for(;a<i[0][0]&&e[a];a++,o++)r({i:a,val:e[a]});i[0][0]<=o&&i.forEach(((t,n)=>{if(t[2])for(let e=0,n=t[2].length;e<n;e++)r({i:a,val:t[2][e]}),a+=1;for(;o<t[1];)o+=1;let f=e.length;for(i[n+1]&&(f=i[n+1][0]);o<f;a++,o++)r({i:a,val:e[o]})}))}else for(let t=0;t<e.length;t++)r({i:t,val:e[t]})},e.version="3.0.7",Object.defineProperty(e,"__esModule",{value:!0})}));
10
+ var rangesIterate=(()=>{var a=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var b=e=>a(e,"__esModule",{value:!0});var y=(e,n)=>{for(var r in n)a(e,r,{get:n[r],enumerable:!0})},I=(e,n,r,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of g(n))!f.call(e,t)&&(r||t!=="default")&&a(e,t,{get:()=>n[t],enumerable:!(s=p(n,t))||s.enumerable});return e};var x=(e=>(n,r)=>e&&e.get(n)||(r=I(b({}),n,1),e&&e.set(n,r),r))(typeof WeakMap!="undefined"?new WeakMap:0);var v={};y(v,{rIterate:()=>E,version:()=>D});var d="3.0.10";var D=d;function E(e,n,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(n&&!Array.isArray(n))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 n}, equal to: ${JSON.stringify(n,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(n===null||!n.length)for(let t=0;t<e.length;t++)r({i:t,val:e[t]});else{let t=Array.from(n),l=s,o=s;if(o<t[0][0])for(;o<t[0][0]&&e[o];o++,l++)r({i:o,val:e[o]});t[0][0]<=l&&t.forEach((i,$)=>{if(i[2])for(let u=0,m=i[2].length;u<m;u++)r({i:o,val:i[2][u]}),o+=1;for(;l<i[1];)l+=1;let c=e.length;for(t[$+1]&&(c=t[$+1][0]);l<c;o++,l++)r({i:o,val:e[l]})})}}return x(v);})();
@@ -1,6 +1,7 @@
1
1
  // Quick Take
2
2
 
3
3
  import { strict as assert } from "assert";
4
+
4
5
  import { rIterate } from "../dist/ranges-iterate.esm.js";
5
6
 
6
7
  // Ranges in the following example "punches out" a "hole" from `a` to `g`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ranges-iterate",
3
- "version": "3.0.7",
3
+ "version": "3.0.10",
4
4
  "description": "Iterate a string and any changes within given string index ranges",
5
5
  "keywords": [
6
6
  "array",
@@ -33,94 +33,38 @@
33
33
  },
34
34
  "types": "types/index.d.ts",
35
35
  "scripts": {
36
- "build": "rollup -c",
37
- "build:esbuild": "node '../../scripts/esbuild.js'",
38
- "build:esbuild:dev": "cross-env MODE=dev node '../../scripts/esbuild.js'",
39
- "ci_test": "npm run build && npm run format && tap --no-only --reporter=silent",
40
- "clean_types": "../../scripts/cleanTypes.js",
41
- "dev": "rollup -c --dev",
42
- "devunittest": "npm run dev && tap --only -R 'base'",
43
- "format": "npm run lect && npm run prettier && npm run lint",
44
- "lect": "lect",
45
- "lint": "../../node_modules/eslint/bin/eslint.js . --ext .js --ext .ts --fix --config \"../../.eslintrc.json\" --quiet",
46
- "perf": "node perf/check",
47
- "prettier": "../../node_modules/prettier/bin-prettier.js '*.{js,css,scss,vue,md,ts}' --write --loglevel silent",
48
- "republish": "npm publish || :",
49
- "tap": "tap",
50
- "pretest": "npm run build",
51
- "test": "npm run test:ci && npm run perf",
52
- "test:ci": "npm run unittest && npm run test:examples && npm run format",
53
- "test:examples": "../../scripts/test-examples.js && npm run lect && npm run prettier",
54
- "tsc": "tsc",
55
- "unittest": "tap --no-only --reporter=terse && tsc -p tsconfig.json --noEmit"
36
+ "build": "node '../../ops/scripts/esbuild.js' && yarn run dts",
37
+ "dev": "DEV=true node '../../ops/scripts/esbuild.js' && yarn run dts",
38
+ "dts": "rollup -c",
39
+ "examples": "node '../../ops/scripts/run-examples.js'",
40
+ "lect": "node '../../ops/lect/lect.js'",
41
+ "letspublish": "yarn publish || :",
42
+ "lint": "eslint . --fix",
43
+ "perf": "node perf/check.js",
44
+ "prepare": "echo 'ready'",
45
+ "pretest": "yarn run lect && yarn run build",
46
+ "test": "c8 yarn run unit && yarn run examples && yarn run lint",
47
+ "unit": "uvu test"
56
48
  },
57
- "tap": {
58
- "check-coverage": false,
59
- "node-arg": [
60
- "--no-warnings",
61
- "--experimental-loader",
62
- "@istanbuljs/esm-loader-hook"
49
+ "engines": {
50
+ "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
51
+ },
52
+ "c8": {
53
+ "check-coverage": true,
54
+ "exclude": [
55
+ "**/test/**/*.*"
63
56
  ],
64
- "timeout": 0
57
+ "lines": 100
65
58
  },
66
59
  "lect": {
67
60
  "licence": {
68
61
  "extras": [
69
62
  ""
70
63
  ]
71
- },
72
- "req": "{ rIterate }",
73
- "various": {
74
- "devDependencies": [
75
- "ranges-apply",
76
- "ranges-merge"
77
- ]
78
64
  }
79
65
  },
80
- "dependencies": {
81
- "@babel/runtime": "^7.16.3"
82
- },
83
66
  "devDependencies": {
84
- "@babel/cli": "^7.16.0",
85
- "@babel/core": "^7.16.0",
86
- "@babel/node": "^7.16.0",
87
- "@babel/plugin-external-helpers": "^7.16.0",
88
- "@babel/plugin-proposal-class-properties": "^7.16.0",
89
- "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
90
- "@babel/plugin-proposal-object-rest-spread": "^7.16.0",
91
- "@babel/plugin-proposal-optional-chaining": "^7.16.0",
92
- "@babel/plugin-transform-runtime": "^7.16.4",
93
- "@babel/preset-env": "^7.16.4",
94
- "@babel/preset-typescript": "^7.16.0",
95
- "@babel/register": "^7.16.0",
96
- "@istanbuljs/esm-loader-hook": "^0.1.2",
97
- "@rollup/plugin-babel": "^5.3.0",
98
- "@rollup/plugin-commonjs": "^21.0.1",
99
- "@rollup/plugin-json": "^4.1.0",
100
- "@rollup/plugin-node-resolve": "^13.0.6",
101
- "@rollup/plugin-strip": "^2.1.0",
102
- "@rollup/plugin-typescript": "^8.3.0",
103
- "@types/node": "^16.11.10",
104
- "@types/tap": "^15.0.5",
105
- "@typescript-eslint/eslint-plugin": "^5.5.0",
106
- "@typescript-eslint/parser": "^5.5.0",
107
- "core-js": "^3.19.2",
108
- "cross-env": "^7.0.3",
109
- "eslint": "^8.3.0",
110
- "lect": "^0.18.7",
111
- "ranges-apply": "^6.0.7",
112
- "ranges-merge": "^8.0.7",
113
- "rollup": "^2.60.1",
114
- "rollup-plugin-ascii": "^0.0.3",
115
- "rollup-plugin-banner": "^0.2.1",
116
- "rollup-plugin-cleanup": "^3.2.1",
117
- "rollup-plugin-dts": "^4.0.1",
118
- "rollup-plugin-terser": "^7.0.2",
119
- "tap": "^15.1.5",
120
- "tslib": "^2.3.1",
121
- "typescript": "^4.5.2"
122
- },
123
- "engines": {
124
- "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
67
+ "ranges-apply": "^6.0.10",
68
+ "ranges-merge": "^8.0.10"
125
69
  }
126
70
  }
package/types/index.d.ts CHANGED
File without changes
package/examples/api.json DELETED
@@ -1 +0,0 @@
1
- {"_quickTake.js":{"title":"Quick Take","content":"import &#x7B; strict as assert &#x7D; from \"assert\";\nimport &#x7B; rIterate &#x7D; from \"ranges-iterate\";\n\n// Ranges in the following example \"punches out\" a \"hole\" from `a` to `g`\n// (included), replacing it with `xyz`. That's what gets iterated.\n\nconst gathered = [];\n\n// a callback-based interface:\nrIterate(\"abcdefghij\", [[0, 7, \"xyz\"]], (&#x7B; i, val &#x7D;) => &#x7B;\n gathered.push(`i = $&#x7B;i&#x7D;; val = $&#x7B;val&#x7D;`);\n&#x7D;);\n\nassert.deepEqual(gathered, [\n \"i = 0; val = x\",\n \"i = 1; val = y\",\n \"i = 2; val = z\",\n \"i = 3; val = h\",\n \"i = 4; val = i\",\n \"i = 5; val = j\",\n]);"}}