Skip to content

Commit

Permalink
config json fix
Browse files Browse the repository at this point in the history
  • Loading branch information
houd1ni committed Dec 2, 2019
1 parent 106c4c4 commit d67da85
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 129 deletions.
21 changes: 12 additions & 9 deletions dist/bundle.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { Curry } from 'ts-toolbelt';
/// <reference types="node" />
/// <reference types="ramda" />

export interface AnyObject {
[key: string]: any;
}
export declare type AnyFunc = (...args: any[]) => any;
export declare type Credentials = 'omit' | 'same-origin' | 'include';
export interface Headers {
[name: string]: string | null;
Expand All @@ -19,12 +21,13 @@ export declare type InMiddleware = ({ query: Query, response: any }: {
}>;
export interface Config {
base: string;
json: true;
json: boolean;
headers: Headers;
timeout: number;
credentials: Credentials;
throwCodes: RegExp;
handleArrays: HandleArrays;
adapter: (url: string, conf: AnyObject) => Promise<AnyObject> | null;
middleware: {
in?: InMiddleware[];
out?: OutMiddleware[];
Expand Down Expand Up @@ -57,17 +60,17 @@ export interface FetchData {
}
export declare type AsyncFn = (...args: any[]) => Promise<any>;
/** Adds new headers to provided Query. */
export declare const addHeaders: import("ts-toolbelt/out/types/src/Function/Curry").Curry<(headers: Headers, query: Query) => Query>;
export declare const forEach: import("ts-toolbelt/out/types/src/Function/Curry").Curry<(fn: Function, items: any[]) => Promise<void>>;
export declare const forEachAsync: import("ts-toolbelt/out/types/src/Function/Curry").Curry<(fn: (item: any) => any, items: any[]) => Promise<any[]>>;
export declare const addHeaders: Curry.Curry<(headers: Headers, query: Query) => Query>;
export declare const forEach: Curry.Curry<(fn: AnyFunc, items: any[]) => Promise<void>>;
export declare const forEachAsync: Curry.Curry<(fn: (item: any) => any, items: any[]) => Promise<any[]>>;
export declare const waitAll: (promises: Promise<any>[]) => Promise<any[]>;
export declare const explore: (value: any) => any;
export declare const clearEmpty: <T = AnyObject>(o: T) => AnyObject;
export declare const bind: (obj: AnyObject, methodName: string) => import("ts-toolbelt/out/types/src/Function/Curry").Curry<any>;
export declare const mapKeys: import("ts-toolbelt/out/types/src/Function/Curry").Curry<(keyMap: {
export declare const bind: (obj: AnyObject, methodName: string) => Curry.Curry<any>;
export declare const mapKeys: Curry.Curry<(keyMap: {
[oldKey: string]: string;
}, o: AnyObject) => any>;
export declare const asyncpipe: (...fns: Function[]) => (data?: any) => Promise<any>;
export declare const asyncpipe: (...fns: AnyFunc[]) => (data?: any) => Promise<any>;
export declare class Fetch {
private config;
private middleware;
Expand All @@ -79,7 +82,7 @@ export declare class Fetch {
export declare class Cached<T = any> {
private cache;
private proceccing;
protected tryCacheWhen<P = T>(key: string, cacheIf: (res: any) => boolean, fetchFn: () => Promise<P>): Promise<P>;
protected tryCacheWhen<P = T>(key: string, cacheIf: (data: any) => boolean, fetchFn: () => Promise<P>): Promise<P>;
protected tryCache<P = T>(key: string, fetchFn: () => Promise<P>): Promise<P>;
protected dropCache(key?: string): void;
}
Expand Down
2 changes: 1 addition & 1 deletion dist/bundle.esm.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/bundle.js

Large diffs are not rendered by default.

112 changes: 11 additions & 101 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"prod:es": "cross-env NODE_ENV=production BUILD=es rollup -c",
"prod": "npm run gentypes && npm run prod:es && npm run prod:cjs"
},
"version": "0.2.6",
"version": "0.2.7",
"ava": {
"files": [
"./test/specs/*.ts"
Expand All @@ -58,11 +58,11 @@
"devDependencies": {
"@babel/preset-env": "^7.7.4",
"@types/node": "^12.12.14",
"@types/ramda": "^0.26.36",
"@types/ramda": "0.26.14",
"ava": "^2.4.0",
"codecov": "^3.6.1",
"cross-env": "^6.0.3",
"dts-bundle-generator": "^3.3.1",
"dts-bundle-generator": "3.1.0",
"nyc": "^14.1.1",
"rollup": "^1.27.8",
"rollup-plugin-commonjs": "^10.1.0",
Expand All @@ -72,7 +72,7 @@
"rollup-plugin-typescript": "^1.0.1",
"ts-node": "^8.5.4",
"tslint": "^5.20.1",
"typescript": "^3.7.2"
"typescript": "3.5.2"
},
"types": "./dist/bundle.d.ts",
"dependencies": {
Expand Down
3 changes: 1 addition & 2 deletions src/Fetch.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import mergeDeepRight from 'ramda/src/mergeDeepRight'
import type from 'ramda/src/type'
import { type, mergeDeepRight } from 'ramda'
import { formURI, addBase, hole } from './utils'
import { Query, Config, OutMiddleware, InMiddleware, FetchData } from './types'
import { addHeaders, asyncpipe } from './helpers'
Expand Down
10 changes: 5 additions & 5 deletions src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
fromPairs, toPairs, compose, map, filter, isNil,
tap, bind as rbind
} from 'ramda'
import { Query, Headers, AnyObject } from './types'
import { Query, Headers, AnyObject, AnyFunc } from './types'

/** Adds new headers to provided Query. */
export const addHeaders = curry((headers: Headers, query: Query): Query => {
Expand All @@ -15,14 +15,14 @@ export const addHeaders = curry((headers: Headers, query: Query): Query => {
})

export const forEach = (() => {
const pipe = async (fn: Function, items: any[], i: number) => {
const pipe = async (fn: AnyFunc, items: any[], i: number) => {
if(i<items.length) {
await fn(items[i])
await pipe(fn, items, ++i)
}
}
return curry(
(fn: Function, items: any[]) => pipe(fn, items, 0)
(fn: AnyFunc, items: any[]) => pipe(fn, items, 0)
)
})()

Expand Down Expand Up @@ -55,7 +55,7 @@ export const mapKeys = curry((
) as any)(o))

export const asyncpipe = (() => {
const pipe = async (fns: Function[], data: any, i: number): Promise<any> =>
const pipe = async (fns: AnyFunc[], data: any, i: number): Promise<any> =>
~i ? await pipe(fns, await fns[i](data), --i) : data
return (...fns: Function[]) => (data?: any) => pipe(fns, data, fns.length-1)
return (...fns: AnyFunc[]) => (data?: any) => pipe(fns, data, fns.length-1)
})()
2 changes: 0 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@



export * from './types'
export * from './helpers'
export { Fetch } from './Fetch'
Expand Down
5 changes: 3 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
export interface AnyObject {
[key: string]: any
}
export type AnyFunc = (...args: any[]) => any

export type Credentials = 'omit' | 'same-origin' | 'include'

Expand All @@ -18,13 +19,13 @@ export type InMiddleware = ({ query: Query, response: any }) =>

export interface Config {
base: string
json: true
json: boolean
headers: Headers
timeout: number
credentials: Credentials
throwCodes: RegExp
handleArrays: HandleArrays
adapter: (url: string, conf: AnyObject) => Promise<Response> | null
adapter: (url: string, conf: AnyObject) => Promise<AnyObject> | null
middleware: {
in?: InMiddleware[]
out?: OutMiddleware[]
Expand Down
3 changes: 1 addition & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

import { curry, type, join, replace } from 'ramda'
import { curry, type, join, replace, reduce, compose, append } from 'ramda'
import { Query, HandleArrays, AnyObject } from './types'
import { reduce, compose, append } from 'ramda'

export const trim = curry((symbols: string, str: string) => {
let found_first = null,
Expand Down

0 comments on commit d67da85

Please sign in to comment.