Fix dependabot issues
This commit is contained in:
parent
c89d9bd8b0
commit
531c6ba7c8
705 changed files with 53406 additions and 20466 deletions
46
node_modules/concordance/lib/serialize.js
generated
vendored
46
node_modules/concordance/lib/serialize.js
generated
vendored
|
|
@ -2,9 +2,6 @@
|
|||
|
||||
const md5hex = require('md5-hex')
|
||||
|
||||
const encoder = require('./encoder')
|
||||
const pluginRegistry = require('./pluginRegistry')
|
||||
|
||||
const argumentsValue = require('./complexValues/arguments')
|
||||
const arrayBufferValue = require('./complexValues/arrayBuffer')
|
||||
const boxedValue = require('./complexValues/boxed')
|
||||
|
|
@ -20,12 +17,16 @@ const regexpValue = require('./complexValues/regexp')
|
|||
const setValue = require('./complexValues/set')
|
||||
const typedArrayValue = require('./complexValues/typedArray')
|
||||
|
||||
const encoder = require('./encoder')
|
||||
|
||||
const itemDescriptor = require('./metaDescriptors/item')
|
||||
const mapEntryDescriptor = require('./metaDescriptors/mapEntry')
|
||||
const pointerDescriptor = require('./metaDescriptors/pointer')
|
||||
const propertyDescriptor = require('./metaDescriptors/property')
|
||||
const statsDescriptors = require('./metaDescriptors/stats')
|
||||
|
||||
const pluginRegistry = require('./pluginRegistry')
|
||||
|
||||
const bigIntValue = require('./primitiveValues/bigInt')
|
||||
const booleanValue = require('./primitiveValues/boolean')
|
||||
const nullValue = require('./primitiveValues/null')
|
||||
|
|
@ -34,6 +35,8 @@ const stringValue = require('./primitiveValues/string')
|
|||
const symbolValue = require('./primitiveValues/symbol')
|
||||
const undefinedValue = require('./primitiveValues/undefined')
|
||||
|
||||
const recursorUtils = require('./recursorUtils')
|
||||
|
||||
// Increment if encoding layout, descriptor IDs, or value types change. Previous
|
||||
// Concordance versions will not be able to decode buffers generated by a newer
|
||||
// version, so changing this value will require a major version bump of
|
||||
|
|
@ -78,7 +81,7 @@ const mappings = [
|
|||
[0x1C, regexpValue.tag, regexpValue.deserialize],
|
||||
[0x1D, setValue.tag, setValue.deserialize],
|
||||
[0x1E, typedArrayValue.tag, typedArrayValue.deserialize],
|
||||
[0x1F, typedArrayValue.bytesTag, typedArrayValue.deserializeBytes]
|
||||
[0x1F, typedArrayValue.bytesTag, typedArrayValue.deserializeBytes],
|
||||
]
|
||||
const tag2id = new Map(mappings.map(mapping => [mapping[1], mapping[0]]))
|
||||
const id2deserialize = new Map(mappings.map(mapping => [mapping[0], mapping[2]]))
|
||||
|
|
@ -116,7 +119,7 @@ class UnsupportedPluginError extends Error {
|
|||
}
|
||||
}
|
||||
|
||||
class UnsupportedVersion extends Error {
|
||||
class UnsupportedVersion extends Error { // eslint-disable-line unicorn/custom-error-definition
|
||||
constructor (serializerVersion) {
|
||||
super('Could not deserialize buffer: a different serialization was expected')
|
||||
this.name = 'UnsupportedVersion'
|
||||
|
|
@ -131,7 +134,7 @@ function shallowSerializeDescriptor (descriptor, resolvePluginRef) {
|
|||
}
|
||||
|
||||
function serializeState (state, resolvePluginRef) {
|
||||
if (Array.isArray(state)) return state.map(serializeState)
|
||||
if (Array.isArray(state)) return state.map(x => serializeState(x))
|
||||
|
||||
if (state && state.tag) {
|
||||
let id, pluginIndex
|
||||
|
|
@ -165,12 +168,12 @@ function serialize (descriptor) {
|
|||
if (!usedPlugins.has(ref.name)) {
|
||||
// Start at 1, since 0 is reserved for Concordance's descriptors.
|
||||
const index = usedPlugins.size + 1
|
||||
usedPlugins.set(ref.name, Object.assign({index}, ref.serialization))
|
||||
usedPlugins.set(ref.name, Object.assign({ index }, ref.serialization))
|
||||
}
|
||||
|
||||
return {
|
||||
id: ref.id,
|
||||
pluginIndex: usedPlugins.get(ref.name).index
|
||||
pluginIndex: usedPlugins.get(ref.name).index,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -205,7 +208,7 @@ function serialize (descriptor) {
|
|||
id,
|
||||
pluginIndex,
|
||||
children: [],
|
||||
state: shallowSerializeDescriptor(descriptor, resolvePluginRef)
|
||||
state: shallowSerializeDescriptor(descriptor, resolvePluginRef),
|
||||
}
|
||||
if (!rootRecord) {
|
||||
rootRecord = record
|
||||
|
|
@ -318,12 +321,27 @@ function deserialize (buffer, options) {
|
|||
const descriptorsByPointerIndex = new Map()
|
||||
const mapPointerDescriptor = descriptor => {
|
||||
if (descriptor.isPointer === true) {
|
||||
if (!descriptorsByPointerIndex.has(descriptor.index)) throw new PointerLookupError(descriptor.index)
|
||||
if (descriptorsByPointerIndex.has(descriptor.index)) {
|
||||
return descriptorsByPointerIndex.get(descriptor.index)
|
||||
}
|
||||
|
||||
return descriptorsByPointerIndex.get(descriptor.index)
|
||||
} else if (descriptor.isComplex === true) {
|
||||
if (typeof rootDescriptor.createRecursor === 'function') {
|
||||
// The descriptor we're pointing to may be elsewhere in the serialized
|
||||
// structure. Consume the entire structure and check again.
|
||||
recursorUtils.consumeDeep(rootDescriptor.createRecursor())
|
||||
|
||||
if (descriptorsByPointerIndex.has(descriptor.index)) {
|
||||
return descriptorsByPointerIndex.get(descriptor.index)
|
||||
}
|
||||
}
|
||||
|
||||
throw new PointerLookupError(descriptor.index)
|
||||
}
|
||||
|
||||
if (descriptor.isComplex === true) {
|
||||
descriptorsByPointerIndex.set(descriptor.pointer, descriptor)
|
||||
}
|
||||
|
||||
return descriptor
|
||||
}
|
||||
|
||||
|
|
@ -336,6 +354,8 @@ function deserialize (buffer, options) {
|
|||
return mapPointerDescriptor(deserializeDescriptor(state, recursor))
|
||||
}
|
||||
}
|
||||
return deserializeRecord(decoded.rootRecord, getDescriptorDeserializer, buffer)
|
||||
|
||||
const rootDescriptor = deserializeRecord(decoded.rootRecord, getDescriptorDeserializer, buffer)
|
||||
return rootDescriptor
|
||||
}
|
||||
exports.deserialize = deserialize
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue