Every line of 'js map constructor' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
73 export function map(map: MapFunc) { return new Map(map); }
7 constructor(private map: Interfaces.IMap) { 8 }
1 export default function MapCtor(entries) { 2 return Object.setPrototypeOf(new Map(entries), Object.getPrototypeOf(this)) 3 }
24 constructor(obj: Object) { 25 super(obj); 26 }
95 export default function Map() { 96 let keys = []; 97 let values = []; 98 99 this.get = function getValueForKey(key) { 100 const index = keys.indexOf(key); 101 if (index === -1) { 102 return undefined; 103 } 104 return values[index]; 105 }; 106 107 this.set = function setValueForKey(key, value) { 108 const index = keys.indexOf(key); 109 if (index === -1) { 110 keys.push(key); 111 values.push(value); 112 } else { 113 values[index] = value; 114 } 115 }; 116 117 this.delete = function deleteKey(key) { 118 const index = keys.indexOf(key); 119 if (index !== -1) { 120 keys.splice(index, 1); 121 values.splice(index, 1); 122 } 123 }; 124 125 this.clear = function clear() { 126 keys = []; 127 values = []; 128 }; 129 130 this.forEach = function(callback, context) { 131 for (let i = 0; i < keys.length; i++) { 132 if (context) { 133 callback.call(context, values[i], keys[i]); 134 } else { 135 callback(values[i], keys[i]); 136 } 137 } 138 }; 139 }
75 constructor(iterable = undefined) { 76 if (!isObject(this)) 77 throw new TypeError('Map called on incompatible type'); 78 79 if (hasOwnProperty.call(this, 'entries_')) { 80 throw new TypeError('Map can not be reentrantly initialised'); 81 } 82 83 initMap(this); 84 85 if (iterable !== null && iterable !== undefined) { 86 for (var [key, value] of iterable) { 87 this.set(key, value); 88 } 89 } 90 }
33 constructor () { 34 this._rootMap = new FlimsyMap() 35 }
93 function createMap() { 94 if( Map !== void 0 ) { 95 return new Map(); 96 } 97 else { 98 return new ObjectMap(); 99 } 100 }
153 constructor(iterable?: ArrayLike<[K, V]>) { 154 if (!(this instanceof Map)) { 155 throw new TypeError('Constructor Map requires "new"'); 156 } 157 158 if (iterable) { 159 // Can't depend on iterable protocol yet. Don't use 160 // forEach so this works with array like objects too. 161 for (let i = 0; i < iterable.length; i++) { 162 this.set(iterable[i][0], iterable[i][1]); 163 } 164 } 165 }
14 constructor(keys, values) { 15 this.keys = keys; 16 this.values = values; 17 }