<commit_before>var helper = require("./contact-helper");
var ContactCommon = require("./contact-model-common");
var imageSource = require("image-source");

var Contact = (function (_super) {
    global.__extends(Contact, _super);

    function Contact(){
        _super.apply(this, arguments);
    }

    Contact.prototype.initializeFromNative = function(contactData, contactFields) {
        contactFields = contactFields || ['name','organization','nickname','notes','photo','urls','phoneNumbers','emailAddresses','postalAddresses']
        
        this.id = helper.getiOSValue("identifier", contactData);
        
        //NAME
        this.name.given = helper.getiOSValue("givenName", contactData);    
        this.name.family = helper.getiOSValue("familyName", contactData);
        this.name.middle = helper.getiOSValue("middleName", contactData);
        this.name.prefix = helper.getiOSValue("namePrefix", contactData);
        this.name.suffix = helper.getiOSValue("nameSuffix", contactData);
        this.name.phonetic.given = helper.getiOSValue("phoneticGivenName", contactData);
        this.name.phonetic.middle = helper.getiOSValue("phoneticMiddleName", contactData);
        this.name.phonetic.family = helper.getiOSValue("phoneticFamilyName", contactData);

        //ORG
        this.organization.jobTitle = helper.getiOSValue("jobTitle", contactData);    
        this.organization.department = helper.getiOSValue("departmentName", contactData);
        this.organization.name = helper.getiOSValue("organizationName", contactData);
        
        this.nickname = helper.getiOSValue("nickname", contactData);
        
        this.notes = helper.getiOSValue("notes", contactData);
        
        if (contactFields.indexOf('photo') > -1 && contactData.imageDataAvailable) {
            this.photo = imageSource.fromData(contactData.imageData).toBase64String('png');
        } else { delete this.photo; }
        
        if(contactFields.indexOf('phoneNumbers') > -1 && contactData.phoneNumbers.count > 0) {
            for(var i = 0; i < contactData.phoneNumbers.count; i++){
                var pdata = contactData.phoneNumbers[i];
                this.phoneNumbers.push(
                    {
                        id: pdata.identifier,
                        label: helper.getPhoneLabel(pdata.label),<commit_msg>Add Picture as Base64 on ios<commit_after>var helper = require("./contact-helper");
var ContactCommon = require("./contact-model-common");
var imageSource = require("image-source");

var Contact = (function (_super) {
    global.__extends(Contact, _super);

    function Contact(){
        _super.apply(this, arguments);
    }

    Contact.prototype.initializeFromNative = function(contactData, contactFields) {
        contactFields = contactFields || ['name','organization','nickname','notes','photo','urls','phoneNumbers','emailAddresses','postalAddresses']
        
        this.id = helper.getiOSValue("identifier", contactData);
        
        //NAME
        this.name.given = helper.getiOSValue("givenName", contactData);    
        this.name.family = helper.getiOSValue("familyName", contactData);
        this.name.middle = helper.getiOSValue("middleName", contactData);
        this.name.prefix = helper.getiOSValue("namePrefix", contactData);
        this.name.suffix = helper.getiOSValue("nameSuffix", contactData);
        this.name.phonetic.given = helper.getiOSValue("phoneticGivenName", contactData);
        this.name.phonetic.middle = helper.getiOSValue("phoneticMiddleName", contactData);
        this.name.phonetic.family = helper.getiOSValue("phoneticFamilyName", contactData);

        //ORG
        this.organization.jobTitle = helper.getiOSValue("jobTitle", contactData);    
        this.organization.department = helper.getiOSValue("departmentName", contactData);
        this.organization.name = helper.getiOSValue("organizationName", contactData);
        
        this.nickname = helper.getiOSValue("nickname", contactData);
        
        this.notes = helper.getiOSValue("notes", contactData);
        
        if (contactFields.indexOf('photo') > -1 && contactData.imageDataAvailable) {
            this.photo = 'data:image/png;base64,' + imageSource.fromData(contactData.imageData).toBase64String('png');
        } else { delete this.photo; }
        
        if(contactFields.indexOf('phoneNumbers') > -1 && contactData.phoneNumbers.count > 0) {
            for(var i = 0; i < contactData.phoneNumbers.count; i++){
                var pdata = contactData.phoneNumbers[i];
                this.phoneNumbers.push(
                    {
                        id: pdata.identifier,
                        label: helper.getPhoneLabel(pdata.label),
{'fraction_non_alphanumeric': 0.13018628281117697, 'fraction_numerical': 0.003386960203217612, 'mean_word_length': 3.0008467400508043, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '3583305', 'n_tokens_mistral': 1339, 'n_tokens_neox': 1240, 'n_words': 197}