@@ -201,18 +201,17 @@ function wrap(middleware, callback) {
201
201
}
202
202
}
203
203
204
- var own$8 = {}.hasOwnProperty;
205
204
function stringifyPosition(value) {
206
205
if (!value || typeof value !== 'object') {
207
206
return ''
208
207
}
209
- if (own$8.call(value, 'position') || own$8.call( value, 'type') ) {
208
+ if ('position' in value || 'type' in value ) {
210
209
return position(value.position)
211
210
}
212
- if (own$8.call(value, 'start') || own$8.call( value, 'end') ) {
211
+ if ('start' in value || 'end' in value ) {
213
212
return position(value)
214
213
}
215
- if (own$8.call(value, 'line') || own$8.call( value, 'column') ) {
214
+ if ('line' in value || 'column' in value ) {
216
215
return point$1(value)
217
216
}
218
217
return ''
@@ -229,19 +228,18 @@ function index(value) {
229
228
230
229
class VFileMessage extends Error {
231
230
constructor(reason, place, origin) {
232
- var parts = [null, null];
233
- var position = {
231
+ const parts = [null, null];
232
+ let position = {
234
233
start: {line: null, column: null},
235
234
end: {line: null, column: null}
236
235
};
237
- var index;
238
236
super();
239
237
if (typeof place === 'string') {
240
238
origin = place;
241
- place = null ;
239
+ place = undefined ;
242
240
}
243
241
if (typeof origin === 'string') {
244
- index = origin.indexOf(':');
242
+ const index = origin.indexOf(':');
245
243
if (index === -1) {
246
244
parts[1] = origin;
247
245
} else {
@@ -21228,29 +21226,33 @@ function stringWidth(string, options = {}) {
21228
21226
if (typeof string !== 'string' || string.length === 0) {
21229
21227
return 0;
21230
21228
}
21229
+ options = {
21230
+ ambiguousIsNarrow: true,
21231
+ ...options
21232
+ };
21231
21233
string = stripAnsi(string);
21232
21234
if (string.length === 0) {
21233
21235
return 0;
21234
21236
}
21235
21237
string = string.replace(emojiRegex(), ' ');
21236
- const ambiguousCharWidth = options.ambiguousIsNarrow ? 1 : 2;
21238
+ const ambiguousCharacterWidth = options.ambiguousIsNarrow ? 1 : 2;
21237
21239
let width = 0;
21238
- for (let index = 0; index < string.length; index++ ) {
21239
- const codePoint = string .codePointAt(index );
21240
+ for (const character of string) {
21241
+ const codePoint = character .codePointAt(0 );
21240
21242
if (codePoint <= 0x1F || (codePoint >= 0x7F && codePoint <= 0x9F)) {
21241
21243
continue;
21242
21244
}
21243
21245
if (codePoint >= 0x300 && codePoint <= 0x36F) {
21244
21246
continue;
21245
21247
}
21246
- const code = eastAsianWidth.eastAsianWidth(string.charAt(index) );
21248
+ const code = eastAsianWidth.eastAsianWidth(character );
21247
21249
switch (code) {
21248
21250
case 'F':
21249
21251
case 'W':
21250
21252
width += 2;
21251
21253
break;
21252
21254
case 'A':
21253
- width += ambiguousCharWidth ;
21255
+ width += ambiguousCharacterWidth ;
21254
21256
break;
21255
21257
default:
21256
21258
width += 1;
0 commit comments