97c87032f25c45ebe418f7d858f2d3d245fff4f7
[platform/framework/web/crosswalk-tizen.git] /
1 /**
2  * @fileoverview A simple map that helps avoid collisions on the Object prototype.
3  * @author Jamund Ferguson
4  * @copyright 2015 Jamund Ferguson. All rights reserved.
5  * @copyright 2011-2013 Ariya Hidayat <ariya.hidayat@gmail.com>
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * * Redistributions of source code must retain the above copyright
11  *   notice, this list of conditions and the following disclaimer.
12  * * Redistributions in binary form must reproduce the above copyright
13  *   notice, this list of conditions and the following disclaimer in the
14  *   documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
20  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27
28 "use strict";
29
30 function StringMap() {
31     this.$data = {};
32 }
33
34 StringMap.prototype.get = function (key) {
35     key = "$" + key;
36     return this.$data[key];
37 };
38
39 StringMap.prototype.set = function (key, value) {
40     key = "$" + key;
41     this.$data[key] = value;
42     return this;
43 };
44
45 StringMap.prototype.has = function (key) {
46     key = "$" + key;
47     return Object.prototype.hasOwnProperty.call(this.$data, key);
48 };
49
50 StringMap.prototype.delete = function (key) {
51     key = "$" + key;
52     return delete this.$data[key];
53 };
54
55 module.exports = StringMap;