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
|
@@ -1,270 +0,0 @@
|
|
|
1
|
-
import { empty as emptyR } from 'ramda';
|
|
2
|
-
|
|
3
|
-
import * as fl from './mapping.js';
|
|
4
|
-
import {
|
|
5
|
-
applyTrait,
|
|
6
|
-
functorTrait,
|
|
7
|
-
setoidTrait,
|
|
8
|
-
semigroupTrait,
|
|
9
|
-
chainTrait,
|
|
10
|
-
ordTrait,
|
|
11
|
-
} from './traits.js';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* The simplest {@link https://github.com/fantasyland/fantasy-land|fantasy-land}
|
|
15
|
-
* compatible monad which attaches no information to values.
|
|
16
|
-
*
|
|
17
|
-
* The Identity type is a very simple type that has no interesting side effects and
|
|
18
|
-
* is effectively just a container of some value. So why does it exist ?
|
|
19
|
-
* The Identity type is often used as the base monad of a monad
|
|
20
|
-
* transformer when no other behaviour is required.
|
|
21
|
-
*
|
|
22
|
-
* @memberOf RA
|
|
23
|
-
* @implements
|
|
24
|
-
* {@link https://github.com/fantasyland/fantasy-land#apply|Apply},
|
|
25
|
-
* {@link https://github.com/fantasyland/fantasy-land#applicative|Applicative},
|
|
26
|
-
* {@link https://github.com/fantasyland/fantasy-land#functor|Functor},
|
|
27
|
-
* {@link https://github.com/fantasyland/fantasy-land#setoid|Setoid},
|
|
28
|
-
* {@link https://github.com/fantasyland/fantasy-land#semigroup|Semigroup},
|
|
29
|
-
* {@link https://github.com/fantasyland/fantasy-land#chain|Chain},
|
|
30
|
-
* {@link https://github.com/fantasyland/fantasy-land#monad|Monad},
|
|
31
|
-
* {@link https://github.com/fantasyland/fantasy-land#ord|Ord},
|
|
32
|
-
* {@link https://github.com/fantasyland/fantasy-land#monoid|Monoid*},
|
|
33
|
-
* {@link https://github.com/fantasyland/fantasy-land#contravariant|Contravariant}
|
|
34
|
-
* @since {@link https://char0n.github.io/ramda-adjunct/1.8.0|v1.8.0}
|
|
35
|
-
*/
|
|
36
|
-
class Identity {
|
|
37
|
-
/**
|
|
38
|
-
* Fantasy land {@link https://github.com/fantasyland/fantasy-land#applicative|Applicative} specification.
|
|
39
|
-
*
|
|
40
|
-
* @static
|
|
41
|
-
* @sig of :: Applicative f => a -> f a
|
|
42
|
-
* @param {*} value
|
|
43
|
-
* @returns {RA.Identity}
|
|
44
|
-
* @example
|
|
45
|
-
*
|
|
46
|
-
* const a = Identity.of(1); //=> Identity(1)
|
|
47
|
-
*/
|
|
48
|
-
static [fl.of](value) {
|
|
49
|
-
return new Identity(value);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
static of(value) {
|
|
53
|
-
return new Identity(value);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* @static
|
|
58
|
-
*/
|
|
59
|
-
static get ['@@type']() {
|
|
60
|
-
return 'RA/Identity';
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Private constructor. Use {@link RA.Identity.of|Identity.of} instead.
|
|
65
|
-
*
|
|
66
|
-
* @param {*} value
|
|
67
|
-
* @return {RA.Identity}
|
|
68
|
-
*/
|
|
69
|
-
constructor(value) {
|
|
70
|
-
this.value = value;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Catamorphism for a value.
|
|
75
|
-
* @returns {*}
|
|
76
|
-
* @example
|
|
77
|
-
*
|
|
78
|
-
* const a = Identity.of(1);
|
|
79
|
-
* a.get(); //=> 1
|
|
80
|
-
*/
|
|
81
|
-
get() {
|
|
82
|
-
return this.value;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Fantasy land {@link https://github.com/fantasyland/fantasy-land#apply|Apply} specification.
|
|
87
|
-
*
|
|
88
|
-
* @sig ap :: Apply f => f a ~> f (a -> b) -> f b
|
|
89
|
-
* @param {RA.Identity} applyWithFn
|
|
90
|
-
* @return {RA.Identity}
|
|
91
|
-
* @example
|
|
92
|
-
*
|
|
93
|
-
* const a = Identity.of(1);
|
|
94
|
-
* const b = Identity.of(1).map(a => b => a + b);
|
|
95
|
-
*
|
|
96
|
-
* a.ap(b); //=> Identity(2)
|
|
97
|
-
*/
|
|
98
|
-
[fl.ap](applyWithFn) {
|
|
99
|
-
return applyTrait[fl.ap].call(this, applyWithFn);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
ap(applyWithFn) {
|
|
103
|
-
return this[fl.ap](applyWithFn);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Fantasy land {@link https://github.com/fantasyland/fantasy-land#functor|Functor} specification.
|
|
108
|
-
*
|
|
109
|
-
* @sig map :: Functor f => f a ~> (a -> b) -> f b
|
|
110
|
-
* @param {Function} fn
|
|
111
|
-
* @return {RA.Identity}
|
|
112
|
-
* @example
|
|
113
|
-
*
|
|
114
|
-
* const a = Identity.of(1);
|
|
115
|
-
* a.map(a => a + 1); //=> Identity(2)
|
|
116
|
-
*/
|
|
117
|
-
[fl.map](fn) {
|
|
118
|
-
return functorTrait[fl.map].call(this, fn);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
map(fn) {
|
|
122
|
-
return this[fl.map](fn);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Fantasy land {@link https://github.com/fantasyland/fantasy-land#setoid|Setoid} specification.
|
|
127
|
-
*
|
|
128
|
-
* @sig equals :: Setoid a => a ~> a -> Boolean
|
|
129
|
-
* @param {RA.Identity} setoid
|
|
130
|
-
* @return {boolean}
|
|
131
|
-
* @example
|
|
132
|
-
*
|
|
133
|
-
* const a = Identity.of(1);
|
|
134
|
-
* const b = Identity.of(1);
|
|
135
|
-
* const c = Identity.of(2);
|
|
136
|
-
*
|
|
137
|
-
* a.equals(b); //=> true
|
|
138
|
-
* a.equals(c); //=> false
|
|
139
|
-
*/
|
|
140
|
-
[fl.equals](setoid) {
|
|
141
|
-
return setoidTrait[fl.equals].call(this, setoid);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
equals(setoid) {
|
|
145
|
-
return this[fl.equals](setoid);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Fantasy land {@link https://github.com/fantasyland/fantasy-land#semigroup|Semigroup} specification.
|
|
150
|
-
*
|
|
151
|
-
* @sig concat :: Semigroup a => a ~> a -> a
|
|
152
|
-
* @param {RA.Identity} semigroup
|
|
153
|
-
* @return {RA.Identity}
|
|
154
|
-
* @example
|
|
155
|
-
*
|
|
156
|
-
* const a = Identity.of(1);
|
|
157
|
-
* const b = Identity.of(1);
|
|
158
|
-
* a.concat(b); //=> 2
|
|
159
|
-
*
|
|
160
|
-
* const c = Identity.of('c');
|
|
161
|
-
* const d = Identity.of('d');
|
|
162
|
-
* c.concat(d); //=> 'cd'
|
|
163
|
-
*
|
|
164
|
-
* const e = Identity.of(['e']);
|
|
165
|
-
* const f = Identity.of(['f']);
|
|
166
|
-
* e.concat(f); //=> ['e', 'f']
|
|
167
|
-
*/
|
|
168
|
-
[fl.concat](semigroup) {
|
|
169
|
-
return semigroupTrait[fl.concat].call(this, semigroup);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
concat(semigroup) {
|
|
173
|
-
return this[fl.concat](semigroup);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* Fantasy land {@link https://github.com/fantasyland/fantasy-land#chain|Chain} specification.
|
|
178
|
-
*
|
|
179
|
-
* @sig chain :: Chain m => m a ~> (a -> m b) -> m b
|
|
180
|
-
* @param {Function} fn Function returning the value of the same {@link https://github.com/fantasyland/fantasy-land#semigroup|Chain}
|
|
181
|
-
* @return {RA.Identity}
|
|
182
|
-
* @example
|
|
183
|
-
*
|
|
184
|
-
* const a = Identity.of(1);
|
|
185
|
-
* const fn = val => Identity.of(val + 1);
|
|
186
|
-
*
|
|
187
|
-
* a.chain(fn).chain(fn); //=> Identity(3)
|
|
188
|
-
*/
|
|
189
|
-
[fl.chain](fn) {
|
|
190
|
-
return chainTrait[fl.chain].call(this, fn);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
chain(fn) {
|
|
194
|
-
return this[fl.chain](fn);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* Fantasy land {@link https://github.com/fantasyland/fantasy-land#ord|Ord} specification.
|
|
199
|
-
*
|
|
200
|
-
* @sig lte :: Ord a => a ~> a -> Boolean
|
|
201
|
-
* @param {RA.Identity} ord
|
|
202
|
-
* @return {boolean}
|
|
203
|
-
* @example
|
|
204
|
-
*
|
|
205
|
-
* const a = Identity.of(1);
|
|
206
|
-
* const b = Identity.of(1);
|
|
207
|
-
* const c = Identity.of(2);
|
|
208
|
-
*
|
|
209
|
-
* a.lte(b); //=> true
|
|
210
|
-
* a.lte(c); //=> true
|
|
211
|
-
* c.lte(a); //=> false
|
|
212
|
-
*/
|
|
213
|
-
[fl.lte](ord) {
|
|
214
|
-
return ordTrait[fl.lte].call(this, ord);
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
lte(ord) {
|
|
218
|
-
return this[fl.lte](ord);
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
/**
|
|
222
|
-
* Fantasy land {@link https://github.com/fantasyland/fantasy-land#monoid|Monoid*} specification.
|
|
223
|
-
* Partial implementation of Monoid specification. `empty` method on instance only, returning
|
|
224
|
-
* identity value of the wrapped type. Using `R.empty` under the hood.
|
|
225
|
-
*
|
|
226
|
-
*
|
|
227
|
-
* @sig empty :: Monoid m => () -> m
|
|
228
|
-
* @return {RA.Identity}
|
|
229
|
-
* @example
|
|
230
|
-
*
|
|
231
|
-
* const a = Identity.of('test');
|
|
232
|
-
* const i = a.empty();
|
|
233
|
-
*
|
|
234
|
-
* a.concat(i); //=> Identity('string');
|
|
235
|
-
* i.concat(a); //=> Identity('string');
|
|
236
|
-
*/
|
|
237
|
-
[fl.empty]() {
|
|
238
|
-
return this.constructor.of(emptyR(this.value));
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
empty() {
|
|
242
|
-
return this[fl.empty]();
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
/**
|
|
246
|
-
* Fantasy land {@link https://github.com/fantasyland/fantasy-land#contravariant|Contravariant} specification.
|
|
247
|
-
*
|
|
248
|
-
* @sig contramap :: Contravariant f => f a ~> (b -> a) -> f b
|
|
249
|
-
* @param {Function} fn
|
|
250
|
-
* @return {RA.Identity}
|
|
251
|
-
* @example
|
|
252
|
-
*
|
|
253
|
-
* const identity = a => a;
|
|
254
|
-
* const add1 = a => a + 1;
|
|
255
|
-
* const divide2 = a => a / 2;
|
|
256
|
-
*
|
|
257
|
-
* Identity.of(divide2).contramap(add1).get()(3); //=> 2
|
|
258
|
-
* Identity.of(identity).contramap(divide2).contramap(add1).get()(3); //=> 2
|
|
259
|
-
* Identity.of(identity).contramap(a => divide2(add1(a))).get()(3); //=> 2
|
|
260
|
-
*/
|
|
261
|
-
[fl.contramap](fn) {
|
|
262
|
-
return this.constructor.of((value) => this.value(fn(value)));
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
contramap(fn) {
|
|
266
|
-
return this[fl.contramap](fn);
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
export default Identity;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export const equals = 'fantasy-land/equals';
|
|
2
|
-
export const lte = 'fantasy-land/lte';
|
|
3
|
-
export const compose = 'fantasy-land/compose';
|
|
4
|
-
export const id = 'fantasy-land/id';
|
|
5
|
-
export const concat = 'fantasy-land/concat';
|
|
6
|
-
export const empty = 'fantasy-land/empty';
|
|
7
|
-
export const map = 'fantasy-land/map';
|
|
8
|
-
export const contramap = 'fantasy-land/contramap';
|
|
9
|
-
export const ap = 'fantasy-land/ap';
|
|
10
|
-
export const of = 'fantasy-land/of';
|
|
11
|
-
export const alt = 'fantasy-land/alt';
|
|
12
|
-
export const zero = 'fantasy-land/zero';
|
|
13
|
-
export const reduce = 'fantasy-land/reduce';
|
|
14
|
-
export const traverse = 'fantasy-land/traverse';
|
|
15
|
-
export const chain = 'fantasy-land/chain';
|
|
16
|
-
export const chainRec = 'fantasy-land/chainRec';
|
|
17
|
-
export const extend = 'fantasy-land/extend';
|
|
18
|
-
export const extract = 'fantasy-land/extract';
|
|
19
|
-
export const bimap = 'fantasy-land/bimap';
|
|
20
|
-
export const promap = 'fantasy-land/promap';
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { equals, pathSatisfies } from 'ramda';
|
|
2
|
-
|
|
3
|
-
import isString from '../isString.js';
|
|
4
|
-
import isNumber from '../isNumber.js';
|
|
5
|
-
import isFunction from '../isFunction.js';
|
|
6
|
-
import { isSameType } from './util.js';
|
|
7
|
-
import * as fl from './mapping.js';
|
|
8
|
-
|
|
9
|
-
export const functorTrait = {
|
|
10
|
-
[fl.map](fn) {
|
|
11
|
-
return this.constructor[fl.of](fn(this.value));
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export const applyTrait = {
|
|
16
|
-
[fl.ap](applyWithFn) {
|
|
17
|
-
return applyWithFn.map((fn) => fn(this.value));
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export const setoidTrait = {
|
|
22
|
-
[fl.equals](setoid) {
|
|
23
|
-
return isSameType(this, setoid) && equals(this.value, setoid.value);
|
|
24
|
-
},
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export const semigroupTrait = {
|
|
28
|
-
[fl.concat](semigroup) {
|
|
29
|
-
let concatenatedValue = this.value;
|
|
30
|
-
|
|
31
|
-
if (isString(this.value) || isNumber(this.value)) {
|
|
32
|
-
concatenatedValue = this.value + semigroup.value;
|
|
33
|
-
} else if (pathSatisfies(isFunction, ['value', fl.concat], this)) {
|
|
34
|
-
concatenatedValue = this.value[fl.concat](semigroup.value);
|
|
35
|
-
} else if (pathSatisfies(isFunction, ['value', 'concat'], this)) {
|
|
36
|
-
concatenatedValue = this.value.concat(semigroup.value);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return this.constructor[fl.of](concatenatedValue);
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export const chainTrait = {
|
|
44
|
-
[fl.chain](fn) {
|
|
45
|
-
const newChain = fn(this.value);
|
|
46
|
-
|
|
47
|
-
return isSameType(this, newChain) ? newChain : this;
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export const ordTrait = {
|
|
52
|
-
[fl.lte](ord) {
|
|
53
|
-
return (
|
|
54
|
-
isSameType(this, ord) && (this.value < ord.value || this[fl.equals](ord))
|
|
55
|
-
);
|
|
56
|
-
},
|
|
57
|
-
};
|
package/src/fantasy-land/util.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useWith,
|
|
3
|
-
curry,
|
|
4
|
-
curryN,
|
|
5
|
-
equals,
|
|
6
|
-
path,
|
|
7
|
-
either,
|
|
8
|
-
complement,
|
|
9
|
-
} from 'ramda';
|
|
10
|
-
|
|
11
|
-
// type :: Monad a => a -> String
|
|
12
|
-
export const type = either(path(['@@type']), path(['constructor', '@@type']));
|
|
13
|
-
|
|
14
|
-
// typeEquals :: Monad a => String -> a -> Boolean
|
|
15
|
-
export const typeEquals = curry(
|
|
16
|
-
(typeIdent, monad) => type(monad) === typeIdent
|
|
17
|
-
);
|
|
18
|
-
|
|
19
|
-
// isSameType :: (Monad a, Monad b) => a -> b -> Boolean
|
|
20
|
-
export const isSameType = curryN(2, useWith(equals, [type, type]));
|
|
21
|
-
|
|
22
|
-
// isNotSameType :: (Monad a, Monad b) => a -> b -> Boolean
|
|
23
|
-
export const isNotSameType = complement(isSameType);
|
package/src/filterIndexed.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { addIndex, filter } from 'ramda';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* {@link http://ramdajs.com/docs/#filter|R.filter} function that more closely resembles `Array.prototype.filter`.
|
|
5
|
-
* It takes two new parameters to its callback function: the current index, and the entire list.
|
|
6
|
-
*
|
|
7
|
-
* `filterIndexed` implementation is simple: `
|
|
8
|
-
* const filterIndexed = R.addIndex(R.filter);
|
|
9
|
-
* `
|
|
10
|
-
*
|
|
11
|
-
* @func filterIndexed
|
|
12
|
-
* @memberOf RA
|
|
13
|
-
* @since {@link https://char0n.github.io/ramda-adjunct/2.31.0|v2.31.0}
|
|
14
|
-
* @category List
|
|
15
|
-
* @typedef Idx = Number
|
|
16
|
-
* @sig Filterable f => ((a, Idx, f a) -> Boolean) -> f a -> f a
|
|
17
|
-
* @param {Function} pred The predicate function
|
|
18
|
-
* @param {Array} list The collection to filter
|
|
19
|
-
* @return {Array} Filterable
|
|
20
|
-
* @see {@link http://ramdajs.com/docs/#addIndex|R.addIndex}, {@link http://ramdajs.com/docs/#filter|R.filter}
|
|
21
|
-
* @example
|
|
22
|
-
*
|
|
23
|
-
* const isValueGtIndex = (val, idx) => val > idx;
|
|
24
|
-
* RA.filterIndexed(isValueGtIndex, [5, 4, 3, 2, 1, 0]); //=> [5, 4, 3]
|
|
25
|
-
*/
|
|
26
|
-
const filterIndexed = addIndex(filter);
|
|
27
|
-
|
|
28
|
-
export default filterIndexed;
|
package/src/findOr.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { pipe, curry, find, defaultTo } from 'ramda';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Returns the first element of the list which matches the predicate.
|
|
5
|
-
* Returns default value if no element matches or matched element is `null`, `undefined` or `NaN`.
|
|
6
|
-
* Dispatches to the find method of the second argument, if present.
|
|
7
|
-
* Acts as a transducer if a transformer is given in list position.
|
|
8
|
-
*
|
|
9
|
-
* @func findOr
|
|
10
|
-
* @memberOf RA
|
|
11
|
-
* @since {@link https://char0n.github.io/ramda-adjunct/2.32.0|v2.32.0}
|
|
12
|
-
* @category List
|
|
13
|
-
* @sig a -> (b -> Boolean) -> [b] -> b | a
|
|
14
|
-
* @param {*} defaultValue The default value
|
|
15
|
-
* @param {Function} fn The predicate function used to determine if the element is the desired one.
|
|
16
|
-
* @param {Array} list The array to consider.
|
|
17
|
-
* @return {*} The element found, or the default value.
|
|
18
|
-
* @see {@link http://ramdajs.com/docs/#defaultTo|R.defaultTo}, {@link http://ramdajs.com/docs/#find|R.find}
|
|
19
|
-
* @example
|
|
20
|
-
*
|
|
21
|
-
* RA.findOr(1, isUndefined, [1, 2, undefined]); // => 1
|
|
22
|
-
* RA.findOr(1, val => val === 2, [1, 2, undefined]); // => 2
|
|
23
|
-
* RA.findOr(1, val => val === 3, [1, 2, undefined]); // => 1
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
const findOr = curry((defaultVal, fn, list) =>
|
|
27
|
-
pipe(find(fn), defaultTo(defaultVal))(list)
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
export default findOr;
|
package/src/flattenDepth.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { curry } from 'ramda';
|
|
2
|
-
|
|
3
|
-
import _makeFlat from './internal/makeFlat.js';
|
|
4
|
-
|
|
5
|
-
const flatten1 = _makeFlat(false);
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Flattens the list to the specified depth.
|
|
9
|
-
*
|
|
10
|
-
* @func flattenDepth
|
|
11
|
-
* @memberOf RA
|
|
12
|
-
* @since {@link https://char0n.github.io/ramda-adjunct/2.19.0|v2.19.0}
|
|
13
|
-
* @category List
|
|
14
|
-
* @sig Number -> [a] -> [b]
|
|
15
|
-
* @param {!number} depth The maximum recursion depth
|
|
16
|
-
* @param {!Array} list The array to flatten
|
|
17
|
-
* @return {!Array} Returns the new flattened array
|
|
18
|
-
* @see {@link http://ramdajs.com/docs/#flatten|R.flatten}, {@link http://ramdajs.com/docs/#unnest|R.unnest}
|
|
19
|
-
* @example
|
|
20
|
-
*
|
|
21
|
-
* RA.flattenDepth(
|
|
22
|
-
* 2,
|
|
23
|
-
* [1, [2], [3, [4, 5], 6, [[[7], 8]]], 9, 10]
|
|
24
|
-
* ); //=> [1, 2, 3, 4, 5, 6, [[7], 8], 9, 10];
|
|
25
|
-
*/
|
|
26
|
-
const flattenDepth = curry((depth, list) => {
|
|
27
|
-
let currentDept = depth;
|
|
28
|
-
let flatList = [...list];
|
|
29
|
-
|
|
30
|
-
while (currentDept > 0) {
|
|
31
|
-
flatList = flatten1(flatList);
|
|
32
|
-
|
|
33
|
-
currentDept -= 1;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return flatList;
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
export default flattenDepth;
|
package/src/flattenPath.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { pathOr, curry, mergeRight } from 'ramda';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Flattens a property path so that its fields are spread out into the provided object.
|
|
5
|
-
* It's like {@link RA.spreadPath|spreadPath}, but preserves object under the property path.
|
|
6
|
-
*
|
|
7
|
-
* @func flattenPath
|
|
8
|
-
* @memberOf RA
|
|
9
|
-
* @since {@link https://char0n.github.io/ramda-adjunct/1.19.0|v1.19.0}
|
|
10
|
-
* @category Object
|
|
11
|
-
* @typedef Idx = String | Int
|
|
12
|
-
* @sig [Idx] -> {k: v} -> {k: v}
|
|
13
|
-
* @param {!Array.<string|number>} path The property path to flatten
|
|
14
|
-
* @param {!Object} obj The provided object
|
|
15
|
-
* @return {!Object} The flattened object
|
|
16
|
-
* @see {@link RA.flattenProp|flattenProp}, {@link RA.spreadPath|spreadPath}
|
|
17
|
-
* @example
|
|
18
|
-
*
|
|
19
|
-
* RA.flattenPath(
|
|
20
|
-
* ['b1', 'b2'],
|
|
21
|
-
* { a: 1, b1: { b2: { c: 3, d: 4 } } }
|
|
22
|
-
* ); // => { a: 1, c: 3, d: 4, b1: { b2: { c: 3, d: 4 } } };
|
|
23
|
-
*/
|
|
24
|
-
const flattenPath = curry((path, obj) =>
|
|
25
|
-
mergeRight(obj, pathOr({}, path, obj))
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
export default flattenPath;
|
package/src/flattenProp.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { of, curry } from 'ramda';
|
|
2
|
-
|
|
3
|
-
import flattenPath from './flattenPath.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Flattens a property so that its fields are spread out into the provided object.
|
|
7
|
-
* It's like {@link RA.spreadProp|spreadProp}, but preserves object under the property path.
|
|
8
|
-
*
|
|
9
|
-
* @func flattenProp
|
|
10
|
-
* @memberOf RA
|
|
11
|
-
* @since {@link https://char0n.github.io/ramda-adjunct/1.19.0|v1.19.0}
|
|
12
|
-
* @category Object
|
|
13
|
-
* @typedef Idx = String | Int
|
|
14
|
-
* @sig [Idx] -> {k: v} -> {k: v}
|
|
15
|
-
* @param {!string|number} prop The property to flatten
|
|
16
|
-
* @param {!Object} obj The provided object
|
|
17
|
-
* @return {!Object} The flattened object
|
|
18
|
-
* @see {@link RA.flattenPath|flattenPath}, {@link RA.spreadProp|spreadProp}
|
|
19
|
-
* @example
|
|
20
|
-
*
|
|
21
|
-
* RA.flattenProp(
|
|
22
|
-
* 'b',
|
|
23
|
-
* { a: 1, b: { c: 3, d: 4 } }
|
|
24
|
-
* ); // => { a: 1, c: 3, d: 4, b: { c: 3, d: 4 } };
|
|
25
|
-
*/
|
|
26
|
-
const flattenProp = curry((prop, obj) => flattenPath(of(Array, prop), obj));
|
|
27
|
-
|
|
28
|
-
export default flattenProp;
|
package/src/floor.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { bind, curryN } from 'ramda';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Returns the largest integer less than or equal to a given number.
|
|
5
|
-
*
|
|
6
|
-
* Note: floor(null) returns integer 0 and do not give a NaN error.
|
|
7
|
-
*
|
|
8
|
-
* @func floor
|
|
9
|
-
* @memberOf RA
|
|
10
|
-
* @since {@link https://char0n.github.io/ramda-adjunct/2.15.0|v2.15.0}
|
|
11
|
-
* @category Math
|
|
12
|
-
* @sig Number -> Number
|
|
13
|
-
* @param {number} number The number to floor
|
|
14
|
-
* @return {number} A number representing the largest integer less than or equal to the specified number
|
|
15
|
-
* @example
|
|
16
|
-
*
|
|
17
|
-
* RA.floor(45.95); //=> 45
|
|
18
|
-
* RA.floor(45.05); //=> 45
|
|
19
|
-
* RA.floor(4); //=> 4
|
|
20
|
-
* RA.floor(-45.05); //=> -46
|
|
21
|
-
* RA.floor(-45.95); //=> -46
|
|
22
|
-
* RA.floor(null); //=> 0
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
const floor = curryN(1, bind(Math.floor, Math));
|
|
26
|
-
|
|
27
|
-
export default floor;
|
package/src/fnull.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { isNil, curryN, curry, apply } from 'ramda';
|
|
2
|
-
|
|
3
|
-
import defaultWhen from './defaultWhen.js';
|
|
4
|
-
import mapIndexed from './mapIndexed.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Returns a function which is called with the given arguments. If any of the given arguments are null or undefined,
|
|
8
|
-
* the corresponding default value for that argument is used instead.
|
|
9
|
-
*
|
|
10
|
-
* @func fnull
|
|
11
|
-
* @memberOf RA
|
|
12
|
-
* @category Function
|
|
13
|
-
* @sig (a ... -> b) -> [c] -> a ... | c -> b
|
|
14
|
-
* @param {Function} function to be executed
|
|
15
|
-
* @param {Array} defaults default arguments
|
|
16
|
-
* @return {Function} will apply provided arguments or default ones
|
|
17
|
-
* @example
|
|
18
|
-
*
|
|
19
|
-
* const addDefaults = RA.fnull((a, b) => a + b, [4, 5])
|
|
20
|
-
*
|
|
21
|
-
* addDefaults(1, 2); // => 3
|
|
22
|
-
* addDefaults(null, 2); // => 6
|
|
23
|
-
* addDefaults(2, null); // => 7
|
|
24
|
-
* addDefaults(undefined, undefined); // => 9
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
const fnull = curry((fn, defaults) =>
|
|
28
|
-
curryN(fn.length, (...args) => {
|
|
29
|
-
const argsWithDefaults = mapIndexed(
|
|
30
|
-
(val, idx) => defaultWhen(isNil, defaults[idx], val),
|
|
31
|
-
args
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
return apply(fn, argsWithDefaults);
|
|
35
|
-
})
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
export default fnull;
|
package/src/inRange.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { ifElse, curry, useWith, both, gte, lte, gt } from 'ramda';
|
|
2
|
-
|
|
3
|
-
const inRangeImp = ifElse(
|
|
4
|
-
gte,
|
|
5
|
-
() => {
|
|
6
|
-
throw new Error(
|
|
7
|
-
'low must not be greater than high in inRange(low, high, value)'
|
|
8
|
-
);
|
|
9
|
-
},
|
|
10
|
-
useWith(both, [lte, gt])
|
|
11
|
-
);
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Checks if `value` is between `low` and up to but not including `high`.
|
|
15
|
-
*
|
|
16
|
-
* @func inRange
|
|
17
|
-
* @memberOf RA
|
|
18
|
-
* @since {@link https://char0n.github.io/ramda-adjunct/2.7.0|v2.7.0}
|
|
19
|
-
* @category Relation
|
|
20
|
-
* @sig Number -> Number -> Number -> Boolean
|
|
21
|
-
* @param {number} low Start of the range
|
|
22
|
-
* @param {number} high The end of the range
|
|
23
|
-
* @param {number} value The value to test
|
|
24
|
-
* @return {boolean}
|
|
25
|
-
* @throws {Error} When `low` is greater than or equal to `high`
|
|
26
|
-
* @example
|
|
27
|
-
*
|
|
28
|
-
* RA.inRange(0, 5, 3); //=> true
|
|
29
|
-
* RA.inRange(0, 5, 0); //=> true
|
|
30
|
-
* RA.inRange(0, 5, 4); //=> true
|
|
31
|
-
* RA.inRange(0, 5, 5); //=> false
|
|
32
|
-
* RA.inRange(0, 5, -1); //=> false
|
|
33
|
-
*/
|
|
34
|
-
export default curry((low, high, value) => inRangeImp(low, high)(value));
|
package/src/included.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { flip, includes } from 'ramda';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Returns true if the specified value is equal, in R.equals terms,
|
|
5
|
-
* to at least one element of the given list or false otherwise.
|
|
6
|
-
* Given list can be a string.
|
|
7
|
-
*
|
|
8
|
-
* Like {@link http://ramdajs.com/docs/#includes|R.includes} but with argument order reversed.
|
|
9
|
-
*
|
|
10
|
-
* @func included
|
|
11
|
-
* @memberOf RA
|
|
12
|
-
* @since {@link https://char0n.github.io/ramda-adjunct/3.0.0|v3.0.0}
|
|
13
|
-
* @category List
|
|
14
|
-
* @sig [a] -> a -> Boolean
|
|
15
|
-
* @param {Array|String} list The list to consider
|
|
16
|
-
* @param {*} a The item to compare against
|
|
17
|
-
* @return {boolean} Returns Boolean `true` if an equivalent item is in the list or `false` otherwise
|
|
18
|
-
* @see {@link http://ramdajs.com/docs/#includes|R.includes}
|
|
19
|
-
* @example
|
|
20
|
-
*
|
|
21
|
-
* RA.included([1, 2, 3], 3); //=> true
|
|
22
|
-
* RA.included([1, 2, 3], 4); //=> false
|
|
23
|
-
* RA.included([{ name: 'Fred' }], { name: 'Fred' }); //=> true
|
|
24
|
-
* RA.included([[42]], [42]); //=> true
|
|
25
|
-
*/
|
|
26
|
-
const included = flip(includes);
|
|
27
|
-
|
|
28
|
-
export default included;
|