-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.js
61 lines (49 loc) · 1.37 KB
/
utils.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
'use strict';
/**
* Module dependencies
*/
var utils = require('lazy-cache')(require);
/**
* Temporarily re-assign `require` to trick browserify and
* webpack into reconizing lazy dependencies.
*
* This tiny bit of ugliness has the huge dual advantage of
* only loading modules that are actually called at some
* point in the lifecycle of the application, whilst also
* allowing browserify and webpack to find modules that
* are depended on but never actually called.
*/
var fn = require;
require = utils; // eslint-disable-line
/**
* Lazily required module dependencies
*/
require('set-value', 'set');
require('get-value', 'get');
require('unset-value', 'del');
require('collection-visit', 'visit');
require('define-property', 'define');
require('to-object-path', 'toPath');
require('class-utils', 'cu');
/**
* Restore `require`
*/
require = fn; // eslint-disable-line
/**
* Run an array of functions by passing each function
* to a method on the given object specified by the given property.
*
* @param {Object} `obj` Object containing method to use.
* @param {String} `prop` Name of the method on the object to use.
* @param {Array} `arr` Array of functions to pass to the method.
*/
utils.run = function(obj, prop, arr) {
var len = arr.length, i = 0;
while (len--) {
obj[prop](arr[i++]);
}
};
/**
* Expose `utils` modules
*/
module.exports = utils;