Normalize the manifest into the expected format

@param {Object} manifest
@param {Function} fn
485688
function normalizeManifest(manifest, fn) {
  var obj = {};
  manifest.forEach(function(file) {
    if (!file) return;
    obj[file.name] = {
      mtime: file.mtime,
      mode: file.mode,
      size: file.size,
      hash: file.hash,
      link: file.link
    };
  });
  fn(null, obj);
}
255266
function normalizeExtensions(list) {
  if (!Array.isArray(list)) list = [ list ];

  return list.map(function (ext) {
    return ext[0] === "." ? ext : "." + ext;
  });
}
304329
function transformManifest(buffer) {
  const content = JSON.parse(buffer.toString())
  if (environment === 'production') {
    const locales = fs.readdirSync(paths.appLocales())
    content.locales = {}
    content.langs = []
    for (const idx in locales) {
      const localContent = require(path.join(paths.appLocales(), locales[idx]))
      const lang = locales[idx].match(/^([^.]*).json$/)[1]
      content.locales[lang] = localContent.manifest ? localContent.manifest : {}
      content.langs.push(lang)
    }
  }
  // icon will be stored in public folder for app with public page
  if (
    hasPublic &&
    content.icon &&
    !content.icon.match(new RegExp(`${publicFolderName}/`))
  ) {
    content.icon = path.join(publicFolderName, content.icon)
  }
  return JSON.stringify(content, null, '  ')
}
1041133
function normalizeClauses (conf) {
  const output = {};
  const validPath = Object.keys(conf).filter(path => Array.isArray(conf[path]));
  validPath.forEach(path => {
    const validClauses = conf[path].filter(c => c.value !== '');
    if (validClauses.length) {
      output[path] = validClauses;
    }
  });
  return output;
}
1269868
function format(f) {
    "use strict";
    var i = 1;
    var args = arguments;
    var len = args.length;
    var str = String(f).replace(/%[sdj%]/g, function _replace(x) {
        if (i >= len) return x;
        switch (x) {
        case '%s':
            return String(args[i++]);
        case '%d':
            return Number(args[i++]);
        case '%j':
            return JSON.stringify(args[i++]);
        case '%%':
            return '%';
        default:
            return x;
        }
    });
    for (var x = args[i]; i < len; x = args[++i]) {
        if (x === null || typeof x !== 'object') {
            str += ' ' + x;
        } else {
            str += '[obj]';
        }
    }
    return str;
}
240546
function normalizePair(pair, resolver, dirname) {
  var options = void 0;
  var value = pair;
  if (Array.isArray(pair)) {
    if (pair.length > 2) {
      throw new Error("Unexpected extra options " + (0, _stringify2.default)(pair.slice(2)) + ".");
    }

    var _pair = (0, _slicedToArray3.default)(pair, 2);

    value = _pair[0];
    options = _pair[1];
  }

  var filepath = null;
  if (typeof value === "string") {
    var _resolver = resolver(value, dirname);

    filepath = _resolver.filepath;
    value = _resolver.value;
  }

  if (!value) {
    throw new Error("Unexpected falsy value: " + String(value));
  }

  if ((typeof value === "undefined" ? "undefined" : (0, _typeof3.default)(value)) === "object" && value.__esModule) {
    if (value.default) {
      value = value.default;
    } else {
      throw new Error("Must export a default export when using ES6 modules.");
    }
  }

  if ((typeof value === "undefined" ? "undefined" : (0, _typeof3.default)(value)) !== "object" && typeof value !== "function") {
    throw new Error("Unsupported format: " + (typeof value === "undefined" ? "undefined" : (0, _typeof3.default)(value)) + ". Expected an object or a function.");
  }

  if (options != null && (typeof options === "undefined" ? "undefined" : (0, _typeof3.default)(options)) !== "object") {
    throw new Error("Plugin/Preset options must be an object, null, or undefined");
  }

  return { filepath: filepath, value: value, options: options };
}
731725
public function writeManifest($manifest)
    {
        $content = "<?php\n\nreturn " .var_export($manifest, true) .";\n";

        $this->files->put($this->manifestPath, $content);

        return array_merge(array('when' => array()), $manifest);
    }
160530
function copyNormalize() {
  var stream = gulp.src(src.normalize)
    .pipe(plugins.rename(function(path) {
      path.basename = '_' + path.basename,
      path.extname = '.scss'
    }))
    .pipe(gulp.dest(paths.sourcefiles + '/sass/vendors/normalize'));
}
1200557
function normalizeFormat(format) {
  const clone = Object.assign({}, format);
  clone.prefix = normalizePrefixSuffix(format.prefix);
  clone.suffix = normalizePrefixSuffix(format.suffix);
  return clone;
}
222199
function watcher(manifest)
{
  return function(file)
  {
    return function(event)
    {
      if (event == 'change')
      {
        fs.stat(file, function(err, stat)
        {
          if (err) return; // do nothing at this point

          var mtime = stat.mtime.getTime();

          if (cache[manifest].version < mtime) cache[manifest].version = mtime;
        });
      }

      // TODO: add support for rename, maybe
    };
  }
}
389439
function (manifest) {
  return {
    startPage: manifest.startPage,
    srcDirectory: manifest.srcDirectory,
    name: manifest.name,
    exposeExperimentalAPIs: true
  }
}
1329544
public static void validateManifest(String manifestName, Manifest manifest)
    throws ConfigException
  {
    Attributes attr = manifest.getMainAttributes();
    if (attr == null)
      return;

    String extList = attr.getValue("Extension-List");
    if (extList == null)
      return;

    Pattern pattern = Pattern.compile("[, \t]+");
    String []split = pattern.split(extList);

    for (int i = 0; i < split.length; i++) {
      String ext = split[i];

      String name = attr.getValue(ext + "-Extension-Name");
      if (name == null)
        continue;

      Package pkg = Package.getPackage(name);

      if (pkg == null) {
        log.warning(L.l("package {0} is missing.  {1} requires package {0}.",
                        name, manifestName));
        continue;
      }

      String version = attr.getValue(ext + "-Specification-Version");

      if (version == null)
        continue;

      if (pkg.getSpecificationVersion() == null ||
          pkg.getSpecificationVersion().equals("")) {
        log.warning(L.l("installed {0} is not compatible with version `{1}'.  {2} requires version {1}.",
                     name, version, manifestName));
      }
      else if (! pkg.isCompatibleWith(version)) {
        log.warning(L.l("installed {0} is not compatible with version `{1}'.  {2} requires version {1}.",
                     name, version, manifestName));
      }
    }
  }
726607
function format(fn) {
  return function(chunk) {
    if (arguments.length > 1) {
      chunk = util.format.apply(null, arguments);
    }
    if (chunk === undefined) {
      chunk = '';
    }
    fn.call(this, chunk);
  };
}
201646
function findMissing(manifest, request, host, fn) {
  request
    .post(host + '/manifest/diff')
    .send({manifest: JSON.stringify(manifest)})
    .end(function(err, res) {
      if (err) return fn(err);
      if (res.error) return fn(res.error);
      fn(null, res.body);
    });
}
524579
function (err, manifest) {
            if (err) {
                // Error generating SRI hashes
                grunt.log.error("Error loading resource: " + err);
                return done(false);
            }

            return saveJson(
                options,
                manifest,
                writeLog(fileCount, done)
            );
        }
592760
function _normalizeArguments(obj) {
    var args = arguments;

    if (!obj || Utils.isFunction(obj)) {
      args = Array.prototype.slice.call(arguments, 0);
      args.unshift({});
    }

    return args;
  }
1222142
function normalize(loader, mods) {
	var modNames = (mods && !Array.isArray(mods)) ? [mods] : mods;

	return (modNames || []).map(function(moduleName) {
		return !_.isString(moduleName) ?
			Promise.resolve(moduleName) :
			loader.normalize(moduleName);
	});
}