merged .tagged(..) and .tags(..), still needs thought..

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2018-12-01 19:30:10 +03:00
parent 67901ddc56
commit 9fbc8ad8c8

View File

@ -375,12 +375,32 @@ var TagsPrototype = {
// .tags(value) // .tags(value)
// -> tags // -> tags
// //
// Check value tags...
// .tags(value, tag)
// .tags(value, tag, ..)
// .tags(value, [tag, ..])
// -> tags
//
// NOTE: this includes all the .persistent tags as well as all the // NOTE: this includes all the .persistent tags as well as all the
// tags actually used. // tags actually used.
tags: function(value){ tags: function(value, ...tags){
var that = this var that = this
// check if value is tagged by tags..,
if(value && tags.length > 0){
tags = tags.length == 1 && tags[0] instanceof Array ?
tags.shift()
: tags
// XXX is this the new version???
var u = this.tags(value)
return tags
.reduce(function(res, tag){
return res === false ?
res
: that.match(tag, u).length > 0 }, true)
// get tags of specific value... // get tags of specific value...
if(value){ } else if(value){
return Object.entries(this.__index || {}) return Object.entries(this.__index || {})
.filter(function(e){ return e[1].has(value) }) .filter(function(e){ return e[1].has(value) })
.map(function(e){ return e[0] }) .map(function(e){ return e[0] })