From fc83f71a9db5e3f1bdffefc619b046bd6788d9d5 Mon Sep 17 00:00:00 2001 From: mrlee23 Date: Wed, 20 Dec 2017 23:03:12 +0900 Subject: [PATCH] Create selectProperties function --- lib/org-mode-parser.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/org-mode-parser.js b/lib/org-mode-parser.js index 4e79c04..c09cdaf 100644 --- a/lib/org-mode-parser.js +++ b/lib/org-mode-parser.js @@ -810,6 +810,19 @@ var OrgQuery=(function () }); return new OrgQuery(nodes); }; + OrgQuery.prototype.selectProperties=function(propNames, orFlag = false){ + var nodes = []; + _.each(this.allNodes, function(n){ + var names = Object.keys(n.properties); + if (_.isString(propNames)) { + names.indexOf(propNames) > -1 && nodes.push(n); + } else if (_.isArray(propNames)) { + var method = orFlag ? 'some' : 'every'; + propNames[method](name => names.indexOf(name) > -1) && nodes.push(n); + } + }); + return new OrgQuery(nodes); + }; // Private manipulation function