How to use the unique function from hoek
Find comprehensive JavaScript hoek.unique code examples handpicked from public code repositorys.
GitHub: bloglovin/hoek
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}]
170
1
33
+ 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)
170
0
14
+ 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); }
0
1
0
GitHub: remind101/hapi
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); }
0
0
71
+ 3 other calls in file
GitHub: KyleAMathews/hapi
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);
0
0
3
GitHub: Marsup/hapi
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; }
0
0
2
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 \'/\'');
0
0
0
hoek.assert is the most popular function in hoek (1712 examples)