string-match-left-right 8.0.1 → 8.0.5
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 +0 -6
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/dist/string-match-left-right.esm.js +8 -4
- package/dist/string-match-left-right.umd.js +2 -2
- package/package.json +35 -35
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
|
-
## 8.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
|
## 8.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
|
|
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
|
package/README.md
CHANGED
|
@@ -32,7 +32,7 @@ This package is ESM only: Node 12+ is needed to use it and it must be imported i
|
|
|
32
32
|
npm i string-match-left-right
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
If you need a legacy version which works with require
|
|
35
|
+
If you need a legacy version which works with `require`, use version 7.1.0
|
|
36
36
|
|
|
37
37
|
## Quick Take
|
|
38
38
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name string-match-left-right
|
|
3
3
|
* @fileoverview Match substrings on the left or right of a given index, ignoring whitespace
|
|
4
|
-
* @version 8.0.
|
|
4
|
+
* @version 8.0.5
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/string-match-left-right/}
|
|
@@ -106,7 +106,8 @@ function march(str, position, whatToMatchVal, originalOpts, special = false, get
|
|
|
106
106
|
for (let y = 0; y <= patience; y++) {
|
|
107
107
|
const nextCharToCompareAgainst = nextIdx > i ? whatToMatchVal[whatToMatchVal.length - charsToCheckCount + 1 + y] : whatToMatchVal[charsToCheckCount - 2 - y];
|
|
108
108
|
const nextCharInSource = str[getNextIdx(i)];
|
|
109
|
-
if (nextCharToCompareAgainst && (!opts.i && str[i] === nextCharToCompareAgainst || opts.i && str[i].toLowerCase() === nextCharToCompareAgainst.toLowerCase()) && (
|
|
109
|
+
if (nextCharToCompareAgainst && (!opts.i && str[i] === nextCharToCompareAgainst || opts.i && str[i].toLowerCase() === nextCharToCompareAgainst.toLowerCase()) && (
|
|
110
|
+
!opts.firstMustMatch || charsToCheckCount !== whatToMatchVal.length)) {
|
|
110
111
|
charsMatchedTotal++;
|
|
111
112
|
if (whitespaceInFrontOfFirstChar()) {
|
|
112
113
|
return false;
|
|
@@ -114,7 +115,8 @@ function march(str, position, whatToMatchVal, originalOpts, special = false, get
|
|
|
114
115
|
charsToCheckCount -= 2;
|
|
115
116
|
somethingFound = true;
|
|
116
117
|
break;
|
|
117
|
-
} else if (nextCharInSource && nextCharToCompareAgainst && (!opts.i && nextCharInSource === nextCharToCompareAgainst || opts.i && nextCharInSource.toLowerCase() === nextCharToCompareAgainst.toLowerCase()) && (
|
|
118
|
+
} else if (nextCharInSource && nextCharToCompareAgainst && (!opts.i && nextCharInSource === nextCharToCompareAgainst || opts.i && nextCharInSource.toLowerCase() === nextCharToCompareAgainst.toLowerCase()) && (
|
|
119
|
+
!opts.firstMustMatch || charsToCheckCount !== whatToMatchVal.length)) {
|
|
118
120
|
if (!charsMatchedTotal && !opts.hungry) {
|
|
119
121
|
return false;
|
|
120
122
|
}
|
|
@@ -201,7 +203,9 @@ function main(mode, str, position, originalWhatToMatch, originalOpts) {
|
|
|
201
203
|
})) {
|
|
202
204
|
throw new Error(`string-match-left-right/${mode}(): [THROW_ID_07] the fourth argument, options object contains trimCharsBeforeMatching. It was meant to list the single characters but one of the entries at index ${culpritsIndex} is longer than 1 character, ${culpritsVal.length} (equals to ${culpritsVal}). Please split it into separate characters and put into array as separate elements.`);
|
|
203
205
|
}
|
|
204
|
-
if (!whatToMatch || !Array.isArray(whatToMatch) ||
|
|
206
|
+
if (!whatToMatch || !Array.isArray(whatToMatch) ||
|
|
207
|
+
Array.isArray(whatToMatch) && !whatToMatch.length ||
|
|
208
|
+
Array.isArray(whatToMatch) && whatToMatch.length === 1 && isStr(whatToMatch[0]) && !whatToMatch[0].trim()
|
|
205
209
|
) {
|
|
206
210
|
if (typeof opts.cb === "function") {
|
|
207
211
|
let firstCharOutsideIndex;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name string-match-left-right
|
|
3
3
|
* @fileoverview Match substrings on the left or right of a given index, ignoring whitespace
|
|
4
|
-
* @version 8.0.
|
|
4
|
+
* @version 8.0.5
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/string-match-left-right/}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
/**
|
|
12
12
|
* @name arrayiffy-if-string
|
|
13
13
|
* @fileoverview Put non-empty strings into arrays, turn empty-ones into empty arrays. Bypass everything else.
|
|
14
|
-
* @version 4.0.
|
|
14
|
+
* @version 4.0.5
|
|
15
15
|
* @author Roy Revelt, Codsen Ltd
|
|
16
16
|
* @license MIT
|
|
17
17
|
* {@link https://codsen.com/os/arrayiffy-if-string/}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "string-match-left-right",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.5",
|
|
4
4
|
"description": "Match substrings on the left or right of a given index, ignoring whitespace",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"left",
|
|
@@ -32,11 +32,13 @@
|
|
|
32
32
|
"types": "types/index.d.ts",
|
|
33
33
|
"scripts": {
|
|
34
34
|
"build": "rollup -c",
|
|
35
|
-
"esbuild": "node '../../scripts/esbuild.js'",
|
|
36
|
-
"esbuild_dev": "cross-env MODE=dev node '../../scripts/esbuild.js'",
|
|
37
35
|
"ci_test": "npm run build && npm run format && tap --no-only --reporter=silent --output-file=testStats.md && npm run clean_cov",
|
|
36
|
+
"clean_cov": "../../scripts/leaveCoverageTotalOnly.js",
|
|
37
|
+
"clean_types": "../../scripts/cleanTypes.js",
|
|
38
38
|
"dev": "rollup -c --dev",
|
|
39
39
|
"devunittest": "npm run dev && tap --only -R 'base'",
|
|
40
|
+
"esbuild": "node '../../scripts/esbuild.js'",
|
|
41
|
+
"esbuild_dev": "cross-env MODE=dev node '../../scripts/esbuild.js'",
|
|
40
42
|
"format": "npm run lect && npm run prettier && npm run lint",
|
|
41
43
|
"lect": "lect",
|
|
42
44
|
"lint": "../../node_modules/eslint/bin/eslint.js . --ext .js --ext .ts --fix --config \"../../.eslintrc.json\" --quiet",
|
|
@@ -44,13 +46,11 @@
|
|
|
44
46
|
"prettier": "../../node_modules/prettier/bin-prettier.js '*.{js,css,scss,vue,md,ts}' --write --loglevel silent",
|
|
45
47
|
"republish": "npm publish || :",
|
|
46
48
|
"tap": "tap",
|
|
47
|
-
"tsc": "tsc",
|
|
48
49
|
"pretest": "npm run build",
|
|
49
50
|
"test": "npm run lint && npm run unittest && npm run test:examples && npm run clean_cov && npm run format",
|
|
50
51
|
"test:examples": "../../scripts/test-examples.js && npm run lect && npm run prettier",
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"clean_types": "../../scripts/cleanTypes.js"
|
|
52
|
+
"tsc": "tsc",
|
|
53
|
+
"unittest": "tap --no-only --output-file=testStats.md --reporter=terse && tsc -p tsconfig.json --noEmit && npm run clean_cov && npm run perf"
|
|
54
54
|
},
|
|
55
55
|
"tap": {
|
|
56
56
|
"check-coverage": false,
|
|
@@ -79,48 +79,48 @@
|
|
|
79
79
|
}
|
|
80
80
|
},
|
|
81
81
|
"dependencies": {
|
|
82
|
-
"@babel/runtime": "^7.
|
|
83
|
-
"arrayiffy-if-string": "^4.0.
|
|
82
|
+
"@babel/runtime": "^7.16.0",
|
|
83
|
+
"arrayiffy-if-string": "^4.0.5",
|
|
84
84
|
"lodash.isplainobject": "^4.0.6",
|
|
85
|
-
"string-character-is-astral-surrogate": "^2.0.
|
|
85
|
+
"string-character-is-astral-surrogate": "^2.0.5"
|
|
86
86
|
},
|
|
87
87
|
"devDependencies": {
|
|
88
|
-
"@babel/cli": "^7.
|
|
89
|
-
"@babel/core": "^7.
|
|
90
|
-
"@babel/node": "^7.
|
|
91
|
-
"@babel/plugin-external-helpers": "^7.
|
|
92
|
-
"@babel/plugin-proposal-class-properties": "^7.
|
|
93
|
-
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.
|
|
94
|
-
"@babel/plugin-proposal-object-rest-spread": "^7.
|
|
95
|
-
"@babel/plugin-proposal-optional-chaining": "^7.
|
|
96
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
97
|
-
"@babel/preset-env": "^7.
|
|
98
|
-
"@babel/preset-typescript": "^7.
|
|
99
|
-
"@babel/register": "^7.
|
|
88
|
+
"@babel/cli": "^7.16.0",
|
|
89
|
+
"@babel/core": "^7.16.0",
|
|
90
|
+
"@babel/node": "^7.16.0",
|
|
91
|
+
"@babel/plugin-external-helpers": "^7.16.0",
|
|
92
|
+
"@babel/plugin-proposal-class-properties": "^7.16.0",
|
|
93
|
+
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
|
|
94
|
+
"@babel/plugin-proposal-object-rest-spread": "^7.16.0",
|
|
95
|
+
"@babel/plugin-proposal-optional-chaining": "^7.16.0",
|
|
96
|
+
"@babel/plugin-transform-runtime": "^7.16.0",
|
|
97
|
+
"@babel/preset-env": "^7.16.0",
|
|
98
|
+
"@babel/preset-typescript": "^7.16.0",
|
|
99
|
+
"@babel/register": "^7.16.0",
|
|
100
100
|
"@istanbuljs/esm-loader-hook": "^0.1.2",
|
|
101
101
|
"@rollup/plugin-babel": "^5.3.0",
|
|
102
|
-
"@rollup/plugin-commonjs": "^
|
|
103
|
-
"@rollup/plugin-node-resolve": "^13.0.
|
|
102
|
+
"@rollup/plugin-commonjs": "^21.0.1",
|
|
103
|
+
"@rollup/plugin-node-resolve": "^13.0.6",
|
|
104
104
|
"@rollup/plugin-strip": "^2.1.0",
|
|
105
|
-
"@rollup/plugin-typescript": "^8.
|
|
105
|
+
"@rollup/plugin-typescript": "^8.3.0",
|
|
106
106
|
"@types/lodash.isplainobject": "^4.0.6",
|
|
107
|
-
"@types/node": "^16.
|
|
107
|
+
"@types/node": "^16.11.6",
|
|
108
108
|
"@types/tap": "^15.0.5",
|
|
109
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
110
|
-
"@typescript-eslint/parser": "^
|
|
111
|
-
"core-js": "^3.
|
|
109
|
+
"@typescript-eslint/eslint-plugin": "^5.3.0",
|
|
110
|
+
"@typescript-eslint/parser": "^5.3.0",
|
|
111
|
+
"core-js": "^3.19.1",
|
|
112
112
|
"cross-env": "^7.0.3",
|
|
113
|
-
"eslint": "^
|
|
114
|
-
"lect": "^0.18.
|
|
115
|
-
"rollup": "^2.
|
|
113
|
+
"eslint": "^8.2.0",
|
|
114
|
+
"lect": "^0.18.5",
|
|
115
|
+
"rollup": "^2.59.0",
|
|
116
116
|
"rollup-plugin-ascii": "^0.0.3",
|
|
117
117
|
"rollup-plugin-banner": "^0.2.1",
|
|
118
118
|
"rollup-plugin-cleanup": "^3.2.1",
|
|
119
|
-
"rollup-plugin-dts": "^4.0.
|
|
119
|
+
"rollup-plugin-dts": "^4.0.1",
|
|
120
120
|
"rollup-plugin-terser": "^7.0.2",
|
|
121
|
-
"tap": "^15.0.
|
|
121
|
+
"tap": "^15.0.10",
|
|
122
122
|
"tslib": "^2.3.1",
|
|
123
|
-
"typescript": "^4.4.
|
|
123
|
+
"typescript": "^4.4.4"
|
|
124
124
|
},
|
|
125
125
|
"engines": {
|
|
126
126
|
"node": ">=12"
|