mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 18:07:49 +00:00
Remove “in” variants.
This commit is contained in:
38
assignIn.js
38
assignIn.js
@@ -1,38 +0,0 @@
|
|||||||
import copyObject from './.internal/copyObject.js';
|
|
||||||
import createAssigner from './.internal/createAssigner.js';
|
|
||||||
import keysIn from './keysIn.js';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is like `assign` except that it iterates over own and
|
|
||||||
* inherited source properties.
|
|
||||||
*
|
|
||||||
* **Note:** This method mutates `object`.
|
|
||||||
*
|
|
||||||
* @since 4.0.0
|
|
||||||
* @alias extend
|
|
||||||
* @category Object
|
|
||||||
* @param {Object} object The destination object.
|
|
||||||
* @param {...Object} [sources] The source objects.
|
|
||||||
* @returns {Object} Returns `object`.
|
|
||||||
* @see assign
|
|
||||||
* @example
|
|
||||||
*
|
|
||||||
* function Foo() {
|
|
||||||
* this.a = 1;
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* function Bar() {
|
|
||||||
* this.c = 3;
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* Foo.prototype.b = 2;
|
|
||||||
* Bar.prototype.d = 4;
|
|
||||||
*
|
|
||||||
* assignIn({ 'a': 0 }, new Foo, new Bar);
|
|
||||||
* // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
|
|
||||||
*/
|
|
||||||
const assignIn = createAssigner((object, source) => {
|
|
||||||
copyObject(source, keysIn(source), object);
|
|
||||||
});
|
|
||||||
|
|
||||||
export default assignIn;
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
import copyObject from './.internal/copyObject.js';
|
|
||||||
import createAssigner from './.internal/createAssigner.js';
|
|
||||||
import keysIn from './keysIn.js';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is like `assignIn` except that it accepts `customizer`
|
|
||||||
* which is invoked to produce the assigned values. If `customizer` returns
|
|
||||||
* `undefined`, assignment is handled by the method instead. The `customizer`
|
|
||||||
* is invoked with five arguments: (objValue, srcValue, key, object, source).
|
|
||||||
*
|
|
||||||
* **Note:** This method mutates `object`.
|
|
||||||
*
|
|
||||||
* @since 4.0.0
|
|
||||||
* @alias extendWith
|
|
||||||
* @category Object
|
|
||||||
* @param {Object} object The destination object.
|
|
||||||
* @param {...Object} sources The source objects.
|
|
||||||
* @param {Function} [customizer] The function to customize assigned values.
|
|
||||||
* @returns {Object} Returns `object`.
|
|
||||||
* @see assignWith
|
|
||||||
* @example
|
|
||||||
*
|
|
||||||
* function customizer(objValue, srcValue) {
|
|
||||||
* return isUndefined(objValue) ? srcValue : objValue;
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* const defaults = partialRight(assignInWith, customizer);
|
|
||||||
*
|
|
||||||
* defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
|
|
||||||
* // => { 'a': 1, 'b': 2 }
|
|
||||||
*/
|
|
||||||
const assignInWith = createAssigner((object, source, srcIndex, customizer) => {
|
|
||||||
copyObject(source, keysIn(source), object, customizer);
|
|
||||||
});
|
|
||||||
|
|
||||||
export default assignInWith;
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
export { default } from './toPairsIn.js';
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
export { default } from './assignInWith.js';
|
|
||||||
34
forIn.js
34
forIn.js
@@ -1,34 +0,0 @@
|
|||||||
import baseFor from './.internal/baseFor.js';
|
|
||||||
import keysIn from './keysIn.js';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Iterates over own and inherited enumerable string keyed properties of an
|
|
||||||
* object and invokes `iteratee` for each property. The iteratee is invoked
|
|
||||||
* with three arguments: (value, key, object). Iteratee functions may exit
|
|
||||||
* iteration early by explicitly returning `false`.
|
|
||||||
*
|
|
||||||
* @since 0.3.0
|
|
||||||
* @category Object
|
|
||||||
* @param {Object} object The object to iterate over.
|
|
||||||
* @param {Function} iteratee The function invoked per iteration.
|
|
||||||
* @returns {Object} Returns `object`.
|
|
||||||
* @see forEach, forEachRight, forInRight, forOwn, forOwnRight
|
|
||||||
* @example
|
|
||||||
*
|
|
||||||
* function Foo() {
|
|
||||||
* this.a = 1;
|
|
||||||
* this.b = 2;
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* Foo.prototype.c = 3;
|
|
||||||
*
|
|
||||||
* forIn(new Foo, function(value, key) {
|
|
||||||
* console.log(key);
|
|
||||||
* });
|
|
||||||
* // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
|
|
||||||
*/
|
|
||||||
function forIn(object, iteratee) {
|
|
||||||
return object == null ? object : baseFor(object, iteratee, keysIn);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default forIn;
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
import baseForRight from './.internal/baseForRight.js';
|
|
||||||
import keysIn from './keysIn.js';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is like `forIn` except that it iterates over properties of
|
|
||||||
* `object` in the opposite order.
|
|
||||||
*
|
|
||||||
* @since 2.0.0
|
|
||||||
* @category Object
|
|
||||||
* @param {Object} object The object to iterate over.
|
|
||||||
* @param {Function} iteratee The function invoked per iteration.
|
|
||||||
* @returns {Object} Returns `object`.
|
|
||||||
* @see forEach, forEachRight, forIn, forOwn, forOwnRight
|
|
||||||
* @example
|
|
||||||
*
|
|
||||||
* function Foo() {
|
|
||||||
* this.a = 1;
|
|
||||||
* this.b = 2;
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* Foo.prototype.c = 3;
|
|
||||||
*
|
|
||||||
* forInRight(new Foo, function(value, key) {
|
|
||||||
* console.log(key);
|
|
||||||
* });
|
|
||||||
* // => Logs 'c', 'b', then 'a' assuming `forIn` logs 'a', 'b', then 'c'.
|
|
||||||
*/
|
|
||||||
function forInRight(object, iteratee) {
|
|
||||||
return object == null ? object : baseForRight(object, iteratee, keysIn);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default forInRight;
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
import baseFunctions from './.internal/baseFunctions.js';
|
|
||||||
import keysIn from './keysIn.js';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates an array of function property names from own and inherited
|
|
||||||
* enumerable properties of `object`.
|
|
||||||
*
|
|
||||||
* @since 4.0.0
|
|
||||||
* @category Object
|
|
||||||
* @param {Object} object The object to inspect.
|
|
||||||
* @returns {Array} Returns the function names.
|
|
||||||
* @see functions
|
|
||||||
* @example
|
|
||||||
*
|
|
||||||
* function Foo() {
|
|
||||||
* this.a = constant('a');
|
|
||||||
* this.b = constant('b');
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* Foo.prototype.c = constant('c');
|
|
||||||
*
|
|
||||||
* functionsIn(new Foo);
|
|
||||||
* // => ['a', 'b', 'c']
|
|
||||||
*/
|
|
||||||
function functionsIn(object) {
|
|
||||||
return object == null ? [] : baseFunctions(object, keysIn(object));
|
|
||||||
}
|
|
||||||
|
|
||||||
export default functionsIn;
|
|
||||||
30
keysIn.js
30
keysIn.js
@@ -1,30 +0,0 @@
|
|||||||
import arrayLikeKeys from './.internal/arrayLikeKeys.js';
|
|
||||||
import baseKeysIn from './.internal/baseKeysIn.js';
|
|
||||||
import isArrayLike from './isArrayLike.js';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates an array of the own and inherited enumerable property names of `object`.
|
|
||||||
*
|
|
||||||
* **Note:** Non-object values are coerced to objects.
|
|
||||||
*
|
|
||||||
* @since 3.0.0
|
|
||||||
* @category Object
|
|
||||||
* @param {Object} object The object to query.
|
|
||||||
* @returns {Array} Returns the array of property names.
|
|
||||||
* @example
|
|
||||||
*
|
|
||||||
* function Foo() {
|
|
||||||
* this.a = 1;
|
|
||||||
* this.b = 2;
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* Foo.prototype.c = 3;
|
|
||||||
*
|
|
||||||
* keysIn(new Foo);
|
|
||||||
* // => ['a', 'b', 'c'] (iteration order is not guaranteed)
|
|
||||||
*/
|
|
||||||
function keysIn(object) {
|
|
||||||
return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default keysIn;
|
|
||||||
40
toPairsIn.js
40
toPairsIn.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 keysIn from './keysIn.js';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates an array of own and inherited 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 entriesIn
|
|
||||||
* @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;
|
|
||||||
*
|
|
||||||
* toPairsIn(new Foo);
|
|
||||||
* // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)
|
|
||||||
*/
|
|
||||||
function toPairsIn(object) {
|
|
||||||
const tag = getTag(object);
|
|
||||||
if (tag == '[object Map]') {
|
|
||||||
return mapToArray(object);
|
|
||||||
}
|
|
||||||
if (tag == '[object Set]') {
|
|
||||||
return setToPairs(object);
|
|
||||||
}
|
|
||||||
return arrayMap(keysIn(object), key => [key, object[key]]);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default toPairsIn;
|
|
||||||
30
valuesIn.js
30
valuesIn.js
@@ -1,30 +0,0 @@
|
|||||||
import baseValues from './.internal/baseValues.js';
|
|
||||||
import keysIn from './keysIn.js';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates an array of the own and inherited enumerable string keyed property
|
|
||||||
* values of `object`.
|
|
||||||
*
|
|
||||||
* **Note:** Non-object values are coerced to objects.
|
|
||||||
*
|
|
||||||
* @since 3.0.0
|
|
||||||
* @category Object
|
|
||||||
* @param {Object} object The object to query.
|
|
||||||
* @returns {Array} Returns the array of property values.
|
|
||||||
* @example
|
|
||||||
*
|
|
||||||
* function Foo() {
|
|
||||||
* this.a = 1;
|
|
||||||
* this.b = 2;
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* Foo.prototype.c = 3;
|
|
||||||
*
|
|
||||||
* valuesIn(new Foo);
|
|
||||||
* // => [1, 2, 3] (iteration order is not guaranteed)
|
|
||||||
*/
|
|
||||||
function valuesIn(object) {
|
|
||||||
return object == null ? [] : baseValues(object, keysIn(object));
|
|
||||||
}
|
|
||||||
|
|
||||||
export default valuesIn;
|
|
||||||
Reference in New Issue
Block a user