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.3 to 0.0.4

dist/FuzzyTree.js.map

2

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

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

@@ -1,230 +0,289 @@

(function (global, factory) {
if (typeof define === 'function' && define.amd) {
define(['exports', 'module', 'lodash'], factory);
} else if (typeof exports !== 'undefined' && typeof module !== 'undefined') {
factory(exports, module, require('lodash'));
} else {
var mod = {
exports: {}
};
factory(mod.exports, mod, global.lodash);
global.FuzzyTree = mod.exports;
}
})(this, function (exports, module, _lodash) {
/* jshint esnext:true */
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory(require("lodash"));
else if(typeof define === 'function' && define.amd)
define(["lodash"], factory);
else if(typeof exports === 'object')
exports["FuzzyTree"] = factory(require("lodash"));
else
root["FuzzyTree"] = factory(root["_"]);
})(this, function(__WEBPACK_EXTERNAL_MODULE_1__) {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
/* jshint esnext:true */
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
var _lodash = __webpack_require__(1);
var FuzzyTree = (function () {
/**
* Construct a new FuzzyTree node.
*/
function FuzzyTree() {
_classCallCheck(this, FuzzyTree);
this._separator = '.';
this._wildcard = '*';
this._greedy = '#';
// reset data, children and dummy:
this.reset();
}
_createClass(FuzzyTree, [{
key: 'reset',
/**
* Remove this node's data and children.
* @return {FuzzyTree} The node itself.
*/
value: function reset() {
this._data = null;
this._children = {};
this._dummy = false;
return this;
}
}, {
key: 'setData',
/**
* Set this node's data.
* @param {*} data The data to set.
* @return {FuzzyTree} The node itself.
*/
value: function setData(data) {
this._data = data;
return this;
}
}, {
key: 'getData',
/**
* Get this node's data.
* @return {*} This node's data.
*/
value: function getData() {
return this._data;
}
}, {
key: 'match',
/**
* Gather all the nodes in this tree who's path pattern matches the given
* path.
* @param {String|Array} path The path to match against.
* @return {Array} An array of FuzzyTree nodes who's path pattern matches
* the given path.
*/
value: function match(path) {
var _this = this;
if ((0, _lodash.isString)(path)) path = path.split(this._separator);
if (!(0, _lodash.isArray)(path)) throw Error('path must be an array or a string');
if (!path.every(_lodash.isString)) throw Error('all path sections must be strings');
if (path.some(function (s) {
return s.length === 0;
})) throw Error('path section cannot be empty');
if (path.some(function (s) {
return s === _this._wildcard || s === _this._greedy;
})) throw Error('path section cannot be a wildcard');
return this._match(path);
}
}, {
key: '_match',
value: function _match(path) {
var res = [],
child,
that = this;
if (!path.length && !this._dummy) {
// if the path is empty, return the node itself.
res.push(this);
} else {
// if the path to one of the children is equal to the next section
// in the requested path, traverse this child.
child = this._children[path[0]];
if (child) _push(res, child._match(path.slice(1)));
// if one of the children's path pattern is a wildcard, it also
// matches the next section of the requested path. traverse it too.
child = this._children[this._wildcard];
if (child) _push(res, child._match(path.slice(1)));
// if one of the children's path pattern is a greedy wildcard,
// traverse this child with all possible sub-paths of the requested
// path.
child = this._children[this._greedy];
if (child) traverseGreedy(child);
}
function traverseGreedy(child) {
var grandchilds = Object.keys(child._children),
wildcard = child._wildcard,
greedy = child._greedy;
if (!grandchilds.length) _push(res, child._match([]));else {
grandchilds.forEach(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)));
}
}
});
}
}
return res;
}
}, {
key: 'find',
/**
* Find the node under a specific path pattern.
* @param {String|Array} path The path pattern of the required node.
* @return {FuzzyTree|Null} The found node, or null if not found.
*/
value: function find(path) {
if ((0, _lodash.isString)(path)) path = path.split(this._separator);
if (!(0, _lodash.isArray)(path)) throw Error('path must be an array or a string');
if (!path.every(_lodash.isString)) throw Error('all path sections must be strings');
if (path.some(function (s) {
return s.length === 0;
})) throw Error('path section cannot be empty');
return this._find(path);
}
}, {
key: '_find',
value: function _find(path) {
if (!path.length) return this._dummy ? null : this;
if (!this._children[path[0]]) return null;
return this._children[path[0]].find(path.slice(1));
}
}, {
key: 'insert',
/**
* Insert a node under the specified path pattern. New nodes will be created
* along the way if needed. If a node already exists under this path pattern
* it will be resetted.
* @param {String|Array} path The path pattern of the new node.
* @return {FuzzyTree} The newly created node.
*/
value: function insert(path) {
if ((0, _lodash.isString)(path)) path = path.split(this._separator);
if (!(0, _lodash.isArray)(path)) throw Error('path must be an array or a string');
if (!path.every(_lodash.isString)) throw Error('all path sections must be strings');
if (path.some(function (s) {
return s.length === 0;
})) throw Error('path section cannot be empty');
return this._insert(path);
}
}, {
key: '_insert',
value: function _insert(path) {
if (!path.length) {
if (this._dummy) {
this._dummy = false;
return this;
}
return this.reset();
}
if (!this._children[path[0]]) {
// create a dummy node along the path
this._children[path[0]] = new FuzzyTree();
this._children[path[0]]._dummy = true;
}
return this._children[path[0]].insert(path.slice(1));
}
}]);
return FuzzyTree;
})();
function _push(target, elements) {
elements.forEach(function (e) {
return target.push(e);
});
}
exports['default'] = FuzzyTree;
module.exports = exports['default'];
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
/***/ },
/* 1 */
/***/ function(module, exports) {
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
module.exports = __WEBPACK_EXTERNAL_MODULE_1__;
var FuzzyTree = (function () {
/**
* Construct a new FuzzyTree node.
*/
function FuzzyTree() {
_classCallCheck(this, FuzzyTree);
this._separator = '.';
this._wildcard = '*';
this._greedy = '#';
// reset data, children and dummy:
this.reset();
}
_createClass(FuzzyTree, [{
key: 'reset',
/**
* Remove this node's data and children.
* @return {FuzzyTree} The node itself.
*/
value: function reset() {
this._data = null;
this._children = {};
this._dummy = false;
return this;
}
}, {
key: 'setData',
/**
* Set this node's data.
* @param {*} data The data to set.
* @return {FuzzyTree} The node itself.
*/
value: function setData(data) {
this._data = data;
return this;
}
}, {
key: 'getData',
/**
* Get this node's data.
* @return {*} This node's data.
*/
value: function getData() {
return this._data;
}
}, {
key: 'match',
/**
* Gather all the nodes in this tree who's path pattern matches the given
* path.
* @param {String|Array} path The path to match against.
* @return {Array} An array of FuzzyTree nodes who's path pattern matches
* the given path.
*/
value: function match(path) {
var _this = this;
if ((0, _lodash.isString)(path)) path = path.split(this._separator);
if (!(0, _lodash.isArray)(path)) throw Error('path must be an array or a string');
if (!path.every(_lodash.isString)) throw Error('all path sections must be strings');
if (path.some(function (s) {
return s.length === 0;
})) throw Error('path section cannot be empty');
if (path.some(function (s) {
return s === _this._wildcard || s === _this._greedy;
})) throw Error('path section cannot be a wildcard');
return this._match(path);
}
}, {
key: '_match',
value: function _match(path) {
var res = [],
child,
that = this;
if (!path.length && !this._dummy) {
// if the path is empty, return the node itself.
res.push(this);
} else {
// if the path to one of the children is equal to the next section
// in the requested path, traverse this child.
child = this._children[path[0]];
if (child) _push(res, child._match(path.slice(1)));
// if one of the children's path pattern is a wildcard, it also
// matches the next section of the requested path. traverse it too.
child = this._children[this._wildcard];
if (child) _push(res, child._match(path.slice(1)));
// if one of the children's path pattern is a greedy wildcard,
// traverse this child with all possible sub-paths of the requested
// path.
child = this._children[this._greedy];
if (child) traverseGreedy(child);
}
function traverseGreedy(child) {
var grandchilds = Object.keys(child._children),
wildcard = child._wildcard,
greedy = child._greedy;
if (!grandchilds.length) _push(res, child._match([]));else {
grandchilds.forEach(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)));
}
}
});
}
}
return res;
}
}, {
key: 'find',
/**
* Find the node under a specific path pattern.
* @param {String|Array} path The path pattern of the required node.
* @return {FuzzyTree|Null} The found node, or null if not found.
*/
value: function find(path) {
if ((0, _lodash.isString)(path)) path = path.split(this._separator);
if (!(0, _lodash.isArray)(path)) throw Error('path must be an array or a string');
if (!path.every(_lodash.isString)) throw Error('all path sections must be strings');
if (path.some(function (s) {
return s.length === 0;
})) throw Error('path section cannot be empty');
return this._find(path);
}
}, {
key: '_find',
value: function _find(path) {
if (!path.length) return this._dummy ? null : this;
if (!this._children[path[0]]) return null;
return this._children[path[0]].find(path.slice(1));
}
}, {
key: 'insert',
/**
* Insert a node under the specified path pattern. New nodes will be created
* along the way if needed. If a node already exists under this path pattern
* it will be resetted.
* @param {String|Array} path The path pattern of the new node.
* @return {FuzzyTree} The newly created node.
*/
value: function insert(path) {
if ((0, _lodash.isString)(path)) path = path.split(this._separator);
if (!(0, _lodash.isArray)(path)) throw Error('path must be an array or a string');
if (!path.every(_lodash.isString)) throw Error('all path sections must be strings');
if (path.some(function (s) {
return s.length === 0;
})) throw Error('path section cannot be empty');
return this._insert(path);
}
}, {
key: '_insert',
value: function _insert(path) {
if (!path.length) {
if (this._dummy) {
this._dummy = false;
return this;
}
return this.reset();
}
if (!this._children[path[0]]) {
// create a dummy node along the path
this._children[path[0]] = new FuzzyTree();
this._children[path[0]]._dummy = true;
}
return this._children[path[0]].insert(path.slice(1));
}
}]);
return FuzzyTree;
})();
function _push(target, elements) {
elements.forEach(function (e) {
return target.push(e);
});
}
module.exports = FuzzyTree;
/***/ }
/******/ ])
});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9GdXp6eVRyZWUuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O1FBUU0sU0FBUzs7Ozs7O0FBS0EsaUJBTFQsU0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YXZlcnNlR3JlZWR5KGNoaWxkLl9jaGlsZHJlblt3aWxkY2FyZF0pO1xuICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGdjID09PSBncmVlZHkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIGNvbnN1bWUgb25lIGFuZCBtb3ZlIG9uXG4gICAgICAgICAgICAgICAgICAgICAgICBfcHVzaChyZXMsIGNoaWxkLl9tYXRjaChwYXRoLnNsaWNlKDEpKSk7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAvLyB3ZSBuZWVkIHRvIGNvbnN1bWUgYXMgbXVjaCBhcyBwb3NzaWJsZSBmcm9tIHRoZSBwYXRoXG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgaSA9IF9sYXN0SW5kZXhPZihwYXRoLnNsaWNlKDEpLCBnYyk7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoaSA+IC0xKXtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfcHVzaChyZXMsIGNoaWxkLl9tYXRjaChwYXRoLnNsaWNlKGkgKyAxKSkpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gcmVzO1xuICAgIH1cblxuICAgIC8qKlxuICAgICAqIEZpbmQgdGhlIG5vZGUgdW5kZXIgYSBzcGVjaWZpYyBwYXRoIHBhdHRlcm4uXG4gICAgICogQHBhcmFtICB7U3RyaW5nfEFycmF5fSBwYXRoIFRoZSBwYXRoIHBhdHRlcm4gb2YgdGhlIHJlcXVpcmVkIG5vZGUuXG4gICAgICogQHJldHVybiB7RnV6enlUcmVlfE51bGx9IFRoZSBmb3VuZCBub2RlLCBvciBudWxsIGlmIG5vdCBmb3VuZC5cbiAgICAgKi9cbiAgICBmaW5kKHBhdGgpe1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GUgYWxvbmcgdGhlIHBhdGhcbiAgICAgICAgICAgIHRoaXMuX2NoaWxkcmVuW3BhdGhbMF1dID0gbmV3IEZ1enp5VHJlZSgpO1xuICAgICAgICAgICAgdGhpcy5fY2hpbGRyZW5bcGF0aFswXV0uX2R1bW15ID0gdHJ1ZTtcbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiB0aGlzLl9jaGlsZHJlbltwYXRoWzBdXS5pbnNlcnQocGF0aC5zbGljZSgxKSk7XG4gICAgfVxufVxuXG5mdW5jdGlvbiBfcHVzaCh0YXJnZXQsIGVsZW1lbnRzKXtcbiAgICBlbGVtZW50cy5mb3JFYWNoKGUgPT4gdGFyZ2V0LnB1c2goZSkpO1xufVxuXG5leHBvcnQgZGVmYXVsdCBGdXp6eVRyZWU7XG4iXX0=
;
//# sourceMappingURL=FuzzyTree.js.map
{
"name": "fuzzytree",
"version": "0.0.3",
"version": "0.0.4",
"description": "Fuzzy tree structure with non-deterministic nodes paths",

@@ -11,3 +11,3 @@ "main": "dist/FuzzyTree.js",

"test": "./node_modules/.bin/mocha --opts tests/mocha.opts tests",
"build": "./node_modules/.bin/babel --modules umd src/FuzzyTree.js --out-file dist/FuzzyTree.js --source-maps inline",
"build": "./node_modules/.bin/webpack",
"lint": "./node_modules/.bin/jshint src/**.js"

@@ -37,6 +37,10 @@ },

"babel": "^5.6.14",
"babel-core": "^5.6.15",
"babel-loader": "^5.3.1",
"jshint": "^2.8.0",
"mocha": "^2.2.5",
"should": "^7.0.1"
"node-libs-browser": "^0.5.2",
"should": "^7.0.1",
"webpack": "^1.10.1"
}
}
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