refactor: mv types.js index.js (and re-export request.js)

This commit is contained in:
AJ ONeal 2022-09-01 00:58:51 -06:00
parent 58b95342f5
commit f83b51bc41
Signed by: coolaj86
GPG Key ID: 585419CA6DB0AA23
3 changed files with 41 additions and 36 deletions

View File

@ -1,14 +1,14 @@
#!/bin/sh
my_typedefs="$(
grep typedef ./types.js | cut -d ' ' -f5
grep typedef ./index.js | cut -d ' ' -f5
)"
rm -f ./local-types.js
rm -f ./types.js
{
echo '/**'
for my_type in $my_typedefs; do
echo " * @typedef {import('./types.js').${my_type}} ${my_type}"
echo " * @typedef {import('./').${my_type}} ${my_type}"
done
echo ' */'
} >> ./local-types.js
} >> ./types.js

34
index.js Normal file
View File

@ -0,0 +1,34 @@
'use strict';
module.exports = require('./request.js');
/**
* @callback Request
* @param {RequestOptions} opts
* @returns {Response}
*/
/**
* @typedef {Object} RequestOptions
* @prop {any} [opts.body]
* @prop {Object.<String,any>} [opts.form]
* @prop {Headers} [opts.headers]
* @prop {String} [opts.method]
* @prop {Boolean | any} [opts.json]
* @prop {String} opts.url
*/
/**
* @typedef {Object} Response
* @prop {any} body
* @prop {Headers} headers
* @prop {Boolean} ok
* @prop {any} [response] - TODO (browser only)
* @prop {any} [request] - TODO
* @prop {String} status
* @prop {Number} statusCode
*/
/**
* @typedef {Object.<String,String|Array<String>>} Headers
*/

View File

@ -1,34 +1,5 @@
'use strict';
module.exports._typesOnly = true;
/**
* @callback Request
* @param {RequestOptions} opts
* @returns {Response}
*/
/**
* @typedef {Object} RequestOptions
* @prop {any} [opts.body]
* @prop {Object.<String,any>} [opts.form]
* @prop {Headers} [opts.headers]
* @prop {String} [opts.method]
* @prop {Boolean | any} [opts.json]
* @prop {String} opts.url
*/
/**
* @typedef {Object} Response
* @prop {any} body
* @prop {Headers} headers
* @prop {Boolean} ok
* @prop {any} [response] - TODO (browser only)
* @prop {any} [request] - TODO
* @prop {String} status
* @prop {Number} statusCode
*/
/**
* @typedef {Object.<String,String|Array<String>>} Headers
* @typedef {import('./').RequestOptions} RequestOptions
* @typedef {import('./').Response} Response
* @typedef {import('./').Headers} Headers
*/