How to use the mapToObject function from hoek

Find comprehensive JavaScript hoek.mapToObject code examples handpicked from public code repositorys.

193
194
195
196
197
198
199
200
201
202
Convert an Array into an Object

```javascript

var array = [1,2,3];
var newObject = Hoek.mapToObject(array);   // results in [{"1": true}, {"2": true}, {"3": true}]

array = [{id: 1}, {id: 2}];
newObject = Hoek.mapToObject(array, "id"); // results in [{"id": 1}, {"id": 2}]
```
fork icon170
star icon0
watch icon14

+ 3 other calls in file

221
222
223
224
225
226
227
228
229
230
Convert an Array into an Object

```javascript

var array = [1,2,3];
var newObject = Hoek.mapToObject(array);   // results in {"1": true, "2": true, "3": true}

array = [{id: 1}, {id: 2}];
newObject = Hoek.mapToObject(array, "id"); // results in {"1": true, "2": true}
```
fork icon170
star icon0
watch icon6

+ 3 other calls in file

152
153
154
155
156
157
158
159
160

var array = [1,2,3];
var newObject = Hoek.mapToObject(array); // results in [{"1": true}, {"2": true}, {"3": true}]

array = [{id: 1}, {id: 2}];
newObject = Hoek.mapToObject(array, "id") // results in [{"id": 1}, {"id": 2}]

```
### intersect(array1, array2)
fork icon170
star icon0
watch icon1

+ 3 other calls in file

161
162
163
164
165
166
167
168
169
170
}

if (criteria.tags &&
    Array.isArray(criteria.tags)) {

    criteria.tags = Hoek.mapToObject(criteria.tags);
}

if (event.handlers) {
    const processing = [];
fork icon25
star icon0
watch icon2

199
200
201
202
203
204
205
206
207
208
    tags: tags,
    data: data,
    internal: !!_internal
};

var tagsMap = Hoek.mapToObject(event.tags);

// Add to request array

this._logger.push(event);
fork icon0
star icon0
watch icon10

149
150
151
152
153
154
155
156
157
158
// Cache

if (this.method === 'get' &&
    (this.settings.cache.expiresIn || this.settings.cache.expiresAt)) {

    this.settings.cache._statuses = Hoek.mapToObject(this.settings.cache.statuses);
    this._cache = new Catbox.Policy({ expiresIn: this.settings.cache.expiresIn, expiresAt: this.settings.cache.expiresAt });
}

// CORS
fork icon0
star icon0
watch icon2

124
125
126
127
128
129
130
131
132
133
    !this._inner.patterns.length) {

    return finish();
}

var unprocessed = Hoek.mapToObject(Object.keys(target));
var key;

if (this._inner.children) {
    for (var i = 0, il = this._inner.children.length; i < il; ++i) {
fork icon0
star icon0
watch icon3