grpc-js-core: remove metadata's lodash dependency

This removes the only remaining use of lodash in Metadata and
improves performance a bit.
This commit is contained in:
cjihrig 2018-10-24 12:00:41 -04:00
parent 6a19cf5205
commit 2f679031fa
No known key found for this signature in database
GPG Key ID: 7434390BDBE9B9C5
1 changed files with 3 additions and 2 deletions

View File

@ -1,5 +1,4 @@
import * as http2 from 'http2';
import {forOwn} from 'lodash';
const LEGAL_KEY_REGEX = /^[0-9a-z_.-]+$/;
const LEGAL_NON_BINARY_VALUE_REGEX = /^[ -~]*$/;
@ -197,12 +196,14 @@ export class Metadata {
*/
static fromHttp2Headers(headers: http2.IncomingHttpHeaders): Metadata {
const result = new Metadata();
forOwn(headers, (values, key) => {
Object.keys(headers).forEach((key) => {
// Reserved headers (beginning with `:`) are not valid keys.
if (key.charAt(0) === ':') {
return;
}
const values = headers[key];
if (isBinaryKey(key)) {
if (Array.isArray(values)) {
values.forEach((value) => {