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

fuzzytree

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fuzzytree - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

2

bower.json
{
"name": "fuzzytree",
"main": "dist/FuzzyTree.js",
"version": "0.0.5",
"version": "0.0.6",
"homepage": "https://github.com/EyalAr/FuzzyTree",

@@ -6,0 +6,0 @@ "authors": [

@@ -179,19 +179,18 @@ (function webpackUniversalModuleDefinition(root, factory) {

greedy = child._greedy;
if (!grandchilds.length) _push(res, child._match([]));else {
(0, _lodash.forEach)(grandchilds, function (gc) {
if (gc === wildcard) {
// consume as much as possible, only if at least two left
traverseGreedy(child._children[wildcard]);
} else if (gc === greedy) {
// consume one and move on
_push(res, child._match(path.slice(1)));
} else {
// we need to consume as much as possible from the path
var i = (0, _lodash.lastIndexOf)(path.slice(1), gc);
if (i > -1) {
_push(res, child._match(path.slice(i + 1)));
}
_push(res, child._match([]));
(0, _lodash.forEach)(grandchilds, function (gc) {
if (gc === wildcard) {
// consume as much as possible, only if at least two left
traverseGreedy(child._children[wildcard]);
} else if (gc === greedy) {
// consume one and move on
_push(res, child._match(path.slice(1)));
} else {
// we need to consume as much as possible from the path
var i = (0, _lodash.lastIndexOf)(path.slice(1), gc);
if (i > -1) {
_push(res, child._match(path.slice(i + 1)));
}
});
}
}
});
}

@@ -198,0 +197,0 @@

{
"name": "fuzzytree",
"version": "0.0.5",
"version": "0.0.6",
"description": "Fuzzy tree structure with non-deterministic nodes paths",

@@ -5,0 +5,0 @@ "main": "dist/FuzzyTree.js",

@@ -107,20 +107,18 @@ /* jshint esnext:true */

greedy = child._greedy;
if (!grandchilds.length) _push(res, child._match([]));
else {
_forEach(grandchilds, gc => {
if (gc === wildcard) {
// consume as much as possible, only if at least two left
traverseGreedy(child._children[wildcard]);
} else if (gc === greedy) {
// consume one and move on
_push(res, child._match(path.slice(1)));
} else {
// we need to consume as much as possible from the path
var i = _lastIndexOf(path.slice(1), gc);
if (i > -1){
_push(res, child._match(path.slice(i + 1)));
}
_push(res, child._match([]));
_forEach(grandchilds, gc => {
if (gc === wildcard) {
// consume as much as possible, only if at least two left
traverseGreedy(child._children[wildcard]);
} else if (gc === greedy) {
// consume one and move on
_push(res, child._match(path.slice(1)));
} else {
// we need to consume as much as possible from the path
var i = _lastIndexOf(path.slice(1), gc);
if (i > -1){
_push(res, child._match(path.slice(i + 1)));
}
});
}
}
});
}

@@ -127,0 +125,0 @@

@@ -386,4 +386,41 @@ import should from "should";

describe("one node a child of another greedy node", function(){
var node = new FuzzyTree(),
pattern1 = "test.hello.#",
pattern2 = "test.hello.#.foo",
newNode1 = node.insert(pattern1),
newNode2 = node.insert(pattern2);
it("should match one node", function(){
var path = "test.hello.world.nice.to.meet.you.foo.bar",
nodes = node.match(path);
nodes.should.have.length(1);
nodes[0].should.be.instanceOf(FuzzyTree);
nodes[0].should.equal(newNode1);
});
it("should match two nodes", function(){
var path = "test.hello.world.hi.bar.baz.bar.foo",
nodes = node.match(path);
nodes.should.have.length(2);
nodes[0].should.be.instanceOf(FuzzyTree);
nodes[1].should.be.instanceOf(FuzzyTree);
nodes.should.containEql(newNode1);
nodes.should.containEql(newNode2);
});
it("should match zero nodes", function(){
var path = "hello",
nodes = node.match(path);
nodes.should.have.length(0);
});
});
});
});

Sorry, the diff of this file is not supported yet

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