ranges-sort 5.0.2 → 5.0.6

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,12 +3,6 @@
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.1 (2021-09-13)
7
-
8
- ### Bug Fixes
9
-
10
- - bump TS and separate ESLint plugins away from this monorepo ([2e07d42](https://github.com/codsen/codsen/commit/2e07d424222b6ffedf5fb45c83ad453627ec2904))
11
-
12
6
  ## 5.0.0 (2021-09-09)
13
7
 
14
8
  ### Features
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2010-%YEAR% Roy Revelt and other contributors
3
+ Copyright (c) 2010-2021 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
@@ -1,68 +1,76 @@
1
1
  /**
2
2
  * @name ranges-sort
3
3
  * @fileoverview Sort string index ranges
4
- * @version 5.0.2
4
+ * @version 5.0.6
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 = "5.0.2";
10
+ var version$1 = "5.0.6";
11
11
 
12
12
  const version = version$1;
13
13
  const defaults = {
14
- strictlyTwoElementsInRangeArrays: false,
15
- progressFn: null
14
+ strictlyTwoElementsInRangeArrays: false,
15
+ progressFn: null,
16
16
  };
17
17
  function rSort(arrOfRanges, originalOptions) {
18
- if (!Array.isArray(arrOfRanges) || !arrOfRanges.length) {
19
- return arrOfRanges;
20
- }
21
- const opts = { ...defaults,
22
- ...originalOptions
23
- };
24
- let culpritsIndex;
25
- let culpritsLen;
26
- if (opts.strictlyTwoElementsInRangeArrays && !arrOfRanges.filter(range => range).every((rangeArr, indx) => {
27
- if (rangeArr.length !== 2) {
28
- culpritsIndex = indx;
29
- culpritsLen = rangeArr.length;
30
- return false;
18
+ if (!Array.isArray(arrOfRanges) || !arrOfRanges.length) {
19
+ return arrOfRanges;
31
20
  }
32
- return true;
33
- })) {
34
- 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!`);
35
- }
36
- if (!arrOfRanges.filter(range => range).every((rangeArr, indx) => {
37
- if (!Number.isInteger(rangeArr[0]) || rangeArr[0] < 0 || !Number.isInteger(rangeArr[1]) || rangeArr[1] < 0) {
38
- culpritsIndex = indx;
39
- return false;
21
+ const opts = { ...defaults, ...originalOptions };
22
+ let culpritsIndex;
23
+ let culpritsLen;
24
+ if (opts.strictlyTwoElementsInRangeArrays &&
25
+ !arrOfRanges
26
+ .filter((range) => range)
27
+ .every((rangeArr, indx) => {
28
+ if (rangeArr.length !== 2) {
29
+ culpritsIndex = indx;
30
+ culpritsLen = rangeArr.length;
31
+ return false;
32
+ }
33
+ return true;
34
+ })) {
35
+ 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!`);
40
36
  }
41
- return true;
42
- })) {
43
- 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!`);
44
- }
45
- const maxPossibleIterations = arrOfRanges.filter(range => range).length ** 2;
46
- let counter = 0;
47
- return Array.from(arrOfRanges).filter(range => range).sort((range1, range2) => {
48
- if (opts.progressFn) {
49
- counter += 1;
50
- opts.progressFn(Math.floor(counter * 100 / maxPossibleIterations));
37
+ if (!arrOfRanges
38
+ .filter((range) => range)
39
+ .every((rangeArr, indx) => {
40
+ if (!Number.isInteger(rangeArr[0]) ||
41
+ rangeArr[0] < 0 ||
42
+ !Number.isInteger(rangeArr[1]) ||
43
+ rangeArr[1] < 0) {
44
+ culpritsIndex = indx;
45
+ return false;
46
+ }
47
+ return true;
48
+ })) {
49
+ 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!`);
51
50
  }
52
- if (range1[0] === range2[0]) {
53
- if (range1[1] < range2[1]) {
54
- return -1;
55
- }
56
- if (range1[1] > range2[1]) {
51
+ const maxPossibleIterations = arrOfRanges.filter((range) => range).length ** 2;
52
+ let counter = 0;
53
+ return Array.from(arrOfRanges)
54
+ .filter((range) => range)
55
+ .sort((range1, range2) => {
56
+ if (opts.progressFn) {
57
+ counter += 1;
58
+ opts.progressFn(Math.floor((counter * 100) / maxPossibleIterations));
59
+ }
60
+ if (range1[0] === range2[0]) {
61
+ if (range1[1] < range2[1]) {
62
+ return -1;
63
+ }
64
+ if (range1[1] > range2[1]) {
65
+ return 1;
66
+ }
67
+ return 0;
68
+ }
69
+ if (range1[0] < range2[0]) {
70
+ return -1;
71
+ }
57
72
  return 1;
58
- }
59
- return 0;
60
- }
61
- if (range1[0] < range2[0]) {
62
- return -1;
63
- }
64
- return 1;
65
- });
73
+ });
66
74
  }
67
75
 
68
76
  export { defaults, rSort, version };
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * @name ranges-sort
3
3
  * @fileoverview Sort string index ranges
4
- * @version 5.0.2
4
+ * @version 5.0.6
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="5.0.2",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.6",Object.defineProperty(e,"__esModule",{value:!0})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ranges-sort",
3
- "version": "5.0.2",
3
+ "version": "5.0.6",
4
4
  "description": "Sort string index ranges",
5
5
  "keywords": [
6
6
  "array",
@@ -29,9 +29,10 @@
29
29
  "types": "types/index.d.ts",
30
30
  "scripts": {
31
31
  "build": "rollup -c",
32
- "esbuild": "node '../../scripts/esbuild.js'",
33
- "esbuild_dev": "cross-env MODE=dev node '../../scripts/esbuild.js'",
34
- "ci_test": "npm run build && npm run format && tap --no-only --reporter=silent --output-file=testStats.md && npm run clean_cov",
32
+ "build:esbuild": "node '../../scripts/esbuild.js'",
33
+ "build:esbuild:dev": "cross-env MODE=dev node '../../scripts/esbuild.js'",
34
+ "ci_test": "npm run build && npm run format && tap --no-only --reporter=silent",
35
+ "clean_types": "../../scripts/cleanTypes.js",
35
36
  "dev": "rollup -c --dev",
36
37
  "devunittest": "npm run dev && tap --only -R 'base'",
37
38
  "format": "npm run lect && npm run prettier && npm run lint",
@@ -41,20 +42,15 @@
41
42
  "prettier": "../../node_modules/prettier/bin-prettier.js '*.{js,css,scss,vue,md,ts}' --write --loglevel silent",
42
43
  "republish": "npm publish || :",
43
44
  "tap": "tap",
44
- "tsc": "tsc",
45
45
  "pretest": "npm run build",
46
- "test": "npm run lint && npm run unittest && npm run test:examples && npm run clean_cov && npm run format",
46
+ "test": "npm run test:ci && npm run perf",
47
+ "test:ci": "npm run unittest && npm run test:examples && npm run format",
47
48
  "test:examples": "../../scripts/test-examples.js && npm run lect && npm run prettier",
48
- "unittest": "tap --no-only --output-file=testStats.md --reporter=terse && tsc -p tsconfig.json --noEmit && npm run clean_cov && npm run perf",
49
- "clean_cov": "../../scripts/leaveCoverageTotalOnly.js",
50
- "clean_types": "../../scripts/cleanTypes.js"
49
+ "tsc": "tsc",
50
+ "unittest": "tap --no-only --reporter=terse && tsc -p tsconfig.json --noEmit"
51
51
  },
52
52
  "tap": {
53
53
  "check-coverage": false,
54
- "coverage-report": [
55
- "json-summary",
56
- "text"
57
- ],
58
54
  "node-arg": [
59
55
  "--no-warnings",
60
56
  "--experimental-loader",
@@ -74,47 +70,47 @@
74
70
  }
75
71
  },
76
72
  "dependencies": {
77
- "@babel/runtime": "^7.15.4"
73
+ "@babel/runtime": "^7.16.3"
78
74
  },
79
75
  "devDependencies": {
80
- "@babel/cli": "^7.15.4",
81
- "@babel/core": "^7.15.5",
82
- "@babel/node": "^7.15.4",
83
- "@babel/plugin-external-helpers": "^7.14.5",
84
- "@babel/plugin-proposal-class-properties": "^7.14.5",
85
- "@babel/plugin-proposal-nullish-coalescing-operator": "^7.14.5",
86
- "@babel/plugin-proposal-object-rest-spread": "^7.15.6",
87
- "@babel/plugin-proposal-optional-chaining": "^7.14.5",
88
- "@babel/plugin-transform-runtime": "^7.15.0",
89
- "@babel/preset-env": "^7.15.6",
90
- "@babel/preset-typescript": "^7.15.0",
91
- "@babel/register": "^7.15.3",
76
+ "@babel/cli": "^7.16.0",
77
+ "@babel/core": "^7.16.0",
78
+ "@babel/node": "^7.16.0",
79
+ "@babel/plugin-external-helpers": "^7.16.0",
80
+ "@babel/plugin-proposal-class-properties": "^7.16.0",
81
+ "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
82
+ "@babel/plugin-proposal-object-rest-spread": "^7.16.0",
83
+ "@babel/plugin-proposal-optional-chaining": "^7.16.0",
84
+ "@babel/plugin-transform-runtime": "^7.16.4",
85
+ "@babel/preset-env": "^7.16.4",
86
+ "@babel/preset-typescript": "^7.16.0",
87
+ "@babel/register": "^7.16.0",
92
88
  "@istanbuljs/esm-loader-hook": "^0.1.2",
93
89
  "@rollup/plugin-babel": "^5.3.0",
94
- "@rollup/plugin-commonjs": "^20.0.0",
90
+ "@rollup/plugin-commonjs": "^21.0.1",
95
91
  "@rollup/plugin-json": "^4.1.0",
96
- "@rollup/plugin-node-resolve": "^13.0.4",
92
+ "@rollup/plugin-node-resolve": "^13.0.6",
97
93
  "@rollup/plugin-strip": "^2.1.0",
98
- "@rollup/plugin-typescript": "^8.2.5",
99
- "@types/node": "^16.9.1",
94
+ "@rollup/plugin-typescript": "^8.3.0",
95
+ "@types/node": "^16.11.9",
100
96
  "@types/tap": "^15.0.5",
101
- "@typescript-eslint/eslint-plugin": "^4.31.0",
102
- "@typescript-eslint/parser": "^4.31.0",
103
- "core-js": "^3.17.3",
97
+ "@typescript-eslint/eslint-plugin": "^5.4.0",
98
+ "@typescript-eslint/parser": "^5.4.0",
99
+ "core-js": "^3.19.1",
104
100
  "cross-env": "^7.0.3",
105
- "eslint": "^7.32.0",
106
- "lect": "^0.18.2",
107
- "rollup": "^2.56.3",
101
+ "eslint": "^8.3.0",
102
+ "lect": "^0.18.6",
103
+ "rollup": "^2.60.0",
108
104
  "rollup-plugin-ascii": "^0.0.3",
109
105
  "rollup-plugin-banner": "^0.2.1",
110
106
  "rollup-plugin-cleanup": "^3.2.1",
111
- "rollup-plugin-dts": "^4.0.0",
107
+ "rollup-plugin-dts": "^4.0.1",
112
108
  "rollup-plugin-terser": "^7.0.2",
113
- "tap": "^15.0.9",
109
+ "tap": "^15.1.2",
114
110
  "tslib": "^2.3.1",
115
- "typescript": "^4.4.3"
111
+ "typescript": "^4.5.2"
116
112
  },
117
113
  "engines": {
118
- "node": ">=12"
114
+ "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
119
115
  }
120
116
  }