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

@ipld/dag-json

Package Overview
Dependencies
Maintainers
3
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ipld/dag-json - npm Package Compare versions

Comparing version 7.0.8 to 8.0.0

22

cjs/browser-test/test-basics.js

@@ -125,2 +125,24 @@ 'use strict';

});
test('bigints', () => {
const verify = inp => {
assert.strictEqual(index.decode(new TextEncoder().encode(String(inp))), inp);
};
verify(0);
verify(1);
verify(-1);
verify(Math.pow(2, 50));
verify(-Math.pow(2, 50));
verify(Number.MAX_SAFE_INTEGER);
verify(-Number.MAX_SAFE_INTEGER);
verify(BigInt('9007199254740992'));
verify(BigInt('9007199254740993'));
verify(BigInt('11959030306112471731'));
verify(BigInt('18446744073709551615'));
verify(BigInt('9223372036854775807'));
verify(BigInt('-9007199254740992'));
verify(BigInt('-9007199254740993'));
verify(BigInt('-9223372036854776000'));
verify(BigInt('-11959030306112471732'));
verify(BigInt('-18446744073709551616'));
});
test('error on circular references', () => {

@@ -127,0 +149,0 @@ const circularObj = {};

2

cjs/index.js

@@ -149,3 +149,3 @@ 'use strict';

const decode = data => {
const options = Object.assign(decodeOptions, { tokenizer: new DagJsonTokenizer(data) });
const options = Object.assign(decodeOptions, { tokenizer: new DagJsonTokenizer(data, decodeOptions) });
return cborgJson__namespace.decode(data, options);

@@ -152,0 +152,0 @@ };

@@ -125,2 +125,24 @@ 'use strict';

});
test('bigints', () => {
const verify = inp => {
assert.strictEqual(index.decode(new TextEncoder().encode(String(inp))), inp);
};
verify(0);
verify(1);
verify(-1);
verify(Math.pow(2, 50));
verify(-Math.pow(2, 50));
verify(Number.MAX_SAFE_INTEGER);
verify(-Number.MAX_SAFE_INTEGER);
verify(BigInt('9007199254740992'));
verify(BigInt('9007199254740993'));
verify(BigInt('11959030306112471731'));
verify(BigInt('18446744073709551615'));
verify(BigInt('9223372036854775807'));
verify(BigInt('-9007199254740992'));
verify(BigInt('-9007199254740993'));
verify(BigInt('-9223372036854776000'));
verify(BigInt('-11959030306112471732'));
verify(BigInt('-18446744073709551616'));
});
test('error on circular references', () => {

@@ -127,0 +149,0 @@ const circularObj = {};

@@ -124,2 +124,24 @@ 'use strict';

});
test('bigints', () => {
const verify = inp => {
assert.strictEqual(decode(new TextEncoder().encode(String(inp))), inp);
};
verify(0);
verify(1);
verify(-1);
verify(Math.pow(2, 50));
verify(-Math.pow(2, 50));
verify(Number.MAX_SAFE_INTEGER);
verify(-Number.MAX_SAFE_INTEGER);
verify(BigInt('9007199254740992'));
verify(BigInt('9007199254740993'));
verify(BigInt('11959030306112471731'));
verify(BigInt('18446744073709551615'));
verify(BigInt('9223372036854775807'));
verify(BigInt('-9007199254740992'));
verify(BigInt('-9007199254740993'));
verify(BigInt('-9223372036854776000'));
verify(BigInt('-11959030306112471732'));
verify(BigInt('-18446744073709551616'));
});
test('error on circular references', () => {

@@ -126,0 +148,0 @@ const circularObj = {};

@@ -125,4 +125,4 @@ import { CID } from 'multiformats';

export const decode = data => {
const options = Object.assign(decodeOptions, { tokenizer: new DagJsonTokenizer(data) });
const options = Object.assign(decodeOptions, { tokenizer: new DagJsonTokenizer(data, decodeOptions) });
return cborgJson.decode(data, options);
};

@@ -124,2 +124,24 @@ 'use strict';

});
test('bigints', () => {
const verify = inp => {
assert.strictEqual(decode(new TextEncoder().encode(String(inp))), inp);
};
verify(0);
verify(1);
verify(-1);
verify(Math.pow(2, 50));
verify(-Math.pow(2, 50));
verify(Number.MAX_SAFE_INTEGER);
verify(-Number.MAX_SAFE_INTEGER);
verify(BigInt('9007199254740992'));
verify(BigInt('9007199254740993'));
verify(BigInt('11959030306112471731'));
verify(BigInt('18446744073709551615'));
verify(BigInt('9223372036854775807'));
verify(BigInt('-9007199254740992'));
verify(BigInt('-9007199254740993'));
verify(BigInt('-9223372036854776000'));
verify(BigInt('-11959030306112471732'));
verify(BigInt('-18446744073709551616'));
});
test('error on circular references', () => {

@@ -126,0 +148,0 @@ const circularObj = {};

@@ -214,4 +214,4 @@ import { CID } from 'multiformats'

// the tokenizer is stateful so we need a single instance of it
const options = Object.assign(decodeOptions, { tokenizer: new DagJsonTokenizer(data) })
const options = Object.assign(decodeOptions, { tokenizer: new DagJsonTokenizer(data, decodeOptions) })
return cborgJson.decode(data, options)
}
{
"name": "@ipld/dag-json",
"version": "7.0.8",
"version": "8.0.0",
"description": "JSON Directed Acrylic Graph (DAG-JSON) for IPLD",

@@ -40,3 +40,3 @@ "main": "./cjs/index.js",

"dependencies": {
"cborg": "^1.3.1",
"cborg": "^1.4.0",
"multiformats": "^9.0.0"

@@ -43,0 +43,0 @@ },

@@ -83,2 +83,28 @@ 'use strict'

test('bigints', () => {
const verify = (inp) => {
assert.strictEqual(decode(new TextEncoder().encode(String(inp))), inp)
}
// plain Number objects
verify(0)
verify(1)
verify(-1)
verify(Math.pow(2, 50))
verify(-Math.pow(2, 50))
verify(Number.MAX_SAFE_INTEGER)
verify(-Number.MAX_SAFE_INTEGER)
// should round-trip as BigInts
verify(BigInt('9007199254740992')) // Number.MAX_SAFE_INTEGER+1
verify(BigInt('9007199254740993'))
verify(BigInt('11959030306112471731'))
verify(BigInt('18446744073709551615')) // max uint64
verify(BigInt('9223372036854775807')) // max int64
verify(BigInt('-9007199254740992'))
verify(BigInt('-9007199254740993'))
verify(BigInt('-9223372036854776000')) // min int64
verify(BigInt('-11959030306112471732'))
verify(BigInt('-18446744073709551616')) // min -uint64
})
test('error on circular references', () => {

@@ -85,0 +111,0 @@ const circularObj = {}

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