bugfix + notes and cleanup...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2018-12-22 02:52:17 +03:00
parent fbcc0b358a
commit 70dcb5aafa

View File

@ -25,13 +25,13 @@
* - will it be faster? * - will it be faster?
* *
* *
* XXX should we do .optimizeTags(tag) on .tag(tag)??? * XXX Q: should we do .optimizeTags(tag) on .tag(tag)???
* ...this might lead to non-trivial behaviour... * ...this might lead to non-trivial behaviour...
* XXX should this serialize recursively down (i.e. serialize items)??? * XXX Q: should this serialize recursively down (i.e. serialize items)???
* ...it might be a good idea to decide on a serialization * ...it might be a good idea to decide on a serialization
* protocol and use it throughout... * protocol and use it throughout...
* XXX should .tags() return all the used tags + .persistent or * XXX Q: should definitions be displayed as persistent tags???
* .persistentAll ??? * ...should this be an option???
* *
* *
* *
@ -268,7 +268,7 @@ var BaseTagsPrototype = {
// //
// Format: // Format:
// { // {
// <tag>: [ <item>, ... ], // <tag>: Set([ <item>, ... ]),
// ... // ...
// } // }
// //
@ -296,8 +296,6 @@ var BaseTagsPrototype = {
// .define('birds', 'bird:many') // .define('birds', 'bird:many')
// is equivalent to: // is equivalent to:
// .togglePersistent('bird:many/birds') // .togglePersistent('bird:many/birds')
//
// XXX Q: should definitions be displayed as persistent tags???
definitions: null, definitions: null,
// Props... // Props...
@ -568,10 +566,6 @@ var BaseTagsPrototype = {
match: function(a, b, cmp){ match: function(a, b, cmp){
var that = this var that = this
// root or base?
var edge = /^\s*[\\\/]/.test(a)
|| /[\\\/]\s*$/.test(a)
// get paths with tag... // get paths with tag...
var paths = function(tag){ var paths = function(tag){
return that.directMatch(tag, cmp) return that.directMatch(tag, cmp)
@ -600,13 +594,15 @@ var BaseTagsPrototype = {
res res
: seen.has(tag) ? : seen.has(tag) ?
false false
: search(tag, seen.add(tag)) }, false) }, false) } : search(target, tag, seen.add(tag)) }, false) }, false) }
var res = this.directMatch(...arguments) var res = this.directMatch(...arguments)
return res !== false ? return res !== false ?
res res
// if there is no edge a then no point in further searching... // if there is no edge (root/base) a then no point in further
: (edge && this.match(a, cmp).length == 0) ? // searching...
: ((/^\s*[\\\/]/.test(a) || /[\\\/]\s*$/.test(a))
&& this.match(a, cmp).length == 0) ?
false false
: search(a, b) : search(a, b)
}, },
@ -764,7 +760,6 @@ var BaseTagsPrototype = {
// //
// XXX should we rename this to .usedTags(..) and .singleTags(..) to // XXX should we rename this to .usedTags(..) and .singleTags(..) to
// .tags(..) ??? // .tags(..) ???
// XXX should this use .persistentAll or .persistent ???
tags: function(value, ...tags){ tags: function(value, ...tags){
var that = this var that = this
@ -830,7 +825,7 @@ var BaseTagsPrototype = {
// Edit API... // Edit API...
// //
// XXX save un-normalized tags to dict... ??? // XXX save un-normalized tags to dict... ??? (a-la flickr)
tag: function(tags, value){ tag: function(tags, value){
var that = this var that = this
value = value instanceof Array ? value : [value] value = value instanceof Array ? value : [value]