Skip to content

Added a more API-like interface to pbjs and pbts #1140

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

cromefire
Copy link

For easier usage in things like gulp

cromefire added 3 commits November 17, 2018 19:59
Signed-off-by: cromefire <tim.l@nghorst.net>
Signed-off-by: cromefire <tim.l@nghorst.net>
Signed-off-by: cromefire <tim.l@nghorst.net>
@cromefire
Copy link
Author

cromefire commented Nov 17, 2018

You can now do:

import {pbjs} from "protobufjs/cli/pbjs";
import {promisify} from "util";
const pbjsAsync = pomisify(pbjs)

pbjs({encode: false}, {content: "syntax = \"proto3\";", name: "foo.proto"}, () => {
    // do something
})
// or
async function doSomething() {
    const js = await pbjsAsync({encode: false}, {content: "syntax = \"proto3\";", name: "foo.proto"})

    // do something
}

Same for pbts

Signed-off-by: cromefire <tim.l@nghorst.net>
@cromefire
Copy link
Author

Also the main functions are not affected by this, so there are no breaking changes

cromefire and others added 3 commits November 17, 2018 21:27
Signed-off-by: cromefire <tim.l@nghorst.net>
Signed-off-by: cromefire <tim.l@nghorst.net>
Signed-off-by: cromefire <tim.langhorst@outlook.de>
@cromefire
Copy link
Author

Is there anything blocking this from being merged @alexander-fenster ?

@alexander-fenster
Copy link
Contributor

@cromefire Just the lack of my free time - apologize for that! I'll go ahead and review/merge later this week. I do use pbjs from my code using the existing API (just the command line options as an array) so I appreciate these changes, just need some time to read through the code :)

@cromefire
Copy link
Author

The best thing is that you don't have to save the file, but you can retrieve it as Buffer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants