|
| 1 | +# Comparison with other libraries |
| 2 | + |
| 3 | +### [Ramda](http://ramdajs.com/) |
| 4 | +Ramda was a huge inspiration for Tinkoff Utils! it has a lot of similarities with naming style, uses same functional programming approach and many other things, with luck of some less popular design ideas like `__` prefixes, `lens*` functions and etc. |
| 5 | + |
| 6 | +| Ramda | Utils | |
| 7 | +| --- | ------ | |
| 8 | +| R.all | /array/all | |
| 9 | +| R.allPass | /function/allPass | |
| 10 | +| R.always | /function/always | |
| 11 | +| R.any | /array/any | |
| 12 | +| R.anyPass | /function/anyPass | |
| 13 | +| R.both | /function/both | |
| 14 | +| R.clone | /clone | |
| 15 | +| R.complement | /function/complement | |
| 16 | +| R.compose | /function/compose | |
| 17 | +| R.composeP | /function/composeP | |
| 18 | +| R.concat | /array/concat | |
| 19 | +| R.cond | /function/cond | |
| 20 | +| R.contains | /array/includes | |
| 21 | +| R.curry | /function/curry (`__` not supported) | |
| 22 | +| R.curryN | /function/curryN | |
| 23 | +| R.defaultTo | /defaultTo | |
| 24 | +| R.difference | /array/difference | |
| 25 | +| R.dropWhile | /array/dropWhile | |
| 26 | +| R.either | /function/either | |
| 27 | +| R.empty | /is/empty | |
| 28 | +| R.equals | /is/equal | |
| 29 | +| R.endsWith | /string/endsWith | !only for strings | |
| 30 | +| R.F | /function/F | |
| 31 | +| R.filter | /array/filter | for arrays, /object/filter | for objects | |
| 32 | +| R.find | /array/find | |
| 33 | +| R.findIndex | /array/findIndex | |
| 34 | +| R.flatten | /array/flatten | |
| 35 | +| R.flip | /function/flip | |
| 36 | +| R.forEach | /array/each | |
| 37 | +| R.forEachObjIndexed | /object/each | |
| 38 | +| R.fromPairs | /object/fromPairs | |
| 39 | +| R.groupBy | /object/groupBy | for objects | |
| 40 | +| R.has | /object/has | |
| 41 | +| R.head | /array/head | |
| 42 | +| R.identity | /function/identity | |
| 43 | +| R.ifElse | /function/ifElse | |
| 44 | +| R.intersection | /array/intersection | |
| 45 | +| R.is | /is/* | |
| 46 | +| R.isEmpty | /is/empty | |
| 47 | +| R.isNil | /is/nil | |
| 48 | +| R.join | /array/join | |
| 49 | +| R.keys | /object/keys | |
| 50 | +| R.last | /array/last | |
| 51 | +| R.length | /array/length | |
| 52 | +| R.map | /array/map | for arrays, /object/map | for objects | |
| 53 | +| R.mapObjIndexed | /object/map | |
| 54 | +| R.maxBy | /array/maxBy | |
| 55 | +| R.merge | /object/merge (accepts n arguments, bot not less than 2) | |
| 56 | +| R.mergeAll | /object/merge (accepts an argument list not an array of arguments) | |
| 57 | +| R.mergeDeepLeft | /object/mergeDeep | |
| 58 | +| R.mergeWith | /object/mergeWith | |
| 59 | +| R.negate | /negate | |
| 60 | +| R.not | /not | |
| 61 | +| R.nth | /array/nth | |
| 62 | +| R.objOf | /object/objOf | |
| 63 | +| R.omit | /object/omit | |
| 64 | +| R.once | /function/once | |
| 65 | +| R.path | /object/path | |
| 66 | +| R.pathEq | /object/pathEq | |
| 67 | +| R.pathOr | /object/pathOr **Note** order of arguments is different (Utils always accepts path as first argument) | |
| 68 | +| R.pathSatisfies | /object/pathApply | |
| 69 | +| R.pick | /object/pick | |
| 70 | +| R.pickBy | /object/pickBy | |
| 71 | +| R.pipe | /object/compose (prefer to use compose) | |
| 72 | +| R.prop | /object/prop | |
| 73 | +| R.propEq | /object/propEq | |
| 74 | +| R.propOr | /object/propOr **Note** order of arguments is different (Utils always accepts prop name as first argument) | |
| 75 | +| R.propApply | /object/propApply | |
| 76 | +| R.range | /array/range | |
| 77 | +| R.reduce | /array/reduce, /object/reduce | |
| 78 | +| R.reduceWhile | /array/reduceWhile | |
| 79 | +| R.reject | /array/reject | |
| 80 | +| R.repeat | /array/repeat | |
| 81 | +| R.replace | /string/replace | |
| 82 | +| R.sort | /array/sort | |
| 83 | +| R.sortBy | /array/sortBy | |
| 84 | +| R.split | /string/split | |
| 85 | +| R.startsWith | /string/startsWith | |
| 86 | +| R.sum | /array/sum | |
| 87 | +| R.tail | /array/tail | |
| 88 | +| R.take | /array/take | |
| 89 | +| R.tap | /function/tap | |
| 90 | +| R.test | /string/test | |
| 91 | +| R.toLower | /string/toLower | |
| 92 | +| R.toPairs | /object/toPairs | |
| 93 | +| R.toString | /string/toString | |
| 94 | +| R.toUpper | /string/toUpper | |
| 95 | +| R.trim | /string/trim | |
| 96 | +| R.type | /type | |
| 97 | +| R.uniq | /array/uniq | |
| 98 | +| R.uniqBy | /array/uniqBy | |
| 99 | +| R.values | /object/values | |
| 100 | +| R.when | /function/when | |
| 101 | +| R.where | /object/where | |
| 102 | +| R.zip | /array/zip | |
| 103 | +| R.zipWith | /array/zipWith | |
| 104 | +| R.comparator | /function/comparator | |
| 105 | +| R.indexOf | /array/indexOf | |
| 106 | +| R.adjust | /array/adjust | |
| 107 | +| R.append | /array/append | |
| 108 | +| R.slice | /array/slice | |
| 109 | +| R.drop | /array/drop | |
| 110 | +| R.dropLast | /array/dropLast | |
| 111 | +| R.remove | /array/remove | |
| 112 | +| R.update | /array/update | |
| 113 | +| R.without | /array/without | |
| 114 | + |
| 115 | + |
| 116 | +### [Lodash](https://lodash.com/) |
| 117 | +Be careful when migrating from lodash to Utils: |
| 118 | +1. Check function signature, since Utils uses data as the last argument in contrast with lodash |
| 119 | +1. Singular lodash methods can accept various argument types when Utils functions are focused and cohesive |
| 120 | +1. Some Lodash functions mutate passed arguments |
| 121 | + |
| 122 | +| Lodash | Utils | |
| 123 | +| --- | ------ | |
| 124 | +| _.compact | /array/filter + /function/identity `filter(identity)` | |
| 125 | +| _.concat | /array/concat | |
| 126 | +| _.difference | /array/difference | |
| 127 | +| _.dropWhile | /array/dropWhile | |
| 128 | +| _.findIndex | /array/findIndex | |
| 129 | +| _.first | /array/head | |
| 130 | +| _.flattenDeep | /array/flatten | |
| 131 | +| _.fromPairs | /object/fromPairs | |
| 132 | +| _.intersection | /array/intersection | |
| 133 | +| _.join | /array/join | |
| 134 | +| _.last | /array/last | |
| 135 | +| _.nth | /array/nth | |
| 136 | +| _.pull* | pull* mutates array, if there no need in it, then /array/filter + /function/* | |
| 137 | +| _.remove | mutates date, otherwise /array/filter + /function/* | |
| 138 | +| _.reverse | /array/reverse | |
| 139 | +| _.take | /array/take | |
| 140 | +| _.uniq | /array/uniq | |
| 141 | +| _.uniqBy | /array/uniqBy | |
| 142 | +| _.without | /array/filter + /function/* | |
| 143 | +| _.zip | /array/zip | |
| 144 | +| _.zipWith | /array/zipWith | |
| 145 | +| _.each | /array/each, /object/each | |
| 146 | +| _.forEach | /array/each, /object/each | |
| 147 | +| _.every | /array/all | |
| 148 | +| _.find | /array/find | |
| 149 | +| _.groupBy | /object/groupBy | |
| 150 | +| _.includes | /array/includes | |
| 151 | +| _.keyBy | /object/keyBy | |
| 152 | +| _.map | /array/map, /object/map | |
| 153 | +| _.partition | /array/partition | |
| 154 | +| _.reduce | /array/reduce, /object/reduce | |
| 155 | +| _.reject | /array/filter + /not `filter(not)` | |
| 156 | +| _.shuffle | /array/shuffle | |
| 157 | +| _.some | /array/any | |
| 158 | +| _.sortBy | /array/sortBy | |
| 159 | +| _.curry | /function/curry | |
| 160 | +| _.debounce | /function/debounce | |
| 161 | +| _.flip | /function/flip | |
| 162 | +| _.negate | /function/complement | |
| 163 | +| _.once | /function/once | |
| 164 | +| _.thtottle | /function/throttle | |
| 165 | +| _.castArray | /array/toArray | |
| 166 | +| _.clone | Object.assign({}, x) | |
| 167 | +| _.cloneDeep | /clone | |
| 168 | +| _.is* | /is/* a small part | |
| 169 | +| _.assign | Object.assign | |
| 170 | +| _.at | /array/map + /object/path | |
| 171 | +| _.defaults | /object/merge | |
| 172 | +| _.defaultsDeep | /object/mergeDeep | |
| 173 | +| _.entries | /object/toPairs | |
| 174 | +| _.forOwn | /object/each | |
| 175 | +| _.get | /object/path, /object/pathOr `get(obj, 'a.b[0].c', 'dflt') => pathOr(['a', 'b', 0, 'c'], 'dflt', obj)` | |
| 176 | +| _.has | /object/has | |
| 177 | +| _.keys | /object/keys | |
| 178 | +| _.mapKeys | /object/reduce + specific function | |
| 179 | +| _.mapValues | /object/map | |
| 180 | +| _.merge | /object/mergeDeep | |
| 181 | +| _.omit | /object/omit | |
| 182 | +| _.pick | /object/pick | |
| 183 | +| _.pickBy | /object/pickBy | |
| 184 | +| _.result | /object/pathApply + /function/applyOrReturn `result(obj, 'a.b', 'dflt') => pathApply(['a', 'b'], applyOrReturn, obj) || 'dflt'` | |
| 185 | +| _.set | /object/pathSet `set(obj, 'a.b[0]', 'val') => newObj = pathSet(['a', 'b', 0], 'val', obj)` | |
| 186 | +| _.toPairs | /object/toPairs | |
| 187 | +| _.values | /object/values | |
| 188 | +| _.tap | /function/tap | |
| 189 | +| _.capitalize | /string/capitalize | |
| 190 | +| _.endsWith | /string/endsWith | |
| 191 | +| _.escape | /string/escape | |
| 192 | +| _.escapeRegExp | /string/escapeRegExp | |
| 193 | +| _.repeat | /array/repeat + /array/join | |
| 194 | +| _.replace | /string/replace | |
| 195 | +| _.split | /string/split | |
| 196 | +| _.toLower | /string/toLower | |
| 197 | +| _.toUpper | /string/toUpper | |
| 198 | +| _.trim | /string/trim | |
| 199 | +| _.trimStart | /string/trimLeft | |
| 200 | +| _.unescape | /string/unescape | |
| 201 | +| _.cond | /function/cond | |
| 202 | +| _.conforms | /object/where | |
| 203 | +| _.constant | /function/always | |
| 204 | +| _.defaultTo | /defaultTo | |
| 205 | +| _.identity | /function/identity | |
| 206 | +| _.noop | /function/noop | |
| 207 | +| _.range | /array/range | |
| 208 | +| _.stub* | /function/always | |
| 209 | +| _.uniqueId | /uniqueId | |
0 commit comments