Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

buffer: add encoding parameter to fill() #4935

Merged
merged 1 commit into from
Feb 10, 2016

Commits on Feb 10, 2016

  1. buffer: add encoding parameter to fill()

    Can now call fill() using following parameters if value is a String:
    
        fill(string[, start[, end]][, encoding])
    
    And with the following if value is a Buffer:
    
        fill(buffer[, start[, end]])
    
    The encoding is ignored if value is not a String. All other non-Buffer
    values are coerced to a uint32.
    
    A multibyte strings will simply be copied into the Buffer until the
    number of bytes run out. Meaning partial strings can be left behind:
    
        Buffer(3).fill('\u0222');
        // returns: <Buffer c8 a2 c8>
    
    In some encoding cases, such as 'hex', fill() will throw if the input
    string is not valid.
    
    PR-URL: nodejs#4935
    Reviewed-By: James M Snell <jasnell@gmail.com>
    trevnorris committed Feb 10, 2016
    Configuration menu
    Copy the full SHA
    b55e580 View commit details
    Browse the repository at this point in the history