MCPcopy
hub / github.com/lodash/lodash / baseConvert

Function baseConvert

fp/_baseConvert.js:138–567  ·  view source on GitHub ↗

* The base implementation of `convert` which accepts a `util` object of methods * required to perform conversions. * * @param {Object} util The util object. * @param {string} name The name of the function to convert. * @param {Function} func The function to convert. * @param {Object} [options]

(util, name, func, options)

Source from the content-addressed store, hash-verified

136 * @returns {Function|Object} Returns the converted function or object.
137 */
138function baseConvert(util, name, func, options) {
139 var isLib = typeof name == 'function',
140 isObj = name === Object(name);
141
142 if (isObj) {
143 options = func;
144 func = name;
145 name = undefined;
146 }
147 if (func == null) {
148 throw new TypeError;
149 }
150 options || (options = {});
151
152 var config = {
153 'cap': 'cap' in options ? options.cap : true,
154 'curry': 'curry' in options ? options.curry : true,
155 'fixed': 'fixed' in options ? options.fixed : true,
156 'immutable': 'immutable' in options ? options.immutable : true,
157 'rearg': 'rearg' in options ? options.rearg : true
158 };
159
160 var defaultHolder = isLib ? func : fallbackHolder,
161 forceCurry = ('curry' in options) && options.curry,
162 forceFixed = ('fixed' in options) && options.fixed,
163 forceRearg = ('rearg' in options) && options.rearg,
164 pristine = isLib ? func.runInContext() : undefined;
165
166 var helpers = isLib ? func : {
167 'ary': util.ary,
168 'assign': util.assign,
169 'clone': util.clone,
170 'curry': util.curry,
171 'forEach': util.forEach,
172 'isArray': util.isArray,
173 'isError': util.isError,
174 'isFunction': util.isFunction,
175 'isWeakMap': util.isWeakMap,
176 'iteratee': util.iteratee,
177 'keys': util.keys,
178 'rearg': util.rearg,
179 'toInteger': util.toInteger,
180 'toPath': util.toPath
181 };
182
183 var ary = helpers.ary,
184 assign = helpers.assign,
185 clone = helpers.clone,
186 curry = helpers.curry,
187 each = helpers.forEach,
188 isArray = helpers.isArray,
189 isError = helpers.isError,
190 isFunction = helpers.isFunction,
191 isWeakMap = helpers.isWeakMap,
192 keys = helpers.keys,
193 rearg = helpers.rearg,
194 toInteger = helpers.toInteger,
195 toPath = helpers.toPath;

Callers 3

createConverterFunction · 0.85
browserConvertFunction · 0.85
test-fp.jsFile · 0.85

Calls 12

keysFunction · 0.85
castArrayFunction · 0.85
cloneArrayFunction · 0.85
baseAryFunction · 0.85
isFunctionFunction · 0.85
mixinFunction · 0.85
toIntegerFunction · 0.85
curryFunction · 0.85
nthArgFunction · 0.85
createConverterFunction · 0.85
wrapFunction · 0.70
iterateeFunction · 0.50

Tested by

no test coverage detected