mirror of
https://github.com/shaka-project/shaka-player.git
synced 2026-06-14 15:56:38 +03:00
64896d70b0
This reflects changes in Google's policy on JavaScript license headers, which should be smaller to avoid increasing the size of the binary unnecessarily. This also updates the company name from "Google, Inc" to "Google LLC". Change-Id: I3f8b9ed3700b6351f43173d50c94d35c333e82b4
42 lines
729 B
JavaScript
42 lines
729 B
JavaScript
/** @license
|
|
* Copyright 2016 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
goog.provide('shaka.util.MapUtils');
|
|
|
|
|
|
/**
|
|
* @summary A set of map/object utility functions.
|
|
*/
|
|
shaka.util.MapUtils = class {
|
|
/**
|
|
* @param {!Object.<KEY, VALUE>} object
|
|
* @return {!Map.<KEY, VALUE>}
|
|
* @template KEY,VALUE
|
|
*/
|
|
static asMap(object) {
|
|
const map = new Map();
|
|
for (const key of Object.keys(object)) {
|
|
map.set(key, object[key]);
|
|
}
|
|
|
|
return map;
|
|
}
|
|
|
|
|
|
/**
|
|
* @param {!Map.<KEY, VALUE>} map
|
|
* @return {!Object.<KEY, VALUE>}
|
|
* @template KEY,VALUE
|
|
*/
|
|
static asObject(map) {
|
|
const obj = {};
|
|
map.forEach((value, key) => {
|
|
obj[key] = value;
|
|
});
|
|
|
|
return obj;
|
|
}
|
|
};
|