Skip to content

Commit

Permalink
Removed Numeric separator
Browse files Browse the repository at this point in the history
  • Loading branch information
jaxoncreed committed Nov 16, 2022
1 parent 7fdb3b4 commit 3189008
Show file tree
Hide file tree
Showing 270 changed files with 1,949 additions and 4,636 deletions.
5 changes: 4 additions & 1 deletion build/replacements.mjs
Expand Up @@ -91,6 +91,8 @@ const internalValidatorsRequireRelativeUtil = ["require\\('internal/util'\\)", "

const internalValidatorsRequireUtilTypes = ["require\\('internal/util/types'\\)", "require('../ours/util').types"]

const internalValidatorsNumericSeparator = ['4_294_967_295', '4294967295']

const streamIndexIsUint8Array = [
"Stream._isUint8Array = require\\('internal/util/types'\\).isUint8Array;",
`
Expand Down Expand Up @@ -253,7 +255,8 @@ export const replacements = {
internalValidatorsRequireRelativeUtil,
internalValidatorsRequireUtilTypes,
internalValidatorsNoRequireSignals,
internalValidatorsNoCoalesceAssignment
internalValidatorsNoCoalesceAssignment,
internalValidatorsNumericSeparator
],
'lib/stream.js': [
streamIndexIsUint8Array,
Expand Down
3 changes: 2 additions & 1 deletion lib/_stream_duplex.js
@@ -1,3 +1,4 @@
'use strict' // Keep this file as an alias for the full stream module.
'use strict'

// Keep this file as an alias for the full stream module.
module.exports = require('./stream').Duplex
3 changes: 2 additions & 1 deletion lib/_stream_passthrough.js
@@ -1,3 +1,4 @@
'use strict' // Keep this file as an alias for the full stream module.
'use strict'

// Keep this file as an alias for the full stream module.
module.exports = require('./stream').PassThrough
3 changes: 2 additions & 1 deletion lib/_stream_readable.js
@@ -1,3 +1,4 @@
'use strict' // Keep this file as an alias for the full stream module.
'use strict'

// Keep this file as an alias for the full stream module.
module.exports = require('./stream').Readable
3 changes: 2 additions & 1 deletion lib/_stream_transform.js
@@ -1,3 +1,4 @@
'use strict' // Keep this file as an alias for the full stream module.
'use strict'

// Keep this file as an alias for the full stream module.
module.exports = require('./stream').Transform
3 changes: 2 additions & 1 deletion lib/_stream_writable.js
@@ -1,3 +1,4 @@
'use strict' // Keep this file as an alias for the full stream module.
'use strict'

// Keep this file as an alias for the full stream module.
module.exports = require('./stream').Writable
13 changes: 2 additions & 11 deletions lib/internal/streams/add-abort-signal.js
@@ -1,52 +1,43 @@
'use strict'

const { AbortError, codes } = require('../../ours/errors')

const eos = require('./end-of-stream')
const { ERR_INVALID_ARG_TYPE } = codes

const { ERR_INVALID_ARG_TYPE } = codes // This method is inlined here for readable-stream
// This method is inlined here for readable-stream
// It also does not allow for signal to not exist on the stream
// https://github.com/nodejs/node/pull/36061#discussion_r533718029

const validateAbortSignal = (signal, name) => {
if (typeof signal !== 'object' || !('aborted' in signal)) {
throw new ERR_INVALID_ARG_TYPE(name, 'AbortSignal', signal)
}
}

function isNodeStream(obj) {
return !!(obj && typeof obj.pipe === 'function')
}

module.exports.addAbortSignal = function addAbortSignal(signal, stream) {
validateAbortSignal(signal, 'signal')

if (!isNodeStream(stream)) {
throw new ERR_INVALID_ARG_TYPE('stream', 'stream.Stream', stream)
}

return module.exports.addAbortSignalNoValidate(signal, stream)
}

module.exports.addAbortSignalNoValidate = function (signal, stream) {
if (typeof signal !== 'object' || !('aborted' in signal)) {
return stream
}

const onAbort = () => {
stream.destroy(
new AbortError(undefined, {
cause: signal.reason
})
)
}

if (signal.aborted) {
onAbort()
} else {
signal.addEventListener('abort', onAbort)
eos(stream, () => signal.removeEventListener('abort', onAbort))
}

return stream
}
43 changes: 10 additions & 33 deletions lib/internal/streams/buffer_list.js
@@ -1,18 +1,14 @@
'use strict'

const { StringPrototypeSlice, SymbolIterator, TypedArrayPrototypeSet, Uint8Array } = require('../../ours/primordials')

const { Buffer } = require('buffer')

const { inspect } = require('../../ours/util')

module.exports = class BufferList {
constructor() {
this.head = null
this.tail = null
this.length = 0
}

push(v) {
const entry = {
data: v,
Expand All @@ -23,7 +19,6 @@ module.exports = class BufferList {
this.tail = entry
++this.length
}

unshift(v) {
const entry = {
data: v,
Expand All @@ -33,7 +28,6 @@ module.exports = class BufferList {
this.head = entry
++this.length
}

shift() {
if (this.length === 0) return
const ret = this.head.data
Expand All @@ -42,73 +36,62 @@ module.exports = class BufferList {
--this.length
return ret
}

clear() {
this.head = this.tail = null
this.length = 0
}

join(s) {
if (this.length === 0) return ''
let p = this.head
let ret = '' + p.data

while ((p = p.next) !== null) ret += s + p.data

return ret
}

concat(n) {
if (this.length === 0) return Buffer.alloc(0)
const ret = Buffer.allocUnsafe(n >>> 0)
let p = this.head
let i = 0

while (p) {
TypedArrayPrototypeSet(ret, p.data, i)
i += p.data.length
p = p.next
}

return ret
} // Consumes a specified amount of bytes or characters from the buffered data.
}

// Consumes a specified amount of bytes or characters from the buffered data.
consume(n, hasStrings) {
const data = this.head.data

if (n < data.length) {
// `slice` is the same for buffers and strings.
const slice = data.slice(0, n)
this.head.data = data.slice(n)
return slice
}

if (n === data.length) {
// First chunk is a perfect match.
return this.shift()
} // Result spans more than one buffer.

}
// Result spans more than one buffer.
return hasStrings ? this._getString(n) : this._getBuffer(n)
}

first() {
return this.head.data
}

*[SymbolIterator]() {
for (let p = this.head; p; p = p.next) {
yield p.data
}
} // Consumes a specified amount of characters from the buffered data.
}

// Consumes a specified amount of characters from the buffered data.
_getString(n) {
let ret = ''
let p = this.head
let c = 0

do {
const str = p.data

if (n > str.length) {
ret += str
n -= str.length
Expand All @@ -123,26 +106,22 @@ module.exports = class BufferList {
this.head = p
p.data = StringPrototypeSlice(str, n)
}

break
}

++c
} while ((p = p.next) !== null)

this.length -= c
return ret
} // Consumes a specified amount of bytes from the buffered data.
}

// Consumes a specified amount of bytes from the buffered data.
_getBuffer(n) {
const ret = Buffer.allocUnsafe(n)
const retLen = n
let p = this.head
let c = 0

do {
const buf = p.data

if (n > buf.length) {
TypedArrayPrototypeSet(ret, buf, retLen - n)
n -= buf.length
Expand All @@ -157,17 +136,15 @@ module.exports = class BufferList {
this.head = p
p.data = buf.slice(n)
}

break
}

++c
} while ((p = p.next) !== null)

this.length -= c
return ret
} // Make sure the linked list only shows the minimal necessary information.
}

// Make sure the linked list only shows the minimal necessary information.
[Symbol.for('nodejs.util.inspect.custom')](_, options) {
return inspect(this, {
...options,
Expand Down

0 comments on commit 3189008

Please sign in to comment.