Skip to content

Commit

Permalink
chore: adjust examples for new linting rules
Browse files Browse the repository at this point in the history
  • Loading branch information
rvagg committed Oct 29, 2024
1 parent fbdc762 commit 0dff3ed
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 12 deletions.
8 changes: 5 additions & 3 deletions examples/car-to-fixture.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
#!/usr/bin/env node

/* eslint-disable no-console */

// Take a .car file and dump its contents to stdout as a single DAG-JSON format
// block. The format is standardised for describing CAR fixtures at
// https://ipld.io/specs/transport/car/fixture/

import fs from 'fs'
import { CarReader } from '@ipld/car/reader'
import { CarIndexer } from '@ipld/car/indexer'
import { CarReader } from '@ipld/car/reader'
import * as dagCbor from '@ipld/dag-cbor'
import * as dagPb from '@ipld/dag-pb'
import * as dagJson from '@ipld/dag-json'
import * as raw from 'multiformats/codecs/raw'
import * as dagPb from '@ipld/dag-pb'
import * as json from 'multiformats/codecs/json'
import * as raw from 'multiformats/codecs/raw'

if (!process.argv[2]) {
console.log('Usage: dump-car.js <path/to/car>')
Expand Down
6 changes: 4 additions & 2 deletions examples/dump-car.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env node

/* eslint-disable no-console */

// Take a .car file and dump its contents into one file per block, with the
// filename being the CID of that block.
// Also prints a DAG-JSON form of the block and its CID to stdout.
Expand All @@ -8,10 +10,10 @@
import fs from 'fs'
import { CarBlockIterator } from '@ipld/car/iterator'
import * as dagCbor from '@ipld/dag-cbor'
import * as dagPb from '@ipld/dag-pb'
import * as dagJson from '@ipld/dag-json'
import * as raw from 'multiformats/codecs/raw'
import * as dagPb from '@ipld/dag-pb'
import * as json from 'multiformats/codecs/json'
import * as raw from 'multiformats/codecs/raw'

if (!process.argv[2]) {
console.log('Usage: dump-car.js [--inspect] <path/to/car>')
Expand Down
2 changes: 2 additions & 0 deletions examples/dump-index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env node

/* eslint-disable no-console */

// Take a .car file and dump its index in DAG-JSON format, one line per block

import fs from 'fs'
Expand Down
4 changes: 3 additions & 1 deletion examples/round-trip.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#!/usr/bin/env node

/* eslint-disable no-console */

// Create a simple .car file with a single block and that block's CID as the
// single root. Then read the .car and fetch the block again.

import fs from 'fs'
import { Readable } from 'stream'
import { CarReader, CarWriter } from '@ipld/car'
import * as raw from 'multiformats/codecs/raw'
import { CID } from 'multiformats/cid'
import * as raw from 'multiformats/codecs/raw'
import { sha256 } from 'multiformats/hashes/sha2'

async function example () {
Expand Down
4 changes: 3 additions & 1 deletion examples/test-examples.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/* eslint-disable no-console */

import assert from 'assert'
import { promisify } from 'util'
import { execFile } from 'child_process'
import { promises as fsPromises } from 'fs'
import { promisify } from 'util'

const { unlink, stat } = fsPromises

Expand Down
12 changes: 7 additions & 5 deletions examples/verify-car.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
#!/usr/bin/env node

/* eslint-disable no-console */

// Example: verify a car file's block bytes match the reported CIDs and that
// they have round-tripishness.
// This example is overly verbose but illustrates some concepts involved in CAR
// files.

import fs from 'fs'
import { bytes, CID } from 'multiformats'
import { CarBlockIterator } from '@ipld/car/iterator'
import * as dagCbor from '@ipld/dag-cbor'
import * as dagPb from '@ipld/dag-pb'
import * as dagJson from '@ipld/dag-json'
import * as raw from 'multiformats/codecs/raw'
import * as dagPb from '@ipld/dag-pb'
import { blake2b256 } from '@multiformats/blake2/blake2b'
import { bytes, CID } from 'multiformats'
import * as json from 'multiformats/codecs/json'
import { sha256 } from 'multiformats/hashes/sha2'
import * as raw from 'multiformats/codecs/raw'
import { from as hasher } from 'multiformats/hashes/hasher'
import { blake2b256 } from '@multiformats/blake2/blake2b'
import { sha256 } from 'multiformats/hashes/sha2'

const { toHex } = bytes

Expand Down

0 comments on commit 0dff3ed

Please sign in to comment.