LISTAG
List Manager supports Array Operation & Query by Tags.
FEATURES
- Javascript Array like
can be used like a normal array with[]
,length
,forEach
,map
,reduce
functions. - Tags Associated with Each Item
can be queried by tags, return a array with items that has the specified tags. - Event Support
listag will emitadd
anddel
event which can be listened on. - TypeScript Support
with Type Definition File included.
WHY LISTAG
When we have some of hash values, we put them into a array:
const List = name: 'tom' value: 1 name: 'bob' value: 2 name: 'bob' value: 3
If we want to get the value out whose name is 'tom', we have to use filter:
const filteredList = List
Listag is a convinience way to do this, with more powerful enhancements.
const lt = ltlt lt
EXAMPLE
Create listag
let lt = 1 color: 'blue' let lt2 = 2 3 color: 'green' owner: 'tom'
Add item(s) to a listag
ltlt
Del item(s) from a listag
lt ltDel = ltlt
Get item(s) from a listag
let blueLt = ltblueLt
get
can filter the result by exclude
some tag value, by add a minus sign -
before the value:
let notBlueLt = lt
Array Operation
consoleconsole lt lt lt
Event
lt lt
Set Tags to a listag
lt
TEST
Unit Test can be found here:
https://github.com/huan/listag/blob/master/tests/
KNOWN ISSUES & SUPPORT
Github Issue - https://github.com/huan/listag/issues
- Listag can not be
instanceof
because it has beenProxy
-ed
CHANGELOG
v0.8 master
- Upgrade TypeScript to the latest version
- DevOps with npm@next
v0.4 (9th Auth 2016)
- support create listag from listag, keep all tags information right
- add
Listag.item()
method to get a ListagItem from Listag, for read tag information
v0.2.3 (7th Aug 2016)
- add TypeScript Declaration File
- support to exclude a tag value by add minus sign(
-
) to value
v0.1.0 (22 Jul 2016)
- support array with tags powered by ES6 Proxy
TODO
- support
for ... in Listag
- support
for ... of Listag
AUTHOR
Zhuohuan LI zixia@zixia.net (http://linkedin.com/in/zixia)
COPYRIGHT & LICENSE
- Code & Docs 2016-2018© zixia
- Code released under the ISC license
- Docs released under Creative Commons