<commit_before>//
//  ImageProcessingRenderer.swift
//  AsyncImageView
//
//  Created by <NAME> on 11/27/15.
//  Copyright © 2015 <NAME>. All rights reserved.
//

import UIKit
import ReactiveCocoa

/// `RendererType` decorator that applies processing to every emitted image.
public final class ImageProcessingRenderer<Renderer: RendererType>: RendererType {
	public typealias Block = (image: UIImage, data: Renderer.Data) -> UIImage

	private let renderer: Renderer
	private let processingBlock: Block

	public init(renderer: Renderer, processingBlock: Block) {
		self.renderer = renderer
		self.processingBlock = processingBlock
	}

	public func renderImageWithData(data: Renderer.Data) -> SignalProducer<UIImage, Renderer.Error> {
		return self.renderer.renderImageWithData(data)
			.observeOn(QueueScheduler())
			.map { $0.image }
			.map { [block = self.processingBlock] image in<commit_msg>ImageProcessingRenderer: parametrized scheduler<commit_after>//
//  ImageProcessingRenderer.swift
//  AsyncImageView
//
//  Created by <NAME> on 11/27/15.
//  Copyright © 2015 <NAME>. All rights reserved.
//

import UIKit
import ReactiveCocoa

/// `RendererType` decorator that applies processing to every emitted image.
public final class ImageProcessingRenderer<Renderer: RendererType>: RendererType {
	public typealias Block = (image: UIImage, data: Renderer.Data) -> UIImage

	private let renderer: Renderer
	private let scheduler: SchedulerType
	private let processingBlock: Block

	public init(renderer: Renderer, processingBlock: Block, scheduler: SchedulerType = QueueScheduler()) {
		self.renderer = renderer
		self.scheduler = scheduler
		self.processingBlock = processingBlock
	}

	public func renderImageWithData(data: Renderer.Data) -> SignalProducer<UIImage, Renderer.Error> {
		return self.renderer.renderImageWithData(data)
			.observeOn(self.scheduler)
			.map { $0.image }
			.map { [block = self.processingBlock] image in
{'fraction_non_alphanumeric': 0.09917355371900827, 'fraction_numerical': 0.011363636363636364, 'mean_word_length': 4.647230320699708, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4362519', 'n_tokens_mistral': 605, 'n_tokens_neox': 559, 'n_words': 160}