all files / api/toJSON/ author.js

100% Statements 8/8
50% Branches 1/2
100% Functions 0/0
100% Lines 8/8
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28        11× 11× 11× 11×                 11×                
'use strict';
 
const R = require('ramda');
 
const splitAndParse = R.compose(R.defaultTo(null), parseInt, R.takeLast(1), R.split('.'), String);
 
module.exports = tuple => {
    const author = tuple[1];
    Eif(author.name) {
        const xAuthor = R.evolve({imageUrl: R.replace('http://www', 'https://is')}, author);
        const retAuthor = R.assoc('type', 'author', R.pick([
            'name',
            'url',
            'imageUrl',
            'twitterId',
            'description',
            'id'
        ], xAuthor));
 
        return Array.of(R.merge({
            "type": "author",
            "id": author.id
        }, tuple[0]),
        R.evolve({id: splitAndParse},retAuthor)
        );
 
    }
};