tagsforobj
v0.0.5
Published
add tags to object!
Downloads
1
Readme
TAGS for JS Objects
A micro library to study ES6 (ES2015) SET Object type, able to add tags to JS Objects.
Documentation
import {tagsEnabler} from 'tagsforobj';
let testObj = { name: "MAXPAYNE" };
testObj = tagsEnabler(testObj);
console.log(testObj); // {name: "MAXPAYNE" } tags are in the prototype...
// ADD
testObj.addTag("man"); // string
testObj.addTag("football player"); // tags can have whitespaces
testObj.addTag(["dad", "guitar player", "developer", "engineer"]); // array of strings
// DELETE
testObj.deleteTag("man");
console.log(testObj.queryTag("man")); // false
testObj.deleteTag(["guitar player", "dad", "random"]);
console.log(testObj.queryTag("dad")); // false
// HAS
console.log(testObj.queryTag("man"));
console.log(testObj.queryTag(["developer", "engineer"])); // AND CONDITION is the DEFAULT
console.log(testObj.queryTag(["developer", "dad"]));
console.log(testObj.queryTag(["dad", "developer"], "OR")); // OR CONDITION
console.log(testObj.queryTag("!dad")); // ! to invert the condition
console.log(testObj.queryTag(["developer", "!dad", "engineer"]));
// CLEAR / SIZE
testObj.clearTags();
console.log(testObj.sizeTags()); // 0
Todo
- [ ] better query system
Bugs
- Uhm...
Built With
ES6 Javascript, microbundle,
Versioning
Versione 0.0.5
License
This project is licensed under the ISC License.