-
Notifications
You must be signed in to change notification settings - Fork 0
/
true-map.js
35 lines (29 loc) · 961 Bytes
/
true-map.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
void function(root){
var map = function(attrs){
var o = Object.create(map.prototype)
o.attributes = Object.create(null)
if ( attrs ) o.set(attrs)
return o
}
map.prototype = {
set : function(key, val){
if ( val ) this.attributes['$' + key] = val
else for ( var p in key ) this.attributes['$' + p] = key[p]
return this
},
get : function(key){
return this.attributes['$' + key]
},
has : function(key){
return '$' + key in this.attributes
},
remove : function(key){
delete this.attributes['$' + key]
return this
}
}
// alias remove
map.prototype['delete'] = map.prototype.remove
if ( typeof module == 'object' && module.exports ) module.exports = map
else root['trueMap'] = map
}(this)