source: trip-planner-front/node_modules/collection-visit/index.js@ 76712b2

Last change on this file since 76712b2 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 709 bytes
Line 
1/*!
2 * collection-visit <https://github.com/jonschlinkert/collection-visit>
3 *
4 * Copyright (c) 2015, 2017, Jon Schlinkert.
5 * Released under the MIT License.
6 */
7
8'use strict';
9
10var visit = require('object-visit');
11var mapVisit = require('map-visit');
12
13module.exports = function(collection, method, val) {
14 var result;
15
16 if (typeof val === 'string' && (method in collection)) {
17 var args = [].slice.call(arguments, 2);
18 result = collection[method].apply(collection, args);
19 } else if (Array.isArray(val)) {
20 result = mapVisit.apply(null, arguments);
21 } else {
22 result = visit.apply(null, arguments);
23 }
24
25 if (typeof result !== 'undefined') {
26 return result;
27 }
28
29 return collection;
30};
Note: See TracBrowser for help on using the repository browser.