Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

named-regexp-groups

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

named-regexp-groups - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3-0

dist/index.es.js

105

package.json
{
"name": "named-regexp-groups",
"version": "1.0.2",
"version": "1.0.3-0",
"description": "Regular expressions with named capture groups and named back-references",
"main": "lib",
"jsnext:main": "src",
"keywords": [
"regular",
"backreference",
"capture",
"expression",
"group",
"named",
"regex",
"regexp",
"named",
"capture",
"group",
"backreference"
"regular"
],

@@ -23,2 +21,4 @@ "homepage": "https://github.com/commenthol/named-regexp-groups/",

"author": "commenthol <commenthol@gmail.com>",
"main": "dist/index.js",
"module": "dist/index.es.js",
"repository": {

@@ -29,21 +29,36 @@ "type": "git",

"scripts": {
"__prepublish": "npm run clean && npm run lint && npm run build && npm test",
"test": "mocha",
"coverage": "nyc --reporter=html --reporter=text mocha",
"build": "babel -d lib src",
"all": "npm run clean && npm run lint && npm run build && npm test",
"build": "rollup -c rollup.conf.js",
"clean": "rimraf dist coverage .nyc_output",
"clean:all": "rimraf node_modules && npm run clean",
"coverage": "nyc -r text -r html npm test",
"lint": "eslint '**/*.js'",
"clean": "rimraf lib coverage"
"prepublishOnly": "npm run all",
"test": "mocha"
},
"devDependencies": {
"babel-cli": "^6.18.0",
"babel-core": "^6.21.0",
"babel-preset-es2015": "^6.18.0",
"babel-preset-stage-0": "^6.16.0",
"babel-preset-stage-1": "^6.16.0",
"babel-preset-stage-2": "^6.18.0",
"babel-register": "^6.18.0",
"core-js": "^2.4.1",
"mocha": "*",
"rimraf": "*",
"safe-regex": "^1.1.0"
"babel": {
"env": {
"development": {
"presets": [
"env",
"stage-2"
]
},
"es5": {
"presets": [
[
"env",
{
"modules": false
}
],
"stage-2"
]
}
},
"ignore": [
"./node_modules",
"./lib",
"./dist/index.js"
]
},

@@ -55,15 +70,31 @@ "eslintConfig": {

],
"rules": {}
"rules": {
"spaced-comment": 0
}
},
"babel": {
"ignore": [
"node_modules"
],
"presets": [
"es2015",
"stage-0",
"stage-1",
"stage-2"
]
}
"dependencies": {},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-preset-env": "^1.6.1",
"babel-preset-stage-2": "^6.24.1",
"babel-register": "^6.26.0",
"core-js": "^2.5.5",
"eslint": "^4.19.1",
"eslint-config-standard": "^11.0.0",
"eslint-plugin-import": "^2.11.0",
"eslint-plugin-node": "^6.0.1",
"eslint-plugin-promise": "^3.7.0",
"eslint-plugin-standard": "^3.0.1",
"mocha": "^5.1.1",
"nyc": "^11.7.1",
"rimraf": "^2.6.2",
"rollup": "^0.58.1",
"rollup-plugin-babel": "^3.0.3",
"rollup-plugin-uglify": "^3.0.0",
"safe-regex": "^1.1.0"
},
"maintainers": [
"commenthol <commenthol@gmail.com>"
]
}

@@ -6,2 +6,3 @@ # named-regexp-groups

[![NPM version](https://badge.fury.io/js/named-regexp-groups.svg)](https://www.npmjs.com/package/named-regexp-groups)
[![Build Status](https://secure.travis-ci.org/commenthol/named-regexp-groups.svg?branch=master)](https://travis-ci.org/commenthol/named-regexp-groups)

@@ -19,2 +20,3 @@ Create a named capture group with `(?<name>.*)` or `(:<name>.*)` when using

* [String.split](#string-split)
* [ES7](#es7)
* [License](#license)

@@ -56,3 +58,3 @@

```js
var r = new NamedRegExp('(?<foo>foo)(?<bar>)(-)(?:wat)(?<na>(?:na)+)(?&na)')
var r = new NamedRegExp('(?<foo>foo)(?<bar>bar)(-)(?:wat)(?<na>(?:na)+)(?&na)')
r.exec('nanafoobar-watnana')

@@ -77,4 +79,4 @@ // => [ 'foobar-watnana', 'foo', 'bar', '-', 'na', 'na',

If using a string as replacement use `$+{name}` to define the placeholder for the capture group.
This follows the Syntax of [PCRE Named backreferences](http://perldoc.perl.org/perlretut.html#Named-backreferences).
If using a string as replacement use `$+{name}` to define the placeholder for the capture group.
This follows the Syntax of [PCRE Named backreferences][].

@@ -115,2 +117,17 @@ ```js

## ES7
The proposed [TC39 proposal-regexp-named-groups](https://github.com/tc39/proposal-regexp-named-groups) is finding it's way into the standard.
Chrome>=64 already supports named groups. Maybe node>=10 soon as well...
Paste this into Chrome>=64
```js
r = new RegExp(/(?<foo>foo)(?<bar>bar)(-)(?:wat)(?<na>(?:na)+)/);
o = r.exec('nanafoobar-watnana')
//> (5) ["foobar-watnana", "foo", "bar", "-", "na",
//> index: 4, input: "nanafoobar-watnana",
//> groups: {foo: "foo", bar: "bar", na: "nana"}]
```
## License

@@ -121,1 +138,2 @@

[license]: ./LICENSE
[PCRE Named backreferences]: http://perldoc.perl.org/perlretut.html#Named-backreferences

@@ -7,3 +7,3 @@ /*!

const R_NAME = /([a-zA-Z_$][a-zA-Z_$0-9]{0,50})/
const R_NAME_REPLACE = new RegExp(`\\$\\+{${R_NAME.source}}`, 'g')
export const R_NAME_REPLACE = new RegExp(`\\$\\+{${R_NAME.source}}`, 'g')
const R_NAMED_BACKREF = new RegExp(`^[?:]&${R_NAME.source}`)

@@ -14,6 +14,3 @@ const R_GROUP = new RegExp(`^[?:]<${R_NAME.source}>([^]*)`)

exports.R_NAME_REPLACE = R_NAME_REPLACE
exports.generate = generate
function generate (str, flags) {
export function generate (str, flags) {
str = str || ''

@@ -36,5 +33,5 @@ var groups = {}

var store = {
count: 0, // counter for unnamed matching group
count: 0, // counter for unnamed matching group
groups: [''], // store for named pattern
names: [] // store for names of capture groups
names: [] // store for names of capture groups
}

@@ -99,6 +96,6 @@

})
.join('')
.replace(R_EMPTY_GROUPS, '') // remove any empty groups
.join('')
.replace(R_EMPTY_GROUPS, '') // remove any empty groups
return {source, flags, groups, named}
}

@@ -5,7 +5,7 @@ /*!

*/
/**
* @module named-regexp-groups
*/
/**
* @module named-regexp-groups
*/
const {generate, R_NAME_REPLACE} = require('./generate')
import {generate, R_NAME_REPLACE} from './generate'

@@ -191,2 +191,1 @@ /**

}
module.exports = NamedRegExp
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc