This repository has been archived on 2024-07-27. You can view files and clone it, but cannot push or open issues or pull requests.
keksAccountGUI/node_modulesOLD/regexp-tree/dist/optimizer/transforms/char-surrogate-pair-to-sing...

27 lines
611 B
JavaScript

/**
* The MIT License (MIT)
* Copyright (c) 2017-present Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
*/
'use strict';
/**
* A regexp-tree plugin to transform surrogate pairs into single unicode code point
*
* \ud83d\ude80 -> \u{1f680}
*/
module.exports = {
shouldRun: function shouldRun(ast) {
return ast.flags.includes('u');
},
Char: function Char(path) {
var node = path.node;
if (node.kind !== 'unicode' || !node.isSurrogatePair || isNaN(node.codePoint)) {
return;
}
node.value = '\\u{' + node.codePoint.toString(16) + '}';
delete node.isSurrogatePair;
}
};