Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rubenjgarcia/wlist
A library to order lists in Node based on weight
https://github.com/rubenjgarcia/wlist
Last synced: 1 day ago
JSON representation
A library to order lists in Node based on weight
- Host: GitHub
- URL: https://github.com/rubenjgarcia/wlist
- Owner: rubenjgarcia
- License: mit
- Created: 2015-12-28T09:21:01.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-01-29T14:11:08.000Z (almost 9 years ago)
- Last Synced: 2024-10-12T19:14:46.251Z (about 1 month ago)
- Language: JavaScript
- Size: 453 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# wlist
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)A library to order lists in Node based on weight
Install using npm
````
npm install wlist
````Generate Jsdoc
````
gulp jsdoc
````Test module
````
gulp test
````
# Usage examples* Order lists
````
var Wlist = require('wlist');
var wlist = new Wlist();wlist.put('item1', 3);
wlist.put('item2', 2);
wlist.put('item3', 1);var items = wlist.get(); // items -> ['item3', 'item2', 'item1']
````* Order lists and get items by name
````
var Wlist = require('wlist');
var wlist = new Wlist();wlist.put('item1', 'item1-name', 3);
wlist.put('item2', 'item2-name', 2);
wlist.put('item3', 'item3-name', -1);var items = wlist.get(); // items -> ['item3', 'item2', 'item1']
var item = wlist.get('item2-name'); // item -> 'item2'
````* Insert items before or after other
````
var Wlist = require('wlist');
var wlist = new Wlist();wlist.put('item1', 'item1-name', 3);
wlist.put('item2', 'item2-name', 2);
wlist.put('item3', 'item3-name', -1);var items = wlist.get(); // items -> ['item3', 'item2', 'item1']
wlist.before('item2-name', 'item4');
items = wlist.get(); // items -> ['item3', 'item4', 'item2', 'item1']wlist.after('item2-name', 'item5');
items = wlist.get(); // items -> ['item3', 'item4', 'item2', 'item5', 'item1']
````For more information see the JSDoc