1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, '__esModule', { value: true });
|
4 |
|
5 | function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
6 |
|
7 | var functions = require('./functions-b6202a08.js');
|
8 | require('folktale/concurrency/task');
|
9 | var R = require('ramda');
|
10 | require('folktale/result');
|
11 | require('ramda-maybe');
|
12 | require('util');
|
13 | var throwingFunctions = require('./throwingFunctions.js');
|
14 | require('folktale/maybe');
|
15 | var monadHelpers = require('./monadHelpers-e0c6950d.js');
|
16 | var NamedTupleMap = _interopDefault(require('namedtuplemap'));
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 | var memoize = function memoize(fn) {
|
38 | var cache = new NamedTupleMap();
|
39 | var memoized = R.curry(function (normalArgs, flatArg) {
|
40 | if (!cache.has(flatArg)) {
|
41 | var result = R.apply(fn, normalArgs);
|
42 | cache.set(flatArg, result);
|
43 | return result;
|
44 | }
|
45 |
|
46 | return cache.get(flatArg);
|
47 | });
|
48 |
|
49 | if (fn.name) {
|
50 | memoized.displayName = fn.name + 'Memoized';
|
51 | }
|
52 |
|
53 | return memoized;
|
54 | };
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 | var memoized = function memoized(func) {
|
69 | return memoizedWith(function () {
|
70 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
71 | args[_key] = arguments[_key];
|
72 | }
|
73 |
|
74 | return args;
|
75 | }, func);
|
76 | };
|
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 |
|
92 |
|
93 | var memoizedWith = function memoizedWith(argumentFilter, func) {
|
94 |
|
95 | var memo = memoize(func);
|
96 |
|
97 | return R.curryN(func.length, function () {
|
98 | for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
99 | args[_key2] = arguments[_key2];
|
100 | }
|
101 |
|
102 |
|
103 | return R.compose(memo(args), functions.flattenObj,
|
104 | R.apply(argumentFilter))(args);
|
105 | });
|
106 | };
|
107 |
|
108 | var isObject = R.compose(R.equals('Object'), R.type);
|
109 | var allAreObjectsOrLists = R.compose(R.either(R.all(isObject), R.all(Array.isArray)), R.values);
|
110 |
|
111 | var hasVersion = function hasVersion(versionLabel) {
|
112 | return function (obj) {
|
113 | return R.has(versionLabel, obj);
|
114 | };
|
115 | };
|
116 |
|
117 | var hasBoth = function hasBoth(versionLabels) {
|
118 | return function (obj) {
|
119 | return R.all(function (versionLabel) {
|
120 | return hasVersion(versionLabel)(obj);
|
121 | }, versionLabels);
|
122 | };
|
123 | };
|
124 |
|
125 | var isEqual = function isEqual(versionLabels) {
|
126 | return function (obj) {
|
127 | return R.both(hasBoth(versionLabels), R.compose(R.apply(R.equals), R.values))(obj);
|
128 | };
|
129 | };
|
130 |
|
131 | var markAdded = function markAdded(obj) {
|
132 | return R.compose(R.append(undefined), R.values)(obj);
|
133 | };
|
134 |
|
135 |
|
136 | var markRemoved = function markRemoved(obj) {
|
137 | return R.compose(R.prepend(undefined), R.values)(obj);
|
138 | };
|
139 |
|
140 |
|
141 | var isAddition = function isAddition(versionLabels) {
|
142 | return function (obj) {
|
143 | return R.both(hasVersion(R.head(versionLabels)), R.complement(hasVersion(R.last(versionLabels))))(obj);
|
144 | };
|
145 | };
|
146 |
|
147 | var isRemoval = function isRemoval(versionLabels) {
|
148 | return function (obj) {
|
149 | return R.both(R.complement(hasVersion(R.head(versionLabels))), hasVersion(R.last(versionLabels)))(obj);
|
150 | };
|
151 | };
|
152 |
|
153 |
|
154 |
|
155 |
|
156 |
|
157 |
|
158 |
|
159 |
|
160 |
|
161 |
|
162 |
|
163 | var objectDiff = R.curry(function (versionLabels, l, r) {
|
164 | var labels = R.defaultTo(['__left', '__right'], versionLabels);
|
165 |
|
166 | var _labels = functions._slicedToArray(labels, 2),
|
167 | left = _labels[0],
|
168 | right = _labels[1];
|
169 |
|
170 | return R.compose(function (result) {
|
171 | return R.map(R.cond([[function (obj) {
|
172 | return isAddition(labels)(obj);
|
173 | }, function (obj) {
|
174 | return markAdded(obj);
|
175 | }], [function (obj) {
|
176 | return isRemoval(labels)(obj);
|
177 | }, function (obj) {
|
178 | return markRemoved(obj);
|
179 | }], [function (obj) {
|
180 | return hasBoth(labels)(obj);
|
181 | }, function (obj) {
|
182 | return R.when(allAreObjectsOrLists,
|
183 |
|
184 | function (o) {
|
185 | return R.compose(
|
186 | function (values) {
|
187 | return R.apply(objectDiff(versionLabels), values);
|
188 | }, R.values)(o);
|
189 | }
|
190 | )(obj);
|
191 | }]]), result);
|
192 | }, function (result) {
|
193 | return R.reject(function (obj) {
|
194 | return isEqual(labels)(obj);
|
195 | }, result);
|
196 | }, R.useWith(R.mergeWith(R.merge), [R.map(R.objOf(left)), R.map(R.objOf(right))]))(l, r);
|
197 | });
|
198 |
|
199 |
|
200 |
|
201 |
|
202 |
|
203 |
|
204 |
|
205 |
|
206 | var prettyPrintObjectDiff = function prettyPrintObjectDiff(versionLabels, l, r) {
|
207 | return R.compose(function (result) {
|
208 | return JSON.stringify(result, null, 2);
|
209 | }, objectDiff)(versionLabels, l, r);
|
210 | };
|
211 |
|
212 |
|
213 |
|
214 |
|
215 |
|
216 |
|
217 |
|
218 |
|
219 |
|
220 |
|
221 |
|
222 |
|
223 |
|
224 |
|
225 |
|
226 |
|
227 |
|
228 |
|
229 |
|
230 | var expectTask = function expectTask(task) {
|
231 | return expect(monadHelpers.taskToPromise(task));
|
232 | };
|
233 |
|
234 |
|
235 |
|
236 |
|
237 |
|
238 |
|
239 | var resultToPromise = function resultToPromise(result) {
|
240 | return new Promise(function (resolve, reject) {
|
241 | return result.map(resolve).mapError(reject);
|
242 | });
|
243 | };
|
244 |
|
245 |
|
246 |
|
247 |
|
248 |
|
249 |
|
250 |
|
251 | var expectKeys = R.curry(function (keyPaths, obj) {
|
252 | expect(R.compose(
|
253 | function (a) {
|
254 | return new Set(a);
|
255 | },
|
256 | function (o) {
|
257 | return R.filter(function (keyPath) {
|
258 | return R.complement(R.isNil)(R.view(R.lensPath(functions.keyStringToLensPath(keyPath)), o));
|
259 | }, keyPaths);
|
260 | })(obj)).toEqual(new Set(keyPaths));
|
261 |
|
262 | return true;
|
263 | });
|
264 |
|
265 |
|
266 |
|
267 |
|
268 |
|
269 |
|
270 |
|
271 |
|
272 | var expectKeysAtPath = R.curry(function (keyPaths, strPath, obj) {
|
273 | expect(R.compose(
|
274 | function (a) {
|
275 | return new Set(a);
|
276 | },
|
277 | function (o) {
|
278 | return R.filter(function (keyPath) {
|
279 | return R.complement(R.isNil)(R.view(R.lensPath(functions.keyStringToLensPath(keyPath)), throwingFunctions.reqStrPathThrowing(strPath, o)));
|
280 | }, keyPaths);
|
281 | })(obj)).toEqual(new Set(keyPaths));
|
282 |
|
283 | return true;
|
284 | });
|
285 |
|
286 | exports.alwaysFunc = functions.alwaysFunc;
|
287 | exports.applyDeep = functions.applyDeep;
|
288 | exports.applyDeepAndMapObjs = functions.applyDeepAndMapObjs;
|
289 | exports.camelCase = functions.camelCase;
|
290 | exports.capitalize = functions.capitalize;
|
291 | exports.chainObjToValues = functions.chainObjToValues;
|
292 | exports.compact = functions.compact;
|
293 | exports.compactEmpty = functions.compactEmpty;
|
294 | exports.compactJoin = functions.compactJoin;
|
295 | exports.duplicateKey = functions.duplicateKey;
|
296 | exports.emptyToNull = functions.emptyToNull;
|
297 | exports.eqStrPath = functions.eqStrPath;
|
298 | exports.eqStrPathsAll = functions.eqStrPathsAll;
|
299 | exports.filterObjToValues = functions.filterObjToValues;
|
300 | exports.filterWithKeys = functions.filterWithKeys;
|
301 | exports.findByParams = functions.findByParams;
|
302 | exports.findMapped = functions.findMapped;
|
303 | exports.findOne = functions.findOne;
|
304 | exports.findOneValueByParams = functions.findOneValueByParams;
|
305 | exports.flattenObj = functions.flattenObj;
|
306 | exports.flattenObjUntil = functions.flattenObjUntil;
|
307 | exports.fromPairsDeep = functions.fromPairsDeep;
|
308 | exports.hasStrPath = functions.hasStrPath;
|
309 | exports.idOrIdFromObj = functions.idOrIdFromObj;
|
310 | exports.isObject = functions.isObject;
|
311 | exports.keyStringToLensPath = functions.keyStringToLensPath;
|
312 | exports.lowercase = functions.lowercase;
|
313 | exports.mapDefault = functions.mapDefault;
|
314 | exports.mapDefaultAndPrefixOthers = functions.mapDefaultAndPrefixOthers;
|
315 | exports.mapKeys = functions.mapKeys;
|
316 | exports.mapKeysAndValues = functions.mapKeysAndValues;
|
317 | exports.mapKeysForLens = functions.mapKeysForLens;
|
318 | exports.mapObjToValues = functions.mapObjToValues;
|
319 | exports.mapProp = functions.mapProp;
|
320 | exports.mapPropValueAsIndex = functions.mapPropValueAsIndex;
|
321 | exports.mapToObjValue = functions.mapToObjValue;
|
322 | exports.mergeAllWithKey = functions.mergeAllWithKey;
|
323 | exports.mergeDeep = functions.mergeDeep;
|
324 | exports.mergeDeepAll = functions.mergeDeepAll;
|
325 | exports.mergeDeepWith = functions.mergeDeepWith;
|
326 | exports.mergeDeepWithConcatArrays = functions.mergeDeepWithConcatArrays;
|
327 | exports.mergeDeepWithRecurseArrayItems = functions.mergeDeepWithRecurseArrayItems;
|
328 | exports.mergeDeepWithRecurseArrayItemsAndMapObjs = functions.mergeDeepWithRecurseArrayItemsAndMapObjs;
|
329 | exports.mergeDeepWithRecurseArrayItemsByAndMergeObjectByRight = functions.mergeDeepWithRecurseArrayItemsByAndMergeObjectByRight;
|
330 | exports.mergeDeepWithRecurseArrayItemsByRight = functions.mergeDeepWithRecurseArrayItemsByRight;
|
331 | exports.moveToKeys = functions.moveToKeys;
|
332 | exports.omitDeep = functions.omitDeep;
|
333 | exports.omitDeepBy = functions.omitDeepBy;
|
334 | exports.omitDeepPaths = functions.omitDeepPaths;
|
335 | exports.onlyOne = functions.onlyOne;
|
336 | exports.onlyOneValue = functions.onlyOneValue;
|
337 | exports.orEmpty = functions.orEmpty;
|
338 | exports.overDeep = functions.overDeep;
|
339 | exports.pickDeepPaths = functions.pickDeepPaths;
|
340 | exports.removeDuplicateObjectsByProp = functions.removeDuplicateObjectsByProp;
|
341 | exports.renameKey = functions.renameKey;
|
342 | exports.replaceValuesAtDepth = functions.replaceValuesAtDepth;
|
343 | exports.replaceValuesAtDepthAndStringify = functions.replaceValuesAtDepthAndStringify;
|
344 | exports.replaceValuesWithCountAtDepth = functions.replaceValuesWithCountAtDepth;
|
345 | exports.replaceValuesWithCountAtDepthAndStringify = functions.replaceValuesWithCountAtDepthAndStringify;
|
346 | exports.reqPath = functions.reqPath;
|
347 | exports.reqPathPropEq = functions.reqPathPropEq;
|
348 | exports.reqStrPath = functions.reqStrPath;
|
349 | exports.splitAtInclusive = functions.splitAtInclusive;
|
350 | exports.strPath = functions.strPath;
|
351 | exports.strPathOr = functions.strPathOr;
|
352 | exports.strPathOrNullOk = functions.strPathOrNullOk;
|
353 | exports.toArrayIfNot = functions.toArrayIfNot;
|
354 | exports.transformKeys = functions.transformKeys;
|
355 | exports.unflattenObj = functions.unflattenObj;
|
356 | exports.unflattenObjNoArrays = functions.unflattenObjNoArrays;
|
357 | exports.findOneThrowing = throwingFunctions.findOneThrowing;
|
358 | exports.findOneValueByParamsThrowing = throwingFunctions.findOneValueByParamsThrowing;
|
359 | exports.mappedThrowIfResultError = throwingFunctions.mappedThrowIfResultError;
|
360 | exports.onlyOneThrowing = throwingFunctions.onlyOneThrowing;
|
361 | exports.onlyOneValueThrowing = throwingFunctions.onlyOneValueThrowing;
|
362 | exports.reqPathPropEqThrowing = throwingFunctions.reqPathPropEqThrowing;
|
363 | exports.reqPathThrowing = throwingFunctions.reqPathThrowing;
|
364 | exports.reqStrPathThrowing = throwingFunctions.reqStrPathThrowing;
|
365 | exports.throwIfResultError = throwingFunctions.throwIfResultError;
|
366 | exports.throwIfSingleResultError = throwingFunctions.throwIfSingleResultError;
|
367 | exports.chainExceptMapDeepestMDeep = monadHelpers.chainExceptMapDeepestMDeep;
|
368 | exports.chainMDeep = monadHelpers.chainMDeep;
|
369 | exports.composeWithChain = monadHelpers.composeWithChain;
|
370 | exports.composeWithChainMDeep = monadHelpers.composeWithChainMDeep;
|
371 | exports.composeWithMap = monadHelpers.composeWithMap;
|
372 | exports.composeWithMapExceptChainDeepestMDeep = monadHelpers.composeWithMapExceptChainDeepestMDeep;
|
373 | exports.composeWithMapMDeep = monadHelpers.composeWithMapMDeep;
|
374 | exports.defaultRunConfig = monadHelpers.defaultRunConfig;
|
375 | exports.defaultRunToResultConfig = monadHelpers.defaultRunToResultConfig;
|
376 | exports.doMDeep = monadHelpers.doMDeep;
|
377 | exports.doMDeepExceptDeepest = monadHelpers.doMDeepExceptDeepest;
|
378 | exports.lift1stOf2ForMDeepMonad = monadHelpers.lift1stOf2ForMDeepMonad;
|
379 | exports.mapExceptChainDeepestMDeep = monadHelpers.mapExceptChainDeepestMDeep;
|
380 | exports.mapMDeep = monadHelpers.mapMDeep;
|
381 | exports.mapMonadByConfig = monadHelpers.mapMonadByConfig;
|
382 | exports.mapOrObjToNamedResponseAndInputs = monadHelpers.mapOrObjToNamedResponseAndInputs;
|
383 | exports.mapResultMonadWithOtherInputs = monadHelpers.mapResultMonadWithOtherInputs;
|
384 | exports.mapResultTaskWithOtherInputs = monadHelpers.mapResultTaskWithOtherInputs;
|
385 | exports.mapToMergedResponseAndInputs = monadHelpers.mapToMergedResponseAndInputs;
|
386 | exports.mapToMergedResponseAndInputsMDeep = monadHelpers.mapToMergedResponseAndInputsMDeep;
|
387 | exports.mapToNamedPathAndInputs = monadHelpers.mapToNamedPathAndInputs;
|
388 | exports.mapToNamedResponseAndInputs = monadHelpers.mapToNamedResponseAndInputs;
|
389 | exports.mapToNamedResponseAndInputsMDeep = monadHelpers.mapToNamedResponseAndInputsMDeep;
|
390 | exports.mapToPath = monadHelpers.mapToPath;
|
391 | exports.mapToResponseAndInputs = monadHelpers.mapToResponseAndInputs;
|
392 | exports.mapWithArgToPath = monadHelpers.mapWithArgToPath;
|
393 | exports.objOfMLevelDeepListOfMonadsToListWithPairs = monadHelpers.objOfMLevelDeepListOfMonadsToListWithPairs;
|
394 | exports.objOfMLevelDeepMonadsToListWithPairs = monadHelpers.objOfMLevelDeepMonadsToListWithPairs;
|
395 | exports.pairsOfMLevelDeepListOfMonadsToListWithPairs = monadHelpers.pairsOfMLevelDeepListOfMonadsToListWithPairs;
|
396 | exports.promiseToTask = monadHelpers.promiseToTask;
|
397 | exports.resultTasksToResultObjTask = monadHelpers.resultTasksToResultObjTask;
|
398 | exports.resultToTask = monadHelpers.resultToTask;
|
399 | exports.resultToTaskNeedingResult = monadHelpers.resultToTaskNeedingResult;
|
400 | exports.resultToTaskWithResult = monadHelpers.resultToTaskWithResult;
|
401 | exports.resultsToResultObj = monadHelpers.resultsToResultObj;
|
402 | exports.retryTask = monadHelpers.retryTask;
|
403 | exports.sequenceBucketed = monadHelpers.sequenceBucketed;
|
404 | exports.stringifyError = monadHelpers.stringifyError;
|
405 | exports.taskToPromise = monadHelpers.taskToPromise;
|
406 | exports.taskToResultTask = monadHelpers.taskToResultTask;
|
407 | exports.toMergedResponseAndInputs = monadHelpers.toMergedResponseAndInputs;
|
408 | exports.toNamedResponseAndInputs = monadHelpers.toNamedResponseAndInputs;
|
409 | exports.traverseReduce = monadHelpers.traverseReduce;
|
410 | exports.traverseReduceDeep = monadHelpers.traverseReduceDeep;
|
411 | exports.traverseReduceDeepResults = monadHelpers.traverseReduceDeepResults;
|
412 | exports.traverseReduceError = monadHelpers.traverseReduceError;
|
413 | exports.traverseReduceResultError = monadHelpers.traverseReduceResultError;
|
414 | exports.traverseReduceWhile = monadHelpers.traverseReduceWhile;
|
415 | exports.traverseReduceWhileBucketed = monadHelpers.traverseReduceWhileBucketed;
|
416 | exports.traverseReduceWhileBucketedTasks = monadHelpers.traverseReduceWhileBucketedTasks;
|
417 | exports.waitAllBucketed = monadHelpers.waitAllBucketed;
|
418 | exports.expectKeys = expectKeys;
|
419 | exports.expectKeysAtPath = expectKeysAtPath;
|
420 | exports.expectTask = expectTask;
|
421 | exports.memoized = memoized;
|
422 | exports.memoizedWith = memoizedWith;
|
423 | exports.objectDiff = objectDiff;
|
424 | exports.prettyPrintObjectDiff = prettyPrintObjectDiff;
|
425 | exports.resultToPromise = resultToPromise;
|
426 |
|