New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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.3 to 0.1.1

LICENSE.txt

52

lib/gex.js

@@ -0,6 +1,9 @@

/* Copyright (c) 2011-2013 Richard Rodger, MIT License */
"use strict";
var _ = require('underscore')
function Gex(gexexp) {
function Gex(gexspec) {
var self = this

@@ -43,2 +46,15 @@

function match(str) {
str = ''+str
var hasmatch = false
var gexstrs = _.keys(gexmap)
//console.log(gexstrs)
for(var i = 0; i < gexstrs.length && !hasmatch; i++ ) {
hasmatch = !!gexmap[gexstrs[i]].exec(str)
//console.log(hasmatch+' '+gexstrs[i]+' '+str)
}
return hasmatch
}
self.on = function(obj) {

@@ -52,3 +68,4 @@ if( _.isString(obj)

{
return (!!re.exec(''+obj)) ? obj : null
//return (!!re.exec(''+obj)) ? obj : null
return match(obj) ? obj : null
}

@@ -61,3 +78,4 @@

for( var i = 0; i < obj.length; i++ ) {
if( !dodgy(obj[i]) && !!re.exec(''+obj[i]) ) {
//if( !dodgy(obj[i]) && !!re.exec(''+obj[i]) ) {
if( !dodgy(obj[i]) && match(obj[i]) ) {
out.push(obj[i])

@@ -73,7 +91,8 @@ }

else if( 'object' == typeof(obj) ) {
else if( _.isObject(obj) ) {
var out = {}
for( var p in obj ) {
if( obj.hasOwnProperty(p) ) {
if( !!re.exec(p) ) {
//if( !!re.exec(p) ) {
if( match(p) ) {
out[p] = obj[p]

@@ -118,3 +137,4 @@ }

else {
return re
var gexstrs = _.keys(gexmap)
return 1 == gexstrs.length ? gexmap[gexstrs[0]] : _.clone(gexmap)
}

@@ -128,12 +148,22 @@ }

self.toString = function() {
return str
return ''+_.keys(gexmap)
}
var str = gexstr(gexexp)
var re = self.re(str)
var gexstrs = (null==gexspec||_.isNaN(gexspec)) ? [] : _.isArray(gexspec) ? gexspec : [gexspec]
//console.log(gexstrs)
var gexmap = {}
_.each( gexstrs, function(str) {
var re = self.re(str)
gexmap[str]=re
})
//console.dir(gexmap)
}
function gex(gexexp) {
var gex = new Gex(gexexp)
function gex(gexspec) {
var gex = new Gex(gexspec)
return gex

@@ -140,0 +170,0 @@ }

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

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

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

],
"license": "MIT",
"dependencies": {
"underscore": ">=1.1.4"
"underscore": "~1.4.4"
},

@@ -23,3 +24,8 @@ "main": "lib/gex",

"node": "*"
}
},
"files":[
"README.md",
"LICENSE.txt",
"lib/gex.js"
]
}

@@ -5,8 +5,9 @@ # gex

Current Version: 0.0.1
Current Version: 0.1.1
Tested on: node 0.4.1
Tested on: node 0.8
Glob expressions for JavaScript
## Glob expressions for JavaScript
*"When regular expressions are just too hard!"*

@@ -29,2 +30,8 @@

And also match against multiple globs:
gex(['a*','b*']).on( 'bx' ) // returns 'bx'
gex(['a*','b*']).on( ['ax','zz','bx'] ) // returns ['ax','bx']
One of the most useful things you can do with this library is quick

@@ -76,12 +83,10 @@ assertions in unit tests. For example if your objects contain dates,

The unit tests use [expresso](https://github.com/visionmedia/expresso)
The unit tests use [mocha](https://github.com/visionmedia/mocha)
npm install expresso
npm install mocha
The tests are in test/gex.test.js
Run with:
mocha test/gex.test.js
## Hacking around with real time charts
![](http://chartaca.com/point/adb6995d-b4b3-4edf-8892-a6d1a2324831/s.gif)
[Chartaca Hit Chart](http://chartaca.com/adb6995d-b4b3-4edf-8892-a6d1a2324831)
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