mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
26 lines
616 B
TypeScript
26 lines
616 B
TypeScript
const defaultOptions = {
|
|
name: '_0x([a-f0-9]){4}',
|
|
kind: 'var'
|
|
};
|
|
|
|
/**
|
|
* Returns string array RegExp
|
|
*
|
|
* @returns {RegExp}
|
|
*/
|
|
export function getStringArrayRegExp(stringArrayItems: string[], options: Partial<typeof defaultOptions> = {}): RegExp {
|
|
const mergedOptions = {
|
|
...defaultOptions,
|
|
...options
|
|
};
|
|
|
|
const { name, kind } = mergedOptions;
|
|
|
|
return new RegExp(
|
|
`function (${name}) *\\(\\) *{` +
|
|
`${kind}.*= *\\[${stringArrayItems.map((item: string) => `\'${item}\'`).join(',')}];.*` +
|
|
`return ${name}\\(\\); *` +
|
|
'}'
|
|
);
|
|
}
|