Sha256: dd69c38099ec2138bce84c4eb02dc9cd11731a998917930eb6dab77fc1db9ac9
Contents?: true
Size: 599 Bytes
Versions: 10
Compression:
Stored size: 599 Bytes
Contents
/** * The MIT License (MIT) * Copyright (c) 2017-present Dmitry Soshnikov <dmitry.soshnikov@gmail.com> */ 'use strict'; /** * A regexp-tree plugin to remove non-capturing empty groups. * * /(?:)a/ -> /a/ * /a|(?:)/ -> /a|/ */ module.exports = { Group: function Group(path) { var node = path.node, parent = path.parent; var childPath = path.getChild(); if (node.capturing || childPath) { return; } if (parent.type === 'Repetition') { path.getParent().replace(node); } else if (parent.type !== 'RegExp') { path.remove(); } } };
Version data entries
10 entries across 10 versions & 3 rubygems