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

gex

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gex - npm Package Compare versions

Comparing version 0.0.1 to 0.0.3

86

lib/gex.js

@@ -8,17 +8,2 @@

var gexstr = ''+gexexp
if( _.isNull(gexexp)
|| _.isNaN(gexexp)
|| _.isUndefined(gexexp) ) {
gexstr = ''
}
gexstr = gexstr.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
gexstr = gexstr.replace(/\\\*/g,'.*')
gexstr = gexstr.replace(/\\\?/g,'.')
gexstr = '^'+gexstr+'$'
var re = new RegExp(gexstr)
function dodgy(obj) {

@@ -30,2 +15,31 @@ return ( _.isNull(obj)

function clean(gexexp) {
var gexstr = ''+gexexp
if( _.isNull(gexexp)
|| _.isNaN(gexexp)
|| _.isUndefined(gexexp) ) {
gexstr = ''
}
return gexstr
}
function gexstr(gexexp) {
var gs = []
if( _.isArray(gexexp) || _.isArguments(gexexp) ) {
for( var i = 0; i < gexexp.length; i++ ){
var s = clean(gexexp[i])
gexexp.push(
( '*' == s || '?' == s ) ? s
: self.esc(s)
)
}
gs = gs.join('')
}
else {
gs = clean(gexexp)
}
return gs
}
self.on = function(obj) {

@@ -74,2 +88,44 @@ if( _.isString(obj)

}
self.esc = function(gexexp) {
var gexstr = clean(gexexp)
gexstr = gexstr.replace(/\*/g,'**')
gexstr = gexstr.replace(/\?/g,'*?')
return gexstr
}
self.re = function(gs) {
if( '' == gs || gs ) {
var gs = self.escregexp(gs)
// use [\s\S] instead of . to match newlines
gs = gs.replace(/\\\*/g,'[\\s\\S]*')
gs = gs.replace(/\\\?/g,'[\\s\\S]')
//gs = gs.replace(/\\\*/g,'.*')
//gs = gs.replace(/\\\?/g,'.')
// escapes ** and *?
gs = gs.replace(/\[\\s\\S\]\*\[\\s\\S\]\*/g,'\\\*')
gs = gs.replace(/\[\\s\\S\]\*\[\\s\\S\]/g,'\\\?')
gs = '^'+gs+'$'
return new RegExp(gs)
}
else {
return re
}
}
self.escregexp = function(restr) {
return restr ? (''+restr).replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&") : ''
}
self.toString = function() {
return str
}
var str = gexstr(gexexp)
var re = self.re(str)
}

@@ -76,0 +132,0 @@

2

package.json

@@ -5,3 +5,3 @@ {

"keywords": ["glob","star","question","mark","expression","regular"],
"version": "0.0.1",
"version": "0.0.3",
"homepage": "https://github.com/rjrodger/gex",

@@ -8,0 +8,0 @@ "author": "Richard Rodger <richard@ricebridge.com> (http://richardrodger.com/)",

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