feat: init
This commit is contained in:
33
node_modules/regexp-tree/dist/optimizer/transforms/char-class-remove-duplicates-transform.js
generated
vendored
Normal file
33
node_modules/regexp-tree/dist/optimizer/transforms/char-class-remove-duplicates-transform.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
* Copyright (c) 2017-present Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* A regexp-tree plugin to remove duplicates from character classes.
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
CharacterClass: function CharacterClass(path) {
|
||||
var node = path.node;
|
||||
|
||||
var sources = {};
|
||||
|
||||
for (var i = 0; i < node.expressions.length; i++) {
|
||||
var childPath = path.getChild(i);
|
||||
var source = childPath.jsonEncode();
|
||||
|
||||
if (sources.hasOwnProperty(source)) {
|
||||
childPath.remove();
|
||||
|
||||
// Since we remove the current node.
|
||||
// TODO: make it simpler for users with a method.
|
||||
i--;
|
||||
}
|
||||
|
||||
sources[source] = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user