rambda 8.1.0 → 8.2.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/package.json CHANGED
@@ -1,39 +1,39 @@
1
1
  {
2
2
  "name": "rambda",
3
- "version": "8.1.0",
3
+ "version": "8.2.0",
4
4
  "scripts": {
5
- "publish:experimental": "node files/publish",
6
- "populatedocs": "cd ../rambda-scripts && yarn populate:docs",
7
- "populatedocs:x": "cd ../rambda-scripts && yarn populate:docs:rambdax",
8
- "populatereadme": "cd ../rambda-scripts && yarn populate:readme",
9
- "populatereadme:x": "cd ../rambda-scripts && yarn populate:readme:rambdax",
10
- "out": "yarn populatedocs && yarn populatereadme && yarn immutable && yarn build",
11
- "x": "yarn populatedocs:x && yarn populatereadme:x && yarn immutable:x",
12
- "github": "cd ../rambda-scripts && yarn github",
5
+ "benchmark": "cd ../rambda-scripts && RAMBDA_RUN_ALL=ON RAMBDA_RUN_INDEXES=ON yarn benchmark",
6
+ "benchmark:all": "yarn build:step && cd ../rambda-scripts && yarn benchmark:all",
7
+ "benchmark:check": "yarn build:step && METHOD=compose yarn benchmark:check:apply",
8
+ "benchmark:check:apply": "cd ../rambda-scripts && yarn check-benchmark",
9
+ "build": "yarn build:main && yarn build:web",
10
+ "build:main": "cross-env NODE_ENV=build rollup -c files/rollup.config.mjs",
11
+ "build:step": "yarn populatereadme && yarn build:main",
12
+ "build:web": "cross-env NODE_ENV=build rollup -c files/rollup.web.config.mjs",
13
+ "d": "yarn out && yarn lint && run d",
14
+ "docs": "npx docsify-cli init ./docs && yarn fix-docsify",
13
15
  "fix-docsify": "cd ../rambda-scripts && yarn fix-docsify:rambda",
16
+ "git:add": "git add -A",
17
+ "github": "cd ../rambda-scripts && yarn github",
14
18
  "immutable": "cd ../rambda-scripts && yarn immutable:rambda",
15
19
  "immutable:x": "cd ../rambda-scripts && yarn immutable:rambdax",
16
- "usedby": "cd ../rambda-scripts && yarn usedby",
20
+ "lint": "yarn git:add && yarn lint:staged && yarn git:add",
17
21
  "lint:all": "cd ../rambda-scripts && yarn lint",
18
22
  "lint:staged": "cd ../rambda-scripts && yarn lint:staged",
19
- "lint": "yarn git:add && yarn lint:staged && yarn git:add",
20
- "git:add": "git add -A",
21
- "build": "yarn build:main && yarn build:web",
22
- "build:web": "cross-env NODE_ENV=build rollup -c files/rollup.web.config.mjs",
23
- "build:main": "cross-env NODE_ENV=build rollup -c files/rollup.config.mjs",
24
- "docs": "npx docsify-cli init ./docs && yarn fix-docsify",
25
23
  "new": "cd ../rambda-scripts && yarn new",
24
+ "out": "yarn populatedocs && yarn populatereadme && yarn immutable && yarn build",
25
+ "populatedocs": "cd ../rambda-scripts && yarn populate:docs",
26
+ "populatedocs:x": "cd ../rambda-scripts && yarn populate:docs:rambdax",
27
+ "populatereadme": "cd ../rambda-scripts && yarn populate:readme",
28
+ "populatereadme:x": "cd ../rambda-scripts && yarn populate:readme:rambdax",
29
+ "publish:experimental": "node files/publish",
26
30
  "run:ramda:test": "cd ../rambda-scripts && yarn run:ramda:test",
27
- "test:typings": "dtslint --localTs ./node_modules/typescript/lib --expectOnly ./source",
28
- "test:all": "jest source/*.spec.js -u --bail=false",
29
31
  "test": "jest -o -u --watch",
32
+ "test:all": "jest source/*.spec.js -u --bail=false",
30
33
  "test:ci": "jest source/*.spec.js --coverage --no-cache -w 1",
31
- "build:step": "yarn populatereadme && yarn build:main",
32
- "benchmark:all": "yarn build:step && cd ../rambda-scripts && yarn benchmark:all",
33
- "benchmark:check": "yarn build:step && METHOD=compose yarn benchmark:check:apply",
34
- "benchmark:check:apply": "cd ../rambda-scripts && yarn check-benchmark",
35
- "benchmark": "cd ../rambda-scripts && RAMBDA_RUN_ALL=ON RAMBDA_RUN_INDEXES=ON yarn benchmark",
36
- "d": "yarn out && yarn lint && run d"
34
+ "test:typings": "dtslint --localTs ./node_modules/typescript/lib --expectOnly ./source",
35
+ "usedby": "cd ../rambda-scripts && yarn usedby",
36
+ "x": "yarn populatedocs:x && yarn populatereadme:x && yarn immutable:x"
37
37
  },
38
38
  "dependencies": {},
39
39
  "devDependencies": {
package/rambda.js CHANGED
@@ -2,6 +2,8 @@
2
2
  export * from './src/F.js'
3
3
  export * from './src/T.js'
4
4
  export * from './src/add.js'
5
+ export * from './src/addIndex.js'
6
+ export * from './src/addIndexRight.js'
5
7
  export * from './src/adjust.js'
6
8
  export * from './src/all.js'
7
9
  export * from './src/allPass.js'
@@ -9,9 +11,13 @@ export * from './src/always.js'
9
11
  export * from './src/and.js'
10
12
  export * from './src/any.js'
11
13
  export * from './src/anyPass.js'
14
+ export * from './src/ap.js'
15
+ export * from './src/aperture.js'
12
16
  export * from './src/append.js'
13
17
  export * from './src/apply.js'
14
18
  export * from './src/applySpec.js'
19
+ export * from './src/applyTo.js'
20
+ export * from './src/ascend.js'
15
21
  export * from './src/assoc.js'
16
22
  export * from './src/assocPath.js'
17
23
  export * from './src/bind.js'
@@ -30,6 +36,7 @@ export * from './src/curry.js'
30
36
  export * from './src/curryN.js'
31
37
  export * from './src/dec.js'
32
38
  export * from './src/defaultTo.js'
39
+ export * from './src/descend.js'
33
40
  export * from './src/difference.js'
34
41
  export * from './src/differenceWith.js'
35
42
  export * from './src/dissoc.js'
@@ -0,0 +1,21 @@
1
+ export function _concat(set1, set2){
2
+ set1 = set1 || []
3
+ set2 = set2 || []
4
+ let idx
5
+ const len1 = set1.length
6
+ const len2 = set2.length
7
+ const result = []
8
+
9
+ idx = 0
10
+ while (idx < len1){
11
+ result[ result.length ] = set1[ idx ]
12
+ idx += 1
13
+ }
14
+ idx = 0
15
+ while (idx < len2){
16
+ result[ result.length ] = set2[ idx ]
17
+ idx += 1
18
+ }
19
+
20
+ return result
21
+ }
@@ -0,0 +1,23 @@
1
+ import { _concat } from './_internals/utils.js'
2
+ import { curryN } from './curryN.js'
3
+
4
+ export function addIndex(
5
+ originalFunction,
6
+ initialIndexFn = () => 0,
7
+ loopIndexChange = x => x + 1
8
+ ){
9
+ return curryN(originalFunction.length, function (){
10
+ const origFn = arguments[ 0 ]
11
+ const list = arguments[ arguments.length - 1 ]
12
+ let idx = initialIndexFn(list.length)
13
+ const args = Array.prototype.slice.call(arguments, 0)
14
+ args[ 0 ] = function (){
15
+ const result = origFn.apply(this, _concat(arguments, [ idx, list ]))
16
+ idx = loopIndexChange(idx)
17
+
18
+ return result
19
+ }
20
+
21
+ return originalFunction.apply(this, args)
22
+ })
23
+ }
@@ -0,0 +1,9 @@
1
+ import { addIndex } from './addIndex.js'
2
+
3
+ export function addIndexRight(originalFunction){
4
+ return addIndex(
5
+ originalFunction,
6
+ listLength => listLength - 1,
7
+ x => x - 1
8
+ )
9
+ }
package/src/ap.js ADDED
@@ -0,0 +1,7 @@
1
+ export function ap(functions, input){
2
+ if (arguments.length === 1){
3
+ return _inputs => ap(functions, _inputs)
4
+ }
5
+
6
+ return functions.reduce((acc, fn) => [ ...acc, ...input.map(fn) ], [])
7
+ }
@@ -0,0 +1,15 @@
1
+ export function aperture(step, list){
2
+ if (arguments.length === 1){
3
+ return _list => aperture(step, _list)
4
+ }
5
+ if (step > list.length) return []
6
+ let idx = 0
7
+ const limit = list.length - (step - 1)
8
+ const acc = new Array(limit)
9
+ while (idx < limit){
10
+ acc[ idx ] = list.slice(idx, idx + step)
11
+ idx += 1
12
+ }
13
+
14
+ return acc
15
+ }
package/src/applyTo.js ADDED
@@ -0,0 +1,7 @@
1
+ export function applyTo(input, fn){
2
+ if (arguments.length === 1){
3
+ return _fn => applyTo(input, _fn)
4
+ }
5
+
6
+ return fn(input)
7
+ }
package/src/ascend.js ADDED
@@ -0,0 +1,23 @@
1
+ export function createCompareFunction(
2
+ a, b, winner, loser
3
+ ){
4
+ if (a === b) return 0
5
+
6
+ return a < b ? winner : loser
7
+ }
8
+
9
+ export function ascend(
10
+ getFunction, a, b
11
+ ){
12
+ if (arguments.length === 1){
13
+ return (_a, _b) => ascend(
14
+ getFunction, _a, _b
15
+ )
16
+ }
17
+ const aValue = getFunction(a)
18
+ const bValue = getFunction(b)
19
+
20
+ return createCompareFunction(
21
+ aValue, bValue, -1, 1
22
+ )
23
+ }
package/src/descend.js ADDED
@@ -0,0 +1,17 @@
1
+ import { createCompareFunction } from './ascend.js'
2
+
3
+ export function descend(
4
+ getFunction, a, b
5
+ ){
6
+ if (arguments.length === 1){
7
+ return (_a, _b) => descend(
8
+ getFunction, _a, _b
9
+ )
10
+ }
11
+ const aValue = getFunction(a)
12
+ const bValue = getFunction(b)
13
+
14
+ return createCompareFunction(
15
+ aValue, bValue, 1, -1
16
+ )
17
+ }