How to use the unique function from hoek

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

125
126
127
128
129
130
131
132
133
134

```javascript

var array = [1, 2, 2, 3, 3, 4, 5, 6];

var newArray = Hoek.unique(array); // results in [1,2,3,4,5,6];

array = [{id: 1}, {id: 1}, {id: 2}];

newArray = Hoek.unique(array, "id") // results in [{id: 1}, {id: 2}]
fork icon170
star icon1
watch icon33

+ 3 other calls in file

183
184
185
186
187
188
189
190
191

var newArray = Hoek.unique(array);    // results in [1,2,3,4,5,6]

array = [{id: 1}, {id: 1}, {id: 2}];

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

### mapToObject(array, key)
fork icon170
star icon0
watch icon14

+ 3 other calls in file

246
247
248
249
250
251
252
253
254
        Hoek.assert(Ip.versions[version], 'version at position ' + i + ' must be one of ' + Object.keys(Ip.versions).join(', '));
        versions.push(version);
    }

    // Make sure we have a set of versions
    versions = Hoek.unique(versions);

    regex = Ip.createIpRegex(versions, ipOptions.cidr);
}
fork icon0
star icon1
watch icon0

139
140
141
142
143
144
145
146
147
148
    labels.forEach(function (label) {

        ids = ids.concat(self._byLabel[label] || []);
    });

    ids = Hoek.unique(ids);
}
else {
    ids = Object.keys(this._byId);
}
fork icon0
star icon0
watch icon71

+ 3 other calls in file

69
70
71
72
73
74
75
76
77
78
}

this.settings = Hoek.applyToDefaults(Defaults.server, args.options || {});
Schema.assert('server', this.settings);

this.settings.labels = Hoek.unique([].concat(this.settings.labels));       // Convert string to array and removes duplicates

// Set basic configuration

this._unixDomainSocket = (args.host && args.host.indexOf('/') !== -1);
fork icon0
star icon0
watch icon3

35
36
37
38
39
40
41
42
43
this.settings = options;                                                        // options cloned in server.connection()
this.server = server;

// Normalize settings

this.settings.labels = Hoek.unique(this.settings.labels || []);                 // Remove duplicates
if (this.settings.port === undefined) {
    this.settings.port = 0;
}
fork icon0
star icon0
watch icon2

145
146
147
148
149
150
151
152
153
154

var settings = Hoek.applyToDefaultsWithShallow(internals.defaults.connection, options || {}, ['app', 'plugins']);

Schema.assert('server', settings);

settings.labels = Hoek.unique([].concat(settings.labels));       // Convert string to array and removes duplicates

// Set basic configuration

Hoek.assert(!settings.location || settings.location.charAt(settings.location.length - 1) !== '/', 'Location setting must not contain a trailing \'/\'');
fork icon0
star icon0
watch icon0