transform

v4.17.15arrow_drop_down
v4.17.15
v4.17.11
STATUS
Passing
DOWNLOADS
137
LICENSE
MIT
VISIBILITY
Public
PUBLISHED
4 years ago
SIZE
N/A
An alternative to `_
2 contributors
Install transform as a package?
Copied
npm i @bit/lodash.lodash.transform
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.cloud
Component Example
React
React
Vue
Angular
React Native
Add dependency... help_outline
Just
import
any of the 1 million components
and packages in Bit or NPM to the example.
import Button from '@bit/grommet.grommet.button';
import Lodash from 'lodash';
toggle layout
No preview available
modifieddraft
chevron_left
chevron_right
transform (
object:Object,
iteratee:Function,
accumulator:*?
) : *

An alternative to reduce this method transforms object to a new accumulator object which is the result of running each of its own enumerable string keyed properties thru iteratee, with each invocation potentially mutating the accumulator object. If accumulator is not provided, a new object with the same [[Prototype]] will be used. The iteratee is invoked with four arguments: (accumulator, value, key, object). Iteratee functions may exit iteration early by explicitly returning false.

Example
transform([2, 3, 4], (result, n) => {
  result.push(n *= n)
  return n % 2 == 0
}, [])
// => [4, 9]

transform({ 'a': 1, 'b': 2, 'c': 1 }, (result, value, key) => {
  (result[value] || (result[value] = [])).push(key)
}, {})
// => { '1': ['a', 'c'], '2': ['b'] }
Arguments
object: Object

The object to iterate over.

iteratee: Function

The function invoked per iteration.

accumulator: *?

The custom accumulator value.

Returns
*

Returns the accumulated value.

Help and resources