line = line.replace(/(.*)require\('buffer'\)(.*)/, '$1require(\'../../\')$2')
// smalloc is only used for kMaxLength
- line = line.replace(/require\('smalloc'\)/, '{ kMaxLength: 0x3FFFFFFF }')
+ line = line.replace(
+ /require\('smalloc'\)/,
+ '{ kMaxLength: process.env.OBJECT_IMPL ? 0x3fffffff : 0x7fffffff }'
+ )
// comment out console logs
line = line.replace(/(.*console\..*)/, '// $1')
exports.INSPECT_MAX_BYTES = 50
Buffer.poolSize = 8192 // not used by this implementation
-var kMaxLength = 0x3fffffff
var rootParent = {}
/**
}
})()
+function kMaxLength () {
+ return Buffer.TYPED_ARRAY_SUPPORT
+ ? 0x7fffffff
+ : 0x3fffffff
+}
+
/**
* Class: Buffer
* =============
function checked (length) {
// Note: cannot use `length < kMaxLength` here because that fails when
// length is NaN (which is otherwise coerced to zero.)
- if (length >= kMaxLength) {
+ if (length >= kMaxLength()) {
throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
- 'size: 0x' + kMaxLength.toString(16) + ' bytes')
+ 'size: 0x' + kMaxLength().toString(16) + ' bytes')
}
return length | 0
}
var Buffer = require('../../').Buffer;
var SlowBuffer = require('../../').SlowBuffer;
-var smalloc = { kMaxLength: 0x3FFFFFFF };
+var smalloc = { kMaxLength: process.env.OBJECT_IMPL ? 0x3fffffff : 0x7fffffff };
// counter to ensure unique value is always copied
var cntr = 0;