Skip to content

Commit

Permalink
Updated isLength.js
Browse files Browse the repository at this point in the history
  • Loading branch information
bevatsal1122 committed Nov 18, 2022
1 parent 2897ef9 commit 22bb2f0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib/isLength.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ export default function isLength(str, options) {
min = arguments[1] || 0;
max = arguments[2];
}

const presentationSequences = str.match(/(\uFE0F|\uFE0E)/g) || [];
const surrogatePairs = str.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g) || [];
const len = str.length - presentationSequences.length - surrogatePairs.length;
const isInsideRange = len >= min && (typeof max === 'undefined' || len <= max);

if (isInsideRange && Array.isArray(options?.discreteLengths)) {
if (isInsideRange && Array.isArray(options?.discreteLengths)){
return options.discreteLengths.some(discreteLen => discreteLen === len);
}

Expand Down

0 comments on commit 22bb2f0

Please sign in to comment.