Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

refactor: convert files regular, name and refs APIs to async/await #2658

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"main": "src/core/index.js",
"browser": {
"./src/core/runtime/init-assets-nodejs.js": "./src/core/runtime/init-assets-browser.js",
"./src/core/runtime/add-from-fs-nodejs.js": "./src/core/runtime/add-from-fs-browser.js",
"./src/core/runtime/config-nodejs.js": "./src/core/runtime/config-browser.js",
"./src/core/runtime/dns-nodejs.js": "./src/core/runtime/dns-browser.js",
"./src/core/runtime/libp2p-nodejs.js": "./src/core/runtime/libp2p-browser.js",
Expand Down Expand Up @@ -96,7 +95,6 @@
"glob": "^7.1.3",
"hapi-pino": "^6.1.0",
"hashlru": "^2.3.0",
"human-to-milliseconds": "^2.0.0",
"interface-datastore": "~0.8.0",
"ipfs-bitswap": "^0.26.0",
"ipfs-block": "~0.8.1",
Expand Down Expand Up @@ -162,6 +160,7 @@
"node-fetch": "^2.3.0",
"p-iteration": "^1.1.8",
"p-queue": "^6.1.0",
"parse-duration": "^0.1.2",
"peer-book": "^0.9.1",
"peer-id": "~0.12.2",
"peer-info": "~0.15.1",
Expand Down
2 changes: 1 addition & 1 deletion src/core/components/add/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const normaliseAddInput = require('ipfs-utils/src/files/normalise-input')
const { parseChunkerString } = require('./utils')
const pipe = require('it-pipe')

module.exports = ({ ipld, dag, gcLock, preload, pin, constructorOptions }) => {
module.exports = ({ ipld, dag, gcLock, preload, pin, options: constructorOptions }) => {
const isShardingEnabled = constructorOptions.EXPERIMENTAL && constructorOptions.EXPERIMENTAL.sharding
return async function * add (source, options) {
options = options || {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
'use strict'

const exporter = require('ipfs-unixfs-exporter')
const { normalizePath } = require('./utils')
const { normalizeCidPath } = require('../utils')

module.exports = function (self) {
return async function * catAsyncIterator (ipfsPath, options) {
module.exports = function ({ ipld, preload }) {
return async function * cat (ipfsPath, options) {
options = options || {}

ipfsPath = normalizePath(ipfsPath)
ipfsPath = normalizeCidPath(ipfsPath)

if (options.preload !== false) {
const pathComponents = ipfsPath.split('/')
self._preload(pathComponents[0])
preload(pathComponents[0])
}

const file = await exporter(ipfsPath, self._ipld, options)
const file = await exporter(ipfsPath, ipld, options)

// File may not have unixfs prop if small & imported with rawLeaves true
if (file.unixfs && file.unixfs.type.includes('dir')) {
Expand Down
5 changes: 2 additions & 3 deletions src/core/components/dns.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

// dns-nodejs gets replaced by dns-browser when webpacked/browserified
const dns = require('../runtime/dns-nodejs')
const callbackify = require('callbackify')

function fqdnFixups (domain) {
// Allow resolution of .eth names via .eth.link
Expand All @@ -14,7 +13,7 @@ function fqdnFixups (domain) {
}

module.exports = () => {
return callbackify.variadic(async (domain, opts) => { // eslint-disable-line require-await
return async (domain, opts) => { // eslint-disable-line require-await
opts = opts || {}

if (typeof domain !== 'string') {
Expand All @@ -24,5 +23,5 @@ module.exports = () => {
domain = fqdnFixups(domain)

return dns(domain, opts)
})
}
}
24 changes: 0 additions & 24 deletions src/core/components/files-regular/add-async-iterator.js

This file was deleted.

3 changes: 0 additions & 3 deletions src/core/components/files-regular/add-from-fs.js

This file was deleted.

3 changes: 0 additions & 3 deletions src/core/components/files-regular/add-from-stream.js

This file was deleted.

23 changes: 0 additions & 23 deletions src/core/components/files-regular/add-from-url.js

This file was deleted.

11 changes: 0 additions & 11 deletions src/core/components/files-regular/add-pull-stream.js

This file was deleted.

13 changes: 0 additions & 13 deletions src/core/components/files-regular/add-readable-stream.js

This file was deleted.

22 changes: 0 additions & 22 deletions src/core/components/files-regular/add.js

This file was deleted.

9 changes: 0 additions & 9 deletions src/core/components/files-regular/cat-pull-stream.js

This file was deleted.

11 changes: 0 additions & 11 deletions src/core/components/files-regular/cat-readable-stream.js

This file was deleted.

10 changes: 0 additions & 10 deletions src/core/components/files-regular/cat.js

This file was deleted.

20 changes: 0 additions & 20 deletions src/core/components/files-regular/get-pull-stream.js

This file was deleted.

19 changes: 0 additions & 19 deletions src/core/components/files-regular/get-readable-stream.js

This file was deleted.

18 changes: 0 additions & 18 deletions src/core/components/files-regular/get.js

This file was deleted.

34 changes: 0 additions & 34 deletions src/core/components/files-regular/index.js

This file was deleted.

9 changes: 0 additions & 9 deletions src/core/components/files-regular/ls-pull-stream.js

This file was deleted.

11 changes: 0 additions & 11 deletions src/core/components/files-regular/ls-readable-stream.js

This file was deleted.

10 changes: 0 additions & 10 deletions src/core/components/files-regular/ls.js

This file was deleted.

9 changes: 0 additions & 9 deletions src/core/components/files-regular/refs-local-pull-stream.js

This file was deleted.

11 changes: 0 additions & 11 deletions src/core/components/files-regular/refs-local-readable-stream.js

This file was deleted.

10 changes: 0 additions & 10 deletions src/core/components/files-regular/refs-local.js

This file was deleted.

9 changes: 0 additions & 9 deletions src/core/components/files-regular/refs-pull-stream.js

This file was deleted.

Loading