2.13.0 • Published 4 years ago

tiered-map v2.13.0

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

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)

npm

jspm

<script type="module">
    import * as pkg from '//dev.jspm.io/tiered-map'
</script>

Usage

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 john

console.log(m.get('name', 75))  // will output john
console.log(m.get('name'))  // will output nothing
console.log(m.get('name', 25))  // will output bob

console.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.

Discover the release history by heading on over to the HISTORY.md file.

Discover how you can contribute by heading on over to the CONTRIBUTING.md file.

These amazing people are maintaining this project:

No sponsors yet! Will you be the first?

These amazing people have contributed code to this project:

Discover how you can contribute by heading on over to the CONTRIBUTING.md file.

Unless stated otherwise all works are:

and licensed under:

2.13.0

4 years ago

2.12.0

4 years ago

2.11.0

4 years ago

2.10.0

4 years ago

2.9.0

4 years ago

2.8.0

4 years ago

2.7.0

4 years ago

2.6.0

4 years ago

2.5.0

4 years ago

2.4.0

4 years ago

2.3.0

4 years ago

2.2.0

4 years ago

2.1.0

4 years ago

2.0.0

4 years ago

1.7.0

4 years ago

1.6.0

4 years ago

1.5.0

4 years ago

1.4.0

4 years ago

1.3.0

4 years ago

1.2.0

5 years ago

1.1.0

8 years ago

1.0.2

8 years ago

1.0.1

9 years ago

1.0.0

9 years ago