Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bojand/grpc-create-metadata
Simple Node.js helper utility for creating gRPC metadata
https://github.com/bojand/grpc-create-metadata
grpc hacktoberfest
Last synced: 10 days ago
JSON representation
Simple Node.js helper utility for creating gRPC metadata
- Host: GitHub
- URL: https://github.com/bojand/grpc-create-metadata
- Owner: bojand
- License: apache-2.0
- Created: 2016-12-17T17:38:55.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2023-03-04T02:30:19.000Z (over 1 year ago)
- Last Synced: 2024-09-19T18:48:47.145Z (about 2 months ago)
- Topics: grpc, hacktoberfest
- Language: JavaScript
- Homepage: https://bojand.github.io/grpc-create-metadata
- Size: 956 KB
- Stars: 5
- Watchers: 4
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-grpc - grpc-create-metadata - Helper utility for creating gRPC `Metadata` (Language-Specific / Node.js)
README
### grpc-create-metadata
Simple Node.js helper utility for creating gRPC metadata**Example** *(Installation)*
```js
npm install grpc-create-metadata
```
**Example** *(Usage)*
```js
const grpc = require('grpc')
const create = require('grpc-create-metadata')
const meta = create({
name: 'Bob',
age: 20,
active: true
});
console.log(meta instanceof grpc.Metadata) // true
console.dir(meta.getMap()) // { foo: 'bar', age: '12', prop: 'true' }
```#### module.exports(metadata, options) ⇒
Metadata
⏏
Utility helper function to createMetadata
object from plain Javascript object
This strictly just callsMetadata.add
with the key / value map of objects.
If the value is aBuffer
it's passed as is.
If the value is aSting
it's passed as is.
Else if the value defined and not a string we simply calltoString()
.
Note thatMetadata
only accept string or buffer values.**Kind**: Exported function
**Returns**:Metadata
- An instance ofMetadata
, or `undefined` if input is not an object| Param | Type | Description |
| --- | --- | --- |
| metadata |Object
| Plain javascript object to tranform intoMetadata
If an instance ofMetadata
is passed in it is simply returned |
| options |Object
| options |
| options.addEmpty |Boolean
| whether to add empty strings. Default:false
|