Comparing version 0.0.14 to 0.0.15-test
@@ -11,3 +11,3 @@ { | ||
}, | ||
"version": "0.0.14", | ||
"version": "0.0.15-test", | ||
"scripts": { | ||
@@ -24,6 +24,6 @@ "lint": "tslint --project ./tsconfig.json", | ||
"dependencies": { | ||
"url-transformers": "^0.0.9" | ||
"url-transformers": "^0.0.10" | ||
}, | ||
"devDependencies": { | ||
"prettier": "^1.15.3", | ||
"prettier": "^2.4.1", | ||
"rollup": "^2.7.2", | ||
@@ -36,4 +36,4 @@ "rollup-plugin-auto-external": "^2.0.0", | ||
"tslint-no-unused": "^0.2.0-alpha.1", | ||
"typescript": "^3.2.2" | ||
"typescript": "^4.4.4" | ||
} | ||
} |
@@ -7,2 +7,23 @@ 'use strict'; | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */ | ||
function __spreadArray(to, from) { | ||
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) | ||
to[j] = from[i]; | ||
return to; | ||
} | ||
var tuple = function () { | ||
@@ -25,5 +46,5 @@ var args = []; | ||
// `Object.assign` is poorly typed: it returns `any` when spreading. Use cast to workaround. | ||
return Object.assign.apply(Object, [{}].concat(arr.map(function (_a) { | ||
return Object.assign.apply(Object, __spreadArray([{}], arr.map(function (_a) { | ||
var _b; | ||
var k = _a[0], v = _a[1]; | ||
var _b; | ||
return (_b = {}, _b[k] = v, _b); | ||
@@ -40,2 +61,42 @@ }))); | ||
function flow(ab, bc, cd, de, ef, fg, gh, hi, ij) { | ||
switch (arguments.length) { | ||
case 1: | ||
return ab; | ||
case 2: | ||
return function () { | ||
return bc(ab.apply(this, arguments)); | ||
}; | ||
case 3: | ||
return function () { | ||
return cd(bc(ab.apply(this, arguments))); | ||
}; | ||
case 4: | ||
return function () { | ||
return de(cd(bc(ab.apply(this, arguments)))); | ||
}; | ||
case 5: | ||
return function () { | ||
return ef(de(cd(bc(ab.apply(this, arguments))))); | ||
}; | ||
case 6: | ||
return function () { | ||
return fg(ef(de(cd(bc(ab.apply(this, arguments)))))); | ||
}; | ||
case 7: | ||
return function () { | ||
return gh(fg(ef(de(cd(bc(ab.apply(this, arguments))))))); | ||
}; | ||
case 8: | ||
return function () { | ||
return hi(gh(fg(ef(de(cd(bc(ab.apply(this, arguments)))))))); | ||
}; | ||
case 9: | ||
return function () { | ||
return ij(hi(gh(fg(ef(de(cd(bc(ab.apply(this, arguments))))))))); | ||
}; | ||
} | ||
return; | ||
} | ||
var isMaybeDefined = function (maybeT) { return maybeT !== undefined; }; | ||
@@ -55,18 +116,4 @@ /** Takes a dictionary containing `Maybe`s and returns a dictionary of all the non-empty values. */ | ||
function pipe() { | ||
var fns = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
fns[_i] = arguments[_i]; | ||
} | ||
var len = fns.length - 1; | ||
// tslint:disable-next-line no-any | ||
return function (x) { | ||
var y = x; | ||
for (var i = 0; i <= len; i++) { | ||
y = fns[i].call(this, y); | ||
} | ||
return y; | ||
}; | ||
} | ||
// https://docs.imgix.com/apis/url/size/fit | ||
exports.ImgixFit = void 0; | ||
(function (ImgixFit) { | ||
@@ -83,2 +130,4 @@ ImgixFit["clamp"] = "clamp"; | ||
})(exports.ImgixFit || (exports.ImgixFit = {})); | ||
// https://docs.imgix.com/apis/url/format/cs | ||
exports.ImgixColorSpace = void 0; | ||
(function (ImgixColorSpace) { | ||
@@ -93,3 +142,3 @@ ImgixColorSpace["srgb"] = "srgb"; | ||
}; | ||
var pickTrueObjectKeys = pipe(pickTrueInObject, | ||
var pickTrueObjectKeys = flow(pickTrueInObject, | ||
// tslint:disable-next-line no-unbound-method | ||
@@ -99,6 +148,6 @@ Object.keys); | ||
var joinWithComma = function (strs) { return strs.join(','); }; | ||
var serializeImgixUrlQueryParamListValue = pipe(pickTrueObjectKeys, joinWithComma, undefinedIfEmptyString); | ||
var serializeImgixUrlQueryParamListValue = flow(pickTrueObjectKeys, joinWithComma, undefinedIfEmptyString); | ||
var mapToSerializedListValueIfDefined = mapValueIfDefined(serializeImgixUrlQueryParamListValue); | ||
var serializeImgixUrlQueryParamValues = function (query) { | ||
return pipe(function () { return ({ | ||
var imgixUrlQueryParams = { | ||
ar: mapValueIfDefined(function (ar) { return ar.w + ":" + ar.h; })(query.ar), | ||
@@ -120,6 +169,27 @@ dpr: query.dpr, | ||
'min-h': query.minH, | ||
}); }, catMaybesDictionary)({}); | ||
'mark-w': query.markW, | ||
'mark-align': query.markAlign, | ||
'mark-pad': query.markPad, | ||
markY: query.markY, | ||
mark64: query.mark64, | ||
blend64: query.blend64, | ||
txt64: query.txt64, | ||
'txt-color': query.txtColor, | ||
'txt-size': query.txtSize, | ||
'txt-align': query.txtAlign, | ||
fm: query.fm, | ||
'txt-font': query.txtFont, | ||
'blend-mode': query.blendMode, | ||
'blend-alpha': query.blendAlpha, | ||
'blend-pad': query.blendPad, | ||
blendW: query.blendW, | ||
mask: query.mask, | ||
'blend-align': query.blendAlign, | ||
blendX: query.blendX, | ||
markX: query.markX, | ||
}; | ||
return catMaybesDictionary(imgixUrlQueryParams); | ||
}; | ||
var buildImgixUrl = function (url) { | ||
return pipe(serializeImgixUrlQueryParamValues, function (query) { return urlTransformers.addQueryToUrl(query)(url); }); | ||
return flow(serializeImgixUrlQueryParamValues, function (query) { return urlTransformers.addQueryToUrl(query)(url); }); | ||
}; | ||
@@ -126,0 +196,0 @@ |
@@ -1,2 +0,1 @@ | ||
declare type Omit<T, K extends keyof any> = Pick<T, Exclude<keyof T, K>>; | ||
export declare enum ImgixFit { | ||
@@ -32,2 +31,4 @@ clamp = "clamp", | ||
}; | ||
export declare type ImgixMarkAlignBase = 'top' | 'middle' | 'bottom' | 'left' | 'center' | 'right'; | ||
export declare type ImgixMarkAlign = `${ImgixMarkAlignBase},${ImgixMarkAlignBase}` | ImgixMarkAlignBase; | ||
export declare type ImgixUrlQueryParams = { | ||
@@ -50,7 +51,28 @@ ar?: ImgixAspectRatio; | ||
'min-h'?: number; | ||
'mark-w'?: number; | ||
'mark-align'?: ImgixMarkAlign; | ||
'mark-pad'?: number; | ||
markY?: number; | ||
mark64?: string; | ||
markX?: number; | ||
blend64?: string; | ||
txt64?: string; | ||
'txt-color'?: string; | ||
'txt-size'?: number; | ||
'txt-align'?: ImgixMarkAlign; | ||
fm?: string; | ||
'txt-font'?: string; | ||
'blend-align'?: ImgixMarkAlign; | ||
'blend-mode'?: string; | ||
'blend-pad'?: number; | ||
'blend-alpha'?: number; | ||
mask?: string; | ||
blendW?: number; | ||
blendX?: number; | ||
}; | ||
export declare type QueryParamsInput = Omit<ImgixUrlQueryParams, 'min-h'> & { | ||
minH?: number; | ||
declare type KebabToCamelCase<S extends string> = S extends `${infer T}-${infer U}` ? `${T}${Capitalize<KebabToCamelCase<U>>}` : S; | ||
export declare type QueryParamsInput = { | ||
[K in keyof ImgixUrlQueryParams as KebabToCamelCase<K>]: ImgixUrlQueryParams[K]; | ||
}; | ||
export declare const buildImgixUrl: (url: string) => (a: QueryParamsInput) => string; | ||
export declare const buildImgixUrl: (url: string) => (query: QueryParamsInput) => string; | ||
export {}; |
import { addQueryToUrl } from 'url-transformers'; | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */ | ||
function __spreadArray(to, from) { | ||
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) | ||
to[j] = from[i]; | ||
return to; | ||
} | ||
var tuple = function () { | ||
@@ -20,5 +41,5 @@ var args = []; | ||
// `Object.assign` is poorly typed: it returns `any` when spreading. Use cast to workaround. | ||
return Object.assign.apply(Object, [{}].concat(arr.map(function (_a) { | ||
return Object.assign.apply(Object, __spreadArray([{}], arr.map(function (_a) { | ||
var _b; | ||
var k = _a[0], v = _a[1]; | ||
var _b; | ||
return (_b = {}, _b[k] = v, _b); | ||
@@ -35,2 +56,42 @@ }))); | ||
function flow(ab, bc, cd, de, ef, fg, gh, hi, ij) { | ||
switch (arguments.length) { | ||
case 1: | ||
return ab; | ||
case 2: | ||
return function () { | ||
return bc(ab.apply(this, arguments)); | ||
}; | ||
case 3: | ||
return function () { | ||
return cd(bc(ab.apply(this, arguments))); | ||
}; | ||
case 4: | ||
return function () { | ||
return de(cd(bc(ab.apply(this, arguments)))); | ||
}; | ||
case 5: | ||
return function () { | ||
return ef(de(cd(bc(ab.apply(this, arguments))))); | ||
}; | ||
case 6: | ||
return function () { | ||
return fg(ef(de(cd(bc(ab.apply(this, arguments)))))); | ||
}; | ||
case 7: | ||
return function () { | ||
return gh(fg(ef(de(cd(bc(ab.apply(this, arguments))))))); | ||
}; | ||
case 8: | ||
return function () { | ||
return hi(gh(fg(ef(de(cd(bc(ab.apply(this, arguments)))))))); | ||
}; | ||
case 9: | ||
return function () { | ||
return ij(hi(gh(fg(ef(de(cd(bc(ab.apply(this, arguments))))))))); | ||
}; | ||
} | ||
return; | ||
} | ||
var isMaybeDefined = function (maybeT) { return maybeT !== undefined; }; | ||
@@ -50,18 +111,2 @@ /** Takes a dictionary containing `Maybe`s and returns a dictionary of all the non-empty values. */ | ||
function pipe() { | ||
var fns = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
fns[_i] = arguments[_i]; | ||
} | ||
var len = fns.length - 1; | ||
// tslint:disable-next-line no-any | ||
return function (x) { | ||
var y = x; | ||
for (var i = 0; i <= len; i++) { | ||
y = fns[i].call(this, y); | ||
} | ||
return y; | ||
}; | ||
} | ||
// https://docs.imgix.com/apis/url/size/fit | ||
@@ -91,3 +136,3 @@ var ImgixFit; | ||
}; | ||
var pickTrueObjectKeys = pipe(pickTrueInObject, | ||
var pickTrueObjectKeys = flow(pickTrueInObject, | ||
// tslint:disable-next-line no-unbound-method | ||
@@ -97,6 +142,6 @@ Object.keys); | ||
var joinWithComma = function (strs) { return strs.join(','); }; | ||
var serializeImgixUrlQueryParamListValue = pipe(pickTrueObjectKeys, joinWithComma, undefinedIfEmptyString); | ||
var serializeImgixUrlQueryParamListValue = flow(pickTrueObjectKeys, joinWithComma, undefinedIfEmptyString); | ||
var mapToSerializedListValueIfDefined = mapValueIfDefined(serializeImgixUrlQueryParamListValue); | ||
var serializeImgixUrlQueryParamValues = function (query) { | ||
return pipe(function () { return ({ | ||
var imgixUrlQueryParams = { | ||
ar: mapValueIfDefined(function (ar) { return ar.w + ":" + ar.h; })(query.ar), | ||
@@ -118,6 +163,27 @@ dpr: query.dpr, | ||
'min-h': query.minH, | ||
}); }, catMaybesDictionary)({}); | ||
'mark-w': query.markW, | ||
'mark-align': query.markAlign, | ||
'mark-pad': query.markPad, | ||
markY: query.markY, | ||
mark64: query.mark64, | ||
blend64: query.blend64, | ||
txt64: query.txt64, | ||
'txt-color': query.txtColor, | ||
'txt-size': query.txtSize, | ||
'txt-align': query.txtAlign, | ||
fm: query.fm, | ||
'txt-font': query.txtFont, | ||
'blend-mode': query.blendMode, | ||
'blend-alpha': query.blendAlpha, | ||
'blend-pad': query.blendPad, | ||
blendW: query.blendW, | ||
mask: query.mask, | ||
'blend-align': query.blendAlign, | ||
blendX: query.blendX, | ||
markX: query.markX, | ||
}; | ||
return catMaybesDictionary(imgixUrlQueryParams); | ||
}; | ||
var buildImgixUrl = function (url) { | ||
return pipe(serializeImgixUrlQueryParamValues, function (query) { return addQueryToUrl(query)(url); }); | ||
return flow(serializeImgixUrlQueryParamValues, function (query) { return addQueryToUrl(query)(url); }); | ||
}; | ||
@@ -124,0 +190,0 @@ |
@@ -6,2 +6,43 @@ 'use strict'; | ||
function _interopNamespace(e) { | ||
if (e && e.__esModule) return e; | ||
var n = Object.create(null); | ||
if (e) { | ||
Object.keys(e).forEach(function (k) { | ||
if (k !== 'default') { | ||
var d = Object.getOwnPropertyDescriptor(e, k); | ||
Object.defineProperty(n, k, d.get ? d : { | ||
enumerable: true, | ||
get: function () { return e[k]; } | ||
}); | ||
} | ||
}); | ||
} | ||
n["default"] = e; | ||
return Object.freeze(n); | ||
} | ||
var assert__namespace = /*#__PURE__*/_interopNamespace(assert); | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */ | ||
function __spreadArray(to, from) { | ||
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) | ||
to[j] = from[i]; | ||
return to; | ||
} | ||
var tuple = function () { | ||
@@ -24,5 +65,5 @@ var args = []; | ||
// `Object.assign` is poorly typed: it returns `any` when spreading. Use cast to workaround. | ||
return Object.assign.apply(Object, [{}].concat(arr.map(function (_a) { | ||
return Object.assign.apply(Object, __spreadArray([{}], arr.map(function (_a) { | ||
var _b; | ||
var k = _a[0], v = _a[1]; | ||
var _b; | ||
return (_b = {}, _b[k] = v, _b); | ||
@@ -39,2 +80,42 @@ }))); | ||
function flow(ab, bc, cd, de, ef, fg, gh, hi, ij) { | ||
switch (arguments.length) { | ||
case 1: | ||
return ab; | ||
case 2: | ||
return function () { | ||
return bc(ab.apply(this, arguments)); | ||
}; | ||
case 3: | ||
return function () { | ||
return cd(bc(ab.apply(this, arguments))); | ||
}; | ||
case 4: | ||
return function () { | ||
return de(cd(bc(ab.apply(this, arguments)))); | ||
}; | ||
case 5: | ||
return function () { | ||
return ef(de(cd(bc(ab.apply(this, arguments))))); | ||
}; | ||
case 6: | ||
return function () { | ||
return fg(ef(de(cd(bc(ab.apply(this, arguments)))))); | ||
}; | ||
case 7: | ||
return function () { | ||
return gh(fg(ef(de(cd(bc(ab.apply(this, arguments))))))); | ||
}; | ||
case 8: | ||
return function () { | ||
return hi(gh(fg(ef(de(cd(bc(ab.apply(this, arguments)))))))); | ||
}; | ||
case 9: | ||
return function () { | ||
return ij(hi(gh(fg(ef(de(cd(bc(ab.apply(this, arguments))))))))); | ||
}; | ||
} | ||
return; | ||
} | ||
var isMaybeDefined = function (maybeT) { return maybeT !== undefined; }; | ||
@@ -54,18 +135,2 @@ /** Takes a dictionary containing `Maybe`s and returns a dictionary of all the non-empty values. */ | ||
function pipe() { | ||
var fns = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
fns[_i] = arguments[_i]; | ||
} | ||
var len = fns.length - 1; | ||
// tslint:disable-next-line no-any | ||
return function (x) { | ||
var y = x; | ||
for (var i = 0; i <= len; i++) { | ||
y = fns[i].call(this, y); | ||
} | ||
return y; | ||
}; | ||
} | ||
// https://docs.imgix.com/apis/url/size/fit | ||
@@ -95,3 +160,3 @@ var ImgixFit; | ||
}; | ||
var pickTrueObjectKeys = pipe(pickTrueInObject, | ||
var pickTrueObjectKeys = flow(pickTrueInObject, | ||
// tslint:disable-next-line no-unbound-method | ||
@@ -101,6 +166,6 @@ Object.keys); | ||
var joinWithComma = function (strs) { return strs.join(','); }; | ||
var serializeImgixUrlQueryParamListValue = pipe(pickTrueObjectKeys, joinWithComma, undefinedIfEmptyString); | ||
var serializeImgixUrlQueryParamListValue = flow(pickTrueObjectKeys, joinWithComma, undefinedIfEmptyString); | ||
var mapToSerializedListValueIfDefined = mapValueIfDefined(serializeImgixUrlQueryParamListValue); | ||
var serializeImgixUrlQueryParamValues = function (query) { | ||
return pipe(function () { return ({ | ||
var imgixUrlQueryParams = { | ||
ar: mapValueIfDefined(function (ar) { return ar.w + ":" + ar.h; })(query.ar), | ||
@@ -122,9 +187,30 @@ dpr: query.dpr, | ||
'min-h': query.minH, | ||
}); }, catMaybesDictionary)({}); | ||
'mark-w': query.markW, | ||
'mark-align': query.markAlign, | ||
'mark-pad': query.markPad, | ||
markY: query.markY, | ||
mark64: query.mark64, | ||
blend64: query.blend64, | ||
txt64: query.txt64, | ||
'txt-color': query.txtColor, | ||
'txt-size': query.txtSize, | ||
'txt-align': query.txtAlign, | ||
fm: query.fm, | ||
'txt-font': query.txtFont, | ||
'blend-mode': query.blendMode, | ||
'blend-alpha': query.blendAlpha, | ||
'blend-pad': query.blendPad, | ||
blendW: query.blendW, | ||
mask: query.mask, | ||
'blend-align': query.blendAlign, | ||
blendX: query.blendX, | ||
markX: query.markX, | ||
}; | ||
return catMaybesDictionary(imgixUrlQueryParams); | ||
}; | ||
var buildImgixUrl = function (url) { | ||
return pipe(serializeImgixUrlQueryParamValues, function (query) { return urlTransformers.addQueryToUrl(query)(url); }); | ||
return flow(serializeImgixUrlQueryParamValues, function (query) { return urlTransformers.addQueryToUrl(query)(url); }); | ||
}; | ||
assert.strictEqual(buildImgixUrl('https://foo.com')({ | ||
assert__namespace.strictEqual(buildImgixUrl('https://foo.com')({ | ||
auto: { | ||
@@ -131,0 +217,0 @@ format: true, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
62725
658
1
+ Added@types/node@14.18.63(transitive)
+ Addedfp-ts@2.16.9(transitive)
+ Addedmonocle-ts@2.3.13(transitive)
+ Addedurl-transformers@0.0.10(transitive)
- Removed@types/node@12.20.55(transitive)
- Removedpipe-ts@0.0.8(transitive)
- Removedurl-transformers@0.0.9(transitive)
Updatedurl-transformers@^0.0.10