You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
We are using lodash in some of our adaptors and most often we use one two function from the entire library.
For example in DHIS2 adaptor we only use indexOf function from lodash. I think we can use lodash implementation of such function and turn it into a util function. For example indexOf
/**
* Gets the index at which the first occurrence of `value` is found in `array`
* using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
* for equality comparisons. If `fromIndex` is negative, it's used as the
* offset from the end of `array`.
*
* @param {Array} array The array to inspect.
* @param {*} value The value to search for.
* @param {number} [fromIndex=0] The index to search from.
* @returns {number} Returns the index of the matched value, else `-1`.
* @example
*
* util.indexOf([1, 2, 1, 2], 2);
* // => 1
*
* // Search from the `fromIndex`.
* util.indexOf([1, 2, 1, 2], 2, 2);
* // => 3
*/
function indexOf(array, value, fromIndex) {
var length = array == null ? 0 : array.length;
if (typeof fromIndex == 'number') {
fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : fromIndex;
} else {
fromIndex = 0;
}
var index = (fromIndex || 0) - 1,
isReflexive = value === value;
while (++index < length) {
var other = array[index];
if ((isReflexive ? other === value : other !== other)) {
return index;
}
}
return -1;
}
The text was updated successfully, but these errors were encountered:
Wouldn't we be better off just re-exporting _ from common? So that all adaptors have access to lodash directly?
I think this is an idea that's been around for a long time - we just haven't gotten around to it. Actually until fairly recently I don't think we've had the technology to do it
Yes and no, i think lodash has lots of functions exporting all of them might not be a good idea in a long run, and i am also worried about docs as well
Description
We are using
lodash
in some of our adaptors and most often we use one two function from the entire library.For example in
DHIS2
adaptor we only useindexOf
function from lodash. I think we can use lodash implementation of such function and turn it into a util function. For example indexOfThe text was updated successfully, but these errors were encountered: