Skip to content

Commit

Permalink
Proper strict mode support. Fixes #79
Browse files Browse the repository at this point in the history
  • Loading branch information
nolanlawson committed Dec 24, 2015
1 parent 96f9561 commit 2ad4e93
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
*/
/* eslint-disable no-proto */

'use strict'

var base64 = require('base64-js')
var ieee754 = require('ieee754')
var isArray = require('isarray')
Expand Down Expand Up @@ -88,8 +90,10 @@ function Buffer (arg) {
return new Buffer(arg)
}

this.length = 0
this.parent = undefined
if (!Buffer.TYPED_ARRAY_SUPPORT) {
this.length = 0
this.parent = undefined
}

// Common case.
if (typeof arg === 'number') {
Expand Down Expand Up @@ -220,6 +224,10 @@ function fromJsonObject (that, object) {
if (Buffer.TYPED_ARRAY_SUPPORT) {
Buffer.prototype.__proto__ = Uint8Array.prototype
Buffer.__proto__ = Uint8Array
} else {
// pre-set for values that may exist in the future
Buffer.prototype.length = undefined
Buffer.prototype.parent = undefined
}

function allocate (that, length) {
Expand Down Expand Up @@ -370,10 +378,6 @@ function byteLength (string, encoding) {
}
Buffer.byteLength = byteLength

// pre-set for values that may exist in the future
Buffer.prototype.length = undefined
Buffer.prototype.parent = undefined

function slowToString (encoding, start, end) {
var loweredCase = false

Expand Down

0 comments on commit 2ad4e93

Please sign in to comment.