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

cbor-redux

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cbor-redux - npm Package Compare versions

Comparing version 0.3.1 to 0.4.0

10

dist/CBOR.d.ts
/** A function that extracts tagged values. */
declare type TaggedValueFunction = (value: number, tag: number) => TaggedValue;
declare type TaggedValueFunction = (value: any, tag: number) => TaggedValue;
/** A function that extracts simple values. */
declare type SimpleValueFunction = (value: number) => SimpleValue;
declare type SimpleValueFunction = (value: any) => SimpleValue;
/** Convenience class for structuring a tagged value. */
export declare class TaggedValue {
constructor(value: number, tag: number);
value: number;
constructor(value: any, tag: number);
value: any;
tag: number;

@@ -14,3 +14,3 @@ }

constructor(value: any);
value: number;
value: any;
}

@@ -17,0 +17,0 @@ /**

@@ -17,3 +17,4 @@ "use strict";

// SameValue algorithm
if (x === y) { // Steps 1-5, 7-10
// Steps 1-5, 7-10
if (x === y) {
// Steps 6.b-6.e: +0 != -0

@@ -52,3 +53,3 @@ return x !== 0 || 1 / x === 1 / y;

let tagValueFunction = function (value, tag) {
return value;
return new TaggedValue(value, tag);
};

@@ -315,2 +316,25 @@ let simpleValFunction = function (value) {

}
function writeVarUint(val, mod) {
if (val <= 0xff) {
if (val < 24) {
writeUint8(val | mod);
}
else {
writeUint8(0x18 | mod);
writeUint8(val);
}
}
else if (val <= 0xffff) {
writeUint8(0x19 | mod);
writeUint16(val);
}
else if (val <= 0xffffffff) {
writeUint8(0x1a | mod);
writeUint32(val);
}
else {
writeUint8(0x1b | mod);
writeUint64(val);
}
}
function writeTypeAndLength(type, length) {

@@ -411,2 +435,6 @@ if (length < 24) {

}
else if (val instanceof TaggedValue) {
writeVarUint(val.tag, 0b11000000);
encodeItem(val.value);
}
else {

@@ -413,0 +441,0 @@ let keys = Object.keys(val);

/** Method for polyfilling CBOR instead of intentionally importing. */
export declare function polyfill(): Promise<void>;

@@ -0,0 +0,0 @@ "use strict";

@@ -30,5 +30,5 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.CBOR = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){

if (typeof Object.is === 'function') return Object.is(x, y); // SameValue algorithm
// Steps 1-5, 7-10
if (x === y) {
// Steps 1-5, 7-10
// Steps 6.b-6.e: +0 != -0

@@ -77,3 +77,3 @@ return x !== 0 || 1 / x === 1 / y;

var tagValueFunction = function tagValueFunction(value, tag) {
return value;
return new TaggedValue(value, tag);
};

@@ -386,2 +386,22 @@

function writeVarUint(val, mod) {
if (val <= 0xff) {
if (val < 24) {
writeUint8(val | mod);
} else {
writeUint8(0x18 | mod);
writeUint8(val);
}
} else if (val <= 0xffff) {
writeUint8(0x19 | mod);
writeUint16(val);
} else if (val <= 0xffffffff) {
writeUint8(0x1a | mod);
writeUint32(val);
} else {
writeUint8(0x1b | mod);
writeUint64(val);
}
}
function writeTypeAndLength(type, length) {

@@ -474,2 +494,5 @@ if (length < 24) {

writeUint8Array(converted);
} else if (val instanceof TaggedValue) {
writeVarUint(val.tag, 192);
encodeItem(val.value);
} else {

@@ -476,0 +499,0 @@ var keys = Object.keys(val);

/** A function that extracts tagged values. */
declare type TaggedValueFunction = (value: number, tag: number) => TaggedValue;
declare type TaggedValueFunction = (value: any, tag: number) => TaggedValue;
/** A function that extracts simple values. */
declare type SimpleValueFunction = (value: number) => SimpleValue;
declare type SimpleValueFunction = (value: any) => SimpleValue;
/** Convenience class for structuring a tagged value. */
export declare class TaggedValue {
constructor(value: number, tag: number);
value: number;
constructor(value: any, tag: number);
value: any;
tag: number;

@@ -14,3 +14,3 @@ }

constructor(value: any);
value: number;
value: any;
}

@@ -17,0 +17,0 @@ /**

@@ -14,3 +14,4 @@ /** @hidden */

// SameValue algorithm
if (x === y) { // Steps 1-5, 7-10
// Steps 1-5, 7-10
if (x === y) {
// Steps 6.b-6.e: +0 != -0

@@ -47,3 +48,3 @@ return x !== 0 || 1 / x === 1 / y;

let tagValueFunction = function (value, tag) {
return value;
return new TaggedValue(value, tag);
};

@@ -309,2 +310,25 @@ let simpleValFunction = function (value) {

}
function writeVarUint(val, mod) {
if (val <= 0xff) {
if (val < 24) {
writeUint8(val | mod);
}
else {
writeUint8(0x18 | mod);
writeUint8(val);
}
}
else if (val <= 0xffff) {
writeUint8(0x19 | mod);
writeUint16(val);
}
else if (val <= 0xffffffff) {
writeUint8(0x1a | mod);
writeUint32(val);
}
else {
writeUint8(0x1b | mod);
writeUint64(val);
}
}
function writeTypeAndLength(type, length) {

@@ -405,2 +429,6 @@ if (length < 24) {

}
else if (val instanceof TaggedValue) {
writeVarUint(val.tag, 0b11000000);
encodeItem(val.value);
}
else {

@@ -407,0 +435,0 @@ let keys = Object.keys(val);

/** Method for polyfilling CBOR instead of intentionally importing. */
export declare function polyfill(): Promise<void>;

@@ -0,0 +0,0 @@ /** Method for polyfilling CBOR instead of intentionally importing. */

{
"name": "cbor-redux",
"version": "0.3.1",
"version": "0.4.0",
"main": "dist/CBOR.js",

@@ -5,0 +5,0 @@ "types": "dist/CBOR.d.ts",

@@ -25,2 +25,3 @@ # cbor-redux

Require `cbor-redux` in [Node](https://www.npmjs.com/package/cbor-redux):
```javascript

@@ -31,12 +32,15 @@ const { CBOR } = require('cbor-redux')

or import in [Deno](https://deno.land/x/cbor_redux):
```javascript
import { CBOR } from 'https://deno.land/x/cbor_redux@0.3.0/mod.ts'
import { CBOR } from 'https://deno.land/x/cbor_redux@0.4.0/mod.ts'
```
or script on an [HTML page](https://www.skypack.dev/npm/cbor-redux):
```html
<script src="https://cdn.skypack.dev/cbor-redux@^0.3.0" type="text/javascript"></script>
<script src="https://cdn.skypack.dev/cbor-redux@^0.4.0" type="text/javascript"></script>
```
> For ES5 polyfill, use es5/CBOR.js in the npm package or else `<script src="https://unpkg.com/cbor-redux@0.3.0/es5/CBOR.js"></script>`.
> For ES5 polyfill, use es5/CBOR.js in the npm package or else `<script src="https://unpkg.com/cbor-redux@0.4.0/es5/CBOR.js"></script>`.
Then you can use it via the `CBOR`-object in your code:

@@ -57,5 +61,7 @@

- **CBOR**._**decode**_(_data: ArrayBuffer_)
> Take the ArrayBuffer object _data_ and return it decoded as a JavaScript object.
- **CBOR**._**encode**_(_data: any_)
> Take the JavaScript object _data_ and return it encoded as a ArrayBuffer object.

@@ -62,0 +68,0 @@

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