Skip to content

Commit

Permalink
refactor: switch from ramda to rambda
Browse files Browse the repository at this point in the history
  • Loading branch information
taymoork2 committed May 27, 2022
1 parent d5cc8b0 commit 4d19499
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 47 deletions.
5 changes: 1 addition & 4 deletions benchmarks/measure.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

const os = require('os');
const { performance: performanceHooks } = require('perf_hooks');
const times = require('ramda/src/times');
const median = require('ramda/src/median');
const map = require('ramda/src/map');
const prop = require('ramda/src/prop');
const { times, median, map, prop } = require('rambda');
const semver = require('semver');

const [ { speed: cpuSpeed } ] = os.cpus();
Expand Down
4 changes: 1 addition & 3 deletions benchmarks/runtime.bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

const { expect } = require('chai');
const { Linter } = require('eslint');
const times = require('ramda/src/times');
const toPairs = require('ramda/src/toPairs');
const fromPairs = require('ramda/src/fromPairs');
const { times, toPairs, fromPairs } = require('rambda');
const {
runBenchmark,
cpuSpeed,
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/handle-done-callback.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

const find = require('ramda/src/find');
const { find } = require('rambda');
const createAstUtils = require('../util/ast');

module.exports = {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/max-top-level-suites.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @author Alexander Afanasyev
*/

const isNil = require('ramda/src/isNil');
const { isNil } = require('rambda');
const createAstUtils = require('../util/ast');

const defaultSuiteLimit = 1;
Expand Down
3 changes: 1 addition & 2 deletions lib/rules/no-synchronous-tests.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

const isNil = require('ramda/src/isNil');
const find = require('ramda/src/find');
const { isNil, find } = require('rambda');
const createAstUtils = require('../util/ast');

const asyncMethods = [ 'async', 'callback', 'promise' ];
Expand Down
7 changes: 1 addition & 6 deletions lib/util/ast.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
'use strict';

const complement = require('ramda/src/complement');
const both = require('ramda/src/both');
const isNil = require('ramda/src/isNil');
const propEq = require('ramda/src/propEq');
const pathEq = require('ramda/src/pathEq');
const find = require('ramda/src/find');
const { complement, both, isNil, propEq, pathEq, find } = require('rambda');
const { getTestCaseNames, getSuiteNames } = require('./names');
const { getAddtionalNames } = require('./settings');

Expand Down
28 changes: 28 additions & 0 deletions lib/util/memoizeWith.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* eslint-disable prefer-rest-params */
'use strict';

/** Memoize a function using a custom cache and a key formatter
*
* (rambda does not include a memoizeWith function)
*
* @param {Function} keyGen The function to generate the cache key.
* @param {Function} fn The function to memoize.
* @return {Function} Memoized version of `fn`.
*/
const memoizeWith = (keyGen, fn) => {
const cache = new Map();

return function () {
const key = keyGen(arguments);

if (!cache.has(key)) {
cache.set(key, fn.apply(this, arguments));
}

return cache.get(key);
};
};

module.exports = {
memoizeWith
};
33 changes: 18 additions & 15 deletions lib/util/names.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
'use strict';

const where = require('ramda/src/where');
const includes = require('ramda/src/includes');
const intersection = require('ramda/src/intersection');
const pipe = require('ramda/src/pipe');
const isEmpty = require('ramda/src/isEmpty');
const complement = require('ramda/src/complement');
const flip = require('ramda/src/flip');
const filter = require('ramda/src/filter');
const over = require('ramda/src/over');
const lensProp = require('ramda/src/lensProp');
const map = require('ramda/src/map');
const view = require('ramda/src/view');
const assoc = require('ramda/src/assoc');
const allPass = require('ramda/src/allPass');
const memoizeWith = require('ramda/src/memoizeWith');
const {
where,
includes,
intersection,
pipe,
isEmpty,
complement,
flip,
filter,
over,
lensProp,
map,
view,
assoc,
allPass
} = require('rambda');
const { memoizeWith } = require('./memoizeWith');

const INTERFACES = {
BDD: 'BDD',
Expand Down Expand Up @@ -130,3 +132,4 @@ module.exports = {
getTestCaseNames,
getSuiteNames
};

24 changes: 10 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
"dependencies": {
"eslint-utils": "^3.0.0",
"ramda": "^0.28.0"
"rambda": "^7.1.0"
},
"devDependencies": {
"chai": "^4.3.6",
Expand Down

0 comments on commit 4d19499

Please sign in to comment.