How to use the flatten function from hoek

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

51
52
53
54
55
56
57
58
59


internals.Alternatives.prototype.try = function (/* schemas */) {


    var schemas = Hoek.flatten(Array.prototype.slice.call(arguments));
    Hoek.assert(schemas.length, 'Cannot add other alternatives without at least one schema');

    var obj = this.clone();
fork icon813
star icon0
watch icon2

+ 3 other calls in file

166
167
168
169
170
171
172
173
174
```javascript

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

var flattenedArray = Hoek.flatten(array, target) // results in [4, 5, 1, 2, 3];
```

### reach(obj, chain, [options])
fork icon170
star icon1
watch icon33

219
220
221
222
223
224
225
226
227

```javascript

var array = [1, [2, 3]];

var flattenedArray = Hoek.flatten(array); // results in [1, 2, 3]

array = [1, [2, 3]];
target = [4, [5]];
fork icon170
star icon0
watch icon14

+ 3 other calls in file

80
81
82
83
84
85
86
87
88
89
};


internals.Podium.prototype.registerEvent = function (events, options = {}) {

    events = Hoek.flatten([].concat(events));
    events.forEach((event) => {

        if (!event) {
            return;
fork icon25
star icon0
watch icon2

329
330
331
332
333
334
335
336
337
338

items() {

    const obj = this.clone();

    Hoek.flatten(Array.prototype.slice.call(arguments)).forEach((type, index) => {

        try {
            type = Cast.schema(this._currentJoi, type);
        }
fork icon0
star icon1
watch icon0

242
243
244
245
246
247
248
249
250
    return joi;
};

root.extend = function () {

    const extensions = Hoek.flatten(Array.prototype.slice.call(arguments));
    Hoek.assert(extensions.length > 0, 'You need to provide at least one extension');

    this.assert(extensions, root.extensionsSchema);
fork icon0
star icon1
watch icon0

66
67
68
69
70
71
72
73
74
    return { errors: this.createError('alternatives.base', null, state, options) };
}

try(/* schemas */) {

    const schemas = Hoek.flatten(Array.prototype.slice.call(arguments));
    Hoek.assert(schemas.length, 'Cannot add other alternatives without at least one schema');

    const obj = this.clone();
fork icon0
star icon0
watch icon1

247
248
249
250
251
252
253
254
255
    return joi;
};

root.extend = function (...args) {

    const extensions = Hoek.flatten(args);
    Hoek.assert(extensions.length > 0, 'You need to provide at least one extension');

    this.assert(extensions, root.extensionsSchema);
fork icon0
star icon0
watch icon0

333
334
335
336
337
338
339
340
341
342

items(...schemas) {

    const obj = this.clone();

    Hoek.flatten(schemas).forEach((type, index) => {

        try {
            type = Cast.schema(this._currentJoi, type);
        }
fork icon0
star icon0
watch icon0

111
112
113
114
115
116
117
118
119
    let labels = [];
    for (let i = 0; i < arguments.length; ++i) {
        labels.push(arguments[i]);
    }

    labels = Hoek.flatten(labels);
    return this._select(labels);
};

fork icon0
star icon0
watch icon1