You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

358 lines
9.7 KiB

4 years ago
  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 map real names to their aliases. */
  254. exports.realToAlias = (function() {
  255. var hasOwnProperty = Object.prototype.hasOwnProperty,
  256. object = exports.aliasToReal,
  257. result = {};
  258. for (var key in object) {
  259. var value = object[key];
  260. if (hasOwnProperty.call(result, value)) {
  261. result[value].push(key);
  262. } else {
  263. result[value] = [key];
  264. }
  265. }
  266. return result;
  267. }());
  268. /** Used to map method names to other names. */
  269. exports.remap = {
  270. 'assignAll': 'assign',
  271. 'assignAllWith': 'assignWith',
  272. 'assignInAll': 'assignIn',
  273. 'assignInAllWith': 'assignInWith',
  274. 'curryN': 'curry',
  275. 'curryRightN': 'curryRight',
  276. 'defaultsAll': 'defaults',
  277. 'defaultsDeepAll': 'defaultsDeep',
  278. 'findFrom': 'find',
  279. 'findIndexFrom': 'findIndex',
  280. 'findLastFrom': 'findLast',
  281. 'findLastIndexFrom': 'findLastIndex',
  282. 'getOr': 'get',
  283. 'includesFrom': 'includes',
  284. 'indexOfFrom': 'indexOf',
  285. 'invokeArgs': 'invoke',
  286. 'invokeArgsMap': 'invokeMap',
  287. 'lastIndexOfFrom': 'lastIndexOf',
  288. 'mergeAll': 'merge',
  289. 'mergeAllWith': 'mergeWith',
  290. 'padChars': 'pad',
  291. 'padCharsEnd': 'padEnd',
  292. 'padCharsStart': 'padStart',
  293. 'propertyOf': 'get',
  294. 'rangeStep': 'range',
  295. 'rangeStepRight': 'rangeRight',
  296. 'restFrom': 'rest',
  297. 'spreadFrom': 'spread',
  298. 'trimChars': 'trim',
  299. 'trimCharsEnd': 'trimEnd',
  300. 'trimCharsStart': 'trimStart',
  301. 'zipAll': 'zip'
  302. };
  303. /** Used to track methods that skip fixing their arity. */
  304. exports.skipFixed = {
  305. 'castArray': true,
  306. 'flow': true,
  307. 'flowRight': true,
  308. 'iteratee': true,
  309. 'mixin': true,
  310. 'rearg': true,
  311. 'runInContext': true
  312. };
  313. /** Used to track methods that skip rearranging arguments. */
  314. exports.skipRearg = {
  315. 'add': true,
  316. 'assign': true,
  317. 'assignIn': true,
  318. 'bind': true,
  319. 'bindKey': true,
  320. 'concat': true,
  321. 'difference': true,
  322. 'divide': true,
  323. 'eq': true,
  324. 'gt': true,
  325. 'gte': true,
  326. 'isEqual': true,
  327. 'lt': true,
  328. 'lte': true,
  329. 'matchesProperty': true,
  330. 'merge': true,
  331. 'multiply': true,
  332. 'overArgs': true,
  333. 'partial': true,
  334. 'partialRight': true,
  335. 'propertyOf': true,
  336. 'random': true,
  337. 'range': true,
  338. 'rangeRight': true,
  339. 'subtract': true,
  340. 'zip': true,
  341. 'zipObject': true,
  342. 'zipObjectDeep': true
  343. };