ramda-adjunct 2.34.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/.nvmrc +1 -0
- package/CHANGELOG.md +973 -0
- package/LICENSE.md +25 -0
- package/README.md +297 -0
- package/SECURITY.md +43 -0
- package/dist/RA.node.js +11172 -0
- package/dist/RA.node.min.js +2 -0
- package/dist/RA.node.min.js.LICENSE.txt +22 -0
- package/dist/RA.web.js +11172 -0
- package/dist/RA.web.min.js +2 -0
- package/dist/RA.web.min.js.LICENSE.txt +22 -0
- package/dist/RA.web.standalone.js +27797 -0
- package/dist/RA.web.standalone.min.js +2 -0
- package/dist/RA.web.standalone.min.js.LICENSE.txt +22 -0
- package/es/Y.js +38 -0
- package/es/allEqual.js +25 -0
- package/es/allEqualTo.js +26 -0
- package/es/allIdentical.js +24 -0
- package/es/allIdenticalTo.js +26 -0
- package/es/allP.js +26 -0
- package/es/allSettledP.js +29 -0
- package/es/allUnique.js +23 -0
- package/es/anyP.js +28 -0
- package/es/appendFlipped.js +23 -0
- package/es/argsPass.js +38 -0
- package/es/async.js +57 -0
- package/es/cata.js +101 -0
- package/es/catchP.js +24 -0
- package/es/ceil.js +26 -0
- package/es/compact.js +21 -0
- package/es/concatAll.js +30 -0
- package/es/concatRight.js +29 -0
- package/es/contained.js +29 -0
- package/es/curryRight.js +24 -0
- package/es/curryRightN.js +32 -0
- package/es/defaultWhen.js +25 -0
- package/es/delayP.js +44 -0
- package/es/dispatch.js +75 -0
- package/es/divideNum.js +19 -0
- package/es/dropArgs.js +22 -0
- package/es/ensureArray.js +22 -0
- package/es/escapeRegExp.js +20 -0
- package/es/fantasy-land/Identity.js +309 -0
- package/es/fantasy-land/mapping.js +20 -0
- package/es/fantasy-land/traits.js +41 -0
- package/es/fantasy-land/util.js +11 -0
- package/es/filterIndexed.js +27 -0
- package/es/findOr.js +28 -0
- package/es/flattenDepth.js +50 -0
- package/es/flattenPath.js +27 -0
- package/es/flattenProp.js +28 -0
- package/es/floor.js +25 -0
- package/es/fnull.js +37 -0
- package/es/hasPath.js +38 -0
- package/es/inRange.js +29 -0
- package/es/index.js +252 -0
- package/es/internal/ap.js +20 -0
- package/es/internal/compareLength.js +5 -0
- package/es/internal/isOfTypeObject.js +7 -0
- package/es/internal/makeFlat.js +46 -0
- package/es/internal/ponyfills/Array.from.js +40 -0
- package/es/internal/ponyfills/Math.sign.js +5 -0
- package/es/internal/ponyfills/Math.trunc.js +14 -0
- package/es/internal/ponyfills/Number.MAX_SAFE_INTEGER.js +2 -0
- package/es/internal/ponyfills/Number.MIN_SAFE_INTEGER.js +2 -0
- package/es/internal/ponyfills/Number.isFinite.js +5 -0
- package/es/internal/ponyfills/Number.isInteger.js +4 -0
- package/es/internal/ponyfills/Number.isNaN.js +5 -0
- package/es/internal/ponyfills/Number.isSafeInteger.js +7 -0
- package/es/internal/ponyfills/Promise.allSettled.js +38 -0
- package/es/internal/ponyfills/Promise.any.js +77 -0
- package/es/internal/ponyfills/String.padEnd.js +24 -0
- package/es/internal/ponyfills/String.padStart.js +26 -0
- package/es/internal/ponyfills/String.repeat.js +46 -0
- package/es/internal/ponyfills/String.replaceAll.js +34 -0
- package/es/internal/ponyfills/String.trimEnd.js +3 -0
- package/es/internal/ponyfills/String.trimStart.js +3 -0
- package/es/invoke.js +20 -0
- package/es/invokeArgs.js +30 -0
- package/es/isArray.js +22 -0
- package/es/isArrayLike.js +87 -0
- package/es/isAsyncFunction.js +22 -0
- package/es/isBigInt.js +23 -0
- package/es/isBoolean.js +21 -0
- package/es/isDate.js +20 -0
- package/es/isEmptyArray.js +26 -0
- package/es/isEmptyString.js +27 -0
- package/es/isError.js +20 -0
- package/es/isEven.js +29 -0
- package/es/isFalse.js +29 -0
- package/es/isFalsy.js +26 -0
- package/es/isFinite.js +33 -0
- package/es/isFloat.js +34 -0
- package/es/isFunction.js +26 -0
- package/es/isGeneratorFunction.js +33 -0
- package/es/isIndexed.js +21 -0
- package/es/isInteger.js +35 -0
- package/es/isInteger32.js +28 -0
- package/es/isIterable.js +33 -0
- package/es/isMap.js +23 -0
- package/es/isNaN.js +41 -0
- package/es/isNaturalNumber.js +25 -0
- package/es/isNegative.js +25 -0
- package/es/isNegativeZero.js +22 -0
- package/es/isNilOrEmpty.js +25 -0
- package/es/isNonEmptyArray.js +27 -0
- package/es/isNonEmptyString.js +30 -0
- package/es/isNonNegative.js +28 -0
- package/es/isNonPositive.js +28 -0
- package/es/isNotArray.js +22 -0
- package/es/isNotArrayLike.js +24 -0
- package/es/isNotAsyncFunction.js +27 -0
- package/es/isNotBoolean.js +22 -0
- package/es/isNotDate.js +21 -0
- package/es/isNotEmpty.js +25 -0
- package/es/isNotFinite.js +29 -0
- package/es/isNotFloat.js +33 -0
- package/es/isNotFunction.js +29 -0
- package/es/isNotGeneratorFunction.js +27 -0
- package/es/isNotInteger.js +34 -0
- package/es/isNotMap.js +24 -0
- package/es/isNotNaN.js +35 -0
- package/es/isNotNil.js +22 -0
- package/es/isNotNilOrEmpty.js +26 -0
- package/es/isNotNull.js +22 -0
- package/es/isNotNumber.js +23 -0
- package/es/isNotObj.js +29 -0
- package/es/isNotObjLike.js +29 -0
- package/es/isNotPair.js +25 -0
- package/es/isNotPlainObj.js +35 -0
- package/es/isNotPrimitive.js +22 -0
- package/es/isNotRegExp.js +22 -0
- package/es/isNotSet.js +23 -0
- package/es/isNotString.js +21 -0
- package/es/isNotUndefined.js +22 -0
- package/es/isNotValidDate.js +22 -0
- package/es/isNotValidNumber.js +25 -0
- package/es/isNull.js +21 -0
- package/es/isNumber.js +23 -0
- package/es/isObj.js +31 -0
- package/es/isObjLike.js +30 -0
- package/es/isOdd.js +24 -0
- package/es/isPair.js +25 -0
- package/es/isPlainObj.js +52 -0
- package/es/isPositive.js +24 -0
- package/es/isPositiveZero.js +22 -0
- package/es/isPrimitive.js +31 -0
- package/es/isPromise.js +27 -0
- package/es/isPrototypeOf.js +34 -0
- package/es/isRegExp.js +21 -0
- package/es/isSafeInteger.js +34 -0
- package/es/isSentinelValue.js +26 -0
- package/es/isSet.js +22 -0
- package/es/isSparseArray.js +30 -0
- package/es/isString.js +20 -0
- package/es/isSymbol.js +27 -0
- package/es/isThenable.js +26 -0
- package/es/isTrue.js +25 -0
- package/es/isTruthy.js +27 -0
- package/es/isUndefined.js +22 -0
- package/es/isValidDate.js +26 -0
- package/es/isValidNumber.js +26 -0
- package/es/lastP.js +63 -0
- package/es/lengthEq.js +22 -0
- package/es/lengthGt.js +22 -0
- package/es/lengthGte.js +24 -0
- package/es/lengthLt.js +22 -0
- package/es/lengthLte.js +23 -0
- package/es/lengthNotEq.js +22 -0
- package/es/lensEq.js +27 -0
- package/es/lensIso.js +55 -0
- package/es/lensNotEq.js +26 -0
- package/es/lensNotSatisfy.js +28 -0
- package/es/lensSatisfies.js +31 -0
- package/es/lensTraverse.js +42 -0
- package/es/liftF.js +37 -0
- package/es/liftFN.js +47 -0
- package/es/list.js +19 -0
- package/es/mapIndexed.js +26 -0
- package/es/mergePath.js +30 -0
- package/es/mergePaths.js +27 -0
- package/es/mergeProp.js +30 -0
- package/es/mergeProps.js +26 -0
- package/es/mergeRight.js +26 -0
- package/es/move.js +25 -0
- package/es/nand.js +27 -0
- package/es/neither.js +39 -0
- package/es/noneP.js +28 -0
- package/es/nonePass.js +31 -0
- package/es/noop.js +19 -0
- package/es/nor.js +28 -0
- package/es/notAllPass.js +31 -0
- package/es/notAllUnique.js +23 -0
- package/es/notBoth.js +39 -0
- package/es/notEqual.js +30 -0
- package/es/omitBy.js +26 -0
- package/es/omitIndexes.js +27 -0
- package/es/overlaps.js +29 -0
- package/es/padCharsEnd.js +31 -0
- package/es/padCharsStart.js +29 -0
- package/es/padEnd.js +24 -0
- package/es/padStart.js +22 -0
- package/es/pathNotEq.js +32 -0
- package/es/pathOrLazy.js +25 -0
- package/es/paths.js +27 -0
- package/es/pickIndexes.js +30 -0
- package/es/propNotEq.js +29 -0
- package/es/rangeStep.js +36 -0
- package/es/reduceIndexed.js +30 -0
- package/es/reduceP.js +111 -0
- package/es/reduceRightP.js +117 -0
- package/es/rejectP.js +23 -0
- package/es/renameKeyWith.js +28 -0
- package/es/renameKeys.js +42 -0
- package/es/renameKeysWith.js +26 -0
- package/es/repeatStr.js +24 -0
- package/es/replaceAll.js +29 -0
- package/es/resolveP.js +29 -0
- package/es/round.js +24 -0
- package/es/seq.js +44 -0
- package/es/sign.js +27 -0
- package/es/skipTake.js +22 -0
- package/es/sliceFrom.js +22 -0
- package/es/sliceTo.js +22 -0
- package/es/sortByProps.js +52 -0
- package/es/spreadPath.js +25 -0
- package/es/spreadProp.js +25 -0
- package/es/stubArray.js +19 -0
- package/es/stubNull.js +18 -0
- package/es/stubObj.js +20 -0
- package/es/stubString.js +18 -0
- package/es/stubUndefined.js +19 -0
- package/es/subtractNum.js +19 -0
- package/es/thenCatchP.js +26 -0
- package/es/thenP.js +28 -0
- package/es/toArray.js +27 -0
- package/es/toInteger32.js +24 -0
- package/es/toUinteger32.js +26 -0
- package/es/trimCharsEnd.js +22 -0
- package/es/trimCharsStart.js +22 -0
- package/es/trimEnd.js +23 -0
- package/es/trimStart.js +22 -0
- package/es/trunc.js +27 -0
- package/es/unzipObjWith.js +26 -0
- package/es/viewOr.js +30 -0
- package/es/weave.js +36 -0
- package/es/weaveLazy.js +38 -0
- package/es/zipObjWith.js +26 -0
- package/lib/Y.js +44 -0
- package/lib/allEqual.js +35 -0
- package/lib/allEqualTo.js +32 -0
- package/lib/allIdentical.js +33 -0
- package/lib/allIdenticalTo.js +32 -0
- package/lib/allP.js +32 -0
- package/lib/allSettledP.js +41 -0
- package/lib/allUnique.js +32 -0
- package/lib/anyP.js +47 -0
- package/lib/appendFlipped.js +29 -0
- package/lib/argsPass.js +48 -0
- package/lib/async.js +67 -0
- package/lib/cata.js +110 -0
- package/lib/catchP.js +30 -0
- package/lib/ceil.js +32 -0
- package/lib/compact.js +30 -0
- package/lib/concatAll.js +40 -0
- package/lib/concatRight.js +35 -0
- package/lib/contained.js +35 -0
- package/lib/curryRight.js +33 -0
- package/lib/curryRightN.js +38 -0
- package/lib/defaultWhen.js +31 -0
- package/lib/delayP.js +54 -0
- package/lib/dispatch.js +50 -0
- package/lib/divideNum.js +25 -0
- package/lib/dropArgs.js +28 -0
- package/lib/ensureArray.js +31 -0
- package/lib/escapeRegExp.js +29 -0
- package/lib/fantasy-land/Identity.js +323 -0
- package/lib/fantasy-land/mapping.js +44 -0
- package/lib/fantasy-land/traits.js +77 -0
- package/lib/fantasy-land/util.js +21 -0
- package/lib/filterIndexed.js +33 -0
- package/lib/findOr.js +34 -0
- package/lib/flattenDepth.js +58 -0
- package/lib/flattenPath.js +33 -0
- package/lib/flattenProp.js +37 -0
- package/lib/floor.js +31 -0
- package/lib/fnull.js +47 -0
- package/lib/hasPath.js +47 -0
- package/lib/inRange.js +37 -0
- package/lib/index.js +863 -0
- package/lib/internal/ap.js +37 -0
- package/lib/internal/compareLength.js +12 -0
- package/lib/internal/isOfTypeObject.js +13 -0
- package/lib/internal/makeFlat.js +54 -0
- package/lib/internal/ponyfills/Array.from.js +52 -0
- package/lib/internal/ponyfills/Math.sign.js +11 -0
- package/lib/internal/ponyfills/Math.trunc.js +22 -0
- package/lib/internal/ponyfills/Number.MAX_SAFE_INTEGER.js +7 -0
- package/lib/internal/ponyfills/Number.MIN_SAFE_INTEGER.js +7 -0
- package/lib/internal/ponyfills/Number.isFinite.js +15 -0
- package/lib/internal/ponyfills/Number.isInteger.js +14 -0
- package/lib/internal/ponyfills/Number.isNaN.js +15 -0
- package/lib/internal/ponyfills/Number.isSafeInteger.js +18 -0
- package/lib/internal/ponyfills/Promise.allSettled.js +48 -0
- package/lib/internal/ponyfills/Promise.any.js +89 -0
- package/lib/internal/ponyfills/String.padEnd.js +34 -0
- package/lib/internal/ponyfills/String.padStart.js +36 -0
- package/lib/internal/ponyfills/String.repeat.js +55 -0
- package/lib/internal/ponyfills/String.replaceAll.js +44 -0
- package/lib/internal/ponyfills/String.trimEnd.js +10 -0
- package/lib/internal/ponyfills/String.trimStart.js +10 -0
- package/lib/invoke.js +29 -0
- package/lib/invokeArgs.js +40 -0
- package/lib/isArray.js +31 -0
- package/lib/isArrayLike.js +98 -0
- package/lib/isAsyncFunction.js +28 -0
- package/lib/isBigInt.js +29 -0
- package/lib/isBoolean.js +27 -0
- package/lib/isDate.js +26 -0
- package/lib/isEmptyArray.js +35 -0
- package/lib/isEmptyString.js +33 -0
- package/lib/isError.js +26 -0
- package/lib/isEven.js +39 -0
- package/lib/isFalse.js +35 -0
- package/lib/isFalsy.js +35 -0
- package/lib/isFinite.js +46 -0
- package/lib/isFloat.js +44 -0
- package/lib/isFunction.js +36 -0
- package/lib/isGeneratorFunction.js +40 -0
- package/lib/isIndexed.js +31 -0
- package/lib/isInteger.js +47 -0
- package/lib/isInteger32.js +37 -0
- package/lib/isIterable.js +42 -0
- package/lib/isMap.js +29 -0
- package/lib/isNaN.js +54 -0
- package/lib/isNaturalNumber.js +35 -0
- package/lib/isNegative.js +34 -0
- package/lib/isNegativeZero.js +28 -0
- package/lib/isNilOrEmpty.js +31 -0
- package/lib/isNonEmptyArray.js +37 -0
- package/lib/isNonEmptyString.js +41 -0
- package/lib/isNonNegative.js +37 -0
- package/lib/isNonPositive.js +37 -0
- package/lib/isNotArray.js +31 -0
- package/lib/isNotArrayLike.js +33 -0
- package/lib/isNotAsyncFunction.js +36 -0
- package/lib/isNotBoolean.js +31 -0
- package/lib/isNotDate.js +30 -0
- package/lib/isNotEmpty.js +31 -0
- package/lib/isNotFinite.js +38 -0
- package/lib/isNotFloat.js +42 -0
- package/lib/isNotFunction.js +38 -0
- package/lib/isNotGeneratorFunction.js +36 -0
- package/lib/isNotInteger.js +43 -0
- package/lib/isNotMap.js +33 -0
- package/lib/isNotNaN.js +44 -0
- package/lib/isNotNil.js +28 -0
- package/lib/isNotNilOrEmpty.js +35 -0
- package/lib/isNotNull.js +31 -0
- package/lib/isNotNumber.js +32 -0
- package/lib/isNotObj.js +38 -0
- package/lib/isNotObjLike.js +38 -0
- package/lib/isNotPair.js +34 -0
- package/lib/isNotPlainObj.js +44 -0
- package/lib/isNotPrimitive.js +31 -0
- package/lib/isNotRegExp.js +31 -0
- package/lib/isNotSet.js +32 -0
- package/lib/isNotString.js +30 -0
- package/lib/isNotUndefined.js +31 -0
- package/lib/isNotValidDate.js +31 -0
- package/lib/isNotValidNumber.js +34 -0
- package/lib/isNull.js +27 -0
- package/lib/isNumber.js +29 -0
- package/lib/isObj.js +42 -0
- package/lib/isObjLike.js +40 -0
- package/lib/isOdd.js +33 -0
- package/lib/isPair.js +34 -0
- package/lib/isPlainObj.js +64 -0
- package/lib/isPositive.js +33 -0
- package/lib/isPositiveZero.js +28 -0
- package/lib/isPrimitive.js +47 -0
- package/lib/isPromise.js +36 -0
- package/lib/isPrototypeOf.js +43 -0
- package/lib/isRegExp.js +27 -0
- package/lib/isSafeInteger.js +46 -0
- package/lib/isSentinelValue.js +35 -0
- package/lib/isSet.js +28 -0
- package/lib/isSparseArray.js +39 -0
- package/lib/isString.js +26 -0
- package/lib/isSymbol.js +33 -0
- package/lib/isThenable.js +35 -0
- package/lib/isTrue.js +31 -0
- package/lib/isTruthy.js +33 -0
- package/lib/isUndefined.js +31 -0
- package/lib/isValidDate.js +36 -0
- package/lib/isValidNumber.js +36 -0
- package/lib/lastP.js +76 -0
- package/lib/lengthEq.js +31 -0
- package/lib/lengthGt.js +31 -0
- package/lib/lengthGte.js +33 -0
- package/lib/lengthLt.js +31 -0
- package/lib/lengthLte.js +32 -0
- package/lib/lengthNotEq.js +31 -0
- package/lib/lensEq.js +33 -0
- package/lib/lensIso.js +62 -0
- package/lib/lensNotEq.js +35 -0
- package/lib/lensNotSatisfy.js +37 -0
- package/lib/lensSatisfies.js +40 -0
- package/lib/lensTraverse.js +51 -0
- package/lib/liftF.js +46 -0
- package/lib/liftFN.js +56 -0
- package/lib/list.js +25 -0
- package/lib/mapIndexed.js +32 -0
- package/lib/mergePath.js +39 -0
- package/lib/mergePaths.js +36 -0
- package/lib/mergeProp.js +39 -0
- package/lib/mergeProps.js +32 -0
- package/lib/mergeRight.js +32 -0
- package/lib/move.js +31 -0
- package/lib/nand.js +33 -0
- package/lib/neither.js +45 -0
- package/lib/noneP.js +39 -0
- package/lib/nonePass.js +37 -0
- package/lib/noop.js +28 -0
- package/lib/nor.js +34 -0
- package/lib/notAllPass.js +37 -0
- package/lib/notAllUnique.js +32 -0
- package/lib/notBoth.js +45 -0
- package/lib/notEqual.js +36 -0
- package/lib/omitBy.js +32 -0
- package/lib/omitIndexes.js +34 -0
- package/lib/overlaps.js +38 -0
- package/lib/padCharsEnd.js +44 -0
- package/lib/padCharsStart.js +42 -0
- package/lib/padEnd.js +32 -0
- package/lib/padStart.js +30 -0
- package/lib/pathNotEq.js +38 -0
- package/lib/pathOrLazy.js +31 -0
- package/lib/paths.js +33 -0
- package/lib/pickIndexes.js +37 -0
- package/lib/propNotEq.js +35 -0
- package/lib/rangeStep.js +45 -0
- package/lib/reduceIndexed.js +36 -0
- package/lib/reduceP.js +122 -0
- package/lib/reduceRightP.js +129 -0
- package/lib/rejectP.js +29 -0
- package/lib/renameKeyWith.js +37 -0
- package/lib/renameKeys.js +51 -0
- package/lib/renameKeysWith.js +32 -0
- package/lib/repeatStr.js +37 -0
- package/lib/replaceAll.js +42 -0
- package/lib/resolveP.js +35 -0
- package/lib/round.js +30 -0
- package/lib/seq.js +50 -0
- package/lib/sign.js +39 -0
- package/lib/skipTake.js +28 -0
- package/lib/sliceFrom.js +28 -0
- package/lib/sliceTo.js +28 -0
- package/lib/sortByProps.js +58 -0
- package/lib/spreadPath.js +31 -0
- package/lib/spreadProp.js +34 -0
- package/lib/stubArray.js +25 -0
- package/lib/stubNull.js +24 -0
- package/lib/stubObj.js +26 -0
- package/lib/stubString.js +24 -0
- package/lib/stubUndefined.js +25 -0
- package/lib/subtractNum.js +25 -0
- package/lib/thenCatchP.js +33 -0
- package/lib/thenP.js +34 -0
- package/lib/toArray.js +40 -0
- package/lib/toInteger32.js +30 -0
- package/lib/toUinteger32.js +32 -0
- package/lib/trimCharsEnd.js +31 -0
- package/lib/trimCharsStart.js +31 -0
- package/lib/trimEnd.js +36 -0
- package/lib/trimStart.js +35 -0
- package/lib/trunc.js +39 -0
- package/lib/unzipObjWith.js +35 -0
- package/lib/viewOr.js +36 -0
- package/lib/weave.js +42 -0
- package/lib/weaveLazy.js +44 -0
- package/lib/zipObjWith.js +32 -0
- package/package.json +204 -0
- package/src/Y.js +32 -0
- package/src/allEqual.js +28 -0
- package/src/allEqualTo.js +25 -0
- package/src/allIdentical.js +26 -0
- package/src/allIdenticalTo.js +25 -0
- package/src/allP.js +27 -0
- package/src/allSettledP.js +34 -0
- package/src/allUnique.js +25 -0
- package/src/anyP.js +33 -0
- package/src/appendFlipped.js +24 -0
- package/src/argsPass.js +40 -0
- package/src/async.js +60 -0
- package/src/cata.js +86 -0
- package/src/catchP.js +25 -0
- package/src/ceil.js +28 -0
- package/src/compact.js +23 -0
- package/src/concatAll.js +34 -0
- package/src/concatRight.js +30 -0
- package/src/contained.js +30 -0
- package/src/curryRight.js +26 -0
- package/src/curryRightN.js +29 -0
- package/src/defaultWhen.js +26 -0
- package/src/delayP.js +45 -0
- package/src/dispatch.js +74 -0
- package/src/divideNum.js +20 -0
- package/src/dropArgs.js +23 -0
- package/src/ensureArray.js +24 -0
- package/src/escapeRegExp.js +22 -0
- package/src/fantasy-land/Identity.js +270 -0
- package/src/fantasy-land/mapping.js +20 -0
- package/src/fantasy-land/traits.js +57 -0
- package/src/fantasy-land/util.js +23 -0
- package/src/filterIndexed.js +28 -0
- package/src/findOr.js +30 -0
- package/src/flattenDepth.js +39 -0
- package/src/flattenPath.js +26 -0
- package/src/flattenProp.js +28 -0
- package/src/floor.js +27 -0
- package/src/fnull.js +38 -0
- package/src/hasPath.js +40 -0
- package/src/inRange.js +34 -0
- package/src/index.js +241 -0
- package/src/internal/ap.js +30 -0
- package/src/internal/compareLength.js +7 -0
- package/src/internal/isOfTypeObject.js +3 -0
- package/src/internal/makeFlat.js +42 -0
- package/src/internal/ponyfills/Array.from.js +34 -0
- package/src/internal/ponyfills/Math.sign.js +3 -0
- package/src/internal/ponyfills/Math.trunc.js +14 -0
- package/src/internal/ponyfills/Number.MAX_SAFE_INTEGER.js +3 -0
- package/src/internal/ponyfills/Number.MIN_SAFE_INTEGER.js +3 -0
- package/src/internal/ponyfills/Number.isFinite.js +8 -0
- package/src/internal/ponyfills/Number.isInteger.js +10 -0
- package/src/internal/ponyfills/Number.isNaN.js +8 -0
- package/src/internal/ponyfills/Number.isSafeInteger.js +11 -0
- package/src/internal/ponyfills/Promise.allSettled.js +18 -0
- package/src/internal/ponyfills/Promise.any.js +29 -0
- package/src/internal/ponyfills/String.padEnd.js +25 -0
- package/src/internal/ponyfills/String.padStart.js +27 -0
- package/src/internal/ponyfills/String.repeat.js +49 -0
- package/src/internal/ponyfills/String.replaceAll.js +44 -0
- package/src/internal/ponyfills/String.trimEnd.js +5 -0
- package/src/internal/ponyfills/String.trimStart.js +5 -0
- package/src/invoke.js +22 -0
- package/src/invokeArgs.js +36 -0
- package/src/isArray.js +27 -0
- package/src/isArrayLike.js +79 -0
- package/src/isAsyncFunction.js +23 -0
- package/src/isBigInt.js +24 -0
- package/src/isBoolean.js +22 -0
- package/src/isDate.js +21 -0
- package/src/isEmptyArray.js +28 -0
- package/src/isEmptyString.js +28 -0
- package/src/isError.js +21 -0
- package/src/isEven.js +31 -0
- package/src/isFalse.js +31 -0
- package/src/isFalsy.js +28 -0
- package/src/isFinite.js +37 -0
- package/src/isFloat.js +36 -0
- package/src/isFunction.js +32 -0
- package/src/isGeneratorFunction.js +43 -0
- package/src/isIndexed.js +24 -0
- package/src/isInteger.js +40 -0
- package/src/isInteger32.js +28 -0
- package/src/isIterable.js +37 -0
- package/src/isMap.js +25 -0
- package/src/isNaN.js +45 -0
- package/src/isNaturalNumber.js +28 -0
- package/src/isNegative.js +27 -0
- package/src/isNegativeZero.js +23 -0
- package/src/isNilOrEmpty.js +26 -0
- package/src/isNonEmptyArray.js +29 -0
- package/src/isNonEmptyString.js +32 -0
- package/src/isNonNegative.js +30 -0
- package/src/isNonPositive.js +30 -0
- package/src/isNotArray.js +24 -0
- package/src/isNotArrayLike.js +26 -0
- package/src/isNotAsyncFunction.js +27 -0
- package/src/isNotBoolean.js +24 -0
- package/src/isNotDate.js +23 -0
- package/src/isNotEmpty.js +26 -0
- package/src/isNotFinite.js +31 -0
- package/src/isNotFloat.js +35 -0
- package/src/isNotFunction.js +29 -0
- package/src/isNotGeneratorFunction.js +27 -0
- package/src/isNotInteger.js +36 -0
- package/src/isNotMap.js +27 -0
- package/src/isNotNaN.js +37 -0
- package/src/isNotNil.js +23 -0
- package/src/isNotNilOrEmpty.js +28 -0
- package/src/isNotNull.js +24 -0
- package/src/isNotNumber.js +25 -0
- package/src/isNotObj.js +29 -0
- package/src/isNotObjLike.js +29 -0
- package/src/isNotPair.js +27 -0
- package/src/isNotPlainObj.js +35 -0
- package/src/isNotPrimitive.js +25 -0
- package/src/isNotRegExp.js +24 -0
- package/src/isNotSet.js +26 -0
- package/src/isNotString.js +23 -0
- package/src/isNotUndefined.js +24 -0
- package/src/isNotValidDate.js +24 -0
- package/src/isNotValidNumber.js +27 -0
- package/src/isNull.js +22 -0
- package/src/isNumber.js +24 -0
- package/src/isObj.js +31 -0
- package/src/isObjLike.js +30 -0
- package/src/isOdd.js +29 -0
- package/src/isPair.js +27 -0
- package/src/isPlainObj.js +65 -0
- package/src/isPositive.js +26 -0
- package/src/isPositiveZero.js +23 -0
- package/src/isPrimitive.js +45 -0
- package/src/isPromise.js +32 -0
- package/src/isPrototypeOf.js +36 -0
- package/src/isRegExp.js +22 -0
- package/src/isSafeInteger.js +40 -0
- package/src/isSentinelValue.js +26 -0
- package/src/isSet.js +24 -0
- package/src/isSparseArray.js +43 -0
- package/src/isString.js +21 -0
- package/src/isSymbol.js +29 -0
- package/src/isThenable.js +28 -0
- package/src/isTrue.js +27 -0
- package/src/isTruthy.js +28 -0
- package/src/isUndefined.js +24 -0
- package/src/isValidDate.js +29 -0
- package/src/isValidNumber.js +28 -0
- package/src/lastP.js +54 -0
- package/src/lengthEq.js +24 -0
- package/src/lengthGt.js +24 -0
- package/src/lengthGte.js +26 -0
- package/src/lengthLt.js +24 -0
- package/src/lengthLte.js +25 -0
- package/src/lengthNotEq.js +24 -0
- package/src/lensEq.js +28 -0
- package/src/lensIso.js +51 -0
- package/src/lensNotEq.js +28 -0
- package/src/lensNotSatisfy.js +30 -0
- package/src/lensSatisfies.js +33 -0
- package/src/lensTraverse.js +44 -0
- package/src/liftF.js +37 -0
- package/src/liftFN.js +45 -0
- package/src/list.js +20 -0
- package/src/mapIndexed.js +27 -0
- package/src/mergePath.js +32 -0
- package/src/mergePaths.js +29 -0
- package/src/mergeProp.js +30 -0
- package/src/mergeProps.js +27 -0
- package/src/mergeRight.js +27 -0
- package/src/move.js +26 -0
- package/src/nand.js +27 -0
- package/src/neither.js +38 -0
- package/src/noneP.js +35 -0
- package/src/nonePass.js +32 -0
- package/src/noop.js +21 -0
- package/src/nor.js +28 -0
- package/src/notAllPass.js +32 -0
- package/src/notAllUnique.js +25 -0
- package/src/notBoth.js +38 -0
- package/src/notEqual.js +31 -0
- package/src/omitBy.js +25 -0
- package/src/omitIndexes.js +27 -0
- package/src/overlaps.js +32 -0
- package/src/padCharsEnd.js +37 -0
- package/src/padCharsStart.js +35 -0
- package/src/padEnd.js +25 -0
- package/src/padStart.js +23 -0
- package/src/pathNotEq.js +31 -0
- package/src/pathOrLazy.js +30 -0
- package/src/paths.js +26 -0
- package/src/pickIndexes.js +30 -0
- package/src/propNotEq.js +30 -0
- package/src/rangeStep.js +37 -0
- package/src/reduceIndexed.js +31 -0
- package/src/reduceP.js +96 -0
- package/src/reduceRightP.js +101 -0
- package/src/rejectP.js +24 -0
- package/src/renameKeyWith.js +30 -0
- package/src/renameKeys.js +40 -0
- package/src/renameKeysWith.js +27 -0
- package/src/repeatStr.js +30 -0
- package/src/replaceAll.js +35 -0
- package/src/resolveP.js +28 -0
- package/src/round.js +26 -0
- package/src/seq.js +38 -0
- package/src/sign.js +33 -0
- package/src/skipTake.js +33 -0
- package/src/sliceFrom.js +23 -0
- package/src/sliceTo.js +23 -0
- package/src/sortByProps.js +31 -0
- package/src/spreadPath.js +26 -0
- package/src/spreadProp.js +25 -0
- package/src/stubArray.js +18 -0
- package/src/stubNull.js +19 -0
- package/src/stubObj.js +19 -0
- package/src/stubString.js +19 -0
- package/src/stubUndefined.js +19 -0
- package/src/subtractNum.js +20 -0
- package/src/thenCatchP.js +27 -0
- package/src/thenP.js +29 -0
- package/src/toArray.js +32 -0
- package/src/toInteger32.js +22 -0
- package/src/toUinteger32.js +26 -0
- package/src/trimCharsEnd.js +25 -0
- package/src/trimCharsStart.js +25 -0
- package/src/trimEnd.js +30 -0
- package/src/trimStart.js +29 -0
- package/src/trunc.js +33 -0
- package/src/unzipObjWith.js +40 -0
- package/src/viewOr.js +32 -0
- package/src/weave.js +35 -0
- package/src/weaveLazy.js +37 -0
- package/src/zipObjWith.js +27 -0
- package/tonicExample.js +4 -0
- package/types/index.d.ts +1553 -0
package/src/cata.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { curry } from 'ramda';
|
|
2
|
+
|
|
3
|
+
import isFunction from './isFunction';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The catamorphism is a way of folding a type into a value.
|
|
7
|
+
*
|
|
8
|
+
* **Either**
|
|
9
|
+
*
|
|
10
|
+
* If the either is right then the right function will be executed with
|
|
11
|
+
* the `right` value and the value of the function returned. Otherwise the left function
|
|
12
|
+
* will be called with the `left` value.
|
|
13
|
+
*
|
|
14
|
+
* **Maybe**
|
|
15
|
+
*
|
|
16
|
+
* If the maybe is Some than the right function will be executed with the `some` value and the value of the function
|
|
17
|
+
* returned. Otherwise the left function with be called without an argument.
|
|
18
|
+
*
|
|
19
|
+
* **Result**
|
|
20
|
+
*
|
|
21
|
+
* If the result is Ok than the right function will be executed with the `Ok` value and the value of the function
|
|
22
|
+
* returned. Otherwise the left function will be called with the `Error` value.
|
|
23
|
+
*
|
|
24
|
+
* **Validation**
|
|
25
|
+
*
|
|
26
|
+
* If the validation is Success than the right function will be executed with the `Success` value and the value of the function
|
|
27
|
+
* returned. Otherwise the left function will be called with the `Failure` value.
|
|
28
|
+
*
|
|
29
|
+
* Supported monadic libraries: {@link https://monet.github.io/monet.js/|monet.js}, {@link https://folktale.origamitower.com/|folktale}, {@link https://github.com/ramda/ramda-fantasy|ramda-fantasy}
|
|
30
|
+
*
|
|
31
|
+
* @func cata
|
|
32
|
+
* @memberOf RA
|
|
33
|
+
* @since {@link https://char0n.github.io/ramda-adjunct/1.4.0|v1.4.0}
|
|
34
|
+
* @category Function
|
|
35
|
+
* @sig (a -> b) -> (a -> c) -> Cata a -> b | c
|
|
36
|
+
* @param {Function} leftFn The left function that consumes the left value
|
|
37
|
+
* @param {Function} rightFn The right function that consumes the right value
|
|
38
|
+
* @param {Cata} catamorphicObj Either, Maybe or any other type with catamorphic capabilities (`cata` or `either` method)
|
|
39
|
+
* @return {*}
|
|
40
|
+
* @see {@link https://monet.github.io/monet.js/#cata|cata explained}
|
|
41
|
+
* @example
|
|
42
|
+
*
|
|
43
|
+
* // Either
|
|
44
|
+
* const eitherR = Either.Right(1);
|
|
45
|
+
* const eitherL = Either.Left(2);
|
|
46
|
+
*
|
|
47
|
+
* RA.cata(identity, identity, eitherR); //=> 1
|
|
48
|
+
* RA.cata(identity, identity, eitherL); //=> 2
|
|
49
|
+
*
|
|
50
|
+
* // Maybe
|
|
51
|
+
* const maybeSome = Maybe.Some(1);
|
|
52
|
+
* const maybeNothing = Maybe.Nothing();
|
|
53
|
+
*
|
|
54
|
+
* RA.cata(identity, identity, maybeSome); //=> 1
|
|
55
|
+
* RA.cata(identity, identity, maybeNothing); //=> undefined
|
|
56
|
+
*/
|
|
57
|
+
const catamorphism = curry((leftFn, rightFn, catamorphicObj) => {
|
|
58
|
+
// folktale support
|
|
59
|
+
if (isFunction(catamorphicObj.matchWith)) {
|
|
60
|
+
return catamorphicObj.matchWith({
|
|
61
|
+
// Result type
|
|
62
|
+
Ok: ({ value }) => rightFn(value),
|
|
63
|
+
Error: ({ value }) => leftFn(value),
|
|
64
|
+
// Maybe type
|
|
65
|
+
Just: ({ value }) => rightFn(value),
|
|
66
|
+
Nothing: () => leftFn(undefined),
|
|
67
|
+
// Validation type
|
|
68
|
+
Success: ({ value }) => rightFn(value),
|
|
69
|
+
Failure: ({ value }) => leftFn(value),
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (isFunction(catamorphicObj.cata)) {
|
|
74
|
+
return catamorphicObj.cata(leftFn, rightFn);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (isFunction(catamorphicObj.getOrElse)) {
|
|
78
|
+
const elseValue = `RA.cata${Math.random()}`;
|
|
79
|
+
const value = catamorphicObj.getOrElse(elseValue);
|
|
80
|
+
return value === elseValue ? leftFn() : rightFn(value);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return catamorphicObj.either(leftFn, rightFn);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
export default catamorphism;
|
package/src/catchP.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { invoker } from 'ramda';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Composable shortcut for `Promise.catch`.
|
|
5
|
+
* The catchP function returns a Promise. It takes two arguments: a callback function for the failure of the Promise
|
|
6
|
+
* and the promise instance itself.
|
|
7
|
+
*
|
|
8
|
+
* @func catchP
|
|
9
|
+
* @memberOf RA
|
|
10
|
+
* @since {@link https://char0n.github.io/ramda-adjunct/2.29.0|v2.29.0}
|
|
11
|
+
* @category Function
|
|
12
|
+
* @sig (a -> Promise b | b) -> Promise b
|
|
13
|
+
* @param {Function} onRejected A Function called if the Promise is rejected. This function has one argument, the rejection reason.
|
|
14
|
+
* @param {Promise} promise Any Promise
|
|
15
|
+
* @return {Promise} Returns a Promise with dealt rejected cases
|
|
16
|
+
* @see {@link RA.thenP|thenP}, {@link RA.resolveP|resolveP}, {@link RA.rejectP|rejectP}, {@link RA.allP|allP}
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
*
|
|
20
|
+
* RA.catchP(() => 'b', Promise.resolve('a')); //=> Promise('a')
|
|
21
|
+
* RA.catchP(() => 'b', Promise.reject('a')); //=> Promise('b')
|
|
22
|
+
*/
|
|
23
|
+
const catchP = invoker(1, 'catch');
|
|
24
|
+
|
|
25
|
+
export default catchP;
|
package/src/ceil.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { bind, curryN } from 'ramda';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Returns the smallest integer greater than or equal to a given number.
|
|
5
|
+
*
|
|
6
|
+
* Note: ceil(null) returns integer 0 and does not give a NaN error.
|
|
7
|
+
*
|
|
8
|
+
* @func ceil
|
|
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 ceil
|
|
14
|
+
* @return {number} The smallest integer greater than or equal to the given number
|
|
15
|
+
* @example
|
|
16
|
+
*
|
|
17
|
+
* RA.ceil(.95); //=> 1
|
|
18
|
+
* RA.ceil(4); //=> 4
|
|
19
|
+
* RA.ceil(7.004); //=> 8
|
|
20
|
+
* RA.ceil(-0.95); //=> -0
|
|
21
|
+
* RA.ceil(-4); //=> -4
|
|
22
|
+
* RA.ceil(-7.004); //=> -7
|
|
23
|
+
* RA.ceil(null); //=> 0
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
const ceil = curryN(1, bind(Math.ceil, Math));
|
|
27
|
+
|
|
28
|
+
export default ceil;
|
package/src/compact.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { reject } from 'ramda';
|
|
2
|
+
|
|
3
|
+
import isFalsy from './isFalsy';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Creates an array with all falsy values removed.
|
|
7
|
+
* The values false, null, 0, "", undefined, and NaN are falsy.
|
|
8
|
+
*
|
|
9
|
+
* @func compact
|
|
10
|
+
* @memberOf RA
|
|
11
|
+
* @since {@link https://char0n.github.io/ramda-adjunct/2.5.0|v2.5.0}
|
|
12
|
+
* @category List
|
|
13
|
+
* @sig Filterable f => f a -> f a
|
|
14
|
+
* @param {Array} list The array to compact
|
|
15
|
+
* @return {Array} Returns the new array of filtered values
|
|
16
|
+
* @see {@link RA.isFalsy|isFalsy}
|
|
17
|
+
* @example
|
|
18
|
+
*
|
|
19
|
+
* RA.compact([0, 1, false, 2, '', 3]); //=> [1, 2, 3]
|
|
20
|
+
*/
|
|
21
|
+
const compact = reject(isFalsy);
|
|
22
|
+
|
|
23
|
+
export default compact;
|
package/src/concatAll.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { concat, identical, identity, pipe, reduce, when } from 'ramda';
|
|
2
|
+
|
|
3
|
+
import stubUndefined from './stubUndefined';
|
|
4
|
+
|
|
5
|
+
const leftIdentitySemigroup = { concat: identity };
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Returns the result of concatenating the given lists or strings.
|
|
9
|
+
* Note: RA.concatAll expects all elements to be of the same type. It will throw an error if you concat an Array with a non-Array value.
|
|
10
|
+
* Dispatches to the concat method of the preceding element, if present. Can also concatenate multiple elements of a [fantasy-land compatible semigroup](https://github.com/fantasyland/fantasy-land#semigroup).
|
|
11
|
+
* Returns undefined if empty array was passed.
|
|
12
|
+
*
|
|
13
|
+
* @func concatAll
|
|
14
|
+
* @memberOf RA
|
|
15
|
+
* @since {@link https://char0n.github.io/ramda-adjunct/2.6.0|v2.6.0}
|
|
16
|
+
* @category List
|
|
17
|
+
* @sig [[a]] -> [a] | Undefined
|
|
18
|
+
* @sig [String] -> String | Undefined
|
|
19
|
+
* @sig Semigroup s => Foldable s f => f -> s | Undefined
|
|
20
|
+
* @param {Array.<Array|string>} list List containing elements that will be concatenated
|
|
21
|
+
* @return {Array|string|undefined} Concatenated elements
|
|
22
|
+
* @see {@link http://ramdajs.com/docs/#concat|R.concat}, {@link RA.concatRight|concatRight}, {@link http://ramdajs.com/docs/#unnest|R.unnest}, {@link http://ramdajs.com/docs/#join|R.join}
|
|
23
|
+
* @example
|
|
24
|
+
*
|
|
25
|
+
* concatAll([[1], [2], [3]]); //=> [1, 2, 3]
|
|
26
|
+
* concatAll(['1', '2', '3']); //=> '123'
|
|
27
|
+
* concatAll([]); //=> undefined;
|
|
28
|
+
*/
|
|
29
|
+
const concatAll = pipe(
|
|
30
|
+
reduce(concat, leftIdentitySemigroup),
|
|
31
|
+
when(identical(leftIdentitySemigroup), stubUndefined)
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
export default concatAll;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { concat, flip } from 'ramda';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Returns the result of concatenating the given lists or strings.
|
|
5
|
+
*
|
|
6
|
+
* Note: R.concat expects both arguments to be of the same type, unlike
|
|
7
|
+
* the native Array.prototype.concat method.
|
|
8
|
+
* It will throw an error if you concat an Array with a non-Array value.
|
|
9
|
+
* Dispatches to the concat method of the second argument, if present.
|
|
10
|
+
*
|
|
11
|
+
* @func concatRight
|
|
12
|
+
* @memberOf RA
|
|
13
|
+
* @since {@link https://char0n.github.io/ramda-adjunct/1.11.0|v1.11.0}
|
|
14
|
+
* @category List
|
|
15
|
+
* @sig [a] -> [a] -> [a]
|
|
16
|
+
* @sig String -> String -> String
|
|
17
|
+
* @param {Array|String} firstList The first list
|
|
18
|
+
* @param {Array|String} secondList The second list
|
|
19
|
+
* @return {Array|String} A list consisting of the elements of `secondList`
|
|
20
|
+
* followed by the elements of `firstList`.
|
|
21
|
+
* @see {@link http://ramdajs.com/docs/#concat|R.concat}
|
|
22
|
+
* @example
|
|
23
|
+
*
|
|
24
|
+
* RA.concatRight('ABC', 'DEF'); //=> 'DEFABC'
|
|
25
|
+
* RA.concatRight([4, 5, 6], [1, 2, 3]); //=> [1, 2, 3, 4, 5, 6]
|
|
26
|
+
* RA.concatRight([], []); //=> []
|
|
27
|
+
*/
|
|
28
|
+
const concatRight = flip(concat);
|
|
29
|
+
|
|
30
|
+
export default concatRight;
|
package/src/contained.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { flip, contains } 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/#contains|R.contains} but with argument order reversed.
|
|
9
|
+
*
|
|
10
|
+
* @func contained
|
|
11
|
+
* @aliases included
|
|
12
|
+
* @memberOf RA
|
|
13
|
+
* @since {@link https://char0n.github.io/ramda-adjunct/2.8.0|v2.8.0}
|
|
14
|
+
* @deprecated since v2.12.0; please use RA.included alias
|
|
15
|
+
* @category List
|
|
16
|
+
* @sig [a] -> a -> Boolean
|
|
17
|
+
* @param {Array|String} list The list to consider
|
|
18
|
+
* @param {*} a The item to compare against
|
|
19
|
+
* @return {boolean} Returns Boolean `true` if an equivalent item is in the list or `false` otherwise
|
|
20
|
+
* @see {@link http://ramdajs.com/docs/#contains|R.contains}
|
|
21
|
+
* @example
|
|
22
|
+
*
|
|
23
|
+
* RA.contained([1, 2, 3], 3); //=> true
|
|
24
|
+
* RA.contained([1, 2, 3], 4); //=> false
|
|
25
|
+
* RA.contained([{ name: 'Fred' }], { name: 'Fred' }); //=> true
|
|
26
|
+
* RA.contained([[42]], [42]); //=> true
|
|
27
|
+
*/
|
|
28
|
+
const contained = flip(contains);
|
|
29
|
+
|
|
30
|
+
export default contained;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { converge, length, identity } from 'ramda';
|
|
2
|
+
|
|
3
|
+
import curryRightN from './curryRightN';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Returns a curried equivalent of the provided function.
|
|
7
|
+
* This function is like curry, except that the provided arguments order is reversed.
|
|
8
|
+
*
|
|
9
|
+
* @func curryRight
|
|
10
|
+
* @memberOf RA
|
|
11
|
+
* @since {@link https://char0n.github.io/ramda-adjunct/1.12.0|v1.12.0}
|
|
12
|
+
* @category Function
|
|
13
|
+
* @sig (* -> a) -> (* -> a)
|
|
14
|
+
* @param {Function} fn The function to curry
|
|
15
|
+
* @return {Function} A new, curried function
|
|
16
|
+
* @see {@link http://ramdajs.com/docs/#curry|R.curry}, {@link RA.curryRightN|curryRightN}
|
|
17
|
+
* @example
|
|
18
|
+
*
|
|
19
|
+
* const concatStrings = (a, b, c) => a + b + c;
|
|
20
|
+
* const concatStringsCurried = RA.curryRight(concatStrings);
|
|
21
|
+
*
|
|
22
|
+
* concatStringCurried('a')('b')('c'); // => 'cba'
|
|
23
|
+
*/
|
|
24
|
+
const curryRight = converge(curryRightN, [length, identity]);
|
|
25
|
+
|
|
26
|
+
export default curryRight;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { curryN, reverse } from 'ramda';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Returns a curried equivalent of the provided function, with the specified arity.
|
|
5
|
+
* This function is like curryN, except that the provided arguments order is reversed.
|
|
6
|
+
*
|
|
7
|
+
* @func curryRightN
|
|
8
|
+
* @memberOf RA
|
|
9
|
+
* @since {@link https://char0n.github.io/ramda-adjunct/1.12.0|v1.12.0}
|
|
10
|
+
* @category Function
|
|
11
|
+
* @sig Number -> (* -> a) -> (* -> a)
|
|
12
|
+
* @param {number} length The arity for the returned function
|
|
13
|
+
* @param {Function} fn The function to curry
|
|
14
|
+
* @return {Function} A new, curried function
|
|
15
|
+
* @see {@link http://ramdajs.com/docs/#curryN|R.curryN}, {@link RA.curryRight|curryRight}
|
|
16
|
+
* @example
|
|
17
|
+
*
|
|
18
|
+
* const concatStrings = (a, b, c) => a + b + c;
|
|
19
|
+
* const concatStringsCurried = RA.curryRightN(3, concatStrings);
|
|
20
|
+
*
|
|
21
|
+
* concatStringCurried('a')('b')('c'); // => 'cba'
|
|
22
|
+
*/
|
|
23
|
+
const curryRightN = curryN(2, (arity, fn) =>
|
|
24
|
+
curryN(arity, function wrapper(...args) {
|
|
25
|
+
return fn.apply(this, reverse(args));
|
|
26
|
+
})
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
export default curryRightN;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { curry } from 'ramda';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Returns the second argument if predicate function returns `true`,
|
|
5
|
+
* otherwise the third argument is returned.
|
|
6
|
+
*
|
|
7
|
+
* @func defaultWhen
|
|
8
|
+
* @memberOf RA
|
|
9
|
+
* @since {@link https://char0n.github.io/ramda-adjunct/2.2.0|v2.2.0}
|
|
10
|
+
* @category Logic
|
|
11
|
+
* @sig (a -> Boolean) -> b -> a -> a | b
|
|
12
|
+
* @param {!function} predicate The predicate function
|
|
13
|
+
* @param {*} defaultVal The default value
|
|
14
|
+
* @param {*} val `val` will be returned instead of `defaultVal` if predicate returns false
|
|
15
|
+
* @return {*} The `val` if predicate returns `false`, otherwise the default value
|
|
16
|
+
* @see {@link http://ramdajs.com/docs/#defaultTo|R.defaultTo}
|
|
17
|
+
* @example
|
|
18
|
+
*
|
|
19
|
+
* RA.defaultWhen(RA.isNull, 1, null); // => 1
|
|
20
|
+
* RA.defaultWhen(RA.isNull, 1, 2); // => 2
|
|
21
|
+
*/
|
|
22
|
+
const defaultWhen = curry((predicate, defaultVal, val) =>
|
|
23
|
+
predicate(val) ? defaultVal : val
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
export default defaultWhen;
|
package/src/delayP.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { curry, propOr, partial, nth } from 'ramda';
|
|
2
|
+
|
|
3
|
+
import isNonNegative from './isNonNegative';
|
|
4
|
+
import isInteger from './isInteger';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Creates a promise which resolves/rejects after the specified milliseconds.
|
|
8
|
+
*
|
|
9
|
+
* @func delayP
|
|
10
|
+
* @memberOf RA
|
|
11
|
+
* @category Function
|
|
12
|
+
* @sig Number -> Promise Undefined
|
|
13
|
+
* @sig {timeout: Number, value: a} -> Promise a
|
|
14
|
+
* @param {number|Object} milliseconds number of milliseconds or options object
|
|
15
|
+
* @return {Promise} A Promise that is resolved/rejected with the given value (if provided) after the specified delay
|
|
16
|
+
* @example
|
|
17
|
+
*
|
|
18
|
+
* RA.delayP(200); //=> Promise(undefined)
|
|
19
|
+
* RA.delayP({ timeout: 1000, value: 'hello world' }); //=> Promise('hello world')
|
|
20
|
+
* RA.delayP.reject(100); //=> Promise(undefined)
|
|
21
|
+
* RA.delayP.reject({ timeout: 100, value: new Error('error') }); //=> Promise(Error('error'))
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
const makeDelay = curry((settleFnPicker, opts) => {
|
|
25
|
+
let timeout;
|
|
26
|
+
let value;
|
|
27
|
+
|
|
28
|
+
if (isInteger(opts) && isNonNegative(opts)) {
|
|
29
|
+
timeout = opts;
|
|
30
|
+
} else {
|
|
31
|
+
timeout = propOr(0, 'timeout', opts);
|
|
32
|
+
value = propOr(value, 'value', opts);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return new Promise((...args) => {
|
|
36
|
+
const settleFn = settleFnPicker(args);
|
|
37
|
+
|
|
38
|
+
setTimeout(partial(settleFn, [value]), timeout);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const delayP = makeDelay(nth(0));
|
|
43
|
+
delayP.reject = makeDelay(nth(1));
|
|
44
|
+
|
|
45
|
+
export default delayP;
|
package/src/dispatch.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import {
|
|
2
|
+
sort,
|
|
3
|
+
comparator,
|
|
4
|
+
prop,
|
|
5
|
+
pipe,
|
|
6
|
+
head,
|
|
7
|
+
curryN,
|
|
8
|
+
reduce,
|
|
9
|
+
reduced,
|
|
10
|
+
curry,
|
|
11
|
+
ifElse,
|
|
12
|
+
} from 'ramda';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Can be used as a way to compose multiple invokers together to form polymorphic functions,
|
|
16
|
+
* or functions that exhibit different behaviors based on their argument(s).
|
|
17
|
+
* Consumes dispatching functions and keep trying to invoke each in turn, until a non-nil value is returned.
|
|
18
|
+
*
|
|
19
|
+
* Accepts a list of dispatching functions and returns a new function.
|
|
20
|
+
* When invoked, this new function is applied to some arguments,
|
|
21
|
+
* each dispatching function is applied to those same arguments until one of the
|
|
22
|
+
* dispatching functions returns a non-nil value.
|
|
23
|
+
*
|
|
24
|
+
* @func dispatch
|
|
25
|
+
* @memberOf RA
|
|
26
|
+
* @since {@link https://char0n.github.io/ramda-adjunct/2.6.0|v2.6.0}
|
|
27
|
+
* @category Function
|
|
28
|
+
* @sig [((a, b, ...) -> x1), ((a, b, ...) -> x2), ...] -> x1 | x2 | ...
|
|
29
|
+
* @param {!Array} functions A list of functions
|
|
30
|
+
* @return {*|undefined} Returns the first not-nil value, or undefined if either an empty list is provided or none of the dispatching functions returns a non-nil value
|
|
31
|
+
* @see {@link RA.isNotNil}
|
|
32
|
+
* @example
|
|
33
|
+
*
|
|
34
|
+
* // returns first non-nil value
|
|
35
|
+
* const stubNil = () => null;
|
|
36
|
+
* const stubUndefined = () => undefined;
|
|
37
|
+
* const addOne = v => v + 1;
|
|
38
|
+
* const addTwo = v => v + 2;
|
|
39
|
+
*
|
|
40
|
+
* RA.dispatch([stubNil, stubUndefined, addOne, addTwo])(1); //=> 2
|
|
41
|
+
*
|
|
42
|
+
* // acts as a switch
|
|
43
|
+
* const fnSwitch = RA.dispatch([
|
|
44
|
+
* R.ifElse(RA.isString, s => `${s}-join`, RA.stubUndefined),
|
|
45
|
+
* R.ifElse(RA.isNumber, n => n + 1, RA.stubUndefined),
|
|
46
|
+
* R.ifElse(RA.isDate, R.T, RA.stubUndefined),
|
|
47
|
+
* ]);
|
|
48
|
+
* fnSwitch(1); //=> 2
|
|
49
|
+
*/
|
|
50
|
+
import isNotNil from './isNotNil';
|
|
51
|
+
import isNonEmptyArray from './isNonEmptyArray';
|
|
52
|
+
import stubUndefined from './stubUndefined';
|
|
53
|
+
|
|
54
|
+
const byArity = comparator((a, b) => a.length > b.length);
|
|
55
|
+
|
|
56
|
+
const getMaxArity = pipe(sort(byArity), head, prop('length'));
|
|
57
|
+
|
|
58
|
+
const iteratorFn = curry((args, accumulator, fn) => {
|
|
59
|
+
const result = fn(...args);
|
|
60
|
+
|
|
61
|
+
return isNotNil(result) ? reduced(result) : accumulator;
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const dispatchImpl = (functions) => {
|
|
65
|
+
const arity = getMaxArity(functions);
|
|
66
|
+
|
|
67
|
+
return curryN(arity, (...args) =>
|
|
68
|
+
reduce(iteratorFn(args), undefined, functions)
|
|
69
|
+
);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const dispatch = ifElse(isNonEmptyArray, dispatchImpl, stubUndefined);
|
|
73
|
+
|
|
74
|
+
export default dispatch;
|
package/src/divideNum.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { divide, flip } from 'ramda';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Divides two numbers, where the second number is divided by the first number.
|
|
5
|
+
*
|
|
6
|
+
* @func divideNum
|
|
7
|
+
* @memberOf RA
|
|
8
|
+
* @since {@link https://char0n.github.io/ramda-adjunct/2.22.0|v2.22.0}
|
|
9
|
+
* @category Math
|
|
10
|
+
* @sig Number -> Number -> Number
|
|
11
|
+
* @param {number} divisor the number to divide by
|
|
12
|
+
* @param {number} dividend the number to divide
|
|
13
|
+
* @return {number} A number representing the quotient of dividing the dividend by the divisor
|
|
14
|
+
* @example
|
|
15
|
+
*
|
|
16
|
+
* RA.divideNum(2, 1); //=> 0.5
|
|
17
|
+
*/
|
|
18
|
+
const divideNum = flip(divide);
|
|
19
|
+
|
|
20
|
+
export default divideNum;
|
package/src/dropArgs.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { nAry } from 'ramda';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Accepts a function with any arity and returns a function with arity of zero.
|
|
5
|
+
* The returned function ignores any arguments supplied to it.
|
|
6
|
+
*
|
|
7
|
+
* @func dropArgs
|
|
8
|
+
* @memberOf RA
|
|
9
|
+
* @since {@link https://char0n.github.io/ramda-adjunct/2.10.0|v2.10.0}
|
|
10
|
+
* @category Logic
|
|
11
|
+
* @sig (...a -> b)-> () -> b
|
|
12
|
+
* @param {Function} fn The function with any arity
|
|
13
|
+
* @return {Function} Returns function with arity of zero
|
|
14
|
+
* @see {@link http://ramdajs.com/docs/#nAry|R.nAry}
|
|
15
|
+
* @example
|
|
16
|
+
*
|
|
17
|
+
* const fn = (a = 1, b = 2) => a + b;
|
|
18
|
+
*
|
|
19
|
+
* RA.dropArgs(fn)('ignore1', 'ignore2'); //=> 3
|
|
20
|
+
*/
|
|
21
|
+
const dropArgs = nAry(0);
|
|
22
|
+
|
|
23
|
+
export default dropArgs;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { when, of } from 'ramda';
|
|
2
|
+
|
|
3
|
+
import isNotArray from './isNotArray';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Returns a singleton array containing the value provided.
|
|
7
|
+
* If value is already an array, it is returned as is.
|
|
8
|
+
*
|
|
9
|
+
* @func ensureArray
|
|
10
|
+
* @memberOf RA
|
|
11
|
+
* @since {@link https://char0n.github.io/ramda-adjunct/2.6.0|v2.6.0}
|
|
12
|
+
* @category List
|
|
13
|
+
* @sig a | [a] -> [a]
|
|
14
|
+
* @param {*|Array} val the value ensure as Array
|
|
15
|
+
* @return {Array}
|
|
16
|
+
* @see {@link http://ramdajs.com/docs/#of|R.of}
|
|
17
|
+
* @example
|
|
18
|
+
*
|
|
19
|
+
* RA.ensureArray(42); //=> [42]
|
|
20
|
+
* RA.ensureArray([42]); //=> [42]
|
|
21
|
+
*/
|
|
22
|
+
const ensureArray = when(isNotArray, of);
|
|
23
|
+
|
|
24
|
+
export default ensureArray;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { when, replace } from 'ramda';
|
|
2
|
+
|
|
3
|
+
import isString from './isString';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Escapes the RegExp special characters.
|
|
7
|
+
*
|
|
8
|
+
* @func escapeRegExp
|
|
9
|
+
* @memberOf RA
|
|
10
|
+
* @since {@link https://char0n.github.io/ramda-adjunct/2.21.0|v2.21.0}
|
|
11
|
+
* @category String
|
|
12
|
+
* @sig String -> String
|
|
13
|
+
* @param {string} val the value to escape
|
|
14
|
+
* @return {string}
|
|
15
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Escaping|MDN Regular Expressions Escaping}
|
|
16
|
+
* @example
|
|
17
|
+
*
|
|
18
|
+
* RA.escapeRegExp('[ramda-adjunct](https://github.com/char0n/ramda-adjunct)'); //=> '\[ramda\-adjunct\]\(https://github\.com/char0n/ramda\-adjunct\)'
|
|
19
|
+
*/
|
|
20
|
+
const escapeRegExp = when(isString, replace(/[.*+?^${}()|[\]\\-]/g, '\\$&'));
|
|
21
|
+
|
|
22
|
+
export default escapeRegExp;
|