Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Use pipe-ts #8

Draft
wants to merge 2 commits into
base: maintenance/upgrade-ts
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"target"
],
"dependencies": {
"pipe-ts": "^0.0.8",
"url-transformers": "^0.0.5"
},
"devDependencies": {
Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// tslint:disable-next-line match-default-export-name
import { pipe, pipeWith } from 'pipe-ts';
import { addQueryToUrl } from 'url-transformers';
import { pickBy } from './helpers';
import { catMaybesDictionary, mapValueIfDefined } from './helpers/maybe';
import { pipe } from './helpers/pipe';

// https://docs.imgix.com/apis/url/size/fit
export enum ImgixFit {
Expand Down Expand Up @@ -94,7 +94,7 @@ type ParsedUrlQueryInput = { [key: string]: unknown };
const serializeImgixUrlQueryParamValues = (query: ImgixUrlQueryParams): ParsedUrlQueryInput =>
pipe(
(): Record<keyof ImgixUrlQueryParams, string | number | undefined> => ({
ar: mapValueIfDefined((ar: ImgixAspectRatio) => `${ar.w}:${ar.h}`)(query.ar),
ar: pipeWith(query.ar, mapValueIfDefined(ar => `${ar.w}:${ar.h}`)),
dpr: query.dpr,
auto: mapToSerializedListValueIfDefined(query.auto),
fit: query.fit,
Expand All @@ -110,7 +110,7 @@ const serializeImgixUrlQueryParamValues = (query: ImgixUrlQueryParams): ParsedUr
facepad: query.facepad,
}),
catMaybesDictionary,
)({});
)();

export const buildImgixUrl = (url: string) =>
pipe(
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,11 @@ path-parse@^1.0.5:
resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c"
integrity sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==

pipe-ts@^0.0.8:
version "0.0.8"
resolved "https://registry.yarnpkg.com/pipe-ts/-/pipe-ts-0.0.8.tgz#ceea3f69549b09f0678d644cf2f849a2f6526568"
integrity sha512-8c8/ZwMJGwkL0aTW064KhH+xsKM5Zj0T3mfTq+O8re4lVnCyJ0o3BmY8QqO6DS3B6t5Uiluj7wM+btC+oTdKpg==

prettier@^1.15.3:
version "1.15.3"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.15.3.tgz#1feaac5bdd181237b54dbe65d874e02a1472786a"
Expand Down