<commit_before>//
//  SwiftJSON.swift
//  Pods
//
//  Created by <NAME> on 28/05/2016.
//
//

import SwiftyJSON

extension RawRepresentable {
    init?(o rawValue: RawValue?) {
        guard let rawValue = rawValue, let value = Self(rawValue: rawValue) else { return nil }
        self = value
    }
}

extension JSON  {
    public func strava<T: Strava>(_ type: T.Type?) -> T? {
        return type?.init(self)
    }
    
    public func strava<T: RawRepresentable>(_ type: T.Type?) -> T? where T.RawValue == Int {
        return type?.init(optionalRawValue: self.int)
    }
    
    public func strava<T: RawRepresentable>(_ type: T.Type?) -> T? where T.RawValue == String {
        return type?.init(optionalRawValue: self.string)
    }

    public func strava<T: Strava>(_ type: T.Type?) -> [T]? {
        return self.arrayValue.flatMap  { T($0) }
    }
 
}<commit_msg>Update SwiftyJSON.swift<commit_after>//
//  SwiftJSON.swift
//  Pods
//
//  Created by <NAME> on 28/05/2016.
//
//

import SwiftyJSON

extension RawRepresentable {
    init?(o rawValue: RawValue?) {
        guard let rawValue = rawValue, let value = Self(rawValue: rawValue) else { return nil }
        self = value
    }
}

extension JSON  {
    public func strava<T: Strava>(_ type: T.Type?) -> T? {
        return type?.init(self)
    }
    
    public func strava<T: RawRepresentable>(_ type: T.Type?) -> T? where T.RawValue == Int {
        return type?.init(optionalRawValue: self.int)
    }
    
    public func strava<T: RawRepresentable>(_ type: T.Type?) -> T? where T.RawValue == String {
        return type?.init(optionalRawValue: self.string)
    }

    public func strava<T: Strava>(_ type: T.Type?) -> [T]? {
        return self.arrayValue.compactMap  { T($0) }
    }
 
}
{'fraction_non_alphanumeric': 0.14383172256964183, 'fraction_numerical': 0.01023308698123934, 'mean_word_length': 2.485148514851485, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 21, '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': '4199484', 'n_tokens_mistral': 625, 'n_tokens_neox': 609, 'n_words': 151}