UNPKG

locutus

Version:

Locutus other languages' standard libraries to JavaScript for fun and educational purposes

32 lines (31 loc) 1.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getCtypePattern = getCtypePattern; const _phpRuntimeState_ts_1 = require("./_phpRuntimeState.js"); const defaultCtypePatterns = { an: /^[A-Za-z\d]+$/g, al: /^[A-Za-z]+$/g, // biome-ignore lint/suspicious/noControlCharactersInRegex: intentional for LC_CTYPE control character class ct: /^[\u0000-\u001F\u007F]+$/g, dg: /^[\d]+$/g, gr: /^[\u0021-\u007E]+$/g, lw: /^[a-z]+$/g, pr: /^[\u0020-\u007E]+$/g, pu: /^[\u0021-\u002F\u003A-\u0040\u005B-\u0060\u007B-\u007E]+$/g, sp: /^[\f\n\r\t\v ]+$/g, up: /^[A-Z]+$/g, xd: /^[A-Fa-f\d]+$/g, }; function getCtypePattern(key) { const ctypeGroup = (0, _phpRuntimeState_ts_1.getPhpLocaleGroup)('LC_CTYPE', 'LC_CTYPE'); if (!ctypeGroup) { const fallbackPattern = defaultCtypePatterns[key]; return fallbackPattern ? new RegExp(fallbackPattern) : undefined; } const pattern = ctypeGroup[key]; if (pattern instanceof RegExp) { return new RegExp(pattern); } const fallbackPattern = defaultCtypePatterns[key]; return fallbackPattern ? new RegExp(fallbackPattern) : undefined; }