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 2.1.0 to 3.0.0

10

package.json
{
"name": "patrun",
"version": "2.1.0",
"version": "3.0.0",
"description": "A fast pattern matcher on JavaScript object properties.",

@@ -20,3 +20,3 @@ "homepage": "https://github.com/rjrodger/patrun",

"scripts": {
"test": "lab -v -P test -t 90",
"test": "lab -v -L -P test -t 90 -r console -o stdout -r html -o test/coverage.html",
"coveralls": "lab -s -P test -r lcov -I URL,URLSearchParams | coveralls",

@@ -27,3 +27,3 @@ "prettier": "prettier --write --no-semi --single-quote patrun.js lib/*.js test/*.js",

"repo-tag": "REPO_VERSION=`node -e \"console.log(require('./package').version)\"` && echo TAG: v$REPO_VERSION && git commit -a -m v$REPO_VERSION && git push && git tag v$REPO_VERSION && git push --tags;",
"repo-publish": "npm run prettier && npm test && npm run repo-tag && npm publish --registry http://registry.npmjs.org "
"repo-publish": "npm run prettier && npm run reset && npm run repo-tag && npm publish --registry http://registry.npmjs.org "
},

@@ -45,3 +45,3 @@ "license": "MIT",

"devDependencies": {
"@hapi/code": "^7.0.0",
"@hapi/code": "^8.0.1",
"@hapi/lab": "^21.0.0",

@@ -51,4 +51,4 @@ "benchmark": "^2.1.4",

"prettier": "^1.19.1",
"serve": "^11.2.0"
"serve": "^11.3.0"
}
}

@@ -1,5 +0,4 @@

/* Copyright (c) 2013-2019 Richard Rodger, MIT License, https://github.com/rjrodger/patrun */
/* Copyright (c) 2013-2020 Richard Rodger, MIT License, https://github.com/rjrodger/patrun */
;(function() {
/* jshint node:true, asi:true, eqnull:true */
'use strict'

@@ -10,5 +9,5 @@ var root = this

var _ = root._ || (has_require && require('lodash'))
if (!_)
throw new Error('patrun requires underscore, see http://underscorejs.org')
//var _ = root._ || (has_require && require('lodash'))
//if (!_)
// throw new Error('patrun requires underscore, see http://underscorejs.org')

@@ -38,4 +37,2 @@ var gex = root.gex || (has_require && require('gex'))

var PS = JSON.stringify(pat).replace(/ /g, '')
var customizer =

@@ -54,3 +51,3 @@ 'function' === typeof custom ? custom.call(self, pat, data) : null

pat[key] = val
;(custom.gex && val.match(/[\*\?]/) ? gexers : plains).push(key)
;(custom.gex && val.match(/[*?]/) ? gexers : plains).push(key)
})

@@ -67,3 +64,2 @@

// Partial matches return next wider match - see partial-match test
//var last_data

@@ -74,3 +70,3 @@ for (var i = 0; i < keys.length; i++) {

var gexer = custom.gex && val.match(/[\*\?]/) ? gex(val) : null
var gexer = custom.gex && val.match(/[*?]/) ? gex(val) : null
if (gexer) gexer.val$ = val

@@ -84,9 +80,5 @@

if (valmap && sort_key == keymap.sk) {
// console.log('ADD A', PS, sort_key, keymap.d)
//last_data = null == keymap.d ? last_data : keymap.d
add_gexer(keymap, key, gexer)
keymap = valmap[val] || (valmap[val] = {})
} else if (!keymap.k) {
// console.log('ADD B', PS, sort_key, keymap.d)
//last_data = null == keymap.d ? last_data : keymap.d
add_gexer(keymap, key, gexer)

@@ -96,6 +88,4 @@ keymap.k = key

keymap.v = {}
// keymap.d = null == keymap.d ? last_data : keymap.d
keymap = keymap.v[val] = {}
} else if (sort_key < keymap.sk) {
// console.log('ADD C', PS, sort_key, keymap.d)
var s = keymap.s,

@@ -116,3 +106,2 @@ g = keymap.g

} else {
// console.log('ADD D', PS, sort_key, keymap.d)
valmap = keymap.v

@@ -152,3 +141,3 @@ keymap = keymap.s || (keymap.s = {})

self.find = function(pat, exact) {
self.find = function(pat, exact, collect) {
if (null == pat) return null

@@ -163,3 +152,8 @@

var patlen = Object.keys(pat).length
var collection = []
if (void 0 !== top.d) {
collection.push(top.d)
}
do {

@@ -185,2 +179,15 @@ key = keymap.k

// follow separate trail without keys seen so far
if (collect && !exact) {
var remainkeys = Object.keys(pat).filter(k => !foundkeys[k])
var remainpat = {}
remainkeys.forEach(rk => (remainpat[rk] = pat[rk]))
var remaincollection = self.find(remainpat, false, true)
// omit first entry if top defined to avoid top duplicates
collection = collection.concat(
void 0 !== top.d ? remaincollection.slice(1) : remaincollection
)
}
if (keymap.s) {

@@ -192,10 +199,13 @@ stars.push(keymap.s)

void 0 === nextkeymap.d ? (exact ? null : data) : nextkeymap.d
//data = void 0 === nextkeymap.d ? null : nextkeymap.d
if (collect && void 0 !== nextkeymap.d) {
collection.push(nextkeymap.d)
}
finalfind = nextkeymap.f
keymap = nextkeymap
} else {
// last data
// data = (exact || void 0 === keymap.d) ? data : keymap.d
}
// no match found for this value, follow star trail
else {
keymap = keymap.s

@@ -227,3 +237,3 @@ }

return data
return collect ? collection : data
}

@@ -267,2 +277,4 @@

self.list = function(pat, exact) {
pat = pat || {}
function descend(keymap, match, missing, acc) {

@@ -279,3 +291,7 @@ if (keymap.v) {

for (var val in keymap.v) {
if (gexval.on(val)) {
if (
val === pat[key] ||
(!exact && null == pat[key]) ||
gexval.on(val)
) {
var valitermatch = { ...itermatch }

@@ -301,3 +317,3 @@ valitermatch[key] = val

if (nextkeymap && nextkeymap.v) {
if (nextkeymap && null != nextkeymap.v) {
descend(

@@ -371,6 +387,6 @@ nextkeymap,

var pal = pa.filter(function(x) {
return !x.match(/[\*\?]/)
return !x.match(/[*?]/)
})
var pas = pa.filter(function(x) {
return x.match(/[\*\?]/)
return x.match(/[*?]/)
})

@@ -377,0 +393,0 @@ pal.sort()

@@ -331,3 +331,3 @@ # patrun

## .find( {...subject...}, exact )
## .find( {...subject...}, exact, collect )

@@ -341,5 +341,14 @@ Return the unique match for this subject, or null if not found. The

If the optional third boolean parameter _collect_ is true, then `find`
returns an array of all sub matches (i.e run `find` on each element of
the power set of the subject pattern elements, and collate in breadth
first order). Thus `{a:1,b:2}` will generate
`{a:1}`,`{b:2}`,`{a:1,b:2}` searches. If _exact_ is true, only
increasing sub patterns in lexicographical order are chosen. Thus
`{a:1,b:2}` will generate `{a:1}`,`{a:1,b:2}`, omitting `{b:2}`. (You
probably want to set _exact_ to false!).
## .list( {...pattern-partial...}, exact )
## .list( {...pattern-partial...}, exact)
Return the list of registered patterns that contain this partial

@@ -346,0 +355,0 @@ pattern. You can use wildcards for property values. Omitted values

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