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

streams2 and explicit encodings #16

Merged
merged 24 commits into from Dec 28, 2013
Merged

streams2 and explicit encodings #16

merged 24 commits into from Dec 28, 2013

Conversation

ghost
Copy link

@ghost ghost commented Dec 25, 2013

This patch uses streams2 and makes the encodings explicit instead of implicit like before. You can now use the following encodings (with room for more):

  • buffer (the default)
  • array
  • string
  • uint8array

All of these encodings should work in all browsers, even if they don't have support for typed arrays natively since this patch uses the typedarray module for Uint8Array polyfill. browserify's Buffer module natively already uses the same version, so this module will be duped in the file size output so there isn't any extra file size overhead.

var concat = require('concat-stream')
process.stdin
  .pipe(concat({ encoding: 'uint8array' }, function (body) {
    console.log(body instanceof Uint8Array)
    console.log([].slice.call(body))
  }))
$ echo abc | node x.js 
true
[ 97, 98, 99, 10 ]

@ghost
Copy link
Author

ghost commented Dec 25, 2013

chrismas sweater cat

@max-mapper
Copy link
Owner

Merging because kitten in christmas sweater

max-mapper pushed a commit that referenced this pull request Dec 28, 2013
streams2 and explicit encodings
@max-mapper max-mapper merged commit d00982c into max-mapper:master Dec 28, 2013
max-mapper added a commit that referenced this pull request Dec 28, 2013
@junosuarez junosuarez mentioned this pull request Dec 29, 2013
@max-mapper
Copy link
Owner

FYI I just published 1.4.0 which makes a slight change to the semantics introduced by this commit.

I published this PR as 1.3.0 not realizing it broke backwards compat in the way that default (no encoding set) streams are handled, so 1.4.0 fixes that.

Basically if you don't set an explicit encoding it will try to infer encoding, which is how 1.x concat-stream has worked. I may remove inference altogether in 2.0

4730459

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant