Last change
on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
364 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | var MIN_SIZE = 16 * 1024;
|
---|
| 2 | var SafeUint32Array = typeof Uint32Array !== 'undefined' ? Uint32Array : Array; // fallback on Array when TypedArray is not supported
|
---|
| 3 |
|
---|
| 4 | module.exports = function adoptBuffer(buffer, size) {
|
---|
| 5 | if (buffer === null || buffer.length < size) {
|
---|
| 6 | return new SafeUint32Array(Math.max(size + 1024, MIN_SIZE));
|
---|
| 7 | }
|
---|
| 8 |
|
---|
| 9 | return buffer;
|
---|
| 10 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.