Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cbor

Package Overview
Dependencies
Maintainers
3
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cbor - npm Package Compare versions

Comparing version 5.1.2 to 5.2.0

73

lib/encoder.js

@@ -97,29 +97,29 @@ 'use strict'

this.semanticTypes = [
Array, this._pushArray,
Date, this._pushDate,
Buffer, this._pushBuffer,
Map, this._pushMap,
NoFilter, this._pushNoFilter,
RegExp, this._pushRegexp,
Set, this._pushSet,
bignumber, this._pushBigNumber,
ArrayBuffer, this._pushUint8Array,
Uint8ClampedArray, this._pushUint8Array,
Uint8Array, this._pushUint8Array,
Uint16Array, this._pushArray,
Uint32Array, this._pushArray,
Int8Array, this._pushArray,
Int16Array, this._pushArray,
Int32Array, this._pushArray,
Float32Array, this._pushFloat32Array,
Float64Array, this._pushFloat64Array
]
this.semanticTypes = {
Array: this._pushArray,
Date: this._pushDate,
Buffer: this._pushBuffer,
Map: this._pushMap,
NoFilter: this._pushNoFilter,
RegExp: this._pushRegexp,
Set: this._pushSet,
BigNumber: this._pushBigNumber,
ArrayBuffer: this._pushUint8Array,
Uint8ClampedArray: this._pushUint8Array,
Uint8Array: this._pushUint8Array,
Uint16Array: this._pushArray,
Uint32Array: this._pushArray,
Int8Array: this._pushArray,
Int16Array: this._pushArray,
Int32Array: this._pushArray,
Float32Array: this._pushFloat32Array,
Float64Array: this._pushFloat64Array
}
// tsc doesn't know about old Url
if (url['Url']) {
this.semanticTypes.push(url['Url'], this._pushUrl)
this.addSemanticType('Url', this._pushUrl)
}
if (url['URL']) {
this.semanticTypes.push(url['URL'], this._pushURL)
this.addSemanticType('URL', this._pushURL)
}

@@ -159,12 +159,9 @@

addSemanticType(type, fun) {
for (let i = 0, len = this.semanticTypes.length; i < len; i += 2) {
const typ = this.semanticTypes[i]
if (typ === type) {
const old = this.semanticTypes[i + 1]
this.semanticTypes[i + 1] = fun
return old
}
if (typeof fun !== 'function') {
throw new TypeError('fun must be of type function')
}
this.semanticTypes.push(type, fun)
return null
const typeName = (typeof type === 'string') ? type : type.name
const old = this.semanticTypes[typeName]
this.semanticTypes[typeName] = fun
return old
}

@@ -227,5 +224,5 @@

if (utils.writeHalf(b2, obj)) {
if (utils.parseHalf(b2) === obj) {
return this._pushUInt8(HALF) && this.push(b2)
}
// I have convinced myself that there are no cases where writeHalf
// will return true but `utils.parseHalf(b2) !== obj)`
return this._pushUInt8(HALF) && this.push(b2)
}

@@ -651,7 +648,5 @@ }

}
for (let i = 0, len1 = this.semanticTypes.length; i < len1; i += 2) {
const typ = this.semanticTypes[i]
if (obj instanceof typ) {
return this.semanticTypes[i + 1].call(obj, this, obj)
}
const converter = this.semanticTypes[obj.constructor.name]
if (converter) {
return converter.call(obj, this, obj)
}

@@ -658,0 +653,0 @@ }

@@ -71,4 +71,5 @@ 'use strict'

// hildjj: If the lower 13 bits are 0,
// we won't lose anything in the conversion
// hildjj: If the lower 13 bits aren't 0,
// we will lose precision in the conversion.
// mant32 = 24bits, mant16 = 11bits, 24-11 = 13
if ((u & 0x1FFF) !== 0) {

@@ -75,0 +76,0 @@ return false

{
"name": "cbor",
"version": "5.1.2",
"version": "5.2.0",
"description": "Encode and parse data in the Concise Binary Object Representation (CBOR) data format (RFC7049).",

@@ -5,0 +5,0 @@ "main": "./lib/cbor.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc