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

patrun

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

patrun - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

patrun-min.map

5

package.json

@@ -18,3 +18,3 @@ {

"main": "patrun.js",
"version": "0.1.0",
"version": "0.1.1",
"scripts": {

@@ -29,2 +29,3 @@ "test": "./node_modules/.bin/jasmine-node ./test",

"patrun-min.js",
"patrun-min.map",
"LICENSE"

@@ -37,4 +38,4 @@ ],

"underscore": "~1.5.2",
"gex": "~0.1.2"
"gex": "~0.1.3"
}
}

2

patrun-min.js
/* Copyright (c) 2013 Richard Rodger, MIT License, https://github.com/rjrodger/patrun */
"use strict";(function(){var e=this,n=e.patrun,r="undefined"!=typeof require,t=e._,i=e.gex;if("undefined"==typeof t){if(!r)throw new Error("patrun requires underscore, see http://underscorejs.org");t=require("underscore")}if("undefined"==typeof i){if(!r)throw new Error("patrun requires gex, see https://github.com/rjrodger/gex");i=require("gex")}var u=e.patrun=function(){var r={},u={};return t.noConflict=function(){return e._=n,r},r.add=function(e,n){for(var i,o=t.keys(e).sort(),s=u,v=0;v<o.length;v++){var d=o[v],f=e[d];if(null!==f&&void 0!==f)if(i=s.v,i&&d==s.k)s=i[f]||(i[f]={});else if(s.k)if(d<s.k){var a=s.v,l=s.s;s.v={},s.s={k:s.k,v:a,s:l},s.k=d,s=s.v[f]={}}else i=s.v,s=s.s||(s.s={}),v--;else s.k=d,s.v={},s=s.v[f]={}}return void 0!==n&&s&&(s.d=n),r},r.find=function(e){var n,r=u,i=null;do if(n=r.k,r.v){var o=r.v[e[n]];o?(i=o.d,r=o):r=r.s}else r=null;while(r);return null===i&&0===t.keys(e).length&&void 0!==u.d&&(i=u.d),i},r.remove=function(e){var n,r=u,t=null,i=[];do if(n=r.k,r.v){var o=r.v[e[n]];o?(i.push({km:r,v:e[n]}),t=o.d,r=o):r=r.s}else r=null;while(r);if(void 0!==t){var s=i[i.length-1];s&&s.km&&s.km.v&&delete s.km.v[s.v]}},r.findall=function(e){function n(r,u,o,s){if(r.v){var v=r.k,d=i(e[v]);for(var f in r.v){var a=t.extend({},u),l=t.extend({},o);if(d.on(f)){a[v]=f,delete l[v];var p=r.v[f];0==t.keys(l).length&&p&&p.d?s.push({match:a,data:p.d}):p&&p.v&&n(p,t.extend({},a),t.extend({},l),s)}}var p=r.s;p&&n(p,t.extend({},a),t.extend({},l),s)}}var r=[];return n(u,{},t.extend({},e),r),r},r.toString=function(e){function n(e,n){for(var r=0;n>r;r++)e.push(" ")}function r(t,i,u,o){if(void 0!==t.d&&(n(i,u),i.push(e(t.d))),t.k&&(i.push("\n"),n(i,u),i.push(t.k+":")),t.v){u++;for(var o in t.v)i.push("\n"),n(i,u),i.push(o+" ->"),r(t.v[o],i,u+1,o);t.s&&(i.push("\n"),n(i,u),i.push("* ->"),r(t.s,i,u+1,o))}}e=t.isFunction(e)?e:function(e){return t.isFunction(e)?"<"+e.name+">":"<"+e+">"};var i=[];return r(u,i,0,""),i.join("")},r.inspect=r.toString,r.toJSON=function(e){return JSON.stringify(u,function(e,n){return t.isFunction(n)?"[Function]":n},e)},r};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=u),exports.patrun=u):e.patrun=u}).call(this);
"use strict";(function(){var e=this,n=e.patrun,r="undefined"!=typeof require,t=e._,u=e.gex;if("undefined"==typeof t){if(!r)throw new Error("patrun requires underscore, see http://underscorejs.org");t=require("underscore")}if("undefined"==typeof u){if(!r)throw new Error("patrun requires gex, see https://github.com/rjrodger/gex");u=require("gex")}var i=e.patrun=function(){var r={},i={};return r.noConflict=function(){return e.previous_patrun=n,r},r.add=function(e,n){for(var u,o=t.keys(e).sort(),s=i,v=0;v<o.length;v++){var d=o[v],f=e[d];if(null!==f&&void 0!==f)if(u=s.v,u&&d==s.k)s=u[f]||(u[f]={});else if(s.k)if(d<s.k){var a=s.v,l=s.s;s.v={},s.s={k:s.k,v:a,s:l},s.k=d,s=s.v[f]={}}else u=s.v,s=s.s||(s.s={}),v--;else s.k=d,s.v={},s=s.v[f]={}}return void 0!==n&&s&&(s.d=n),r},r.find=function(e){var n,r=i,u=null;do if(n=r.k,r.v){var o=r.v[e[n]];o?(u=o.d,r=o):r=r.s}else r=null;while(r);return null===u&&0===t.keys(e).length&&void 0!==i.d&&(u=i.d),u},r.remove=function(e){var n,r=i,t=null,u=[];do if(n=r.k,r.v){var o=r.v[e[n]];o?(u.push({km:r,v:e[n]}),t=o.d,r=o):r=r.s}else r=null;while(r);if(void 0!==t){var s=u[u.length-1];s&&s.km&&s.km.v&&delete s.km.v[s.v]}},r.findall=function(e){function n(r,i,o,s){if(r.v){var v=r.k,d=u(e[v]);for(var f in r.v){var a=t.extend({},i),l=t.extend({},o);if(d.on(f)){a[v]=f,delete l[v];var p=r.v[f];0==t.keys(l).length&&p&&p.d?s.push({match:a,data:p.d}):p&&p.v&&n(p,t.extend({},a),t.extend({},l),s)}}var p=r.s;p&&n(p,t.extend({},a),t.extend({},l),s)}}var r=[];return n(i,{},t.extend({},e),r),r},r.toString=function(e){function n(e,n){for(var r=0;n>r;r++)e.push(" ")}function r(t,u,i,o){if(void 0!==t.d&&(n(u,i),u.push(e(t.d))),t.k&&(u.push("\n"),n(u,i),u.push(t.k+":")),t.v){i++;for(var o in t.v)u.push("\n"),n(u,i),u.push(o+" ->"),r(t.v[o],u,i+1,o);t.s&&(u.push("\n"),n(u,i),u.push("* ->"),r(t.s,u,i+1,o))}}e=t.isFunction(e)?e:function(e){return t.isFunction(e)?"<"+e.name+">":"<"+e+">"};var u=[];return r(i,u,0,""),u.join("")},r.inspect=r.toString,r.toJSON=function(e){return JSON.stringify(i,function(e,n){return t.isFunction(n)?"[Function]":n},e)},r};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=i),exports.patrun=i):e.patrun=i}).call(this);
//# sourceMappingURL=patrun-min.map

@@ -7,3 +7,3 @@ /* Copyright (c) 2013 Richard Rodger, MIT License, https://github.com/rjrodger/patrun */

var root = this
var previousPatrun = root.patrun
var previous_patrun = root.patrun

@@ -35,4 +35,5 @@ var has_require = typeof require !== 'undefined'

_.noConflict = function() {
root._ = previousPatrun;
self.noConflict = function() {
root.previous_patrun = previous_patrun;
return self;

@@ -39,0 +40,0 @@ }

@@ -39,2 +39,3 @@ # patrun

[![Build Status](https://travis-ci.org/rjrodger/patrun.png?branch=master)](https://travis-ci.org/rjrodger/patrun)

@@ -209,3 +210,3 @@

* 1: More specific mathches beat less specific matches. That is, more property values beat fewer.
* 1: More specific matches beat less specific matches. That is, more property values beat fewer.
* 2: Property names are checked in alphabetical order.

@@ -216,3 +217,54 @@

# API
## patrun()
Generates a new pattern matcher instance.
## .add( {...pattern...}, object )
Register a pattern, and the object that will be returned if an input matches.
## .find( {...pattern...} )
Return the unique match for this pattern, or null if not found
## .findall( {...pattern...} )
Return the list of matches for this pattern. You can use wildcards for property values.
Omitted values are *not* equivalent to a wildcard of _"*"_, you must specify each property explicitly.
```JavaScript
pm = patrun()
.add({a:1,b:1},'B1')
.add({a:1,b:2},'B2')
// finds nothing: []
console.log( pm.findall({a:1}) )
// finds:
// [ { match: { a: '1', b: '1' }, data: 'B1' },
// { match: { a: '1', b: '2' }, data: 'B2' } ]
console.log( pm.findall({a:1,b:'*'}) )
```
## .remove( {...pattern...} )
Remove this pattern, and it's object, from the matcher.
## .toString( func )
Generate a string representation of the decision tree for debugging. Optionally provide a formatting function for objects.
## .toJSON( indent )
Generate JSON representation of the tree.
# Development

@@ -219,0 +271,0 @@

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