|
Last change
on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
1.3 KB
|
| Rev | Line | |
|---|
| [a762898] | 1 | 'use strict';
|
|---|
| 2 |
|
|---|
| 3 | Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|---|
| 4 |
|
|---|
| 5 | const identity = require('../../function/identity.js');
|
|---|
| 6 | const isFunction = require('../../predicate/isFunction.js');
|
|---|
| 7 | const forEach = require('../array/forEach.js');
|
|---|
| 8 | const isBuffer = require('../predicate/isBuffer.js');
|
|---|
| 9 | const isObject = require('../predicate/isObject.js');
|
|---|
| 10 | const isTypedArray = require('../predicate/isTypedArray.js');
|
|---|
| 11 | const iteratee = require('../util/iteratee.js');
|
|---|
| 12 |
|
|---|
| 13 | function transform(object, iteratee$1 = identity.identity, accumulator) {
|
|---|
| 14 | const isArrayOrBufferOrTypedArray = Array.isArray(object) || isBuffer.isBuffer(object) || isTypedArray.isTypedArray(object);
|
|---|
| 15 | iteratee$1 = iteratee.iteratee(iteratee$1);
|
|---|
| 16 | if (accumulator == null) {
|
|---|
| 17 | if (isArrayOrBufferOrTypedArray) {
|
|---|
| 18 | accumulator = [];
|
|---|
| 19 | }
|
|---|
| 20 | else if (isObject.isObject(object) && isFunction.isFunction(object.constructor)) {
|
|---|
| 21 | accumulator = Object.create(Object.getPrototypeOf(object));
|
|---|
| 22 | }
|
|---|
| 23 | else {
|
|---|
| 24 | accumulator = {};
|
|---|
| 25 | }
|
|---|
| 26 | }
|
|---|
| 27 | if (object == null) {
|
|---|
| 28 | return accumulator;
|
|---|
| 29 | }
|
|---|
| 30 | forEach.forEach(object, (value, key, object) => iteratee$1(accumulator, value, key, object));
|
|---|
| 31 | return accumulator;
|
|---|
| 32 | }
|
|---|
| 33 |
|
|---|
| 34 | exports.transform = transform;
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.