Socket
Socket
Sign inDemoInstall

multiformats

Package Overview
Dependencies
Maintainers
1
Versions
153
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

multiformats - npm Package Compare versions

Comparing version 9.4.6 to 9.4.7

12

cjs/src/codecs/json.js

@@ -5,8 +5,8 @@ 'use strict';

const {name, code, encode, decode} = {
name: 'json',
code: 512,
encode: json => new TextEncoder().encode(JSON.stringify(json)),
decode: bytes => JSON.parse(new TextDecoder().decode(bytes))
};
const textEncoder = new TextEncoder();
const textDecoder = new TextDecoder();
const name = 'json';
const code = 512;
const encode = node => textEncoder.encode(JSON.stringify(node));
const decode = data => JSON.parse(textDecoder.decode(data));

@@ -13,0 +13,0 @@ exports.code = code;

@@ -7,9 +7,6 @@ 'use strict';

const raw = bytes$1 => bytes.coerce(bytes$1);
const {name, code, encode, decode} = {
name: 'raw',
code: 85,
decode: raw,
encode: raw
};
const name = 'raw';
const code = 85;
const encode = node => bytes.coerce(node);
const decode = data => bytes.coerce(data);

@@ -16,0 +13,0 @@ exports.code = code;

@@ -1,6 +0,6 @@

export const {name, code, encode, decode} = {
name: 'json',
code: 512,
encode: json => new TextEncoder().encode(JSON.stringify(json)),
decode: bytes => JSON.parse(new TextDecoder().decode(bytes))
};
const textEncoder = new TextEncoder();
const textDecoder = new TextDecoder();
export const name = 'json';
export const code = 512;
export const encode = node => textEncoder.encode(JSON.stringify(node));
export const decode = data => JSON.parse(textDecoder.decode(data));
import { coerce } from '../bytes.js';
const raw = bytes => coerce(bytes);
export const {name, code, encode, decode} = {
name: 'raw',
code: 85,
decode: raw,
encode: raw
};
export const name = 'raw';
export const code = 85;
export const encode = node => coerce(node);
export const decode = data => coerce(data);
{
"name": "multiformats",
"version": "9.4.6",
"version": "9.4.7",
"description": "Interface for multihash, multicodec, multibase and CID",

@@ -135,14 +135,14 @@ "main": "./cjs/src/index.js",

"devDependencies": {
"@types/node": "^16.0.0",
"@typescript-eslint/eslint-plugin": "^4.22.0",
"@typescript-eslint/parser": "^4.22.0",
"@types/node": "^16.7.10",
"@typescript-eslint/eslint-plugin": "^4.30.0",
"@typescript-eslint/parser": "^4.30.0",
"buffer": "^6.0.3",
"c8": "^7.7.1",
"cids": "^1.1.6",
"hundreds": "0.0.9",
"ipjs": "^5.0.3",
"mocha": "^9.0.0",
"c8": "^7.8.0",
"cids": "^1.1.9",
"hundreds": "^0.0.9",
"ipjs": "^5.1.0",
"mocha": "^9.1.1",
"polendina": "^1.1.0",
"standard": "^16.0.3",
"typescript": "^4.2.4"
"typescript": "^4.4.2"
},

@@ -149,0 +149,0 @@ "standard": {

// @ts-check
/**
* @template {number} Code
* @template T
* @typedef {import('./interface').BlockCodec<Code, T>} BlockCodec
* @typedef {import('./interface').ByteView<T>} ByteView
*/
const textEncoder = new TextEncoder()
const textDecoder = new TextDecoder()
export const name = 'json'
export const code = 0x0200
/**
* @template T
* @type {BlockCodec<0x0200, T>}
* @param {T} node
* @returns {ByteView<T>}
*/
export const { name, code, encode, decode } = {
name: 'json',
code: 0x0200,
encode: json => new TextEncoder().encode(JSON.stringify(json)),
decode: bytes => JSON.parse(new TextDecoder().decode(bytes))
}
export const encode = (node) => textEncoder.encode(JSON.stringify(node))
/**
* @template T
* @param {ByteView<T>} data
* @returns {T}
*/
export const decode = (data) => JSON.parse(textDecoder.decode(data))

@@ -6,22 +6,19 @@ // @ts-check

/**
* @template {number} Code
* @template T
* @typedef {import('./interface').BlockCodec<Code, T>} BlockCodec
* @typedef {import('./interface').ByteView<T>} ByteView
*/
export const name = 'raw'
export const code = 0x55
/**
* @param {Uint8Array} bytes
* @returns {Uint8Array}
* @param {Uint8Array} node
* @returns {ByteView<Uint8Array>}
*/
const raw = (bytes) => coerce(bytes)
export const encode = (node) => coerce(node)
/**
* @template T
* @type {BlockCodec<0x55, Uint8Array>}
* @param {ByteView<Uint8Array>} data
* @returns {Uint8Array}
*/
export const { name, code, encode, decode } = {
name: 'raw',
code: 0x55,
decode: raw,
encode: raw
}
export const decode = (data) => coerce(data)

@@ -1,6 +0,6 @@

export const name: string;
export const name: "json";
export const code: 512;
export const encode: (data: T) => import("./interface").ByteView<T>;
export const decode: (bytes: import("./interface").ByteView<T>) => T;
export type BlockCodec<Code extends number, T_1> = import('./interface').BlockCodec<Code, T_1>;
export function encode<T>(node: T): ByteView<T>;
export function decode<T>(data: ByteView<T>): T;
export type ByteView<T> = import('./interface').ByteView<T>;
//# sourceMappingURL=json.d.ts.map

@@ -1,6 +0,10 @@

export const name: string;
/**
* @template T
* @typedef {import('./interface').ByteView<T>} ByteView
*/
export const name: "raw";
export const code: 85;
export const encode: (data: Uint8Array) => import("./interface").ByteView<Uint8Array>;
export const decode: (bytes: import("./interface").ByteView<Uint8Array>) => Uint8Array;
export type BlockCodec<Code extends number, T_1> = import('./interface').BlockCodec<Code, T_1>;
export function encode(node: Uint8Array): ByteView<Uint8Array>;
export function decode(data: ByteView<Uint8Array>): Uint8Array;
export type ByteView<T> = import('./interface').ByteView<T>;
//# sourceMappingURL=raw.d.ts.map

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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