ranges-sort 4.1.0 → 5.0.3

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,36 @@
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
+ ## 5.0.3 (2021-11-02)
7
+
8
+ ### Bug Fixes
9
+
10
+ - bump TS and separate ESLint plugins away from this monorepo ([b1ebce1](https://github.com/codsen/codsen/commit/b1ebce1637d8c41c2d848fc24b0ba4058865bd5d))
11
+
12
+ ### Features
13
+
14
+ - migrate to ES Modules ([c579dff](https://github.com/codsen/codsen/commit/c579dff3b23205e383035ca10ddcec671e35d0fe))
15
+
16
+ ### BREAKING CHANGES
17
+
18
+ - programs now are in ES Modules and won't work with Common JS require()
19
+
20
+ ## 5.0.1 (2021-09-13)
21
+
22
+ ### Bug Fixes
23
+
24
+ - bump TS and separate ESLint plugins away from this monorepo ([2e07d42](https://github.com/codsen/codsen/commit/2e07d424222b6ffedf5fb45c83ad453627ec2904))
25
+
26
+ ## 5.0.0 (2021-09-09)
27
+
28
+ ### Features
29
+
30
+ - migrate to ES Modules ([8c9d95d](https://github.com/codsen/codsen/commit/8c9d95d5dea0b769c2f070397141918a4893d575))
31
+
32
+ ### BREAKING CHANGES
33
+
34
+ - programs now are in ES Modules and won't work with Common JS require()
35
+
6
36
  ## 4.1.0 (2021-05-24)
7
37
 
8
38
  ### Features
package/README.md CHANGED
@@ -26,10 +26,14 @@
26
26
 
27
27
  ## Install
28
28
 
29
+ This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required:
30
+
29
31
  ```bash
30
32
  npm i ranges-sort
31
33
  ```
32
34
 
35
+ If you need a legacy version which works with `require`, use version 4.1.0
36
+
33
37
  ## Quick Take
34
38
 
35
39
  ```js
@@ -1,13 +1,13 @@
1
1
  /**
2
2
  * @name ranges-sort
3
3
  * @fileoverview Sort string index ranges
4
- * @version 4.1.0
4
+ * @version 5.0.3
5
5
  * @author Roy Revelt, Codsen Ltd
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/ranges-sort/}
8
8
  */
9
9
 
10
- var version$1 = "4.1.0";
10
+ var version$1 = "5.0.3";
11
11
 
12
12
  const version = version$1;
13
13
  const defaults = {
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * @name ranges-sort
3
3
  * @fileoverview Sort string index ranges
4
- * @version 4.1.0
4
+ * @version 5.0.3
5
5
  * @author Roy Revelt, Codsen Ltd
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/ranges-sort/}
8
8
  */
9
9
 
10
- !function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self).rangesSort={})}(this,(function(e){"use strict";const r={strictlyTwoElementsInRangeArrays:!1,progressFn:null};e.defaults=r,e.rSort=function(e,n){if(!Array.isArray(e)||!e.length)return e;const t={...r,...n};let s,o;if(t.strictlyTwoElementsInRangeArrays&&!e.filter((e=>e)).every(((e,r)=>2===e.length||(s=r,o=e.length,!1))))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(e[s],null,4)}) has not two but ${o} elements!`);if(!e.filter((e=>e)).every(((e,r)=>!(!Number.isInteger(e[0])||e[0]<0||!Number.isInteger(e[1])||e[1]<0)||(s=r,!1))))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(e[s],null,4)}) does not consist of only natural numbers!`);const i=e.filter((e=>e)).length**2;let a=0;return Array.from(e).filter((e=>e)).sort(((e,r)=>(t.progressFn&&(a+=1,t.progressFn(Math.floor(100*a/i))),e[0]===r[0]?e[1]<r[1]?-1:e[1]>r[1]?1:0:e[0]<r[0]?-1:1)))},e.version="4.1.0",Object.defineProperty(e,"__esModule",{value:!0})}));
10
+ !function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self).rangesSort={})}(this,(function(e){"use strict";const r={strictlyTwoElementsInRangeArrays:!1,progressFn:null};e.defaults=r,e.rSort=function(e,n){if(!Array.isArray(e)||!e.length)return e;const t={...r,...n};let s,o;if(t.strictlyTwoElementsInRangeArrays&&!e.filter((e=>e)).every(((e,r)=>2===e.length||(s=r,o=e.length,!1))))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(e[s],null,4)}) has not two but ${o} elements!`);if(!e.filter((e=>e)).every(((e,r)=>!(!Number.isInteger(e[0])||e[0]<0||!Number.isInteger(e[1])||e[1]<0)||(s=r,!1))))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(e[s],null,4)}) does not consist of only natural numbers!`);const i=e.filter((e=>e)).length**2;let a=0;return Array.from(e).filter((e=>e)).sort(((e,r)=>(t.progressFn&&(a+=1,t.progressFn(Math.floor(100*a/i))),e[0]===r[0]?e[1]<r[1]?-1:e[1]>r[1]?1:0:e[0]<r[0]?-1:1)))},e.version="5.0.3",Object.defineProperty(e,"__esModule",{value:!0})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ranges-sort",
3
- "version": "4.1.0",
3
+ "version": "5.0.3",
4
4
  "description": "Sort string index ranges",
5
5
  "keywords": [
6
6
  "array",
@@ -21,17 +21,21 @@
21
21
  "email": "roy@codsen.com",
22
22
  "url": "https://codsen.com"
23
23
  },
24
- "main": "dist/ranges-sort.cjs.js",
25
- "module": "dist/ranges-sort.esm.js",
26
- "browser": "dist/ranges-sort.umd.js",
24
+ "type": "module",
25
+ "exports": {
26
+ "script": "./dist/ranges-sort.umd.js",
27
+ "default": "./dist/ranges-sort.esm.js"
28
+ },
27
29
  "types": "types/index.d.ts",
28
30
  "scripts": {
29
31
  "build": "rollup -c",
30
- "esbuild": "node '../../scripts/esbuild.js'",
31
- "esbuild_dev": "cross-env MODE=dev node '../../scripts/esbuild.js'",
32
32
  "ci_test": "npm run build && npm run format && tap --no-only --reporter=silent --output-file=testStats.md && npm run clean_cov",
33
+ "clean_cov": "../../scripts/leaveCoverageTotalOnly.js",
34
+ "clean_types": "../../scripts/cleanTypes.js",
33
35
  "dev": "rollup -c --dev",
34
36
  "devunittest": "npm run dev && tap --only -R 'base'",
37
+ "esbuild": "node '../../scripts/esbuild.js'",
38
+ "esbuild_dev": "cross-env MODE=dev node '../../scripts/esbuild.js'",
35
39
  "format": "npm run lect && npm run prettier && npm run lint",
36
40
  "lect": "lect",
37
41
  "lint": "../../node_modules/eslint/bin/eslint.js . --ext .js --ext .ts --fix --config \"../../.eslintrc.json\" --quiet",
@@ -39,22 +43,22 @@
39
43
  "prettier": "../../node_modules/prettier/bin-prettier.js '*.{js,css,scss,vue,md,ts}' --write --loglevel silent",
40
44
  "republish": "npm publish || :",
41
45
  "tap": "tap",
42
- "tsc": "tsc",
43
46
  "pretest": "npm run build",
44
47
  "test": "npm run lint && npm run unittest && npm run test:examples && npm run clean_cov && npm run format",
45
48
  "test:examples": "../../scripts/test-examples.js && npm run lect && npm run prettier",
46
- "unittest": "./node_modules/.bin/tap --no-only --output-file=testStats.md --reporter=terse && tsc -p tsconfig.json --noEmit && npm run clean_cov && npm run perf",
47
- "clean_cov": "../../scripts/leaveCoverageTotalOnly.js",
48
- "clean_types": "../../scripts/cleanTypes.js"
49
+ "tsc": "tsc",
50
+ "unittest": "tap --no-only --output-file=testStats.md --reporter=terse && tsc -p tsconfig.json --noEmit && npm run clean_cov && npm run perf"
49
51
  },
50
52
  "tap": {
53
+ "check-coverage": false,
51
54
  "coverage-report": [
52
55
  "json-summary",
53
56
  "text"
54
57
  ],
55
- "nyc-arg": [
56
- "--exclude=**/*.cjs.js",
57
- "--exclude=**/*.umd.js"
58
+ "node-arg": [
59
+ "--no-warnings",
60
+ "--experimental-loader",
61
+ "@istanbuljs/esm-loader-hook"
58
62
  ],
59
63
  "timeout": 0
60
64
  },
@@ -70,43 +74,47 @@
70
74
  }
71
75
  },
72
76
  "dependencies": {
73
- "@babel/runtime": "^7.14.0"
77
+ "@babel/runtime": "^7.16.0"
74
78
  },
75
79
  "devDependencies": {
76
- "@babel/cli": "^7.14.3",
77
- "@babel/core": "^7.14.3",
78
- "@babel/node": "^7.14.2",
79
- "@babel/plugin-external-helpers": "^7.12.13",
80
- "@babel/plugin-proposal-class-properties": "^7.13.0",
81
- "@babel/plugin-proposal-nullish-coalescing-operator": "^7.14.2",
82
- "@babel/plugin-proposal-object-rest-spread": "^7.14.2",
83
- "@babel/plugin-proposal-optional-chaining": "^7.14.2",
84
- "@babel/plugin-transform-runtime": "^7.14.3",
85
- "@babel/preset-env": "^7.14.2",
86
- "@babel/preset-typescript": "^7.13.0",
87
- "@babel/register": "^7.13.16",
80
+ "@babel/cli": "^7.16.0",
81
+ "@babel/core": "^7.16.0",
82
+ "@babel/node": "^7.16.0",
83
+ "@babel/plugin-external-helpers": "^7.16.0",
84
+ "@babel/plugin-proposal-class-properties": "^7.16.0",
85
+ "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
86
+ "@babel/plugin-proposal-object-rest-spread": "^7.16.0",
87
+ "@babel/plugin-proposal-optional-chaining": "^7.16.0",
88
+ "@babel/plugin-transform-runtime": "^7.16.0",
89
+ "@babel/preset-env": "^7.16.0",
90
+ "@babel/preset-typescript": "^7.16.0",
91
+ "@babel/register": "^7.16.0",
92
+ "@istanbuljs/esm-loader-hook": "^0.1.2",
88
93
  "@rollup/plugin-babel": "^5.3.0",
89
- "@rollup/plugin-commonjs": "^19.0.0",
94
+ "@rollup/plugin-commonjs": "^21.0.1",
90
95
  "@rollup/plugin-json": "^4.1.0",
91
- "@rollup/plugin-node-resolve": "^13.0.0",
92
- "@rollup/plugin-strip": "^2.0.1",
93
- "@rollup/plugin-typescript": "^8.2.1",
94
- "@types/node": "^15.6.0",
95
- "@types/tap": "^15.0.1",
96
- "@typescript-eslint/eslint-plugin": "^4.24.0",
97
- "@typescript-eslint/parser": "^4.24.0",
98
- "core-js": "^3.12.1",
96
+ "@rollup/plugin-node-resolve": "^13.0.6",
97
+ "@rollup/plugin-strip": "^2.1.0",
98
+ "@rollup/plugin-typescript": "^8.3.0",
99
+ "@types/node": "^16.11.6",
100
+ "@types/tap": "^15.0.5",
101
+ "@typescript-eslint/eslint-plugin": "^5.2.0",
102
+ "@typescript-eslint/parser": "^5.2.0",
103
+ "core-js": "^3.19.0",
99
104
  "cross-env": "^7.0.3",
100
- "eslint": "^7.27.0",
101
- "lect": "^0.17.0",
102
- "rollup": "^2.49.0",
105
+ "eslint": "^8.1.0",
106
+ "lect": "^0.18.3",
107
+ "rollup": "^2.59.0",
103
108
  "rollup-plugin-ascii": "^0.0.3",
104
109
  "rollup-plugin-banner": "^0.2.1",
105
110
  "rollup-plugin-cleanup": "^3.2.1",
106
- "rollup-plugin-dts": "^3.0.1",
111
+ "rollup-plugin-dts": "^4.0.0",
107
112
  "rollup-plugin-terser": "^7.0.2",
108
- "tap": "^14.11.0",
109
- "tslib": "^2.2.0",
110
- "typescript": "^4.2.4"
113
+ "tap": "^15.0.10",
114
+ "tslib": "^2.3.1",
115
+ "typescript": "^4.4.4"
116
+ },
117
+ "engines": {
118
+ "node": ">=12"
111
119
  }
112
120
  }
@@ -1,86 +0,0 @@
1
- /**
2
- * @name ranges-sort
3
- * @fileoverview Sort string index ranges
4
- * @version 4.1.0
5
- * @author Roy Revelt, Codsen Ltd
6
- * @license MIT
7
- * {@link https://codsen.com/os/ranges-sort/}
8
- */
9
-
10
- 'use strict';
11
-
12
- Object.defineProperty(exports, '__esModule', { value: true });
13
-
14
- var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
15
-
16
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
17
-
18
- var _objectSpread__default = /*#__PURE__*/_interopDefaultLegacy(_objectSpread);
19
-
20
- var version$1 = "4.1.0";
21
-
22
- var version = version$1;
23
- var defaults = {
24
- strictlyTwoElementsInRangeArrays: false,
25
- progressFn: null
26
- };
27
- function rSort(arrOfRanges, originalOptions) {
28
- if (!Array.isArray(arrOfRanges) || !arrOfRanges.length) {
29
- return arrOfRanges;
30
- }
31
- var opts = _objectSpread__default['default'](_objectSpread__default['default']({}, defaults), originalOptions);
32
- var culpritsIndex;
33
- var culpritsLen;
34
- if (opts.strictlyTwoElementsInRangeArrays && !arrOfRanges.filter(function (range) {
35
- return range;
36
- }).every(function (rangeArr, indx) {
37
- if (rangeArr.length !== 2) {
38
- culpritsIndex = indx;
39
- culpritsLen = rangeArr.length;
40
- return false;
41
- }
42
- return true;
43
- })) {
44
- 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, ".concat(culpritsIndex, "th range (").concat(JSON.stringify(arrOfRanges[culpritsIndex], null, 4), ") has not two but ").concat(culpritsLen, " elements!"));
45
- }
46
- if (!arrOfRanges.filter(function (range) {
47
- return range;
48
- }).every(function (rangeArr, indx) {
49
- if (!Number.isInteger(rangeArr[0]) || rangeArr[0] < 0 || !Number.isInteger(rangeArr[1]) || rangeArr[1] < 0) {
50
- culpritsIndex = indx;
51
- return false;
52
- }
53
- return true;
54
- })) {
55
- 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, ".concat(culpritsIndex, "th range (").concat(JSON.stringify(arrOfRanges[culpritsIndex], null, 4), ") does not consist of only natural numbers!"));
56
- }
57
- var maxPossibleIterations = Math.pow(arrOfRanges.filter(function (range) {
58
- return range;
59
- }).length, 2);
60
- var counter = 0;
61
- return Array.from(arrOfRanges).filter(function (range) {
62
- return range;
63
- }).sort(function (range1, range2) {
64
- if (opts.progressFn) {
65
- counter += 1;
66
- opts.progressFn(Math.floor(counter * 100 / maxPossibleIterations));
67
- }
68
- if (range1[0] === range2[0]) {
69
- if (range1[1] < range2[1]) {
70
- return -1;
71
- }
72
- if (range1[1] > range2[1]) {
73
- return 1;
74
- }
75
- return 0;
76
- }
77
- if (range1[0] < range2[0]) {
78
- return -1;
79
- }
80
- return 1;
81
- });
82
- }
83
-
84
- exports.defaults = defaults;
85
- exports.rSort = rSort;
86
- exports.version = version;
@@ -1,94 +0,0 @@
1
- /**
2
- * @name ranges-sort
3
- * @fileoverview Sort string index ranges
4
- * @version 4.1.0
5
- * @author Roy Revelt, Codsen Ltd
6
- * @license MIT
7
- * {@link https://codsen.com/os/ranges-sort/}
8
- */
9
-
10
- (function (global, factory) {
11
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
12
- typeof define === 'function' && define.amd ? define(['exports'], factory) :
13
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.rangesSort = {}));
14
- }(this, (function (exports) { 'use strict';
15
-
16
- var version$1 = "4.1.0";
17
-
18
- const version = version$1;
19
- const defaults = {
20
- strictlyTwoElementsInRangeArrays: false,
21
- progressFn: null,
22
- };
23
- function rSort(arrOfRanges, originalOptions) {
24
- // quick ending
25
- if (!Array.isArray(arrOfRanges) || !arrOfRanges.length) {
26
- return arrOfRanges;
27
- }
28
- // fill any settings with defaults if missing:
29
- const opts = { ...defaults, ...originalOptions };
30
- // arrOfRanges validation
31
- let culpritsIndex;
32
- let culpritsLen;
33
- // validate does every range consist of exactly two indexes:
34
- if (opts.strictlyTwoElementsInRangeArrays &&
35
- !arrOfRanges
36
- .filter((range) => range)
37
- .every((rangeArr, indx) => {
38
- if (rangeArr.length !== 2) {
39
- culpritsIndex = indx;
40
- culpritsLen = rangeArr.length;
41
- return false;
42
- }
43
- return true;
44
- })) {
45
- 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, ${culpritsIndex}th range (${JSON.stringify(arrOfRanges[culpritsIndex], null, 4)}) has not two but ${culpritsLen} elements!`);
46
- }
47
- // validate are range indexes natural numbers:
48
- if (!arrOfRanges
49
- .filter((range) => range)
50
- .every((rangeArr, indx) => {
51
- if (!Number.isInteger(rangeArr[0]) ||
52
- rangeArr[0] < 0 ||
53
- !Number.isInteger(rangeArr[1]) ||
54
- rangeArr[1] < 0) {
55
- culpritsIndex = indx;
56
- return false;
57
- }
58
- return true;
59
- })) {
60
- 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, ${culpritsIndex}th range (${JSON.stringify(arrOfRanges[culpritsIndex], null, 4)}) does not consist of only natural numbers!`);
61
- }
62
- // let's assume worst case scenario is N x N.
63
- const maxPossibleIterations = arrOfRanges.filter((range) => range).length ** 2;
64
- let counter = 0;
65
- return Array.from(arrOfRanges)
66
- .filter((range) => range)
67
- .sort((range1, range2) => {
68
- if (opts.progressFn) {
69
- counter += 1;
70
- opts.progressFn(Math.floor((counter * 100) / maxPossibleIterations));
71
- }
72
- if (range1[0] === range2[0]) {
73
- if (range1[1] < range2[1]) {
74
- return -1;
75
- }
76
- if (range1[1] > range2[1]) {
77
- return 1;
78
- }
79
- return 0;
80
- }
81
- if (range1[0] < range2[0]) {
82
- return -1;
83
- }
84
- return 1;
85
- });
86
- }
87
-
88
- exports.defaults = defaults;
89
- exports.rSort = rSort;
90
- exports.version = version;
91
-
92
- Object.defineProperty(exports, '__esModule', { value: true });
93
-
94
- })));