ryanve / response.js

Responsive design toolkit
http://responsejs.com
Other
801 stars 123 forks source link

Response.affix anyone? #1

Closed ryanve closed 12 years ago

ryanve commented 12 years ago

Response.affix is an array utility that was used within some of the other methods. But since version 0.2.7 it is no longer needed within the library, so I'm considering removing it in the next version. Any objections? I think we should keep the lib as small as possible, but if you think it would be useful to keep...

Response.affix = function(prefix, array, suffix) {
    if ( !prefix || !$.isArray(array) ) { return false; } // Quit if args are wrong.
    var suffix = suffix || '';
    return $.map( array, function(value) { return prefix + value + suffix; } ) // Affix each value and return array.
};// Response.affix
ryanve commented 12 years ago

Removed for version 0.2.8

ryanve commented 12 years ago

A revamped version of Response.affix was added to version 0.4.0. This time it's here to stay. It looks like this:


function affix(arr, prefix, suffix) {
    // Return array that is a copy of arr with the prefix/suffix added to each value.
    var r = []
      , i = arr.length;
    prefix = prefix || '';
    suffix = suffix || '';
    while ( i && i-- ) {
        if (i in arr) {
            r[i] = prefix + arr[i] + suffix;
        }
    }
    return r;
}