_mapping.js 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. /** Used to map aliases to their real names. */
  2. exports.aliasToReal = {
  3. // Lodash aliases.
  4. 'each': 'forEach',
  5. 'eachRight': 'forEachRight',
  6. 'entries': 'toPairs',
  7. 'entriesIn': 'toPairsIn',
  8. 'extend': 'assignIn',
  9. 'extendAll': 'assignInAll',
  10. 'extendAllWith': 'assignInAllWith',
  11. 'extendWith': 'assignInWith',
  12. 'first': 'head',
  13. // Methods that are curried variants of others.
  14. 'conforms': 'conformsTo',
  15. 'matches': 'isMatch',
  16. 'property': 'get',
  17. // Ramda aliases.
  18. '__': 'placeholder',
  19. 'F': 'stubFalse',
  20. 'T': 'stubTrue',
  21. 'all': 'every',
  22. 'allPass': 'overEvery',
  23. 'always': 'constant',
  24. 'any': 'some',
  25. 'anyPass': 'overSome',
  26. 'apply': 'spread',
  27. 'assoc': 'set',
  28. 'assocPath': 'set',
  29. 'complement': 'negate',
  30. 'compose': 'flowRight',
  31. 'contains': 'includes',
  32. 'dissoc': 'unset',
  33. 'dissocPath': 'unset',
  34. 'dropLast': 'dropRight',
  35. 'dropLastWhile': 'dropRightWhile',
  36. 'equals': 'isEqual',
  37. 'identical': 'eq',
  38. 'indexBy': 'keyBy',
  39. 'init': 'initial',
  40. 'invertObj': 'invert',
  41. 'juxt': 'over',
  42. 'omitAll': 'omit',
  43. 'nAry': 'ary',
  44. 'path': 'get',
  45. 'pathEq': 'matchesProperty',
  46. 'pathOr': 'getOr',
  47. 'paths': 'at',
  48. 'pickAll': 'pick',
  49. 'pipe': 'flow',
  50. 'pluck': 'map',
  51. 'prop': 'get',
  52. 'propEq': 'matchesProperty',
  53. 'propOr': 'getOr',
  54. 'props': 'at',
  55. 'symmetricDifference': 'xor',
  56. 'symmetricDifferenceBy': 'xorBy',
  57. 'symmetricDifferenceWith': 'xorWith',
  58. 'takeLast': 'takeRight',
  59. 'takeLastWhile': 'takeRightWhile',
  60. 'unapply': 'rest',
  61. 'unnest': 'flatten',
  62. 'useWith': 'overArgs',
  63. 'where': 'conformsTo',
  64. 'whereEq': 'isMatch',
  65. 'zipObj': 'zipObject'
  66. };
  67. /** Used to map ary to method names. */
  68. exports.aryMethod = {
  69. '1': [
  70. 'assignAll', 'assignInAll', 'attempt', 'castArray', 'ceil', 'create',
  71. 'curry', 'curryRight', 'defaultsAll', 'defaultsDeepAll', 'floor', 'flow',
  72. 'flowRight', 'fromPairs', 'invert', 'iteratee', 'memoize', 'method', 'mergeAll',
  73. 'methodOf', 'mixin', 'nthArg', 'over', 'overEvery', 'overSome','rest', 'reverse',
  74. 'round', 'runInContext', 'spread', 'template', 'trim', 'trimEnd', 'trimStart',
  75. 'uniqueId', 'words', 'zipAll'
  76. ],
  77. '2': [
  78. 'add', 'after', 'ary', 'assign', 'assignAllWith', 'assignIn', 'assignInAllWith',
  79. 'at', 'before', 'bind', 'bindAll', 'bindKey', 'chunk', 'cloneDeepWith',
  80. 'cloneWith', 'concat', 'conformsTo', 'countBy', 'curryN', 'curryRightN',
  81. 'debounce', 'defaults', 'defaultsDeep', 'defaultTo', 'delay', 'difference',
  82. 'divide', 'drop', 'dropRight', 'dropRightWhile', 'dropWhile', 'endsWith', 'eq',
  83. 'every', 'filter', 'find', 'findIndex', 'findKey', 'findLast', 'findLastIndex',
  84. 'findLastKey', 'flatMap', 'flatMapDeep', 'flattenDepth', 'forEach',
  85. 'forEachRight', 'forIn', 'forInRight', 'forOwn', 'forOwnRight', 'get',
  86. 'groupBy', 'gt', 'gte', 'has', 'hasIn', 'includes', 'indexOf', 'intersection',
  87. 'invertBy', 'invoke', 'invokeMap', 'isEqual', 'isMatch', 'join', 'keyBy',
  88. 'lastIndexOf', 'lt', 'lte', 'map', 'mapKeys', 'mapValues', 'matchesProperty',
  89. 'maxBy', 'meanBy', 'merge', 'mergeAllWith', 'minBy', 'multiply', 'nth', 'omit',
  90. 'omitBy', 'overArgs', 'pad', 'padEnd', 'padStart', 'parseInt', 'partial',
  91. 'partialRight', 'partition', 'pick', 'pickBy', 'propertyOf', 'pull', 'pullAll',
  92. 'pullAt', 'random', 'range', 'rangeRight', 'rearg', 'reject', 'remove',
  93. 'repeat', 'restFrom', 'result', 'sampleSize', 'some', 'sortBy', 'sortedIndex',
  94. 'sortedIndexOf', 'sortedLastIndex', 'sortedLastIndexOf', 'sortedUniqBy',
  95. 'split', 'spreadFrom', 'startsWith', 'subtract', 'sumBy', 'take', 'takeRight',
  96. 'takeRightWhile', 'takeWhile', 'tap', 'throttle', 'thru', 'times', 'trimChars',
  97. 'trimCharsEnd', 'trimCharsStart', 'truncate', 'union', 'uniqBy', 'uniqWith',
  98. 'unset', 'unzipWith', 'without', 'wrap', 'xor', 'zip', 'zipObject',
  99. 'zipObjectDeep'
  100. ],
  101. '3': [
  102. 'assignInWith', 'assignWith', 'clamp', 'differenceBy', 'differenceWith',
  103. 'findFrom', 'findIndexFrom', 'findLastFrom', 'findLastIndexFrom', 'getOr',
  104. 'includesFrom', 'indexOfFrom', 'inRange', 'intersectionBy', 'intersectionWith',
  105. 'invokeArgs', 'invokeArgsMap', 'isEqualWith', 'isMatchWith', 'flatMapDepth',
  106. 'lastIndexOfFrom', 'mergeWith', 'orderBy', 'padChars', 'padCharsEnd',
  107. 'padCharsStart', 'pullAllBy', 'pullAllWith', 'rangeStep', 'rangeStepRight',
  108. 'reduce', 'reduceRight', 'replace', 'set', 'slice', 'sortedIndexBy',
  109. 'sortedLastIndexBy', 'transform', 'unionBy', 'unionWith', 'update', 'xorBy',
  110. 'xorWith', 'zipWith'
  111. ],
  112. '4': [
  113. 'fill', 'setWith', 'updateWith'
  114. ]
  115. };
  116. /** Used to map ary to rearg configs. */
  117. exports.aryRearg = {
  118. '2': [1, 0],
  119. '3': [2, 0, 1],
  120. '4': [3, 2, 0, 1]
  121. };
  122. /** Used to map method names to their iteratee ary. */
  123. exports.iterateeAry = {
  124. 'dropRightWhile': 1,
  125. 'dropWhile': 1,
  126. 'every': 1,
  127. 'filter': 1,
  128. 'find': 1,
  129. 'findFrom': 1,
  130. 'findIndex': 1,
  131. 'findIndexFrom': 1,
  132. 'findKey': 1,
  133. 'findLast': 1,
  134. 'findLastFrom': 1,
  135. 'findLastIndex': 1,
  136. 'findLastIndexFrom': 1,
  137. 'findLastKey': 1,
  138. 'flatMap': 1,
  139. 'flatMapDeep': 1,
  140. 'flatMapDepth': 1,
  141. 'forEach': 1,
  142. 'forEachRight': 1,
  143. 'forIn': 1,
  144. 'forInRight': 1,
  145. 'forOwn': 1,
  146. 'forOwnRight': 1,
  147. 'map': 1,
  148. 'mapKeys': 1,
  149. 'mapValues': 1,
  150. 'partition': 1,
  151. 'reduce': 2,
  152. 'reduceRight': 2,
  153. 'reject': 1,
  154. 'remove': 1,
  155. 'some': 1,
  156. 'takeRightWhile': 1,
  157. 'takeWhile': 1,
  158. 'times': 1,
  159. 'transform': 2
  160. };
  161. /** Used to map method names to iteratee rearg configs. */
  162. exports.iterateeRearg = {
  163. 'mapKeys': [1],
  164. 'reduceRight': [1, 0]
  165. };
  166. /** Used to map method names to rearg configs. */
  167. exports.methodRearg = {
  168. 'assignInAllWith': [1, 0],
  169. 'assignInWith': [1, 2, 0],
  170. 'assignAllWith': [1, 0],
  171. 'assignWith': [1, 2, 0],
  172. 'differenceBy': [1, 2, 0],
  173. 'differenceWith': [1, 2, 0],
  174. 'getOr': [2, 1, 0],
  175. 'intersectionBy': [1, 2, 0],
  176. 'intersectionWith': [1, 2, 0],
  177. 'isEqualWith': [1, 2, 0],
  178. 'isMatchWith': [2, 1, 0],
  179. 'mergeAllWith': [1, 0],
  180. 'mergeWith': [1, 2, 0],
  181. 'padChars': [2, 1, 0],
  182. 'padCharsEnd': [2, 1, 0],
  183. 'padCharsStart': [2, 1, 0],
  184. 'pullAllBy': [2, 1, 0],
  185. 'pullAllWith': [2, 1, 0],
  186. 'rangeStep': [1, 2, 0],
  187. 'rangeStepRight': [1, 2, 0],
  188. 'setWith': [3, 1, 2, 0],
  189. 'sortedIndexBy': [2, 1, 0],
  190. 'sortedLastIndexBy': [2, 1, 0],
  191. 'unionBy': [1, 2, 0],
  192. 'unionWith': [1, 2, 0],
  193. 'updateWith': [3, 1, 2, 0],
  194. 'xorBy': [1, 2, 0],
  195. 'xorWith': [1, 2, 0],
  196. 'zipWith': [1, 2, 0]
  197. };
  198. /** Used to map method names to spread configs. */
  199. exports.methodSpread = {
  200. 'assignAll': { 'start': 0 },
  201. 'assignAllWith': { 'start': 0 },
  202. 'assignInAll': { 'start': 0 },
  203. 'assignInAllWith': { 'start': 0 },
  204. 'defaultsAll': { 'start': 0 },
  205. 'defaultsDeepAll': { 'start': 0 },
  206. 'invokeArgs': { 'start': 2 },
  207. 'invokeArgsMap': { 'start': 2 },
  208. 'mergeAll': { 'start': 0 },
  209. 'mergeAllWith': { 'start': 0 },
  210. 'partial': { 'start': 1 },
  211. 'partialRight': { 'start': 1 },
  212. 'without': { 'start': 1 },
  213. 'zipAll': { 'start': 0 }
  214. };
  215. /** Used to identify methods which mutate arrays or objects. */
  216. exports.mutate = {
  217. 'array': {
  218. 'fill': true,
  219. 'pull': true,
  220. 'pullAll': true,
  221. 'pullAllBy': true,
  222. 'pullAllWith': true,
  223. 'pullAt': true,
  224. 'remove': true,
  225. 'reverse': true
  226. },
  227. 'object': {
  228. 'assign': true,
  229. 'assignAll': true,
  230. 'assignAllWith': true,
  231. 'assignIn': true,
  232. 'assignInAll': true,
  233. 'assignInAllWith': true,
  234. 'assignInWith': true,
  235. 'assignWith': true,
  236. 'defaults': true,
  237. 'defaultsAll': true,
  238. 'defaultsDeep': true,
  239. 'defaultsDeepAll': true,
  240. 'merge': true,
  241. 'mergeAll': true,
  242. 'mergeAllWith': true,
  243. 'mergeWith': true,
  244. },
  245. 'set': {
  246. 'set': true,
  247. 'setWith': true,
  248. 'unset': true,
  249. 'update': true,
  250. 'updateWith': true
  251. }
  252. };
  253. /** Used to track methods with placeholder support */
  254. exports.placeholder = {
  255. 'bind': true,
  256. 'bindKey': true,
  257. 'curry': true,
  258. 'curryRight': true,
  259. 'partial': true,
  260. 'partialRight': true
  261. };
  262. /** Used to map real names to their aliases. */
  263. exports.realToAlias = (function() {
  264. var hasOwnProperty = Object.prototype.hasOwnProperty,
  265. object = exports.aliasToReal,
  266. result = {};
  267. for (var key in object) {
  268. var value = object[key];
  269. if (hasOwnProperty.call(result, value)) {
  270. result[value].push(key);
  271. } else {
  272. result[value] = [key];
  273. }
  274. }
  275. return result;
  276. }());
  277. /** Used to map method names to other names. */
  278. exports.remap = {
  279. 'assignAll': 'assign',
  280. 'assignAllWith': 'assignWith',
  281. 'assignInAll': 'assignIn',
  282. 'assignInAllWith': 'assignInWith',
  283. 'curryN': 'curry',
  284. 'curryRightN': 'curryRight',
  285. 'defaultsAll': 'defaults',
  286. 'defaultsDeepAll': 'defaultsDeep',
  287. 'findFrom': 'find',
  288. 'findIndexFrom': 'findIndex',
  289. 'findLastFrom': 'findLast',
  290. 'findLastIndexFrom': 'findLastIndex',
  291. 'getOr': 'get',
  292. 'includesFrom': 'includes',
  293. 'indexOfFrom': 'indexOf',
  294. 'invokeArgs': 'invoke',
  295. 'invokeArgsMap': 'invokeMap',
  296. 'lastIndexOfFrom': 'lastIndexOf',
  297. 'mergeAll': 'merge',
  298. 'mergeAllWith': 'mergeWith',
  299. 'padChars': 'pad',
  300. 'padCharsEnd': 'padEnd',
  301. 'padCharsStart': 'padStart',
  302. 'propertyOf': 'get',
  303. 'rangeStep': 'range',
  304. 'rangeStepRight': 'rangeRight',
  305. 'restFrom': 'rest',
  306. 'spreadFrom': 'spread',
  307. 'trimChars': 'trim',
  308. 'trimCharsEnd': 'trimEnd',
  309. 'trimCharsStart': 'trimStart',
  310. 'zipAll': 'zip'
  311. };
  312. /** Used to track methods that skip fixing their arity. */
  313. exports.skipFixed = {
  314. 'castArray': true,
  315. 'flow': true,
  316. 'flowRight': true,
  317. 'iteratee': true,
  318. 'mixin': true,
  319. 'rearg': true,
  320. 'runInContext': true
  321. };
  322. /** Used to track methods that skip rearranging arguments. */
  323. exports.skipRearg = {
  324. 'add': true,
  325. 'assign': true,
  326. 'assignIn': true,
  327. 'bind': true,
  328. 'bindKey': true,
  329. 'concat': true,
  330. 'difference': true,
  331. 'divide': true,
  332. 'eq': true,
  333. 'gt': true,
  334. 'gte': true,
  335. 'isEqual': true,
  336. 'lt': true,
  337. 'lte': true,
  338. 'matchesProperty': true,
  339. 'merge': true,
  340. 'multiply': true,
  341. 'overArgs': true,
  342. 'partial': true,
  343. 'partialRight': true,
  344. 'propertyOf': true,
  345. 'random': true,
  346. 'range': true,
  347. 'rangeRight': true,
  348. 'subtract': true,
  349. 'zip': true,
  350. 'zipObject': true,
  351. 'zipObjectDeep': true
  352. };