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