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

regexp-tpl

Package Overview
Dependencies
Maintainers
5
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

regexp-tpl - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

23

package.json
{
"name": "regexp-tpl",
"version": "2.0.0",
"version": "2.0.1",
"description": "Templated regular expressions.",
"main": "src/index.js",
"files": [
"src/index.js",
"LICENSE",
"README.md"
],
"scripts": {

@@ -34,13 +39,13 @@ "test": "mocha src/*.mocha.js",

"devDependencies": {
"coveralls": "^2.11.2",
"eslint": "^3.2.2",
"eslint-config-simplifield": "^3.0.0",
"istanbul": "^0.4.4",
"mocha": "^3.0.1"
"coveralls": "^3.0.2",
"eslint": "^5.8.0",
"eslint-config-simplifield": "^8.1.0",
"istanbul": "^0.4.5",
"mocha": "^5.2.0"
},
"dependencies": {
"debug": "^2.2.0",
"escape-regexp-component": "^1.0.2",
"miniquery": "^1.0.0"
"debug": "^4.1.0",
"escape-string-regexp": "^1.0.5",
"miniquery": "^1.1.2"
}
}

@@ -11,3 +11,4 @@ # regexp-tpl

[![Code Climate](https://codeclimate.com/github/SimpliField/regexp-tpl.svg)](https://codeclimate.com/github/SimpliField/regexp-tpl)
[![Package Quality](http://npm.packagequality.com/badge/regexp-tpl.png)](http://packagequality.com/#?package=regexp-tpl)
[![Package Quality](http://npm.packagequality.com/shield/regexp-tpl.png)](http://packagequality.com/#?package=regexp-tpl)
[![Dependency Status](https://dependencyci.com/github/SimpliField/regexp-tpl/badge)](https://dependencyci.com/github/SimpliField/regexp-tpl)

@@ -14,0 +15,0 @@ ## Installation

'use strict';
const escRegExp = require('escape-regexp-component');
const escRegExp = require('escape-string-regexp');
const miniquery = require('miniquery');
const debug = require('debug')('regexp-tpl');
const DEFAULT_TEMPLATE = /(.*|^)\{([a-z0-9_\-\.\*\@\#]+)\}(.*|$)/i;
const DEFAULT_TEMPLATE = /(.*|^)\{([a-z0-9_\-.*@#]+)\}(.*|$)/i;
function regexpTpl(objs, regExpTemplate, regExpFlags, templateRegExp) {
let hasUnmatchedTemplateValues = false;
let regExp;
if(!(objs instanceof Array)) {
if (!(objs instanceof Array)) {
throw Error('`objs` must be an instanceof `Array`');
}
if('string' !== typeof regExpTemplate) {
if ('string' !== typeof regExpTemplate) {
throw Error('`regExpTemplate` must be a string');

@@ -27,6 +26,6 @@ }

if(values.length) {
if (values.length) {
return $1 + (1 === values.length ?
escRegExp(values[0]) :
'(' + values.map(escRegExp).join('|') + ')') + $3;
`(${values.map(escRegExp).join('|')})`) + $3;
}

@@ -38,3 +37,3 @@

while((templateRegExp || DEFAULT_TEMPLATE).test(regExpTemplate)) {
while ((templateRegExp || DEFAULT_TEMPLATE).test(regExpTemplate)) {
regExpTemplate = regExpTemplate.replace(

@@ -46,3 +45,3 @@ (templateRegExp || DEFAULT_TEMPLATE),

if(hasUnmatchedTemplateValues) {
if (hasUnmatchedTemplateValues) {
debug('Could not build (unmatched template value):', regExpTemplate);

@@ -52,3 +51,4 @@ return {}.undef;

regExp = new RegExp(regExpTemplate, regExpFlags);
// eslint-disable-next-line
const regExp = new RegExp(regExpTemplate, regExpFlags);

@@ -55,0 +55,0 @@ debug('Built:', regExp);

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