extra-utils 3.6.0 → 3.7.0
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 +8 -2
- package/lib/string/remove-leading-blank-lines.d.ts +1 -1
- package/lib/string/remove-leading-blank-lines.js +6 -2
- package/lib/string/remove-leading-blank-lines.js.map +1 -1
- package/lib/string/remove-trailing-blank-lines.d.ts +1 -1
- package/lib/string/remove-trailing-blank-lines.js +6 -2
- package/lib/string/remove-trailing-blank-lines.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -137,7 +137,10 @@ removeBlankLines(
|
|
|
137
137
|
|
|
138
138
|
#### removeLeadingBlankLines
|
|
139
139
|
```ts
|
|
140
|
-
function removeLeadingBlankLines(
|
|
140
|
+
function removeLeadingBlankLines(
|
|
141
|
+
text: string
|
|
142
|
+
, maxRemovals: number = Infinity
|
|
143
|
+
): string
|
|
141
144
|
```
|
|
142
145
|
|
|
143
146
|
Example:
|
|
@@ -153,7 +156,10 @@ removeLeadingBlankLines(
|
|
|
153
156
|
|
|
154
157
|
#### removeTrailingBlankLines
|
|
155
158
|
```ts
|
|
156
|
-
function removeTrailingBlankLines(
|
|
159
|
+
function removeTrailingBlankLines(
|
|
160
|
+
text: string
|
|
161
|
+
, maxRemovals: number = Infinity
|
|
162
|
+
): string
|
|
157
163
|
```
|
|
158
164
|
|
|
159
165
|
Example:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function removeLeadingBlankLines(text: string): string;
|
|
1
|
+
export declare function removeLeadingBlankLines(text: string, maxRemovals?: number): string;
|
|
@@ -2,10 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.removeLeadingBlankLines = void 0;
|
|
4
4
|
const utils_1 = require("./utils");
|
|
5
|
-
function removeLeadingBlankLines(text) {
|
|
5
|
+
function removeLeadingBlankLines(text, maxRemovals = Infinity) {
|
|
6
6
|
const lines = text.split('\n');
|
|
7
|
-
|
|
7
|
+
let removals = 0;
|
|
8
|
+
while (removals < maxRemovals &&
|
|
9
|
+
lines.length > 0 &&
|
|
10
|
+
(0, utils_1.isBlankLine)(lines[0])) {
|
|
8
11
|
lines.shift();
|
|
12
|
+
removals++;
|
|
9
13
|
}
|
|
10
14
|
return lines.join('\n');
|
|
11
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remove-leading-blank-lines.js","sourceRoot":"","sources":["../../src/string/remove-leading-blank-lines.ts"],"names":[],"mappings":";;;AAAA,mCAAqC;AAErC,SAAgB,uBAAuB,
|
|
1
|
+
{"version":3,"file":"remove-leading-blank-lines.js","sourceRoot":"","sources":["../../src/string/remove-leading-blank-lines.ts"],"names":[],"mappings":";;;AAAA,mCAAqC;AAErC,SAAgB,uBAAuB,CACrC,IAAY,EACZ,cAAsB,QAAQ;IAE9B,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAE9B,IAAI,QAAQ,GAAG,CAAC,CAAA;IAChB,OACE,QAAQ,GAAG,WAAW;QACtB,KAAK,CAAC,MAAM,GAAG,CAAC;QAChB,IAAA,mBAAW,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EACrB;QACA,KAAK,CAAC,KAAK,EAAE,CAAA;QACb,QAAQ,EAAE,CAAA;KACX;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACzB,CAAC;AAjBD,0DAiBC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function removeTrailingBlankLines(text: string): string;
|
|
1
|
+
export declare function removeTrailingBlankLines(text: string, maxRemovals?: number): string;
|
|
@@ -2,10 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.removeTrailingBlankLines = void 0;
|
|
4
4
|
const utils_1 = require("./utils");
|
|
5
|
-
function removeTrailingBlankLines(text) {
|
|
5
|
+
function removeTrailingBlankLines(text, maxRemovals = Infinity) {
|
|
6
6
|
const lines = text.split('\n');
|
|
7
|
-
|
|
7
|
+
let removals = 0;
|
|
8
|
+
while (removals < maxRemovals &&
|
|
9
|
+
lines.length > 0 &&
|
|
10
|
+
(0, utils_1.isBlankLine)(lines[lines.length - 1])) {
|
|
8
11
|
lines.pop();
|
|
12
|
+
removals++;
|
|
9
13
|
}
|
|
10
14
|
return lines.join('\n');
|
|
11
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remove-trailing-blank-lines.js","sourceRoot":"","sources":["../../src/string/remove-trailing-blank-lines.ts"],"names":[],"mappings":";;;AAAA,mCAAqC;AAErC,SAAgB,wBAAwB,
|
|
1
|
+
{"version":3,"file":"remove-trailing-blank-lines.js","sourceRoot":"","sources":["../../src/string/remove-trailing-blank-lines.ts"],"names":[],"mappings":";;;AAAA,mCAAqC;AAErC,SAAgB,wBAAwB,CACtC,IAAY,EACZ,cAAsB,QAAQ;IAE9B,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAE9B,IAAI,QAAQ,GAAG,CAAC,CAAA;IAChB,OACE,QAAQ,GAAG,WAAW;QACtB,KAAK,CAAC,MAAM,GAAG,CAAC;QAChB,IAAA,mBAAW,EAAC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,EACpC;QACA,KAAK,CAAC,GAAG,EAAE,CAAA;QACX,QAAQ,EAAE,CAAA;KACX;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACzB,CAAC;AAjBD,4DAiBC"}
|