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 4.0.0 to 5.0.0

cjs/browser-test/test-basics.js

28

cjs/index.js

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

const _encode = obj => transform__default['default'](obj, (result, value, key) => {
const transformEncode = obj => transform__default['default'](obj, (result, value, key) => {
const cid = multiformats.CID.asCID(value);

@@ -26,3 +26,3 @@ if (cid) {

} else if (typeof value === 'object' && value !== null) {
result[key] = _encode(value);
result[key] = transformEncode(value);
} else {

@@ -32,3 +32,3 @@ result[key] = value;

});
const encode = obj => {
const _encode = obj => {
if (typeof obj === 'object' && !multiformats.bytes.isBinary(obj) && !multiformats.CID.asCID(obj) && obj) {

@@ -38,7 +38,7 @@ if (isCircular__default['default'](obj, { asCID: true })) {

}
obj = _encode(obj);
obj = transformEncode(obj);
}
return multiformats.bytes.fromString(json__default['default'](obj));
};
const _decode = obj => transform__default['default'](obj, (result, value, key) => {
const transformDecode = obj => transform__default['default'](obj, (result, value, key) => {
if (typeof value === 'object' && value !== null) {

@@ -51,6 +51,6 @@ if (value['/']) {

} else {
result[key] = _decode(value);
result[key] = transformDecode(value);
}
} else {
result[key] = _decode(value);
result[key] = transformDecode(value);
}

@@ -61,8 +61,12 @@ } else {

});
const decode = buffer => {
const obj = JSON.parse(multiformats.bytes.toString(buffer));
return _decode({ value: obj }).value;
const _decode = data => {
const obj = JSON.parse(multiformats.bytes.toString(data));
return transformDecode({ value: obj }).value;
};
const name = 'dag-json';
const code = 297;
const {name, code, decode, encode} = {
name: 'dag-json',
code: 297,
encode: _encode,
decode: _decode
};

@@ -69,0 +73,0 @@ exports.code = code;

@@ -9,3 +9,3 @@ import json from 'fast-json-stable-stringify';

import { base64 } from 'multiformats/bases/base64';
const _encode = obj => transform(obj, (result, value, key) => {
const transformEncode = obj => transform(obj, (result, value, key) => {
const cid = CID.asCID(value);

@@ -18,3 +18,3 @@ if (cid) {

} else if (typeof value === 'object' && value !== null) {
result[key] = _encode(value);
result[key] = transformEncode(value);
} else {

@@ -24,3 +24,3 @@ result[key] = value;

});
const encode = obj => {
const _encode = obj => {
if (typeof obj === 'object' && !bytes.isBinary(obj) && !CID.asCID(obj) && obj) {

@@ -30,7 +30,7 @@ if (isCircular(obj, { asCID: true })) {

}
obj = _encode(obj);
obj = transformEncode(obj);
}
return bytes.fromString(json(obj));
};
const _decode = obj => transform(obj, (result, value, key) => {
const transformDecode = obj => transform(obj, (result, value, key) => {
if (typeof value === 'object' && value !== null) {

@@ -43,6 +43,6 @@ if (value['/']) {

} else {
result[key] = _decode(value);
result[key] = transformDecode(value);
}
} else {
result[key] = _decode(value);
result[key] = transformDecode(value);
}

@@ -53,13 +53,11 @@ } else {

});
const decode = buffer => {
const obj = JSON.parse(bytes.toString(buffer));
return _decode({ value: obj }).value;
const _decode = data => {
const obj = JSON.parse(bytes.toString(data));
return transformDecode({ value: obj }).value;
};
const name = 'dag-json';
const code = 297;
export {
encode,
decode,
name,
code
export const {name, code, decode, encode} = {
name: 'dag-json',
code: 297,
encode: _encode,
decode: _decode
};
{
"name": "@ipld/dag-json",
"version": "4.0.0",
"description": "JSON Directed Acrylic Graph for IPLD",
"directories": {
"test": "test"
},
"version": "5.0.0",
"description": "JSON Directed Acrylic Graph (DAG-JSON) for IPLD",
"main": "./cjs/index.js",
"types": "./types/index.d.ts",
"scripts": {
"lint": "standard",
"build": "npm_config_yes=true npx ipjs@latest build --tests",
"publish": "npm_config_yes=true npx ipjs@latest publish",
"test:cjs": "npm run build && mocha dist/cjs/node-test/test-*.js",
"lint": "standard *.js test/*.js",
"build": "npm run build:js && npm run build:types",
"build:js": "ipjs build --tests --main && npm run build:copy",
"build:copy": "cp -a tsconfig.json index.js dist/ && mkdir -p dist/test && cp test/*.js dist/test/",
"build:types": "npm run build:copy && cd dist && tsc --build",
"publish": "ipjs publish",
"test:cjs": "npm run build:js && mocha dist/cjs/node-test/test-*.js && npm run test:cjs:browser",
"test:node": "hundreds mocha test/test-*.js",
"test:browser": "polendina --cleanup dist/cjs/node-test/test-*.js",
"test": "npm run lint && npm run test:node && npm run test:cjs && npm run test:browser",
"coverage": "c8 --reporter=html mocha test/test-*.js && npx st -d coverage -p 8080"
"test:cjs:browser": "polendina --page --worker --serviceworker --cleanup dist/cjs/node-test/test-*.js",
"test:ts": "npm run build:types && npm run test --prefix test/ts-use",
"test": "npm run lint && npm run test:node && npm run test:cjs && npm run test:ts",
"coverage": "c8 --reporter=html mocha test/test-*.js && npm_config_yes=true npx st -d coverage -p 8080"
},
"exports": {
"browser": "./esm/index.js",
"require": "./cjs/index.js",
"import": "./esm/index.js",
"browser": "./esm/index.js"
"import": "./esm/index.js"
},
"license": "(Apache-2.0 AND MIT)",
"repository": {
"type": "git",
"url": "git+https://github.com/mikeal/dag-json.git"
"url": "git+https://github.com/ipld/js-dag-json.git"
},
"keywords": [],
"author": "Mikeal Rogers <mikeal.rogers@gmail.com> (https://www.mikealrogers.com/)",
"license": "(Apache-2.0 AND MIT)",
"keywords": [
"IPFS",
"IPLD"
],
"bugs": {
"url": "https://github.com/mikeal/dag-json/issues"
"url": "https://github.com/ipld/js-dag-json/issues"
},
"homepage": "https://github.com/mikeal/dag-json#readme",
"devDependencies": {
"hundreds": "0.0.8",
"mocha": "^8.1.1",
"polendina": "^1.1.0",
"standard": "^14.3.4"
},
"homepage": "https://github.com/ipld/js-dag-json",
"dependencies": {
"@ipld/is-circular": "^2.0.0",
"@types/lodash.transform": "^4.6.6",
"fast-json-stable-stringify": "^2.1.0",
"lodash.transform": "^4.6.0",
"multiformats": "^4.0.0"
"multiformats": "^7.0.0"
},
"devDependencies": {
"hundreds": "^0.0.9",
"ipjs": "^5.0.0",
"mocha": "^8.3.2",
"polendina": "^1.1.0",
"standard": "^16.0.3",
"typescript": "^4.2.4"
},
"directories": {
"test": "test"
},
"typesVersions": {
"*": {
"*": [
"types/*"
],
"types/*": [
"types/*"
]
}
},
"author": "Mikeal Rogers <mikeal.rogers@gmail.com> (https://www.mikealrogers.com/)",
"browser": "./cjs/index.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