From 4eddfed8adaa849b44a58c2fde817f3be42aee82 Mon Sep 17 00:00:00 2001 From: Alex Potsides Date: Thu, 3 Sep 2020 11:03:54 +0100 Subject: [PATCH] chore: revert "feat: add typeScript support (#3236)" (#3264) This reverts commit be26dd723ed8c76efee149a993a8ade7f75f960e. The build was failing. --- package.json | 3 +-- src/add-all.js | 17 ++--------------- src/add.js | 16 +--------------- src/bitswap/stat.js | 7 +------ src/bitswap/unwant.js | 7 +------ src/bitswap/wantlist-for-peer.js | 7 +------ src/bitswap/wantlist.js | 7 +------ src/block/get.js | 7 +------ src/block/put.js | 6 +----- src/config/replace.js | 2 +- src/dag/put.js | 2 +- src/files/write.js | 2 +- src/id.js | 7 +------ src/index.js | 14 +++----------- src/lib/configure.js | 15 ++------------- src/lib/to-url-search-params.js | 4 ---- src/object/patch/append-data.js | 2 +- src/object/patch/set-data.js | 2 +- src/object/put.js | 2 +- src/pubsub/publish.js | 2 +- src/pubsub/subscription-tracker.js | 2 +- src/resolve.js | 7 +------ src/version.js | 7 +------ 23 files changed, 26 insertions(+), 121 deletions(-) diff --git a/package.json b/package.json index bf85308b4..06a29f033 100644 --- a/package.json +++ b/package.json @@ -185,7 +185,6 @@ "shunkin ", "victorbjelkholm ", "Łukasz Magiera ", - "Łukasz Magiera ", - "Xmader " + "Łukasz Magiera " ] } diff --git a/src/add-all.js b/src/add-all.js index 68088db5c..de3483648 100644 --- a/src/add-all.js +++ b/src/add-all.js @@ -6,14 +6,10 @@ const configure = require('./lib/configure') const multipartRequest = require('./lib/multipart-request') const toUrlSearchParams = require('./lib/to-url-search-params') const anySignal = require('any-signal') -const { AbortController } = require('abort-controller') +const AbortController = require('abort-controller') module.exports = configure((api) => { - // eslint-disable-next-line valid-jsdoc - /** - * @type {import('../../ipfs/src/core/components/add-all').AddAll} - */ - async function * addAll (input, options = {}) { + return async function * addAll (input, options = {}) { const progressFn = options.progress // allow aborting requests on body errors @@ -43,16 +39,8 @@ module.exports = configure((api) => { } } } - return addAll }) -/** - * @typedef {import('../../ipfs/src/core/components/add-all').UnixFSEntry} UnixFSEntry - */ - -/** - * @returns {UnixFSEntry} - */ function toCoreInterface ({ name, hash, size, mode, mtime, mtimeNsecs }) { const output = { path: name, @@ -71,6 +59,5 @@ function toCoreInterface ({ name, hash, size, mode, mtime, mtimeNsecs }) { } } - // @ts-ignore return output } diff --git a/src/add.js b/src/add.js index 7770be584..3190b9a7d 100644 --- a/src/add.js +++ b/src/add.js @@ -4,26 +4,12 @@ const addAll = require('./add-all') const last = require('it-last') const configure = require('./lib/configure') -/** - * @typedef {import("./lib/core").ClientOptions} ClientOptions - */ - -// eslint-disable-next-line valid-jsdoc -/** - * @param {ClientOptions} options - */ module.exports = (options) => { const all = addAll(options) return configure(() => { - // eslint-disable-next-line valid-jsdoc - /** - * @type {import('../../ipfs/src/core/components/add').Add} - */ - async function add (input, options = {}) { // eslint-disable-line require-await - // @ts-ignore + return async function add (input, options = {}) { // eslint-disable-line require-await return last(all(input, options)) } - return add })(options) } diff --git a/src/bitswap/stat.js b/src/bitswap/stat.js index 8f1b64afa..ec2745896 100644 --- a/src/bitswap/stat.js +++ b/src/bitswap/stat.js @@ -6,11 +6,7 @@ const configure = require('../lib/configure') const toUrlSearchParams = require('../lib/to-url-search-params') module.exports = configure(api => { - // eslint-disable-next-line valid-jsdoc - /** - * @type {import('../../../ipfs/src/core/components/bitswap/stat').Stat} - */ - async function stat (options = {}) { + return async (options = {}) => { const res = await api.post('bitswap/stat', { searchParams: toUrlSearchParams(options), timeout: options.timeout, @@ -20,7 +16,6 @@ module.exports = configure(api => { return toCoreInterface(await res.json()) } - return stat }) function toCoreInterface (res) { diff --git a/src/bitswap/unwant.js b/src/bitswap/unwant.js index 602776e7c..b9706cebc 100644 --- a/src/bitswap/unwant.js +++ b/src/bitswap/unwant.js @@ -5,11 +5,7 @@ const configure = require('../lib/configure') const toUrlSearchParams = require('../lib/to-url-search-params') module.exports = configure(api => { - // eslint-disable-next-line valid-jsdoc - /** - * @type {import('../../../ipfs/src/core/components/bitswap/unwant').Unwant} - */ - async function unwant (cid, options = {}) { + return async (cid, options = {}) => { const res = await api.post('bitswap/unwant', { timeout: options.timeout, signal: options.signal, @@ -22,5 +18,4 @@ module.exports = configure(api => { return res.json() } - return unwant }) diff --git a/src/bitswap/wantlist-for-peer.js b/src/bitswap/wantlist-for-peer.js index 7d0599a38..b777ee7d6 100644 --- a/src/bitswap/wantlist-for-peer.js +++ b/src/bitswap/wantlist-for-peer.js @@ -5,11 +5,7 @@ const configure = require('../lib/configure') const toUrlSearchParams = require('../lib/to-url-search-params') module.exports = configure(api => { - // eslint-disable-next-line valid-jsdoc - /** - * @type {import('../../../ipfs/src/core/components/bitswap/wantlist-for-peer').WantlistForPeer} - */ - async function wantlistForPeer (peerId, options = {}) { + return async (peerId, options = {}) => { peerId = typeof peerId === 'string' ? peerId : new CID(peerId).toString() const res = await (await api.post('bitswap/wantlist', { @@ -24,5 +20,4 @@ module.exports = configure(api => { return (res.Keys || []).map(k => new CID(k['/'])) } - return wantlistForPeer }) diff --git a/src/bitswap/wantlist.js b/src/bitswap/wantlist.js index 96f33cad9..2599c7ed7 100644 --- a/src/bitswap/wantlist.js +++ b/src/bitswap/wantlist.js @@ -5,11 +5,7 @@ const configure = require('../lib/configure') const toUrlSearchParams = require('../lib/to-url-search-params') module.exports = configure(api => { - // eslint-disable-next-line valid-jsdoc - /** - * @type {import('../../../ipfs/src/core/components/bitswap/wantlist').WantlistFn} - */ - async function wantlist (options = {}) { + return async (options = {}) => { const res = await (await api.post('bitswap/wantlist', { timeout: options.timeout, signal: options.signal, @@ -19,5 +15,4 @@ module.exports = configure(api => { return (res.Keys || []).map(k => new CID(k['/'])) } - return wantlist }) diff --git a/src/block/get.js b/src/block/get.js index 18a1fdf3a..f39aa6d96 100644 --- a/src/block/get.js +++ b/src/block/get.js @@ -6,11 +6,7 @@ const configure = require('../lib/configure') const toUrlSearchParams = require('../lib/to-url-search-params') module.exports = configure(api => { - // eslint-disable-next-line valid-jsdoc - /** - * @type {import('../../../ipfs/src/core/components/block/get').BlockGet} - */ - async function get (cid, options = {}) { + return async (cid, options = {}) => { cid = new CID(cid) const res = await api.post('block/get', { @@ -25,5 +21,4 @@ module.exports = configure(api => { return new Block(new Uint8Array(await res.arrayBuffer()), cid) } - return get }) diff --git a/src/block/put.js b/src/block/put.js index 5d3f62803..09888a815 100644 --- a/src/block/put.js +++ b/src/block/put.js @@ -7,13 +7,9 @@ const multipartRequest = require('../lib/multipart-request') const configure = require('../lib/configure') const toUrlSearchParams = require('../lib/to-url-search-params') const anySignal = require('any-signal') -const { AbortController } = require('abort-controller') +const AbortController = require('abort-controller') module.exports = configure(api => { - // eslint-disable-next-line valid-jsdoc - /** - * @type {import('../../../ipfs/src/core/components/block/put').BlockPut} - */ async function put (data, options = {}) { if (Block.isBlock(data)) { const { name, length } = multihash.decode(data.cid.multihash) diff --git a/src/config/replace.js b/src/config/replace.js index 33df9ed5a..63ced0e20 100644 --- a/src/config/replace.js +++ b/src/config/replace.js @@ -5,7 +5,7 @@ const multipartRequest = require('../lib/multipart-request') const configure = require('../lib/configure') const toUrlSearchParams = require('../lib/to-url-search-params') const anySignal = require('any-signal') -const { AbortController } = require('abort-controller') +const AbortController = require('abort-controller') module.exports = configure(api => { return async (config, options = {}) => { diff --git a/src/dag/put.js b/src/dag/put.js index d0a395b43..e4f261c63 100644 --- a/src/dag/put.js +++ b/src/dag/put.js @@ -9,7 +9,7 @@ const configure = require('../lib/configure') const multipartRequest = require('../lib/multipart-request') const toUrlSearchParams = require('../lib/to-url-search-params') const anySignal = require('any-signal') -const { AbortController } = require('abort-controller') +const AbortController = require('abort-controller') const multicodec = require('multicodec') module.exports = configure((api, opts) => { diff --git a/src/files/write.js b/src/files/write.js index 0fcbbec80..c3e72c9bb 100644 --- a/src/files/write.js +++ b/src/files/write.js @@ -6,7 +6,7 @@ const configure = require('../lib/configure') const multipartRequest = require('../lib/multipart-request') const toUrlSearchParams = require('../lib/to-url-search-params') const anySignal = require('any-signal') -const { AbortController } = require('abort-controller') +const AbortController = require('abort-controller') module.exports = configure(api => { return async (path, input, options = {}) => { diff --git a/src/id.js b/src/id.js index a4e86eb02..e86846076 100644 --- a/src/id.js +++ b/src/id.js @@ -6,11 +6,7 @@ const configure = require('./lib/configure') const toUrlSearchParams = require('./lib/to-url-search-params') module.exports = configure(api => { - // eslint-disable-next-line valid-jsdoc - /** - * @type {import('../../ipfs/src/core/components/id').Id} - */ - async function id (options = {}) { + return async (options = {}) => { const res = await api.post('id', { timeout: options.timeout, signal: options.signal, @@ -27,5 +23,4 @@ module.exports = configure(api => { return output } - return id }) diff --git a/src/index.js b/src/index.js index acd27d14f..3d0eeeedd 100644 --- a/src/index.js +++ b/src/index.js @@ -14,17 +14,9 @@ const urlSource = require('ipfs-utils/src/files/url-source') */ /** - * @typedef {object} HttpOptions - * @property {Headers | Record} [headers] - An object or [Headers](https://developer.mozilla.org/en-US/docs/Web/API/Headers) instance that can be used to set custom HTTP headers. Note that this option can also be [configured globally](#custom-headers) via the constructor options. - * @property {URLSearchParams | Record} [searchParams] - An object or [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) instance that can be used to add additional query parameters to the query string sent with each request. - * @property {object} [ipld] - * @property {any[]} [ipld.formats] - An array of additional [IPLD formats](https://github.com/ipld/interface-ipld-format) to support - * @property {(format: string) => Promise} [ipld.loadFormat] - an async function that takes the name of an [IPLD format](https://github.com/ipld/interface-ipld-format) as a string and should return the implementation of that codec - */ - -// eslint-disable-next-line valid-jsdoc -/** - * @param {ClientOptions} options + * + * @param {ClientOptions } options + * @return {Object} */ function ipfsClient (options = {}) { return { diff --git a/src/lib/configure.js b/src/lib/configure.js index 6396c05d1..49b2d2f5a 100644 --- a/src/lib/configure.js +++ b/src/lib/configure.js @@ -9,19 +9,8 @@ const Client = require('./core') */ /** - * @template T - * @typedef {(client: Client, clientOptions: ClientOptions) => T} Fn - */ - -/** - * @template T - * @typedef {(clientOptions: ClientOptions) => T} Factory - */ - -/** - * @template T - * @param {Fn} fn - * @returns {Factory} + * @param {function(Client, ClientOptions): void} fn + * @returns {function(ClientOptions): void} */ const configure = (fn) => { return (options) => { diff --git a/src/lib/to-url-search-params.js b/src/lib/to-url-search-params.js index 10f12d83d..1e0bbeb4b 100644 --- a/src/lib/to-url-search-params.js +++ b/src/lib/to-url-search-params.js @@ -3,10 +3,6 @@ const modeToString = require('./mode-to-string') const mtimeToObject = require('./mtime-to-object') -/** - * @param {object} params - * @returns {URLSearchParams} - */ module.exports = ({ arg, searchParams, hashAlg, mtime, mode, ...options } = {}) => { if (searchParams) { options = { diff --git a/src/object/patch/append-data.js b/src/object/patch/append-data.js index bb27ea8fc..c33490750 100644 --- a/src/object/patch/append-data.js +++ b/src/object/patch/append-data.js @@ -5,7 +5,7 @@ const multipartRequest = require('../../lib/multipart-request') const configure = require('../../lib/configure') const toUrlSearchParams = require('../../lib/to-url-search-params') const anySignal = require('any-signal') -const { AbortController } = require('abort-controller') +const AbortController = require('abort-controller') module.exports = configure(api => { return async (cid, data, options = {}) => { diff --git a/src/object/patch/set-data.js b/src/object/patch/set-data.js index a2aa4180f..59c3394b5 100644 --- a/src/object/patch/set-data.js +++ b/src/object/patch/set-data.js @@ -5,7 +5,7 @@ const multipartRequest = require('../../lib/multipart-request') const configure = require('../../lib/configure') const toUrlSearchParams = require('../../lib/to-url-search-params') const anySignal = require('any-signal') -const { AbortController } = require('abort-controller') +const AbortController = require('abort-controller') module.exports = configure(api => { return async (cid, data, options = {}) => { diff --git a/src/object/put.js b/src/object/put.js index f5aa827cd..c9e46898a 100644 --- a/src/object/put.js +++ b/src/object/put.js @@ -6,7 +6,7 @@ const multipartRequest = require('../lib/multipart-request') const configure = require('../lib/configure') const toUrlSearchParams = require('../lib/to-url-search-params') const anySignal = require('any-signal') -const { AbortController } = require('abort-controller') +const AbortController = require('abort-controller') const unit8ArrayToString = require('uint8arrays/to-string') const uint8ArrayFromString = require('uint8arrays/from-string') diff --git a/src/pubsub/publish.js b/src/pubsub/publish.js index 9ec83bc69..0b24f4fc2 100644 --- a/src/pubsub/publish.js +++ b/src/pubsub/publish.js @@ -4,7 +4,7 @@ const configure = require('../lib/configure') const toUrlSearchParams = require('../lib/to-url-search-params') const multipartRequest = require('../lib/multipart-request') const anySignal = require('any-signal') -const { AbortController } = require('abort-controller') +const AbortController = require('abort-controller') module.exports = configure(api => { return async (topic, data, options = {}) => { diff --git a/src/pubsub/subscription-tracker.js b/src/pubsub/subscription-tracker.js index d5640bdd1..191f832ce 100644 --- a/src/pubsub/subscription-tracker.js +++ b/src/pubsub/subscription-tracker.js @@ -1,6 +1,6 @@ 'use strict' -const { AbortController } = require('abort-controller') +const AbortController = require('abort-controller') class SubscriptionTracker { constructor () { diff --git a/src/resolve.js b/src/resolve.js index 1dbac9256..a7635dad1 100644 --- a/src/resolve.js +++ b/src/resolve.js @@ -4,11 +4,7 @@ const configure = require('./lib/configure') const toUrlSearchParams = require('./lib/to-url-search-params') module.exports = configure(api => { - // eslint-disable-next-line valid-jsdoc - /** - * @type {import('../../ipfs/src/core/components/resolve').Resolve} - */ - async function resolve (path, options = {}) { + return async (path, options = {}) => { const res = await api.post('resolve', { timeout: options.timeout, signal: options.signal, @@ -21,5 +17,4 @@ module.exports = configure(api => { const { Path } = await res.json() return Path } - return resolve }) diff --git a/src/version.js b/src/version.js index 67d1ab314..28c49101b 100644 --- a/src/version.js +++ b/src/version.js @@ -5,11 +5,7 @@ const configure = require('./lib/configure') const toUrlSearchParams = require('./lib/to-url-search-params') module.exports = configure(api => { - // eslint-disable-next-line valid-jsdoc - /** - * @type {import('../../ipfs/src/core/components/version').Version} - */ - async function version (options = {}) { + return async (options = {}) => { const res = await api.post('version', { timeout: options.timeout, signal: options.signal, @@ -20,5 +16,4 @@ module.exports = configure(api => { return toCamel(data) } - return version })