0.0.5 • Published 4 years ago

tagsforobj v0.0.5

Weekly downloads
1
License
ISC
Repository
github
Last release
4 years ago

TAGS for JS Objects

npm.io npm.io npm.io

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.

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago