UNPKG

@skhemata/skhemata-form

Version:

Skhemata Form Web Component. This web component can be used as base web component when working with forms and inputs.

19 lines (17 loc) 590 B
import assertString from './util/assertString'; /* eslint-disable prefer-rest-params */ export default function isLength(str, options) { assertString(str); let min; let max; if (typeof (options) === 'object') { min = options.min || 0; max = options.max; } else { // backwards compatibility: isLength(str, min [, max]) min = arguments[1] || 0; max = arguments[2]; } const surrogatePairs = str.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g) || []; const len = str.length - surrogatePairs.length; return len >= min && (typeof max === 'undefined' || len <= max); }