Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove multiple default exports in modules #23

Closed
wants to merge 2 commits into from
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
18 changes: 1 addition & 17 deletions src/modules/autoc.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import type {
ModuleOptions,
ModuleOptionsWithValidateTrue,
ModuleOptionsWithValidateFalse,
ModuleThis,
} from '../lib/moduleCommon';

Expand Down Expand Up @@ -29,26 +27,12 @@ const queryOptionsDefaults = {
lang: 'en'
};

export default function autoc(
this: ModuleThis,
query: string,
queryOptionsOverrides?: AutocOptions,
moduleOptions?: ModuleOptionsWithValidateFalse
): Promise<any>;

export default function autoc(
this: ModuleThis,
query: string,
queryOptionsOverrides?: AutocOptions,
moduleOptions?: ModuleOptionsWithValidateTrue
): Promise<AutocResult>;

export default function autoc(
this: ModuleThis,
query: string,
queryOptionsOverrides?: AutocOptions,
moduleOptions?: ModuleOptions
): Promise<any> {
): Promise<AutocResult> {

return this._moduleExec({
moduleName: "autoc",
Expand Down
18 changes: 1 addition & 17 deletions src/modules/historical.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import type {
ModuleOptions,
ModuleOptionsWithValidateTrue,
ModuleOptionsWithValidateFalse,
ModuleThis,
} from '../lib/moduleCommon';

Expand Down Expand Up @@ -31,26 +29,12 @@ const queryOptionsDefaults: Omit<HistoricalOptions,'period1'> = {
includeAdjustedClose: true,
};

export default function historical(
this: ModuleThis,
symbol: string,
queryOptionsOverrides: HistoricalOptions,
moduleOptions?: ModuleOptionsWithValidateFalse
): Promise<any>;

export default function historical(
this: ModuleThis,
symbol: string,
queryOptionsOverrides: HistoricalOptions,
moduleOptions?: ModuleOptionsWithValidateTrue
): Promise<HistoricalResult>;

export default function historical(
this: ModuleThis,
symbol: string,
queryOptionsOverrides: HistoricalOptions,
moduleOptions?: ModuleOptions
): Promise<any> {
): Promise<HistoricalResult> {

return this._moduleExec({
moduleName: "historical",
Expand Down
25 changes: 1 addition & 24 deletions src/modules/quote.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import type {
ModuleOptions,
ModuleOptionsWithValidateTrue,
ModuleOptionsWithValidateFalse,
ModuleThis,
} from '../lib/moduleCommon';

Expand Down Expand Up @@ -114,33 +112,12 @@ export interface QuoteOptions {
const queryOptionsDefaults = {
};

export default function quote(
this: ModuleThis,
query: string | string[],
queryOptionsOverrides?: QuoteOptions,
moduleOptions?: ModuleOptionsWithValidateFalse
): Promise<any>;

export default function quote(
this: ModuleThis,
query: string[],
queryOptionsOverrides?: QuoteOptions,
moduleOptions?: ModuleOptionsWithValidateTrue
): Promise<QuoteResponse>;

export default function quote(
this: ModuleThis,
query: string,
queryOptionsOverrides?: QuoteOptions,
moduleOptions?: ModuleOptionsWithValidateTrue
): Promise<Quote>;

export default function quote(
this: ModuleThis,
query: string | string[],
queryOptionsOverrides?: QuoteOptions,
moduleOptions?: ModuleOptions
): Promise<any> {
): Promise<QuoteResponse> {
const symbols = typeof query === 'string' ? query : query.join(',');

return this._moduleExec({
Expand Down
16 changes: 0 additions & 16 deletions src/modules/quoteSummary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { QuoteSummaryResult } from './quoteSummary-iface';

import type {
ModuleOptions,
ModuleOptionsWithValidateTrue,
ModuleOptionsWithValidateFalse,
ModuleThis,
} from '../lib/moduleCommon';

Expand Down Expand Up @@ -91,20 +89,6 @@ const queryOptionsDefaults = {
modules: ['price', 'summaryDetail']
};

export default function quoteSummary(
this: ModuleThis,
symbol: string,
queryOptionsOverrides?: QuoteSummaryOptions,
moduleOptions?: ModuleOptionsWithValidateFalse
): Promise<any>;

export default function quoteSummary(
this: ModuleThis,
symbol: string,
queryOptionsOverrides?: QuoteSummaryOptions,
moduleOptions?: ModuleOptionsWithValidateTrue
): Promise<QuoteSummaryResult>;

export default function quoteSummary(
this: ModuleThis,
symbol: string,
Expand Down
28 changes: 27 additions & 1 deletion src/modules/search.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import search from './search';
const { InvalidOptionsError } = require('../lib/errors');

import _env from '../env-node';
import _fetch from '../lib/yahooFinanceFetch';
Expand Down Expand Up @@ -33,4 +32,31 @@ describe('search', () => {
});
});

it('successfully figure out symbol for Evolution Gaming Group', async () => {
const response = await yf.search('Apple', {}, { devel: 'search-Evolution Gaming Group.json'});

const onlyQuotesWithQuoteTypeEquity = response.quotes.filter(
(searchQuote) => {
if ('quoteType' in searchQuote && searchQuote.quoteType === 'EQUITY') {
return true;
} else {
return false;
}
},
);

let symbol;
if (
'quoteType' in onlyQuotesWithQuoteTypeEquity[0] &&
'symbol' in onlyQuotesWithQuoteTypeEquity[0]
) {
symbol = onlyQuotesWithQuoteTypeEquity[0].symbol;
} else {
throw new Error(`The quote we found din't have a symbol`);
}

expect(symbol).toBe('AAPL');

});

});
18 changes: 1 addition & 17 deletions src/modules/search.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import type {
ModuleOptions,
ModuleOptionsWithValidateTrue,
ModuleOptionsWithValidateFalse,
ModuleThis,
} from '../lib/moduleCommon';

Expand Down Expand Up @@ -88,26 +86,12 @@ const queryOptionsDefaults = {
enableEnhancedTrivialQuery: true
};

export default function search(
this: ModuleThis,
query: string,
queryOptionsOverrides?: SearchOptions,
moduleOptions?: ModuleOptionsWithValidateFalse,
): Promise<any>;

export default function search(
this: ModuleThis,
query: string,
queryOptionsOverrides?: SearchOptions,
moduleOptions?: ModuleOptionsWithValidateTrue,
): Promise<SearchResult>;

export default function search(
this: ModuleThis,
query: string,
queryOptionsOverrides?: SearchOptions,
moduleOptions?: ModuleOptions
): Promise<any> {
): Promise<SearchResult> {

return this._moduleExec({
moduleName: "search",
Expand Down