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 CHANGED
@@ -137,7 +137,10 @@ removeBlankLines(
137
137
 
138
138
  #### removeLeadingBlankLines
139
139
  ```ts
140
- function removeLeadingBlankLines(text: string): string
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(text: string): string
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
- while (lines.length > 0 && (0, utils_1.isBlankLine)(lines[0])) {
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,CAAC,IAAY;IAClD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAE9B,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,IAAA,mBAAW,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE;QAChD,KAAK,CAAC,KAAK,EAAE,CAAA;KACd;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACzB,CAAC;AARD,0DAQC"}
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
- while (lines.length > 0 && (0, utils_1.isBlankLine)(lines[lines.length - 1])) {
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,CAAC,IAAY;IACnD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAE9B,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,IAAA,mBAAW,EAAC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,EAAE;QAC/D,KAAK,CAAC,GAAG,EAAE,CAAA;KACZ;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACzB,CAAC;AARD,4DAQC"}
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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "extra-utils",
3
- "version": "3.6.0",
3
+ "version": "3.7.0",
4
4
  "description": "Utilities for JavaScript and Typescript",
5
5
  "files": [
6
6
  "lib"