Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bevry-archive/tiered-map
Sponsor this project to keep it maintained
https://github.com/bevry-archive/tiered-map
archived client-side data-manipulation model nodejs
Last synced: about 9 hours ago
JSON representation
Sponsor this project to keep it maintained
- Host: GitHub
- URL: https://github.com/bevry-archive/tiered-map
- Owner: bevry-archive
- License: other
- Created: 2015-04-02T19:57:56.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-01-15T07:03:54.000Z (almost 2 years ago)
- Last Synced: 2024-11-02T02:34:36.296Z (5 days ago)
- Topics: archived, client-side, data-manipulation, model, nodejs
- Language: JavaScript
- Homepage:
- Size: 721 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- Changelog: HISTORY.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
README
Tiered Map
A simple map of key value pairs with support for tiers (e.g. defaults go at tier 25, standards go at 50, and overrides go at tier 75)
## Usage
```javascript
var TieredMap = require('tiered-map')var m = new TieredMap({
tiers: {
'high': 75
}
onChangeListener: function(key, newValue, oldValue){
console.log('The key', key, 'changed from', oldValue, 'to', newValue)
}
})m.set('name', 'ben') // name defaults to ben (default level is 50)
m.set('name', 'bob', 25) // name will stay bob
m.set('name', null) // name will become bob
m.set('name', 'john', 'high') // name will become johnconsole.log(m.get('name', 75)) // will output john
console.log(m.get('name')) // will output nothing
console.log(m.get('name', 25)) // will output bobconsole.log(m.getTier('high')) // will output 75
```Very useful for having multiple tiers of data attributes with different priorities. For example, you could have default values at tier 25, adjusted values at tier 50, and override values at tier 75.
Install
- Install:
npm install --save tiered-map
- Import:
import * as pkg from ('tiered-map')
- Require:
const pkg = require('tiered-map')
``` html
import * as pkg from '//dev.jspm.io/[email protected]'
```
Editions
This package is published with the following editions:
-
tiered-map
aliasestiered-map/source/index.js
-
tiered-map/source/index.js
is ESNext source code for Node.js 10 || 12 || 13 || 14 with Require for modules -
tiered-map/edition-browsers/index.js
is ESNext compiled for web browsers with Require for modules
History
Discover the release history by heading on over to the HISTORY.md
file.
Contribute
Discover how you can contribute by heading on over to the CONTRIBUTING.md
file.
Backers
Maintainers
These amazing people are maintaining this project:
Sponsors
No sponsors yet! Will you be the first?
Contributors
These amazing people have contributed code to this project:
Discover how you can contribute by heading on over to the CONTRIBUTING.md
file.
License
Unless stated otherwise all works are:
- Copyright © 2015+ Bevry Pty Ltd
and licensed under: