ramda-adjunct 5.0.0 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +1 -1
- package/dist/RA.node.js +10440 -452
- package/dist/RA.node.min.js +1 -1
- package/dist/RA.web.js +10440 -452
- package/dist/RA.web.min.js +1 -1
- package/dist/RA.web.standalone.js +18646 -447
- package/dist/RA.web.standalone.min.js +1 -1
- package/dist/package.json +1 -0
- package/es/async.js +4 -4
- package/es/copyKeys.js +1 -1
- package/es/dispatch.js +5 -5
- package/es/fantasy-land/Identity.js +3 -3
- package/es/fantasy-land/traits.js +1 -1
- package/es/flattenDepth.js +5 -5
- package/es/internal/ponyfills/Array.from.js +5 -5
- package/es/internal/ponyfills/Promise.allSettled.js +5 -5
- package/es/internal/ponyfills/Promise.any.js +15 -15
- package/es/lastP.js +5 -5
- package/es/reduceP.js +4 -4
- package/es/reduceRightP.js +4 -4
- package/es/renameKey.js +1 -1
- package/es/sortByProps.js +5 -5
- package/lib/allEqual.js +1 -1
- package/lib/allIdentical.js +1 -1
- package/lib/allSettledP.js +1 -1
- package/lib/allUnique.js +1 -1
- package/lib/anyP.js +1 -1
- package/lib/argsPass.js +1 -1
- package/lib/async.js +5 -5
- package/lib/cata.js +1 -1
- package/lib/compact.js +1 -1
- package/lib/concatAll.js +1 -1
- package/lib/copyKeys.js +2 -2
- package/lib/curryRight.js +1 -1
- package/lib/delayP.js +1 -1
- package/lib/dispatch.js +6 -6
- package/lib/ensureArray.js +1 -1
- package/lib/escapeRegExp.js +1 -1
- package/lib/fantasy-land/Identity.js +3 -3
- package/lib/fantasy-land/traits.js +2 -2
- package/lib/flattenDepth.js +6 -6
- package/lib/flattenProp.js +1 -1
- package/lib/fnull.js +1 -1
- package/lib/index.js +1 -1
- package/lib/internal/ap.js +1 -1
- package/lib/internal/isCoercible.js +1 -1
- package/lib/internal/makeFlat.js +1 -1
- package/lib/internal/ponyfills/Array.from.js +6 -6
- package/lib/internal/ponyfills/Math.trunc.js +1 -1
- package/lib/internal/ponyfills/Number.isFinite.js +1 -1
- package/lib/internal/ponyfills/Number.isInteger.js +1 -1
- package/lib/internal/ponyfills/Number.isNaN.js +1 -1
- package/lib/internal/ponyfills/Number.isSafeInteger.js +1 -1
- package/lib/internal/ponyfills/Promise.allSettled.js +6 -6
- package/lib/internal/ponyfills/Promise.any.js +16 -16
- package/lib/internal/ponyfills/String.padEnd.js +1 -1
- package/lib/internal/ponyfills/String.padStart.js +1 -1
- package/lib/internal/ponyfills/String.repeat.js +1 -1
- package/lib/internal/ponyfills/String.replaceAll.js +1 -1
- package/lib/invoke.js +1 -1
- package/lib/invokeArgs.js +1 -1
- package/lib/isArray.js +1 -1
- package/lib/isArrayLike.js +1 -1
- package/lib/isBlank.js +1 -1
- package/lib/isEmptyArray.js +1 -1
- package/lib/isEven.js +1 -1
- package/lib/isFalsy.js +1 -1
- package/lib/isFinite.js +1 -1
- package/lib/isFloat.js +1 -1
- package/lib/isFunction.js +1 -1
- package/lib/isIndexed.js +1 -1
- package/lib/isInteger.js +1 -1
- package/lib/isInteger32.js +1 -1
- package/lib/isIterable.js +1 -1
- package/lib/isNaN.js +1 -1
- package/lib/isNaturalNumber.js +1 -1
- package/lib/isNegative.js +1 -1
- package/lib/isNonEmptyArray.js +1 -1
- package/lib/isNonEmptyString.js +1 -1
- package/lib/isNonNegative.js +1 -1
- package/lib/isNonPositive.js +1 -1
- package/lib/isNotArray.js +1 -1
- package/lib/isNotArrayLike.js +1 -1
- package/lib/isNotAsyncFunction.js +1 -1
- package/lib/isNotBoolean.js +1 -1
- package/lib/isNotDate.js +1 -1
- package/lib/isNotFinite.js +1 -1
- package/lib/isNotFloat.js +1 -1
- package/lib/isNotFunction.js +1 -1
- package/lib/isNotGeneratorFunction.js +1 -1
- package/lib/isNotInteger.js +1 -1
- package/lib/isNotMap.js +1 -1
- package/lib/isNotNaN.js +1 -1
- package/lib/isNotNilOrEmpty.js +1 -1
- package/lib/isNotNull.js +1 -1
- package/lib/isNotNumber.js +1 -1
- package/lib/isNotObj.js +1 -1
- package/lib/isNotObjLike.js +1 -1
- package/lib/isNotPair.js +1 -1
- package/lib/isNotPlainObj.js +1 -1
- package/lib/isNotPrimitive.js +1 -1
- package/lib/isNotRegExp.js +1 -1
- package/lib/isNotSet.js +1 -1
- package/lib/isNotString.js +1 -1
- package/lib/isNotUndefined.js +1 -1
- package/lib/isNotValidDate.js +1 -1
- package/lib/isNotValidNumber.js +1 -1
- package/lib/isObj.js +1 -1
- package/lib/isObjLike.js +1 -1
- package/lib/isOdd.js +1 -1
- package/lib/isPair.js +1 -1
- package/lib/isPlainObj.js +1 -1
- package/lib/isPositive.js +1 -1
- package/lib/isPrimitive.js +1 -1
- package/lib/isPromise.js +1 -1
- package/lib/isPrototypeOf.js +1 -1
- package/lib/isSafeInteger.js +1 -1
- package/lib/isSentinelValue.js +1 -1
- package/lib/isSparseArray.js +1 -1
- package/lib/isThenable.js +1 -1
- package/lib/isUinteger32.js +1 -1
- package/lib/isUndefined.js +1 -1
- package/lib/isValidDate.js +1 -1
- package/lib/isValidNumber.js +1 -1
- package/lib/lastP.js +6 -6
- package/lib/lengthEq.js +1 -1
- package/lib/lengthGt.js +1 -1
- package/lib/lengthGte.js +1 -1
- package/lib/lengthLt.js +1 -1
- package/lib/lengthLte.js +1 -1
- package/lib/lengthNotEq.js +1 -1
- package/lib/lensNotEq.js +1 -1
- package/lib/lensNotSatisfy.js +1 -1
- package/lib/lensSatisfies.js +1 -1
- package/lib/lensTraverse.js +1 -1
- package/lib/liftF.js +1 -1
- package/lib/liftFN.js +1 -1
- package/lib/mergePaths.js +1 -1
- package/lib/mergeProp.js +1 -1
- package/lib/noneP.js +1 -1
- package/lib/noop.js +1 -1
- package/lib/notAllUnique.js +1 -1
- package/lib/padCharsEnd.js +1 -1
- package/lib/padCharsStart.js +1 -1
- package/lib/padEnd.js +1 -1
- package/lib/padStart.js +1 -1
- package/lib/rangeStep.js +1 -1
- package/lib/reduceP.js +5 -5
- package/lib/reduceRightP.js +5 -5
- package/lib/renameKey.js +2 -2
- package/lib/renameKeyWith.js +1 -1
- package/lib/renameKeys.js +1 -1
- package/lib/repeatStr.js +1 -1
- package/lib/replaceAll.js +1 -1
- package/lib/sign.js +1 -1
- package/lib/sortByProp.js +1 -1
- package/lib/sortByProps.js +5 -5
- package/lib/spreadProp.js +1 -1
- package/lib/toArray.js +1 -1
- package/lib/toNumber.js +1 -1
- package/lib/trimCharsEnd.js +1 -1
- package/lib/trimCharsStart.js +1 -1
- package/lib/trimEnd.js +1 -1
- package/lib/trimStart.js +1 -1
- package/lib/trunc.js +1 -1
- package/lib/unzipObjWith.js +1 -1
- package/package.json +33 -30
- package/types/index.d.ts +0 -5
- package/babel.config.cjs +0 -56
- package/src/Y.js +0 -32
- package/src/allEqual.js +0 -28
- package/src/allEqualTo.js +0 -25
- package/src/allIdentical.js +0 -26
- package/src/allIdenticalTo.js +0 -25
- package/src/allP.js +0 -27
- package/src/allSettledP.js +0 -34
- package/src/allUnique.js +0 -25
- package/src/anyP.js +0 -33
- package/src/appendFlipped.js +0 -24
- package/src/argsPass.js +0 -40
- package/src/async.js +0 -60
- package/src/cata.js +0 -86
- package/src/catchP.js +0 -25
- package/src/ceil.js +0 -28
- package/src/compact.js +0 -23
- package/src/concatAll.js +0 -35
- package/src/concatRight.js +0 -30
- package/src/copyKeys.js +0 -31
- package/src/curryRight.js +0 -26
- package/src/curryRightN.js +0 -29
- package/src/defaultWhen.js +0 -26
- package/src/delayP.js +0 -45
- package/src/dispatch.js +0 -74
- package/src/divideNum.js +0 -20
- package/src/dropArgs.js +0 -23
- package/src/ensureArray.js +0 -24
- package/src/escapeRegExp.js +0 -22
- package/src/fantasy-land/Identity.js +0 -270
- package/src/fantasy-land/mapping.js +0 -20
- package/src/fantasy-land/traits.js +0 -57
- package/src/fantasy-land/util.js +0 -23
- package/src/filterIndexed.js +0 -28
- package/src/findOr.js +0 -30
- package/src/flattenDepth.js +0 -39
- package/src/flattenPath.js +0 -28
- package/src/flattenProp.js +0 -28
- package/src/floor.js +0 -27
- package/src/fnull.js +0 -38
- package/src/inRange.js +0 -34
- package/src/included.js +0 -28
- package/src/index.js +0 -241
- package/src/internal/ap.js +0 -30
- package/src/internal/compareLength.js +0 -7
- package/src/internal/isCoercible.js +0 -12
- package/src/internal/isOfTypeObject.js +0 -3
- package/src/internal/makeFlat.js +0 -42
- package/src/internal/ponyfills/Array.from.js +0 -34
- package/src/internal/ponyfills/Math.sign.js +0 -3
- package/src/internal/ponyfills/Math.trunc.js +0 -14
- package/src/internal/ponyfills/Number.MAX_SAFE_INTEGER.js +0 -3
- package/src/internal/ponyfills/Number.MIN_SAFE_INTEGER.js +0 -3
- package/src/internal/ponyfills/Number.isFinite.js +0 -8
- package/src/internal/ponyfills/Number.isInteger.js +0 -10
- package/src/internal/ponyfills/Number.isNaN.js +0 -8
- package/src/internal/ponyfills/Number.isSafeInteger.js +0 -11
- package/src/internal/ponyfills/Promise.allSettled.js +0 -18
- package/src/internal/ponyfills/Promise.any.js +0 -29
- package/src/internal/ponyfills/String.padEnd.js +0 -25
- package/src/internal/ponyfills/String.padStart.js +0 -27
- package/src/internal/ponyfills/String.repeat.js +0 -49
- package/src/internal/ponyfills/String.replaceAll.js +0 -44
- package/src/internal/ponyfills/String.trimEnd.js +0 -5
- package/src/internal/ponyfills/String.trimStart.js +0 -5
- package/src/invoke.js +0 -22
- package/src/invokeArgs.js +0 -36
- package/src/isArray.js +0 -27
- package/src/isArrayLike.js +0 -79
- package/src/isAsyncFunction.js +0 -23
- package/src/isBigInt.js +0 -24
- package/src/isBlank.js +0 -33
- package/src/isBoolean.js +0 -22
- package/src/isDate.js +0 -21
- package/src/isEmptyArray.js +0 -28
- package/src/isEmptyString.js +0 -28
- package/src/isError.js +0 -21
- package/src/isEven.js +0 -31
- package/src/isFalse.js +0 -31
- package/src/isFalsy.js +0 -28
- package/src/isFinite.js +0 -37
- package/src/isFloat.js +0 -36
- package/src/isFunction.js +0 -32
- package/src/isGeneratorFunction.js +0 -26
- package/src/isIndexed.js +0 -24
- package/src/isInteger.js +0 -40
- package/src/isInteger32.js +0 -28
- package/src/isIterable.js +0 -37
- package/src/isMap.js +0 -25
- package/src/isNaN.js +0 -45
- package/src/isNaturalNumber.js +0 -28
- package/src/isNegative.js +0 -27
- package/src/isNegativeZero.js +0 -23
- package/src/isNilOrEmpty.js +0 -26
- package/src/isNonEmptyArray.js +0 -28
- package/src/isNonEmptyString.js +0 -31
- package/src/isNonNegative.js +0 -30
- package/src/isNonPositive.js +0 -30
- package/src/isNotArray.js +0 -24
- package/src/isNotArrayLike.js +0 -26
- package/src/isNotAsyncFunction.js +0 -27
- package/src/isNotBoolean.js +0 -24
- package/src/isNotDate.js +0 -23
- package/src/isNotFinite.js +0 -31
- package/src/isNotFloat.js +0 -35
- package/src/isNotFunction.js +0 -29
- package/src/isNotGeneratorFunction.js +0 -27
- package/src/isNotInteger.js +0 -36
- package/src/isNotMap.js +0 -27
- package/src/isNotNaN.js +0 -37
- package/src/isNotNil.js +0 -23
- package/src/isNotNilOrEmpty.js +0 -28
- package/src/isNotNull.js +0 -24
- package/src/isNotNumber.js +0 -25
- package/src/isNotObj.js +0 -29
- package/src/isNotObjLike.js +0 -29
- package/src/isNotPair.js +0 -27
- package/src/isNotPlainObj.js +0 -35
- package/src/isNotPrimitive.js +0 -26
- package/src/isNotRegExp.js +0 -24
- package/src/isNotSet.js +0 -26
- package/src/isNotString.js +0 -23
- package/src/isNotUndefined.js +0 -24
- package/src/isNotValidDate.js +0 -24
- package/src/isNotValidNumber.js +0 -27
- package/src/isNull.js +0 -22
- package/src/isNumber.js +0 -24
- package/src/isObj.js +0 -31
- package/src/isObjLike.js +0 -30
- package/src/isOdd.js +0 -29
- package/src/isPair.js +0 -27
- package/src/isPlainObj.js +0 -65
- package/src/isPositive.js +0 -26
- package/src/isPositiveZero.js +0 -23
- package/src/isPrimitive.js +0 -46
- package/src/isPromise.js +0 -32
- package/src/isPrototypeOf.js +0 -36
- package/src/isRegExp.js +0 -22
- package/src/isSafeInteger.js +0 -40
- package/src/isSentinelValue.js +0 -26
- package/src/isSet.js +0 -24
- package/src/isSparseArray.js +0 -43
- package/src/isString.js +0 -21
- package/src/isSymbol.js +0 -29
- package/src/isThenable.js +0 -28
- package/src/isTrue.js +0 -27
- package/src/isTruthy.js +0 -28
- package/src/isUinteger32.js +0 -29
- package/src/isUndefined.js +0 -24
- package/src/isValidDate.js +0 -29
- package/src/isValidNumber.js +0 -28
- package/src/lastP.js +0 -54
- package/src/lengthEq.js +0 -24
- package/src/lengthGt.js +0 -24
- package/src/lengthGte.js +0 -26
- package/src/lengthLt.js +0 -24
- package/src/lengthLte.js +0 -25
- package/src/lengthNotEq.js +0 -24
- package/src/lensEq.js +0 -28
- package/src/lensIso.js +0 -51
- package/src/lensNotEq.js +0 -28
- package/src/lensNotSatisfy.js +0 -30
- package/src/lensSatisfies.js +0 -33
- package/src/lensTraverse.js +0 -56
- package/src/liftF.js +0 -37
- package/src/liftFN.js +0 -45
- package/src/list.js +0 -20
- package/src/mapIndexed.js +0 -27
- package/src/mergePath.js +0 -30
- package/src/mergePaths.js +0 -29
- package/src/mergeProp.js +0 -30
- package/src/mergeProps.js +0 -27
- package/src/move.js +0 -26
- package/src/nand.js +0 -27
- package/src/neither.js +0 -38
- package/src/noneP.js +0 -35
- package/src/nonePass.js +0 -32
- package/src/noop.js +0 -21
- package/src/nor.js +0 -28
- package/src/notAllPass.js +0 -32
- package/src/notAllUnique.js +0 -25
- package/src/notBoth.js +0 -38
- package/src/notEqual.js +0 -31
- package/src/omitBy.js +0 -25
- package/src/omitIndexes.js +0 -27
- package/src/overlaps.js +0 -30
- package/src/padCharsEnd.js +0 -37
- package/src/padCharsStart.js +0 -35
- package/src/padEnd.js +0 -25
- package/src/padStart.js +0 -23
- package/src/pathNotEq.js +0 -31
- package/src/pathOrLazy.js +0 -30
- package/src/paths.js +0 -26
- package/src/pickIndexes.js +0 -30
- package/src/propNotEq.js +0 -30
- package/src/rangeStep.js +0 -37
- package/src/reduceIndexed.js +0 -31
- package/src/reduceP.js +0 -96
- package/src/reduceRightP.js +0 -101
- package/src/rejectP.js +0 -24
- package/src/renameKey.js +0 -33
- package/src/renameKeyWith.js +0 -30
- package/src/renameKeys.js +0 -40
- package/src/renameKeysWith.js +0 -27
- package/src/repeatStr.js +0 -30
- package/src/replaceAll.js +0 -35
- package/src/resolveP.js +0 -28
- package/src/round.js +0 -26
- package/src/seq.js +0 -38
- package/src/sign.js +0 -33
- package/src/skipTake.js +0 -33
- package/src/sliceFrom.js +0 -23
- package/src/sliceTo.js +0 -23
- package/src/sortByPaths.js +0 -55
- package/src/sortByProp.js +0 -45
- package/src/sortByProps.js +0 -31
- package/src/spreadPath.js +0 -26
- package/src/spreadProp.js +0 -25
- package/src/stubArray.js +0 -18
- package/src/stubNull.js +0 -19
- package/src/stubObj.js +0 -19
- package/src/stubString.js +0 -19
- package/src/stubUndefined.js +0 -19
- package/src/subtractNum.js +0 -20
- package/src/thenCatchP.js +0 -27
- package/src/toArray.js +0 -32
- package/src/toInteger32.js +0 -22
- package/src/toNumber.js +0 -24
- package/src/toUinteger32.js +0 -26
- package/src/trimCharsEnd.js +0 -25
- package/src/trimCharsStart.js +0 -25
- package/src/trimEnd.js +0 -30
- package/src/trimStart.js +0 -29
- package/src/trunc.js +0 -33
- package/src/unzipObjWith.js +0 -40
- package/src/viewOr.js +0 -32
- package/src/weave.js +0 -35
- package/src/weaveLazy.js +0 -37
- package/src/zipObjWith.js +0 -27
package/src/lastP.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { bind, last, map, curryN } from 'ramda';
|
|
2
|
-
|
|
3
|
-
import allP from './allP.js';
|
|
4
|
-
import lengthEq from './lengthEq.js';
|
|
5
|
-
import lengthGte from './lengthGte.js';
|
|
6
|
-
import rejectP from './rejectP.js';
|
|
7
|
-
import resolveP from './resolveP.js';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Returns a promise that is fulfilled by the last given promise to be fulfilled,
|
|
11
|
-
* or rejected with an array of rejection reasons if all of the given promises are rejected.
|
|
12
|
-
*
|
|
13
|
-
* @func lastP
|
|
14
|
-
* @memberOf RA
|
|
15
|
-
* @category Function
|
|
16
|
-
* @since {@link https://char0n.github.io/ramda-adjunct/2.23.0|v2.23.0}
|
|
17
|
-
* @sig [Promise a] -> Promise a
|
|
18
|
-
* @param {Iterable.<*>} iterable An iterable object such as an Array or String
|
|
19
|
-
* @return {Promise} A promise that is fulfilled by the last given promise to be fulfilled, or rejected with an array of rejection reasons if all of the given promises are rejected.
|
|
20
|
-
* @see {@link RA.anyP|anyP}
|
|
21
|
-
* @example
|
|
22
|
-
*
|
|
23
|
-
* const delayP = timeout => new Promise(resolve => setTimeout(() => resolve(timeout), timeout));
|
|
24
|
-
* delayP.reject = timeout => new Promise((resolve, reject) => setTimeout(() => reject(timeout), timeout));
|
|
25
|
-
* RA.lastP([
|
|
26
|
-
* 1,
|
|
27
|
-
* delayP(10),
|
|
28
|
-
* delayP(100),
|
|
29
|
-
* delayP.reject(1000),
|
|
30
|
-
* ]); //=> Promise(100)
|
|
31
|
-
*/
|
|
32
|
-
const lastP = curryN(1, (iterable) => {
|
|
33
|
-
const fulfilled = [];
|
|
34
|
-
const rejected = [];
|
|
35
|
-
const onFulfill = bind(fulfilled.push, fulfilled);
|
|
36
|
-
const onReject = bind(rejected.push, rejected);
|
|
37
|
-
|
|
38
|
-
const listOfPromises = map(
|
|
39
|
-
(p) => resolveP(p).then(onFulfill).catch(onReject),
|
|
40
|
-
[...iterable]
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
return allP(listOfPromises).then(() => {
|
|
44
|
-
if (lengthEq(0, fulfilled) && lengthEq(0, rejected)) {
|
|
45
|
-
return undefined;
|
|
46
|
-
}
|
|
47
|
-
if (lengthGte(1, fulfilled)) {
|
|
48
|
-
return last(fulfilled);
|
|
49
|
-
}
|
|
50
|
-
return rejectP(rejected);
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
export default lastP;
|
package/src/lengthEq.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { equals } from 'ramda';
|
|
2
|
-
|
|
3
|
-
import compareLength from './internal/compareLength.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Returns `true` if the supplied list or string has a length equal to `valueLength`.
|
|
7
|
-
*
|
|
8
|
-
* @func lengthEq
|
|
9
|
-
* @memberOf RA
|
|
10
|
-
* @since {@link https://char0n.github.io/ramda-adjunct/2.8.0|v2.8.0}
|
|
11
|
-
* @category List
|
|
12
|
-
* @sig Number -> [*] -> Boolean
|
|
13
|
-
* @param {number} valueLength The length of the list or string
|
|
14
|
-
* @param {Array|string} value The list or string
|
|
15
|
-
* @return {boolean}
|
|
16
|
-
* @see {@link RA.lengthNotEq|lengthNotEq}, {@link RA.lengthLt|lengthLt}, {@link RA.lengthGt|lengthGt}, {@link RA.lengthLte|lengthLte}, {@link RA.lengthGte|lengthGte},, {@link http://ramdajs.com/docs/#equals|equals}, {@link http://ramdajs.com/docs/#length|length}
|
|
17
|
-
* @example
|
|
18
|
-
*
|
|
19
|
-
* RA.lengthEq(3, [1,2,3]); //=> true
|
|
20
|
-
* RA.lengthEq(3, [1,2,3,4]); //=> false
|
|
21
|
-
*/
|
|
22
|
-
const lengthEq = compareLength(equals);
|
|
23
|
-
|
|
24
|
-
export default lengthEq;
|
package/src/lengthGt.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { flip, gt } from 'ramda';
|
|
2
|
-
|
|
3
|
-
import compareLength from './internal/compareLength.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Returns `true` if the supplied list or string has a length greater than `valueLength`.
|
|
7
|
-
*
|
|
8
|
-
* @func lengthGt
|
|
9
|
-
* @memberOf RA
|
|
10
|
-
* @since {@link https://char0n.github.io/ramda-adjunct/2.8.0|v2.8.0}
|
|
11
|
-
* @category List
|
|
12
|
-
* @sig Number -> [*] -> Boolean
|
|
13
|
-
* @param {number} valueLength The length of the list or string
|
|
14
|
-
* @param {Array|string} value The list or string
|
|
15
|
-
* @return {boolean}
|
|
16
|
-
* @see {@link RA.lengthEq|lengthEq}, {@link RA.lengthNotEq|lengthNotEq}, {@link RA.lengthLt|lengthLt}, {@link RA.lengthLte|lengthLte}, {@link RA.lengthGte|lengthGte}, {@link http://ramdajs.com/docs/#gt|gt}, {@link http://ramdajs.com/docs/#length|length}
|
|
17
|
-
* @example
|
|
18
|
-
*
|
|
19
|
-
* RA.lengthGt(3, [1,2,3,4]); //=> true
|
|
20
|
-
* RA.lengthGt(3, [1,2,3]); //=> false
|
|
21
|
-
*/
|
|
22
|
-
const lengthGt = compareLength(flip(gt));
|
|
23
|
-
|
|
24
|
-
export default lengthGt;
|
package/src/lengthGte.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { flip, gte } from 'ramda';
|
|
2
|
-
|
|
3
|
-
import compareLength from './internal/compareLength.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Returns `true` if the supplied list or string has a length greater than or equal to
|
|
7
|
-
* `valueLength`.
|
|
8
|
-
*
|
|
9
|
-
* @func lengthGte
|
|
10
|
-
* @memberOf RA
|
|
11
|
-
* @since {@link https://char0n.github.io/ramda-adjunct/2.8.0|v2.8.0}
|
|
12
|
-
* @category List
|
|
13
|
-
* @sig Number -> [*] -> Boolean
|
|
14
|
-
* @param {number} valueLength The length of the list or string
|
|
15
|
-
* @param {Array|string} value The list or string
|
|
16
|
-
* @return {boolean}
|
|
17
|
-
* @see {@link RA.lengthEq|lengthEq}, {@link RA.lengthNotEq|lengthNotEq}, {@link RA.lengthLt|lengthLt}, {@link RA.lengthGt|lengthGt}, {@link RA.lengthLte|lengthLte}, {@link http://ramdajs.com/docs/#gte|gte}, {@link http://ramdajs.com/docs/#length|length}
|
|
18
|
-
* @example
|
|
19
|
-
*
|
|
20
|
-
* RA.lengthGte(3, [1,2,3,4]); //=> true
|
|
21
|
-
* RA.lengthGte(3, [1,2,3]); //=> true
|
|
22
|
-
* RA.lengthGte(3, [1,2]); //=> false
|
|
23
|
-
*/
|
|
24
|
-
const lengthGte = compareLength(flip(gte));
|
|
25
|
-
|
|
26
|
-
export default lengthGte;
|
package/src/lengthLt.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { flip, lt } from 'ramda';
|
|
2
|
-
|
|
3
|
-
import compareLength from './internal/compareLength.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Returns `true` if the supplied list or string has a length less than `valueLength`.
|
|
7
|
-
*
|
|
8
|
-
* @func lengthLt
|
|
9
|
-
* @memberOf RA
|
|
10
|
-
* @since {@link https://char0n.github.io/ramda-adjunct/2.8.0|v2.8.0}
|
|
11
|
-
* @category List
|
|
12
|
-
* @sig Number -> [*] -> Boolean
|
|
13
|
-
* @param {number} valueLength The length of the list or string
|
|
14
|
-
* @param {Array|string} value The list or string
|
|
15
|
-
* @return {boolean}
|
|
16
|
-
* @see {@link RA.lengthEq|lengthEq}, {@link RA.lengthNotEq|lengthNotEq}, {@link RA.lengthGt|lengthGt}, {@link RA.lengthLte|lengthLte}, {@link RA.lengthGte|lengthGte}, {@link http://ramdajs.com/docs/#lt|lt}, {@link http://ramdajs.com/docs/#length|length}
|
|
17
|
-
* @example
|
|
18
|
-
*
|
|
19
|
-
* RA.lengthLt(3, [1,2]); //=> true
|
|
20
|
-
* RA.lengthLt(3, [1,2,3]); //=> false
|
|
21
|
-
*/
|
|
22
|
-
const lengthLt = compareLength(flip(lt));
|
|
23
|
-
|
|
24
|
-
export default lengthLt;
|
package/src/lengthLte.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { flip, lte } from 'ramda';
|
|
2
|
-
|
|
3
|
-
import compareLength from './internal/compareLength.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Returns `true` if the supplied list or string has a length less than or equal to `valueLength`.
|
|
7
|
-
*
|
|
8
|
-
* @func lengthLte
|
|
9
|
-
* @memberOf RA
|
|
10
|
-
* @since {@link https://char0n.github.io/ramda-adjunct/2.8.0|v2.8.0}
|
|
11
|
-
* @category List
|
|
12
|
-
* @sig Number -> [*] -> Boolean
|
|
13
|
-
* @param {number} valueLength The length of the list or string
|
|
14
|
-
* @param {Array|string} value The list or string
|
|
15
|
-
* @return {boolean}
|
|
16
|
-
* @see {@link RA.lengthEq|lengthEq}, {@link RA.lengthNotEq|lengthNotEq}, {@link RA.lengthLt|lengthLt}, {@link RA.lengthGt|lengthGt}, {@link RA.lengthGte|lengthGte}, {@link http://ramdajs.com/docs/#lte|lte}, {@link http://ramdajs.com/docs/#length|length}
|
|
17
|
-
* @example
|
|
18
|
-
*
|
|
19
|
-
* RA.lengthLte(3, [1,2]); //=> true
|
|
20
|
-
* RA.lengthLte(3, [1,2,3]); //=> true
|
|
21
|
-
* RA.lengthLte(3, [1,2,3,4]); //=> false
|
|
22
|
-
*/
|
|
23
|
-
const lengthLte = compareLength(flip(lte));
|
|
24
|
-
|
|
25
|
-
export default lengthLte;
|
package/src/lengthNotEq.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { complement, equals } from 'ramda';
|
|
2
|
-
|
|
3
|
-
import compareLength from './internal/compareLength.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Returns `true` if the supplied list or string has a length not equal to `valueLength`.
|
|
7
|
-
*
|
|
8
|
-
* @func lengthNotEq
|
|
9
|
-
* @memberOf RA
|
|
10
|
-
* @since {@link https://char0n.github.io/ramda-adjunct/2.8.0|v2.8.0}
|
|
11
|
-
* @category List
|
|
12
|
-
* @sig Number -> [*] -> Boolean
|
|
13
|
-
* @param {number} valueLength The length of the list or string
|
|
14
|
-
* @param {Array|string} value The list or string
|
|
15
|
-
* @return {boolean}
|
|
16
|
-
* @see {@link RA.lengthEq|lengthEq}, {@link RA.lengthLt|lengthLt}, {@link RA.lengthGt|lengthGt}, {@link RA.lengthLte|lengthLte}, {@link RA.lengthGte|lengthGte}, {@link http://ramdajs.com/docs/#equals|equals}, {@link http://ramdajs.com/docs/#length|length}
|
|
17
|
-
* @example
|
|
18
|
-
*
|
|
19
|
-
* RA.lengthNotEq(3, [1,2,3,4]); //=> true
|
|
20
|
-
* RA.lengthNotEq(3, [1,2,3]); //=> false
|
|
21
|
-
*/
|
|
22
|
-
const lengthNotEq = compareLength(complement(equals));
|
|
23
|
-
|
|
24
|
-
export default lengthNotEq;
|
package/src/lensEq.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { view, curryN, equals, pipe } from 'ramda';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Returns `true` if data structure focused by the given lens equals provided value.
|
|
5
|
-
*
|
|
6
|
-
* @func lensEq
|
|
7
|
-
* @memberOf RA
|
|
8
|
-
* @since {@link https://char0n.github.io/ramda-adjunct/1.13.0|1.13.0}
|
|
9
|
-
* @category Relation
|
|
10
|
-
* @typedef Lens s a = Functor f => (a -> f a) -> s -> f s
|
|
11
|
-
* @sig Lens s a -> b -> s -> Boolean
|
|
12
|
-
* @see {@link RA.lensNotEq|lensNotEq}
|
|
13
|
-
* @param {function} lens Van Laarhoven lens
|
|
14
|
-
* @param {*} value The value to compare the focused data structure with
|
|
15
|
-
* @param {*} data The data structure
|
|
16
|
-
* @return {boolean} `true` if the focused data structure equals value, `false` otherwise
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
*
|
|
20
|
-
* RA.lensEq(R.lensIndex(0), 1, [0, 1, 2]); // => false
|
|
21
|
-
* RA.lensEq(R.lensIndex(1), 1, [0, 1, 2]); // => true
|
|
22
|
-
* RA.lensEq(R.lensPath(['a', 'b']), 'foo', { a: { b: 'foo' } }) // => true
|
|
23
|
-
*/
|
|
24
|
-
const lensEq = curryN(3, (lens, val, data) =>
|
|
25
|
-
pipe(view(lens), equals(val))(data)
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
export default lensEq;
|
package/src/lensIso.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { curry, map } from 'ramda';
|
|
2
|
-
|
|
3
|
-
// This implementation was highly inspired by the implementations
|
|
4
|
-
// in ramda-lens library.
|
|
5
|
-
//
|
|
6
|
-
// https://github.com/ramda/ramda-lens
|
|
7
|
-
|
|
8
|
-
// isomorphic :: ((a -> b), (b -> a)) -> Isomorphism
|
|
9
|
-
// Isomorphism = x -> y
|
|
10
|
-
const isomorphic = (to, from) => {
|
|
11
|
-
const isomorphism = (x) => to(x);
|
|
12
|
-
isomorphism.from = from;
|
|
13
|
-
return isomorphism;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
// isomorphisms :: ((a -> b), (b -> a)) -> (a -> b)
|
|
17
|
-
const isomorphisms = (to, from) =>
|
|
18
|
-
isomorphic(
|
|
19
|
-
curry((toFunctorFn, target) => map(from, toFunctorFn(to(target)))),
|
|
20
|
-
curry((toFunctorFn, target) => map(to, toFunctorFn(from(target))))
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
// from :: Isomorphism -> a -> b
|
|
24
|
-
const from = curry((isomorphism, x) => isomorphism.from(x));
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Defines an isomorphism that will work like a lens. It takes two functions.
|
|
28
|
-
* The function that converts and the function that recovers.
|
|
29
|
-
*
|
|
30
|
-
* @func lensIso
|
|
31
|
-
* @memberOf RA
|
|
32
|
-
* @since {@link https://char0n.github.io/ramda-adjunct/1.19.0|1.19.0}
|
|
33
|
-
* @category Relation
|
|
34
|
-
* @typedef Lens s a = Functor f => (a -> f a) -> s -> f s
|
|
35
|
-
* @sig (s -> a) -> (a -> s) -> Lens s a
|
|
36
|
-
* @param {!function} to The function that converts
|
|
37
|
-
* @param {!function} from The function that recovers
|
|
38
|
-
* @return {!function} The isomorphic lens
|
|
39
|
-
* @see {@link http://ramdajs.com/docs/#lens|R.lens}
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
*
|
|
43
|
-
* const lensJSON = RA.lensIso(JSON.parse, JSON.stringify);
|
|
44
|
-
*
|
|
45
|
-
* R.over(lensJSON, assoc('b', 2), '{"a":1}'); //=> '{"a":1,"b":2}'
|
|
46
|
-
* R.over(RA.lensIso.from(lensJSON), R.replace('}', ',"b":2}'), { a: 1 }); // => { a: 1, b: 2 }
|
|
47
|
-
*/
|
|
48
|
-
const lensIso = curry(isomorphisms);
|
|
49
|
-
lensIso.from = from;
|
|
50
|
-
|
|
51
|
-
export default lensIso;
|
package/src/lensNotEq.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { complement } from 'ramda';
|
|
2
|
-
|
|
3
|
-
import lensEq from './lensEq.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Returns `true` if data structure focused by the given lens doesn't equal provided value.
|
|
7
|
-
*
|
|
8
|
-
* @func lensNotEq
|
|
9
|
-
* @memberOf RA
|
|
10
|
-
* @since {@link https://char0n.github.io/ramda-adjunct/1.13.0|1.13.0}
|
|
11
|
-
* @category Relation
|
|
12
|
-
* @typedef Lens s a = Functor f => (a -> f a) -> s -> f s
|
|
13
|
-
* @sig Lens s a -> b -> s -> Boolean
|
|
14
|
-
* @see {@link RA.lensEq|lensEq}
|
|
15
|
-
* @param {function} lens Van Laarhoven lens
|
|
16
|
-
* @param {*} value The value to compare the focused data structure with
|
|
17
|
-
* @param {*} data The data structure
|
|
18
|
-
* @return {boolean} `false` if the focused data structure equals value, `true` otherwise
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
*
|
|
22
|
-
* RA.lensNotEq(R.lensIndex(0), 1, [0, 1, 2]); // => true
|
|
23
|
-
* RA.lensNotEq(R.lensIndex(1), 1, [0, 1, 2]); // => false
|
|
24
|
-
* RA.lensNotEq(R.lensPath(['a', 'b']), 'foo', { a: { b: 'foo' } }) // => false
|
|
25
|
-
*/
|
|
26
|
-
const lensNotEq = complement(lensEq);
|
|
27
|
-
|
|
28
|
-
export default lensNotEq;
|
package/src/lensNotSatisfy.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { complement } from 'ramda';
|
|
2
|
-
|
|
3
|
-
import lensSatisfies from './lensSatisfies.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Returns `true` if data structure focused by the given lens doesn't satisfy the predicate.
|
|
7
|
-
* Note that the predicate is expected to return boolean value.
|
|
8
|
-
*
|
|
9
|
-
* @func lensNotSatisfy
|
|
10
|
-
* @memberOf RA
|
|
11
|
-
* @since {@link https://char0n.github.io/ramda-adjunct/1.13.0|1.13.0}
|
|
12
|
-
* @category Relation
|
|
13
|
-
* @typedef Lens s a = Functor f => (a -> f a) -> s -> f s
|
|
14
|
-
* @sig Boolean b => (a -> b) -> Lens s a -> s -> b
|
|
15
|
-
* @see {@link RA.lensSatisfies|lensSatisfies}
|
|
16
|
-
* @param {Function} predicate The predicate function
|
|
17
|
-
* @param {Function} lens Van Laarhoven lens
|
|
18
|
-
* @param {*} data The data structure
|
|
19
|
-
* @return {boolean} `false` if the focused data structure satisfies the predicate, `true` otherwise
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
*
|
|
23
|
-
* RA.lensNotSatisfy(RA.isTrue, R.lensIndex(0), [false, true, 1]); // => true
|
|
24
|
-
* RA.lensNotSatisfy(RA.isTrue, R.lensIndex(1), [false, true, 1]); // => false
|
|
25
|
-
* RA.lensNotSatisfy(RA.isTrue, R.lensIndex(2), [false, true, 1]); // => true
|
|
26
|
-
* RA.lensNotSatisfy(R.identity, R.lensProp('x'), { x: 1 }); // => true
|
|
27
|
-
*/
|
|
28
|
-
const lensNotSatisfy = complement(lensSatisfies);
|
|
29
|
-
|
|
30
|
-
export default lensNotSatisfy;
|
package/src/lensSatisfies.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { view, curryN, pipe } from 'ramda';
|
|
2
|
-
|
|
3
|
-
import isTrue from './isTrue.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Returns `true` if data structure focused by the given lens satisfies the predicate.
|
|
7
|
-
* Note that the predicate is expected to return boolean value and will be evaluated
|
|
8
|
-
* as `false` unless the predicate returns `true`.
|
|
9
|
-
*
|
|
10
|
-
* @func lensSatisfies
|
|
11
|
-
* @memberOf RA
|
|
12
|
-
* @since {@link https://char0n.github.io/ramda-adjunct/1.13.0|1.13.0}
|
|
13
|
-
* @category Relation
|
|
14
|
-
* @typedef Lens s a = Functor f => (a -> f a) -> s -> f s
|
|
15
|
-
* @sig Boolean b => (a -> b) -> Lens s a -> s -> b
|
|
16
|
-
* @see {@link RA.lensNotSatisfy|lensNotSatisfy}
|
|
17
|
-
* @param {Function} predicate The predicate function
|
|
18
|
-
* @param {Function} lens Van Laarhoven lens
|
|
19
|
-
* @param {*} data The data structure
|
|
20
|
-
* @return {boolean} `true` if the focused data structure satisfies the predicate, `false` otherwise
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
*
|
|
24
|
-
* RA.lensSatisfies(RA.isTrue, R.lensIndex(0), [false, true, 1]); // => false
|
|
25
|
-
* RA.lensSatisfies(RA.isTrue, R.lensIndex(1), [false, true, 1]); // => true
|
|
26
|
-
* RA.lensSatisfies(RA.isTrue, R.lensIndex(2), [false, true, 1]); // => false
|
|
27
|
-
* RA.lensSatisfies(R.identity, R.lensProp('x'), { x: 1 }); // => false
|
|
28
|
-
*/
|
|
29
|
-
const lensSatisfies = curryN(3, (predicate, lens, data) =>
|
|
30
|
-
pipe(view(lens), predicate, isTrue)(data)
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
export default lensSatisfies;
|
package/src/lensTraverse.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { traverse, curry, pipe, prop, curryN } from 'ramda';
|
|
2
|
-
|
|
3
|
-
import Identity from './fantasy-land/Identity.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Creates a [Traversable](https://github.com/fantasyland/fantasy-land#traversable) lens
|
|
7
|
-
* from an [Applicative](https://github.com/fantasyland/fantasy-land#applicative)-returning function.
|
|
8
|
-
*
|
|
9
|
-
* When executed, it maps an [Applicative](https://github.com/fantasyland/fantasy-land#applicative)-returning
|
|
10
|
-
* function over a [Traversable](https://github.com/fantasyland/fantasy-land#traversable),
|
|
11
|
-
* then uses [`sequence`](https://ramdajs.com/docs/#sequence) to transform the resulting Traversable of Applicative
|
|
12
|
-
* into an Applicative of Traversable.
|
|
13
|
-
*
|
|
14
|
-
* Dispatches to the `traverse` method of the third argument, if present.
|
|
15
|
-
*
|
|
16
|
-
* @func lensTraverse
|
|
17
|
-
* @memberOf RA
|
|
18
|
-
* @since {@link https://char0n.github.io/ramda-adjunct/2.7.0|2.7.0}
|
|
19
|
-
* @category Relation
|
|
20
|
-
* @typedef Lens s a = Functor f => (a -> f a) -> s -> f s
|
|
21
|
-
* @sig fantasy-land/of :: TypeRep f => f ~> a → f a
|
|
22
|
-
* @sig Applicative f => (a -> f a) -> Lens s a
|
|
23
|
-
* @sig Applicative f => TypeRep f -> Lens s a
|
|
24
|
-
* @param {!Object|!Function} TypeRepresentative with an `of` or `fantasy-land/of` method
|
|
25
|
-
* @return {!function} The Traversable lens
|
|
26
|
-
* @see {@link http://ramdajs.com/docs/#lens|R.lens}, {@link http://ramdajs.com/docs/#traverse|R.traverse}
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
*
|
|
30
|
-
* const maybeLens = RA.lensTraverse(Maybe.of);
|
|
31
|
-
* const safeDiv = n => d => d === 0 ? Maybe.Nothing() : Maybe.Just(n / d)
|
|
32
|
-
*
|
|
33
|
-
* R.over(maybeLens, safeDiv(10), [2, 4, 5]); // => Just([5, 2.5, 2])
|
|
34
|
-
* R.over(maybeLens, safeDiv(10), [2, 0, 5]); // => Nothing
|
|
35
|
-
*
|
|
36
|
-
* R.view(maybeLens, [Maybe.Just(2), Maybe.Just(3)]); // => Maybe.Just([2, 3])
|
|
37
|
-
*
|
|
38
|
-
* R.set(maybeLens, Maybe.Just(1), [Maybe.just(2), Maybe.Just(3)]); // => Maybe.Just([1, 1])
|
|
39
|
-
*/
|
|
40
|
-
/* eslint-disable no-nested-ternary */
|
|
41
|
-
const lensTraverse = curryN(1, (F) => {
|
|
42
|
-
const of =
|
|
43
|
-
typeof F['fantasy-land/of'] === 'function'
|
|
44
|
-
? F['fantasy-land/of']
|
|
45
|
-
: typeof F.of === 'function'
|
|
46
|
-
? F.of
|
|
47
|
-
: F;
|
|
48
|
-
const TypeRep = { 'fantasy-land/of': of };
|
|
49
|
-
|
|
50
|
-
return curry((toFunctorFn, target) =>
|
|
51
|
-
Identity.of(traverse(TypeRep, pipe(toFunctorFn, prop('value')), target))
|
|
52
|
-
);
|
|
53
|
-
});
|
|
54
|
-
/* eslint-enable */
|
|
55
|
-
|
|
56
|
-
export default lensTraverse;
|
package/src/liftF.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { curryN } from 'ramda';
|
|
2
|
-
|
|
3
|
-
import liftFN from './liftFN.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* "lifts" a function to be the specified arity, so that it may "map over" objects that satisfy
|
|
7
|
-
* the fantasy land Apply spec of algebraic structures.
|
|
8
|
-
*
|
|
9
|
-
* Lifting is specific for {@link https://github.com/scalaz/scalaz|scalaz} and {@link http://functionaljava.org/|function Java} implementations.
|
|
10
|
-
* Old version of fantasy land spec were not compatible with this approach,
|
|
11
|
-
* but as of fantasy land 1.0.0 Apply spec also adopted this approach.
|
|
12
|
-
*
|
|
13
|
-
* This function acts as interop for ramda <= 0.23.0 and {@link https://monet.github.io/monet.js/|monet.js}.
|
|
14
|
-
*
|
|
15
|
-
* More info {@link https://github.com/fantasyland/fantasy-land/issues/50|here}.
|
|
16
|
-
*
|
|
17
|
-
* @func liftF
|
|
18
|
-
* @memberOf RA
|
|
19
|
-
* @since {@link https://char0n.github.io/ramda-adjunct/1.2.0|v1.2.0}
|
|
20
|
-
* @category Function
|
|
21
|
-
* @sig Apply a => (a... -> a) -> (a... -> a)
|
|
22
|
-
* @param {Function} fn The function to lift into higher context
|
|
23
|
-
* @return {Function} The lifted function
|
|
24
|
-
* @see {@link RA.liftFN|liftFN}
|
|
25
|
-
* @example
|
|
26
|
-
*
|
|
27
|
-
* const { Maybe } = require('monet');
|
|
28
|
-
*
|
|
29
|
-
* const add3 = (a, b, c) => a + b + c;
|
|
30
|
-
* const madd3 = RA.liftF(add3);
|
|
31
|
-
*
|
|
32
|
-
* madd3(Maybe.Some(10), Maybe.Some(15), Maybe.Some(17)); //=> Maybe.Some(42)
|
|
33
|
-
* madd3(Maybe.Some(10), Maybe.Nothing(), Maybe.Some(17)); //=> Maybe.Nothing()
|
|
34
|
-
*/
|
|
35
|
-
const liftF = curryN(1, (fn) => liftFN(fn.length, fn));
|
|
36
|
-
|
|
37
|
-
export default liftF;
|
package/src/liftFN.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { curry, head, slice, reduce, curryN, map } from 'ramda';
|
|
2
|
-
|
|
3
|
-
import ap from './internal/ap.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* "lifts" a function to be the specified arity, so that it may "map over" objects that satisfy
|
|
7
|
-
* the fantasy land Apply spec of algebraic structures.
|
|
8
|
-
*
|
|
9
|
-
* Lifting is specific for {@link https://github.com/scalaz/scalaz|scalaz} and {@link http://www.functionaljava.org/|functional java} implementations.
|
|
10
|
-
* Old version of fantasy land spec were not compatible with this approach,
|
|
11
|
-
* but as of fantasy land 1.0.0 Apply spec also adopted this approach.
|
|
12
|
-
*
|
|
13
|
-
* This function acts as interop for ramda <= 0.23.0 and {@link https://monet.github.io/monet.js/|monet.js}.
|
|
14
|
-
*
|
|
15
|
-
* More info {@link https://github.com/fantasyland/fantasy-land/issues/50|here}.
|
|
16
|
-
*
|
|
17
|
-
* @func liftFN
|
|
18
|
-
* @memberOf RA
|
|
19
|
-
* @since {@link https://char0n.github.io/ramda-adjunct/1.2.0|v1.2.0}
|
|
20
|
-
* @category Function
|
|
21
|
-
* @sig Apply a => Number -> (a... -> a) -> (a... -> a)
|
|
22
|
-
* @param {number} arity The arity of the lifter function
|
|
23
|
-
* @param {Function} fn The function to lift into higher context
|
|
24
|
-
* @return {Function} The lifted function
|
|
25
|
-
* @see {@link http://ramdajs.com/docs/#lift|R.lift}, {@link http://ramdajs.com/docs/#ap|R.ap}
|
|
26
|
-
* @example
|
|
27
|
-
*
|
|
28
|
-
* const { Maybe } = require('monet');
|
|
29
|
-
*
|
|
30
|
-
* const add3 = (a, b, c) => a + b + c;
|
|
31
|
-
* const madd3 = RA.liftFN(3, add3);
|
|
32
|
-
*
|
|
33
|
-
* madd3(Maybe.Some(10), Maybe.Some(15), Maybe.Some(17)); //=> Maybe.Some(42)
|
|
34
|
-
* madd3(Maybe.Some(10), Maybe.Nothing(), Maybe.Some(17)); //=> Maybe.Nothing()
|
|
35
|
-
*/
|
|
36
|
-
const liftFN = curry((arity, fn) => {
|
|
37
|
-
const lifted = curryN(arity, fn);
|
|
38
|
-
return curryN(arity, (...args) => {
|
|
39
|
-
const accumulator = map(lifted, head(args));
|
|
40
|
-
const apps = slice(1, Infinity, args);
|
|
41
|
-
return reduce(ap, accumulator, apps);
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
export default liftFN;
|
package/src/list.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { unapply, identity } from 'ramda';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Creates a list from arguments.
|
|
5
|
-
*
|
|
6
|
-
* @func list
|
|
7
|
-
* @memberOf RA
|
|
8
|
-
* @since {@link https://char0n.github.io/ramda-adjunct/1.1.0|v1.1.0}
|
|
9
|
-
* @category List
|
|
10
|
-
* @sig a... -> [a...]
|
|
11
|
-
* @param {...*} items The items of the feature list
|
|
12
|
-
* @return {Array} New list created from items
|
|
13
|
-
* @see {@link https://github.com/ramda/ramda/wiki/Cookbook#create-a-list-function|Ramda Cookbook}
|
|
14
|
-
* @example
|
|
15
|
-
*
|
|
16
|
-
* RA.list('a', 'b', 'c'); //=> ['a', 'b', 'c']
|
|
17
|
-
*/
|
|
18
|
-
const list = unapply(identity);
|
|
19
|
-
|
|
20
|
-
export default list;
|
package/src/mapIndexed.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { addIndex, map } from 'ramda';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* {@link http://ramdajs.com/docs/#map|R.map} function that more closely resembles Array.prototype.map.
|
|
5
|
-
* It takes two new parameters to its callback function: the current index, and the entire list.
|
|
6
|
-
*
|
|
7
|
-
* `mapIndexed` implementation is simple : `
|
|
8
|
-
* const mapIndexed = R.addIndex(R.map);
|
|
9
|
-
* `
|
|
10
|
-
* @func mapIndexed
|
|
11
|
-
* @memberOf RA
|
|
12
|
-
* @since {@link https://char0n.github.io/ramda-adjunct/2.5.0|v2.5.0}
|
|
13
|
-
* @category List
|
|
14
|
-
* @typedef Idx = Number
|
|
15
|
-
* @sig Functor f => ((a, Idx, f a) => b) => f a -> f b
|
|
16
|
-
* @param {Function} fn The function to be called on every element of the input `list`
|
|
17
|
-
* @param {Array} list The list to be iterated over
|
|
18
|
-
* @return {Array} The new list
|
|
19
|
-
* @see {@link http://ramdajs.com/docs/#addIndex|R.addIndex}, {@link http://ramdajs.com/docs/#map|R.map}
|
|
20
|
-
* @example
|
|
21
|
-
*
|
|
22
|
-
* RA.mapIndexed((val, idx, list) => idx + '-' + val, ['f', 'o', 'o', 'b', 'a', 'r']);
|
|
23
|
-
* //=> ['0-f', '1-o', '2-o', '3-b', '4-a', '5-r']
|
|
24
|
-
*/
|
|
25
|
-
const mapIndexed = addIndex(map);
|
|
26
|
-
|
|
27
|
-
export default mapIndexed;
|
package/src/mergePath.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { curry, over, lensPath, mergeLeft } from 'ramda';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Create a new object with the own properties of the object under the `path`
|
|
5
|
-
* merged with the own properties of the provided `source`.
|
|
6
|
-
* If a key exists in both objects, the value from the `source` object will be used.
|
|
7
|
-
*
|
|
8
|
-
* @func mergePath
|
|
9
|
-
* @memberOf RA
|
|
10
|
-
* @since {@link https://char0n.github.io/ramda-adjunct/1.18.0|v1.18.0}
|
|
11
|
-
* @category Object
|
|
12
|
-
* @sig [k] -> {a} -> {k: {a}} -> {k: {a}}
|
|
13
|
-
* @see {@link RA.mergeProp|mergeProp}
|
|
14
|
-
* @param {!Array} path The property path of the destination object
|
|
15
|
-
* @param {!Object} source The source object
|
|
16
|
-
* @param {!Object} obj The object that has destination object under corresponding property path
|
|
17
|
-
* @return {!Object} The new version of object
|
|
18
|
-
* @example
|
|
19
|
-
*
|
|
20
|
-
* RA.mergePath(
|
|
21
|
-
* ['outer', 'inner'],
|
|
22
|
-
* { foo: 3, bar: 4 },
|
|
23
|
-
* { outer: { inner: { foo: 2 } } }
|
|
24
|
-
* ); //=> { outer: { inner: { foo: 3, bar: 4 } }
|
|
25
|
-
*/
|
|
26
|
-
const mergePath = curry((path, source, obj) =>
|
|
27
|
-
over(lensPath(path), mergeLeft(source), obj)
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
export default mergePath;
|
package/src/mergePaths.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { curryN, pipe, mergeAll } from 'ramda';
|
|
2
|
-
|
|
3
|
-
import paths from './paths.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Merge objects under corresponding paths.
|
|
7
|
-
*
|
|
8
|
-
* @func mergePaths
|
|
9
|
-
* @memberOf RA
|
|
10
|
-
* @since {@link https://char0n.github.io/ramda-adjunct/1.17.0|v1.17.0}
|
|
11
|
-
* @category Object
|
|
12
|
-
* @sig [[k]] -> {k: {a}} -> {a}
|
|
13
|
-
* @see {@link RA.mergeProps|mergeProps}
|
|
14
|
-
* @param {!Array} paths The property paths to merge
|
|
15
|
-
* @param {!Object} obj The object to query
|
|
16
|
-
* @return {!Object} The object composed of merged property paths of obj
|
|
17
|
-
* @example
|
|
18
|
-
*
|
|
19
|
-
* const obj = {
|
|
20
|
-
* foo: { fooInner: { fooInner2: 1 } },
|
|
21
|
-
* bar: { barInner: 2 }
|
|
22
|
-
* };
|
|
23
|
-
*
|
|
24
|
-
* { ...obj.foo.fooInner, ...obj.bar }; //=> { fooInner2: 1, barInner: 2 }
|
|
25
|
-
* RA.mergePaths([['foo', 'fooInner'], ['bar']], obj); //=> { fooInner2: 1, barInner: 2 }
|
|
26
|
-
*/
|
|
27
|
-
const mergePaths = curryN(2, pipe(paths, mergeAll));
|
|
28
|
-
|
|
29
|
-
export default mergePaths;
|
package/src/mergeProp.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { curry, of } from 'ramda';
|
|
2
|
-
|
|
3
|
-
import mergePath from './mergePath.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Create a new object with the own properties of the object under the `p`
|
|
7
|
-
* merged with the own properties of the provided `source`.
|
|
8
|
-
* If a key exists in both objects, the value from the `source` object will be used.
|
|
9
|
-
*
|
|
10
|
-
* @func mergeProp
|
|
11
|
-
* @memberOf RA
|
|
12
|
-
* @since {@link https://char0n.github.io/ramda-adjunct/1.18.0|v1.18.0}
|
|
13
|
-
* @category Object
|
|
14
|
-
* @sig [k] -> {a} -> {k: {a}} -> {k: {a}}
|
|
15
|
-
* @see {@link RA.mergePath|mergePath}
|
|
16
|
-
* @param {!Array} p The property of the destination object
|
|
17
|
-
* @param {!Object} source The source object
|
|
18
|
-
* @param {!Object} obj The object that has destination object under corresponding property
|
|
19
|
-
* @return {!Object} The new version of object
|
|
20
|
-
* @example
|
|
21
|
-
*
|
|
22
|
-
* RA.mergeProp(
|
|
23
|
-
* 'outer',
|
|
24
|
-
* { foo: 3, bar: 4 },
|
|
25
|
-
* { outer: { foo: 2 } }
|
|
26
|
-
* ); //=> { outer: { foo: 3, bar: 4 } };
|
|
27
|
-
*/
|
|
28
|
-
const mergeProp = curry((p, subj, obj) => mergePath(of(Array, p), subj, obj));
|
|
29
|
-
|
|
30
|
-
export default mergeProp;
|