@ipld/codec-interface
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -90,2 +90,5 @@ 'use strict' | ||
async reader (block) { | ||
// Skip a decoding if the source is available. | ||
if (block.source && block.source()) return new Reader(block.source()) | ||
// Full decoding is required for the standard Reader interface | ||
let decoded = await block.decode() | ||
@@ -92,0 +95,0 @@ return new Reader(decoded) |
{ | ||
"name": "@ipld/codec-interface", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Codec interface for IPLD.", | ||
@@ -10,3 +10,3 @@ "main": "index.js", | ||
"scripts": { | ||
"test": "nyc --branches 100 --functions 100 --lines 100 aegir test -t node", | ||
"test": "nyc --check-coverage --branches=100 --functions=100 --lines=100 --statements=100 aegir test", | ||
"pretest": "aegir lint" | ||
@@ -13,0 +13,0 @@ }, |
@@ -46,8 +46,10 @@ # Install | ||
### Reader.get(path) | ||
### Reader.get(path | ||
### Reader.links() | ||
Returns a generator of all the links in the block. | ||
### Reader.tree() | ||
'use strict' | ||
/* globals it */ | ||
const _codec = require('../') | ||
const CID = require('cids') | ||
const { it } = require('mocha') | ||
const assert = require('assert') | ||
@@ -6,0 +6,0 @@ const tsame = require('tsame') |
'use strict' | ||
/* globals it */ | ||
const { CodecInterface } = require('../') | ||
const CID = require('cids') | ||
const { it } = require('mocha') | ||
const assert = require('assert') | ||
@@ -36,2 +36,11 @@ const tsame = require('tsame') | ||
test('source optimization', async () => { | ||
let reader = await mock.reader({ source: () => fixture }) | ||
let one = reader.get('/a/1').value | ||
same(one, 1) | ||
reader = await mock.reader({ source: () => null, decode: () => fixture }) | ||
one = reader.get('/a/1').value | ||
same(one, 1) | ||
}) | ||
test('links', async () => { | ||
@@ -38,0 +47,0 @@ let reader = await getReader() |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8441
218
55