mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 15:57:48 +00:00
Remove more modules that have ES equivs.
This commit is contained in:
@@ -1 +0,0 @@
|
||||
export { default } from './toPairs.js';
|
||||
43
fill.js
43
fill.js
@@ -1,43 +0,0 @@
|
||||
import baseFill from './.internal/baseFill.js';
|
||||
import isIterateeCall from './.internal/isIterateeCall.js';
|
||||
|
||||
/**
|
||||
* Fills elements of `array` with `value` from `start` up to, but not
|
||||
* including, `end`.
|
||||
*
|
||||
* **Note:** This method mutates `array`.
|
||||
*
|
||||
* @since 3.2.0
|
||||
* @category Array
|
||||
* @param {Array} array The array to fill.
|
||||
* @param {*} value The value to fill `array` with.
|
||||
* @param {number} [start=0] The start position.
|
||||
* @param {number} [end=array.length] The end position.
|
||||
* @returns {Array} Returns `array`.
|
||||
* @example
|
||||
*
|
||||
* const array = [1, 2, 3];
|
||||
*
|
||||
* fill(array, 'a');
|
||||
* console.log(array);
|
||||
* // => ['a', 'a', 'a']
|
||||
*
|
||||
* fill(Array(3), 2);
|
||||
* // => [2, 2, 2]
|
||||
*
|
||||
* fill([4, 6, 8, 10], '*', 1, 3);
|
||||
* // => [4, '*', '*', 10]
|
||||
*/
|
||||
function fill(array, value, start, end) {
|
||||
const length = array == null ? 0 : array.length;
|
||||
if (!length) {
|
||||
return [];
|
||||
}
|
||||
if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
|
||||
start = 0;
|
||||
end = length;
|
||||
}
|
||||
return baseFill(array, value, start, end);
|
||||
}
|
||||
|
||||
export default fill;
|
||||
41
findIndex.js
41
findIndex.js
@@ -1,41 +0,0 @@
|
||||
import baseFindIndex from './.internal/baseFindIndex.js';
|
||||
import toInteger from './toInteger.js';
|
||||
|
||||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||
const nativeMax = Math.max;
|
||||
|
||||
/**
|
||||
* This method is like `find` except that it returns the index of the first
|
||||
* element `predicate` returns truthy for instead of the element itself.
|
||||
*
|
||||
* @since 1.1.0
|
||||
* @category Array
|
||||
* @param {Array} array The array to inspect.
|
||||
* @param {Function} predicate The function invoked per iteration.
|
||||
* @param {number} [fromIndex=0] The index to search from.
|
||||
* @returns {number} Returns the index of the found element, else `-1`.
|
||||
* @see find, findKey, findLast, findLastIndex, findLastKey
|
||||
* @example
|
||||
*
|
||||
* const users = [
|
||||
* { 'user': 'barney', 'active': false },
|
||||
* { 'user': 'fred', 'active': false },
|
||||
* { 'user': 'pebbles', 'active': true }
|
||||
* ];
|
||||
*
|
||||
* findIndex(users, ({ user }) => user == 'barney');
|
||||
* // => 0
|
||||
*/
|
||||
function findIndex(array, predicate, fromIndex) {
|
||||
const length = array == null ? 0 : array.length;
|
||||
if (!length) {
|
||||
return -1;
|
||||
}
|
||||
let index = fromIndex == null ? 0 : toInteger(fromIndex);
|
||||
if (index < 0) {
|
||||
index = nativeMax(length + index, 0);
|
||||
}
|
||||
return baseFindIndex(array, predicate, index);
|
||||
}
|
||||
|
||||
export default findIndex;
|
||||
32
isInteger.js
32
isInteger.js
@@ -1,32 +0,0 @@
|
||||
import toInteger from './toInteger.js';
|
||||
|
||||
/**
|
||||
* Checks if `value` is an integer.
|
||||
*
|
||||
* **Note:** This method is based on
|
||||
* [`Number.isInteger`](https://mdn.io/Number/isInteger).
|
||||
*
|
||||
* @since 4.0.0
|
||||
* @category Lang
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` is an integer, else `false`.
|
||||
* @see isNumber, toInteger, toNumber
|
||||
* @example
|
||||
*
|
||||
* isInteger(3);
|
||||
* // => true
|
||||
*
|
||||
* isInteger(Number.MIN_VALUE);
|
||||
* // => false
|
||||
*
|
||||
* isInteger(Infinity);
|
||||
* // => false
|
||||
*
|
||||
* isInteger('3');
|
||||
* // => false
|
||||
*/
|
||||
function isInteger(value) {
|
||||
return typeof value == 'number' && value == toInteger(value);
|
||||
}
|
||||
|
||||
export default isInteger;
|
||||
@@ -1,35 +0,0 @@
|
||||
import isInteger from './isInteger.js';
|
||||
|
||||
/** Used as references for various `Number` constants. */
|
||||
const MAX_SAFE_INTEGER = 9007199254740991;
|
||||
|
||||
/**
|
||||
* Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754
|
||||
* double precision number which isn't the result of a rounded unsafe integer.
|
||||
*
|
||||
* **Note:** This method is based on
|
||||
* [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger).
|
||||
*
|
||||
* @since 4.0.0
|
||||
* @category Lang
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.
|
||||
* @example
|
||||
*
|
||||
* isSafeInteger(3);
|
||||
* // => true
|
||||
*
|
||||
* isSafeInteger(Number.MIN_VALUE);
|
||||
* // => false
|
||||
*
|
||||
* isSafeInteger(Infinity);
|
||||
* // => false
|
||||
*
|
||||
* isSafeInteger('3');
|
||||
* // => false
|
||||
*/
|
||||
function isSafeInteger(value) {
|
||||
return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;
|
||||
}
|
||||
|
||||
export default isSafeInteger;
|
||||
40
toPairs.js
40
toPairs.js
@@ -1,40 +0,0 @@
|
||||
import arrayMap from './.internal/arrayMap.js';
|
||||
import getTag from './.internal/getTag.js';
|
||||
import mapToArray from './.internal/mapToArray.js';
|
||||
import setToPairs from './.internal/setToPairs.js';
|
||||
import keys from './keys.js';
|
||||
|
||||
/**
|
||||
* Creates an array of own enumerable string keyed-value pairs for `object`
|
||||
* which can be consumed by `fromPairs`. If `object` is a map or set, its
|
||||
* entries are returned.
|
||||
*
|
||||
* @since 4.0.0
|
||||
* @alias entries
|
||||
* @category Object
|
||||
* @param {Object} object The object to query.
|
||||
* @returns {Array} Returns the key-value pairs.
|
||||
* @example
|
||||
*
|
||||
* function Foo() {
|
||||
* this.a = 1;
|
||||
* this.b = 2;
|
||||
* }
|
||||
*
|
||||
* Foo.prototype.c = 3;
|
||||
*
|
||||
* toPairs(new Foo);
|
||||
* // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
|
||||
*/
|
||||
function toPairs(object) {
|
||||
const tag = getTag(object);
|
||||
if (tag == '[object Map]') {
|
||||
return mapToArray(object);
|
||||
}
|
||||
if (tag == '[object Set]') {
|
||||
return setToPairs(object);
|
||||
}
|
||||
return arrayMap(keys(object), key => [key, object[key]]);
|
||||
}
|
||||
|
||||
export default toPairs;
|
||||
Reference in New Issue
Block a user