-
-
Notifications
You must be signed in to change notification settings - Fork 33.1k
Closed
Labels
bufferIssues and PRs related to the buffer subsystem.Issues and PRs related to the buffer subsystem.docIssues and PRs related to the documentations.Issues and PRs related to the documentations.
Description
Per this documentation: https://nodejs.org/dist/latest-v4.x/docs/api/buffer.html#buffer_class_method_buffer_from_array
Buffer.from(array)
was added in v3.0. However, this example (taken from docs) fails in Node v4.2.3 and Node v4.4.4
const buf = Buffer.from([0x62,0x75,0x66,0x66,0x65,0x72]);
// creates a new Buffer containing ASCII bytes
// ['b','u','f','f','e','r'] <-- fails in Node < v4.5.0
// error
TypeError: this is not a typed array.
at Function.from (native)
at repl:1:20
at REPLServer.defaultEval (repl.js:262:27)
at bound (domain.js:287:14)
at REPLServer.runBound [as eval] (domain.js:300:12)
at REPLServer.<anonymous> (repl.js:431:12)
at emitOne (events.js:82:20)
at REPLServer.emit (events.js:169:7)
at REPLServer.Interface._onLine (readline.js:211:10)
at REPLServer.Interface._line (readline.js:550:8)
Now as per latest docs: https://nodejs.org/api/buffer.html#buffer_class_method_buffer_from_array, our friend seems to have been "added in v5.10.0"
And rightfully so, fails in v5.0.0
λ rpm-extract → λ git master* → node -v
v5.0.0
λ rpm-extract → λ git master* → node
> console.log(Buffer.from([0x62,0x75,0x66,0x66,0x65,0x72]))
TypeError: this is not a typed array.
at Function.from (native)
at repl:1:20
So, my question is:
- Documentation is inconsistent and misleading.
- I want to support node v4 and v6. But this intermittent behavior will cause unwanted issues for consumers who are on > 4.0 and < 5.10.0 . What's the best way to handle this?
All the tests were done using nvm on a 64 bit OSX El Capitan.
Metadata
Metadata
Assignees
Labels
bufferIssues and PRs related to the buffer subsystem.Issues and PRs related to the buffer subsystem.docIssues and PRs related to the documentations.Issues and PRs related to the documentations.