forked from ipfs/js-ipfs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move files to root level (ipfs#1150)
Moves remaining files that contain root level commands to the root of the src directory. This makes it easier for new contributors to find things. It also renames the `files-mfs` dir to `files` to reflect the fact that it lives in the "files" namespace currently. BREAKING CHANGE: files in `src/files-regular` have moved to `src`. The `src/files-mfs` directory has been renamed to `src/files`. If you were previously requiring files from these directories e.g. `require('ipfs-http-client/src/files-regular/add')` then please be aware that they have moved. License: MIT Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
- Loading branch information
Alan Shaw
authored
Nov 12, 2019
1 parent
2275c2a
commit 559a97d
Showing
22 changed files
with
179 additions
and
181 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
'use strict' | ||
|
||
const configure = require('../lib/configure') | ||
const cleanCID = require('../utils/clean-cid') | ||
const IsIpfs = require('is-ipfs') | ||
const ndjson = require('iterable-ndjson') | ||
const toIterable = require('../lib/stream-to-iterable') | ||
const toCamel = require('../lib/object-to-camel') | ||
|
||
module.exports = config => { | ||
const refs = (configure(({ ky }) => { | ||
return async function * refs (args, options) { | ||
options = options || {} | ||
|
||
const searchParams = new URLSearchParams() | ||
|
||
if (options.format !== undefined) { | ||
searchParams.set('format', options.format) | ||
} | ||
|
||
if (options.edges !== undefined) { | ||
searchParams.set('edges', options.edges) | ||
} | ||
|
||
if (options.unique !== undefined) { | ||
searchParams.set('unique', options.unique) | ||
} | ||
|
||
if (options.recursive !== undefined) { | ||
searchParams.set('recursive', options.recursive) | ||
} | ||
|
||
if (options.maxDepth !== undefined) { | ||
searchParams.set('max-depth', options.maxDepth) | ||
} | ||
|
||
if (!Array.isArray(args)) { | ||
args = [args] | ||
} | ||
|
||
for (let arg of args) { | ||
try { | ||
arg = cleanCID(arg) | ||
} catch (err) { | ||
if (!IsIpfs.ipfsPath(arg)) { | ||
throw err | ||
} | ||
} | ||
|
||
searchParams.append('arg', arg.toString()) | ||
} | ||
|
||
const res = await ky.get('refs', { | ||
timeout: options.timeout, | ||
signal: options.signal, | ||
headers: options.headers, | ||
searchParams | ||
}) | ||
|
||
for await (const file of ndjson(toIterable(res.body))) { | ||
yield toCamel(file) | ||
} | ||
} | ||
}))(config) | ||
|
||
refs.local = require('./local')(config) | ||
|
||
return refs | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.