{"size": 907, "ext": "js", "max_stars_repo_path": "__perfs__/lib/collection/into.js", "max_stars_repo_name": "creativewave/markdown-api", "max_stars_repo_stars_event_min_datetime": "2019-04-29T10:21:03.000Z", "max_stars_repo_stars_event_max_datetime": "2019-04-29T10:21:03.000Z", "max_issues_repo_path": "__perfs__/lib/collection/into.js", "max_issues_repo_name": "creativewave/markdown-api", "max_issues_repo_issues_event_min_datetime": "2020-07-26T16:58:48.000Z", "max_issues_repo_issues_event_max_datetime": "2021-03-29T10:22:34.000Z", "max_forks_repo_path": "__perfs__/lib/collection/into.js", "max_forks_repo_name": "creativewave/markdown-api", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": 5, "max_forks_count": null, "avg_line_length": 31.275862069, "max_line_length": 72, "alphanum_fraction": 0.625137817}

const benchmark = require('../../benchmark')
const compose = require('lodash/fp/compose')
const filterReducer = require('../../../lib/collection/filterReducer')
const into = require('../../../lib/collection/into')
const mapReducer = require('../../../lib/collection/mapReducer')

const increment = i => ++i
const isEven = i => i % 2 === 0
const transducer = compose(mapReducer(increment), filterReducer(isEven))
const reducer = (collection, value) => {
    const incremented = increment(value)
    if (isEven(incremented)) {
        return collection.concat([incremented])
    }
    return collection
}

const createArray = () => [...Array(100)].map((_, i) => i)

benchmark({
    name: 'into()',
    units: {
        current: () => into([], transducer, createArray()),
        native: () => createArray().reduce(reducer, []),
        nativeAlt: () => createArray().map(increment).filter(isEven),
    },
})
