index.js
function formalizeWrap(wrap) {
    const result = {before: '', after: ''};

    if ((typeof wrap === 'string' && wrap.length > 0) || typeof wrap === 'number') {
        result.before = result.after = wrap;
    } else if (Array.isArray(wrap) && wrap.length > 0) {
        result.before = [].slice.call(wrap, 0, 1)[0];
        result.after = wrap.length > 1 ? [].slice.call(wrap, 1, 2)[0] : result.before;
    } else if (_.isPlainObject(wrap)) {
        let i = 0;

        // crappy method getting the value of the first and second item in object
        for (let el in wrap) {
            if (!wrap.hasOwnProperty(el)) {
                continue;
            }

            if (i < 2) {
                result.before = wrap[el];
            }

            i++;
        }

        // set value of after to the value of before if after is empty
        result.after = result.after.length < 1 ? result.before : result.after;
    }

    return result;
}
function formalizeWrap(wrap) {
    const result = {before: '', after: ''};

    if ((typeof wrap === 'string' && wrap.length > 0) || typeof wrap === 'number') {
        result.before = result.after = wrap;
    } else if (Array.isArray(wrap) && wrap.length > 0) {
        result.before = [].slice.call(wrap, 0, 1)[0];
        result.after = wrap.length > 1 ? [].slice.call(wrap, 1, 2)[0] : result.before;
    } else if (_.isPlainObject(wrap)) {
        let i = 0;

        // crappy method getting the value of the first and second item in object
        for (let el in wrap) {
            if (!wrap.hasOwnProperty(el)) {
                continue;
            }

            if (i < 2) {
                result.before = wrap[el];
            }

            i++;
        }

        // set value of after to the value of before if after is empty
        result.after = result.after.length < 1 ? result.before : result.after;
    }

    return result;
}
function formalizeWrap ( wrap ) { const result = { before : '' , after : '' } ; if ( ( typeof wrap === 'string' && wrap . length > 0 ) || typeof wrap === 'number' ) { result . before = result . after = wrap ; } else if ( Array . isArray ( wrap ) && wrap . length > 0 ) { result . before = [ ] . slice . call ( wrap , 0 , 1 ) [ 0 ] ; result . after = wrap . length > 1 ? [ ] . slice . call ( wrap , 1 , 2 ) [ 0 ] : result . before ; } else if ( _ . isPlainObject ( wrap ) ) { let i = 0 ; // crappy method getting the value of the first and second item in object for ( let el in wrap ) { if ( ! wrap . hasOwnProperty ( el ) ) { continue ; } if ( i < 2 ) { result . before = wrap [ el ] ; } i ++ ; } // set value of after to the value of before if after is empty result . after = result . after . length < 1 ? result . before : result . after ; } return result ; }
Formalize any given value as wrap object

@param wrap
@returns {{before: '', after: ''}}
Formalize any given value as wrap object