Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mhweiner/js-ordered-dict
A simple, extendable, sortable JavaScript OrderedDict.
https://github.com/mhweiner/js-ordered-dict
Last synced: 2 months ago
JSON representation
A simple, extendable, sortable JavaScript OrderedDict.
- Host: GitHub
- URL: https://github.com/mhweiner/js-ordered-dict
- Owner: mhweiner
- License: mit
- Created: 2017-04-17T18:37:12.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-08-23T03:17:28.000Z (5 months ago)
- Last Synced: 2024-10-11T22:55:53.120Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 83 KB
- Stars: 4
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DEPRECATED: OrderedDict
This project is no longer maintained. Modern JavaScript features such as `Map` and `Set` now offer built-in alternatives. Please consider using those instead.Thank you for your support, and I encourage you to check out my other open source projects on GitHub:
https://github.com/mhweiner
# OrderedDict
A simple, extendable, sortable JavaScript OrderedDict.## Installation
```bash
npm i js-ordered-dict
```## Example Usage
```js
var a = new OrderedDict();//set/push
a.set('Bellanca','Citabria');
a.set('Boeing','777');
a.set('Piper','Cub');//get
a.values(); //['Citabria','777','Cub'] (note: respects order of entry)
a.keys(); //['Bellanca','Boeing','Piper'] (note: respects order of entry)
a.get('Piper'); //'Cub'
a.has('Boeing'); //true
a.first(); //'Citabria'
a.last(); //'Cub'
a.nth(1); //'777'
a.firstKey(); //'Bellanca'
a.lastKey(); //'Piper'
a.keyAtIndex(1); //'Boeing'//length
a.size(); //3//removal
a.remove('Boeing');
a.values(); //['Citabria','Cub']//iteration
a.forEach((value, key) => {
...
});//updating values
a.set('Bellanca', 'Decathalon');
a.values(); //['Decathalon','Cub']//inserting values at a certain position
a.size(); //2
a.insert(1, 'Honda', {'model': 'HondaJet'});
a.values(); //['Decathalon', {'model': 'HondaJet'}, 'Cub']
a.size(); //3//clear
a.clear();
a.values(); //[]//sorting
a.arr.sort(); //using built-in Array.prototype.sort()
a.values(); //['172','Yankee','SR-72']//clone
let d = new OrderedDict();
d.set('foo', 'bar');let a = d.clone();
a.get('foo'); //'bar'```
## License
[MIT](https://github.com/mhweiner/mr-router/blob/master/LICENSE). Free to use in all your things!
## Contribution
DO IT! PR's welcome. Need to add testing and linting.