<commit_before>//
//  Extensions.swift
//  SwiftlySalesforce
//
//  For license & details see: https://www.github.com/mike4aday/SwiftlySalesforce
//  Copyright (c) 2017. All rights reserved.
//

public extension DateFormatter {
	
	// Adapted from http://codingventures.com/articles/Dating-Swift/

	public static let salesforceDateTimeFormatter: DateFormatter = {
		let formatter = DateFormatter()
		formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZ"
		return formatter
	}()
	
	public static let salesforceDateFormatter: DateFormatter = {
		let formatter = DateFormatter()
		formatter.dateFormat = "yyyy-MM-dd"
		return formatter
	}()
}

public extension Dictionary {
	
	/// Creates a dictionary from an array of items.
	/// - Parameter items: array whose elements will become values in the dictionary
	/// - Parameter key: function that returns a key for the given item
	public init(items: [Value], key: (Value) -> Key) {
		self.init()
		for item in items {
			self[key(item)] = item
		}
	}
}

public extension JSONDecoder {
	
	convenience init(dateFormatter: DateFormatter) {
		self.init()
		self.dateDecodingStrategy = .formatted(DateFormatter.salesforceDateTimeFormatter)
	}
}

public extension Promise where T == Data {
<commit_msg>Added encoder convenience initializer; corrected error where decoder convenience initializer was ignoring formatter argument<commit_after>//
//  Extensions.swift
//  SwiftlySalesforce
//
//  For license & details see: https://www.github.com/mike4aday/SwiftlySalesforce
//  Copyright (c) 2017. All rights reserved.
//

public extension DateFormatter {
	
	// Adapted from http://codingventures.com/articles/Dating-Swift/

	public static let salesforceDateTimeFormatter: DateFormatter = {
		let formatter = DateFormatter()
		formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZ"
		return formatter
	}()
	
	public static let salesforceDateFormatter: DateFormatter = {
		let formatter = DateFormatter()
		formatter.dateFormat = "yyyy-MM-dd"
		return formatter
	}()
}

public extension Dictionary {
	
	/// Creates a dictionary from an array of items.
	/// - Parameter items: array whose elements will become values in the dictionary
	/// - Parameter key: function that returns a key for the given item
	public init(items: [Value], key: (Value) -> Key) {
		self.init()
		for item in items {
			self[key(item)] = item
		}
	}
}

public extension JSONDecoder {
	
	convenience init(dateFormatter: DateFormatter) {
		self.init()
		self.dateDecodingStrategy = .formatted(dateFormatter)
	}
}

public extension JSONEncoder {
	
	convenience init(dateFormatter: DateFormatter) {
		self.init()
		self.dateEncodingStrategy = .formatted(dateFormatter)
	}
}

public extension Promise where T == Data {

{'fraction_non_alphanumeric': 0.10551470588235294, 'fraction_numerical': 0.003676470588235294, 'mean_word_length': 3.938294010889292, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '2638393', 'n_tokens_mistral': 877, 'n_tokens_neox': 787, 'n_words': 232}