swc/bundler/tests/.cache/deno/e15c629849ad80411d71bbfb9fed0866fd521c3c.ts
강동윤 d60c3242af
fix(swc): Fix bugs (#1739)
swc_bundler:
 - Fix cycle detection for complex circular imports. (denoland/deno#10752)

swc_ecma_transforms_typescript:
 - Allow using large values for an enum variant.
2021-05-25 14:30:17 +09:00

15 lines
571 B
TypeScript

// Loaded from https://deno.land/x/discordeno@11.0.0-rc.2/src/util/validate_length.ts
/** Validates the length of a string in JS. Certain characters in JS can have multiple numbers in length in unicode and discords api is in python which treats length differently. */
export function validateLength(text: string, options: { max?: number; min?: number }) {
const length = [...text].length;
// Text is too long
if (options.max && length > options.max) return false;
// Text is too short
if (options.min && length < options.min) return false;
return true;
}