MCPcopy
hub / github.com/vercel/hyper / flatten

Method flatten

bin/yarn-standalone.js:7077–7192  ·  view source on GitHub ↗

* TODO

(patterns)

Source from the content-addressed store, hash-verified

7075 */
7076
7077 flatten(patterns) {
7078 var _this9 = this;
7079
7080 return (0, (_asyncToGenerator2 || _load_asyncToGenerator()).default)(function* () {
7081 if (!_this9.flags.flat) {
7082 return patterns;
7083 }
7084
7085 const flattenedPatterns = [];
7086
7087 for (var _iterator12 = _this9.resolver.getAllDependencyNamesByLevelOrder(patterns), _isArray12 = Array.isArray(_iterator12), _i12 = 0, _iterator12 = _isArray12 ? _iterator12 : _iterator12[Symbol.iterator]();;) {
7088 var _ref25;
7089
7090 if (_isArray12) {
7091 if (_i12 >= _iterator12.length) break;
7092 _ref25 = _iterator12[_i12++];
7093 } else {
7094 _i12 = _iterator12.next();
7095 if (_i12.done) break;
7096 _ref25 = _i12.value;
7097 }
7098
7099 const name = _ref25;
7100
7101 const infos = _this9.resolver.getAllInfoForPackageName(name).filter(function (manifest) {
7102 const ref = manifest._reference;
7103 invariant(ref, 'expected package reference');
7104 return !ref.ignore;
7105 });
7106
7107 if (infos.length === 0) {
7108 continue;
7109 }
7110
7111 if (infos.length === 1) {
7112 // single version of this package
7113 // take out a single pattern as multiple patterns may have resolved to this package
7114 flattenedPatterns.push(_this9.resolver.patternsByPackage[name][0]);
7115 continue;
7116 }
7117
7118 const options = infos.map(function (info) {
7119 const ref = info._reference;
7120 invariant(ref, 'expected reference');
7121 return {
7122 // TODO `and is required by {PARENT}`,
7123 name: _this9.reporter.lang('manualVersionResolutionOption', ref.patterns.join(', '), info.version),
7124
7125 value: info.version
7126 };
7127 });
7128 const versions = infos.map(function (info) {
7129 return info.version;
7130 });
7131 let version;
7132
7133 const resolutionVersion = _this9.resolutions[name];
7134 if (resolutionVersion && versions.indexOf(resolutionVersion) >= 0) {

Callers 6

getFlattenedDepsMethod · 0.80
initMethod · 0.80
hydrateMethod · 0.80
paginateMethod · 0.80
yarn-standalone.jsFile · 0.80
forceLineReturnMethod · 0.80

Calls 14

_load_asyncToGeneratorFunction · 0.85
invariantFunction · 0.85
filterMethod · 0.80
indexOfMethod · 0.80
getRootManifestsMethod · 0.80
getResolvedPatternMethod · 0.80
saveRootManifestsMethod · 0.80
nextMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected